Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Introduction to Programming

For Beginners
Allan Martell
RECAP
RECAP

1) What's a value?
RECAP

1) What's a value?
2) What's a data type?
RECAP

1) What's a value?
2) What's a data type?
3) Which are the four data types?
RECAP

1) What's a value?
2) What's a data type?
3) Which are the four data types?

Exercise:
1) Create a folder on the desktop called 'programming'
2) Open IDLE and create a script. Name it variables.py
and save it within the 'programming' folder
VARIABLES
VARIABLES


'Boxes' to store values of a particular data type
VARIABLES


'Boxes' to store values of a particular data type

In order to create a variable we follow two steps:
VARIABLES


'Boxes' to store values of a particular data type

In order to create a variable we follow two steps:

Declaration. Assigning a
name to the variable.
VARIABLES


'Boxes' to store values of a particular data type

In order to create a variable we follow two steps:

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name
STRINGS
STRINGS


Strings are sequences of characters wrapped in double quotation
marks (“”)
STRINGS


Strings are sequences of characters wrapped in double quotation
marks (“”)

Declaration. Assigning a
name to the variable.

first_name =
last_name =
STRINGS


Strings are sequences of characters wrapped in double quotation
marks (“”)

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

first_name = “Allan”
last_name = “Martell”
STRINGS


Strings are sequences of characters wrapped in double quotation
marks (“”)

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

first_name = “Allan”
last_name = “Martell”

NOTE: Strings are wrapped in double quotation marks


(“”)
STRINGS


Strings are sequences of characters wrapped in double quotation
marks (“”)

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

first_name = “Allan”
last_name = “Martell”

NOTE: Strings are wrapped in double quotation marks


(“”)

Exercise: declare an initialize a string variable


BOOLEANS
BOOLEANS


A value that can be either True or False
BOOLEANS


A value that can be either True or False

Declaration. Assigning a
name to the variable.

tuesday =
attentive =
BOOLEANS


A value that can be either True or False

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

tuesday = False
attentive = True
BOOLEANS


A value that can be either True or False

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

tuesday = False
attentive = True

NOTE: The first word of a boolean value is a capital


letter, but all the rest are lowercase.
BOOLEANS


A value that can be either True or False

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

tuesday = False
attentive = True

NOTE: The first letter of a boolean value is a capital


letter, but all the rest are lowercase.

Exercise: declare an initialize a boolean variable


INTEGER
INTEGER

Whole numbers, such as 7 or 14.


INTEGER

Whole numbers, such as 7 or 14.

Declaration. Assigning a
name to the variable.

x=
y=
INTEGER

Whole numbers, such as 7 or 14.

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

x= 8
y = 11
INTEGER

Whole numbers, such as 7 or 14.

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

x= 8
y = 11

Exercise: declare an initialize an integer variable


FLOATS
FLOATS


Floating point numbers, or non-integer numbers, such as 5.0, or 4.5
FLOATS


Floating point numbers, or non-integer numbers, such as 5.0, or 4.5

Declaration. Assigning a
name to the variable.

a=
b=
FLOATS


Floating point numbers, or non-integer numbers, such as 5.0, or 4.5

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

a= 4.67
b= 1.0
FLOATS


Floating point numbers, or non-integer numbers, such as 5.0, or 4.5

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

a= 4.67
b= 1.0

NOTE: 1 is an integer, but 1.0 is a float.


FLOATS


Floating point numbers, or non-integer numbers, such as 5.0, or 4.5

Declaration. Assigning a Initialization. Assigning a


name to the variable. value to the variable name

a= 4.67
b= 1.0

NOTE: 1 is an integer, but 1.0 is a float.

Exercise: declare an initialize a float variable.


CONCLUSION
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type


CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name =
last_name =
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan”
last_name = “Martell”
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day =
at_ilab =
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False
at_ilab = True
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean

x =
y =
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean

x = 7
y = 22
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean

x = 7 Integer
y = 22 Integer
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean

x = 7 Integer
y = 22 Integer

a =
b =
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean

x = 7 Integer
y = 22 Integer

a = 6.78
b = 0.5
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean

x = 7 Integer
y = 22 Integer

a = 6.78 Float
b = 0.5 Float
CONCLUSION
When initializing a variable, you can assign it one of the different data
types:

Declaration Initialization Data Type

name = “Allan” String


last_name = “Martell” String

is_day = False Boolean


at_ilab = True Boolean

x = 7 Integer
y = 22 Integer

a = 6.78 Float
b = 0.5 Float

Exercise: continue with the exercise from last session.


EXERCISE

Within the script variables2.py, declare and Initialize:

– Five Integers
– Five Floating-Points
– Five Strings
– Five Booleans

Print them one by one

You might also like