0% found this document useful (0 votes)
5 views2 pages

Day1 Python Notes

The document provides an overview of core Python concepts including syntax, indentation, comments, variables, constants, and data types. It explains the importance of correct indentation, the use of comments for code readability, and introduces common data types such as integers, floats, strings, and booleans. Additionally, it covers type checking and type casting methods in Python.

Uploaded by

Saniya
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)
5 views2 pages

Day1 Python Notes

The document provides an overview of core Python concepts including syntax, indentation, comments, variables, constants, and data types. It explains the importance of correct indentation, the use of comments for code readability, and introduces common data types such as integers, floats, strings, and booleans. Additionally, it covers type checking and type casting methods in Python.

Uploaded by

Saniya
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
You are on page 1/ 2

Day 1 - Core Python: Syntax, Variables, Data Types

1. Python Syntax and Indentation

Python uses indentation (whitespace) to define blocks of code. Correct indentation is important to avoid

errors. Real-life example: If you follow traffic rules properly (indentation), you avoid accidents (errors).

if 5 > 2:
print('Five is greater than two')

2. Comments

Comments are used to explain code and make it more readable. They are ignored by the Python interpreter.

# This is a single-line comment


'''This is a
multi-line comment'''

3. Variables and Constants

Variables store data values. Constants are variables whose values should not change (use uppercase by

convention).

name = 'Saniya'
age = 23
PI = 3.14 # Constant

4. Data Types

Common data types include:

- int: Integer numbers

- float: Decimal numbers

- str: Text data

- bool: True/False values

x = 10 # int
y = 3.14 # float
z = 'Hi' # str
b = True # bool
Day 1 - Core Python: Syntax, Variables, Data Types

5. Type Checking and Type Casting

Use type() to check data type. Use int(), float(), str() to convert between types.

x = '123'
print(int(x)) # 123
print(type(int(x))) # <class 'int'>

You might also like