0% found this document useful (0 votes)
3 views14 pages

Python Assignment Practical

The document outlines various mathematical and programming operations, including finding roots of quadratic equations, prime number checks, pyramid printing, character type identification, string manipulations, file handling, and class definitions for 2D and 3D points. Each operation specifies input parameters and expected output results. It serves as a guide for implementing these functionalities in programming.
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)
3 views14 pages

Python Assignment Practical

The document outlines various mathematical and programming operations, including finding roots of quadratic equations, prime number checks, pyramid printing, character type identification, string manipulations, file handling, and class definitions for 2D and 3D points. Each operation specifies input parameters and expected output results. It serves as a guide for implementing these functionalities in programming.
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.

Roots of a Quadratic Equation

Input Parameters: a, b, c → coefficients of quadratic equation.

Output Parameters: Nature of roots (real, equal, complex)

Values of roots.

2. Prime Number Operations

(a)Check if n is prime

Input :Integer n

Output: Message stating whether n is prime


(b) Generate all prime numbers till n

Input: Integer n

Output: List of primes ≤ n

(c) Generate first n prime numbers

Input: Integer n

Output: First n primes


3. Pyramid and Reverse Pyramid

Input: Number of rows

Output: Printed star pyramid

Printed reverse pyramid

reversed
4. Character Operations

Input: A single character

Output: Type of character (letter/digit/special)

If letter → uppercase or lowercase


5. String Operations

Input: A string and required characters

Output: Frequency

Modified strings
6. Swap the first N characters of two strings
7. Find All Indices of Substring

Input: String1, String2


Output: List of indices or -1

8. Cube of Even Integers (Loop & List Comprehension)

Input: List of integers

Output: List of cubes of even numbers.


9. File Handling

(a) Count Characters, Words, Lines

Input: File

Output: Counts

(b) Frequency of Characters


(c) Print words in reverse order

(d) Copy even lines to "File1" & odd to "File2"


10. Dictionary of Numbers and Cubes

Input: Range 1 to 5

Output: Dictionary like {1:1, 2:8, ...}

11. Tuple Operations

Input: Tuple t1

Output: Printed values and new tuples


12. Employee Class

Input: Employee details

Count variable (class variable)

Output: Display employee info

13. Class 2DPoint

Input: x and y coordinates

Output: Printed coordinates


Distance between points

14. Class 3DPoint (Inheritance)

Input: x, y, z values

Output: Printed coordinates

15. Accept Name & Validate (Exception Handling)

Input: Name string

Output: Valid or invalid message

You might also like