Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is in Python: Alter your code for previous Do It Now problem, with the change that the row should only be printed by the

This is in Python:

Alter your code for previous Do It Now problem, with the change that the row should only be printed by the second number that the user enters. For example, the user enters two numbers of 5 and 7 for the two input lines in the code, and the following will be printed:

5 x 1 = 5

5 x 2 = 10

5 x 3 = 15

5 x 4 = 20

5 x 5 = 25

5 x 6 = 30

5 x 7 = 35

*Previous Code that question refers to!*

Write a code to ask a number (one digit) from the user and prints the respective row of the multiplication table. For example, if the user enters 5, the following lines will be printed. Note that, if the user enters any number outside the range of 1-9, the program should display an error message.

5 x 1 = 5

5 x 2 = 10

5 x 3 = 15

5 x 4 = 20

5 x 5 = 25

5 x 6 = 30

5 x 7 = 35

5 x 8 = 40

5 x 9 = 45

5 x 10 = 50

num = int(input('Please enter the number : '));

while(num<1 or num>9):

num = int(input('Incorrect value entered, please re-enter : '));

for i in range(1,10):

print(num,' x ',i,' = ',num*i);

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions