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

Program 3

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)
5 views2 pages

Program 3

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

**********************************************************************

11. Practice Problems


1. Write a Python program to calculate the area of a circle.
2. Create a program to print even numbers between 1 and 50.
3. Write a function to find the maximum of three numbers.
4. Develop a simple guessing game where the user guesses a number between 1 and 10.

Tips for Learning Python


 Practice daily by writing small programs.
 Explore Python documentation: docs.python.org.
 Use online platforms like HackerRank or LeetCode for challenges.

Here’s a simple list of essential Python commands and keywords for beginners:
Basic Commands
1. print() – Display output.
2. input() – Take user input.
3. len() – Find the length of an object.
4. type() – Check the type of a variable.
5. str(), int(), float() – Type conversion.
6. range() – Generate a sequence of numbers.
7. sorted() – Sort items in a list.
8. max() / min() – Find the maximum or minimum.
9. sum() – Calculate the sum of items in a list.

Math Commands
10. abs() – Absolute value.
11. round() – Round a number.
12. pow() – Raise to a power.

List Methods
13. .append() – Add an item to a list.
14. .remove() – Remove an item from a list.
15. .pop() – Remove and return the last item.
16. .sort() – Sort a list.
17. .reverse() – Reverse the list order.
String Commands
18. .lower() – Convert to lowercase. [ name=("SNEHASIS"), print(name.lower()) # output: Snehasis]
19. .upper() – Convert to uppercase.
20. .strip() – Remove whitespace.
21. .split() – Split a string. [text = "apple,banana" , print(text.split(",")) # Output: ['apple', 'banana']
22. .replace() – Replace parts of a string. [text = "I like cats" print(text.replace("cats", "dogs")) # Output: I like
dogs

Loops and Conditions


23. for – Loop through items.
24. while – Loop while a condition is true.
25. if, elif, else – Conditional statements.

File Handling Commands


26. open() – Open a file.
27. .read() – Read file contents.
28. .write() – Write to a file.
29. .close() – Close a file.

Error Handling
30. try / except – Handle errors.

Importing Modules
31. import – Import a module (e.g., math).
32. from – Import specific parts of a module.

Miscellaneous
33. def – Define a function.
34. return – Return a value from a function.
35. with – Context manager (e.g., for file handling).
36. break – Exit a loop early.
37. continue – Skip the current iteration.

You might also like