Python Tutorial(Practicals)
BSMMP 2.1
Tutor: Mr. Robert Maina
OVERVIEW & PURPOSE
The following is a computational mathematics I guide on the programming practicals
using Python Language.
LESSON 1: 17TH JUNE, 2022
Objectives
1. Introduction to python programming(data types, conditional statements, loops
and functions)
2. Installation of relevant software.
Introduction
1. Data Types
Text Type: str
Numeric Types: int, float, complex
Sequence Types: list, tuple, range
Mapping Type: dict
Set Types: set, frozenset
Boolean Type: bool
Binary Types:bytes, bytearray, memoryview
None Type: NoneType
1
2. Conditional Statements
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
3. Loops
Python has two primitive loop commands:
a) while loops
i = 1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")
b) for loops
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
if x == "banana":