0% found this document useful (0 votes)
3 views2 pages

Lab5 - Topic 6 User Defined Functions

This document outlines Lab 5 for a Computer Science course at Imam Abdulrahman Bin Faisal University, focusing on user-defined functions in Python. It includes objectives, required tools, and a series of programming tasks that students must complete, such as converting minutes to seconds, calculating the perimeter of a rectangle, and generating a multiplication table. Students are instructed to submit their work via Blackboard or email, with specific naming conventions for their files.

Uploaded by

4zntpqsktm
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)
3 views2 pages

Lab5 - Topic 6 User Defined Functions

This document outlines Lab 5 for a Computer Science course at Imam Abdulrahman Bin Faisal University, focusing on user-defined functions in Python. It includes objectives, required tools, and a series of programming tasks that students must complete, such as converting minutes to seconds, calculating the perimeter of a rectangle, and generating a multiplication table. Students are instructed to submit their work via Blackboard or email, with specific naming conventions for their files.

Uploaded by

4zntpqsktm
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

MINISTRY OF EDUCATION ‫وزارة التعليم‬

IMAM ABDULRAHMAN BIN ‫جامعة اﻻٕمام‬


FAISAL UNIVERSITY ‫عبد الرحمن بن فيصل‬
DEANSHIP OF PREPARATORY ‫عمادة السنة التحضيرية و‬
YEAR AND SUPPORTING STUDIES ‫الدراسات المساندة‬
ٓ
COMPUTER SCIENCE DEPARTMENT ‫قسم الحاسب اﻻ لي‬

Lab 5: User-Defined Functions

Objective(s)
 To be able to define new functions in Python.
 To understand the details of function calls and parameter passing in Python

Tool(s)/Software
 Pycharm
or
 IDLE (Python 3.10 or above)
or
 https://www.online-python.com/
Description
 Write python programs that solve the following problems:

Tasks/Assignments(s)
Q1:

Write a function in Python that converts minutes given by the user to seconds: S=M*60. Then
call the function and print the result.

Q2:

Write a function in Python that takes length and width as parameters and return the perimeter
of rectangle: P=2L+2W. Call the function with two values given by the user.

Q3:
Write function to display the multiplication table of a number given by the user.
Example of output:
Please give the multiplier:5
From where to start:1
Where to stop:10
1*5=5
2*5=10
….
10*5=50

COMP105-LAB5 1
MINISTRY OF EDUCATION ‫وزارة التعليم‬
IMAM ABDULRAHMAN BIN ‫جامعة اﻻٕمام‬
FAISAL UNIVERSITY ‫عبد الرحمن بن فيصل‬
DEANSHIP OF PREPARATORY ‫عمادة السنة التحضيرية و‬
YEAR AND SUPPORTING STUDIES ‫الدراسات المساندة‬
ٓ
COMPUTER SCIENCE DEPARTMENT ‫قسم الحاسب اﻻ لي‬

Q4:
Write a function in Python that takes two numbers as parameters. This function returns the
sum, difference, multiplication, and division between these two numbers. User return
statement with many values. Then call the function and print the sum, the difference,
multiplication, and division.

Q5:
Write a function in Python that takes two numbers as parameters: Balance and rate of interest.
This function returns the new balance after accumulating interest on the account.
Call the function with the balance amount argument given by the user and a fixed rate equal
to 5%.
Hint: New Balance= Balance*(1+rate)

Q6:
Write a function in Python called everyThreeNum() and that takes two parameters start and
end. This function returns a list of numbers incremented by 3 starting from the start till the
end.
Example of output:
Start=5
End=12
[5, 8, 11]

Start=90
End=100
[90, 93, 96, 99]

Deliverables
 Submit the files via blackboard. If the blackboard is not working, send an email.
 No submissions or late submissions are penalized (from participation marks).
 Name the document Python_Lab5_StudentName_Q#

COMP105-LAB5 2

You might also like