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
Add a clause for identifying the sibling relationship. The predicate on the left handside of the rule should be sibling(X, Y), s
jolli1 [7]

Answer:

following are the solution to this question:

Explanation:

For Siblings (X,Y);

Alice(X),

Edward(Y),

parent(Edward,Victoria,Albert) //Albert is the father F

parent(Alice,Victoria,Albert)  //Victoria is the Mother M

Therefore,

X is siblings of Y when;

X is the mother M and father is F, and  Y is the same mother and father as X does, and satisfing the given condition.

It can be written as the following prolog rule:

Siblings_of(X,Y):

parents(X,M,F)

parents(Y,M,F)

Siblings_of(X,Y): parents(X,M,F), parents(Y,M,F)

|? - sibling_of(alice,edward).

yes

|? - Sibling_of(alice,X).

X=Edward

|? - Sibling_of(alice,alice).

yes

5 0
3 years ago
Select the statements that describe Windows® desktops.
antoniya [11.8K]

Answer:

The Recycle Bin is a common desktop feature.

Shortcuts to frequently used programs can be added.

5 0
3 years ago
Read 2 more answers
Merlia is creating a presentation about her ethnic heritage for a homework assignment. Her friend John, a PowerPoint 2016 expert
Elanso [62]

Answer:

"apply to All"

Explanation:

The “Apply to All” button repeats a slide customization across all your slides, leaving them evenly. With this button, a modification made to one slide can be applied to all slides. This makes the power point presentation even and visually pleasing.

Since John told Merlia that it's often better to use the same slide transition consistently, we can conclude that John showed Merlia the "apply to all" button so she can apply the same transition to all slides in the presentation.

7 0
4 years ago
Help ASAP!!! During which phase of a well-structured study session is each occurring?
gladu [14]

Answer:

1. drill

2. discuss

3. review

4. prepare

Explanation:

Your Welcome!

7 0
3 years ago
Read 2 more answers
8. It is used to get qualitative data.​
frez [133]

Answer:

please give me brainlist and follow

Explanation:

Qualitative data describes qualities or characteristics. It is collected using questionnaires, interviews, or observation, and frequently appears in narrative form. For example, it could be notes taken during a focus group on the quality of the food at Cafe Mac, or responses from an open-ended questionnaire.

7 0
3 years ago
Other questions:
  • If the value of the expression,
    13·1 answer
  • Consider the following relational schema, where the primary keys are Bold,
    7·1 answer
  • The set of instructions that tells a computer
    12·2 answers
  • The drawback to copyright protection is that the underlying ideas behind the work are not protected, only their manifestation in
    9·1 answer
  • When can you message on brainly? My account says I have to answer more questions first.
    6·1 answer
  • What can your employer do to protect you from overhead power lines?
    13·1 answer
  • Write a function that simulates the roll of a six-sided dice. The name of the function is rollDice. The function accepts no para
    8·1 answer
  • Help<br> SOS<br> Quick <br><br><br><br><br> Hurry
    5·1 answer
  • How to recover deleted photos after deleting from recently deleted
    13·2 answers
  • Information technology student Roberta has been assigned a project on how to detect unwanted outgoing attacks. Which step is par
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!