0% found this document useful (0 votes)
3 views

Python_Practice_Questions_Updated

The document contains a collection of Python practice questions categorized into various topics such as basic problems, operators, loops, data structures, file handling, exception handling, sorting algorithms, vectors and matrices, and case studies. Each category includes specific tasks to enhance programming skills, such as checking numbers, sorting lists, handling files, and implementing algorithms. The questions aim to provide a comprehensive understanding of Python programming concepts and practical applications.

Uploaded by

otj7w
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 views

Python_Practice_Questions_Updated

The document contains a collection of Python practice questions categorized into various topics such as basic problems, operators, loops, data structures, file handling, exception handling, sorting algorithms, vectors and matrices, and case studies. Each category includes specific tasks to enhance programming skills, such as checking numbers, sorting lists, handling files, and implementing algorithms. The questions aim to provide a comprehensive understanding of Python programming concepts and practical applications.

Uploaded by

otj7w
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
You are on page 1/ 2

Python Practice Questions

Basic Python-Based Problems and Data Types


- Write a Python program to check if a number is positive, negative, or zero.
- Create a function that takes a string and checks if it's a palindrome.
- Write a program that converts a given temperature from Celsius to Fahrenheit.
- Define a function that calculates the factorial of a number using recursion.

Python Operators, Loops, and Control Flow


- Write a program that prints numbers from 1 to 50, but for multiples of 3, print 'Fizz' instead.
- Write a function that calculates the sum of all odd numbers up to a specified number.
- Create a Python function to check if a number is prime.
- Write a Python program to print the reverse of a given integer.

Tuples, Dictionaries, and Lists


- Write a function that merges two dictionaries by adding values of common keys.
- Given a list of tuples with student names and scores, sort the list by scores.
- Create a function that removes duplicates from a list and returns the unique values.
- Write a Python program to count the occurrences of each character in a given string.

File Handling
- Write a Python program that appends data to an existing file.
- Create a function to count the number of words in a text file.
- Write a Python program to copy content from one file to another.
- Develop a function that reads a CSV file and prints each row as a dictionary.

Exception Handling
- Write a program that takes a list of numbers and calculates their average. Handle cases where the
list is empty.
- Write a Python program to safely perform division and handle any exceptions.
- Define a function that opens a file and prints its contents, with exception handling for file not found.
- Create a function that safely converts a list of strings to integers and handles conversion errors.
Basics of Sorting Algorithms
- Implement the Insertion Sort algorithm to sort a list of numbers.
- Write a function that performs Merge Sort on a given list.
- Develop a Python program to sort a list of dictionaries by a specific key.
- Create a function to perform Quick Sort on a list of integers.

Vectors and Matrices


- Write a Python function that adds two vectors of the same length.
- Create a function to calculate the transpose of a 3x3 matrix.
- Write a program that multiplies a vector by a scalar value.
- Develop a Python program to find the determinant of a 2x2 matrix.

Case Studies
- Baker's Problem: Write a function to calculate ingredient quantities based on batch size.
- Caesar Cipher: Create a decryption function for Caesar cipher.
- Substitution Cipher: Implement a simple substitution cipher with a given key.
- Baker's Problem: Develop a function to estimate baking time based on available ovens.

You might also like