Let's say we had a shop, MyShoppe, and wanted to prompt for the shop name. We...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Let's say we had a shop, MyShoppe, and wanted to prompt for the shop name. We would use: shopName = input("Please enter the shop name: ") This will store the user-entered shop name into the variable shopName. Let's prompt for the quantity of 2 items in the shop, a ring and glasses. ringQTY=input("Please enter ring QTY: ") glassesQTY = input("Please enter glasses QTY: ") Run the program as it is; it prompts for user input, but doesn't output anything. Let's add print statements for our current variables print("Shop name is {}".format(shopName)) print("Ring QTY is {}".format(ringQTY)) print("Glasses QTY is {}".format(glassesQTY)) Test the program. We can see that the program works and prints the correct quantities that we entered. Let's say we wanted to add up all of our inventory in our shop and print the total. Try: print("Inventory Total: {}".format(ringQTY+glassesQTY)) What do you think the inventory total will be if we have 4 rings and 5 glasses? Test it (run the program). Notice how the output is 45 and not 9. Why is that? Well, when you take a value from input it is a string value by default. So when we ask for the shop name, it is a string value. When we ask for the QTY, it is also a string value by default. What is happening when we add these 2 quantity string values is they are being concatenated. This means we need to convert the user entered values for QTY into integers, and we do this using casting. Modify the prompts to include casting: ringQTY = 77+] Uchiha Symbol Wallpaper on Wallpapers... ring QTY: ")) glassesQTY er glasses QTY: ")) https://www.google.com/url?sa=i&url=https%... Now run the program -- we get the value 9! Let's say we had a shop, MyShoppe, and wanted to prompt for the shop name. We would use: shopName = input("Please enter the shop name: ") This will store the user-entered shop name into the variable shopName. Let's prompt for the quantity of 2 items in the shop, a ring and glasses. ringQTY=input("Please enter ring QTY: ") glassesQTY = input("Please enter glasses QTY: ") Run the program as it is; it prompts for user input, but doesn't output anything. Let's add print statements for our current variables print("Shop name is {}".format(shopName)) print("Ring QTY is {}".format(ringQTY)) print("Glasses QTY is {}".format(glassesQTY)) Test the program. We can see that the program works and prints the correct quantities that we entered. Let's say we wanted to add up all of our inventory in our shop and print the total. Try: print("Inventory Total: {}".format(ringQTY+glassesQTY)) What do you think the inventory total will be if we have 4 rings and 5 glasses? Test it (run the program). Notice how the output is 45 and not 9. Why is that? Well, when you take a value from input it is a string value by default. So when we ask for the shop name, it is a string value. When we ask for the QTY, it is also a string value by default. What is happening when we add these 2 quantity string values is they are being concatenated. This means we need to convert the user entered values for QTY into integers, and we do this using casting. Modify the prompts to include casting: ringQTY = 77+] Uchiha Symbol Wallpaper on Wallpapers... ring QTY: ")) glassesQTY er glasses QTY: ")) https://www.google.com/url?sa=i&url=https%... Now run the program -- we get the value 9!
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these algorithms questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
In the 1D Arrays Unit, you created a command-line Contact Manager v1. Now upgrade the software to include a graphic user interface. Your contact manager must: Have a menu bar that provides access to...
-
1. Rick and Barbara are married with two children. Four yearsago, Barbara bought a $75,000 life insurance policy on her motherslife and named her children as policy beneficiaries. Barbara didnot name...
-
Using the information from Exercise 14-6, prepare a schedule showing the status of the appropriation at the end of the first quarter. In Exercise 14-6, 1. Receives a warrant from the Treasury...
-
Four securities have the following expected returns: A = 15%, B = 12%, C = 30%, and D = 22% Calculate the expected returns for a portfolio consisting of all four securities under the following...
-
What are prions? How do they reproduce?
-
Tammie contracted with Kristine to manufacture, sell, and deliver to Kristine and put in running order a certain machine. Once Tammie had set up the machine and put it in running order, however,...
-
1. (a) Calculate the Energy of Photons ejected from a 1.00-mm area of sodium metal by 500-nm EM radiation. (b) Given that the binding energy is 2.28 eV, what Kinetic Energy is carried away by the...
-
The following data relate to the operations of Shilow Company, a wholesale distributor of consumer goods: Current assets as of March 31: Cash $ 8,000 Accounts receivable 20,000 Inventory 36,000...
-
For the month of October, Kingston Sales Ltd. had the following transactions: $175,000 in sales plus HST; 30% of which were on account, the remaining sales were cash. The cost of the inventory sold...
-
Formal Research Report Assignment MARKETING 1. You work in the marketing department of a clothing and apparel company. Your supervisor is considering the idea of using social media to advertise your...
-
All of the following are general - purpose financial statements except a ( n ) cash budgetO statement of stockholders' equity income statement balance sheetSend
-
Hello hope your have a great day my question is I am making an assigment that I have to create an product to sell in Mcdanals and I picked to sell bun less vegetable burger with broccoli I am done...
-
Make a Brainstorming Mind Map or Concept Map about Business Example: TV network deals for coverage Small city teams vs. Large city teams Dependence on investors Player injuries Basketball & big...
-
I chose Medical Office Manager In this assignment, you will create a rsum. First, search online for a job posting for a position that interests you and for which you are qualified (or almost...
-
If Yxi+ +k and Y=1, work aut V.().
-
In exchange for land, the company received a 12-month note on January 1. The face amount of the note is $1,000, and the stated rate of interest is 13%, compounded annually. The 13% rate is equal to...
-
Joan is a self-employed attorney in New York City. Joan took a trip to San Diego, CA, primarily for business, to consult with a client and take a short vacation. On the trip, Joan incurred the...
-
Jerry made the following contributions during 2012: His synagogue (by check).....................................................$680 The Democratic Party (by check)...
-
For each of the following cases, indicate the filing status for the taxpayer(s) for 2012 using the following legend: A - Single B - Married, filing a joint return C - Married, filing separate returns...
-
A running mountain lion can make a leap 10.0 m long, reaching a maximum height of 3.0 m. a. What is the speed of the mountain lion just as it leaves the ground? b. At what angle does it leave the...
-
In punting a football, the kicker tries to maximize both the distance of the kick and its hang timethe time that the ball is in the air. A kicker gets off a great punt with a hang time of 5.0 s that...
-
Emily throws a soccer ball out of her dorm window to Allison, who is waiting below to catch it. If Emily throws the ball at an angle of 30 below horizontal with a speed of 12 m/s, how far from the...
Study smarter with the SolutionInn App