Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Imagine you have a set of squares and starting from the first square to the last, you are supposed to put n times the number

Imagine you have a set of squares and starting from the first square to the last, you are supposed to put n times the number of coins in the previous square to the next one. For example, if you start with m coins, you should continue by putting m*n, m*n2 , m*n3 coins to the following squares. The number of squares and the number of coins put on the first square will be determined by the user. After getting your inputs, you need to calculate how many coins will be on each square and in total.

In this homework you need to do the following with Python and using only IF statements (conditional statements), FOR loop, WHILE loop for complete this assignment:

- Ask user the number of squares, the multiplication coefficient (n) and the number of coins to put into the first square (m).

- All inputs should be positive integers. If you get an invalid input, your program should give a proper error immediately, before taking any other input and getting terminated.

- Calculate the number of coins on each square and print their sum at the end.

- Make sure you place comments in your program.

= + + 2 +

Sample screen output:

>>

Enter the number of squares: -3

Please enter an integer larger than zero!

>>

Enter the number of squares: 4

Enter the number of coins on the first square (m): -1

Please enter an integer larger than zero!

>>

Enter the number of squares: 4

Enter the number of coins on the first square (m): 2

Enter the multiplication coefficient (n): -6

Please enter an integer larger than zero!

>>

Enter the number of squares: 4

Enter the number of coins on the first square (m): 2

Enter the multiplication coefficient (n): 3

1 . square: 2 coins.

2 . square: 6 coins.

3 . square: 18 coins.

4 . square: 54 coins.

You got 80 coins in total!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

Question Can a self-employed person adopt a profit sharing plan?

Answered: 1 week ago