<aside> 💡 Exercise: Write a Python program that takes a list of words and counts how many times each word appears in the list.

</aside>

Part 1: Python Syntax

Python is a high-level, interpreted programming language. It is known for its clear syntax and readability. Python uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages, making it quite easy to read.

Python is also a very versatile language, making it a good choice for beginners and experts alike. Now, let's dive into the basic syntax of Python.

Comments the best place to start: comments. In Python, comments are marked by the # symbol. Anything after # on a line is not executed by the Python interpreter. Comments are important for leaving notes and reminders within the code.

Example:


# This is a comment
print("Hello, World!")  # This will print "Hello, World!" to the console

Variables and Data Types

Python is dynamically typed, which means you don't have to declare the data type of a variable when you create one. You use the assignment operator = to assign values to a variable.

Example:


# variables in python
x = 5           # x is of type int
y = "John"      # y is of type str
print(x)
print(y)

There are several data types built into Python. Here are the most common ones:

It's important to note that Python is case-sensitive, which means Variable and variable are different variables.

Here's how you can check the type of a variable: