Constitution
Constitution
1) You are tasked with automating a repetitive file-renaming task. How would you
approach this problem using Python? Write a Python script to rename files in a
folder sequentially (e.g., file1.txt, file2.txt).
2) What is Python, and why is it widely used in fields such as data science and web
development? List its key features.
3) Your data science team uses Google Colab for collaborative analysis. How would
you upload a dataset and visualize the first five rows using Python in Google Colab?
4) Explain the advantages of using Google Colab over local development
environments.
5) You are building a tip calculator for a restaurant. Ask the user to input the bill
amount (float), calculate a 15% tip, and display the result.
6) Differentiate between mutable and immutable data types in Python. Are integers
mutable?
7) Create a program that accepts a sentence from the user and performs the
following: Counts the number of words. Replaces all occurrences of the word
"Python" with "Coding".
8) What is the difference between the find() and index() string methods? Explain with
examples.
9) Write a program that accepts a user’s name and age, and prints: "Hello [Name], in
10 years, you will be [Age + 10] years old."
10) How does the input() function handle different data types? How can you ensure
the input is of a specific type, like an integer?
11) Write a program that calculates the square root of a number. Include error
handling to manage invalid inputs like strings or negative numbers.
12) Develop a program that prints the multiplication table for a user-specified
number using a for loop. Add input validation to ensure the user enters only
positive integers.
13) Explain the differences between a while loop and a for loop. When would you
choose one over the other?
14) Write a program to accept a list of numbers from the user. Sort the list in
ascending order and remove any duplicates.
15) What is the difference between append() and extend() in Python lists? Provide
examples.
16) You are given a tuple containing product prices. Write a Python function that
calculates the average price.
17) Why are tuples immutable? How does immutability impact their performance
compared to lists?
18) Create a Python program to find the union, intersection, and difference between
two sets of student names.
19) What are some real-life use cases of sets in Python? How do they differ from
lists?
20) Create a dictionary to store the marks of students in three subjects. Write a
program to calculate and display each student’s average mark.
21) What are dictionary keys, and why must they be immutable? Can you use a list
as a dictionary key?
22) Your team needs a data visualization library. Research and provide a brief script
that uses Matplotlib to create a simple bar chart.
23) What is a Python library? Explain how libraries like Pandas, Matplotlib, and
NumPy are used in different domains.
24) Write a Python program to create a 3x3 NumPy array filled with random integers.
Calculate its row-wise and column-wise sums.
25) How do NumPy arrays differ from Python lists? Why are NumPy arrays preferred
in data processing?
26) Create a 4D NumPy array to store monthly sales data for four products across
three regions over two years. Write a script to calculate the total sales for each
product.
27) Explain the concept of high-dimensional arrays. How does slicing work in a 3D or
4D NumPy array?
UNIT-V