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]
3 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]3 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
Which column and row references are updated when you copy the formula: =F$5+12? Value 12 Column F Column F and row 5 Row 5
NemiM [27]
The answer is column F. During relative copy and paste in Excel, the positioning of the '$' symbol effectively indicated an absolute reference to a position, so that is not updated. Therefore, in the formula '<span>=F$5+12</span>', only column F is updated. 
8 0
4 years ago
[PROGRAMMING] A ____ signal indicates that a specific amount of time should pass before an action starts.
Inessa [10]
A time signal will do that, I believe!
5 0
3 years ago
16. (PPT) You can use features on the Video Tools Playback tab to adjust how and when the video plays during the slide
Nezavi [6.7K]

Answer:

a. True

Explanation:

5 0
2 years ago
Use the nutrition label to determine how many calories would be consumed by drinking 1 liter of Mountain Dew.
Rus_ich [418]
1 liter of mountain dew is 170 calories
4 0
3 years ago
Read 2 more answers
Which of the following are wise entrepreneurial decisions or concepts? Check all of the boxes that apply.
Artyom0805 [142]

Answer:

a b e d f

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • What are three things to consider in programming design?
    14·1 answer
  • Which device in a wireless local area network (wlan) determines the next network point to which a packet should be forwarded tow
    12·1 answer
  • Assume that the myname.txt file is currently closed. write the code segment that opens the file without erasing it, write anothe
    13·1 answer
  • What is the first document that colleges review when making admissions decisions
    10·2 answers
  • A ____ is a battery-operated power source directly attached to one or more devices and to a power supply (such as a wall outlet)
    14·1 answer
  • When you move a paragraph in a document that includes text with a footnote, what happens to the footnote reference?
    14·1 answer
  • Which of the following statements is FALSE?
    10·2 answers
  • Select the correct answer from each drop-down menu.
    10·1 answer
  • Where do file name extensions appear?
    14·1 answer
  • Which of the following is a software tool used to manage data for a project in a logical and hierarchical order?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!