Python code is a set of instructions written in the Python programming language that tells the computer what to do. It is known for its clean, readable, and beginner-friendly syntax.
Feature | Description |
---|---|
Simple Syntax | Easy to write and understand. Looks like plain English. |
Indentation-based | Uses indentation (spaces) to define blocks instead of curly braces {} . |
Dynamically Typed | No need to declare data types. Python detects it automatically. |
Interpreted Language | Code runs line by line, making it easy to debug and test. |
Extensive Libraries | Thousands of built-in and third-party modules for data, web, AI, and more. |
# This is a comment
print("Hello, World!") # Output: Hello, World!
Explanation:
#
is used for comments.print()
is a built-in function to show output on the screen.
name = input("Enter your name: ")
print("Welcome,", name)
Sample Output:
Enter your name: Sairam
Welcome, Sairam
Part | Example | Purpose |
---|---|---|
Variable | x = 10 |
Stores data |
Function | def greet(): |
Groups reusable code |
Conditionals | if x > 5: |
Makes decisions |
Loops | for i in range(5): |
Repeats code |
Comments | # This is a comment |
Describes the code (not executed) |