Let us worry about your assignment instead!

We Helped With This Python Programming Assignment: Have A Similar One?

SOLVED
CategoryProgramming
SubjectPython
DifficultyCollege
StatusSolved
More InfoPython Assignments
15391

Short Assignment Requirements

I have five labs that I need to submit by EOD tomorrow. I can send the last two later, but they are all the same format. They are all "beginner" Python coding Labs and should only take minutes for someone who knows what they're doing.

Assignment Description

Purpose. The purpose of this exercise is to provide more practice in writing programs that (1) read numbers from an input file, (2) perform calculations, and (3) show output results.

Background. You know how to read multiple values from an input file. You know how to store them as numbers. You know how to addition, multiplication, and division. And you know how to echo input values and print calculated results. That's all you need to know in order to do this exercise.

Your Turn. Write a program that reads five numbers from input prompts, adds them to get their total, and calculates their average by dividing their total by 5. For these numbers, use the present temperatures from 5 different cities in the world — degrees C or F — your choice. The output should something like this:

The total of 67.6 87. 7 67.8 56. 8 89.9 1 s 369 . 8øØØØØØOØøø007

The average of 67.6 87. 7 67.8 56. 8 89.9 1 s 73. 96øØØØØØØØØ001

But wait — let's do something about all those zeros! Here's how to round off a number to a maximum of two decimal digits, using a variable name "average" for storing the calculated average:

overage

overage

Statements like this belong in the calculations code block, after the variable "average" gets calculated and before "average" gets printed in the output code block, like this:

G average averaoe

b

c

d average

This is the first time we're seeing a calculation that has the same variable name appearing twice. In this case, the original number stored in average (in this case, 73.96000000000001) gets replaced with an updated, rounded-off value (in this case, it should be 73.96). Apply this, so that your program shows something like this:

The total of 67.6 87.7 67.8 56.8 89.9 is 369.8

The average of 67.6 87. 7 67.8 56.8 89.9                                  73.96

I also rounded the total to one decimal digit before printing it, using the following: notice the pattern?

Submitting Your Work. Submit your work as you did in previous exercises, submitting the contents of the repl.it "edit" box.


Comsc 101                                                             Page I of2                                    Programming Exercise 7

For the second program:

Calculate the total miles driven, the average miles driven for the five days.

The amount of gas used to drive these total miles and the miles per gallon used for the total trip.

Use all the information you learned at the beginning of this lesson.

This is the log for the trip. Input the following.

Day I

256 miles driven using 1 1 gallons

Day 2

276 miles driven using 13 gallons

Day 3

296 miles driven using 16 gallons

Day 4

210 miles driven using 1 1 gallons

Day 5

83 miles driven using 9 gallons

Submitting Your Work. Submit your work as you did in previous exercises, submitting the contents of the repl.it "edit" box. Name this program: Exercise 7 B

Comsc 101                                                             Page 2 of 2                                   Programming Exercise 7

Assignment Description

Programming Exercise 6: Doing The Math

Purpose. The purpose of this exercise is to show the difference between two types of data — text and numbers, and how math computations can be performed with numbers. It also demonstrates how comments can be placed anywhere — not just in the comment block. See the sample below.

Background. In all previous exercises, the input got read as text. That's the default for Python. Even if the text involves digits and is intended as a number, it is still just text. That is, the computer does not distinguish between letters and numbers on the keyboard — it's all just series of keystrokes. Remember adding the first and last names in the previous assignment? Adding 1 and 1 in the same way would result in 11. Try this:

1

2

3

4

5

     6 b  input('b: ')

8                                                                         

9                 c       a         b

10

  11  print (a, 'plus' , b

 

 

I plus i equalB Il None

To specify that a variable should store a number, do something like this, for a decimal use float or for a whole number use int . )

1 z 3 4

S 6

8

9

11

        Pot, St                

L xe ec•i ss_

a

b   floatanput('b: t

           cal c                           print (a,

)) bloc K

equals' , c)

 

 

1.0 plug 1.0 equals 2.0 None

"float" is an abbreviation for "floating point number". The "floating point" is the decimal in numbers that have a fractional part — like 1% is 1.5, and the period in 1.5 is the "floating point".

PROGRAM 1: Your Turn. Write a program that converts a temperature (from an input prompt) from degrees Centigrade to degrees Fahrenheit. The calculation is f 9 * c / 5 + 32, where c is the temperature in degrees C (the input), and f is degrees F (the output). You recognize the plus sign, but what are these others — the slash and the asterisk? / is for division; * is multiplication. This multiplies 9 times degrees C, divides that result by 5, and then adds 32.

Comsc 101     Page I of 2      Programming Exercise 6 Your output should look like this: 100 . 0 degrees c equals 212 . 0 degrees F. It should "echo" the value read from an input prompt (in this case, 100.0) and print the calculated variable (here, 212.0), with nice labeling to identify each.

Check your work by comparing these easy reference points: -40C is -40F (the only point where C and F are the same), OC is 32F (the freezing point of water), and IOOC is 212F (the boiling point of water)

Convert the following: 12 c, 45 c, 32 c 75 c.

Submitting Your Work. Do a snippet of the code and printout, and paste the image to a word document or copy and paste the code onto a word document and Submit your work as you did in previous exercises. Label the program Exercise 6.

Program 2: When given an unknown length in inches, calculate how many centimeters it is.

Write a program in which a user will input a number in inches and the computer will convert the inches to centimeters.

The input number must be a decimal number.

               Input these numbers: 34.75,         45.67,       10,       12.5

There are 2.54 centimeters per inch.

Copy the codes to word document and submit as program "Exercise 6C

Comsc 101                                                             Page 2 of 2                                   Programming Exercise 6

Assignment Description

Programming Exercise 5A: Doing Text “Concatenation”

Purpose. The purpose of this exercise is to show how text stored in variables can be concatenated, or joined, to form new text sequences. It allows you to control spacing!

This introduces a new code block that comes between the variables code block and the output code block. It’s the “calculations code block”. It creates additional variables, but their values are not hard-coded, and not interactive (from input statements). They are calculated based on values stored in other variables.

Background. Here’s how to concatenate variables containing text. Presuming that the variables myFirstName and myLastName already exist, we can create new variables like this:

 

 


Then you can simply print one of these new variables, like this: print(myName).

Note that concatenation does not include spacing like the print statements with multiple, comma-separated values does. So the programmer has to put these in, like the text with one spacebar character separating first and last name above, and the space after Ms. above.

Your Turn. Rewrite the program from exercise 4 so that there are no print statements with multiple, comma-separated values. Create concatenated variables in a calculations code block to combine into new variables what’s in each of exercise 4’s print statements. Even if a print statement has just one text value (like print('Congratulations!')), store that is a variable in the calculations code block. Each print statement should print a variable, only.

Don’t get the idea that print statements should always print just variables, and that text should always be concatenated for later printing – that’s not the case at all. We’re just doing so here in order to show how concatenation works.

Submitting Your Work. Use the Snippet’s edit program.  Copy the code you used and the results. Submit your work contents of the repl.it “edit” box.

Customer Feedback

"Thanks for explanations after the assignment was already completed... Emily is such a nice tutor! "

Order #13073

Find Us On

soc fb soc insta


Paypal supported