Docsity

“Python Programming Language Notes – Beginner to Advanced (With Examples)”, Lecture notes of Applications of Computer Sciences

Toggle sidebar
bg1
📘
PYTHON LANGUAGE NOTES
1. Introduction to Python
•High-level programming language (easy to understand).
•Interpreted (executed line by line).
•Dynamically typed (no need to declare variable types).
•Portable (runs on different platforms: Windows, Linux, macOS).
•Open-source and widely used in web development, data science, AI, automation, etc.
2. Basic Syntax
Comments:
Python
# Single-line comment
""" Multi-line
  comment """
• Print Statement:
Python
print("Hello, World!")
3. Variables and Data Types
No need to declare type explicitly:
Python
x = 10 # Integer
y = 3.14 # Float
name = "Adi" # String
flag = True # Boolean
Type checking:
--------------------
Python
type(x) # <class 'int'>
4. Data Structures
A) Strings
s = "Python"
print(s[0]) # P
print(s[-1]) # n
pf3
pf4

Partial preview of the text

Download “Python Programming Language Notes – Beginner to Advanced (With Examples)” and more Lecture notes Applications of Computer Sciences in PDF only on Docsity!

📘 PYTHON LANGUAGE NOTES

1. Introduction to Python

•High-level programming language (easy to understand). •Interpreted (executed line by line). •Dynamically typed (no need to declare variable types). •Portable (runs on different platforms: Windows, Linux, macOS). •Open-source and widely used in web development, data science, AI, automation, etc.

2. Basic Syntax

Comments:

Python

Single-line comment

""" Multi-line comment """

  • Print Statement:

Python

print("Hello, World!")

3. Variables and Data Types

No need to declare type explicitly:

Python

x = 10 # Integer y = 3.14 # Float name = "Adi" # String flag = True # Boolean

Type checking:

Python

type(x) #

4. Data Structures

A) Strings

s = "Python" print(s[0]) # P print(s[-1]) # n

print(s[0:4]) # Pyth

B) Lists (mutable, ordered)

nums = [1, 2, 3, 4] nums.append(5) nums[0] = 10

C) Tuples (immutable, ordered)

t = (1, 2, 3)

D) Sets (unordered, unique values)

s = {1, 2, 2, 3} print(s) # {1, 2, 3}

E) Dictionaries (key-value pairs)

d = {"name": "Adi", "age": 20} print(d["name"]) # Adi

Operators

Arithmetic: + - * / % // ** Comparison: == != > < >= <= Logical: and or not Membership: in, not in Identity: is, is not

  1. Conditional Statements

x = 10 if x > 0: print("Positive") elif x == 0: print("Zero") else: print("Negative")

  1. Loops

For Loop:

with open("data.txt", "w") as f: f.write("Hello Python")

with open("data.txt", "r") as f: print(f.read())

  1. Important Libraries

NumPy → Numerical computing

Pandas → Data analysis

Matplotlib → Data visualization

Scikit-learn → Machine Learning

TensorFlow / PyTorch → Deep Learning

Flask / Django → Web development