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 command backs up the single database called 'websites' to the file 'websites_backup.sql'?
kaheart [24]

Answer:

(d) mysqldump websites -u root -p > websites_backup.sql

Explanation:

To create a backup mysqldump is used.It is a data backup program.This program was originally written by Igor Romanenko. It creates a backup of file name websites_backup.sql.

So among the given options in the question option d is the correct option which backs up the single database websites in the file website_backup.sql.

8 0
3 years ago
Please explain in simple words. What does a root do to your tablet? And how do you do it? Is it worth doing it if you only play
nadya68 [22]
Root is a term for android devices similar to "jailbreak" for Apple devices. Rooting gives you basically full control of your device but is considered to be a third party software because you are modifying the operating system. I would watch a YouTube video on how to root your device. I tried to root my device so I could get this screen recording app to work. I think it is really up to you because I think it avoids warranty.
6 0
3 years ago
What effect does using quotas in file server resource manager have?
andrezito [222]
It limits the number of gigabytes allocated to a volume or folder
5 0
3 years ago
What is the best way to determine if a cable inside a computer is a data and instruction cable or a power cable?
Liono4ka [1.6K]
You have to trace it back to its source to determine it. Data cables are flat and cables are round.
4 0
3 years ago
What is class in python
Nataly_w [17]

Answer:

It is a code template for creating objects.

7 0
3 years ago
Read 2 more answers
Other questions:
  • What are the tiny little dots that make up a digital photograph?
    8·2 answers
  • Programmers use a(n) ____ when they need the computer to repeatedly process one or more program instructions until some conditio
    13·1 answer
  • Excel has more than 400 additional functions that perform just about every type of calculation you can imagine. Answer
    6·1 answer
  • In the end, businesses that use teams tend to have ______.
    7·2 answers
  • PLEASE HELP ASAP!!
    13·1 answer
  • The private field, which is known as the property‘s __________, holds any data that is assigned to the property.a. private datab.
    9·1 answer
  • Deon plans to ride a 15 mile bicycle trail.his if his average is 20 miles per hour
    15·1 answer
  • Neview of related literature happens in two wayo (1) Traditional and
    6·1 answer
  • Your data warehousing project group is debating whether to create a prototype of a data warehouse before its implementation. The
    12·1 answer
  • Anil needs to show the overlap of people who live in a certain neighborhood in his city and who support a specific political can
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!