II B.
Tech II Semester
PYTHON PROGRAMMING Lab
Lab External Examination Question Paper
Experiment1
a) Running instructions in Interactive interpreter and a Python Script
b) Write a program to purpose fully raise Indentation Error and correct it.
Experiment 2
a) Write a program to compute distance between two points taking input from
the user (Pythagorean Theorem).
b) Write a program add.py that takes 2 numbers as command line arguments and
prints its sum.
Experiment 3
a) Write a Program for checking whether the given number is a even number or
not.
b) Using a for loop, write a program that prints out the d ecimal equivalents of
1/2,1/3,1/4,...,1/10.
Experiment 4
a) Write a program using a for loop that loops over a sequence. What is
sequence?
b) Write a program using a while loop th at asks the user for a number, and
prints a count down from that number to zero.
Experiment 5
a) Find the sum of all the primes below two million. E ach new term in the
Fibonacci sequence is generated by adding the previous two terms. By starting
with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
b) By considering the terms in the Fibonacci sequence whose values do not
exceed four million, find the sum of the even-valued terms.
Experiment 6
a) Write a program to count the numbers of characters in the string and store
them in a dictionary data structure.
b) Write a program to use split and join methods in the st ring and trace a birth
day with a dictionary data structure.
Experiment 7
a) Write a program combine_lists that combines these lists into a di ctionary.
b) Write a program to count frequency of characters in a given file. Can you use
character frequency to tell whether the given file is a Python program file, C
program file or a text file?
Experiment 8
a) Write a program to print each line of a file in reverse order.
b) Write a program to compute the numb er of characters, words and lines in a
file.
Experiment 9
a) Write a function dups to find all duplicates in the list.
b) Write a function unique to find all the unique elements of a list.
Experiment 10
a) Write a function cumulative_product to compute cumulative product of
a list of numb ers.
b) Write a function reverse to reverse a list. Without using the reverse function.
c) Write function to compute gcd, lcm of two numbers. Each function shouldn’t
exceed one line.
Experiment 11
a) Write a program to perform addition of two square matrices.
b) Write a program to perform multiplication of two squ are matrices.
Experiment 12
Class variables and instance variable and illustration of the self variable
i) Robot.
ii) ATM Machine.
Experiment - 13
a) Write a program to implement the following figures using turtle