Lecture 6 Exercises¶
These are not graded for correctness, but if you did not complete the Lecture Waiver with 100% before today’s lecture, you should either try at least one of them, or do work on these on paper and hand them to an instructor after lecture!
Write code to assign the string
"You can apply to SI!"
to output
if the string "SI 106"
is in the list courses
. If it is not in courses
, assign the value "Take SI 106!"
to the variable output
.
Create the variable
z
whose value is 30
. Write code to see if z
is greater than y
. If so, add 5 to y
’s value, otherwise do nothing. Then, multiply z
and y
, and assign the resulting value to the variable x
.
Challenge In XYZ University, upper level math classes are numbered 300 and up. Upper level English classes are numbered 200 and up. Upper level Psychology classes are 400 and up. Create two lists,
upper
and lower
. Then write code that uses iteration and conditional statements to assign each course in classes
to the correct list, upper
or lower
. HINT: remember, you can convert some strings to different types!