Python
Python
●
Python is a text based programming language.
●
Python is case sensitive.
Python Code
Python Interpreter Machine Code
(Source Code)
Interpreter – Translates the source code into language that the computer can understand.
Machine Code – The language that a computer uses to carry out instructions.
●
Interactive mode – The Python shell allows commands to be entered and run
immediately.
●
Script mode – Python’s text editor, which allows programmers to enter a list
of commands and they are executed together.
Python shell – The Python interactive mode, where commands can be typed directly.
Variables
●
Variable : A named memory location used to store data of a given type
during program execution. A variable can change value as the program runs.
●
A variable is like a container that stores data in a program.
●
Programmers give variables specific names to easily refer them and
manipulate data.
user_name = "Joe"
user_age = 25
user_age = user_age + 1
Exercise : Re-write this program utilizing input() command prompting user to input name and age.
user_name = "Joe"
user_age = 25
Python code below shows a number of variables storing different pieces of data with different data
types.
name = “Joe”
age = 12
address = “10/H , New Road”
balance = 120.45
Casting
●
Casting : The process of ensuring data is set to the correct data type.
●
Python’s input function captures user input as a string data type.