0% found this document useful (0 votes)
26 views

Basic Programming Concepts - Variables, Data Types

Uploaded by

okkid021
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Basic Programming Concepts - Variables, Data Types

Uploaded by

okkid021
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Basic programming

concepts: variables,
data types

Dr Kazeem Oyebode
PhD Computer Engineering
LEARNING OBJECTIVEs

❖ Understand software development process


❖ Identify valid identifiers.
❖ Identify Python data types.
Software development process

A structured set of activities are required to develop a software system.


Many different software processes but all involve:
❖ Elicitation – Find out what the clients need. Understand the client's
subjective world;
❖ Analysis – Analyse requirements and strike out ambiguous requirements;
Software development process

❖ Specification – defining what the system should do;


❖ Design and implementation – defining the organization of
the system and implementing the system;
❖ Validation – checking that it does what the customer
wants;
❖ Evolution – changing the system in response to changing
needs
Five Basic Programming Elements

The five fundamental components of programming are:

❖ input:
❖ output:
❖ arithmetic:
❖ conditional:
❖ looping:
Compilers Development Environment

❖ Development environment are platforms where we write and run


Python codes.
❖ The following are popular development environments.
❖ PyCharm
❖ Spyder
❖ Visual Studio

an online development environment found here -


https://www.programiz.com/python-programming/online-compiler/
Standard Data Types

❖ The data stored in memory can be of many types. For example, a person's
age is stored as a numeric value. Python has various standard data types
that are used to define the operations possible on them
Standard Data Types

Python has five standard data types −


❖ Numbers
❖ String
❖ List
❖ Tuple
❖ Dictionary
Python Numbers

❖ Number data types store numeric values.


❖ Python supports two different numerical types −
❖ Integers and float
❖ For example
❖ my_age = 20
❖ my_weight = 46.7
❖ Run this code, as seen in the next slide
Integers and floats
String Data type

❖ Python defines strings as a contiguous group of characters that are


enclosed in quotation marks..
❖ Python allows either pair of single or double quotes
String Data type

❖ Subsets of strings can be taken using the slice operator ([ ] and [:] ) with
indexes starting at 0 in the beginning of the string and working their way
from -1 to the end.
❖ The plus (+) sign is the string concatenation operator
❖ The asterisk (*) is the repetition operator.
String data type
Operators

❖ Operators manipulate the value of operands. Consider the expression


❖ 44 + 50 = 94.
❖ Here, 44 and 50 are called the operands and + is called the operator.
Arithmetic Operators
Identifier

❖ Identifier is the name given to entities like variables, functions, etc.


❖ For example, in the statement, x = 6 , x is an identifier.
Naming rules for Identifiers

❖ 1. Identifiers can have any small letter (a .. z) or capital letter (A .. Z),


underscore ( _ ), digit (0...9).
❖ 2. An identifier can be any combination of the above but must not start with
a digit.
❖ For example. James1 is valid but 1James is not valid
❖ _123Kazeem is valid but 123Kazeem is not valid
Naming rules for Identifiers

❖ 3. Identifiers are letter case sensitive


❖ E.g. an identifier named Raheem is different from another named raheem
❖ 4. Special symbols like !,&, @, #, $, % etc. cannot be used in our identifier
❖ E.g. myname$ = “Kazeem” is invalid
Python reserved words - they cannot
be used as identifiers
Identify valid variable names
Analyse the code below and give an output
Python Comparison Operators

❖ These operators compare the values on either side of them and decide the
relation among them.
❖ They are also called relational operators. Assume variable ‘a’ holds the
value 10 and variable ‘b’ holds the value 20, then see next slide.
Comparison operations
Summary
Summary

● We discussed software development process

●We have learned variables and valid identifiers in Python

● Finally, we learned different data types in Python


FURTHER READING RESOURCES

❖ Python Programming Fundamentals (2nd Edition) by Kent D.


Lee
❖ Python Programming: An Introduction to Computer Science (2nd
Edition) by John Zelle
Thank
You

You might also like