BCAA-152P: PROGRAMMING IN PYTHON LAB
Course Outcome (CO)
CO1 Enhance the ability to solve problems using system approaches, critical and
innovative thinking and technology to create solutions.
CO2 Understand the purpose and the process of code in python.
CO3 Understand the basics of python programming like variable and operators.
CO4 Acquire programming skills in core python programming using Control
Statements
CO5 Design and analyse the working of functions in python programming.
CO6 To work with the Files, reading and writing data from the files using python
program.
DETAILED SYLLABUS
LIST OF PROGRAMS:
1. Input and Output
(a) Write a program to find the largest element among three
Numbers.
(b) Write a program to print the sum of all the even numbers in the
range 1 - 50 and print the even sum.
(c) Write a Program to display all prime numbers within an interval
of given X1 & X2.
2. Variables and Functions
a. Write a program to swap two numbers without using a temporary
variable.
b. Write a program to define a function with multiple return values.
c. Write a program to define a function using default arguments.
3. Loops and conditionals
a. Write a program to print the
following patterns using loop: *
** *** ****
b. Write a program to print multiplication table of a given number X1
to range X2.
4. Strings
a. Write a program to find the length of the string without using any
library functions.
b. Write a program to check if two strings are anagrams or not.
c. Write a program to check if the substring is present in a given
string or not.
5. Lists
a. Write a program to perform the given operations on a list:
i. add ii. insert iii. slicing
b. Write a program to perform any 5 built-in functions by taking any
list.
c. Write a program to get a list of the even numbers from a given list
of numbers. (use only comprehensions)
6. Tuples
a.Write a program to create tuples (name, age, address, college) for at
least two members and concatenate the tuples and print the
concatenated tuples.
b.Write a program to return the top 'n' most frequently occurring chars
and their respective counts.
e.g. aaaaabbbbcccc, 2 should return [(a 5) (b 4)]
7. Sets
a. Write a program to count the number of vowels in a string (No
control flow allowed).
b. Write a program that displays which letters are present in both
strings.
c. Write a program to sort given list of strings in the order of their
vowel counts.
8. Dictionaries
a. Write a program to check if a given key exists in a dictionary or
not.
b. Write a program to add a new key-value pair to an existing
dictionary.
c. Write a program to sum all the items in a given dictionary.
9. Files
a.Write a program to sort words in a file and put them in another file.
The output file should have only lower-case words, so any upper
case words from source must be lowered.
b.Write a program to find the most frequent words in a text. (read
from a text file).
10. Classes
a. Write a Python class named Person with attributes name, age,
weight (kgs), height (ft) and takes them through the
constructor and exposes a method get_bmi_result() which
returns one of "underweight", "healthy", "obese".
b. Write a Python class named Circle constructed by a radius and
two methods which will compute the area and the perimeter
of a circle.