In [1]:

```
print "My salary is $10000"
```

In [2]:

```
salary = 10000; #Declare and store 10000 in variable called salary
print "My salary is %d." %salary
```

In [3]:

```
brothers = 7 #declaring variable & storing value
brides = 7 #declaring variable & storing value
print "%d brides for %d brothers" %(brides, brothers)
```

In [4]:

```
cats = 2
dogs = 1
ponies = 1
others = 46
total_pets = cats + dogs + ponies + others;
print "We have %d pets in total\n" %total_pets
```

In [5]:

```
cookies = 5
cookie_calories = 125
total_eaten = 0
eaten = 2
cookies = cookies - eaten
total_eaten = total_eaten + eaten
print "I have eaten %d cookies. There are %d cookies left" %(eaten, cookies)
eaten = 3
cookies = cookies - eaten
total_eaten = total_eaten + eaten
print "I have eaten %d more. Now there are %d cookies left\n" %(eaten, cookies)
print "Total energy consumed is %d calories.\n" %(total_eaten*cookie_calories)
```

In [6]:

```
cookies = 45
children = 7
cookies_per_child = 0
cookies_left_over = 0
cookies_per_child = cookies/children
print "You have %d children and %d cookies" %(children, cookies)
print "Give each child %d cookies.\n" %cookies_per_child
cookies_left_over = cookies%children
print "There are %d cookies left over.\n" %cookies_left_over
```

In [7]:

```
plank_length = 10.0
piece_count = 4.0
piece_length = 0.0
piece_length = plank_length/piece_count;
print "A plank %f feet long can be cut into %f pieces %f feet long.\n" %(plank_length, piece_count, piece_length)
```

In [8]:

```
radius = 0.0
diameter = 0.0
circumference = 0.0
area = 0.0
Pi = 3.14159265
print "Input the diameter of the table:",
diameter = float(raw_input())
radius = diameter/2.0
circumference = 2.0*Pi*radius
area = Pi*radius*radius
print "\nThe circumference is %0.2f" %circumference
print "\nThe area is %0.2f\n" %area
```

In [9]:

```
PI = 3.14159
radius = 0.0
diameter = 0.0
circumference = 0.0
area = 0.0
print "Input the diameter of a table:",
diameter = float(raw_input())
radius = diameter/2.0
circumference = 2.0*PI*radius
area = PI*radius*radius;
print "\nThe circumference is %.2f. " %circumference
print "\nThe area is %.2f.\n" %area
```

In [10]:

```
diameter = 0.0
radius = 0.0
Pi = 3.14159
print "Input the diameter of the table:",
diameter = float(raw_input())
radius = diameter/2.0
print "\nThe circumference is %.2f." %(2.0*Pi*radius)
print "\nThe area is %.2f.\n" %(Pi*radius*radius)
```

In [11]:

```
import sys
print "Size of Integer is: " + str(sys.getsizeof(int()))
print "Size of Float is: " + str(sys.getsizeof(float()))
print "Size of Long is: " + str(sys.getsizeof(long()))
print "Size of String is: " + str(sys.getsizeof(str()))
```

In [12]:

```
Revenue_Per_150 = 4.5
JanSold = 23500
FebSold = 19300
MarSold = 21600
RevQuarter = 0.0
QuarterSold = JanSold + FebSold + MarSold
print "Stock sold in\n Jan: %d\n Feb: %d\n Mar: %d\n" %(JanSold, FebSold, MarSold)
print "Total stock sold in first quarter: %d\n" %QuarterSold
RevQuarter = QuarterSold/150*Revenue_Per_150
print "Sales revenue this quarter is:$%.2f\n" %RevQuarter
```

In [13]:

```
first = 'T'
second = 63
print "The first example as a letter looks like this - ", first
print "The first example as a number looks like this - ", ord(first)
print "The second example as a letter looks like this - ", chr(second)
print "The second example as a number looks like this - %d\n" %second
```

In [14]:

```
first = 'A'
second = 'B'
last = 'Z'
number = 40
ex1 = ord(first) + 2
ex2 = ord(second) - 1
ex3 = ord(last) + 2
print "Character values \t %-5c%-5c%-5c\n" %(chr(ex1), chr(ex2), chr(ex3))
print "Numerical equivalents\t %-5d%-5d%-5d\n" %(ex1, ex2, ex3)
print "The number %d is the code for the character %c" %(number, chr(number))
```

In [15]:

```
shorty = 0.0
lofty = 0.0
feet = 0.0
inches = 0.0
shorty_to_lofty = 0.0
lofty_to_tree = 0.0
inches_per_foot = 12.0
print "Enter Lofty's height to the top of his/her head, in whole feet: ",
feet = float(raw_input())
print "...and then inches: ",
inches = float(raw_input())
lofty = feet*inches_per_foot + inches
print "Enter Shorty's height up to his/her eyes, in whole feet: ",
feet = float(raw_input())
print "... and then inches: ",
inches = float(raw_input())
shorty = feet*inches_per_foot + inches
print "Enter the distance between Shorty and Lofty, in whole feet: ",
feet = float(raw_input())
print "... and then inches: ",
inches = float(raw_input())
shorty_to_lofty = feet*inches_per_foot + inches
print "Finally enter the distance from Lofty to the tree to the nearest foot: ",
feet = float(raw_input())
lofty_to_tree = feet*inches_per_foot
tree_height = shorty + (shorty_to_lofty + lofty_to_tree)*(lofty-shorty)/shorty_to_lofty
print "The height of the tree is %ld feet and %ld inches.\n" %(tree_height/inches_per_foot, tree_height% inches_per_foot)
```