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

Week - 3 Lab - 2 Lab Aim: Understand The Conditional Statements and Looping Statements of

This document contains the lab manual for the Python Programming course being conducted at SVKM's NMIMS University. It outlines the tasks and exercises for weeks 3 and 4 of the course. In week 3, students will practice conditional statements and looping statements using an online website and solve problems involving calculating grades based on percentage, checking number types, and drawing patterns using loops. In week 4, students will practice working with lists, tuples, dictionaries and sets using an online resource and solve problems involving list and tuple operations, creating a menu-driven food ordering program using dictionaries, and explaining tuples.

Uploaded by

Sahil Shah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Week - 3 Lab - 2 Lab Aim: Understand The Conditional Statements and Looping Statements of

This document contains the lab manual for the Python Programming course being conducted at SVKM's NMIMS University. It outlines the tasks and exercises for weeks 3 and 4 of the course. In week 3, students will practice conditional statements and looping statements using an online website and solve problems involving calculating grades based on percentage, checking number types, and drawing patterns using loops. In week 4, students will practice working with lists, tuples, dictionaries and sets using an online resource and solve problems involving list and tuple operations, creating a menu-driven food ordering program using dictionaries, and explaining tuples.

Uploaded by

Sahil Shah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering


COURSE: Python Programming Lab Manual
Faculty: Prof. Leena Nadkar
BTI Sem III - Div B,C,D

Week - 3
Lab -2
Lab Aim: Understand the Conditional Statements and Looping Statements of
Python Programming

Task 1: Practice using interactive website - learnpython.org


● Conditions
● Loops

Task 2: Solve the following questions:


a. Consider inputs for 5 subjects. Also accept First name, Last name and roll
no. Calculate the score and percentage of all the 5 subjects. Also print
Grade.
If percentage<= 100 and percentage>= 75 print Grade A
If percentage<= 74and percentage>= 60print Grade B
If percentage<= 59and percentage>= 40 print Grade C
Below 39 is Fail
b. Given an integer, n, perform the following conditional actions:
(Hackerrank)
a. If n is odd, print Weird
b. If n is even and in the inclusive range of 2to 5, print Not Weird
c. If n is even and in the inclusive range of 6 to 20 , print Weird
d. If n is even and greater than 20 , print Not Weird
The input should be in integer format only.
c. Given a positive integer N, the task is to write a Python program to check
if the number is prime or not. (Hackerrank)
Examples :
Input: n = 11
Output: true
Input: n = 15
Output: false
Input: n = 1
Output: false
d. Compute a program that accepts three sides to find whether it is an
equilateral triangle, isosceles triangle or scalene triangle. Also check if a
triangle can be formed by the inputted values.
e. Write a Python program to check if a character is an Alphabet digit or
special character with a practical.
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Python Programming Lab Manual
Faculty: Prof. Leena Nadkar
BTI Sem III - Div B,C,D

f. Also check whether the user given character is alphabet or digit or special
character. The first if statement checks whether the given character is
between a and z or A and Z. If TRUE, it is an alphabet. Otherwise, it
enters the elif statement where it checks whether a character is between 0
and 9. If True, it is a digit. Otherwise, it is a special character.
g. Simulate the following for understanding the working of loops in Python:
https://python-iitk.vlabs.ac.in/exp/loops/simulation.html
h. Develop a program to draw the following pattern

a. b.
h. Using a for loop, write a program that prints out the decimal equivalents
of 1/2, 1/3, 1/4, . . . , 1/10.
i. Each new term in the Fibonacci sequence is generated by adding the
previous two terms. By starting with 1 and 2, the first 10 terms will be: 1,
2, 3, 5, 8, 13, 21, 34, 55, 89 By considering the terms in the Fibonacci
sequence whose values do not exceed four million, find the sum of the
even-valued terms

Week - 4
Lab -3
Lab Aim: Understand and implement List, Tuple & Dictionary in python
programming:

Task 1: Practice using interactive website - learnpython.org


● Lists
● Dictionaries
● Sets
● List Comprehensions

Task 2: Solve the following questions:


a. Simulate the following for understanding List, Tuple and Dictionaries:
https://python-iitk.vlabs.ac.in/exp/data-types/simulation.html

b. Create a list in python for storing supermarket bill details and perform the
following operations on it:
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Python Programming Lab Manual
Faculty: Prof. Leena Nadkar
BTI Sem III - Div B,C,D

○ List indices
○ Add an item to the end of the list
○ Insert an item at a given position
○ Modify an element by using the index of the element
○ Remove an item from the list
○ Remove all items from the list
○ Slice Elements from a List
○ Remove the item at the given position in the list, and return it
○ Return the index in the list of the first item whose value is x
○ Return the number of times 'x' appear in the list
○ Sort the items of the list in place
○ Reverse the elements of the list in place
c. Create a tuple for storing student information and perform the following
functions:
○ Print an item of the tuple
○ Check if an element exists within a tuple
○ Check number of times an item has repeated
○ Remove an item from a tuple
○ Slice a tuple
○ Get the index of an item of the tuple
○ Print the size of a tuple
○ Modify items of a tuple

d. Develop a menu driven program for a food hub.


Example:
Please select option:
1- Veg Menu
2- Non-Veg Menu
0- Exit
Enter your choice: 1
You have selected option 1 – Veg
Select from the following options for Veg
1- Veg Burger
2- Veg Pizza
3- Dosa
Enter your choice: 2
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Python Programming Lab Manual
Faculty: Prof. Leena Nadkar
BTI Sem III - Div B,C,D

Do you wish to continue [Y/N] ? Y


Select from the following options for Veg
1- Veg Burger
2- Veg Pizza
3- Dosa
Enter your choice: 1
Do you wish to continue [Y/N] ? N
Your order is : [“Veg Pizza”, “Veg Burger”]
Perform operations accordingly.
b. For the same above example include price. The output will look like
{“Veg Pizza” : 120, “Veg Burger”: 110}. Also print the total price of user
choice items.
c. Perform all the operations of indexing and accessing tuples and sets. Also
explain how tuple is different from other data structures

You might also like