Lecture - 5
COMPUTER SYSTEMS AND
PROGRAMMING
(ME-2609)
Basic Definitions
• What is a Program?
• Set of instructions
• Programmer
• Person who writes a program
• Do the programming
• User vs Programmer.
• User see the computer as a set of tools e.g using application software's
• Programmer learns the computer ways and language
Programming Languages
• A programming language is a vocabulary and set of grammatical
rules for instructing a computer or computing device to perform
specific tasks .
• Different programming languages exists including
• C, C++, Python, Java, Assembly etc.
• High and low level programming languages
Compiling the Program
• Compiler
• Interpreter
• Assembler
Translation Hierarchy
Flowcharts in programming
•Aflowchart is a type of diagram that represents a
workflow or process
• A flowchart can also be defined as a diagrammatic representation of an algorithm
• A step-by-step approach to solving a task.
• The flowchart shows the steps as boxes, and their order by connecting the boxes with arrows.
Pseudo Code
• A pseudocode is a plain language description of the steps in an algorithm.
• It is intended for human reading rather than machine reading.
• In other words, it is a plain English version of the detailed steps of a computer program that can
be read by non-programmers and used to map code.
A Simple Example
Let's say a bank customer wants to use an ATM to withdraw $100 cash from her account. You need to program for the
ATM to check the customer's balance and determine if there is enough money in the account. The pseudocode would
look something like this:
What is Python?
• Python is a general purpose interpreted, interactive, object-
oriented high-level programming language.
• Python is open source.
• Python is also a scripting language.
• Python is a cross platform language
History of Python Language
• First introduced in 1991 by Guido van Rossum.
• It was initially conceived in later 1980s and its
implementation was started in December 1989.
• Guido van Rossum was a fan of “Monty Python’s Flying
Circus” a famous TV show.
Scope of Python
• Very popular language now a days and is being used different
areas:
• Data Science
• Machine Learning
• Artificial Intelligence
• Signal and Image Processing
• Bio informatics
• Web Development
• Network Programming
• Game Development
• Databases
Python Versions
• Today, two versions of python are available
• Python 2.x
• Python 3.x
• Most the changes are incremental and hardly noticeable
• In some cases, program written for Python 2 may not work on the
systems having Python 3
IDEs for Python
• IDLE
• PyCharm
• Spyder
• Thony
• Jupyter Notebook
• Visual Studio
Talking to Python
Anaconda
• A free and open-source distribution of the Python
programming language.
• The distribution comes with the Python interpreter and various
packages related to machine learning and data science.
• Makes it easy to install/update packages and create/load
environments
Anaconda Navigator
Python Program
Input
Processing
(Adding two numbers)
Entity
Output
Python Elements
• Vocabulary / Words
• Valid Syntax Structure
Python Vocabulary
Note: You cannot use these reserved words as variable names
Python Program
Variable
• Variables are locations in memory for storing data.
• It is difficult for us to handle these numerical addresses in our
programs.
• So, we give a name to these locations and these names are
variables
Variables
• Variables is a named memory location.
• Programmer can choose the name of the variable.
• The content of the variable can be changed.
A=5 A 5 50
B = 10
B 10
A = 50
Variable Rule
• Thumb Rules for variables
• It can be any name except the reserved keywords of language.
• Must consists of letters, numbers and underscores.
• Must starts with the letter or underscore.
• Python language is a case sensitive
• Name and name is not same.
• Temp and temp is not same.
Assignment Operator
• An assignment statement “ ”
• Takes an expression
• Evaluates it
• Stores the value in the variable
• For Example x= 5 Constant
Variable Assignment
Executing Assignment Statement
Enter
Looks like nothing
happened
Enter
Display the value
of A
Print Statement
• Python provides a build in function print(), which allows the program to
the display the text on the screen.
Syntax
print(‘Hello word’)
print(Variable name)
User Input
• Python provides a build in function input(), which allows the program to
get the input at the run time.
• This function only takes the string as an input.
• Need to convert, incase of numbers
Syntax
x = input(‘Enter the value’)
Comments
• Any line started with hash (#)
symbol will be ignored by python.
• Why comment??
• Describe what is going to happen
in a program
Sentences/ Lines
A = 10 Simple Assignment Statement
A = 10 + 10 Assignment with Expression
Print(A) Function
Data Types
Data Types