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
Ratling [72]
3 years ago
15

Write a program for determining if a year is a leap year. In the Gregorian calendar system you can check if it is a leaper if it

is divisible by 4 but not by 100 unless it is also divisible by 400.
Computers and Technology
1 answer:
SOVA2 [1]3 years ago
8 0

Answer:

def leap_year_check(year):

return if int(year) % 4 == 0 and (int(year) % 100 != 0 or int(year) % 400 == 0)

Explanation:

The function is named leap_year_check and takes in an argument which is the year which we wish to determine if it's a new year or not.

int ensures the argument is read as an integer and not a float.

The % obtains the value of the remainder after a division exercise. A remainder of 0 means number is divisible by the quotient and a remainder other wise means it is not divisible by the quotient.

If the conditions is met, that is, (the first condition is true and either the second or Third condition is true)

the function leap_year_check returns a boolean ; true and false if otherwise.

You might be interested in
Within program menus, some menu items have an arrow next to them. What will open if you click on that command?
hodyreva [135]
The answer is most probably a subemenu
4 0
4 years ago
Read 2 more answers
Find the error and rewrite the code with the error fixed.
kap26 [50]

Answer:

Explanation:

1st mistake: Barcode is written with upeer case, that's not the convention for variables in java, only classes.

2nd: Barcode is public, it is convention to always leave variables private then create getters and setters in case you need to change the value but never acess the variable outside the class it belongs. Also the class should at least have a default constructor in case you are going to instantiate an object outside it.

so the product class should be:

--------------------------------------------------------------------

public class Product {

private int barcode;

        public Product() {

        // default constructor

        }

public int getBarcode() {

 return barcode;

}

public void setBarcode(int barcode) {

 this.barcode = barcode;

}

}

-------------------------------------------------------------------------

3rd: in the main class now you can instantiate the 2 objects but you are gonna set the variable and get the value through the method, like this:

public class Main {

 

public static void main(String[] args) {

   

 Product prod1 = new Product();

 prod1.setBarcode(123456);

 Product prod2 = new Product();

 prod2.setBarcode(987654);

 System.out.println(prod1.getBarcode());

 System.out.println(prod2.getBarcode());

}

}

-----------------------------------------------------------------------------------

Assuming the 2 classes (main and product) are in the same package. But in case they are in different packages, just make sure to import the Product class into the Main class so that you can instantiante an object (new Product()) of it.

7 0
3 years ago
Occurs when the same data are stored in multiple places
Minchanka [31]
D. Data redundancy. This means the data is located in multiple places when it isn't necessary to do so.
8 0
3 years ago
What kind of game was Pole Position?
sesenic [268]
A racing game, with cars on a race track.
7 0
3 years ago
Which font attribute allows you to change the text from bold to
Sladkaya [172]
F o n t T y p e . Yea it’s font Tyler’s
8 0
3 years ago
Read 2 more answers
Other questions:
  • Use ________ resolution when recording human speech in an audio file.
    14·1 answer
  • The inner planets are called terrestrial because they
    11·2 answers
  • Which of the following is not a feature of Hootsuite?
    14·1 answer
  • Software that protects confidentiality by screening outgoing documents to identify and block transmission of sensitive informati
    12·1 answer
  • The data in a database management system that identifies the names of​ tables, fields in each​ table, and the properties of each
    13·2 answers
  • Greedy Algorithm Design
    8·1 answer
  • What is the full form of ARPANet, WAN,FTP,DCP,HTML,ISP and last WWW​
    12·2 answers
  • 49 points!
    14·1 answer
  • tiny electrical paths to connect everything together is called ? A. graphic card B. audio card C. CPU D. Motherboard
    6·1 answer
  • Different the policies and protocols in the industry
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!