Python Programming
1.
Write the following Python expressions in mathematical notation.
a.
dm = m * (sqrt(1 + v / c) / sqrt(1
-
v / c)
-
1)
b.
volume = pi * r * r * h
c.
volume = 4
* pi * r ** 3 / 3
d.
z = sqrt(x * x + y * y)
2.
What are the values of the following expressions? In each line, assume that
s = "Hello"
t = "World"
a.
len(s) + len(t)
b.
s[1] + s[2]
c.
s[len(s) // 2]
d.
s + t
e.
t + s
f.
s * 2
3.
Write a program that prompts the user to input an integer that represents cents. The program will then calculate the smallest combination of coins that the user has. For example, 27 cents is 1 quarter,0 nickle, and 2 pennies.
That is 27=1*25+0*5+2*1
1. a. import math dm = m * (math.sqrt(1 + v / c) / math.sqrt(1-v / c)-1) b. import math volume = math.pi * r * r * h c. import math volume = (4 * math.pi * r ** 3) / 3 d. import math z = math.sqrt(x * x + y * y) ================================ 2. s = "Hello" t = "World" a. len(s) + len(t) is 10 b. s[1] + s[2] is 'el' c. s[len(s) // 2] is 'l' d. s + t is 'HelloWorld' e. t + s is 'WorldHello' f. s * 2 is 'HelloHello' ================================ 3. amount = eval(input("Enter amount in cents: ")) print((amount//25),"quarters,",end=" ") amount = amount % 25 print((amount//10),"dimes,",end=" ") amount = amount % 10 print((amount//5),"nickles,",end=" ") amount = amount % 5 print(amount,"pennies.")
Get Answers For Free
Most questions answered within 1 hours.