Lecture 2 Exercises¶
Write code to divide the integer value
3
by the integer value 7
, and save the resulting value in the variable y
. Then write code to divide the floating point value 3.0
by the integer value 7
, and save the resulting value in the variable b
. (Consider, before you write the code or print out the values: what type of value will be stored in the variable y
? What type of value will be stored in the variable b
?)
Write code to let the user input their name. Store the string in a variable. Then write code to print out
Welcome to the world of programming, <USER'S NAME>
(except instead of “<USER’S NAME>” should be the name the user typed).
Below is some code that assigns values to variables. Write code below it that makes it so that the variable
x
holds an integer value that is greater by 2 than the integer value it currently holds. That code should work no matter what the current value of x
is! Then, write code that makes the variable apple
hold the string value "television"
. Do not change any of the existing code.