Programming – Python
The traditional introduction to programming in any language is to display the words ‘Hello World’ on a
computer screen.
(1)
The editing window for Python The runtime window for Python
(2)
(3) String Handling
(a) Length of the text
Len (“Computer Science”)
(b) Substring
"Computer Science"[9:16]
(c) Convert all letters in to CAPITAL letters
"Computer Science".upper()
(d) Convert all letters in to simple letters
"Computer Science".lower()
(4) Procedures & Functions
def Stars():
print("************")
Stars()
def Stars(Number):
for counter in range (Number):
print("*", end = "")
Stars(10)
def Celsius(Temperature):
return (Temperature - 32) / 1.8
Celsius(25)
(5) Library routines
Value1 = 10%3
Value2 = 10//3
Value = divmod(10,3)
Value3 = round(6.97354, 2)
from random import random
Value4 = random()