Basics of Coding
Basics of Coding
Welcome to the basics of coding! In this document, we will cover fundamental programming
concepts with simple Python examples and explanations.
---
1. Printing Output
print("Hello, World!") # This prints "Hello, World!" to the screen
3. User Input
user_name = input("Enter your name: ") # Takes user input as a string
4. Conditional Statements
num = int(input("Enter a number: ")) # Converts input to an integer
if num > 0:
elif num == 0:
else:
5. Loops
# Using a for loop to print numbers from 1 to 5
count = 5
print(count)
6. Functions
def greet(name):
7. Lists
fruits = ["apple", "banana", "cherry"] # Creating a list
8. Dictionaries
person = {"name": "Alice", "age": 25, "city": "New York"} # Creating a dictionary
print(person)
9. Exception Handling
try:
except ZeroDivisionError:
🌟 Conclusion
These are the fundamental building blocks of coding. Keep practicing these concepts to
build a strong foundation. Happy coding! 🚀