You are on page 1of 1

python

chapter one
Exercises
1. Write a program that will output two messages of
your choice on the screen, on separate lines.
2. Write a program that will output this rocket on the
screen.
*
***
*****
*******
*******
*******
*******
*******
*******
*******
*******
***
*****
3. Write a program that will read three integers and
display the sum.
4. Write a program that will read two integers and
display the product.
5. Enter the length, width and depth of a rectangular
swimming pool. Calculate the volume of water
required to fill the pool and display this volume.
6. X DIV Y calculates how many times y divides into
x, for example 7 DIV 3 is 2. X MOD Y calculates the
remainder that results after division, for example 7
MOD 3 is 1.
Write a program that will read in two integers
Number1 and Number2. Using DIV and MOD, your
program should display the whole number part
and the remainder of dividing Number 1 by
Number 2.
Make the display easy to understand for the user.
7. Write a program to enter an amount of money as a
whole number, for example 78, and display the
minimum number of 20, 10, 5 notes and 2 and
1 coins that make up this amount.
For example, the value 78 would give 3 twenty
pound notes, 1 ten pound note, 1 five pound note,
1 two pound coin and 1 one pound coin.
Syntax
!"#$%&'()**+ -+"*./0
outputs the text string to the screen.
!"#$%&'1+2" 34) #56/7 8+2"94)0
outputs the text string to the screen
followed by the value contained in the
variable.
8+2"94) : ;
assigns the value 5 to the variable.
#$!2%94) : #$!2%&'<*)35) )$%)" 8+2" 34)6/0
assigns the input from the keyboard to the
variable.
8+2"94) : #$%&#$!2%94)0
converts the variable value to an integer
and assigns it to the other variable.
Vocabulary
=3"#3>*)
a labelled location that can contain a value
which can be referenced by the program at
a later date.
355#4$?)$%
the process of storing a value in a particular
variable.
.3%3@%8!)
the kind of information. e.g. string (text) or
integer.
+!)"3%+"
a symbol used to represent an arithmetic
operation.
A+??)$%
a line of text that explains a section of
programming code.

You might also like