Class Notes (809,279)
CSC108H1 (113)
Lecture

# october 03 notes

2 Pages
73 Views

School
University of Toronto St. George
Department
Computer Science
Course
CSC108H1
Professor
Michelle Craig
Semester
Fall

Description
 Given two variables, is_empty of type bool , indicating whether a class roster is empty or not, and number_of_credits of type integer , containing the number of credits for a class, write an expression that evaluates to True if the class roster is not empty and the class is one or three credits. 1. is_empty = true 2. ise_empty = false 3. number_of_credits == 1 or number of credits == 3  every value in python has a truth associated with it  immutable_par o global namespace  x [007]  _ _name_ _ [009] o heap  x [007]  _ _name_ _ [009]  54 [100] creates a new int value, doesn’t change the original int 1. def double(x): 2. x = x * 2 # does not return; the new int. value associated with x not called upon 3. # x does double because local memory deletes after function completes 4. # x still original value 5. def double_fixed(x): 6. return x * 2 7. 8. if _ _name_ _ == „_ _main_ _‟ 9. x = 27 10. double(x) 11. print x # gives 27, doesn‟t double 12. 13. x = 99 14. x = double_fixed(x) 15. print x 16. 17. x = 5 18. x = double(x) 19. print x # returns None, because function does not return anything  DOC STRING slides, read online  Strings – sequence of characters >>> name = raw_input(“please enter our name “) >>> type(name) o Ex. >>> „csc‟ + „108‟ >>> int(„108‟) >>> dept = „csc‟ 108 >>> num = „108‟ >>> int(„-5‟) >>> dept + num -5 „csc108‟ >>>
More Less

Related notes for CSC108H1

OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.