Skip to content

Latest commit

History

History
71 lines (60 loc) 路 2.6 KB

Days-1-3.md

File metadata and controls

71 lines (60 loc) 路 2.6 KB

Day 1: Introduction to Python

  • Python is a high-level, interpreted programming language known for its readability and simplicity.
  • It is versatile and widely used in various domains, including web development, data analysis, artificial intelligence, and more.
  • Python code is executed line by line, making it an excellent choice for beginners.
  • Example:
# This is a simple Python program that prints a message
print("Hello, World!")

Day 2: Variables and Data Types

  • Variables are used to store and manipulate data in Python.
  • Python supports various data types, including:
    • Strings (text): name = "John"
    • Integers (whole numbers): age = 30
    • Floats (decimal numbers): height = 6.1
    • Lists (ordered collections of items): fruits = ["apple", "banana", "cherry"]
    • Tuples (immutable, ordered collections): point = (3, 4)
    • Dictionaries (key-value pairs): person = {"name": "Alice", "age": 25}
  • Variables are dynamically typed, meaning their data type can change during runtime.
  • Example:
name = "John"
age = 30
height = 6.1
fruits = ["apple", "banana", "cherry"]
person = {"name": "Alice", "age": 25}

Day 3: Conditional Statements and Loops

  • Conditional statements allow your code to make decisions based on conditions.
  • Common conditional statements include if, elif (else if), and else.
  • Loops, such as for and while, are used for repetitive tasks.

Conditional Statements:

x = 10
if x > 5:
    print("x is greater than 5")
elif x == 5:
    print("x is equal to 5")
else:
    print("x is less than 5")

For Loop:

  • For loops are used to iterate over a sequence (e.g., a list or string).
  • Example:
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print("I love " + fruit)

While Loop:

  • While loops continue executing as long as a specified condition is True.
  • Example:
count = 0
while count < 5:
    print("Count: " + str(count))
    count += 1

These examples provide a deeper understanding of Python's core concepts. Make sure to run them in a Python environment to see the results. You can install Python by downloading it from the official Python website python.org. After installation, you can use a code editor or Python's built-in IDLE to write and run Python code.

These foundational concepts will serve as the building blocks for your Python journey. Continue to explore and experiment with Python to solidify your understanding and become a proficient Python programmer.