|
Variable
|
sth that can change
|
|
String
|
a list of characters
|
|
Integer number
|
Whole number/counting number
|
|
Float number
|
The number in decimal
|
|
Syntax
|
Grammar/Structure of language
|
|
Modulo
|
Find the remainder
|
|
Boolean
|
True/False
|
name = "time GIRARD"
print (name.upper()) > TIM GIRARD
print (name.lower()) > time girard
print (name.capitalize()) > Tim girard
print (name.title()) > Tim Girard
|
string+string
|
combines the string together
|
|
string+number
|
crash
|
|
number+number
|
Math(addition)
|
|
string*string
|
crash
|
|
string*number
|
combines he string multiple times
|
|
number*number
|
math(multiply)
|
|
string**number
|
crash
|
import ramdom
mylist = ["Dog", "Fish", "Cat", "Bear"]
counter = 0
while counter < 10 :
random_item = random.choice (mylist)
print (random_item)
counter = counter + 1
|
print()
|
displays information on the screen
|
|
input()
|
receives info from the user
|
|
float()
|
converts a value to floating point
|
|
str()
|
converts
|
|
mylists3 =[1, 'hello' , 2.5]
|
|
print (mylists)
|
|
print (mylists2)
|
|
print (mylists3)
|
|
#how to make a list with all numbers from 0-99
|
|
mynumbers = range(5)
|
|
for num in numbers:
|
|
print(num)
|
def max2(num1, num2):
if num1 > num2:
maxvalue = num1
elif num2 > num1:
maxvalue = num2
return maxvalue
#function call
print(max2(92, 3))
print(max2(4, 5))
def max3(num1, num2, num3):
maxvalue = num1
if num2 > maxvalue:
maxvalue = num1
elif num3 > maxvalue:
maxvalue = num3
return maxvalue
#function call
print(max3(92, 5, 6))
print(max3(8, 9, 7))
print(max3(99, 40, 49))
def maxlist(list):
maxvalue = list[0]
for num in list:
if num > maxvalue:
maxvalue = num
return maxvalue
mylist = 3, 5657, 90333, 33333333
print(maxlist(mylist))
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.