# -*- coding: utf-8 -*- """ Created on Wed Oct 12 10:58:41 2022 @author: cpresser """ # Decisions: if statements # check a condition, run some code if the condition is true # no repetition x = 0 #specify the condition if x > 0: # if it is true print(f"{x} is positive.") # run after if regardless of the condition #add an if for negative if x < 0: print(f"{x} is negative.") print("Done.") #list of values mylist = [7, -2, 0, 6, 10, -17, 3] numPositive = 0 #count positive numbers for n in mylist: #check if current n is positive if n > 0: print(f"{n} is positive.") numPositive += 1 print(f"There are {numPositive} positive values.") # else clause # must be attached to an if x = 123 if x > -10 and x < 10: print(f"{x} is a one digit number.") elif x > -100 and x < 100: print(f"{x} is a two digit number.") elif x > -1000 and x < 1000: print(f"{x} is a three digit number.") else: #when the condition is false print(f"{x} is something else.") if x > 0: print(f"{x} is positive") elif x < 0: #else if print(f"{x} is negative") else: print(f"{x} is zero")