Programming Assignment: Homework 1a - Math Practice
Math Practice
#########################################################
### EXECUTE THIS CELL BEFORE YOU TEST YOUR SOLUTIONS ###
#########################################################
import imp
sol = imp.load_compiled("sol", "./sol.py")
from nose.tools import assert_equal
Calculate the result of 3.93 multiplied by 4901 and save it in a variable named 'q1', then print it out.
q1 = 3.93 * 4901
print(q1)
Calculate the result of 215 divided by 6 and save it in a variable named 'q2', then print it out.
q2 = 215 / 6
print(q2)
Calculate the result of 3 divided by 0.3 and save it in a variable named 'q3', then print it out.
q3 = 3 / 0.3
print(q3)
Calculate the remainder of 215 divided by 6 and save it in a variable named 'q4', then print it out.
q4 = 215 % 6
print(q4)
Calculate the value of 9 raised to the 12th power and save it in a variable named 'q5', then print it out
q5 = 9 ** 12
print(q5)
Cast 3.5 to an integer and save it in a variable named 'q6', then print it out.
q6 = int(3.5)
print(q6)
Data Types Practice
Calculate the data type of "False"
(notice the quotes around the word False!) and save it in a variable named 'q7', then print
q7 = type("False")
print(q7)
Calculate the data type of True and save it in a variable named 'q8', then print it out.
q8 = type(True)
print(q8)
Calculate the data type of the result of 1000 divided by 10 and save it in a variable named 'q9', then print it out.
q9 = type(1000 / 10)
print(q9)
Cast the value of 6.3 divided by 3.8 to an integer. Save it in a variable named 'q10', then print it out.
q10 = int(6.3 / 3.8)
print(q10)
String Practice
Concatenate the strings 'James', 'Brian', and 'Patrick' - store the result in a variable called 'q11', then print it out. Make sure to add a single empty space between the names!
q11 = 'James' + ' ' + 'Brian' + ' ' + 'Patrick'
print(q11)
Make the following string correct, storing it in a variable named 'q12':q12 = "4 % 2 = " + (4 % 2))
q12 = "4 % 2 = " + str(4 % 2)
print(q12)
Save the following quote, (including the double quotes), in a variable called 'q13', then print it:
Albert Einstein's best quote is "I have no special talent. I am only passionately curious."
q13 = 'Albert Einstein\'s best quote is "I have no special talent. I am only passionately curious.\"'
print(q13)