from __future__ import division, print_function
Use code to determine the answers to the question 1.1-1.4
What is the type of 1
? Use the function type
to determine.
What about the type of 1.0
?
What is the resulting type of adding an 1
and 1
?
What is different about the resulting type of adding 1
and 1.0
?
So, what can you say about the resulting type of adding an int
and a float
?
Use code to determine the answers to the question 2.1-2.4
What is the type of "Daniel"
?
What is the type of 'Computer'
?
What happens when you add "Daniel"
and 'Computer'
?
What is the resulting type of adding "Daniel"
and 'Computer'
?
Is there a difference between single quotes and double quotes?
What happens when you add two strings?
Use code to determine the answers to the question 3.1
What is the resulting type of adding 3
and '3'
?
Can you explain why the error occured?
Use code to determine the answers to the question 4.1-4.4
Make a list that contains 4
and 5.0
.
Can you make a list that has 1
, 2
and "tree"
in it?
Can you make a list that contains 1
, 2
, "tree"
, and [4, 5.0]
?
Think about another type we haven't used in Question 4. Can you put it in the list of [1, 2.0]
?
What types can lists contain?
Add lists [5, 6, 'apple']
and [True, 12, 5.0]
together. What happens?
Use code to determine the answers to the question 5.1-5.4
Multiply 5
and 4
.
Multiply 'Shiro'
by 3
.
Multiply 5.0
and 4
.
Multiply ['Shiro', 5]
by 4
.
What patterns emerge when you multiply different types with an integer?
The upper left corner that's colored represents the operator. For example, in figure 1, B represents the result of False and True.
Use code to check your above answers.
# Explore here
Are 3
and '3'
equivalent? Use code to confirm.
Are "Daniel"
and "daniel"
equivalent? Use code to confirm.
What is the result of (not False) == True
?
Given x
and without using False
, make x
have the value of False
with one operator.
x = True
Define a variable x
, that has a value of 5
.
Define a variable y
, that has a value of x
.
What is the value of y
?
Change x
to 4
. What is the value of y
?
Define a variable z
, that has a value of the sum of x
and y
Assign x
another value, 12
. What are the values of y
and z
?
Given the following lines of code, what is the value of the variable seven
?
seven = 8
Given the following lines of code, are the variables shiro
and Shiro
equivalent?
shiro = 10
Shiro = 12
Define a variable x
that has the value 10
times 20
.
Given x increment it by 3 by using two different operators.
Find the remainder of 78
divided by 14
using one operator from lecture. For example -
$16 = 5 * 3 + 1$ (1 is the remainder).
Given x
, make x
10 times smaller using one operation. Return a value that has the type int
.
x = 200
What type(s) can you multiply lists with, without creating an error?
Write code to produce
a. 'HelloHelloHello'
b. 'Hello3'
using the 'Hello'
and 3
(any type) exactly once each.