Warning: Trying to access array offset on value of type bool in /home/topgsnkq/timelyhomework.com/wp-content/themes/enfold/framework/php/function-set-avia-frontend.php on line 570

CMPSC 206 Computer Programming Python

2.12 Ch 2 Warm up: Variables, input, and type conversion (Python 3)

(1) Prompt the user to input an integer between 0 and 155, a float, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space. (Submit for 2 points).

Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user’s input value is shown on the next line, but such values don’t actually appear as output when the program runs.

Enter integer (0 - 155):_x000D_
99_x000D_
Enter float:_x000D_
3.77_x000D_
Enter character:_x000D_
z_x000D_
Enter string:_x000D_
Howdy_x000D_
99 3.77 z Howdy_x000D_

(2) Extend to also output in reverse. (Submit for 1 point, so 3 points total).

Enter integer (0 - 155):_x000D_
99_x000D_
Enter float:_x000D_
3.77_x000D_
Enter character:_x000D_
z_x000D_
Enter string:_x000D_
Howdy_x000D_
99 3.77 z Howdy_x000D_
Howdy z 3.77 99_x000D_

(3) Extend to convert the integer to a character by using the ‘chr()’ function, and output that character. (Submit for 2 points, so 5 points total).

Enter integer (0 - 155):_x000D_
99_x000D_
Enter float:_x000D_
3.77_x000D_
Enter character:_x000D_
z_x000D_
Enter string:_x000D_
Howdy_x000D_
99 3.77 z Howdy_x000D_
Howdy z 3.77 99_x000D_
99 converted to a character is c_x000D_

LAB

ACTIVITY

2.12.1: Ch 2 Warm up: Variables, input, and type conversion (Python 3)

2.13 Ch 2 Program: Cooking measurement converter (Python 3)

(1) Prompt the user for the number of cups of lemon juice, water, and sugar needed to make lemonade. Prompt the user to specify the number of servings the recipe yields. Output the ingredients and serving size. (Submit for 2 points).

Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user’s input value is shown on the next line, but such values don’t actually appear as output when the program runs.

Enter amount of lemon juice (in cups):_x000D_
2_x000D_
Enter amount of water (in cups):_x000D_
16_x000D_
Enter amount of agave nectar (in cups):_x000D_
2.5_x000D_
How many servings does this make?_x000D_
6_x000D_
_x000D_
Lemonade ingredients - yields 6.0 servings_x000D_
2.0 cup(s) lemon juice_x000D_
16.0 cup(s) water_x000D_
2.5 cup(s) agave nectar_x000D_

(2) Prompt the user to specify the desired number of servings. Adjust the amounts of each ingredient accordingly, and then output the ingredients and serving size. (Submit for 4 points, so 6 points total).

How many servings would you like to make?_x000D_
48_x000D_
_x000D_
Lemonade ingredients - yields 48.0 servings_x000D_
16.0 cup(s) lemon juice_x000D_
128.0 cup(s) water_x000D_
20.0 cup(s) agave nectar_x000D_

(3) Convert the ingredient measurements from (2) to gallons. Output the ingredients and serving size. Note: There are 16 cups in a gallon. (Submit for 2 points, so 8 points total).

Lemonade ingredients - yields 48.0 servings_x000D_
1.0 gallon(s) lemon juice_x000D_
8.0 gallon(s) water_x000D_
1.25 gallon(s) agave nectar
 
"Looking for a Similar Assignment? Order now and Get 10% Discount! Use Code "GET10" in your order"

If this is not the paper you were searching for, you can order your 100% plagiarism free, professional written paper now!

Order Now Just Browsing

All of our assignments are originally produced, unique, and free of plagiarism.

Free Revisions Plagiarism Free 24x7 Support