Python Variable, Data Types and Operators
Python Variable, Data Types and Operators
PROGRAMMING
Print Formatting
Functions in Python
Python Pros
We can use python for developing desktop GUI applications and
Web Applications
is extensible
is dynamically typed.
History of Python
In the early 1980s, Van Rossum used to work at CWI (Centrum voor
Wiskunde en Informatica) as an implementer of the programming language
called ABC.
In the late 1980s, while working on a new distributed operating system
called AMOEBA there are things that ABC could not make
So Van Rossum himself started designing a new simple scripting language
that could overcome the flaws of ABC which he called PYTHON
Back in the 1970s, there was a popular BBC comedy tv show called Monty
Python’s Fly Circus and Van Rossum happened to be the big fan of that
show.
Python Programming Timeline
Debugging
• is trying to find why your code doesn’t behave what you want it to.
Basic Debugging
4. Syntax Error – the last common type of error well cover for
now. Syntax error is kind of catch all error. It refers to lots of
different things that can be done wrong, all based on violating
Python’s internal grammar.
Variables in Python
you can assign value to the variables using assignment operator ‘=’ .
Simple Type
x=1
Operator Function
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Logical Operators (not,or,and)
It also reverse the output of Boolean Expressions into its opposite value
Logical not (not)
a b a or b
a b a and b
str.lower() – use to convert all the string character into lower case
mystr = “Hello”
mystr.lower()
+ concatenates String
Ex.
lastName = ‘Salavacion’
firstName = ‘Kaye Harris’
fullName = firstName + “ ” + lastName
print(fullName)
+= appends Strings
Ex.
name= ‘Kaye Harris’
name += “ Salavacion”
print(name)
* duplicate number of character
Ex.
message= “Ha”
print(message * 8)
String Indexing
mystr = “Hello”
s[0]
#output H
s[1]
#output e
s[2]
#output l
String Slicing
String Slicing
String Slicing