1. The following program demonstrates the use of format() function to format a string. Please rewrite...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. The following program demonstrates the use of format() function to format a string. Please rewrite program by using 'f-string' method to generate the same outputs. (2* 4points) [1] stri= 'The area of (01s) is (11,d) square miles str2 = 'The population of (018) is (11.21) of the U.S. population state Florida area 65758 population 21780000 total 331900000 [2] print(stri.format(state, area)) print (str2.format(state, population/total)) The area of Florida is 65,758 square miles The population of Florida is 6.56% of the U.S. population 2. Write a function meal_total() that calculates the total amount of a meal purchased at a restaurant. The function should ask the user to enter their name, the charge for the food, what percent tip, and 7 percent sales tax. Display each of these amounts and the final total amount along with the user name when calling the function. (8 points) 3. Write a function generateLogin(first, last, zipc) that takes 3 parameters first, last and zipc. The function generates and returns a login name for a user given their firstname, lastname, and zipcode such that it has every other character of their first, last, and zipcode in the respective order and returns this login name all in uppercase. (function 6 points & formatting 6 points). Here is an example, use input() to serve varying end users' information. Input o Firstname: Mingyan o Lastname: Xu o Zipcode: 33602 Output Generated login: MNYNX362 1. The following program demonstrates the use of format() function to format a string. Please rewrite program by using 'f-string' method to generate the same outputs. (2* 4points) [1] stri= 'The area of (01s) is (11,d) square miles str2 = 'The population of (018) is (11.21) of the U.S. population state Florida area 65758 population 21780000 total 331900000 [2] print(stri.format(state, area)) print (str2.format(state, population/total)) The area of Florida is 65,758 square miles The population of Florida is 6.56% of the U.S. population 2. Write a function meal_total() that calculates the total amount of a meal purchased at a restaurant. The function should ask the user to enter their name, the charge for the food, what percent tip, and 7 percent sales tax. Display each of these amounts and the final total amount along with the user name when calling the function. (8 points) 3. Write a function generateLogin(first, last, zipc) that takes 3 parameters first, last and zipc. The function generates and returns a login name for a user given their firstname, lastname, and zipcode such that it has every other character of their first, last, and zipcode in the respective order and returns this login name all in uppercase. (function 6 points & formatting 6 points). Here is an example, use input() to serve varying end users' information. Input o Firstname: Mingyan o Lastname: Xu o Zipcode: 33602 Output Generated login: MNYNX362
Expert Answer:
Answer rating: 100% (QA)
Answer 1 Using fstrings for string formatting state Florida area 65758 population 21780000 total 331... View the full answer
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
1. (3 Marks) You are given the following C program: #include #include #include int main(void) { int var 80; pid t pidA-1, pidB= -1; printf("before fork "); if ((pidA = fork()) < 0) { printf("fork...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Express the following directions by two other means; set up and fill in a table with three columns, one for bearing, one for azimuthN (AzimN), and one for azimuths (Azims): a. N 3040'E b. AzimN...
-
Calculate S (for the system) when the state of2.00 mol diatomic perfect gas molecules, for which Cp,m = 7/2 R, is changed from 25C and 1.50 atm to 135C and 7.00 atm. How do you rationalize the sign...
-
A solution was prepared by dissolving 5.76 g of KCl MgCl2 6H2O (277.85 g/mol) in sufficient water to give 2.000 L. Calculate (a) The molar analytical concentration of KCl MgCl2 in this solution....
-
Suppose the economys labor market is competitive and that labor demand can be written as w = 50 0.3E while labor supply can be written as w = 8 + 0.2E where E is the total amount of employment in...
-
Roy Akins was the accounting manager at Zelco, Inc., a tire manufacturer, and he played golf with Hugh Stallings, the CEO, who was something of a celebrity in the community. The CEO stood to earn a...
-
A block slides down a ramp that has a coefficient of kinetic friction of 0.2. The ramp makes an angle of 15 degrees with the horizontal. What is the total force that the block feels if its mass is 3...
-
Forecasting with the Parsimonious Method and Estimating Share Value Using the ROPI Model Following are income statements and balance sheets for Cisco Systems. Cisco Systems Consolidated Statements of...
-
Looking back on the last 14 weeks of course material, explain one element or characteristic of the U.S. legal system that stood out to you compared to your own country's legal system. If your...
-
X Corporation has a value of $200,000,000 and has a capital structure comprised of 200,000,000 issued and outstanding shares of common voting stock, so that the common voting stock immediately before...
-
How do genetic mutations affect organogenesis and embryonic patterning?
-
Summarize the following: The ideal scenario is when any factor influencing the analyte signal also impacts the internal standard signal in a similar way. This is done to ensure that the effects on...
-
How do obligate anaerobic bacteria adapt to environments devoid of oxygen, and what metabolic pathways do they utilize for energy production?
-
How do cellular signaling pathways regulate tissue patterning and differentiation during embryogenesis?
-
(a) Give comparison between squirrel cage and slip ring induction machine? Discuss the working principle of three phase induction motor. (8) (b) State different methods of speed control of three...
-
Write the given system without the use of matrices. D) - ()- d (x sin t + 8 (2+ 1)
-
Define the term normalization.
-
Clancys is interested in graphical output for its DSS. It wants to see a graphical comparison of how many of each style of uniform are being sold each year. a. Choose an appropriate graph style and...
-
How does Ajax improve a Web page that changes based on user actions?
-
Understanding the Feds actions that are needed to stabilize the interest rate The diagram below shows three different money demand curves and a target interest rate i*. Fill in the table below using...
-
This section looks at US recessions over the past 60 years. To work out this problem, first obtain quarterly data on US output growth for the period 1960 to the most recent data from www.bea.gov....
-
This question asks you to examine the movements of investment and consumption before, during and after the recession of 2001. It also asks you to consider the response of investment and consumption...
Study smarter with the SolutionInn App