0% found this document useful (0 votes)
9 views3 pages

Tutorial 1

The document is a tutorial on computer programming by Sir Pythagoras, divided into practical (Section A) and theoretical (Section B) tasks. Section A includes tasks on variable creation, using input and print functions, and type casting, while Section B consists of questions related to programming concepts and definitions. Submissions for Section B are due by January 27, 2025, and Section A can be submitted until January 28, 2025.

Uploaded by

danieldenis6060
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Tutorial 1

The document is a tutorial on computer programming by Sir Pythagoras, divided into practical (Section A) and theoretical (Section B) tasks. Section A includes tasks on variable creation, using input and print functions, and type casting, while Section B consists of questions related to programming concepts and definitions. Submissions for Section B are due by January 27, 2025, and Section A can be submitted until January 28, 2025.

Uploaded by

danieldenis6060
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DELTA LESSONS

Introduction to computer programming


tutorial 1
By sir Pythagoras
-The tutorial contains two sections A and B
-Section A is practical and section B is not
-Submit section B for marking before 27-01-2025
-Section A maybe submitted any day before 28-01-2025
Section A
Task 1: basic variable creation
Create a variable and assign it any number as a value
Create another variable and assign it any number as a value
Perform addition on the 2 numbers and display the result on the screen

Task 2: using input() and print()


Modify the program you did in class to print the following output
Your name is _name_ and you are _age_ years old
e.g if I enter Pythagoras as name and 40 as age
your output should be
Your name is pythagoras and you are 40 years old

Task 3:using input() and print() and int()


Background:what ever the input from the input() function stored in a variable is of
type str i.e string
Recall “10” is str , 10 is int , 10.0 is float
When someone enters a number using the input function it is considered a string and
hence you cannot do mathematical operations on that number
In order to be to do so you need to convert it to type int i.e using int() function this is
called type casting(changing a variable from one data type to another)
For example:
X =input(“enter your age /t”)

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

X=input(“enter your age /t”)

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

Print(X) #will print “12” –mathematical operations cannot work

Print(Y) #will print 12 --mathematical operations can work

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

You might also like