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
Arturiano [62]
3 years ago
14

In Python please:

Computers and Technology
1 answer:
sergey [27]3 years ago
6 0

Answer:

Following are the program in the Python Programming Language.

#set variable for input year by user

y=int(input("Enter year: "))

#set variable and initialize to 0

flag=0

#check condition that year is divisible by 4

if(y%4==0):

 #check that the year is divisible by 100

 if(y%100==0):

   #check that the year is divisible by 400

   if(y%400 ==0):

     #then initialized flag to 1

     flag=1

   else:

     #otherwise remain 0

     flag = 0

 else:

   flag = 1

else:

 flag = 0

#for break line

print()

#check that if flag is equal to 1

if(flag==1):

 print("29 days in February")

#otherwise else

else:

 print("28 days in February")

<u>Output</u>:

Enter year: 2020

29 days in February

Explanation:

<u>Following are the description of the program</u>:

  • Set variable 'y' in which we get integer value as year from the user.
  • Set variable 'flag' and initialize that variable to 0.
  • Then, we set if-else conditional statements to check that the variable 'y' is divisible by 4 then, we check that the variable 'y' is divisible by 100 and we also check that the following variable is divisible by 400.
  • Finally, we set if-else conditional statement to check that the variable 'flag' is equal to 1 then print about the leap year, otherwise it print about the non-leap year.
You might be interested in
I play Among us :) hbu
11Alexandr11 [23.1K]

Answer:nice

Explanation:u tryna play doe?

7 0
3 years ago
Read 2 more answers
Write a Java program that generates a random number between 0 and 50. Then, the program prompts for guesses until the user is co
tino4ka555 [31]

Answer:

Here is the JAVA program:

import java.util.Scanner;  //to accept input from user

public class Main {   //class name

   public static void   GuessTheNumber()      {  //method to guess the number

       Scanner input = new Scanner(System.in);   //creates Scanner object to accept input from user

       int number = (int)(50 * Math.random()) ;   //generates random number from 0 to 50

       int trials = 10;  //allows 10 trials to user to guess the number

       int i, userGuess;  //stores user guess

       System.out.println("Guess a number between 0 to 50");  //prompts user to guess a number between 0 to 50  

       for (i = 0; i <trials; i++) {  //allows user to keep guessing in 10 trials

           System.out.println("Enter your guess: ");   //prompts user to enter a number as a guess

           userGuess = input.nextInt();  //reads users entered number(guess)

           if (number == userGuess) {  //if users guess is correct

               System.out.println("Congratulations! The guess is correct!");  //displays congratulatory message

               break;              }  //the loop breaks after correct guess is made

           else if (number>userGuess) {  //if user guess is less than correct number

               System.out.println("Too low");             }  

           else if (number<userGuess) {  //if user guess is greater than correct number

               System.out.println("Too high");            }          }    

       if (i == trials) {  //if user has made 10 wrong guesses

           System.out.println("You exceeded 10 trials!");

           System.out.println("The correct number was " + number);          }      } //displays the correct number if user made 10 wrong guesses

 

   public static void main(String arg[])      {     //start of main method

       GuessTheNumber();      }  } //calls method to start the guessing game

Explanation:

The program prompts the user to enter a guess and it uses random() method to generate randoms numbers from 0 to 50. The loop keeps iterating and prompting the user to enter a guess until the limit of number of trials exceeds. The trials are set to 10 so the user can guess a number in 10 tries. If the user guesses a number that is higher than the correct guess then the program indicates that the guess is too high by displaying a message "too high" and if user guesses a number that is lower than the correct guess then the program indicates that the guess is too low by displaying a message "too low". If user makes 10 wrong guess then the program displays the correct guess and ends. The screenshot of the output is attached.

5 0
3 years ago
Why is ipsec considered to be a transparent security protocol?
Alex17521 [72]
Ipsec is considered to be a transparent security protocol because IPsec (Internet Protocol Security) is designed so that modifications of programs, additional training, additional client setup are not allowed.  It <span>provide security </span>functions<span>, authentication and encryption, at the IP (Internet Protocol) level. </span>
3 0
3 years ago
PLEASE HELP ME ASAP I HAVE AN EXAM SOON!!!!
3241004551 [841]

Answer:

try seeing if the nozzle of the cartridge is clogged

Explanation:

8 0
3 years ago
How to create json object from variables javascript
tino4ka555 [31]
Not entirely sure what you want to achieve, but consider this program:

var a = 'foo';
var b = 'bar';

var c = { first : a, second : b };

console.log(JSON.stringify(c, null, 4));

A json object c is constructed using the values from variables a and b. Is this what you mean?
8 0
4 years ago
Other questions:
  • You're trying to decide which disk technology to use on your new server. the server will be in heavy use around the clock every
    10·1 answer
  • While traveling in India, Sabina notes all of her daily expenses in rupees in her spreadsheet. At the end of the day, she wants
    5·2 answers
  • How to cite a website, like asha.org?
    6·1 answer
  • Find the maximum value and minimum value in below mention code. Assign the maximum value to maxMiles, and the minimum value to m
    11·1 answer
  • Gary lives in an area that receives a lot of rain throughout the year. which device would be useful to him to maintain his compu
    8·1 answer
  • An array of Strings, names, has been declared and initialized. Write the statements needed to determine whether any of the array
    9·1 answer
  • We need ____ pointers to build a linked list.
    6·1 answer
  • Which of these statements about symmetric key encryption is true? The file is encrypted with a private key and can be decrypted
    14·1 answer
  • Why Do You Need to Set Goals for a LinkedIn Automation Campaign?
    15·1 answer
  • A pcr-based method to detect a specific pathogen in a specimen works by amplifying a ________ that is specific to the prospected
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!