0% found this document useful (0 votes)
6 views4 pages

01 Python Programming Fundamentals

intruction to python programming
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

01 Python Programming Fundamentals

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

Python Programming

Fundamentals
A clear introduction to syntax, variables, decisions, loops, and
functions

Document type: Original educational notes


Language: English
Purpose: Personal study and academic reference

This document contains newly written material and may be shared only where the uploader has the right to
upload it.

Original educational notes | Page 1


1. Introduction to Python
Python is a high-level, general-purpose programming language designed to make
programs easy to read and write. It is widely used in education, web development,
automation, data analysis, artificial intelligence, and scientific computing. A Python
program is normally written as a sequence of statements. The interpreter reads those
statements and executes them.

Main Features
 Simple syntax: Python uses clear words and fewer symbols than many languages.
 Interpreted execution: programs can be run without a separate compilation step.
 Portable: the same program can often run on Windows, Linux, and macOS.
 Large standard library: built-in modules support files, mathematics, dates, text
processing, and more.
 Multiple programming styles: Python supports procedural, object-oriented, and
functional programming.

2. Variables and Data Types


A variable is a name used to store a value. Python creates the variable when a value is
assigned. The data type tells us what kind of value is stored and what operations can be
performed on it.
Type Example Purpose
int 25 Whole numbers
float 12.5 Decimal numbers
str "Hello" Text
bool True Logical values
list [10, 20, 30] Ordered, changeable
collection
tuple (10, 20, 30) Ordered, unchangeable
collection
set {10, 20, 30} Unordered collection of
unique values
dict {"name": "Ravi"} Key-value pairs

name = "Anita"
age = 18
height = 1.62
is_student = True

print(name, age, height, is_student)

Original educational notes | Page 2


3. Operators and Expressions
Operators are symbols or keywords used to perform calculations and comparisons. An
expression combines values, variables, and operators to produce a result.
Category Operators Example
Arithmetic +, -, *, /, //, %, ** a+b
Comparison ==, !=, >, <, >=, <= age >= 18
Logical and, or, not x > 0 and x < 10
Assignment =, +=, -=, *= score += 1
Membership in, not in "a" in word
Identity is, is not x is None

4. Decision Making
Decision statements allow a program to choose which block of code should run. Python
uses indentation to show which statements belong to a block.
marks = 72

if marks >= 75:


print("Distinction")
elif marks >= 50:
print("Pass")
else:
print("Needs improvement")

The conditions are checked from top to bottom. As soon as one condition is true, its block
executes and the remaining alternatives are skipped.

5. Loops
A loop repeats a group of statements. A for loop is suitable when iterating through a
sequence or a known range. A while loop is useful when repetition should continue as
long as a condition remains true.
for number in range(1, 6):
print(number)

count = 3
while count > 0:
print(count)
count -= 1

 break immediately stops the nearest loop.


 continue skips the remaining statements in the current iteration.
 pass performs no action and can be used as a placeholder.

Original educational notes | Page 3


6. Functions
A function is a reusable block of code that performs a specific task. Parameters receive
input values, and the return statement sends a result back to the caller.
def calculate_area(length, width):
area = length * width
return area

result = calculate_area(5, 3)
print("Area:", result)

Functions improve readability, reduce repeated code, and make testing easier. A lambda
function is a small anonymous function, usually used for a short single expression.
square = lambda x: x * x
print(square(6))

7. Practice Questions
1. Write a program to check whether a number is positive, negative, or zero.
2. Use a for loop to print the multiplication table of a given number.
3. Create a list of five marks and calculate the total and average.
4. Write a function that returns the largest of three numbers.
5. Explain the difference between a list, tuple, set, and dictionary.

Conclusion
Python fundamentals include variables, data types, operators, decisions, loops, and
functions. A strong understanding of these topics provides the foundation for file
handling, object-oriented programming, data analysis, and larger software projects.

Original educational notes | Page 4

You might also like