0% found this document useful (0 votes)
7 views20 pages

Python Programming Examples and Functions

The document outlines a series of Python programming tasks, each requiring the implementation of user-defined functions for various applications. Tasks include temperature conversion, time format conversion, string manipulation, pattern printing, Fibonacci series generation, user login validation, mathematical calculations, random number generation, prime and palindrome checks, Armstrong number verification, stack implementation, file operations, and record searching in CSV files. Each program is structured with an input code section and an output section, indicating the expected functionality.

Uploaded by

arpanpal578
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views20 pages

Python Programming Examples and Functions

The document outlines a series of Python programming tasks, each requiring the implementation of user-defined functions for various applications. Tasks include temperature conversion, time format conversion, string manipulation, pattern printing, Fibonacci series generation, user login validation, mathematical calculations, random number generation, prime and palindrome checks, Armstrong number verification, stack implementation, file operations, and record searching in CSV files. Each program is structured with an input code section and an output section, indicating the expected functionality.

Uploaded by

arpanpal578
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1

PROGRAM:1
Write a program in Python to convert a given temperature in Celsius into Fahrenheit with
the help of a user defined function.

INPUT CODE:

OUTPUT:
2

PROGRAM:2
Write a Program in Python to Convert Time from 12-hour to 24-hour format.
INPUT CODE:

OUTPUT:
3

PROGRAM:3
Write a program in Python with a user defined function with a string as a parameter that
replaces all vowels in the string with a “@”
INPUT CODE:

OUTPUT:
4

PROGRAM:4
Write a program in Python to print the “Diamond Pattern” using a user defined function
with”*”.
INPUT CODE:

OUTPUT:
5

PROGRAM:5
Write a program in Python using user defined function to print the “Fibonacci Series”
Up to n terms
INPUT CODE:

OUTPUT:
6

PROGRAM:6
Write a Python program to accept the username “Admin” as the default argument and
password 123 entered by the user to allow login into the system.
INPUT CODE:

OUTPUT:
7

PROGRAM:7
Write a Python program to calculate the value of sin(x) using its Taylor series expansion up
to n terms, with the help of a user-defined function.
CODE:

OUTPUT:
8

PROGRAM 8:
Write a “Random Number Generator” program in Python that generates random numbers
between 1 and 6, which stimulates a dice.
INPUT CODE:

OUTPUT:
9

PROGRAM:9
Write a program in Python to check whether a given number is Prime Number or not using
a user-defined function.
INPUT CODE:

OUTPUT:
10

PROGRAM:1O
Write a program in Python to check whether a given number is a Palindrome or not using a
user-defined function.
INPUT CODE:

OUTPUT:
11

PROGRAM:11
Write a program in Python to check whether a given number is an Armstrong number or not
using a user-defined function
INPUT CODE:

OUTPUT:
12

PROGRAM:12
Write a program in Python to implement a stack using a list data structure.
INPUT CODE:
13

OUTPUT:
14

PROGRAM:13
Write a program that accepts a filename of a text file and displays the longest line in the file
.
INPUT CODE:

OUTPUT:
15

PROGRAM:14
Write a program in Python that removes all the lines that contain in the character ‘a’ in a file
and write it to another file
INPUT CODE:

OUTPUT:
16

PROGRAM:15
Write a program in Python to perform read and write operation for a [Link] file having
fields as roll number, name, stream and percentage.
INPUT CODE:

OUTPUT:
17

PROGRAM:16
Write a program in Python to search the record of a particular student from a CSV file based
on an input name.
INPUT CODE:
18

OUTPUT:
19

PROGRAM:17
Write a program to create binary file with roll number and name. Then search for a given
roll number and display the name. If the roll number is not found. Then display the
appropriate message.
INPUT CODE:
20

OUTPUT:

You might also like