a = pow(2,3)
print(a)
8
b = complex(2,3)
print(b)
(2+3j)
from math import sin
c = sin(5)
print(c)
-0.9589242746631385
import numpy as np
d = np.sin(5)
print(d)
-0.9589242746631385
f = complex(5,3)
print(f)
(5+3j)
g = complex(imag=3,real=5)
print(g)
(5+3j)
def plus3(n):
out = n + 3
return out
h = plus3(2)
print(h)
5
def tri_area(b,h):
area = 0.5*b*h
return area
k = tri_area(2,5)
print(k)
5.0
# Create a function that calculates the distance an object will fall in a certain amount of time
# d = 0.5 * g * t**2
# on earth g=9.81 m/s^2
# on the mooon g=1.62 m/s^2
def fall_dist(t,g=9.81):
d = 0.5*g*t**2
return d
# calculate the distance an object falls on earth in 3 seconds
m = fall_dist(3)
print(m)
44.145
# calculate the distnace an object falls on the moon in 3 seconds
n = fall_dist(3,g=1.62)
print(n)
7.290000000000001
help(pow)
Help on built-in function pow in module builtins: pow(x, y, z=None, /) Equivalent to x**y (with two arguments) or x**y % z (with three arguments) Some types, such as ints, are able to use a more efficient algorithm when invoked using the three argument form.
help(fall_dist)
Help on function fall_dist in module __main__: fall_dist(t, g=9.81)
def fall_dist(t,g=9.81):
"""
The fall_dist() function calculates the distance an object falls in a given amount of time
input: time, int or float and optionally g= int, or float for the acceleration due to gravity, default g=9.81
output: fall distance, int or float
m = fall_dist(3)
print(m)
44.145
n = fall_dist(3,g=1.62)
print(n)
7.290000000000001
"""
d = 0.5*g*t**2
return d
help(fall_dist)
Help on function fall_dist in module __main__: fall_dist(t, g=9.81) The fall_dist() function calculates the distance an object falls in a given amount of time input: time, int or float and optionally g= int, or float for the acceleration due to gravity, default g=9.81 output: fall distance, int or float m = fall_dist(3) print(m) 44.145 n = fall_dist(3,g=1.62) print(n) 7.290000000000001
%ls
Volume in drive C is Windows Volume Serial Number is B899-AB94 Directory of C:\Users\student\Desktop 10/22/2019 02:37 PM <DIR> . 10/22/2019 02:37 PM <DIR> .. 10/22/2019 02:02 PM <DIR> .ipynb_checkpoints 10/22/2019 01:32 PM 1,457 Kaltura Capture.lnk 05/13/2016 01:33 PM 210 MSDS Online.url 10/22/2019 02:37 PM 57 myfuncs.py 08/01/2018 04:14 PM <DIR> Safety Information 10/22/2019 02:32 PM 9,322 Week5_notes_functions.ipynb 4 File(s) 11,046 bytes 4 Dir(s) 321,217,835,008 bytes free
import myfuncs
myfuncs.plus2(3)
5
from myfuncs import plus2
plus2(3)
5
import myfuncs
dir(myfuncs)
myfuncs.plus2(3)
5