0% found this document useful (0 votes)
56 views13 pages

Prac File Correction PDF

The document contains descriptions of 20 Python programs. Each program includes an objective, task, sample code, and output. The tasks involve concepts like file handling, loops, functions, lists, dictionaries, reading/writing files and CSV files.

Uploaded by

krishadhikari25
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)
56 views13 pages

Prac File Correction PDF

The document contains descriptions of 20 Python programs. Each program includes an objective, task, sample code, and output. The tasks involve concepts like file handling, loops, functions, lists, dictionaries, reading/writing files and CSV files.

Uploaded by

krishadhikari25
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/ 13

Program-18

Objective: To understand the concept of multiple files handing in


Python.
Task: Assuming that a text file named TEXT1.TXT already contains
some text written into it, write a function named vowelwords(), that
reads the file TEXT1.TXT and creates a new file named TEXT2.TXT,
which shall contain only those words from the file TEXT1.TXT which
don’t start with an uppercase vowel (i.e., with ‘A’, ‘E’, ‘I’, ‘O’, ‘U’). For
example, if the file TEXT1.TXT contains Carry Umbrella and Overcoat
When It rains. Then the text file TEXT2.TXT shall contain Carry and
When rains
TEXT1.TXT:

Source Code:

TEXT2.TXT:

Output:
Program-5
Objective: To understand the concepts of while() loop.
Task: Write a program to determine whether a number is a perfect
number, an Armstrong number or a palindrome.
Source Code:
Output:
Program-11
Objective: To understand the concept of list as parameter to a
function.
Task: Write a Python script to print largest and smallest element
present in a list without using min() and max() built in functions. The
list should be passed as parameter to a function.
Source Code:

Output:
Program-19
Objective: To understand the working of readlines() function.
Task: Write a function in PYTHON to count the number of lines
ending with a vowel from a text file 'STORY1.TXT'

Text File:

Source Code:

Output:
Program-20
Objective: To understand the working of readline() function.
Task: Read a text file(story.txt) line by line and display each word
separated by a #.

Text File:

Source Code:

Output:
Program-25
Objective: To understand the concept of csv.reader(), next(), header
in csv file.
Task: program to read and display CSV file(authors.csv) without
heading and avoid blank lines between records
CSV File:

Source Code:

Output:
Program-4
Objective: To understand the concepts of simple & nested for()
loop.
Task: Write a program to input the value of x and n and print the
sum of the following series:
•1 + x + x ² + x ³+ x ⁴ + x ⁵+...x^n
• 1 − 𝑥 + 𝑥² − 𝑥³ + 𝑥 ⁴ − 𝑥 ⁵+ . .. 𝑥^ 𝑛
• 𝑥 − 𝑥²/2 + 𝑥³ /3+ 𝑥 ⁴/4 − 𝑥 ⁵/ 5 . .. 𝑥 ^𝑛 / 𝑛
• 𝑥 + x ² /2! − 𝑥³ /3! + 𝑥 ⁴ /4! − 𝑥 ⁵/5! . .. 𝑥^ 𝑛 / 𝑛
Source Code:
Output:
Program-13
Objective: To understand the concept of dictionary as an argument
to a function.
Task: Write a Python script to create a dictionary to store AQI(Air
quality index) for ten cities of India and display best and worst city
name based of AQI. Use Dictionary as an argument to a function

Source Code:
Output:
Program-8
Objective: To understand the concepts of for() loop, function
parameters and return value.
Task: Write a Python script to calculate the factorial of a given
number using function. The number should be passed as parameter
and function should return the value of factorial.

Source Code:

Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy