answer.
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]
1 year 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]1 year 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
Memory is a _____________ that includes the organization and shaping of information by processing, storage, and retrieval of inf
vaieri [72.5K]

Answer:

A. <em>Encoding Process </em>

Explanation:

Memory is an <em>encoding process </em>that includes the organization and shaping of information by processing, storage, and retrieval of information.

There are two types of memory in computing, <em>RAM </em>and <em>ROM</em>. <em>RAM </em>stands for <em>Random Access Memory</em>. It I the core memory of the computer and it is especially faster regarding reading and writing process. As an analogy, RAM memory is like the “<em>Short-term</em>” memory of the computer. <em>ROM </em>stands for <em>Read-Only Memory</em>, this is the type of memory in charge of permanently storing data in the computer. It contains the necessary information to run the computer. As an analogy, <em>ROM </em>memory is like the “<em>long-term</em>” memory of the computer.

3 0
1 year ago
. Create a text file that contains your expenses for last month in the following categories: • Rent • Gas • Food • Clothing • Ca
Whitepunk [10]

Answer:

  1. from matplotlib import pyplot as plt
  2. with open("text.txt") as file:
  3.    data = file.readlines()
  4.    category = []
  5.    amount = []
  6.    for row in data:
  7.        values = row.split(" ")
  8.        category.append(values[0])
  9.        amount.append(float(values[1]))
  10.    
  11. figure = plt.figure()
  12. ax = figure.add_axes([0,0,1,1])
  13. ax.axis('equal')
  14. ax.pie(amount, labels = category, autopct='%1.2f%%')
  15. plt.show()

Explanation:

Firstly, we need to import matplotlib library (Line 1).

Next, open a file stream and use readlines method to read the data from the text file (Line 4). Presume the data read from the text files are as follows:

Rent 450

Gas 150

Food 500

Clothing 120

Car 600

Create two lists, category and amount (Line 5-6). Use a for loop to traverse through the read data and use split method to break each row of data into two individual items. The first item is added to category list whereas the second item is added to amount list (Line 7 - 10).

Next, create a plot figure and then add the axes (Line 12 - 13). We can use the pie method to generate a pie chart (Line 15) by setting the amount list as first argument and category list as value of labels attributes. The output pie chart can be found in the attachment.

7 0
2 years ago
Which statement below correctly differentiates between frames and bits? Frames have more information in them than bits. Frames a
9966 [12]
<span>Frames have more information in them than bits.
</span>
<span>Frames are made up of bits but not vice versa.


A bit (BInary digiT) is the basic unit of digital. It can be 0 (logical false, off) or 1 (not logical false - true, on). Four bits are in a nybble, which can have a value of 0 - 15, eight bits are in a byte which can have a value of 0 - 255. Words vary in size, they consist of multiple bytes and are generally correlated with the system's data bus/processor data width (a 64 bit system has an 8 byte word).
</span>
5 0
2 years ago
Read 2 more answers
Drag each label to the correct location on the image.
pantera1 [17]

Answer:

1.computer-based  training modules  is an example of hierarchical technique.

Explanation:

Computer based training modules are the example of hierarchical model or technique of website. In this technique courses or modules are linked with each other in hierarchical structure. To start some advance module we should learn some basic modules first.

2.school website is an example of Linear Structure of Website.

Explanation:

In linear structure of website, pages are linked in a sequence. We can follow the links to find some information in sequential manner.

3.bookstore  website is an example of Linear Structure of Website.

Explanation:

In linear structure of website, pages are linked in a sequence. We can follow the links to find some information in sequential manner.

4.single-product  websites is an example of Linear Structure of Website.

Explanation:

In linear structure of website, pages are linked in a sequence. We can follow the links to find some information in sequential manner.

5.county library  website is an example of Webbed technique.

Explanation:

Computer based training modules are the example of webbed model or technique of website. In this technique many pages are connected or linked to many other pages and each page can access any other page. This is a complex structure of website.

6.online gift store  website is an example of Linear Structure of Website.

Explanation:

In linear structure of website, pages are linked in a sequence. We can follow the links to find some information in sequential manner.

7.federal government  website is an example of Webbed technique.

Explanation:

Computer based training modules are the example of webbed model or technique of website. In this technique many pages are connected or linked to many other pages and each page can access any other page. This is a complex structure of website.

3 0
2 years ago
The it department is reporting that a company web server is receiving an abnormally high number of web page requests from differ
Talja [164]
<span>In the scenario in which the IT department is reporting that a company web server is receiving an abnormally high number of web page requests from different locations simultaneously the DDoS security attack is occurring.
</span>DDos stands for Distributed Denial of Service<span> . This </span><span>attack is an attempt to make an online service unavailable by overwhelming it with traffic from multiple sources.</span>
8 0
1 year ago
Other questions:
  • Carlos owns a hardware store. He currently is not using any software to track what he has in the store. In one to two sentences,
    9·2 answers
  • 1. Do you consider Facebook, MySpace, and LinkedIn forms of disruptive or sustaining technology? Why?
    15·1 answer
  • Each of these is a basic type of a touch screen, except ________.
    10·2 answers
  • Java uses interfaces to provide the benefits of multiple inheritance. A superclass object is a subclass object. A subclass is of
    8·1 answer
  • Mrs. Johnson is here today to receive an intercostal nerve block to mitigate the debilitating pain of her malignancy. Her cancer
    13·1 answer
  • Compare the elements of the basic Software Development Life Cycle with 2 other models. How are they similar? How are they differ
    9·1 answer
  • Write the definition of a class Telephone. The class has no constructors, one instance variable of type String called number, an
    9·1 answer
  • On a webpage, a _____ provides supplemental material such as social networking feeds and ads. Group of answer choices footer sid
    9·1 answer
  • +10 points~~~Which option is used in emails to inform the recipient that they should exercise discretion in accordance with shar
    12·1 answer
  • In this image, which feature did we most likely use to quickly change the background, fonts, and layout?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!