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
In a spreadsheet, there are many features that help you edit quickly. True False
9966 [12]

Answer:

True

Explanation:

There are many form a quick editing

i hoped this helped

;)

7 0
3 years ago
How do I convince my mom to buy a gaming computer for me? She says we already have 3 other computers/laptops in the house to use
Natalka [10]

Answer: ??

Explanation: explain to her that you don't have your own. keep asking and convince her you're doing good in school, (if u are) and that you listen and you should be responsible to have your own

4 0
3 years ago
With the exception of a(n) ____________________, the Paste command allows you to paste an object without creating a link.
mylen [45]
<span>Chart
</span>With the exception of a Chart, the Paste command allows you to paste an object without creating a link.
4 0
3 years ago
Anthony is deciding between different savings accounts at his bank. He has four options, based on how frequently interest compou
anastassius [24]
He should pick the most reliable one.

Hope this helps.

4 0
3 years ago
Give three reasons why it s important to ensure your portfollo is professional
FrozenT [24]

Answer:

1. Showcase your skills

Explanation:

2. Stand out from the crowd

3. Keep track of all emails, notes, and performance reviews

6 0
3 years ago
Other questions:
  • when you cross or enter traffic from a full stop, how much space should you allow on city streets? on the highway?
    11·1 answer
  • ______________ is only one of the marketing mix tools that acompany uses to achieve its marketing objectives.
    7·1 answer
  • What would be a situation in which you could use an excel chart to present your data
    8·2 answers
  • What are the benefits of using a multiview sketch?
    11·1 answer
  • In addition to the decimal number system, the number systems used most often in PLC operationand programming are ________.
    9·1 answer
  • "Packet switches have multiple links attached to them. For each attached link the packet switch has a/an ____________, which sto
    7·1 answer
  • List pros and cons of HCI technology​
    5·2 answers
  • Name:
    13·1 answer
  • Describe the Order of Operations in Java programming.
    11·1 answer
  • How does Accenture help companies harness the power of data to achieve optimal business outcomes?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!