0% found this document useful (0 votes)
3 views6 pages

Rupesh Python New

The document outlines a series of practical exercises for a Python programming lab, covering topics such as basic syntax, control flow, data structures, file handling, and functions. Each exercise includes specific programming tasks that students must complete, such as calculating distances, implementing search algorithms, and analyzing data using libraries like NumPy and Pandas. The exercises are designed to enhance students' understanding of Python programming concepts and problem-solving skills.

Uploaded by

spbrother594
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Rupesh Python New

The document outlines a series of practical exercises for a Python programming lab, covering topics such as basic syntax, control flow, data structures, file handling, and functions. Each exercise includes specific programming tasks that students must complete, such as calculating distances, implementing search algorithms, and analyzing data using libraries like NumPy and Pandas. The exercises are designed to enhance students' understanding of Python programming concepts and problem-solving skills.

Uploaded by

spbrother594
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

INDEX

PYTHON PROGRAMMING Lab (CSP-005)


Practical Name Date
S. Page Teacher
No No. Remarks

1. Exercise 1 - Basics.
a) Running instructions in Interactive interpreter
and a Python Script.

b) Write a program to purposefully raise


Indentation Error and Correct it.

2. Exercise 2 – Operations.
a) Write a program to compute distance between
two points taking input from the user (Pythagorean
Theorem).
b) Write a program [Link] that takes 2 numbers as
command line arguments and prints its sum.

3.
Exercise - 3 Control Flow.
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 decimal equivalents of 1/2, 1/3, 1/4, . . . ,1/10.
c) Write a program using a for loop that loops over
a sequence.
d) Write a program using a while loop that asks the
user for a number, and prints a countdown from that
number to zero.
4. Exercise 4 - Control Flow – Continued.
a) Find the sum of all the primes below two
million. Adding the previous two terms, each new
term in the Fibonacci sequence is generated. 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.
c) Linear search and Binary search.
d) Selection sort, Insertion sort

5. Exercise - 5 – DS.
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 string and trace a birthday with a dictionary
data structure.

6. Exercise - 6 DS – Continued.
a) Write a program combine_lists that combines
these lists into a dictionary. 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?
7. Exercise - 7 Files.
a) Write a program to print each line of a file in
reverse order.
b) Write a program to compute the number of
characters, words and lines in a file

8.
Exercise - 8 Functions
a) Write a function ball_collide that takes two
balls as parameters and computes if they are
colliding. Your function should return a Boolean
representing whether or not the balls are colliding.
Hint: Represent a ball on a plane as a tuple of (x, y,
r), r being the radius If (distance between two balls
centers) <= (sum of their radii), then (they are
colliding)
b) Find the mean, median, and mode for the
given set of numbers in a list.

9. Exercise - 9 Functions – Continued


a) Write a func-on nearly_equal to test whether
two strings are nearly equal. Two strings a and bare
nearly equal when a single muta-on on b can
generate a.
b) Write a func-on dups to find all duplicates in
the list.
c) Write a func-on unique to find all the unique
elements of a list
10. Exercise - 10 - Functions –Problem-Solving
a) Write a function cumulative_product to
compute the cumulative product of a list of numbers.
b) Write a function reverse to reverse a list.
Without using the reverse function.
c) Write a function to compute gcd, lcm of two
numbers. Each function shouldn’t exceed one line.

11. Exercise - 11–Python Packages


a) Install packages requests, flask and explore
them. using (pip).
b) Plot graphs using python and Matplotlib.
c) Data Analysis using NumPy and Pandas
Libraries
Exercise 4 - Control Flow – Continued.
a) Find the sum of all the primes below two million. Adding the previous two terms, each new term
in the Fibonacci sequence is generated. 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.

Linear search and Binary search.


Selection sort, Insertion sort

You might also like