Class 2 - Updated
Class 2 - Updated
WEEK 2
Agenda
Python Variables
Python Datatypes
Imperative Statements
2
A value is one of the basic things a program
works with, like a letter or a number.
Print Simple
For previous class we used the value “Hello
String World” and passed it through the print function
# initializing string
print (string)
3
By default, python's print() function ends with a newline.
This function comes with a parameter called 'end.' The
default value of this parameter is '\n,' i.e., the new line
Print end character. You can end a print statement with any
character or string using this parameter.
command
Try this
print("Welcome to")
print("Georgian College",end='!')
print("Python",end='@')
4
Python Variables
In Python, variables are used to store data that can be referenced and manipulated during
program execution. A variable is essentially a name that is assigned to a value. Unlike many
other programming languages, Python variables do not require explicit declaration of type.
The type of the variable is inferred based on the value assigned.
Variables act as placeholders for data. They allow us to store and reuse values in our
program.
5
Rules for Naming Variables
6
Python
Data Types
7
Python Data Types
In computer programming, data types specify the type of data that can be stored inside a variable.
For example,
8
9
Python Numeric Data type
10
Python Numeric Data type
11
12
13
Python String Data type
14
15
Creating Strings
Strings can be created by enclosing
characters inside single quotes or double-
quotes.
16
Strings are indexed with each character
assigned a position (starting from 0).
17
18
19
20
21
22
23
Python List
24
25
26
27
28
29
30
Python Tuple
31
32
33
34
35
Python Dictionary
36
37
38
39
40
41
42
43
44
45
46
Class and Object
47
48
49
Type Conversion
50
Implicit Type Conversion:
Implicit type conversion (also known as type coercion) is automatically done by Python when
converting one data type to another, typically from a smaller type to a larger type.
51
Explicit Type Conversion:
Explicit type conversion (also known as type casting) is done manually by the user using functions like
int(), float(), str(), etc.
52
Imperative
Programming
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Thank You
68