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
djyliett [7]
3 years ago
9

My code get an input of 1900 and it should output not a leap year but it fails first line of code. It should output not a Leap a

ny number with 1500 not divisble by 4 with/out a remainder should output (not a leap year. )
input_year = int(input())

if input_year % 4 == 0: #fails on this step, 1900 should be false
print(input_year, "- is Leap Year")

elif input_year % 100 == 0:
print(input_year, "- leap year")

elif input_year % 400 ==0:
print(input_year, "is a leap year")

else:
print(input_year, "- not a leap year")
Computers and Technology
1 answer:
marshall27 [118]3 years ago
3 0

Answer:

Explanation:

The code does not fail on the first step since 1900 divided by 4 is actually 475 and has no remainder, meaning that it should return True. The code won't work because the if statements need to be nested in a different format. The correct algorithm would be the following, which can also be seen in the picture attached below that if we input 1900 it would output is not a leap year as it fails on the division by 400 which gives a remainder of 0.75

input_year = int(input())

if input_year % 4 == 0:

   if input_year % 100 == 0:

       if input_year % 400 == 0:

           print(input_year, "is a leap year")

       else:

           print(input_year, "- not a leap year")

   else:

       print(input_year, "is a leap year")

else:

   print(input_year, "- not a leap year")

You might be interested in
in a deisgn project, what two types of graphics or images is the digital artist respondsible for creating?
Inga [223]
Vector and raster images
7 0
3 years ago
How many bits are required to encode an image that is 25 pixels wide and 50 pixels tall, if you encode each pixel with 12 bits o
AURORKA [14]

Just multiply all numbers to get the total number of bits:

25*50*12 = 15000 bits.

3 0
3 years ago
Write a program that inputs an integer denoting a month (1 for January, 2 for February, ... , 12 for December), and outputs how
Korolek [52]

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variable

int inp_month;

cout<<"Enter month:";

// read month

cin>>inp_month;

// if month is february

if(inp_month==2)

cout<<"Number of days in month:28"<<endl;

// if month is 4 or 6 or 9 or 11

else if(inp_month==4||inp_month==6||inp_month==9||inp_month==11)

cout<<"Number of days in month:30"<<endl;

else

// for others month

cout<<"Number of days in month:31"<<endl;

return 0;

}

Explanation:

Read month from user and assign it to variable "inp_month".If month is 2 then  there is 28 days in the month.If input month is 4 or 6 or 9 or 11 then there is 30 days in the month.For other month there will be 31 days in month.We assume there is no leap year.

Output:

Enter month:4                                                                                                              

Number of days in month:30

6 0
3 years ago
What is the most common example of a magnetic storage medium in a personal computer
AnnyKZ [126]

Answer: magnetic tape, floppy disks and hard-disk drives

Explanation:

5 0
3 years ago
What is one pass of a coding sequence called?​
Oksi-84 [34.3K]

Answer:

In computer programming, a one-pass compiler is a compiler that passes through the parts of each compilation unit only once, immediately translating each part into its final machine code. ... This refers to the logical functioning of the compiler, not to the actual reading of the source file once only.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Why do astronomers prefer to use the reflecting telescope rather than the refracting telescope to view distant objects in space?
    15·2 answers
  • Write an if/else statement that assigns 0 to x when y is equal to 10; otherwise it should assign
    9·1 answer
  • . A wireless ……..is a device used to resolvewireless network connectivity problems.
    8·1 answer
  • Font size, font style, and _______ are all aspects of character formatting.
    14·2 answers
  • How do you know if something is in the public domain
    5·1 answer
  • How should a Salesforce Admin fulfill those requirements? Universal Containers launches a Partner Community for their resellers
    13·1 answer
  • Which composer below was not part of the classical period? <br> A. Beethoven B. Bach<br> C. Mozart
    6·1 answer
  • Are the blank space around the edges of the page
    5·1 answer
  • Function _one(array)
    6·1 answer
  • Question 7 (1 point)
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!