Slide 1 Introduction
Slide 1 Introduction
MICHEAL OGUNDERO
EMAIL – [email protected]
INTRODUCTION
WHY LEARN ENGINEERING COMPUTING?
1. Web Development
2. Data Science
3. Game Development
4. Scientific Computing
5. Cybersecurity
INTEGRATED DEVELOPMENT ENVIRONMENT
These are software applications that provide tools to programmers for software
development.
Some Examples are:
1. Visual Studio Code
2. PyCharm
3. Atom
4. PyDev
5. SpyDer
Some are also available for use on smart phones.
FEATURES OF PYTHON PROGRAMMING LANGUAGE
Functions…
The general syntax to execute a function is
functionName ( parameters )
Now let’s try out one.
type(10)
the function ‘Type’ returns the data type of the parameter.
Also try
type(‘Hey you’)
type([3, 5,9])
INTRODUCTION: DATA TYPES AND FUNCTIONS
Functions…
• Strings and lists are both sequences of parts (characters or elements).
• We can find the length of that sequence with another function with the abbreviated name len.
len([1, 2, 3])
len('abcd')
list()
max(5, 11, 2)
• The print function will print as strings everything in a comma-separated sequence of expressions, and it
will separate the results with single blanks, and advance to the next line at the end, by default
x=3
y=5
print('The sum of', x, 'plus', y, 'is', x+y)
print()
• This takes you to the next line
INTRODUCTION: DATA TYPES AND FUNCTIONS
Functions…
• Some of the names of types serve as conversion functions
str(23)
int('125')
ARITHMETIC OPERATORS
1. + Addition
2. - Subtraction
3. * Multiplication
4. / Division
5. % Mod (the remainder after dividing)
6. ** Exponentiation (note that ^ does not do this operation, as you might have seen in other
languages)
7. // Divides and rounds down to the nearest integer
2*3
• Python uses the normal precedence of arithmetic operations: Multiplications and divisions are done
before addition and subtraction, unless there are parentheses.
Division and Remainders
• Python uses the doubled division symbol // for the operation that produces just the integer quotient,
and introduces the symbol % for the operation of finding the remainder.
5/2
5//2
5%2
EXERCISE
1. My electricity bills for the last three months have been $23, $32 and $64. What is the average
monthly electricity bill over the three month period? Write an expression to calculate the mean, and
use print() to view the result.
2. Two parts of a floor need tiling. One part is 9 tiles wide by 7 tiles long, the other is 5 tiles wide by 7
tiles long. How many tiles are needed?