Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Counting using while loops-Python
(Using Pycharm Community edition)
Ask the user for 3 inputs. Tell them NOT to use ZERO
1) the user inputs the a STARTING number
"User, what is the starting number of the range?" -- they enter 1
2) the user inputs an ENDING number for the loop.
User, what is the ending number of the range?" --- they enter 10
3) the user inputs the INCREMENT for the counter (increments of 1, 3, 4, 6, etc).
User, what is the increment of the range?" --- they enter 2
(Go back and look at the previous work on RANGE)
"User, what is the starting number of the range?" -- they enter 1
2) the user inputs an ENDING number for the loop.
User, what is the ending number of the range?" --- they enter 10
3) the user inputs the INCREMENT for the counter (increments of 1, 3, 4, 6, etc).
User, what is the increment of the range?" --- they enter 2
(Go back and look at the previous work on RANGE)
Using inputs, you will create FOUR while loops. Each loop will look similar in style to this :
while a <= ?:
print (a)
a = a + ?
Loop 1 and Loop 2 will use addition and multiplication to increase the count
Loop 3 and Loop 4 will use subtraction and division to decrease the count
Use the Starting number and Ending number and increments for ADDING / SUBTRACTING
Reverse the Starting number and the Ending number for SUBTRACTION / DIVISION
Example:
What is your starting number? 1
What is your ending number? 10
What is the increment you are going by? 2
addition and multiplication - starting number and ending number
ADDITION a = a + 2 | MULTIPLICATION a = a * 2
subtraction and division - reverse
The ENDING number MUST BE the STARTING number.
The STARTING number MUST be the ENDING number.
SUBTRACTION a = a - 2 | DIVISION a = a / 2
SUBTRACTION a = a - 2 | DIVISION a = a / 2
IDEA : you could set each counter to be a different letter...
a = 0 , b = 0, c = 0, d = 0.
a = 0 , b = 0, c = 0, d = 0.
Disclaimer - some of the operations do not have to work depending on when numbers are inputted for the start, end and increment
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Hi, I need help with a Java coding problem. Instructions: Create a loop to break a number into its digits. - Ask the user to enter another number - Use an if-else statement to determine if the number is positive or negative - Use a while loop to print the digits of the number entered. Sample Output: Enter a number: 6178 The number in the 1's place is 8. The number in the 10's place is 7. The number in the 100's place is 1. The number in the 1000's place is 6.arrow_forward• Write a program that asks the user to enter the size of a triangle (an integer from 1 to 10) • Display the triangle by writing lines of asterisks • The first line will have one asterisk, the next two, and so on, with each line having one more asterisk than the last line up to the number entered by the user. • On the following line, write one fewer asterisk and continue decreasing the number of asterisks by 1 for each successive line until only one asterisk is displayed. (Hint: Use nested for loops; the outside loop controls the number of lines to write, and the inside loop controls the number of asterisks to display on a line.) • For example, if the user enters 3, the output would be: Input Data: • An integer between 1 to 10 Set up an input validation loop to ensure the entered data is within range • As long as the entered data is not within range, the user is to be prompted repeatedly until the entered data is within range; at that point, then the valid input data is to be used to…arrow_forwardwhy would you choose to utilize a for loop as opposed to a while loop?arrow_forward
- Write a program that asks the user to enter the size of a triangle (an integer from 1 to 10) Display the triangle by writing lines of asterisks The first line will have one asterisk, the next two, and so on, with each line having one more asterisk than the last line up to the number entered by the user. On the following line, write one fewer asterisk and continue decreasing the number of asterisks by 1 for each successive line until only one asterisk is displayed. (Hint: Use nested for loops; the outside loop controls the number of lines to write, and the inside loop controls the number of asterisks to display on a line.) For example, if the user enters 3, the output would be: ** *** Input Data: An integer between 1 to 10 Set up an input validation loop to ensure the entered data is within range As long as the entered data is not within range, the user is to be prompted repeatedly until the entered data is within range; at that point, then the valid input data is to be used to set up…arrow_forwardwhy would you choose to utilize a for loop as opposed to a while loop?arrow_forwardA loop should output 1 to n. If n is 5, the output is 12345. What should XXXand YYY be? Choices are in the form XXX / YYY.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education