-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMethods.py
43 lines (35 loc) · 936 Bytes
/
Methods.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import math
import random
my_num = 66
pow(2, 2) #Takes first number to the power of second
abs(-10) #Gets absolute value
round(3.141592) #Rounds
lst = [1,2,3,4,5]
results = map(simple, lst)
print(list(results))
math.factorial(42)
42.5.ceil()
math.sqrt(4)
math.sqrt(2)
abc = ['b', 'c', 'd']
x = abc.index("c")
#Looks at all contents list
print(random.choices("a","b","c", k=5 )) #chooses random
print(f"This is my num {my_num}")
HelloWorld = "Hello World"
HelloWorld.Capatalize()
HelloWorld.find("o") #finds first instance of characters in string
HelloWorld.isalnum() #if it's alpha numerical
#islower(), isspace(), istitle(), isupper(), isdigit
HelloWorld.endswith("d") #True or false
HelloWorld.isdigit(x)#gets digit
lst = [1, 2, 3, 4]
bst = [4,5,6]
lst.insert(1, bst)#i
lst.extend(bst)#adds bst to lst
lst.pop(0) #remofes item at given index
lst.sort() #sorts list
#map
def upper(x):
return str(x).upper
map(upper, text)