0% found this document useful (0 votes)
7 views1 page

Python Programming Exercises and Examples

The document outlines a series of programming tasks in Python, including finding the largest of three numbers, displaying prime numbers, swapping variables, and demonstrating various operators. It also includes tasks for string manipulation, function creation, list operations, tuple handling, dictionary key checking, and class creation with inheritance. Additionally, it covers the creation of NumPy arrays, showcasing fundamental programming concepts and practices in Python.

Uploaded by

nsinguluri819
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 views1 page

Python Programming Exercises and Examples

The document outlines a series of programming tasks in Python, including finding the largest of three numbers, displaying prime numbers, swapping variables, and demonstrating various operators. It also includes tasks for string manipulation, function creation, list operations, tuple handling, dictionary key checking, and class creation with inheritance. Additionally, it covers the creation of NumPy arrays, showcasing fundamental programming concepts and practices in Python.

Uploaded by

nsinguluri819
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. Write a program to find the largest element among three Numbers.

2. Write a Program to display all prime numbers within an interval

3. Write a program to swap two numbers without using a temporary variable.

4. Demonstrate the following Operators in Python with suitable examples.

i) Arithmetic Operators ii) Relational Operators iii) Assignment Operatorsiv) Logical

Operators v) Bit wise Operators vi) Ternary Operator vii) Membership Operatorsviii)

Identity Operators

5. Write a program to print multiplication table of a given number.

[Link] a Python program to input a string and print:

1. The first character

2. The last character

3. The length of the string

7. Write a Python program to create a function that takes two numbers and returns their sum.
Call the function and display the result.

8. Write a Python program to create a list of 5 numbers and:

1. Print the largest number

2. Print the smallest number

3. Print the list in reverse order

[Link] a Python function greet(name, message="Welcome") that prints a greeting message.


Call the function with and without the default parameter.

10. 1. Write a program to create tuples (name, age, address, college) for at least two

members and concatenate the tuples and print the concatenated tuples.

11. Write a program to check if a given key exists in a dictionary or not.

12. Write a Python program to create a class Student with attributes name and age.
Create an object and display the student details.

13. Write a Python program that defines a class Car with a constructor that initializes brand and
[Link] two objects and print their details.

14. Write a Python program that demonstrates single inheritance:


Create a base class Animal with a method sound().
Create a derived class Dog that inherits from Animal and prints "Bark".

15. Write a Python program to demonstrate multiple inheritance:


Create two base classes Father and Mother with simple methods.
Create a derived class Child that inherits from both and calls methods from both parents.

16. Python Program to demonstrate NumPy arrays creation using array () function.

You might also like