Prac File Correction PDF
Prac File Correction PDF
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: