3.3 Code Practice: Question 1
(Phython coding btw)
Question:

Test if a date is a payday based on the day of the month (15th or the 30th).

Sample run:

Enter today's day numerically: 17
Sorry, not a payday.
Enter today's day numerically: 30
It's payday!​

Respuesta :

tanoli

Answer:

Explanation:

Python Code:

date = int(input("Enter today's day numerically: "))

if date == 15 :

   print("it's Payday")

elif date == 30 :

   print("it's Payday")

else:

   print("Sorry, not a PayDay");

Code Explanation:

First get date integer value from input by using input() method in python.

After that check is entered date equals to 15 or 30 then print it's Payday and at the end if user enter other then 15 and 30 the print Sorry, not a PayDay in else clause.

Code Ouput

Enter today's day numerically: 15

it's Payday

Enter today's day numerically: 17

Sorry, not a PayDay

This program illustrates the use of if-conditional statements.

The program in Python, where comments are used to explain each line is as follows:

#This gets input for today's day

day = int(input("Enter today's day numerically: "))

#This checks if input is 15 or 30

if day == 15 or day == 30:

   #If yes, it prints "pay day"

   print("It's payday!")

#If otherwise

else:

   #It prints "not a pay day"

   print("Sorry, not a payday.")

See attachment for sample run

Read more about similar programs at:

https://brainly.com/question/18229084

Ver imagen MrRoyal
ACCESS MORE
EDU ACCESS