Python Basic 2: Review On Day 1
Python Basic 2: Review On Day 1
DAY 2
PYTHON BASIC 2
PYTHON PROGRAMMING ESSENTIALS
Review on Day 1
DAY 1 PYTHON PROGRAMMING ESSENTIALS 2
Introduction
Installation of Python Interpreter
Familiarization on Code Editor and IDE Creating
first Python program Identifiers
Basic Syntax
Taking input/output
Output Formatting
Variables
DAY 2 PYTHON PROGRAMMING ESSENTIALS 3
Datatype
DAY 2 PYTHON PROGRAMMING ESSENTIALS 4
Type Conversion
DAY 2 PYTHON PROGRAMMING ESSENTIALS 5
Converting one data type into another. Use to specify type of data on a variable
#converting numeric to text
area = 20
Arithmetic Operators
DAY 2 PYTHON PROGRAMMING ESSENTIALS 7
Equal ==
Not Equal !=
Greater than >
Less than <
Less than or equal <=
Relational Operators
DAY 2 PYTHON PROGRAMMING ESSENTIALS 8 Greater than or equal to >=
Equal sign = x = 2 Add AND += x += 3 equivalent x = x +
3Subtract AND -= x -= 2 equivalent x = x – 3Multiply AND
*= x *= 2 equivalent x = x * 3Divide AND /= x /= 2 equivalent
x = x / 2Modulus AND %= x %=2 equivalent x = x % 2
Assignment Operators
DAY 2 PYTHON PROGRAMMING ESSENTIALS 9
x = True y = False
AND and x and y = False OR or x or y = True NOT not
not x = False
Logical Operators
DAY 2 PYTHON PROGRAMMING ESSENTIALS 10
Parenthesis ( )
Exponent **
MDMod * / % AS + -
Precedence of Operators
DAY 2 PYTHON PROGRAMMING ESSENTIALS 11
1. Allow the user to enter the following
1. Name (Text) (Peter Smith) 2. Math Grade (float) (90.34) 3.
Science Grade (float) (85.32)
4. English Grade (integer) (80) DAY 2 PYTHON PROGRAMMING ESSENTIALS 12
Practice 1
"""Day 2 – Practice 1
By: Rogie Taborda
"""
DAY 2 PYTHON PROGRAMMING ESSENTIALS 13
Exercise 1
Filename: Day2_Exe1_Lastname_Firstname.py
String
DAY 2 PYTHON PROGRAMMING ESSENTIALS 15
A string is a sequence of characters.
Python does not have a character data type Square
brackets can be used to access elements of the string. string1 =
“The quick brown fox” string2 = ‘The fast green turtle’ string3 = ”””This milk
costs 30 pesos ”””
String Functions
DAY 2 PYTHON PROGRAMMING ESSENTIALS 19
Returns string as uppercase upper( )Returns string as
lowercase lower( )Converts first character to capital letter
capitalize( )Every first letter of each word capitalized title(
)Splits the string at the specified separator split( )Returns
a string where value is replaced replace( )Returns number of
characters on a string len( )
String Functions
DAY 2 PYTHON PROGRAMMING ESSENTIALS 20
Numbers
DAY 2 PYTHON PROGRAMMING ESSENTIALS 22
print(type(val1))
print(type(val2))
Mathematical Functions DAY 2 PYTHON PROGRAMMING ESSENTIALS 23
Random Number
DAY 2 PYTHON PROGRAMMING ESSENTIALS 25
* D R A W R E S U L T *9 5 37 17 26
Exercise 2
Filename: Day2_Exe2_Lastname_Firstname.py
Summary
DAY 2 PYTHON PROGRAMMING ESSENTIALS 27
Variables
Datatype
Type Conversion
Operators & Expressions
String
Numbers
Random