[go: up one dir, main page]

0% found this document useful (0 votes)
20 views16 pages

Python Final Project

Uploaded by

pandeykajal6981
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)
20 views16 pages

Python Final Project

Uploaded by

pandeykajal6981
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/ 16

Practical File

Programming with
Python
Name - JAIRAJ PANDEY
PRACTICAL
Roll Number-24521
FILE PYTHON
Course-B.SC Computer
Science College-
Shaheed Sukhdev
College Of Business
Studies, University Of
Delhi
01 WAP to find the roots of a quadratic equation Code

PRACTICAL FILE PYTHON


INPUT

OUTPUT

1|Page
02 WAP to accept a number ‘n’ and a. Check if ’n’ is prime b.
Generate all prime numbers till ‘n’ c. Generate first ‘n’ prime
numbers This program may be done using functions. Code

INPUT

OUTPUT

2|Page
03 WAP to create a pyramid of the character
‘*’ and a reverse pyramid

INPUT

OUTPUT

3|Page
04. WAP that accepts a character and performs the following: a. print whether the
character is a letter or numeric digit or special character. Code

INPUT

OUTPUT

4|Page
B)if the character is a letter, print whether the letter is uppercase or
lowercase Code

INPUT

OUTPUT

5|Page
C)c. if the character is a numeric digit, prints its name in text (e.g., if input is 9,
output is NINE). Code

INPUT

OUTPUT

6|Page
6. WAP to swap the first n characters of two strings.

input

Output

7|Page
07 Write a function that accepts two strings and returns the indices of all the
occurrences of the second string in the first string as a list. If the second string
is not present in the first string then it should return -1.

CODE

8|Page
Q8.WAP to create a list of the cubes of only the even integers appearing in
the input list (may have elements of other types also) using the following: a.
for loop b. list comprehension

INPUT

OUTPT

9|Page
Q.9 WAP to read a file and a. Print the total number of characters, words and lines
in the file. b. Calculate the frequency of each character in the file. Use a variable of
dictionary type to maintain the count. c. Print the words in reverse order. d. Copy
even lines of the file to a file named ‘File1’ and odd lines to another file named
‘File2’

INPUT

10 | P a g e
OUTPUT

11 | P a g e
Q10. WAP to define a class Point with coordinates x and y as attributes. Create
relevant methods and print the objects. Also define a method distance to calculate
the distance between any two point objects

INPUT

OUTPUT

12 | P a g e
Q11.Write a function that prints a dictionary where the keys are numbers
between 1 and 5 and the values are cubes of the keys.

INPUT

OUTPUT

13 | P a g e
Q12. Consider a tuple t1=(1, 2, 5, 7, 9, 2, 4, 6, 8, 10). WAP to perform following
operations: a. Print half the values of the tuple in one line and the other half in the
next line. b. Print another tuple whose values are even numbers in the given tuple.
c. Concatenate a tuple t2=(11,13,15) with t1. d. Return maximum and minimum
value from this tuple

INPUT

OUTPUT

14 | P a g e
13.WAP to accept a name from a user. Raise and handle appropriate
exception(s) if the text entered by the user contains digits and/or special
characters

CODE

15 | P a g e

You might also like