Python Excerise 1
Python Excerise 1
In [57]: # [ ] show the type after assigning bucket = a whole number value such as 16
bucket = 16
type (bucket)
Out[57]: int
In [58]: # [ ] show the type after assigning bucket = a word in "double quotes"
bucket = "water"
type (bucket)
Out[58]: str
Out[102]: int
In [60]: # [ ] Review and run code for adding a variable string and a literal string
shoe_color = "brown"
print ("my shoe color is " + shoe_color)
In [61]: sm_number = 5 + 5
big_number = 134
sm_number + big_number
Out[61]: 144
In [63]: 35+15
Out[63]: 50
In [64]: X = 10;
Y = 5
1
In [65]: X + Y
Out[65]: 15
In [66]: # [ ] review & run code for Integer addition in variables and in a print function
int_sum = 6 + 7
print(int_sum)
13
26
In [88]: # [ ] perform Integer addition in the variable named new_msg (add 2 or more Integers)
new_msg = "9 "
# [ ] create and print a new string variable, new_msg_2, that concatenates new_msg + a
new_msg_2 = "Eggs"
print (new_msg + new_msg_2)
9 Eggs
my number is 123
In [94]: # [ ] review and run the code - then fix any Errors
total_cost = "3" + "45"
print(total_cost)
345
2
In [97]: # [ ] review and run the code - then fix any Errors
school_num = "123"
print("the street number of Central School is " + school_num)
In [124]: # [ ] Read and run the code - write a hypothesis for what you observe adding float + i
# [ ] HYPOTHESIS:
type (5)
print (type(3))
print(3.3 + 3)
<class 'int'>
6.3
Alton
Out[127]: 'RamAndShyam'
3
Hello World!
---------------------------------------------------------------------------
<ipython-input-144-65c3307914da> in <module>()
----> 1 PriNt("Hello World!")
*
* *
*****
* *
* *
_ _
\ /
\ . . /
V
4
print("***")
print("*")
print("***")
print()
***
*
***
*
***