Tutorial 1
Tutorial 1
If I enter 10 , X will store “10” and not 10 so if I want X to store an int not string I will change
the code to the following
Y = int(X)
#this will convert the numerical string from the input to int and will enable you do
mathematical operations on it(division,multiplication,subtraction etc)
If I entered 12
Question
Write a program that asks a user to enter their age and then it prints the
year they were born e.g if the age entered is 24 the it should print 2001
Hint: store the input in a variable age and print 2025 – int (age) using
print()
Section B (33marks)
Write the answers on a paper
Task 4: answer the following questions
a) What is a variable? (2marks)
b) Name any three rules for naming a variable (6marks)
c) Name three reasons why it is important to use comments in a program (6marks)
d) Define an IDE (2marks)
e) Name any three IDE’s (3marks)
f) List any three primitive data types in python(3marks)
g) Write a program that asks a user their age and prints the year they were
born(6marks)
h) Which of the following is valid variable name
a) Full name
b) Age_at_death_random_variable
c) $age
d) Print
i) What will be the output of the following code
x = 7.0
print(type(x))
a) str
b) bool
c) float
d) int
j) Which of the following symbols is an assignment operator in python
a) $
b) ==
c) >=
d) =
k) Which of the following symbols is used for comments in python
a) $
b) #
c) <--
d) /*
e)
l) Which of the following is the default IDE for python
a) Pycharm
b) IDE
c) Python
d) IDLE