Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Python file

Uploaded by

hbdz936
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Python file

Uploaded by

hbdz936
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

INDIRA GANDHI DELHI TECHNICAL UNIVERSITY

KASHMERE GATE, NEW DELHI-110006

Python Program File


(2024-2028)

SUBMITTED BY: SUBMITTED TO:


HARSHITA BHARDWAJ MS.
IT1 RICHA
04401032024 MA’AM
INDEX
S.NO PROGRAMS
1. Implement a program to calculate the
remainder of two numbers using the modulo operator

2. Write a program that takes two lists and returns True if


they have at least one common member.

3. Write a Python script to sort (ascending and


descending) a dictionary by value.

4. Write Python programs to demonstrate the following: i)


input( ) ii) print( ) iii) ‘sep’ attribute iv) ‘end’ attribute v)
replacement Operator ({ })

5. Python program that accepts a string and calculates


the number of digits and Letters

6. Write a Python program to get a substring from a given


string starting from the 3rd character to the 5th character.

7. Write a Python program to remove a key-value pair


from a dictionary

8. Write a Python program to read and write to a binary


file using random access methods

9. Write a Python program to handle the exception that


occurs when trying to open a nonexistent file

10. Write a Python program to handle the exception that


occurs when accessing an index out of range in a list

11. Create a Python class Student with attributes name and grade. Use
the__str__ and __len__ in-built functions to customize the string
representation and length of the object.

12. Create a base class Animal with a method sound. Create a derived class
Dog that overrides the sound method to print & quot; Woof & quot;. Create
an object of the Dog class and call its sound method.

13. Create a Python class named Car with attributes brand and model. Create
an object of this class and print its attributes
14. Write a Python function that takes a list as an argument and returns the sum
of all the elements in the list. Test this function with a sample list

15. Write a Python function named operate that takes two numbers and an
operation as arguments. The operation can be add, subtract, multiply, or
divide. Use lambda functions to perform the respective operations.

16. Use Matplotlib to plot a sine wave from 0 to 2π

17. Create a NumPy array containing numbers from 1 to 10.


Calculate its mean, median, and standard deviation.

18. Create a basic Flask application with a route that


returns
"Hello, this is our first flask website!”.

19. Create a Tkinter window with an entry field. When a button is clicked,
display the entered text in a message box

20. Install PyTorch. Create a tensor with random values


and perform basic operations like addition and
multiplication.
Code-1:

OUTPUT:

Code-2:

Output:
Code-3

Output:

Code-4:

Output:
Code-5:

Output:

Code-6:

Output:
Code-7

Output:

Code-8:

Output:
Code-9:

OUTPUT:

Code-10:
:

OUTPUT:
CODE-11:

OUTPUT:

Code-12:

Output:
Code-13:

OUTPUT:

Code-14:

Output:
Code-15:

Output:
CODE-16:

OUTPUT:-
Code-17.:

Output:

CODE-18:

OUTPUT:
CODE-19:

OUTPUT:
CODE-20:

OUTPUT:

You might also like