M01 Assignments

Introduction

The lessons for M01 concentrate on making sure you understand the basics of coding and running Python programs.

Unless otherwise specified for a specific assignment, you will always submit the .py program file to complete coding assignments. See these instructions for submitting assignments.

M01_Assignments

M01_Assn1: Exercise #1 (Display User Name and Age)

This is a very simple first assignment.

I suggest doing the following BEFORE you start coding:

  • Write a program that asks the user for a first name, last name and age (three separate prompts).
  • The age should be converted to an INT after it is entered. (2 lines of code)
  • Display what the user entered after each entry ("You entered ...")
  • display all the data in a single line that is similar to: John Smith is 29 years old!

Test values: I will use the following any first name, last name, and age to test your program. Your results should look very similar to the image below

M01_Assn Ex1 Test Output

Figure 1: M01_Assn1 #Ex1 Test Output

M01_Assn1: Exercise #2 (Calculate Cube Area)

Calculate the surface area of a cube. A cube has six sides that are the same size and shape. Once you know the area of 1 side (square), you need to multiply that by 6 to get the area of the entire cube. See this page for an explanation.

As with Exercise #1, prompt the user for the length of a single side of the cube, then convert the answer to an INT. (2 lines of code). Calculate the total area of the cube and display an informative message with the results.

Test values: I will test your program with multiple values such as 7, 6 and 5. Your results should look very similar to the image below

M01_Assn Ex2 Test Output

Figure 2: M01_Assn1 #Ex2 Test Output

M01_Assn2: Exercise #3 (Convert a Celsius Temperature to Fahrenheit)

This is your first significant assignment. As always, I suggest doing the following BEFORE you start coding:

These articles describe how to write Python programs for this course. Warning: simply pulling code off the Internet will NOTcut it (happens every session...). Programs must follow course standards, including creating a program header, prompting user correctly, and providing sufficient output. If you get help from others, make sure they understand the course standards.

The last item above is almost an exact copy of what you need for your code. It also explains how and why the code is written as it is written.

Assignment: Write a program that prompts the user for a Celsius temperature and convert it to Fahrenheit. If you are uncertain whether your calculation is correct, find an Internet source such as this converter and test your entries.

Test values: I will use the following 2 test values (32.0, 22.5). (Use the same value to test your program and confirm you get the correct results!). Your results should look very similar to the images below (the calculations should be exactly the same)

M01_Assn Ex1 Test Output 1

Figure 3: M01_Assn1 #Ex1 Test Output 1

M01_Assn Ex1 Test Output 2

Figure 4: M01_Assn1 #Ex1 Test Output 2

M01_Assn2: Exercise #4 (Calculate Meal Tip and Tax)

Read the article on Configuring User Prompts to correctly format your input prompt statement, accept the user input, and display results.

Make sure to include a program header at the top of your program and include multiple comments in your code.

Assignment: prompt the user for the amount charged for a meal, such as $22.50. Calculate a tip using 18% (.18) as the suggested tip rate. Calculate a state sales tax amount using a 7% tax rate (.07).

Display on separate lines the amount of the meal the user entered, the tip amount, the state sales tax amount, and the total amount that needs to be paid (meal + tip + tax).

Test values: I will use the following 2 meal amounts to test your program (100,00, 50.55). (Use the same value to test your program and confirm you get the correct results!). Your results should look very similar to the image below (the calculations should be exactly the same)>

M01_Assn Ex2 Test Output 1

Figure 5: M01_Assn1 #Ex2 Test Output 1

M01_Assn Ex2 Test Output 2

Figure 6: M01_Assn1 #Ex2 Test Output 2