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
How does human error relate to security risks
oksian1 [2.3K]

Answer:

The error could let people through who really shouldn't be through

8 0
3 years ago
___ Jacking is a crime that takes place when a hacker misdirects URL to a different site. The Link Itself Looks Safe, But the us
const2013 [10]

Answer: Web Jacking

Here, the hacker takes control of a web site fraudulently. He may change the content of the original site or even redirect the user to another fake similar looking page controlled by him.


If you have any other questions about computers or even hacking hit me up because I know a lot about computers

6 0
3 years ago
Which of these statements describes the difference between binary and decimal numbers?
ElenaW [278]

Answer:

A

Binary numbers use only the digits 0 and 1; decimal numbers use 0 through 9.

Explanation:

Binary means in couples of two. So you count using 0s and 1s like 01, 10, 11, 100, 101, 110, 111, and so on.

7 0
3 years ago
Read 2 more answers
is an interviewing method in which a mall interviewer intercepts and directs willing respondents to nearby computers where each
geniusboy [140]

Answer:

computer-assisted self-interviewing

Explanation:

Based on the description of the interviewing method that is being provided, it can be said that this method is known as computer-assisted self-interviewing. Like mentioned in the question this is when interviewees answer the interview questions through a computer screen. This is similar to telephone interviews but it is instead through a computer.

3 0
3 years ago
How can you relate the careers in Finance as BSIS students?
Vinvika [58]

Explanation:

Banker.

Accountant.

Financial advisor.

Financial analyst.

Investment manager.

Insurance agent.

Financial analyst.

Financial associate.

Financial planner.

Investment analyst.

Budget analyst.

hope it helps

8 0
3 years ago
Other questions:
  • The rules that determine what is allowed in a program are known as the
    14·1 answer
  • A dendrochronologist interprets:
    10·2 answers
  • "A switch passes data based on the MAC address."A. TrueB. False
    15·1 answer
  • Write a function called print_function that takes integer number as argument and prints the following pattern if input is 3
    14·1 answer
  • Can some one help me i do not now how to give a BRANLEST. if you help i will give you one BRANLEST.
    7·2 answers
  • Write a program that creates a Date object, sets its elapsed time to 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10
    9·1 answer
  • How will you define a text?
    10·1 answer
  • What are the four components of security documentation?
    9·1 answer
  • In your own view, how can social media be used in teaching and learning in higher education?
    10·1 answer
  • In which directory would a system administrator store scripts that should be run monthly by the cron daemon?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!