0% found this document useful (0 votes)
29 views

Practical - Python

Python is traditionally introduced by displaying "Hello World" on screen. It has editing and runtime windows for writing and running code. Functions in Python include string handling like length, substring, uppercase/lowercase conversion. Procedures can be defined like a Stars() function to print asterisks, or a Celsius conversion function. Built-in library routines provide math functions like modulus, integer division, and rounding, as well as random number generation.

Uploaded by

samanali nonis
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)
29 views

Practical - Python

Python is traditionally introduced by displaying "Hello World" on screen. It has editing and runtime windows for writing and running code. Functions in Python include string handling like length, substring, uppercase/lowercase conversion. Procedures can be defined like a Stars() function to print asterisks, or a Celsius conversion function. Built-in library routines provide math functions like modulus, integer division, and rounding, as well as random number generation.

Uploaded by

samanali nonis
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/ 2

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()

You might also like