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]
2 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]2 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
Fill in this function that takes three parameters, two Strings and an int. 4- // Write some test function calls here! The String
zimovet [89]

Answer:

The function in Java is as follows:

public static void printMessage(String lineOne, String lineTwo, int lines){

       for(int i = 1;i<=lines;i++){

           if(i%2 == 1){

               System.out.println(lineOne);

           }

           else{

               System.out.println(lineTwo);

           }

       }

   }

Explanation:

This defines the function

public static void printMessage(String lineOne, String lineTwo, int lines){

This iterates through the number of lines

       for(int i = 1;i<=lines;i++){

String lineOne is printed on odd lines i.e. 1,3,5....

      if(i%2 == 1){

               System.out.println(lineOne);

           }

String lineTwo is printed on even lines i.e. 2,4,6....

           else{

               System.out.println(lineTwo);

           }

       }

   }

To call the function from main, use:

printMessage("Hi", "Karel", 5);

8 0
2 years ago
Which of the following is not considered a system component that can be found inside a computer? A-CPU B-RAM C-PCIe graphics ada
Julli [10]

The answer is C) PCIe graphics adapter, because it is not required for the computer to work.

8 0
2 years ago
_______ allows you to add formatting such as shapes and colors to text. a. worddraw b. wordart c. worddesign d. wordshapes
4vir4ik [10]
Word Design is the answer.
4 0
2 years ago
Read 2 more answers
Which daemon manages the physical memory by moving process from physical memory to swap space when more physical memory is neede
Anastasy [175]

Answer:

Swap daemon

Explanation:

Swap daemon manages the physical memory by moving process from physical memory to swap space when more physical memory is needed. The main function of the swap daemon is to monitor processes running on a computer to determine whether or not it requires to be swapped.

The physical memory of a computer system is known as random access memory (RAM).

A random access memory (RAM) can be defined as the internal hardware memory which allows data to be read and written (changed) in a computer.Basically, a random access memory (RAM) is used for temporarily storing data such as software programs, operating system (OS),machine code and working data (data in current use) so that they are easily and rapidly accessible to the central processing unit (CPU).

Additionally, RAM is a volatile memory because any data stored in it would be lost or erased once the computer is turned off. Thus, it can only retain data while the computer is turned on and as such is considered to be a short-term memory.

There are two (2) main types of random access memory (RAM) and these are;

1. Static Random Access Memory (SRAM).

2. Dynamic Random Access Memory (DRAM).

6 0
3 years ago
Smartphones combine the features of which two types of devices?
tankabanditka [31]
Idunno if you got the answer to this question or if I'm too late, feel free to message me if I'm not!
6 0
2 years ago
Read 2 more answers
Other questions:
  • Where can you change your web page SafeSearch settings?
    8·1 answer
  • A(n) monitoring vulnerability scanner is one that listens in on the network and determines vulnerable versions of both server an
    7·1 answer
  • 4. How can you select non-adjacent cells (i.e. cells that are not all together in one block)?
    5·2 answers
  • Which option is used to apply formatting to multiple objects on a single slide while still maintaining the ability to manage the
    14·2 answers
  • How many license plates are there if a license plate contains 3 letters from the 26 available in the English alphabet followed b
    15·1 answer
  • The small company where you work needs to implement a second server for its accounting system, but does not have the funds to pu
    11·1 answer
  • In determining where to store specific data in a(n) centralized DBMS, factors such as communications cost, response time, storag
    12·1 answer
  • Given two variables, is Empty of type boolean, indicating whether a class roster is empty or not, and number Of Credits of type
    10·1 answer
  • In what way , if any, can your social media presence affect your chances of getting a job in social media?
    8·1 answer
  • Write a summary of five things that you learned about CSS. Do not copy and paste the information. Summarize each point in your o
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!