0% found this document useful (0 votes)
2 views2 pages

Python Basics Exercises

This document provides a set of beginner-level Python exercises covering fundamental concepts such as variables, data types, strings, numbers, lists, dictionaries, conditional statements, loops, functions, file handling, and error handling. Each exercise is designed to reinforce learning through practical application, including tasks like creating variables, manipulating strings, performing arithmetic operations, and handling user input. Additionally, it suggests simple project ideas for further practice.

Uploaded by

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

Python Basics Exercises

This document provides a set of beginner-level Python exercises covering fundamental concepts such as variables, data types, strings, numbers, lists, dictionaries, conditional statements, loops, functions, file handling, and error handling. Each exercise is designed to reinforce learning through practical application, including tasks like creating variables, manipulating strings, performing arithmetic operations, and handling user input. Additionally, it suggests simple project ideas for further practice.

Uploaded by

aishuammu3092
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Basics - Exercise Set for

Beginners
Exercise Set 1: Variables & Data Types
 Create variables for:
- Your name (string)
- Your age (int)
- Your height in meters (float)
- Whether you like Python (boolean)
 Print the types of each variable using type().

Exercise Set 2: Strings


 Ask the user for their first and last name and print the full name.
 Convert a string "python is FUN" to:
- All lowercase
- All uppercase
- Capitalized

Exercise Set 3: Numbers & Operators


 Take two numbers as input from the user and:
- Print their sum, difference, product, quotient
 Use //, %, and ** operators and explain their output.

Exercise Set 4: Lists & Tuples


 Create a list of 5 favorite movies.
 Add a movie to the list, remove one, and sort the list.
 Convert it into a tuple and print it.

Exercise Set 5: Dictionaries


 Create a dictionary of 3 friends and their ages.
 Add a new entry and delete one.
 Print all keys and values.
Exercise Set 6: Conditional Statements
 Ask the user for their age and:
- If age < 13: print “Child”
- If 13–17: print “Teenager”
- If 18+: print “Adult”

Exercise Set 7: Loops


 Print all numbers from 1 to 10 using a for loop.
 Print even numbers from 1 to 20 using a while loop.
 Loop through a list of fruits and print each one.

Exercise Set 8: Functions


 Create a function greet(name) that returns "Hello, <name>!"
 Create a function area_of_circle(radius) and return the area.

Exercise Set 9: File Handling


 Write a short story to a file called story.txt.
 Read it back and print the contents.

Exercise Set 10: Error Handling


 Write code that divides two numbers but catches divide-by-zero error.
 Use a try-except block when converting user input to integer.

Bonus: Simple Project Ideas


 Calculator: Take user input and perform +, -, *, / operations.
 To-Do List: Add tasks to a list and remove them.
 Guessing Game: Generate a random number and let user guess it.

You might also like