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

Python Basics: Syntax, Variables, Types

The document provides an overview of basic Python syntax, including case sensitivity, variable naming rules, and indentation. It covers common data types, type casting, and various operators such as arithmetic, relational, logical, and assignment operators. Additionally, it explains input and output methods, along with commenting styles in Python.

Uploaded by

Siddhesh Dhekane
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views10 pages

Python Basics: Syntax, Variables, Types

The document provides an overview of basic Python syntax, including case sensitivity, variable naming rules, and indentation. It covers common data types, type casting, and various operators such as arithmetic, relational, logical, and assignment operators. Additionally, it explains input and output methods, along with commenting styles in Python.

Uploaded by

Siddhesh Dhekane
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

1.

Basic Python Syntax

• Python is case-sensitive
• Uses indentation (spaces) instead of
braces {}
• Statements usually end at a new line
(no semicolon needed)
if x > 5:
print("Hello")
2. Variables
• A variable is a name that stores a value.
• Must start with a letter or underscore
• Cannot start with a number
• No special characters except
• Cannot use Python keywords

age = 20
name = "Alex"
_marks = 95
3. Data Types
Common Built-in Data Types
Type Example

int 10, -5

float 3.14, 2.0

str "hello", 'Python'

bool True, False

list [1, 2, 3]

tuple (1, 2, 3)

set {1, 2, 3}

dict {"a": 1, "b": 2}


4. Type Casting
Converting one data type to another.

int("5") # 5
float(3) # 3.0
str(10) # "10"
5. Operators
Arithmetic Operators
• + # Addition
• - # Subtraction
• * # Multiplication
• / # Division
• % # Modulus
• ** # Exponent
• // # Floor division
Relational (Comparison)
Operators
==
!=
>
<
>=
<=
Returns True or False
Logical Operators

• and
• or
• not
Assignment Operators
• =
• +=
• -=
• *=
• /=
• %=
Input and Output
Output (print)
print("Hello World")
print("Age:", 20)
Multiple values:
print("Sum =", a + b)
Input
input() always takes string input
name = input("Enter your name: ")
Comments
 Single-line comment
# This is a comment
 Multi-line comment
"""
This is a
multi-line comment
"""

You might also like