Lab: Literals, Operators, Variables and Print#

We covered a lot today! This lab will help you build skill in doing the essential programming tasks of using literals, operators and variables. Along the way you’ve used the print() function a lot. The last part of the lab will give you more practice with print(), an essential funtion seeing what your program is doing!

Part 1: Literals#

In the cells provided write enter the literals that each question asks for. Run the cell to make sure that your literal is correct.

1. Integer#

Write an integer literal in the box below:

2. String#

Write a string literal in the box below:

3. Float#

Write a floating point number literal in the box below:

4. Boolean#

Write a boolean literal in the box below:

5. Scientific Notation#

Write Avogadro’s Number as a literal.

6. String#

Write your full name in the box below as a string literal.

7. Data Type#

In the box below use the type() function to determine the type of True

Part 2: Operators#

1. Modulus#

Write a program that computes and prints the value of 127 modulus 34.

2. Multiply#

Write a program that multiplies 234.4 by 5.

3. Compare Numbers#

Write a program that determines if 45.6 is less than 34.5

4. Multiply and Compare#

Write a program that determines if 4.2 times 45 is less than or equal to 345.3

5. Days#

Write a program that computes how many days there are in 20 years.

6. Mileage#

Write a program that computes how far your car can go if it gets 34.5 miles per gallon and has a 11.5 gallon tank.

7. How Much Gas#

Write a program that computes how much gas you need to go 200 miles if your car gets 34.5 miles per gallon.

8. A Lot of You#

Write a program that prints your name 100 times using the * operator.

2.9. Concatenation#

Write a program that concatenates three strings together using the + operator.

Part 3: Printing#

Part 4: Using Variables#

1. Add Variables#

Add the two variables named a and b. Start with the code already in the cell.

a = 12.3
b = 6.4

5. Print True or False#

Use the print function to print True if a is less than b. False otherwise.

6. Print True or False#

Use the print function to print True if a is greater than or equal to b. False otherwise.