0% found this document useful (0 votes)
5 views14 pages

Python Programming Basics: Variables & Data Types

Uploaded by

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

Python Programming Basics: Variables & Data Types

Uploaded by

bpjoaq
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Introduction to

Python Programming

Prepared By: Rosemarie O. San Andres


Variables
- Containers to store data
- Created by assignment: variable_name = value
Example:
x = 5
y = “Joshua“
Note: Use lowercase and underscores for clarity
Example:
total_product
Rules in Naming Variable
 Must start with letter or underscore character
 Cannot start with number
 Can only contain alpha-numeric characters and underscore (A-z,0-9, _ )
 Case-sensitive (name, Name and NAME are different variables)
 The reserved words(Keywords) cannot be used in naming the variables.
Data Types
TYPE Example USE CASE
INT 16,19,24 Quantity, age,
stock count
FLOAT 5.6, 4.5, 3.34 Price, Ratings,
salary
STR “name,” “product” Names, codes,
descriptions
BOOL True or false Status, Availability
checks
Checking Data Types
x = "Hello World" str
x = 20 int
x = 20.5 float
x = 1jcomplex
x = ["apple", "banana", "cherry"] list
x = ("apple", "banana", "cherry") tuple
x = range(6) range
x = {"name" : "John", "age" : 36} dict
x = {"apple", "banana", "cherry"} set
Real life Business Examples
Your family run a store that sells T-shirts at ₱ 250. A customer buys 4
shirts.

Code:

Price = 250
Quantity = 4
Total = Price * Quantity
print(“Total:” , Total)
OUTPUT
Common Mistakes to Avoid
 Using input() without converting to int or float
 Using = instead of ==
 Forgetting quotation marks for strings
 Mixing data types in calculations
 Indentation
 Missing colons
 Incorrect operator
 Mismatched parentheses
Exercise
Ask for your item name, number of items and price for item
Calculates total cost
Compute VAT(20%) [to compute * total and 0.20]
Display subtotal , VAT and grand total
Thank you.
End of Discussion

You might also like