# printing output print("Message to the user") # variables job = "fisherman" print(job) job = "software developer" number = 1 print(number) # concatenataion print(job + " " + str(number)) number += 5 print(number * 50) # input from user age = int(input("What is your age?\n")) print(age) # conditions print(age >= 18) # branching/decisions/ "if statements" if age >= 21: print("You can drink") elif age >= 25: print("this is unreachable because 21 > 25") else: print("you can't drink") # loops (for/while) # keep adding to a total until user quits user_input = input("Enter a number or q to quit:\n") total = 0 while user_input != "q": total = total + int(user_input) print(total) user_input = input("Enter another number or q to quit:\n") name_of_student = "Josh" print("Length of Josh = " + str(len(name_of_student))) # range function (start/stop/step) #we go up to but not including the stop # 1 parameter = the stop # J - O - S -H for i in range(len(name_of_student)): print(name_of_student[i]) # H - S - O - J # 3 parameters = start and stop and step for i in range(len(name_of_student) - 1, -1, -1): print(name_of_student[i]) # H - S - O - J # 2 parameters = start and stop for i in range(0, len(name_of_student)): # 4- 1 - 0 = = 3 = H # 4- 1 - 1 = 2 = S # 4- 1 - 1 = 1 = O # 4- 1 - 1 = 0 = J print(name_of_student[len(name_of_student) - 1 -i]) # functions/methods/procedures/subprograms/subroutines/modules # input/output or even just named with no input or output # data validation # arrays/lists colors = ["blue", "red", "green", "purple", "yellow"] for color in colors: print(color) def valid_color(my_color): for color in colors: if my_color == color: return True # if not found return False print(valid_color("fruit")) #False print(valid_color("blue")) #True # file manipulation