Module 4
Module 4
I. INTRODUCTION:
Understanding Python's syntax and data types is fundamental to harnessing the power of
this versatile programming language. Python's syntax emphasizes readability and
simplicity, enabling developers to write clean, concise code with ease. Its dynamic typing
system supports a variety of data types, including integers, strings, and complex
structures, allowing seamless handling of diverse data. These features are complemented
by Python’s indentation rules, which structure code blocks for better readability and
functionality. Together, these elements form the foundation of Python programming,
empowering developers to create efficient, scalable, and innovative solutions across a
wide range of applications.
III.DISCUSSION:
CHAPTER 4.1 Introduction to Python
What is Python?
programming journey. The major focus behind creating it is making it easier for
History of Python
Python was created in 1980s by Guido van Rossum. During his research at the
of reading and usage. The first ever version was released in the year 1991 which
and data analysis, in 1994, Python 1.0 was released with extra features like
Engineering-Computing Academy of
Science and Technology
BSIT
map, lambda, and filter functions. After that adding new functionalities and
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
development.
Why Python?
etc).
Python has syntax that allows developers to write programs with fewer
functional way.
Python syntax is like grammar for this programming language. Syntax refers to
the set of rules that defines how to write and organize code so that the Python
interpreter can understand and run it correctly. These rules ensure that your
Indentation in Python
beginning of code line. It is used to define the code blocks. Indentation is crucial
in Python because, unlike many other programming languages that use braces
hand it became difficult to rectify indentation errors. Even one extra or less space
Python Variables
memory. Unlike some other languages, you don't need to declare a variable's
type explicitly in Python. Based on the value assigned, Python will dynamically
In the below example, variable 'a' is initialize with integer value and variable 'b'
during runtime.
Python Identifiers
functions, classes, and other entities. They are used to uniquely identify the
Engineering-Computing Academy of
Science and Technology
BSIT
entity within the program. They should start with a letter (a-z, A-Z) or an
Output Variables
variables.
separated by a comma:
Global Variables
Python
the user provides input and presses "Enter". The entered data is then returned
different types, and different types can do different things. Python has the
Python Numbers
Python:
int
float
complex
Variables of numeric types are created when you assign a value to them:
Python Casting
There may be times when you want to specify a type on to a variable. This can
int() - constructs an integer number from an integer literal, a float literal (by
whole number)
Strings
quotation marks.
String slicing in Python is a way to get specific parts of a string by using start,
end, and step values. It’s especially useful for text manipulation and data
parsing.
Upper Case
a = "Hello, World!"
print(a.upper())
Engineering-Computing Academy of
Science and Technology
BSIT
Lower Case
a = "Hello, World!"
print(a.lower())
Replace String
a = "Hello, World!"
print(a.replace("H", "J"))
String Concatenation
F-Strings
F-String was introduced in Python 3.6, and is now the preferred way of
formatting strings.
Engineering-Computing Academy of
Science and Technology
BSIT
To specify a string as an f-string, simply put an f in front of the string literal, and
III. ASSESSMENT:
Reference List:
C - Basic Syntax. (n.d.). https://www.tutorialspoint.com/cprogramming/c_basic_syntax.htm
basic-syntax/
S, H. S. (2024, July 23). The One-Stop Solution To Learn Everything You Need To Know About
variables-in-c#:~:text=In%20C%20programming%20language%2C%20a,times%20during
%20the%20program%20execution.
Engineering-Computing Academy of
Science and Technology
BSIT
What is an IDE? - Integrated Development Environment Explained - AWS. (n.d.). Amazon Web