File: Section3_PythonNumbers/integersAndFloats.py- Integers are numbers with no decimal houses like the following examples
- While Floats may be rounded but always have a decimal house
- The method type() is used to reveal the type of the argument used
type(5) //<class "int">
type(5.0) //<class "float">File: Section3_PythonNumbers/basicOperators.py- If you calculate an integer and a float the answer will always be a float
print("Type of 12 + 1.5",type(12+1.5)) #Type of 12 + 1.5 <class 'float'>- It rounds down the result
print("10 / 3 = ", 10 / 3, " | 10 // 3 = ", 10 // 3)
#10 / 3 = 3.3333333333333335 | 10 // 3 = 3print("8 ** 3 = ", 8 ** 3)
#8 ** 3 = 512- Remainder of the operation
print(38 % 10)
# 10 goes into 38... 3 times, with a remainder of 8- length of a string
name = "Alex"
len(name) #4- Inputs a question to the user and can be captured in a variable
first_name = input("What is your name?")
print("So your name is " + first_name+ "!")
#So your name is XXX!- They change the variable type, int will chop the float decimal off
age = input("How old are you?")
doubled_age = int(age) * 2
print("if we multiplied your age by 2 it would be: " + str(doubled_age))
#How old are you?20
#if we multiplied your age by 2 it would be: 40- f strings will read and evaluate and code between {} the result will be turned into a string and inserted into the overall string
age_in_days = input("How old are you? (in days (years*365))")
print(f"You are {float(age_in_days) / 365} old!")
#How old are you? (in days (years*365))7665
#You are 21.0 old!- if you compare float and ints they represent the same value
print(4.00000 == 4)
#True
print(4.00001 == 4)
#False- The "in" operator looks to see if an items is a member of a sequence.
"a" in "cat"
#Truefrom random import randint
print(randint(1,6))- Start is included, Stop is excluded
- Yo may not provide the starting point so the range will start at 0
#range(1,10,2) #Start, Stop and Step
for num in range(5,10):
print(num)
#5,6,7,8,9