1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ostrovityanka [42]
3 years ago
7

Assignment 8: Calendar Create a calendar program that allows the user to enter a day, month and year in three separate variables

. Then ask the user to select froma menu of choices using this formatting: Please enter a date Day: Month: Year: Menu: 1) Calculate the number of days in the given month. 2) Calculate the number of days left in the given year t must include the following functions: ter and returns a 1 if a year is a leap year et and O if it is not. This information will only be used by other functions umber of days: This subprogram will accept the date as parameters and return how many days are in the given monthe. the date as parameters and then calculate the number of days left in the year. This should not include the date the user entered in the count
this is what I have so far:
def number_of_days(m):
if (m == 1,3,5,7,8,9,11):
woh = 31
elif (m == 2):
woh = 28
elif (m == 4,6,10,12):
woh = 30
print (woh)
print (29)


def days_left(d,m,y):
if (d > 0):
print ('135')
def leap_year(d,m,y):
if (d > 0):
print ('1')

day = int(input('Enter the day.'))
month = int(input('Enter the month.'))
year = int(input('Enter the year.'))
menu = int(input('Day in month or left in year? (1,2)'))
if (menu == 1):
monthdays = number_of_days(month)
print (monthdays)
elif (menu == 2):
dayleft = days_left(day,month,year)
print (dayleft)
Computers and Technology
1 answer:
Katen [24]3 years ago
5 0

Answer:

Following are the correct code to this question:

def leap_year(year):#defining a method to check if year is leap year

   if ((year%4==0) and (year%100!=0)) or (year%400==0):#defining condition to check value

       return 1 #return value 1

   return 0 #return 0

def number_of_days(month,year):#defining method number_of_days to calculate year or month is leap year are not  

   if month==2: #defining if block to calculate leap year value  

       if leap_year(year):#using if block to call leap_year month  

           return 29#return value 29

   return 28 #return value 28

   if month in days_31: #defining if block to calculate day

       return 31 #return value 31

   return 30#return value 30

def days_left(day,month,year):#defining method days_Left  

   daysLeft = number_of_days(month,year)-day#defining variable daysLeft which calls number_of_days method  

   month += 1 #increment month variable value by 1

   while month<=12:#defining while loop to Calculate left days

       daysLeft += number_of_days(month,year) #using daysLeft variable to hold number_of_days value

       month += 1 #increment value of month variable by 1

   return daysLeft #return daysLeft value

days_31 = [1,3,5,7,8,10,12] #defining days_31 dictionary and assign value

days_30 = [4,6,9,11] # defining days_30 dictionary and assign value

print('Please enter a date') #print message

day = int(input('Day: ')) #defining day variable and input value  

month = int(input('Month: '))#defining Month variable and input value

year = int(input('Year: '))#defining Year variable and input value

print('Menu:')#print message

print('press 1 to Calculate the number of days in the given month.')#print message

print('press 2 to Calculate the number of days left in the given year.')#print message

choice = int(input())#defining choice variable and input the value

if choice==1: #defining if block to check choice

   print(number_of_days(month,year)) #call method number_of_days and print value

elif choice==2: #defining elif block to check value

   print(days_left(day,month,year))#call days_left and print value

Output:

Please enter a date

Day: 2

Month: 6

Year: 2018

Menu:

press 1 to Calculate the number of days in the given month.

press 2 to Calculate the number of days left in the given year.

2

194

Explanation:

In the given python code, three methods "leap_year, number_of_days, and days_left " is declared, in which we calculate all the values that can be described as follows:

  • In the leap_year method, it accepts the year variable, which calculates the year is the leap year and returns its value that is 1.
  • In the next method number_of_days, it is declared that accepts the "year and month"  variable as the parameter and calculates and returns its value.
  • In the last days_left method, it calculates the left days and returns its value, and outside the method, two dictionary variable days_31 and days_30 is declared, which assign a value and used use three input variable day, month, and year variable to accepts user input value.
  • In the next step, a choice variable is declared, that input values and calls and print its value accordingly.
You might be interested in
when an overridden method is called from within a subclass, it will always refer to the version of that method defined by the (a
bija089 [108]

Option b is correct. When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the subclass.

Subclasses are classes that can be created by adding new functionality to a parent class, such as new object variables or new methods. In terms of automata theory, a subclass expands the state transition table with new rows and states. However, by overriding (changing) existing functionality, the majority of OO programming languages also enable us to derive subclasses from parent classes. When implementing a class, all that is required to be specified is the new or updated functionality thanks to inheritance mechanisms between parent class and subclass.

Lines connected through a circle connect the subclasses HourlyEmployee and SalaryEmployee to the superclass Employee. The circled letter "d" stands for disjointness, which demands that the specification's subclasses be distinct. As a result, an entity can belong to only one of the specification's subclasses. An individual employee can only be paid either hourly wages or a salary; they cannot be paid both. The open sides of the inheritance (arch) symbols face the superclass.

To know more about subclass click on the link:

brainly.com/question/13790787

#SPJ4

6 0
1 year ago
A brief communication used in businesses is called a _____.
Bad White [126]

Answer:

C. Memo

Explanation:

Hope this helps :)

6 0
3 years ago
Read 2 more answers
List any four e-commerce website​
Ipatiy [6.2K]

Answer:

Amazon. Founded in the US in 1994, Amazon started as an online bookstore that later diversified to products including media, electronics, apparel, furniture, food, toys, and jewelry.

eBay. ...

Walmart. ...

Etsy. ...

Home Depot. ...

Target. ...

Best Buy. ...

Wayfair.

5 0
3 years ago
Read 2 more answers
What is the name and purpose of the star next to a slide in a PowerPoint presentation?
Finger [1]
If you observe closely, you may see that these stars are shown only against some slides and not all of them.

The stars are just an indication that the particular slide has custom animation. That was you can quickly see at a glance if a slide has content that is animated.

The same star symbol is also shown when the slide itself has any slide transition set.
7 0
3 years ago
Gaven's instructor told him to include a personal statement in his work portfolio. Why did his instructor recommend including a
algol [13]
The recommendation of the instructor for Gaven to include a personal statement in his work portfolio will allow him to identify his career goals. If he is unable to show this to his work portfolio then he may simply state it in the personal statement. Thus, the answer to this item is letter A. 
3 0
3 years ago
Other questions:
  • How can you recognize an unsecured wireless network?
    9·1 answer
  • What is the last step in planning your budget
    11·1 answer
  • Write a function addOne that adds 1 to its integer referenceparameter. The function returns nothing.
    11·1 answer
  • 60 POINTS!
    13·1 answer
  • Assign jsonData with the parsed value of the stringData variable. Then, assign 29 to the points property in jsonData and assign
    13·1 answer
  • Many major employers routinely monitor the performance of their employees through the computers and telephones they use. Employe
    12·1 answer
  • What are the advantages to using a linked implementation as opposed to an array implementation?
    8·1 answer
  • What is the HCF of smallest prime number and the smallest composite number?​
    12·1 answer
  • Using Microsoft Word, write a 250-word essay on the fading of home telephone use with the advent of recent technology, and share
    14·1 answer
  • How would a barcode reader be used in a healthcare industry?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!