# Chapter 1 : Types, Variables, and Standard I/O: Lost Fortune¶

### Exmaple 1.1 Page no : 6¶

In [1]:
print "Game Over!"

Game Over!


### Exmaple 1.2 Page no : 11¶

In [2]:
print "Game Over!"

Game Over!


### Exmaple 1.3 Page no : 12¶

In [3]:
print "Game Over!"

Game Over!


### Exmaple 1.4 Page no : 13¶

In [4]:
print "7 + 3 = " , 7 + 3
print "7 - 3 = " , 7 - 3
print "7 * 3 = " , 7 * 3
print "7 / 3 = " , 7 / 3
print "7.0 / 3.0 = " , 7.0 / 3.0
print "7 % 3 = " , 7 % 3
print "7 + 3 * 5 = " , 7 + 3 * 5
print "(7 + 3) * 5 = " , (7 + 3) * 5

7 + 3 =  10
7 - 3 =  4
7 * 3 =  21
7 / 3 =  2
7.0 / 3.0 =  2.33333333333
7 % 3 =  1
7 + 3 * 5 =  22
(7 + 3) * 5 =  50


### Example 1.5 Page no : 17¶

In [5]:
score = 0;
distance = 1200.76;
playAgain = 'y'
shieldsUp = True;
lives = 3;
aliensKilled = 10;
engineTemp = 6572.89;
print "\nscore: " , score
print "distance: " , distance
print "playAgain: " , playAgain
#skipping shieldsUp since you dont generally print Boolean values
print "lives: " , lives
print "aliensKilled: " , aliensKilled
print "engineTemp: " , engineTemp

print "\nHow much fuel? ",
fuel = 5  # raw_input()

print "fuel: " , fuel
bonus = 10;
print "\nbonus: " , bonus

score:  0
distance:  1200.76
playAgain:  y
lives:  3
aliensKilled:  10
engineTemp:  6572.89

How much fuel?  fuel:  5

bonus:  10


### Example 1.6 Page no : 35¶

In [6]:
score = 5000;
print "score: " , score
#altering the value of a variable
score = score + 100;
print "score: " , score
#combined assignment operator
score += 100;
print "score: " , score
# increment operators
lives = 3;
lives += 1
print "lives: ", lives

lives = 3;
lives += 1
print "lives: ", lives

lives = 3;
lives += 1
bonus = lives * 10;
print "lives, bonus = " , lives , ", " , bonus

lives = 3;
bonus = lives * 10;
lives += 1
print "lives, bonus = " , lives , ", " , bonus
#integer wrap around
score = 4294967295;
print "\nscore: " , score
score += 1
print "score: ", score

score:  5000
score:  5100
score:  5200
lives:  4
lives:  4
lives, bonus =  4 ,  40
lives, bonus =  4 ,  30

score:  4294967295
score:  4294967296


### Example 1.7 Page no : 30¶

In [7]:
ALIEN_POINTS = 150;
aliensKilled = 10;
score = aliensKilled * ALIEN_POINTS;
print "score: " , score
NOVICE = 0
EASY = 1
NORMAL =2
HARD=3
UNBEATABLE=4
myDifficulty = EASY;
FIGHTER_COST = 25
BOMBER_COST=26
CRUISER_COST = 50
myShipCost = BOMBER_COST;
print  "\nTo upgrade my ship to a Cruiser will cost" , (CRUISER_COST - myShipCost) , " Resource Points.\n";

score:  1500

To upgrade my ship to a Cruiser will cost 24  Resource Points.



### Example 1.8 Page no : 33¶

In [8]:
GOLD_PIECES = 900;

print "Welcome to Lost Fortune\n\n";
print  "Enter a number: ";
print "Enter a number, smaller than the first: ";
killed = 5 #int(raw_input())

print "Enter your last name: ";
#tell the story
print "\nA brave group of " , adventurers , " set out on a quest ";
print "- in search of the lost treasure of the Ancient Dwarves. ";
print "The group was led by that legendary rogue, " , leader , ".\n";
print "\nAlong the way, a band of marauding ogres ambushed the party. ";
print "All fought bravely under the command of " , leader,
print ", and the ogres were defeated, but at a cost. ",
print "Of the adventurers, " , killed , " were vanquished, ",
print "leaving just " , survivors , " in the group.\n"

print "\nThe party was about to give up all hope. ";
print "But while laying the deceased to rest, ";
print "they stumbled upon the buried fortune. ";
print "So the adventurers split " , GOLD_PIECES , " gold pieces." ,
print leader , " held on to the extra " , (GOLD_PIECES % survivors),
print " pieces to keep things fair of course.\n"

Welcome to Lost Fortune

Enter a number:
Enter a number, smaller than the first:

A brave group of  10  set out on a quest
- in search of the lost treasure of the Ancient Dwarves.
The group was led by that legendary rogue,  xyz .

Along the way, a band of marauding ogres ambushed the party.
All fought bravely under the command of  xyz , and the ogres were defeated, but at a cost.  Of the adventurers,  5  were vanquished,  leaving just  5  in the group.

The party was about to give up all hope.
But while laying the deceased to rest,
they stumbled upon the buried fortune.
So the adventurers split  900  gold pieces. xyz  held on to the extra  0  pieces to keep things fair of course.