Docsity

Python Functions,Class and Objects, Lab Reports of Programming Languages

Toggle sidebar
bg1
Faizan ul haque C1
FUNCTIONS, CLASS AND OBJECT
OBJECTIVE:
Familiarization with Python language using function, class and object.
LAB TASKS:
1: Write a function called describe_city( ) that accepts the name of a city and its country. The function
should print a simple sentence, such as Islamabad is in Pakistan. Give the parameter for the country a
default value. Call your function for three different cities, at least one of which is not in the default
country.
2: Write a function called absolute_num() that accepts one parameter, num. The function should return
only positive value, and apply condition on it. This function returns the absolute value of the entered
number
pf2

Partial preview of the text

Download Python Functions,Class and Objects and more Lab Reports Programming Languages in PDF only on Docsity!

Faizan ul haque C

FUNCTIONS, CLASS AND OBJECT

OBJECTIVE:

Familiarization with Python language using function, class and object. LAB TASKS: 1: Write a function called describe_city( ) that accepts the name of a city and its country. The function should print a simple sentence, such as Islamabad is in Pakistan. Give the parameter for the country a default value. Call your function for three different cities, at least one of which is not in the default country. 2: Write a function called absolute_num() that accepts one parameter, num. The function should return only positive value, and apply condition on it. This function returns the absolute value of the entered number

Faizan ul haque C 3: Create a Class “Employee”, it’s a common base class for all the employee. Then initialize employee’s parameter like empName and salary and create function like displayCount() contain total number of employee in your knowledge base and displayEmployee() contain empName and their salary.