Python Functions

1) Write a function that calculates the volume of a sphere with radius r for only values > 0, return 0 otherwise . V=4/3  π r^3

2)  Write a function that finds you weight in stones using the formula.  mstone = mkgx2.2/14

3) Write a function that takes some monetary amount from the user in dollars, and then display exact changes for this amount using the minimum number of coins. For example, $0.97 shows 3 quarters, 2 dimes, and 2 pennies. 

 

Output: 
change_it(97)

The change for 97 cents is:
3 quarters
2 dimes
2 pennies

 Write an function to calculate both Ohm’s Law and Power transferred. The function takes i and r as inputs and prints the results (see output below). Calculate only if both i and r are > 0. 

 

FORMULA
 i is current, v is voltage, r is resistance, p is power
 p = i * v   # power = current * volatage
 v = i * r   # voltage = current * resistance
def ohms_law(i, r): 
   '''
     i is current
     r is resistance
   '''
   # check if both i and r are greater than 0
   # calculate v and p
   # PRINT v and p
omhs_law(5, 5)
v = 25 p = 125

omhs_law(-5, -5)
0
Tags: No tags