Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer problems 3a, 3b, and 3c one by one. This question focused on the utilization of the for loops and nested loops. 1 Write
Please answer problems 3a, 3b, and 3c one by one.
This question focused on the utilization of the for loops and nested loops.
1 Write a program in Python and comment on each step.
This question focused on the utilization of the for loops and nested loops.
2 Only use the 'format' function, 'while', 'for', 'if', and 'else' loops. Do not write something like this in your program print("{:4d}".format(i+j), end=""), and do not use 'join', 'def' function.
Problem 3a: Addition Table Write a program that prompts the user for two integers that are greater than or equal to zero. Ensure that the first integer is less than the second integer. Next, write a program that generates an "addition table" using these numbers that computes the sums of all possible values - use the output below as a guide: Lowest number: -5 Lowest number must be 0 or greater Lowest number: 0 Highest number: 0 Highest number must be larger than lowest number! Highest number: 5 Here are some hints to get you started: - Don't worry about formatting your table until you have a basic version printing out correctly. - Start by generating the first line of output (the ' + ' sign and the column headings) - Next, generate the left most column (the row headings) - Big hint: Python prints from top to bottom, left to right. Before moving onto the next row, what do you have to do? Do you need another loop here? - When you're ready to format your table you need to ensure that no matter what there will always be room for all of your numbers. Hint: you might need to count the size of your largest possible value and use that as part of the "format" function. For example, notice how the spacing in the following tables always works out no matter the size of the values being printed: Part 3b: Addition Table Next, add in a feature that asks the user if they want to identify 'Prime' numbers in their table. If the user elects to show prime numbers you can print a lowercase ' p ' character after each prime number. Ensure that your table displays correctly, as described above. Lowest number: 0 Highest number: 10 Would you like to identify Prime numbers in your table? (y) : pikachu Invalid command, try again Would voll 1ikp to identifv Drime numbers in vour table? (y): y This program should be named as follows: LastNameFirstName_assign5_prob3b.py Part 4c: Addition Table (Extra Credit) Expand your program to support ALL of the arithmetic operators (+,,,/,// and %) - prompt the user for an operator to use and then display the desired table. Validate your data accordingly. Ensure that your tables print out using the expected formatting. Note that negative numbers are not considered Prime for the purpose of this part of the assignment. This program should be named as follows: LastNameFirstName_assign5_prob3c.pyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started