CDAT - Computer Science‎ > ‎2015-16‎ > ‎CSP‎ > ‎News and Assignments‎ > ‎

30 SEP & 1 OCT

posted Sep 29, 2015, 10:41 AM by Tom Culpepper   [ updated Sep 29, 2015, 11:21 AM ]
Continue to practice on the quizzes for tomorrow.  Remember: you can do these at home too.  Some of you still need to show me your "hardest problem" from the quizzes.

9th period:  We'll also go over quiz 3 at the beginning of class.
Mod practice
Need practice with the modulo operator?  Thomas Popa from 5th period wrote this program you should try. 

import random #Gets random module
x = None      #Set x as nothing right now
y = None      #Set y as nothing right now
finish = False#finish is set to false

while finish == False:  #While finish is false generate x and y as random ints
    x = random.randint(0,100) #Then add them to a question
    y = random.randint(0,10)
    answer = int(raw_input(str(x) + " MODULO (%) "+ str(y)))
    #compare the user's answer to whatever x modulo y is. If it's true then congratulate
    if answer == x%y: #and give option to end program. Else repeat.
        print "Good job!"
        done = raw_input("Type DONE if you're finished.")
        if done == "DONE":
            finish = True
        print "Incorrect"