0% found this document useful (0 votes)
41 views4 pages

Assignment 2

Uploaded by

gayatri mohite
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)
41 views4 pages

Assignment 2

Uploaded by

gayatri mohite
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
You are on page 1/ 4

Function:

Q.1) Define a function. Explain function definition and function call with an example.

Q.2)Differentiate between Local & Global variable. Write a python program to demonstrate
difference between local and global variable.

Q.3)Explain the following types of function arguments with examples:

i) Required arguments ii) Keyword arguments

iii)Default arguments

Q.4)What is a lambda function? Explain it with a suitable example.

Q.5) Explain Module and Package

Programs:

1) Write python program using function to find greatest of three numbers by passing
numbers as argument..
2) Write python program using lambada function to find whether number is odd or even.
3) Write a python program to display tables from 1 to 10 using formatting character.
4) Write a program to swap two numbers using a function
5) Write program using lambda function which adds 10 th the number passed in as an
argument and print the result?

String

Q.1) What is a string?

Q.2) String Operation i) Concatenation ii) Appending iii) String repetition

Q.3) Explain indexing and slicing operation on string?

Q.4) Write a program to count the number of characters and words in the given string.

s = “Welcome to the world of python programming”

Q.5) Explain following string methods with example.

i) strip() ii) index() iii) isdigit()

Q.6) Explain following with suitable examples?


 ord() and chr() functions
 in and not in operators on string

Q.7) Explain following string methods with example.

i) Rindex ii) Z fill iii) Split

Q.9) What will be the output of following statement S = “Welcome to Python”.

i) Print (s[1:9])

ii) Print (s[ :6])

iii) Print (s[4: ])

iv) Print (s[1: –1])

v) Print (“Come” not in str)

Q.10) Explain following string methods with example : [6]

i) Join ii) Enumerate iii) 1 strip

Q.11) Write python, program to find whether a given character is present in a string or not. In
case it is present print the index at which it is present. Do not use built in string method.

Q.12) Write a python program to check whether a given string starts with specified character.

Q13) Explain string formatting operators in detail

Q14) Explain built in method and function in details?

Q.15)Explain string module in details?

Q16)s=”Programming and Problem Solving”? [5]

1.print(s[:11])
2.print(s[::-1])
3.print(s[“And” not in s)
4.print(s[4])
5.prints[0:10])

Q.17)Justify strings are immutable with example?

Q.18) Explain following string methods with example. [6]


i) title() ii) startswith() iii) zfill()

Q.19) Write Python Program to display a string and count character in the string using a loop?

Object Oriented Programming Language

Q.1) Justify the statement “Inheritance helps to make reusable code”

Q.2) Write a python program that uses class to store exam number and marks of four subjects.
Use list to store the marks of four subject

Q.3) Explain following Terms : i) Data Abstraction & Encapsulation ii) Polymorphism

Q.4) Write a python program to create class car with two attributes name & cost. Create two
objects and display information

Q.5) Explain the init( ) method?

Q.6)Explain class variables and object variable with suitable example

Q.7) Write a program to create a class ‘Employee’ with two attributes. Display the details of two
employees?

File Handling

Q.1)What is a file? Explain different access modes for opening files

Q.2)Explain text and binary files

Q.3)What is directory? List out directory methods and explain it?

Q.4)Explain different dictionary methods with example.

Q.5)Explain relative path and absolute path of a file.?

Q.6)Explain any three methods for reading and writing files

Q.7)Write a python program that counts the number of tabs and new line characters in a file

Q.8)Write a program to copy the contents of one file to another file

Q.9)Write a program to read first 10 characters from the file and display it
Q.10)Write a python program to display current directory, create directory and remove created
directory

Q.11) Write a python program that reads data from one file and write into another file and line
by line.

You might also like