0% found this document useful (0 votes)
6 views6 pages

Python Programming Lab Manual

The document is a Python Programming Lab Manual that outlines various exercises aimed at exploring Python's official website, using its built-in help system, and performing basic programming tasks. It includes procedures for using the Python interpreter as a calculator, calculating compound interest, reading user input, printing patterns, and checking character types. Each section provides a clear aim, procedure, and expected output for the exercises.

Uploaded by

naniganji2703
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)
6 views6 pages

Python Programming Lab Manual

The document is a Python Programming Lab Manual that outlines various exercises aimed at exploring Python's official website, using its built-in help system, and performing basic programming tasks. It includes procedures for using the Python interpreter as a calculator, calculating compound interest, reading user input, printing patterns, and checking character types. Each section provides a clear aim, procedure, and expected output for the exercises.

Uploaded by

naniganji2703
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

PYTHON PROGRAMMING LAB

MANUAL

PYTHON PROGRAMMING LAB


Ms. Konda Sravya
1. I) AIM: To explore the official Python website
Procedure
1. Open any web browser (Chrome, Edge, Firefox, etc.).
2. In the address bar, type: [Link]
3. Press Enter.
Observation
The homepage of Python Software Foundation website contains:
• Information about the Python programming language.
• Download option for the latest Python version.
• Documentation section.
• Community and support links.
• News and updates related to Python.

Important Sections on the Website


Downloads
Used to download the latest version of Python for Windows, Mac, or Linux.
Documentation
Contains official Python tutorials and reference guides.
About
Gives information about Python’s history and features.
Community
Provides discussion forums and user groups.
Result
Successfully explored the official Python website and understood its main sections and features.
II) AIM: To learn how to use the built-in help system in Python.
Procedure
1. Open Command Prompt (Windows) or Terminal (Mac/Linux).
2. Type: python
and press Enter to start the Python interpreter.
3. At the Python prompt (>>>), type: help()

Python Programming Lab Manual


Observation
After typing help(), the Python interactive help utility starts.
It displays:
Welcome to Python 3.14's help utility! If this is your first time using
Python, you should definitely check out the tutorial at
[Link]

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To get a list of available
modules, keywords, symbols, or topics, enter "modules", "keywords",
"symbols", or "topics".

You can use the following keyboard shortcuts at the main interpreter prompt.
F1: enter interactive help, F2: enter history browsing mode, F3: enter paste
mode (press again to exit).

Each module also comes with a one-line summary of what it does; to list
the modules whose name or summary contain a given string such as "spam",
enter "modules spam".

To quit this help utility and return to the interpreter,


enter "q", "quit" or "exit".
Now you can:
Type the name of any function (example: print)
It displays:

Help on built-in function print in module builtins:


print(*args, sep=' ', end='\n', file=None, flush=False)

Prints the values to a stream, or to [Link] by default.

sep

string inserted between values, default a space.

end

string appended after the last value, default a newline.

Python Programming Lab Manual


file

a file-like object (stream); defaults to the current [Link].

flush

whether to forcibly flush the stream.

2. AIM: To start a Python interpreter and use it as a Calculator.


Procedure
1. Open Command Prompt (Windows) or Terminal (Mac/Linux).
2. Type: python and press Enter to start the Python interpreter.
3. At the Python prompt (>>>),
The symbol >>> is called the Python prompt.
Now you can perform mathematical operations
Operations
Addition
>>> 2+3
5
Subtraction
>>>3-2
1
Multiplication
>>> 3*2
6

Python Programming Lab Manual


Division
>>>5/2
2.5
Modular Division(gives remainder)
>>>5%2
1
Power
>>>5**2
25

Conclusion
The Python interpreter can be used as a calculator to perform basic arithmetic operations such as addition,
subtraction, multiplication, division, modulus, and exponentiation.
3. AIM: To write a Python program to calculate Compound Interest when Principal, Rate of Interest, and
Number of Periods are given.
Program
principal = 10000
rate = 10
time = 2
amount = principal*((1+(rate/100))**time)
compound_interest = amount - principal
print("compound interest is : ",compound_interest)
Output
compound interest is : 2100.000000000002
4. AIM: To read the name, address, email and phone number of a person through the keyboard and print the
details.
Program
# to read name, address, email, phone no from user
name = input("enter your name: ")
address = input("enter your address: ")
email = input("enter your email: ")
phone_number = int(input("enter your phone number: "))
# to display the details
print("your name is: "+name)
print("your address is: "+address)
print("your email is: "+email)
print("your phone number is"+str(phone_number))
Output
enter your name: sphoorthy
enter your address: nadergul
Python Programming Lab Manual
enter your email: sphoorthy123@[Link]
enter your phone number: 1234567890
your name is: sphoorthy
your address is: nadergul
your email is: sphoorthy123@[Link]
your phone number is1234567890
5. AIM: To print the following pattern:
5
44
333
2222
11111
Program
n=5
for i in range(n,0,-1):
for j in range(n-i+1):
print(i,end=" ")
print()
Output
5
44
333
2222
11111
6. AIM: Write a program to check whether the given input is digit or lowercase character or uppercase
character or a special character(use 'if-else-if' ladder)
Program
ch = input("enter any character: ")
if [Link]():
print(ch,"is a digit")
elif [Link]():
print(ch,"is a lower case character")
elif [Link]():
print(ch,"is a upper case character")
else:
print(ch,"is a special case character")
Output1
enter any character: a
a is a lower case character
Output2
enter any character: A
A is a upper case character
Output3
enter any character: 2
2 is a digit
Output4
enter any character: @
@ is a special case character

Python Programming Lab Manual

Common questions

Powered by AI

Python's simplicity and powerful features make it highly beneficial in educational contexts and practical applications. For education, Python's clear syntax and readability ease the learning curve for beginners. It serves as an excellent tool for teaching foundational programming concepts through hands-on practice, such as arithmetic operations, input/output handling, and control structures. For practical applications, Python's extensive libraries and support for various programming paradigms enhance its applicability in fields like web development, data science, and automation, making it an all-encompassing tool that bridges learning and real-world implementation effectively .

Utilizing the Python interpreter as a calculator demonstrates its versatility and user-friendliness for performing computations. This capability makes Python not only suitable for programming but also for quick calculations without needing additional software. It supports operations such as addition, subtraction, multiplication, division, modulus, and exponentiation, making it a convenient tool for educational purposes and quick calculations .

New programmers may face challenges such as understanding Python's syntax, lack of familiarity with programming concepts, and managing errors or debugging. Mitigating these challenges involves utilizing resources like Python's official documentation for structured learning and practical guides. Engaging with community forums can provide support and assistance in troubleshooting. Starting with simple projects and gradually increasing complexity helps build confidence and competence. Emphasizing practice through interactive coding environments and exercises hones problem-solving skills and accelerates learning .

Python programs can effectively handle user input and output by utilizing built-in functions like 'input()' for receiving data and 'print()' for displaying results. For instance, a program can read multiple inputs from a user, such as name, address, email, and phone number, using 'input()', process this data, and use 'print()' to output a formatted message with the user's details. Efficient input handling often involves type casting, and robust output involves string concatenation and formatting to ensure clarity and correctness of information presented to the user .

The Python interactive help utility provides crucial features that are essential for learning and using Python. It delivers a tutorial link for newcomers, lists available modules, keywords, and topics, and allows users to access detailed information about functions and modules by their names. This system is important as it serves as a self-contained resource for programmers to understand Python's functionalities, enhance their coding skills, and troubleshoot issues autonomously without external resources, thus fostering an environment of self-learning and discovery .

The built-in help system in Python provides an interactive utility that assists developers by offering detailed information on Python modules, keywords, symbols, or topics. When a developer types 'help()' in the Python interpreter, the system displays guidance on using Python, including tutorials and lists of available modules. This utility allows users to query for help on specific functions by entering their names, providing descriptions and parameter details, which is crucial for writing and understanding Python code accurately .

The official Python website offers various resources that support learning and effective usage of Python. It has a Documentation section containing official tutorials and reference guides which help users understand and utilize Python's features fully. The Community section provides discussion forums and user groups, facilitating peer support and knowledge exchange. Additionally, the site provides a Download section for accessing the latest Python versions compatible with different operating systems .

The 'if-else-if' ladder in Python plays a critical role in decision-making by allowing the program to choose between multiple actions based on conditions. It evaluates expressions sequentially from top to bottom, and executes the block of code corresponding to the first true condition. This construct facilitates checking for different categories, like determining if a character is a digit, lowercase letter, uppercase letter, or special character, thereby enabling complex conditional logic and flow control in a structured manner .

Integrating object-oriented programming principles in Python can significantly enhance code structure by utilizing classes and objects. Python, as an OOP language, allows developers to define classes that encapsulate data attributes and methods, promoting modularity and reusability. Inheritance and polymorphism can be employed to derive new classes from existing ones and override methods for specific behaviors, respectively. Encapsulation ensures data is only accessible through defined interfaces, promoting robustness. This structured approach improves maintainability, reduces redundancy, and supports complex applications development .

To print a specified pattern using loops in Python, one can employ nested loops. In the given scenario, a descending numerical pattern is printed where each line displays a certain number. The outer loop controls the number of lines and runs from the starting number down to 1. The inner loop determines how many times the number should be printed on each line, based on the position in the sequence. Utilizing the 'range' function and 'print' statements with repeated values achieves the desired pattern output effectively .

You might also like