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
Lynna [10]
3 years ago
11

Write a program asks the user for an integer N and then adds up the first N odd integers. For example, if the user asks the sum

of the first 10 odd integers, the program computes: Use a loop for this. Use instructions and pseudo instructions up to chapter 24. Use exception handler services for input and output. How many odd numbers: 10 The sum: 100 If the user enters a negative integer or non-integer, just print a zero. Start your source file with comments that describe it:
Computers and Technology
1 answer:
abruzzese [7]3 years ago
7 0

Answer:

The program in Python is as follows:

while True:

   try:

       num = input("Number of odds: ")

       num = int(num)

       break

   except ValueError:

       print("Invalid integer! ...")

sum = 0

odd = 1

if num > 0:

   for i in range(num):

       sum+=odd

       odd+=2

print("Total:",sum)

Explanation:

This is repeated until a valid integer is inputted

while True:

This uses exception

   try:

This gets the number of odd numbers

       num = input("Number of odds: ")

This converts the input to integer

       num = int(num)

       break

If input is invalid, this catches the exception

<em>    except ValueError:</em>

<em>        print("Invalid integer! ...")</em>

This initializes sum to 0

sum = 0

This initializes odd to 1

odd = 1

If input is positive

if num > 0:

This add the first num odd numbers

<em>    for i in range(num):</em>

<em>        sum+=odd</em>

<em>        odd+=2</em>

This prints the total

print("Total:",sum)

You might be interested in
Considering current online newspaper editions and the characteristics of digital age media, how do you think newspaper design mi
NeX [460]
One way that a newspaper design may change in the future is that they will only be available in an interactive online edition. The correct answer is B. <span />
6 0
3 years ago
Please help,
MAXImum [283]

Answer:Answer I think it might be true Explanation in the Explanation

Explanation: So I think it might be true because Ergonomics is the science of conforming the workplace and all of its elements to the worker, and in the question it says that "How a product relates to the human body", so I think it might be true, Sorry if I got this wrong.

GOOOOOOD LUUUUUCCCCCCKK

8 0
3 years ago
20 points
Keith_Richards [23]
If the four colors are well -balanced then nothing could be best scheme other than the "Square" as it is it's characteristic

In short, Your Answer would be Option C

Hope this helps!
7 0
3 years ago
Other than technology and start-up costs what are two
sattari [20]
The other two particular cases of hindrances that could keep an organization or individual from entering a market are the beneath: 
Individual attributes - there are sure occupations that specific criminals are not permitted to do - sex wrongdoers can't start up youngster mind offices; individuals with associations with composed wrongdoing shouldn't have the capacity to begin gambling clubs, and so on. There are employments that outsiders can't do. Furthermore, for a few employments, you require unique trusted status. 
Local legal restricti - you can't simply begin a taxicab organization in New York, you need to have emblems for your taxis. It is practically difficult to get one from the city, so you regularly need to purchase another person out
6 0
3 years ago
Slack space most commonly contains visible data. True or false?
Ivanshal [37]
That is so True because slack space mostly has visible dada
7 0
3 years ago
Other questions:
  • A benefit of IPsec is __________.
    8·1 answer
  • How do you open Microsoft Excel 2013 with Windows 8?
    13·1 answer
  • One purpose of the dual ignition system on an aircraft engine is to provide for?
    7·2 answers
  • Which of these might be an example of an advertiser's target group?
    6·2 answers
  • What command is used to generate an RSA key pair?
    9·1 answer
  • Which statement accurately compares the restart at 1 and continue numbering featured of word
    15·2 answers
  • Which of the following works on the pay-per-click (PPC) and cost-per-click (CPC) concept? ~ Plato
    9·1 answer
  • What is the correct name for the words Home, Insert, Design, Layout, References, etc. in the ribbon in Word 2016?
    8·2 answers
  • What Two external audio recorders are most commonly used ??
    8·1 answer
  • How does a security information and event management system (SIEM) in a SOC help the personnel fight against security threats
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!