0% found this document useful (0 votes)
1 views10 pages

Python Syntax and Basic Concepts

Uploaded by

qaanqaan873
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)
1 views10 pages

Python Syntax and Basic Concepts

Uploaded by

qaanqaan873
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

Python Syntax & Basic

Concepts
Your journey into writing clean, functional Python code starts here

Instructor: Captain Najib Hussein Mohamed

Python Programming @Copyright By Captain Najib Hussein 2026


What is Syntax?

Rules of the Road

Syntax = rules for writing code

Wrong syntax → Error ❌

Correct syntax → Success ✔️

Python Programming @Copyright By Captain Najib Hussein 2026


Comments: Your Code Notes
How to Comment

# This is a comment
print("Hello")

Why Comment?
Comments explain code without affecting execution

Practice

# My first program
print("I love Python")

Python Programming @Copyright By Captain Najib Hussein 2026


Variables: Store Your Data
What's a Variable? Example

Think of variables as labeled containers for your


name = "Najib"
data
print(name)

name = "Ali"
Output: Najib
age = 20

Python Programming @Copyright By Captain Najib Hussein 2026


Variable Naming Rules
❌ Don't Start With Number ✔️ Use Letters & Underscore ❌ No Spaces
user name = "Ali" → Wrong
1name = "Ali" → Wrong user_name = "Ali" → Good

Python Programming @Copyright By Captain Najib Hussein 2026


Data Types
Python recognizes different kinds of data

String Integer
"Hello" — Text enclosed in quotes 10 — Whole numbers without decimals

Float Boolean
3.5 — Numbers with decimals True/False — Logical values

Python Programming @Copyright By Captain Najib Hussein 2026


Data Type Examples

name = "Ali" # String


age = 20 # Integer
height = 1.75 # Float
is_student = True # Boolean

Python Programming @Copyright By Captain Najib Hussein 2026


Print with Variables
Store Data

name = "Ali"

Print It

print(name)

See Output
Output: Ali

Python Programming @Copyright By Captain Najib Hussein 2026


Combine Variables
Example Code Output

name = "Ali" My name is Ali


age = 20 I am 20 years old
print("My name is", name)
print("I am", age, "years old") Use commas to combine text and variables

Python Programming @Copyright By Captain Najib Hussein 2026


Simple Calculation
Define Variables

x = 5
y = 10

Calculate

print(x + y)

Result
Output: 15

Python Programming @Copyright By Captain Najib Hussein 2026

You might also like