##Stuff to go over in Review 2 ## THIS IS FOR CS1301 ##boolean #and or not ##conditionals # if def elifblock(): if (5==5 or 4==5) and not (5 <4 or 10>3): print "HELLO" elif 5 == 5 and not 4 != 5: print "This is the elif block" else: print "it failed both the if and the elif" def bouncer(): age = int(raw_input("what is your age")) if age <18: print "GO AWAY!" else: if age <21: print "You can come in" else: print "you can drink too" ##boolean expressions # == < > <= >= != <> ##while for recurse def whileLoopDemo(): done = False i = 56 while done == False: print i i += 5 if i > 120: done = True def add10Percent(): grades = [90, 97, 84, 45, 67, 96] print "Before:", grades print "Grade list: " for gradeIndex in range(len(grades)): print grades[gradeIndex] grades[gradeIndex] += grades[gradeIndex] * 0.1 print "After:", grades def recursiveFunc(): print "woo!" recursiveFunc() def factorial(x): if x < 2: return x else: return x * factorial(x - 1) def factWhile(x): n = 1 while x >= 2: n = n * x x -= 1 return n #Runtime error - occurs while the program is actually running - something # wrong with variables or etc #Syntax error - Something that is wrong with your syntax, ie, # the 'grammar' of the code #Semantic error - An error in your programming logic, causes it to behave # differently than you want ##strings arrays tuples alias ##print vs return def function(n): n += 5 print n ##robo stuff # Movement functions # Sensor functions >> What they do, what the different sensors are, etc # Other robot capabilities # Do not worry about HTML/CSS beyond what they are ##writing code # # # # YOU ARE RESPONSIBLE FOR ALL MATERIALS THAT HAVE BEEN COVERED IN LECTURE # SINCE THE LAST TEST. # Yes, this includes robot stuff. # Practice writing code on paper! It's not the same as writing code on # your computer. #