Question

In: Computer Science

This is in Python: Alter your code for previous Do It Now problem, with the change...

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);

Solutions

Expert Solution

//pls provide +ve rating,thanks!

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

while(num<1 or num>9):

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

limit = int(input('Please enter the limit : '));

while(limit<1 or limit>9):

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

for i in range(1,limit+1):

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

#################################

#output

Please enter the number : 5
Please enter the limit : 7
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

//screenshot


Related Solutions

fix this code in python and show me the output. do not change the code import...
fix this code in python and show me the output. do not change the code import random #variables and constants MAX_ROLLS = 5 MAX_DICE_VAL = 6 #declare a list of roll types ROLLS_TYPES = [ "Junk" , "Pair" , "3 of a kind" , "5 of a kind" ] #set this to the value MAX_ROLLS pdice = [0,0,0,0,0] cdice = [0,0,0,0,0] #set this to the value MAX_DICE_VAL pdice = [0,0,0,0,0,0] cdice = [0,0,0,0,0,0] #INPUT - get the dice rolls i...
C++ CODE Change your code from Part A to now present a menu to the user...
C++ CODE Change your code from Part A to now present a menu to the user asking them for an operation to perform on the text that was input. You must include the following functions in your code exactly as provided. Additionally, you must have function prototypes and place them above your main function, and the function definitions should be placed below the main function. Your program should gracefully exit if the user inputs the character q or sends the...
I would like the following code in PYTHON please, there was a previous submission of this...
I would like the following code in PYTHON please, there was a previous submission of this question but I am trying to have the file save as a text file and not a json. Any help would be greatly appreciated. Create an application that does the following: The user will enter product codes and product numbers from the keyboard as strings. The product code must consist of four capital letters. The product number can only consist of numeric characters, but...
Implement the following function by replacing the pass keyword with your code. Do not change the...
Implement the following function by replacing the pass keyword with your code. Do not change the spelling of the function name or the parameter list. def order_pie(): Important notes: Ask ONLY these questions, in EXACTLY this order. Do not ask more questions than are necessary to arrive at the right answer. You can expect the input values to be 'yes' or 'no'. For this assignment you do not have to worry about other spellings or capitalization. The return values must...
construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should...
construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should include two heuristic functions -misplaced tiles and calculation of manhattan distance. The code should work for all cases of puzzle.
Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
Create a code showing Arduino IMU data being plotted by your Python code.  
Create a code showing Arduino IMU data being plotted by your Python code.  
This is my code for python. I am trying to do the fourth command in the...
This is my code for python. I am trying to do the fourth command in the menu which is to add an employee to directory with a new phone number. but I keep getting error saying , "TypeError: unsupported operand type(s) for +: 'dict' and 'dict". Below is my code. What am I doing wrong? from Lab_6.Employee import * def file_to_directory(File): myDirectory={}       with open(File,'r') as f: data=f.read().split('\n')    x=(len(data)) myDirectory = {} for line in range(0,199):      ...
For this problem, you should: describe the algorithm using aflowchart and thenwrite Python code...
For this problem, you should: describe the algorithm using a flowchart and thenwrite Python code to implement the algorithm.You must include:a.) a picture of the flowchart you are asked to create,b.) a shot of the Python screen of your code, andc.) a shot of the Python screen of your output.Program Requirements: Your application will implement a stopwatch to beused during a 1500-meter race in a swimming match. The input to theapplication will be the number of seconds for two different...
In Python we will be using the below code for the problem: rainfile=open('rainfall.txt') for line in...
In Python we will be using the below code for the problem: rainfile=open('rainfall.txt') for line in rainfile: values = line.split() #print(values) print (values[0], 'had', values[1], 'inches of rain.') rainfile.close( ) The following is the text from rainfall.txt Akron 26.81 Albia 37.65 Algona 30.69 Allison 33.64 Alton 27.43 AmesW 34.07 AmesSE 33.95 Anamosa 35.33 Ankeny 33.38 Atlantic 34.77 Audubon 33.41 Beaconsfield 35.27 Bedford 36.35 BellePlaine 35.81 Belleveu 34.35 Blocton 36.28 Bloomfield 38.02 Boone 36.30 Brighton 33.59 Britt 31.54 Buckeye 33.66 BurlingtonKBUR...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT