0% found this document useful (0 votes)
106 views8 pages

Lab 3: Python Control Structure

This document discusses Python control structures including decision making using if/else statements, iteration with for and while loops, and functions. It provides steps to install Jupyter Notebook and create a Python file to code control structures. Examples are given for if/else statements, for loops, while loops, and defining a function to check for a fever based on a user's input temperature. References for further information on Python, Jupyter, and control structures are also included.

Uploaded by

Joki Roy
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)
106 views8 pages

Lab 3: Python Control Structure

This document discusses Python control structures including decision making using if/else statements, iteration with for and while loops, and functions. It provides steps to install Jupyter Notebook and create a Python file to code control structures. Examples are given for if/else statements, for loops, while loops, and defining a function to check for a fever based on a user's input temperature. References for further information on Python, Jupyter, and control structures are also included.

Uploaded by

Joki Roy
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/ 8

Lab 3 : Python

Control Structure
Objective:
In this lab we are going to code using Jupyter Notebook. Throughout this lab, we will cover
python control structure.

Steps:

Install WinPython

1. Start Jupyter Notebook.


2. Create a new python 3 file.
3. Change the title to “Python Control Structure” and start code.

2020 | WIJDAN SKILLS ENTERPRISE (KC0041054-P)


4. The code below is for decision-making when we only want code to be executed if a
certain requirement is met. The program evaluates the condition and will execute
statements if the condition result is True.

2020 | WIJDAN SKILLS ENTERPRISE (KC0041054-P)


5. The for loop in Python is used to iterate over a sequence (list, tuple, string) or other
iterable objects. Here, val is the variable that takes the value of the item inside the
sequence on each iteration. Loop continues until we reach the last item in the
sequence.

2020 | WIJDAN SKILLS ENTERPRISE (KC0041054-P)


6. The while loop in Python is used to iterate over a block of code as long as the test
expression (condition) is True. We generally use this loop when we don't know
beforehand, the number of times to iterate.

2020 | WIJDAN SKILLS ENTERPRISE (KC0041054-P)


7. In Python, function is a collection of associated statements that perform a specific
task. Functions help break into smaller and more flexible parts of our program. As our
system grows bigger and bigger, it's more structured and manageable by functions.
It also prevents repetition, and makes code reusable.

2020 | WIJDAN SKILLS ENTERPRISE (KC0041054-P)


8. Python Exercise:
a. Create a function to determine fever
b. When the function is called
i. Ask to enter body temperature
ii. Answer whether or not you have a fever
➔ 38 and above - fever
➔ Below than 38 - healthy

The result as below :

2020 | WIJDAN SKILLS ENTERPRISE (KC0041054-P)


References:

1. https://github.com/winpython

2. https://jupyter.org/

3. https://www.w3schools.com/python/default.asp

2020 | WIJDAN SKILLS ENTERPRISE (KC0041054-P)

You might also like