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
Question 3 / 5
Andrej [43]

Answer:

False

Explanation:

3 0
3 years ago
You need to open the negative screw on the ceiling fan,what driver should you use?​
ELEN [110]

Answer:

flat screw driver

because if the screw is negative then you will need a flat screw driver

8 0
3 years ago
Program ___________________ are written explanations that are not part of the program logic but that serve as documentation for
Aleks04 [339]

Answer:

Program Comments

Explanation:

program comments are explanations. They are not executable code and the can actually appear anywhere in your code. Their main function is code documentation for the future. In Java programming language for example three types of comments is used. These are

// Single line comments  (This starts with two forward slashes

/* Multiple Line

comment

Style*/    

The third is the javadoc that gives a description of a function. I looks like the multiple line but is has two asterics

/** This is javadoc

comment

style*/

8 0
4 years ago
A user reports his or her computer is slow to boot. You check the boot order and determine that the computer is checking the C d
Nata [24]
You could turn off memory testing, but defragmentating and running chkdsk on C: would be better to try first.
6 0
3 years ago
How does entertainment relate to coding?
liberstina [14]

Answer:

not sure if this is the type of answer you're looking for but: Entertainment can relate to coding because in TV shows and movies, there is lots of editing. Especially with cartoons. Inorder to make these, we have to use coding. This can even relate to real life plays and preformenses depending on how much technology you use to preform them.

3 0
3 years ago
Other questions:
  • All objects in an object-oriented program are instantiated (created) from a ____.
    12·1 answer
  • How much health did a supply drop balloon originally have??
    7·2 answers
  • Which of the following would you not see on a windows 10 start menu?
    6·1 answer
  • Which of the following modes of replication requires a very low latency network connection and ensures data remains in synch wit
    9·1 answer
  • When mapping a drive, you can type in the path to the shared folder on the host computer. what is the syntax for the path?
    7·1 answer
  • Should the use of hacktivists by a country against enemy organizations be considered an act of war? Why or why not? How about th
    8·1 answer
  • Help plzzzzzzzzzzzzzzzzzzzzzzzzz
    14·1 answer
  • 35 POINTS
    10·1 answer
  • Match the TCP/IP Layer to a problem that can happen there.
    8·1 answer
  • Questic
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!