Revised Manual For PPL - NEP
Revised Manual For PPL - NEP
Theory: The "Hello, World!" program is a simple script that outputs the text "Hello,
World!" to the screen. It is often used as the first program written by someone learning a
new programming language because it demonstrates the basic syntax and structure of
the language.
Explanation print: This is a built-in Python function used to display the specified
message to the screen. "Hello, World!": The message to be displayed. In Python, text is
enclosed in either single (') or double (") quotation marks.
2. Basic Arithmetic Operations
Purpose: The purpose of this program is to familiarize students with performing basic
arithmetic operations in Python. The program demonstrates how to use Python to
perform addition, subtraction, multiplication, and division. It helps students understand
how to work with variables, operators, and basic input/output functions in Python. This
exercise is fundamental for developing more complex mathematical and logical
operations in future programming tasks.
Objective: Perform basic arithmetic operations using Python.
Instructions: Write a Python program to perform addition, subtraction, multiplication,
and division.
1
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
3. Temperature Conversion
Purpose: The purpose of this program is to teach students how to implement a basic
temperature conversion calculator in Python. The program typically converts temperatures
between Celsius and Fahrenheit. This exercise helps students practice using mathematical
formulas, writing functions, and handling user input and output. It also reinforces the concept
of writing reusable code and modular programming.
2
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
3
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
Viva Questions:
Print "Hello, World!"
What is the significance of the print function in Python?
Why is "Hello, World!" often used as a first program in learning a new programming
language?
How do you write comments in Python?
What are some other basic functions available in Python similar to print?
Can you modify the print statement to print on the same line without a newline character?
2. Basic Arithmetic Operations
What are the basic arithmetic operations in Python?
How does integer division differ from regular division in Python?
What will be the result of 5 % 2 and what does the % operator do?
What will be the output of 2 ** 3 in Python and why?
Explain operator precedence and how it affects arithmetic operations in Python.
Case Study:
Write a Python program that determines whether a given number (accepted from the user)
is even or odd, and prints an appropriate message to the user.
Write a Python program that calculates the area of a circle based on the radius entered by
the user.
Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn.
Write a Python function to convert Fahrenheit to Celsius.
Write a Python program to calculate the difference between a given number and 17. If the
number is greater than 17, return twice the absolute difference.
4
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
Theory: Variable operations involve the use of variables to perform calculations and store
values. Variables can store different types of data such as integers, floats, strings, and more.
Common operations include arithmetic operations (addition, subtraction, multiplication,
division), assignment operations, and comparison operations.
2. Variable Swapping
Purpose: The purpose of a Variable Swapping program in Python is to illustrate how to
exchange the values of two variables. This can be done using a temporary variable or more
efficiently using Python's tuple unpacking. This program helps students understand the concept
of variable assignment and the importance of efficiently managing variable values in different
scenarios.
Objective: Swap the values of two variables without using a temporary variable.
Instructions: Write a Python program to swap the values of two variables.
Theory: Variable swapping is the process of exchanging the values of two variables. This can
be done in multiple ways, but Python provides a simple and intuitive way using tuple
unpacking. Swapping is useful in various algorithms, such as sorting algorithms.
5
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
Viva Questions:
Variable Operations
What are variables in Python?
How do you declare a variable in Python?
What are the different types of variables in Python?
Explain the concept of dynamic typing in Python.
How do you perform arithmetic operations on variables?
What is type casting and how do you do it in Python?
Case Study:-
Write a Python program to display the first and last colors from the following list.
color_list = ["Red","Green","White" ,"Black"]
Write a Python program to test whether a passed letter is a vowel or not.
Write a Python program that concatenates all elements in a list into a string and returns it.
Write a program swap two variables in Python?
6
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
1. String Manipulation
a. Purpose: The purpose of a String Manipulation program in Python is to showcase the various
ways to work with strings. This includes concatenation, slicing, indexing, and using built-in
string methods (such as .upper(), .lower(), .replace(), etc.). This program aims to teach students
how to manipulate and handle text data effectively, which is a crucial skill in many
programming tasks.
b. Objective: Practice string manipulation techniques.
c. Instructions: Use string concatenation and slicing to modify and display strings.
Theory: String manipulation involves various operations that can be performed on strings.
These operations include concatenation, slicing, indexing, and using built-in functions like
upper(), lower(), replace(), and split(). Strings are sequences of characters and can be indexed
and sliced similarly to lists.
Viva Questions:
String Manipulation
What is a string in Python?
How do you create a string in Python?
What are some common string operations?
How do you concatenate strings in Python?
Explain string slicing with an example.
What is the use of the split() and join() methods in strings?
7
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
Case Study:-
Write a program to find index value of the substring in the given string.
Write a python program to check whether the string is Symmetrical or Palindrome
Write a Python program to print even length words in a input string.
Write a Python program that accepts the user's first and last name and prints them in
reverse order
8
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
9
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
10
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
Viva Questions
If-Else Statements
What is an if-else statement, and when would you use it?
Explain the syntax of an if-else statement in Python.
Can you nest if-else statements? Provide an example.
For Loop
What is a for loop, and how does it work in Python?
Explain how a for loop can be used to iterate over a list or a string.
How would you use a for loop with the range() function? Provide an example.
While Loop
What is a while loop, and when would you use it?
How does a while loop differ from a for loop?
Explain how a while loop can potentially create an infinite loop.
Case Study:
Write a Python program that takes an age as input and prints whether the person is a child,
teenager, adult, or senior citizen based on the age.
Write a Python program that prints the first 10 natural numbers using a for loop.
Write a Python program that iterates through a list of numbers and prints each number
squared.
Write a Python program that prints numbers from 1 to 5 using a while loop.
Write a Python program that asks the user to guess a number until they get it right, using a
while loop.
12
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
13
ANNASAHEB DANGE COLLEGE OF ENGINEERING AND TECHNOLOGY, ASHTA
Department of Mechanical Engineering
Course Name and Code: Python Programming Laboratory, 2MEVS254 Class: SY
1. Purpose:
The purpose of Exception Handling in Python is to provide a way to manage errors gracefully.
This allows a program to continue running or to handle the error in a specific manner instead of
crashing. Exception handling helps in writing robust and error-resistant code by catching and
handling exceptions that may occur during runtime.
2. Objective:
Practice handling exceptions and errors in Python.
3. Instructions:
Use try-except blocks to catch and handle exceptions. Implement specific exceptions and finally
clauses where needed.
Theory:
Exception handling in Python is done using try, except, else, and finally blocks. The try block
contains the code that may throw an exception. The except block catches and handles the
exception if it occurs. The else block is optional and runs if no exception was raised. Finally, the
finally block is executed regardless of whether an exception occurred or not, typically used for
cleanup actions.
Viva Questions:
What is an Exception in Python?
How do you handle exceptions in Python?
What is the purpose of the finally block in Python?
Can you handle multiple exceptions in a single try-except block?
What is the difference between except and else in exception handling?
Case Study
Write a program that prompts the user for two numbers and handles ValueError (if the
input is not a number) and ZeroDivisionError (if the user tries to divide by zero).
Write a function that checks if a number is positive, and raises a ValueError if it’s not.
Create a custom exception class NegativeNumberError and raise it if a user inputs a
negative number.
14