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
Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is: *
MrRa [10]

Answer:

Following are the code to this question:

b= input()#defining b variable for input character value

h= input()#defining h variable for input character value

b_width=6#defining b_width variable that holds an integer value 6

r1 = ' ' * b_width+h#defining r1 variable that calculates hash lines

r2 = b*b_width+h*2#defining r3 variable that calculates 6 asterisk and 2 hash line  

r3 = b*b_width+h*3#defining r3 variable that calculates 6 asterisk and 3 hash line

print(r1)#print r1 variable value

print(r2)#print r2 variable value

print(r3)#print r3 variable value

print(r2)#print r2 variable value

print(r1)#print r1 variable value

Output:

please find the attachment.

Explanation:

In the given python code, three variable "b,h, and b_width" is declared, in which "b_width" holds an integer variable "6" and variable "b and h" is used to an input character value.  In the next line, "r1, r2, and r3" is declared, that holds arrowhead values which can be defined as follows:

  • In the "r1" variable, it stores space with b_width variable and one h variable value.
  • In the "r2" variable it stores b_width and 2*h variable value.
  • In the "r3" variable it stores b_width and 3*h variable value.

At the last, it prints the "r1, r2, and r3" variable value and for arrowheads,  it follows the above program code.

6 0
3 years ago
Macronutrients include carbon, phosphorous, oxygen, sulfur, hydrogen, nitrogen and zinc. (T/F)
kvv77 [185]

Answer:

The answer to your question is False

Explanation:

Macronutrients are complex organic molecules, these molecules give energy to the body, promote the growing and the good regulation of the body. Examples of macromolecules are Proteins, carbohydrates, and Lipids.

Micronutrients are substances that do not give energy to the body but they are essential for the correct functioning of the body. Examples of micronutrients are Vitamins and Minerals.

3 0
3 years ago
How do you comment on someone's answer on Brainly???
Semenov [28]
Press ANSWER , and reply
5 0
3 years ago
Read the excerpt from a teacher's lesson plan. Global communication, especially in today's digital age, can benefit all of you i
Rufina [12.5K]

The best line to be added to the teacher’s lesson plan, which is supposed to emphasize the benefits of global communication, would be (D) learning in a global community enables you to expand your horizons and learn new languages.

The other options are not suitable because they highlight the negative side of global communications, which is not something that the teacher’s lesson intends to do.

8 0
3 years ago
Read 2 more answers
Which of these appliances can be classified as a robot? You can choose 2.
Natali [406]

Answer:

ummmm i think b

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • A client reports the client has been experiencing increased stress at work. The client has been managing the stress by drinking
    5·1 answer
  • Select the correct answer.
    6·1 answer
  • How does microchip work
    12·1 answer
  • Which statement about the Paste Link option is true? A)Even if the source file (spreadsheet) is deleted, the data updates automa
    11·1 answer
  • Select the correct statement below about database services or database instances:
    5·1 answer
  • Forms open in _______, which provides a user-friendly interface for entering data.
    11·1 answer
  • On the Format tab, in the Shape Styles group, there is the option to change the _____. a. Shape Effects b. Shape Fill c. Shape O
    5·1 answer
  • 12) If the image's name is filename.gif, how can I make this image the background of my page?
    6·1 answer
  • There are types of templates​
    5·1 answer
  • Which technology do online storesusually use to present customized content?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!