Programming Python Variables and Data Types Questions
1. **Variables and Data Types:**
a. Declare a variable `name` and assign your name to it.
b. Create variables for storing an integer, a float, and a string.
2. **Conditional Statements:**
a. Write a program that checks if a given number is even or odd.
b. Create a program that determines whether a student’s grade is ‘A’, ‘B’, ‘C’, ‘D’, or ‘F’ based on their score.
3. **Loops:**
a. Write a loop that prints the numbers from 1 to 10.
b. Using a loop, calculate the sum of all numbers from 1 to 100.
4. **Lists:**
a. Create a list of your favorite colors and print the third color in the list.
b. Write a program to find the largest element in a given list of numbers.
5. **Functions:**
a. Define a function that takes two parameters and returns their sum.
b. Create a function that checks if a given number is prime.
6. **Dictionaries:**
a. Define a dictionary representing a person’s information with keys like “name,” “age,” and “city.”
b. Write a program that counts the frequency of each character in a given string using a dictionary.
7. **File Handling:**
a. Create a text file with a few lines of text. Write a program to read and print the contents of the file.
8. **Exception Handling:**
a. Write a program that asks the user for input and handles a ValueError if the input is not a number.
b. Create a program that opens a file and handles a FileNotFoundError if the file doesn’t exist.
9. **Classes and Objects:**
a. Define a class `Book` with attributes like title, author, and year. Create an object of the class.
b. Extend the `Car` class from the previous example with a method that calculates the mileage.
10. **Modules and Libraries:**
a. Import the `random` module and generate a random number between 1 and 100.
b. Use the `math` module to calculate the square root of a given number.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
