a = 10
b = 20
c = 0
if ( a and b ):
print ("Line 1 - a and b are true")
else:
print ("Line 1 - Either a is not true or b is not true")
if ( a or b ):
print ("Line 2 - Either a is true or b is true or both are true")
else:
print ("Line 2 - Neither a is tru

4.
Python Decision Making
Decision making structures require that the programmer specify one or more conditions to be
evaluated or tested by the program, along with a statement or statements to be executed if the
condition is determined to be true, and op

CHUKA UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE & ICT
COMP 103: FUNDAMENTALS OF COMPUTER PROGRAMMING (45/15; CF 3.5)
Y1S2
1.0
Course Purpose
To introduce students to computer programming
2.0
Learning Outcomes
Upon completion of the course, the student sho

a = 21
b = 10
c = 0
c = a + b
print ("Line 1 - Value of c is ", c)
c = a - b
print ("Line 2 - Value of c is ", c)
c = a * b
print ("Line 3 - Value of c is ", c)
c = a / b
print ("Line 4 - Value of c is ", c)
c = a % b
print ("Line 5 - Value of c is ", c)

a = 21
b = 10
c = 0
c = a + b
print ("Line 1 - Value of c is ", c)
c += a
print ("Line 2 - Value of c is ", c)
c *= a
print ("Line 3 - Value of c is ", c)
c /= a
print ("Line 4 - Value of c is ", c)
c = 2
c %= a
print ("Line 5 - Value of c is ", c)
c *= a

CHUKA UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
COMP 103: INTRODUCTION TO COMPUTER PROGRAMMING
Assignment Task
Write a Python program to accept students details (registration number) and capture the scores of
the courses they are doing namely: Maths, Scie

CHUKA UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
COMP 103: FUNDAMENTALS OF COMPUTER PROGRAMMING
Python Exercise tasks:
(1). Write a program to computes and displays the largest and the smallest of three input integer
values. The program should prompt the u

a = 21
b = 10
c = 0
if ( a = b ):
print ("Line 1 - a is equal to b")
else:
print ("Line 1 - a is not equal to b")
if ( a != b ):
print ("Line 2 - a is not equal to b")
else:
print ("Line 2 - a is equal to b")
#if ( a <> b ):
#
print ("Line 3 - a is not eq

a = 60
b = 13
c = 0
# 60 = 0011 1100
# 13 = 0000 1101
c = a & b;
# 12 = 0000 1100
print ("Line 1 - Value of c is ", c)
c = a | b;
# 61 = 0011 1101
print ("Line 2 - Value of c is ", c)
c = a ^ b;
# 49 = 0011 0001
print ("Line 3 - Value of c is ", c)
c = ~a

a
b
c
d
e
=
=
=
=
=
20
10
15
5
0
e = (a + b) * c / d
#( 30 * 15 ) / 5
print ("Value of (a + b) * c / d is ", e)
e = (a + b) * c) / d
# (30 * 15 ) / 5
print ("Value of (a + b) * c) / d is ", e)
e = (a + b) * (c / d);
# (30) * (15/5)
print ("Value of (a + b

3.0
Variables, Identifiers, Assignment & Operations
Python Variables
A variable is a reserved memory location for storing a value. This means that when you create a
variable you reserve some space in memory.
Based on the data type of a variable, the Pytho