1. Write a program that utilizes string literals and variables. 2. Differentiate between a literal and a variable. 3. Write a program that calculates the average of multiple values. nts NOTES: You...


1. Write a program that utilizes string literals and variables.<br>2. Differentiate between a literal and a variable.<br>3. Write a program that calculates the average of multiple values.<br>nts<br>NOTES: You will submit two files after completing this homework:<br>• ONE source files: yourName_LAB2.py<br>• One image files: jpg. yourName LAB2_output.jpg.<br>NOTE: Separate the parts of the lab by outputting the question # and printing a line.<br>Directions<br>carch<br>1. Variables and literals<br>. Read all the directions before you start coding!<br>• You will create a program, in your IDE, that uses a variable<br>• Define a variable, something like var1.<br>- Then assign the number 5 to your variable. If you need help with this refer to the Variable page here in Canyas. This should be the first line of your program and it should look something like this. Use the numeric value of 5 instead of 0:<br>- Next write code to print the following statement on your screen: My favorite number is 5<br>. You should use the print function (print

Extracted text: 1. Write a program that utilizes string literals and variables. 2. Differentiate between a literal and a variable. 3. Write a program that calculates the average of multiple values. nts NOTES: You will submit two files after completing this homework: • ONE source files: yourName_LAB2.py • One image files: jpg. yourName LAB2_output.jpg. NOTE: Separate the parts of the lab by outputting the question # and printing a line. Directions carch 1. Variables and literals . Read all the directions before you start coding! • You will create a program, in your IDE, that uses a variable • Define a variable, something like var1. - Then assign the number 5 to your variable. If you need help with this refer to the Variable page here in Canyas. This should be the first line of your program and it should look something like this. Use the numeric value of 5 instead of 0: - Next write code to print the following statement on your screen: My favorite number is 5 . You should use the print function (print "blah blah blah") to do this. - Do not code the 5 as a literal 51. it should be a number (so no quotes around it). • You should use your variable, in a print statement, to print the value, such as: print("My favorite number is ", number) Where number in the example is your variable name. - Using a variable in your print statement makes your statement more robust. If the value changes say to 42 then you don't have to change your print statement it will display the, correct, new number. Try running your program multiple times changing your number each ti Pay attention to what happens with the output. - Name the source code file: yourName_LAB2_1 py. - Run the program. - Capture the output and save it as an image file named yourName_LAB2_output1.jpg - Continue with this code in problem #2. 2. Variables and literals, Again - Now, using your program from #1. put double quotes around the variable in your print statement. In my example it would be number. Save it as a new file, yourName_LAB22 py., and run the program again. Your code should look like this: print"My favorite number is", "number) - Capture the output and save it as an image file named yourName_LAB2_output2 jpg. Do you see the different between the two outputs? Submit the py file and both jpg files. - In your submission box on Canvas, include a short explanation on why the two outputs are different. 3. Average of values - When we want to find the average of a set of numbers we add the values up and then divide the sum by the number of values. • Create 5 variables that stores the following values, one in each variable: 28, 32, 37, 24, and 33. If you need help with this refer to the Variable page here in Canvas - Your program should next calculate the sum of these five variables and store the result in a separate variable named sum. - Next the program should divide the sum variable by 5 (the number of values) to get the average. You should store the average in a new variable, like something called results. - Display, by using the print function, the average on the screen. Tip: add the variables together not the actually numbers. Something like mySum - a+b+c - Name the source code file yourName_HW2.py. - Compile and run the program. Capture the output console and save it as an image file named yourName LAB2_output jpg - Submit 1 py files and 1 image files through Canvas Here is a sample of your output:
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here