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
Readme [11.4K]
2 years ago
8

Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lowe

r even number. Hint: Use an if statement and the % operator to detect if n is odd, decrementing n if so. Enter an integer: 7 Sequence: 64 20 (2) If n is negative, output 0, Hint: Use an if statement to check if n is negative. If so, just set n = 0. Enter an integer: -1 Sequence: 0 Show transcribed image text (1) Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lower even number. Hint: Use an if statement and the % operator to detect if n is odd, decrementing n if so. Enter an integer: 7 Sequence: 64 20 (2) If n is negative, output 0, Hint: Use an if statement to check if n is negative. If so, just set n = 0. Enter an integer: -1 Sequence: 0
Computers and Technology
1 answer:
seropon [69]2 years ago
7 0

Answer:

The program in Python is as follows:

n = int(input("Enter an integer: "))

if n < 0:

   n = 0

print("Sequence:",end=" ")

for i in range(n,-1,-1):

   if i%2 == 0:

       print(i,end = " ")

Explanation:

This gets input for n

n = int(input("Enter an integer: "))

This sets n to 0 if n is negative

<em>if n < 0:</em>

<em>    n = 0</em>

This prints the string "Sequence"

print("Sequence:",end=" ")

This iterates from n to 0

for i in range(n,-1,-1):

This check if current iteration value is even

   if i%2 == 0:

If yes, the number is printed

       print(i,end = " ")

You might be interested in
Let's play Silly Sentences!
Mrac [35]

Answer:

Grace sat quietly in a stinky stadium with her blue jacket

Grace jumped on a plane to Paris.

Grace ate bananas, apples, and guavas quietly while she listened to the news.

Grace is the name of a major character in my favorite novel

Grace was looking so beautiful as she walked to the podium majestically.

Grace looked on angrily at the blue-faced policeman who blocked her way.

3 0
3 years ago
A blue line, called a ____ line, that appears when you are dragging a GUI object on a Windows Form object indicates that the obj
ser-zykov [4K]

Answer:

snap

Explanation:

The line which appears when we are dragging an object of GUI on a object of  windows Form indicates that the object that is being dragged is aligned horizontally with the object which is connected by the blue line is called a snap line.

Hence we conclude that the answer to this question is snap line.

3 0
3 years ago
Which one of these is not an area of AI? Computer vision/image, recognition Voice recognition, Robotics, Web design
Verdich [7]

Answer:

Computer vision/image

6 0
2 years ago
Read 2 more answers
_____ is a protocol used by e-mail clients to download e-mails to your computer.
navik [9.2K]
Smtp : Simple Mail Transfer Protocol
3 0
3 years ago
List the five ethical rules that you feel are most important for one to follow when using the internet.
seropon [69]
1. Be smart
2. Do not tell anyone your personal info
3. Use reliable resources while looking up things (org,net,ect. no .coms)
4. ask your parents or guardian if you can go on a specific website And number 5 have fun!
7 0
3 years ago
Other questions:
  • What does using indirect quotations allow a writer to do?
    7·2 answers
  • Tonya is working with a team of subject matter experts to diagnose a problem with her system. The experts determine that the pro
    14·1 answer
  • Which design element involves the act of lining up objects vertically or horizontally to give a sense of order?
    15·1 answer
  • Possible consequences for plagiarism, listed in CAVA's Academic Integrity Policy, may include:
    9·1 answer
  • Just forgot where she saved a certain file on her computer therefore she searched for all files with jpg file extension which ty
    13·2 answers
  • Why is democracy the best form of government
    5·1 answer
  • Suppose that outFileis an ofstreamvariable and output is to be stored in the file outputData.out. Which of the following stateme
    14·1 answer
  • Image-editing software is used to_____
    7·1 answer
  • How is a UDP socket fully identified? What about a TCP socket? What is the difference between the full identification of both so
    9·1 answer
  • For questions 3-6, consider the following two-dimensional array:
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!