Docsity

Python programming unit 1 complete notes for beginners, Study notes of Programming Languages

Toggle sidebar
bg1
BCA IInd Year
Subject: Python Programming
UNIT-1 NOTES
Unit 1: Basics of Python
Python
Definition:
Python is a high-level, interpreted, general-purpose programming language. It is designed to be easy to read, easy to
write, and suitable for many kinds of programming such as web development, automation, data science, and AI.
Important Points:
Python uses simple English-like syntax.
It is case-sensitive.
Python supports procedural, object-oriented, and functional programming styles.
It is widely used in real-world software and research.
Features of Python:
Easy to learn for beginners.
Works on Windows, Linux, and macOS.
Has ready-made modules for many tasks.
Free and open source
Interpreted Language
Object Oriented Language.
Python Installation and Running Programs
Definition:
Python programs can be written and executed in interactive mode, script mode, or through an IDE. Interactive mode
runs commands one by one, while script mode runs a full file.
Examples:
Using IDLE.
Using VS Code.
Running a .py file from the terminal.
Variables, Identifiers, and Keywords
Definition:
Variable is the name of memory location that is used to store data. Identifiers are the names given to
variables, functions, classes, and other elements. Keywords are reserved words with special meaning in
Python.
Example: int age = 20
name = "Alexa"
print(age , name) #Here age and name are variables and int is keyword
pf3
pf4
pf5

Partial preview of the text

Download Python programming unit 1 complete notes for beginners and more Study notes Programming Languages in PDF only on Docsity!

BCA IInd Year

Subject: Python Programming

UNIT-1 NOTES

Unit 1: Basics of Python

Python Definition: Python is a high-level, interpreted, general-purpose programming language. It is designed to be easy to read, easy to write, and suitable for many kinds of programming such as web development, automation, data science, and AI. Important Points:  Python uses simple English-like syntax.  It is case-sensitive.  Python supports procedural, object-oriented, and functional programming styles.  It is widely used in real-world software and research. Features of Python:  Easy to learn for beginners.  Works on Windows, Linux, and macOS.  Has ready-made modules for many tasks.  Free and open source  Interpreted Language  Object Oriented Language. Python Installation and Running Programs Definition: Python programs can be written and executed in interactive mode, script mode, or through an IDE. Interactive mode runs commands one by one, while script mode runs a full file. Examples:  Using IDLE.  Using VS Code.  Running a .py file from the terminal.

Variables, Identifiers, and Keywords

Definition:

Variable is the name of memory location that is used to store data. Identifiers are the names given to

variables, functions, classes, and other elements. Keywords are reserved words with special meaning in

Python.

Example: int age = 20

name = "Alexa" print(age , name) #Here age and name are variables and int is keyword

Data Types Definition: Data types define the type and size of value a variable can hold. Python has several built-in data types such as integer, float, string, boolean, list, tuple, set, and dictionary. int a = 10 float b = 3. c = "Python" print(type(a), type(b), type(c)) #Output Comments, Indentation, and Docstrings Definition: Comments are lines written to explain code for humans. Indentation means spacing at the beginning of a line to define blocks of code. Docstrings are string literals used to document functions, classes, or modules. Single-line comment: # Multiple- line comment: “”” “”” Operators Definition: Operators are symbols that perform operations on values or variables. Python supports arithmetic, relational, logical, assignment, membership, and bitwise operators. 1) Arithmetic operators These are used for mathematical calculations. Operator Name Example Result

  • Addition 10 + 3 13
  • Subtraction 10 - 3 7
  • Multiplication 10 * 3 30 / Division 10 / 3 3.333... // Floor division 10 // 3 3 % Modulus 10 % 3 1 ** Exponentiation 10 ** 3 1000 3) Assignment operators

Priority Operators Description Associativity 1 () Parentheses Highest / overrides order 2 ** Exponentiation Right to left 3 ++x, - -x Unary plus, unary minus Right to left 4 *, /, //, % Multiplication, division, floor division, modulus Left to right 5 +, - Addition, subtraction Left to right 6 <<, >> Bitwise shift operators Left to right 7 & Bitwise AND Left to right 8 ^ Bitwise XOR Left to right 9 | Bitwise OR Left to right 10 ==, !=, >, >=, <, <=, in, not in Comparison, membership Left to right 11 not Logical NOT Right to left 12 and Logical AND Left to right 13 or Logical OR Left to right Expressions Definition: An expression is a combination of values, variables, and operators that produces a result result = 5 + 2 * 3 print(result) Boolean expression: A Boolean expression in Python is any expression that evaluates to either True or False. It is commonly used in if statements, loops, and logical decisions. 5 > 3 # True 10 == 20 # False

age >= 18 # True or False depending on age Expression Meaning a == b True if a equals b a != b True if a is not equal to b a > b True if a is greater than b a < b True if a is smaller than b a >= b True if a is greater than or equal to b a <= b True if a is less than or equal to b x in y True if x is present in y x is y True if both refer to the same object