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 python how do you write for prime factors
olasank [31]

Answer:

The while loop is used and the factors of the integer are computed by using the modulus operator and checking if the remainder of the number divided by i is 0. 3. Then the factors of the integer are then again checked if the factor is prime or not.

Explanation:

google

4 0
3 years ago
Chang is a network engineer. He is revising the company's firewall implementation procedure. As part of this work, he is reviewi
erastovalidia [21]

Answer:

d

Explanation:

3 0
3 years ago
What are color highlights?
SVETLANKA909090 [29]

A- overusing highlights lowers the contrast and degrads the effect of the highlights.

3 0
3 years ago
Read 2 more answers
You have a desktop computer that supports both IEEE 1394 and USB 2.0. You are purchasing some devices that will connect to these
zimovet [89]

Answer:

IEEE 1394 supports more devices on a single bus

Explanation:

What this means is that IEEE 1394 provides a single plug-and-socket connection on which up to 63 devices can be attached with data transfer speeds up to 400 Mbps (megabit s per second). The standard describes a serial bus( A shared channel that transmits data one bit after the other over a single wire or fiber) or pathway between one or more peripheral devices and your computer's microprocessor .

7 0
3 years ago
A circuit is supplied with 30 VDC and contains three resistors connected in series. The value or R1 is 80 , the value of R2 is 1
Llana [10]
One approach to solving this is to first calculate the current the will flow through all three resistors:

The total resistance is R1+R2+R3 = 5280

I = V/R = 30/5280 ≈ 5,682 mA

Then the drop across R2 = I*R2 = 5,7mA * 1000 ≈ 5.682 V.

So this is based on the fact that V=I*R and there is one current running in the entire chain, ie., it is the same through each resistor.
6 0
3 years ago
Other questions:
  • Describe the concepts of confidentiality, integrity, and availability (C-I-A), and explain each of the seven domains of a typica
    9·1 answer
  • The ability to learn a new computer software program is to ____________ as knowledge of state capitals is to _____________.
    11·1 answer
  • Can a computer will work more efficiently if you perform disk optimization
    9·1 answer
  • Find some search engine as many that you can find
    9·1 answer
  • A personal business letter is a letter that is ____.
    13·1 answer
  • The numeric keys on the keyboard are sometimes called the ten keypad. true false
    9·2 answers
  • A Windows application which demands a lot of raw processing power to execute repetitive complex calculations is a good candidate
    9·1 answer
  • When performing the ipconfig command, what does the following output line depict if found in the tunnel adapter settings?
    5·1 answer
  • What is the most appropriate data type for each of these items?
    15·1 answer
  • What are the five generations of computer software​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!