I am completely stumped on this homework question and cannot figure out how to make the range count down, and I don't know what 5 characters wide means. or how to get the totals. and how to separate the two different multipls from odd and even.  I am able to make the range go from1-300.this is the homework question I have.program4_1.pyWrite a Python program that uses a for loop with the range function to inspect all integers from 300 down to 1. See page 170-172 to learn about the range function. Code in the loop should find exact multiples of 23 and print them in fields 5 characters wide on one line. The loop should also determine two totals; the total of the even multiples and the total of the odd multiples of 23. When the loop ends, the program should display these two totals.

Question
Asked Sep 19, 2019
395 views

I am completely stumped on this homework question and cannot figure out how to make the range count down, and I don't know what 5 characters wide means. or how to get the totals. and how to separate the two different multipls from odd and even. 

 I am able to make the range go from1-300.

this is the homework question I have.

program4_1.py
Write a Python program that uses a for loop with the range function to inspect all integers from 300 down to 1. See page 170-172 to learn about the range function. Code in the loop should find exact multiples of 23 and print them in fields 5 characters wide on one line. The loop should also determine two totals; the total of the even multiples and the total of the odd multiples of 23. When the loop ends, the program should display these two totals.

 

 

check_circle

Expert Answer

star
star
star
star
star
1 Rating
Step 1

Program Instructions:

  • Use -1 to decrement down the count.
  • The text can be made 5 characters wide by using %5d, also use end = “ “ to print the numbers in one line.
  • Separate the even and odd multiples and add them to get their total.
Step 2

Program:
even_multiples_total = 0

odd_multiples_total = 0

for i in range(300,1,-1):

  if i % 23 == 0:

    print("%5d"% (i),end="")

    if i % 2 == 0:

      even_multiples_total+=i

  &...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: 11,12,13

A: Two main advantages of storing data digitally rather than in analog format are:Data stored in digita...

question_answer

Q: Hello. I am having trouble with an assignment. When I run the program, it says: TypeError: can't mul...

A: To remove this “TypeError: can't multiply sequence by non-int of type 'float' “, we can use NumPy. N...

question_answer

Q: Show a derivation tree for w = aaabbaaa using the grammar in Example 5.1. EXAMPLE 5.1 The grammar G ...

A: Solution:Given that,w = aaabbaaa

question_answer

Q: Locate and list three examples of image map button bars on the Web, or of particularly creative uses...

A: Image map button are the hyperlink areas on an image and is created using specific image coordinates...

question_answer

Q: Load “Lock5Data” into your R console. Load “OlympicMarathon” data set in“Lock5Data”. This data set c...

A: First we install the Lock5Data package and then load the package. Then we load the library dplyr to ...

question_answer

Q: do big data could replace the artistic vision of a creative director? and why?

A: Justification:“Yes”, big data replace the artistic vision of a creative director.

question_answer

Q: Hi,please I need to use Python for the following: Use for loop to do the following: 1) print the num...

A: Program instructions:Use range() in for loop to print the numbers.Function range() has here argument...

question_answer

Q: What can you show me about Python rules and methods?

A: Note:The following summary is about some syntax rules followed in python and rules to define a metho...

question_answer

Q: Associate each of the following concepts with one of the languages we covered (pseudo code,FORTRAN, ...

A: Associating languages with given concepts:ALGOL 60: Pass by nameALGOL 60: Pass by valueFORTRAN: Assi...