Python programming
Python programming
Keezhamoongiladi, Chidambaram-608102
Class: I B.Sc Mathematics Course Code: 23UPYPE15
Semester: I Title: Allied-Python Programming
UNIT-I
SECTION-A
1. .Match the following
if - lists
( ) - keyword
{ } - tuple
[ ] - dictionary
2. ----------- is known as python chevron prompt.
3. Python is a ------------ language.
4. Match the following
Step: 1 - python 2.7 folder
Step: 2 - python command line
Step: 3 - START
Step: 4 - All programs
5. Which character is used in python for comments?
(a) & (b) * (c) # (d) @
6. Numeric, lists, tuples are the
(a) keywords (b) comments (c) identifiers (d) data types
7. Match the following
**= - floor division
*= - modulus
%= - exponential
//= - multiply
8. The slice operator is used for ------------.
9. Boolean expressions have only one of the two values
(a) true or false (b) positive or negative (c) > or < (d) # or &
SECTION-B
1. Write the procedure for installing python on Windows OS.
2. How to initialize a variable. Give an example.
3. Describe about a List and give an example.
4. Describe about a Dictionary and give an example.
5. Explain assignment operator and give an example.
SECTION-C
1. Explain any three data types in python with examples.
2. What are the different types of operators in python and explain it.
3. Explain string operation and give an example.
4. Explain comparison operator and give an example.
5. Explain membership operator and identity operator and give an example.
UNIT-II
SECTION-A
1. Range (n) generates a sequence of numbers that starts with
(a) 1 (b) 0 (c) n (d) n-1
2. If the break statement in a ------------ is executed.
3. The Boolean expression after the if statement is called the ------------.
4. Match the following
Var = = - convert all letters
.lower( ) - block of statement
if elif else - expression
5. The alternative execution provides ------------ possibilities.
SECTION-B
1. Write a python program to display the Fibonacci sequence for n terms.
2. Write a python program to check if the input year is a leap year or not.
3. Explain for loop and give an example.
4. Explain range ( ) function and give an example.
5. Explain break and continue statements and give an example.
SECTION-C
1. Draw a flow diagram of while statement and give an example.
2. Explain input from keyboard and give an example.
3. Explain if elif else statement and give an example.
UNIT-III
SECTION-A
1. Match the following
dir ( ) - anonymous function
math - user defined function
lambda - module
2. The syntax of the return statement is
(a) return (expression) (b) return [expression] (c) return ( ) (d) None of them
3. ------------ is an anonymous function.
4. The return statement is used to -------------.
5. The help ( ) function is a ------------in Python Programming Language.
SECTION-B
1. Write a program to get a calendar for a month.
2. Explain user defined function with an example.
3. Explain keyword arguments with an example.
4. Write a function called ninelines that uses a function threelines to print nine blank
lines. Print twenty seven new lines using this.
SECTION-C
1. Explain the types of arguments with an example.
2. Explain the date and time with an example.
3. Explain the dir ( ) and help( ) functions with an example.
UNIT-IV
SECTION-A
1. Match the following
file.tell ( ) - to access the file
file.flush ( ) - file’s current position
file.mode - internal buffer memory
2. --------------- is the syntax for opening a file in Python.
3. Python strings can have -------------- not just text.
4. Deleting a file in Python is done with the help of
(a) delete ( ) (b) exit ( ) (c) remove ( ) (d) None of them
5. Directory can be said to be a ------------- of files.
SECTION-B
1. Give the syntax for each of basic directory methods.
2. Explain reading from a file with example.
3. Explain writing to a file with example.
4. Explain closing a file with example.
5. Explain opening a file with example.
SECTION-C
1. Explain various methods to work with directories.
2. Explain various methods to manipulate files.
3. List out the different modes of opening the file.
UNIT-V
SECTION-A
1. ------------- is the process of creation of an object of a class.
2. The syntax of creating an object in Python is
(a) obj_name = class_name ( )
(b) class_name ( ) = obj_name
(c) None of them
3. The objects are mutable means ---------------.
4. Match the following
Varname - private
_varname - keyword
Class - public
SECTION-B
1. Write a function that has class Animal with a method legs. Create two subclasses
Tiger and Dog. Now, access the method leg explicity with the class Dog and
implicity with the class Tiger.
2. Explain class, method, instance and function overloading with example.
3. How are the objects created in Python? Give an example.
4. Explain objects as return values with example.
SECTION-C
1. Write a Python program to demonstrate classes and their attributes.
2. Write a Python program to demonstrate Inheritance and method overriding.
3. Explain built-in class attributes with example.
4. Explain data encapsulation with example.