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
If you use the assign software to a user option, how does the new software install to the user's computer? 70-411
Serggg [28]
Hi,

If you install a new software and you select option for all users the software will be installed in a special folder that is shared by all the users and each user would represent a subfolder in the shared folder.

Hope this helps.
r3t40
3 0
2 years ago
In the ______ stage of the systems development life cycle, the design specifications are translated into computer code.
faust18 [17]
In the Programming stage of the system development life cycle, the design specifications are translated into computer code
7 0
3 years ago
On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * r^n, where n is the distance
vodomira [7]

Answer:

Following are the code to this question:

import math# import math module

def RaiseToPower():   # defining a function RaiseToPower

   r= math.pow(2,1/12)    # defining r variable that calcualte the decimal point value.

   return r # return r variable value.

f0= float(input()) #defining f0 variable that hold input frequency .

for n in range(0,5):#defining for loop to count all frequency

   fn = f * math.pow(RaiseToPower(),n)    # defining fn variable that calls method RaiseToPower and multiply the value by frequency

   print(fn,end=' ')    # use print method to prints all five frequency

Output:

440

440.0 466.1637615180899 493.8833012561241 523.2511306011974 554.3652619537443

Explanation:

Description of the above python code can be defined as follows:

  • In the above code first we import the package of the math module for converting frequency, after importing package a "RaiseToPower" method is declared, inside the method r variable is declared, that counts decimal value and return its value.
  • In the next step, "f0" a frequency variable is declared that input a value from the user and defined a for loop to in the loop fn variable declared, calls the method and pass its input value and stores its decimal points and at the last print its value.

6 0
3 years ago
Which of these statements regarding mobile games is true? A. They are typically played indoors. B. They have detailed environmen
Lyrx [107]

Answer:

c and d

Explanation:

6 0
3 years ago
What three files do you need to perform a mail merge?<br><br> HELP ASAP PLEASE!!
Burka [1]

The 3 files you need to have for a successful mail merge are:

  • An Excel spreadsheet works
  • Outlook Contact List.
  • Apple Contacts List or Text file, etc.

<h3>What is Mail Merge?</h3>

This is known to be the act of carrying out  a Mail Merge and it is one where a person will need to use a Word document and a recipient list, that is an Excel workbook.

Files needed are:

  • Text file,
  • address files, etc.

The 3 files you need to have for a successful mail merge are:

An Excel spreadsheet worksOutlook Contact List.

Apple Contacts List or Text file, etc.

Learn more about mail merge from

brainly.com/question/20904639

#SPJ1

4 0
1 year ago
Other questions:
  • Add the following functions to the code:
    9·1 answer
  • In the U.S. highway numbering system, north-south routes have
    9·2 answers
  • Briefly explain five measures you have undertaken to protect your confidential
    12·1 answer
  • Frank develops a questionnaire for his study on Internet dating. One of his questions asks, "How do you feel about Internet dati
    14·2 answers
  • Which of the following actions is an example of "window dressing?" a. Using some of the firm’s cash to reduce long-term debt. b.
    13·1 answer
  • Which of the following is not true about VOIP?
    9·1 answer
  • Each AWS region is composed of two or more locations that offer organizations the ability to operate production systems that are
    7·1 answer
  • For this assignment, select one of the organizations with a prominent IT department from the Topic 1 assignment. Once identified
    11·1 answer
  • Clicking the ____ opens the insert function dialog box.
    13·1 answer
  • What is considered appropriate dress for men and women in the workplace? Select all that apply.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!