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]
2 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]2 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
How do ethics affect people?
Mnenie [13.5K]
People are affected because ethics are suppose to be moral
5 0
3 years ago
Convert each of the fo" wing base ten representations to its equivalent binary form a. 6 b. 13 C. d. 18 e. 27
asambeis [7]

Answer:

6=110

13=1101

18=10010

27=11011

Explanation:

A decimal number is converted to binary number by constantly dividing the decimal number by 2 till the number becomes zero and then write the remainders in reverse order of obtaining them.Then we will get our binary number.

I will provide you 1 example:-

18/2 = 9   the  remainder =0

9/2 = 4    the remainder =1

4/2 = 2    the remainder =0

2/2 = 1     the remainder =0

1/2 = 0     the remainder =1

Writing the remainder in reverse order 10010 hence it is the binary equivalent of 18.

6 0
2 years ago
5 things that i learned about internet safty
Ksenya-84 [330]
1. To not put your real name in a username
2. Don't give people your personal information
3. Tell your parents if someone messages you something and you don't know them
4. make your social media accounts private
5. Ask for a adult for help if you see something that confuses you
7 0
3 years ago
Read 2 more answers
Filtering of packets as they leave the network destined for the internet is called ____________ .
e-lub [12.9K]
<span>Filtering of packets as they leave the network destined for the internet is called packet filtering. This firewall technique is also known as static filtering, and it is mainly used to control network access through the process of monitoring both outgoing and incoming packets. Along with monitoring, it functions to allow the packets to pass or halt which takes place based on the source of Internet Protocol.</span>
6 0
3 years ago
In company a, there is a team that performs day-to-day it operations with a focus on security. they are responsible for a wide r
jasenka [17]

The security operation being carried out by this team is Administrative in nature.

<h3>What is the role of an Administrators?</h3>

An Administrators is known to be a person who works or handles the day-to-day deployment, operation and looking of an IT environment.

Note that their areas of concern are the systems, networks and applications as well as others and as such, The security operation being carried out by this team is Administrative in nature.

Learn more about  security operation from

brainly.com/question/371967

#SPJ1

6 0
2 years ago
Other questions:
  • Two or more computers that transfer information between computers are called a
    7·1 answer
  • You press the power button in order to start your computer but hear nothing and see nothing. Name 2 possible reasons for this.
    6·1 answer
  • A base class named Garden contains a private field width and a property public int Width that contains get and set accessors. A
    11·1 answer
  • To read visual and audio text means
    11·1 answer
  • Assume the availability of class named DateManager that provides a static method, printTodaysDate, that accepts no arguments and
    11·1 answer
  • ______ is a customer-facing CRM application.<br><br> FAQ<br><br> Search<br><br> SFA<br><br> E-mail
    6·1 answer
  • PLEASE HELP. I’ll mark you BRAINLIST <br> Please read the comment under this question
    9·1 answer
  • Explain the computer according to size​
    10·1 answer
  • Hello i need help whats -5 = 500
    13·2 answers
  • What is meant by reflection?​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!