Full-day introductory training to the Python programming language and basics of programming for people who are interested in the subject but have never done anything related to it before and would like to explore it from a beginner's standpoint. This training was held at the TrustYou HQ office in Munich, Germany, once per quarter between 2017 and 2019.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
this presentation will walk you through basic introduction to python, major features of python, how python runs on our system and some important commands used in python.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
this presentation will walk you through basic introduction to python, major features of python, how python runs on our system and some important commands used in python.
Introduction to python -easiest way to understand python for beginners
What is Python…?
Differences between programming and scripting language
Programming Paradigms
History of Python
Scope of Python
Why do people use Python?
Installing Python
** Python Certification Training: https://www.edureka.co/python **
This Edureka tutorial on "Python Tutorial for Beginners" (Python Blog Series: https://goo.gl/nKQJHQ) covers all the basics of Python. It includes python programming examples, so try it yourself and mention in the comments section if you have any doubts. Following are the topics included in this PPT:
Introduction to Python
Reasons to choose Python
Installing and running Python
Development Environments
Basics of Python Programming
Starting with code
Python Operators
Python Lists
Python Tuples
Python Sets
Python Dictionaries
Conditional Statements
Looping in Python
Python Functions
Python Arrays
Classes and Objects (OOP)
Conclusion
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Python is a widely-used and powerful computer programming language that has helped system administrators manage computer networks and problem solve computer systems for decades. Python has also built some popular applications like BitTorrent, Blender, Calibre, Dropbox, and much more. Going further, the “Pi” in Raspberry Pi stands for Python, so learning Python will instill more confidence when working with Raspberry Pi projects. Python is usually the first programming language people learn primarily because it is easy to learn and provides a solid foundation to learn other computer programming languages. In this webinar,
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and work in the Python shell.
• Use calculations, variables, strings, lists, and if statements.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
The recording is available at https://youtu.be/ThcWmJFf-ho.
1. Python Presented By: Rajesh Kumar Guided By: Mr. Jaishankar Bhatt
2. Content Python Introduction Python Code Execution Python Comments & Indentation Variables Data Types Strings Collections (Arrays)
3. Python Introduction What is Python? Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum Released in 1991
4. Python Code Execution Source code extension is .py Byte code extension is .pyc (compiled python code) Python’s runtime execution model:
5. Comments •Creating a Comment: Ex: Comments starts with a # Output:
6. Comments •Multi Line Comments: Ex: or:
7. Python Indentation •Indentation refers to the spaces at the beginning of a code line. Ex1: Ex2:
8. Variables •Variables are containers for storing data values. Ex:
9. Data Types •Built-in Data Types
10. Getting the Data Type •You can get the data type of any object by using the type() method. Ex: Print the data type of the variable x: Output:
11. Setting the Data Type •In Python, the data type is set when you assign a value to a variable:
12. Strings •String literals in python are surrounded by either single quotation marks, or double quotation marks. •'hello' is the same as "hello". Ex:
13. Multiline Strings •You can assign a multiline string to a variable by using three quotes Ex: Output:
14. Slicing •You can return a range of characters by using the slice syntax. Ex:Get the characters from position 2 to position 5. Output:
15. String Methods Method Description len() Returns the length of a string. lower() Returns the string in lower case. upper() Returns the string in upper case. count() Returns the number of times a specified value appears in the string.
16. Collections (Arrays) •There are four collection data types in the Python programming language. Types: 1. List 2. Tuple 3. Set 4. Dictionary
17. Python Lists •A list is a collection which is ordered and changeable. In Python lists are written with square brackets. Ex: Create a List: Output:
18. Python Tuples •A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Ex: Create a Tuple: Output:
19. Python Sets •A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Ex: Create a Set:
20. Python Dictionaries •A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets. Ex: Create a Dictionary:
21. Conclusion Python is a great option, whether you are a beginning programmer looking to learn the basics, an experienced programmer designing a large application, or anywhere in between. The basics of Python are easily grasped, and yet its capabilities are vast.
22. Reference https://www.udemy.com/course/learn- programming-with-python https://www.w3schools.com/python/default.asp
Open source general-purpose. Multiplatform programming language
Object Oriented, Procedural, Functional
Easy to interface with C/ObjC/Java/Fortran
Easy to interface with C++ (via SWIG)
Great interactive environment
Python 'philosophy' emphasis readability, clarity and simplicity
The Interactive Interpreter
it is very easy to learn and understand.
Why is Python emerging technology?
Python with DataSciences and Machine Learning is future.
Python can also be used with Electronics.
Python as Scripting Language
Materi logika dan pemrograman untuk microteaching di Amikom. beberapa referensi diambil dari http://www.slideshare.net/BaabtraMentoringPartner/algorithms-introduction-to-computer-programming
Introduction to python -easiest way to understand python for beginners
What is Python…?
Differences between programming and scripting language
Programming Paradigms
History of Python
Scope of Python
Why do people use Python?
Installing Python
** Python Certification Training: https://www.edureka.co/python **
This Edureka tutorial on "Python Tutorial for Beginners" (Python Blog Series: https://goo.gl/nKQJHQ) covers all the basics of Python. It includes python programming examples, so try it yourself and mention in the comments section if you have any doubts. Following are the topics included in this PPT:
Introduction to Python
Reasons to choose Python
Installing and running Python
Development Environments
Basics of Python Programming
Starting with code
Python Operators
Python Lists
Python Tuples
Python Sets
Python Dictionaries
Conditional Statements
Looping in Python
Python Functions
Python Arrays
Classes and Objects (OOP)
Conclusion
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Python is a widely-used and powerful computer programming language that has helped system administrators manage computer networks and problem solve computer systems for decades. Python has also built some popular applications like BitTorrent, Blender, Calibre, Dropbox, and much more. Going further, the “Pi” in Raspberry Pi stands for Python, so learning Python will instill more confidence when working with Raspberry Pi projects. Python is usually the first programming language people learn primarily because it is easy to learn and provides a solid foundation to learn other computer programming languages. In this webinar,
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and work in the Python shell.
• Use calculations, variables, strings, lists, and if statements.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
The recording is available at https://youtu.be/ThcWmJFf-ho.
1. Python Presented By: Rajesh Kumar Guided By: Mr. Jaishankar Bhatt
2. Content Python Introduction Python Code Execution Python Comments & Indentation Variables Data Types Strings Collections (Arrays)
3. Python Introduction What is Python? Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum Released in 1991
4. Python Code Execution Source code extension is .py Byte code extension is .pyc (compiled python code) Python’s runtime execution model:
5. Comments •Creating a Comment: Ex: Comments starts with a # Output:
6. Comments •Multi Line Comments: Ex: or:
7. Python Indentation •Indentation refers to the spaces at the beginning of a code line. Ex1: Ex2:
8. Variables •Variables are containers for storing data values. Ex:
9. Data Types •Built-in Data Types
10. Getting the Data Type •You can get the data type of any object by using the type() method. Ex: Print the data type of the variable x: Output:
11. Setting the Data Type •In Python, the data type is set when you assign a value to a variable:
12. Strings •String literals in python are surrounded by either single quotation marks, or double quotation marks. •'hello' is the same as "hello". Ex:
13. Multiline Strings •You can assign a multiline string to a variable by using three quotes Ex: Output:
14. Slicing •You can return a range of characters by using the slice syntax. Ex:Get the characters from position 2 to position 5. Output:
15. String Methods Method Description len() Returns the length of a string. lower() Returns the string in lower case. upper() Returns the string in upper case. count() Returns the number of times a specified value appears in the string.
16. Collections (Arrays) •There are four collection data types in the Python programming language. Types: 1. List 2. Tuple 3. Set 4. Dictionary
17. Python Lists •A list is a collection which is ordered and changeable. In Python lists are written with square brackets. Ex: Create a List: Output:
18. Python Tuples •A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Ex: Create a Tuple: Output:
19. Python Sets •A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Ex: Create a Set:
20. Python Dictionaries •A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets. Ex: Create a Dictionary:
21. Conclusion Python is a great option, whether you are a beginning programmer looking to learn the basics, an experienced programmer designing a large application, or anywhere in between. The basics of Python are easily grasped, and yet its capabilities are vast.
22. Reference https://www.udemy.com/course/learn- programming-with-python https://www.w3schools.com/python/default.asp
Open source general-purpose. Multiplatform programming language
Object Oriented, Procedural, Functional
Easy to interface with C/ObjC/Java/Fortran
Easy to interface with C++ (via SWIG)
Great interactive environment
Python 'philosophy' emphasis readability, clarity and simplicity
The Interactive Interpreter
it is very easy to learn and understand.
Why is Python emerging technology?
Python with DataSciences and Machine Learning is future.
Python can also be used with Electronics.
Python as Scripting Language
Materi logika dan pemrograman untuk microteaching di Amikom. beberapa referensi diambil dari http://www.slideshare.net/BaabtraMentoringPartner/algorithms-introduction-to-computer-programming
Learning Outcome: 1- Gain knowledge and understanding the meaning of computer language? 2- Draw conclusions about concepts: data types, variables, Conditional statements, looping statements, functions and Object Oriented Programming.
Key Concepts: 1- Concept of computer language. 2- Concept of different data types, variables, Conditional statements, looping statements, functions and Object Oriented Programming.
Skills: At the completion of the program, students should be able to: 1- understand the structure of the program. 2- Design some programs include different data types, variables, Conditional statements and looping statements. 3- Compile the program (Run).
Essential Questions: 1- What is meant by programming language and give some examples? 2- What are the key features or characteristics of language? Textbook and Resource Materials: https://www.w3schools.com
Evidence of Learning: Create a presentation contains some concepts of computer languages and display the Concepts of different data types, variables, Conditional statements, looping statements, functions and Object Oriented Programming.
SEC Topic & Code: Using appropriate programming language to produce a project that solves societal or learning problem creatively
Complete Course Available at: https://github.com/Ebad8931/PythonWorkshop
Introduction to Python Presentation that talks about the pros and Cons of Programming in Python and introduces basic Programming Concepts like Data Types and Operators.
Workshop slides which give an overview of python programming. The slides are accompanied by DIY (do it yourself) programs which can be found as in GitHub (https://github.com/bhalajin/blueprints)
It was presented in #NullHyd on 14th Dec, 2019 with 4 hours hands-on session. All code has been shared in github repo as well: https://github.com/jassics/python-for-cybersecurity
Complete Course Available at: https://github.com/Ebad8931/PythonWorkshop
Python Functions are discussed in this Presentation. The concept of Functional Programming is explained through a Time Conversion from AM to PM Example. Special functions like Lambdas, map and filter etc are also introduced here.
Complete Course Available at: https://github.com/Ebad8931/PythonWorkshop
Basic Concepts of Loops and Conditional Statements in Python are introduced in the presentation. Also covers How to get input from the Console and includes interactive Problems.
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...NelTorrente
In this research, it concludes that while the readiness of teachers in Caloocan City to implement the MATATAG Curriculum is generally positive, targeted efforts in professional development, resource distribution, support networks, and comprehensive preparation can address the existing gaps and ensure successful curriculum implementation.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
Intro to Python for Non-Programmers
1. Intro to Python for
Non-Programmers
Ahmad Alhour / Team Lead, TrustYou
23 April, 2019
2.
3. Overview
● A very basic intro to programming
● Intended for people who have no clue about it
● Mainly, to give you a taste of what it is about
● Hopefully, it’ll put you on the right track to study
on your own
3aalhour.com
4. Hello!
I am Ahmad
I have been doing programming as a
hobby since I was a kid, and
professionally since 2008. I also have
a B.Sc. degree in Computer Science.
At TrustYou, I lead several projects, all
powered by Python!
4
5. 15 mins
Intro and Setting
Expectations
30 mins
What is Programming?
10 mins
Intro to REPL.it
45 mins
Numbers, Variables
and Strings
30 mins
Functions (Part 1)
Plan Until Lunch
6. 15 mins
Recap and
Review
45 mins
Conditionals
45 mins
While Loops
and Collections
45 mins
For Loops and
Functions (Part 2)
30 mins
Wrapping Up
Plan After Lunch
8. ““Blessed is he who expects nothing,
for he shall never be disappointed.”
― Alexander Pope
8aalhour.com
9. Group Exercise:
Let’s Set Expectations Together
● Learn the basics of Programming
● Learn the basics of Python
● There will be no installation
9aalhour.com
12. 12
Programming 101
● Is a way of telling the computer how to
do certain things by giving it a set of
instructions
● These instructions are called Programs
● Everything that a computer does, is
done using a computer program
aalhour.com
15. 15
What is a Programmer?
“A programmer is an Earthling who can
turn big amounts of caffeine and pizza
into code!”
― Anonymous
aalhour.com
16.
17. 17
Seriously, what is a programmer?
● A person who writes instructions is a
computer programmer
● These instructions come in different
languages
● These languages are called computer
languages
aalhour.com
18. 4.
What is a Programming
Language?
18aalhour.com
19. 19
What is a Programming
Language?
● A programming language is a type of
written language that tells computers
what to do
● They are used to make all the
computer programs
● A P.L. is like a set of instructions that
the computer follows to do something
aalhour.com
20. 20
Machine Language
● The computer’s native language
● The set of instructions have to be
coded in 1s and 0s in order for the
computer to follow them
● Writing programs in binary (1s and 0s)
is tedious
● Lowest level language
aalhour.com
21. 21
High-level Languages
● Programming languages that are
closer to English than Machine code
● Human-readable
● Expresses more by writing less
aalhour.com
29. 29
The Python Programming
Language
● High-level programming language
● Named after BBC’s
"Monty Python’s Flying Circus" show
● One of the most adopted languages
world-wide
● Most TY products are powered by it
aalhour.com
30. 30
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for each_number in numbers:
print(each_number)
Example Python Program:
Counting to 10
37. 37
Numbers in Python
● One of value types
● Demo:
○ Numbers in interactive mode
○ Basic arithmetic
aalhour.com
38. 38
Evaluation Order of Operations
● First, “*” and “/” are evaluated
● Then, “-” and “+” are evaluated
● All operations are evaluated
left-to-right
aalhour.com
40. 40
Grouping Calculations with
Parentheses
● Used for separating calculations into
distinct groups
● For example:
○ (10 * 2) + (5 - 3) / (4 + 2)
○ → 20 + 2 / 6
○ → 20 + 0.333
○ → 20.333
aalhour.com
41. 41
Evaluation Order of Operations:
Revisited!
● First, what is in “(” and “)” is evaluated
● Then, “*” and “/” are evaluated
● Then, “-” and “+” are evaluated
● All operations are evaluated
left-to-right
aalhour.com
44. 44
Variables in Python
● Used to give names to values
● You give names to stuff to refer to
them later on in your program
● You give names to stuff using the “=”
symbol, known as “assignment
operator”
● Variable names must begin with a
letter
aalhour.com
45. 45
● Implement one plus one operations
using variables
Demo Time
aalhour.com
46. 46
Example usage:
● Calculate the average population for
Earth in 2015
● Give it a name
● Everytime you want to refer to it you
just use the name rather than to
recalculate it again
Variables in Python
aalhour.com
47. 47
Break the calculation down using
variables:
● (10 * 2) + (5 - 3) / (4 + 2)
● X + Y / Z
● Store result in “result” name
Demo Time
aalhour.com
48. 48
Break the following calculations down
into sub-calculations and store them into
variables:
● 9 * (9 - 9) * 10 / 15
● (1 + 1 + 1) * (2 + 6) / 2
● 10 + 1 * (2 - 4) / 20
● 50 - 5 - (5 - 10) / 2
● (1 + 2) - 5 * (3 - 7 + 4) * 9 / 12
Exercise
aalhour.com
50. 50
● Used to represent text in Python
● Examples:
○ “Hello, World!”
○ “My name is Ahmad.”
○ “Bier und Brezel.”
● Any text in between “” is a string in
Python
Strings in Python
aalhour.com
51. 51
● Type in the following strings in the
interactive shell:
○ “Hello, World!”
○ “My name is Ahmad.”
○ “Bier und Brezel.”
● Use all of the above with print
● Store all of the above in variables and
then print them
Demo Time
aalhour.com
52. 52
Print the following poem:
Doubt thou the stars are fire;
Doubt that the sun doth move;
Doubt truth to be a liar;
But never doubt I love.
― William Shakespeare, Hamlet
Exercise
aalhour.com
55. 55
● Just like how variables give name to
values, functions give name to
calculations/instructions
● It is easier to refer to a group of
instructions with a name than write
them all over again
● You need three main words to define
functions: “def”, “<name>” and “return”
Functions in Python
aalhour.com
56. 56
● You know functions already!
● Print is a Python function that takes
whatever value you’d like and prints it
on the screen
● Print can take several values
separated by commas, e.g.:
○ print(“My name is:”, “Slim Shady”)
○ print(“One plus one is:”, 2)
Functions in Python
aalhour.com
57. 57
● Define a new function
● Print William Shakespeare’s poem
● repl.it/@aalhour/WilliamShakespeare
Demo Time
aalhour.com
58. 58
● Define a new function
● Code the one plus one example in
variables
● Return the result
Demo Time
aalhour.com
59. 59
● Define a function to calculate each of
the following, with variables, and
return the result:
○ 9 * (9 - 9) * 10 / 15
○ (1 + 1 + 1) * (2 + 6) / 2
○ 10 + 1 * (2 - 4) / 20
○ 50 - 5 - (5 - 10) / 2
○ (1 + 2) - 5 * (3 - 7 + 4) * 9 / 12
Exercise
aalhour.com
60. 60
● Functions can take values as
arguments!
● Useful for doing tasks with user input,
for example:
○ Given 5 numbers, return the avg.
○ Given weight and height of a
person, calculate their BMI.
Functions in Python
aalhour.com
61. 61
● Define a new function for printing
different values
● Define a new function for calculating
BMI given height and weight
● repl.it/@aalhour/FuncsWithVars
Demo Time
aalhour.com
62. 62
● Define a function that accepts two
arguments and returns the result of
their addition
● Define a function that takes five
arguments and returns the average
Exercise
aalhour.com
64. 15 mins
Recap and
Review
45 mins
Conditionals
45 mins
While Loops
and Collections
45 mins
For Loops and
Functions (again!)
30 mins
Wrapping Up
Plan After Lunch
68. 68
● They are the Yes/No questions of
programming
● The answer is either a True or a False
● These values are called Booleans
● Conditionals compare values together
● Using simple operators such as:
○ >, <, >=, <= and ==
Conditionals
aalhour.com
69. 69
Compare several numbers together and
check the results:
● 1 < 10
● 1 <= 10
● 5 > 2
● 5 >= 2
● 1 == 1
● 0 <= 0
Demo Time
aalhour.com
70. 70
Evaluate the following in your mind and
then on REPL.IT:
● 1 + 1 + 1 + 1 + 1 > 4
● 2 * 2 < 5 / 3
● 5 * 3 >= 15
● 10 / 2 == 5
● (25 * 3) - 100 / 2 < (25 * 2) + 1
Exercise
aalhour.com
71. 71
● First, what is in “(” and “)” is evaluated
● Then, “*” and “/” are evaluated
● Then, “-” and “+” are evaluated
● Lastly, comparisons are evaluated
○ “>”, “>=”, “<”, “<=”, “==”
● Operations get evaluated left-to-right
Evaluation Order of Operations:
Expanded
aalhour.com
72. 72
● A Python statement for making
decisions based on a condition
● In a nutshell: if this, then that
● For example:
If your age is greater than 18,
then you are allowed to enter the bar
The If Statement
aalhour.com
73. 73
● If old enough to enter bar, print
“proceed to bar!”.
● If not old enough to enter bar, print
“too young still!”
Demo Time
aalhour.com
74. 74
Teenager Exercise 01:
Define an “age” variable and insert your
age. Write an if statement to display
“teenager” if age is less than 21
Exercises
aalhour.com
75. 75
Exercises
Positive Number 01:
Define a “number” variable and insert a
random value. Write an if statement to
display “positive” if the number is greater
than 0
aalhour.com
76. 76
● Expanded If-Statement for handling
cases that don’t match the condition.
● In a nutshell: if this, then that;
otherwise, something else
● For example:
○ If your age is greater than 18, then
you are allowed to enter the bar;
otherwise, you are asked to leave
The If-Else Statement
aalhour.com
77. 77
Translate the following into Python:
If old enough to enter bar
then print “proceed to bar!”
else print “please, leave!”
Demo Time
aalhour.com
78. 78
● Teenager Exercise 02:
Expand the code and add an else
block which prints “adult” if the
teenager check is not met
● Positive Number 02:
Expand the code and add an else
block which prints “negative” if the
positive check is not met
Exercises
aalhour.com
79. 79
● Teenager Exercise 03:
Wrap the exercise’s code in a function
that accepts an “age” argument and
returns nothing.
● Positive Number 03:
Wrap the exercise’s code in a function
that accepts a “number” argument and
returns nothing.
Exercises
aalhour.com
82. 82
● Loops are good for repeating
instructions for a number of times
● They’re good because we don’t have
to duplicate code, but we just tell the
program to keep repeating stuff
● Loops repeat stuff according to a
condition as well
While Loops
aalhour.com
83. 83
● Example:
○ While my BMI is above 100, keep
working out!
○ While my coffee is not empty, keep
writing code!
● You need two words to loop stuff:
○ “while” and “break”
○ Break is used to stop looping or
else you will loop forever!
While Loops
aalhour.com
84. 84
while True:
print(1) # Prints 1 forever
while 1 == 1:
print(1) # Prints 1 forever
while 5 > 2:
print(1) # Prints 1 forever
Code Examples
aalhour.com
85. 85
# Prints 1 once, then stops
while True:
print(1)
break
# Prints 1 once, then stops
while 1 == 1:
print(1)
break
Code Examples
aalhour.com
86. 86
● Print “Hello, World!” forever!
● Print your own name forever!
● Calculate the following formula and
print the result forever:
○ 10 * 312 / 57 + 23 * 5 + 823 / 74
Play Time
aalhour.com
87. 87
● To avoid running forever, we need to
maintain a counter and a limit
● Counters are variables that keep track
of how many times a loop ran
● Limits allow us to break out of the loop
once the loop runs for a max. number
of times
Counters and Limits
aalhour.com
88. 88
counter = 1
while counter < 10:
print(counter)
counter = counter + 1
Code Example
aalhour.com
89. 89
● Add a counter number and increment it
inside the loop. Print the counter to
show that its value changes.
● Add a limit check before the work with
a break.
Demo Time
aalhour.com
90. 90
● Print numbers from 0 until 1 million
● Teenager Exercise 04:
Define age variable and assign it to 1.
Run the loop with the teenager check.
The loop should print the age and then
increment it until the age is no longer
teeanger, after which the loop should
terminate
Exercises
aalhour.com
91. 91
● You can ask for the user’s input using
the built-in “input” function
● For example:
input(“Enter a number:”)
● Useful for asking the user for data.
User Input
aalhour.com
92. 92
● Ask the user for their name and then
print it out.
● Ask the user for their age and print it
out with the statement: “Your age is:”
Demo Time
aalhour.com
93. 93
Teenager Exercise 05:
Ask the user for their age. Run the loop
with the teenager check on the user
input. The loop should print “You are still
a teenager” alongside the age and then
increment it until the age is no longer
teeanger, after which the loop should
terminate.
Exercises
aalhour.com
94. 94
Teenager Exercise 06:
Wrap the Teenager Exercise #05 with a
function that asks the user for their age
and then prints out the message: “You
are still a teenager:” alongside their age.
Increments the age number until the
loop no longer runs.
Exercises
aalhour.com
97. 97
● Collections are a way of keeping items
together, e.g.: bags!
● We will take a look at lists in Python
● Lists are good for memorizing the
order in which we keep things too
Collections
aalhour.com
98. 98
A list of numbers:
[1, 2, 3, 4, 5]
A list of strings:
[“Alice”, “Bob”, “Claire”]
A mixed list of things:
[123, “Ahmad”, message]
Examples of Collections
aalhour.com
99. 99
Anything in between “[” and “]” is
considered a list
A list can contain anything in Python:
● Numbers
● Strings
● Variables
● Other lists
How can I create a collection?
aalhour.com
100. 100
● Create a list of the English alphabet
● Create a list that contains your:
○ first name
○ last name
○ your lucky number
○ your current address
● Print the above lists using the print()
function
Exercises
aalhour.com
101. 101
● Ranges in Python are useful functions
for generating collections of numbers
● More like a shortcut
● Easy to use
● Example:
○ range(1, 10): generates a collection
of all numbers from 1 until 9 (stops
at 10 but doesn’t include it)
Ranges
aalhour.com
102. 102
● range() takes three arguments:
○ Start: number to start with
○ End: number to stop at
○ Step: increment size
● Examples:
○ range(0, 5, 1) → [0,1,2,3,4,5]
○ range(0, 6, 2) → [0, 2, 4]
○ range(0, 6, 3) → [0, 3]
Ranges: In Detail
aalhour.com
103. 103
● start = 0 by default, unless specified
● step = 1 by default, unless specified
● end is mandatory and must be always
specified
● Examples:
○ range(6) → [0,1,2,3,4,5]
■ Same as: range(0, 6, 1)
Ranges: Default Behavior
aalhour.com
104. 104
● Generate a list of all odd numbers
greater than 0 and less than 1000
● Generate a list of all even numbers
greater than 29 and less than 250
● Generate a list of all numbers less
than -1 and greater than -132
● Generate a list of all even numbers
less than -250 and greater than -277
Exercises
aalhour.com
107. 107
● For loops are another way to apply the
same computation more than once
according to a check in your program
● Similar to While Loops but easier to
maintain
○ No need for a counter
○ No need for a beaking check
For Loops
aalhour.com
108. 108
For loops need a collection in order to…
well, loop! :P
Example: for every item in shopping cart,
print it out on the screen:
for item in [“Shoes”, “Tablet”]:
print(item)
For Loops
aalhour.com
109. 109
for number in [1, 2, 3, 4, 5]:
print(number)
for number in range(6):
print(number)
for person in [“AA”, “AM”, “DW”, “DV”]:
print(person)
For Loops: Examples
aalhour.com
110. 110
● Syntax:
○ for <variable name> in <collection>:
■ List of commands
● The variable name can be whatever
you want
● The collection can have whatever you
want but it must be a collection, not
anything else
How do I make a for loop?
aalhour.com
111. 111
1. For every item in the collection:
a. Assign the item to the variable
name that the programmer wrote
b. Enter the block
c. Execute all commands
d. Go to 1 and grab the next the item
2. If the collection is empty or has no
more items to see, then exit the block
How do for loops work?
aalhour.com
112. 112
for number in [1, 2, 3, 4, 5]:
print(number)
Loop execution log:
number = 1 → print(1)
number = 2 → print(2)
number = 3 → print(3)
number = 4 → print(4)
number = 5 → print(5)
Demo
aalhour.com
113. 113
● Using range() and a for loop:
○ Print your name 25 times
○ Print “Hello, World!” 10 times
Play time!
aalhour.com
114. 114
Teenager Exercise 01: Reloaded
Ask the user for their age. Check if the
user is a teenager. Run a for loop over a
range of ages until an age value that is
not a teenage number anymore. Run a
for loop and display the “you’re a
teenager” message according to the list
of ages (range)
Exercises
aalhour.com
115. 115
Teenager Exercise 02: Reloaded
Wrap your solution for the “Teenager
Exercise 01: Reloaded” exercise with a
function that asks the user for their age
and then prints out the message:
“You are still a teenager:” alongside their
age.
Exercises
aalhour.com
120. 120
● Numbers: 1, 2, 3
● Order of operations: (, ), *, /, +, -, <, >, >=, <=, ==
● Strings: “Hi!”
● Variables: x = 1
● Functions:
def greet(person):
print(“Hello, ”, person)
● Conditionals: 1 >= 10
What You’ve Learned So Far
aalhour.com
121. 121
● While Loops:
while True:
greet(“Ahmad”)
● Lists:
[1, 2, 3, “Alice”, “Bob”]
● Ranges:
range(10) → [1, 2, 3, …, 9]
● For Loops:
for number in range(10):
print(number)
What You’ve Learned So Far
aalhour.com
123. 123
Online Courses
● Intro to Python - by Udacity
○ https://bit.ly/2N45h6F
○ 5 weeks long. Completely FREE.
● Intro to Python: Absolute Beginner - by edX
○ https://bit.ly/2NJg2MW
○ 5 weeks. Completely FREE.
● Python for Everybody - by Coursera
○ https://bit.ly/1KSzsbb
○ 7 weeks long. Only first seven days are free.
Resources for Further Study
aalhour.com
124. 124
Resources for Further Study
Interactive Learning
● Codecademy - Learn by Coding
○ https://www.codecademy.com
○ Completely Free.
Books
● Think Python, 2nd edition
○ http://greenteapress.com/thinkpython2
○ Completely Free Online.
aalhour.com