python
python
PYTHON
Python is a high-level, interpreted
programming language known for its
simplicity and readability.
PYTHON
•A versatile and powerful programming
language that has become a staple in various
fields such as web development, data science,
artificial intelligence, and automation.
PYTHON
•Python was created by Guido van Rossum and
first released in 1991.
•Its design philosophy emphasizes code
readability and simplicity, making it an
excellent choice for both beginners and
seasoned programmers.
PYTHON
•Python allows developers to express concepts
in fewer lines of code compared to many
other languages.
FEATURES AND CHARACTERISTICS
1. Ease of Learning and Use
2. Interpreted Language
3. Dynamic Typing
4. Versatile and Multipurpose
• Web Development
• Data Science and Machine Learning
• Automation and Scripting
• Game Development
FEATURES AND CHARACTERISTICS
4. Extensive Libraries and Frameworks
5. Community and Support
6. Cross-Platform Compatibility
7. Cross-Platform Compatibility
8. Object-Oriented and Functional Programming
9. Indentation
10. Growing Popularity
BASIC SYNTAX AND DATA
TYPES IN PYTHON
A. Basic Syntax
•Python's syntax is designed to be
intuitive and readable, which makes
it accessible for beginners.
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
1. Indentation: Python uses indentation to define
blocks of code (e.g., in functions, loops, and
conditionals). Unlike many other languages
that use braces or keywords, proper
indentation is important for the code to run
correctly.
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
1. Indentation
Example:
if True:
print("Hello, World!")
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
2. Comments: You can add comments to your
code using the # symbol. Comments are
ignored by the interpreter and are useful for
explaining code.
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
2. Comments
Example:
# This is a comment
print("This will run") # This is an
inline comment
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
3. Variables: Python allows you to create
variables without declaring their type. The
type is inferred from the value assigned.
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
3. Variables
Example:
x = 10 # Integer
name = "Alice" # String
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
print() function: The print() function prints the
specified message to the screen, or other standard
output device.
Example:
x = 10 # Integer
print(x)
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
input() function: The input() function in Python is
used to take input from the user. It allows you to
prompt the user for information, which can then be
used in your program..
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
input() function:
Example:
name = input()
print(name)
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
Casting Variables: A technique used to convert a
datatype to another datatype.
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Casting Variables: A technique used to convert a
datatype to another datatype.
Syntax:
• Convert Number to String
• Str(number)
• Convert String to Numbers
• int(string)
• float(string)
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Casting Variables:
example:
firstname = “Maria”
number = 5
print(firstname + str(number))
BASIC SYNTAX AND DATA
TYPES IN PYTHON
B. Data Types
•Python supports various built-in data
types that enable you to work with
different kinds of data.
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some of the most commonly used:
1. Numeric Types:
Integers (int): Whole numbers, (e.g., 5)
Floats (float): Decimal numbers, (e.g.,
3.14, -0.001).
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
1. Numeric Types:
Example:
age = 25 # Integer
pi = 3.14 # Float
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
2. Strings (str): A sequence of characters
enclosed in single or double quotes. Strings
are immutable.
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
2. Strings (str):
Example:
greeting = "Hello, World!"
BASIC SYNTAX AND DATA
TYPES IN PYTHON
Here are some fundamental aspects:
2. Booleans: represent one of two values: True
or False.
Example:
print(10 > 9)
print(9==9)
print(10<9)
ACTIVITY
Create a simple calculator
Create a program that will perform one of the
arithmetic operators when the user inputs 2 numbers.
Sample Output:
First Number: 50
Second Number: 30
50 x 30 = 1500