0% found this document useful (0 votes)
24 views68 pages

Class 2 - Updated

The document outlines the agenda for a Python programming course, covering topics such as variables, data types, strings, lists, tuples, and classes. It explains the use of the print function, variable naming rules, and type conversion methods in Python. Additionally, it introduces imperative programming and the basics of handling text data and exceptions.

Uploaded by

mani.hen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views68 pages

Class 2 - Updated

The document outlines the agenda for a Python programming course, covering topics such as variables, data types, strings, lists, tuples, and classes. It explains the use of the print function, variable naming rules, and type conversion methods in Python. Additionally, it introduces imperative programming and the basics of handling text data and exceptions.

Uploaded by

mani.hen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

BDAT1004

WEEK 2
Agenda
Python Variables

Python Datatypes

String, List, Tuple, Index, Range

Introduction to Class and Object

Imperative Statements

Introduction to Text Data, Files, and Exceptions

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

string = "Hello World"

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("Welcome to",end=' ')

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.

Triple quotes can also be used in Python, but


are generally used to represent multi-line
strings.

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

You might also like