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
(tco 6) after connecting to an ftp site, the _____ command will upload multiple files.
m_a_m_a [10]
<span>After connecting to an ftp site, the mget command will upload multiple files.
</span><span>The </span>mget command<span>  retrieves multiple files from a remote server directory and stores them in the current local directory.
</span><span>ftp> mget <start of the like files> *
</span>

ftp> mget file01 file02 file03

ftp> mget filename*

ftp> mget *.txt

5 0
3 years ago
What kind of computer system you recommend?
In-s [12.5K]
Depends on your budget and usage.
If no/low budget and happy with speed of current computer - replace network card or get an USB network card to resolve no wifi signal issue.
If no problem with budget - get a brand new latest computer.

Remember, it’s your data in the computer that worth a lot,computer hardware doesn’t cost that much and can be easily replaced.
7 0
3 years ago
Question # 9
Ganezh [65]

Answer:

flight stimulators are used to train astronaut and design simple air craft

8 0
2 years ago
L a s t. i achieve 15 of 15 question on brainly.
Veseljchak [2.6K]
The Control key on a computer keyboard is a key that is used by pressing it in combination with other keys, enabling other keys on the keyboard to perform secondary functions. It is generally labeled as Ctrl.
4 0
3 years ago
How many slides would be in a PowerPoint presentation based on the formatting of the Word outline?
IrinaVladis [17]

Answer:

A. two

Explanation:

can i have brainliest please

5 0
3 years ago
Read 2 more answers
Other questions:
  • What is a critique of the feature detector model of object recognition?​?
    8·1 answer
  • if i set my payment and use free trial on Scribd website, can i cancel my payment and NOT PAYING after one month??
    8·1 answer
  • Which of the following statements is false? People tend to shortcut security procedures because the procedures are inconvenient.
    13·1 answer
  • When a Python script is running as a standalone program, what will the __name__ variable be set to?
    7·1 answer
  • Write a Python function called simulate_observations. It should take no arguments, and it should return an array of 7 numbers. E
    7·1 answer
  • Why is it important to be part of a team in times you fail and in times you succeed?​
    15·1 answer
  • 1. Which of the following is not related to a buffer overflow? A. Static buffer overflow B. Index error C. Canonicalization erro
    10·1 answer
  • In our discussion of Computer Hardware, we talked about three essential hardware components that are there inside every computer
    14·1 answer
  • Overnight Delivery Service delivers a package to Pam. At the request of Overnight's delivery person, to acknowledge receipt Pam
    13·1 answer
  • A group of users in a small publishing office want to share large image files in a common folder with high availability. Which o
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!