CST445 Module 1 Part 2 Basics
CST445 Module 1 Part 2 Basics
Python Basics
2
First Program
3
Python Comments
► String Literals
► In Python, a string literal is a sequence of
characters enclosed in single or double
quotation marks
6
Python Variables
Output
Sally
<class 'str'>
<class 'float'>
8
Variable Names
If you try to
combine a string
and a number,
Python will give
you an error:
13
Excercises
► Complex
► Complex numbers are written with a "j" as the imaginary part:
23
Type Conversion
► Type Casting:
In typing casting, a data type is converted into
another data type by the programmer using the
casting operator during the program design.
24
Type Conversion
► Type Coercion
► In type conversion, a data type is
automatically converted into another data type
by a compiler at the compiler time.
25
Type Conversion
► Operators are used to perform operations ► Python divides the operators in the following
on variables and values. groups:
► Arithmetic operators
► Assignment operators
► Comparison operators
► Logical operators
► Identity operators
► Membership operators
► Bitwise operators
37
Arithmetic operators