Professional Documents
Culture Documents
Alpro Class 3
Alpro Class 3
Alpro Class 3
PROGRAMMING
Session 3
Variable
x=5+7:4 Expression
Operand
Anita Safitri, M.Kom
Variable
• Variables are containers for storing data values.
• Python has no command for declaring a variable. A variable is created the
moment you first assign a value to it.
• Variable names are case-sensitive.
• E.g.: name = ‘John’
age = 10
print (name)
print (age)
• Float
✓ This type only recognizes real numbers (a combination of fractions and integers)
✓ conversion of data into float form can be done by using the float() function.
• Conversion of data into string class can be done by using the str() function.
• To check if a certain phrase or character is present or not in a string, we can use the
keyword in and not in.
E.g.: txt = "The best things in life are free!”
print("free" in txt)
Ilustration of List
Elemen a b c 162 57 60112 x z
Index 0 1 2 3 4 5 6 7
• Dictionary
✓ an unordered collection of items. Like lists, dictionaries have indexes and the content of
elements is mutable.