1 of 19

Python Essentials II�Module 2 - 2.3.1.1 ~ 2.3.1.10

Cisco Networking Academy Introduction

1

STEAM Clown ™ Productions

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

2 of 19

Licensing & Attribution

Open Source Philosophy - I have come to realize that I’m really not competing with other teachers. Maybe I have some local competition, but in reality, if a student is not coming to my class or my school, then I’m not competing with other teachers in any way… If you work more than a District away, then we really are not competitors. Let's Share... Collaborate... Help each other... I, and you, may have sweat blood and tears developing a lesson plan, a lab, or presentation… There is an ENORMOUS unpaid value there… I get that… I don’t begrudge teachers who are trying to sell their collateral… I’m just saying that is not what I’m going to do. But that is my plan. I’m going to share virtually everything I develop. Join Me!!! See More

CC BY-NC-SA 4.0

https://creativecommons.org/licenses/by-nc-sa/4.0/

https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode

GNU Public License & EUPL (European Union Public Licence)

Any included or linked Programming Code Is licensed under GNU General Public License v3.0 & and / or licensed under EUPL 1.2 or later

See the Appendix for Additional Licensing & Attribution Information

2

Please maintain this slide with any

modifications you make

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

3 of 19

Resources & Materials Needed

  • PC, Laptop or Other device to access sites & applications specified by your Instructor
  • Access to the Cisco Networking Academy �Python Esentials class

3

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

4 of 19

👉 Try This:

  • Browser: You can use a web based Browser IDE like Replit.com, PythonTutor or Trinket.
  • Installed Python IDLE: If you installed Python open an IDLE window

4

print("Hisssssssssss")

Try This 👉

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

5 of 19

Sections Covered In This Lesson

  • 2.3.1.1 Operators- data manipulation tools
  • 2.3.1.2 Arithmetic operators: exponentiation
  • 2.3.1.3 Multiplication and Division
  • 2.3.1.4 Integer division
  • 2.3.1.5 Remainder (modulo)
  • 2.3.1.6 Addition; Subtraction/unary/binary
  • 2.3.1.7 Operator priorities and their bindings
  • 2.3.1.8 Operators, bindings: exponentiation
  • 2.3.1.9 List of priorities;operators,parentheses

5

Try This 👉

Work all the code examples in the sections

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

6 of 19

Key Concepts & Topics...

  • Python as a calculator
    • operator is a symbol of programming language that operates on values, e.g. add or +
    • expressions are formed with data and operators
  • Exponentiation: base ** exponent
    • when both arguments are integers, result is int
    • when at least one argument is a float, result is flt
  • Arithmetic: *, mult; /, divide (result is a float)
  • Integer divide: //
    • e.g. print (-6//4) and print (6.0//-4) will yield -2 and -2.0 (because the real result is -1.5 rounded to -2 or -2.0)
    • Integer divide is also called floor division

6

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

7 of 19

Key Concepts & Topics...

  • Remainder (modulo): %, remainder left after the integer division
    • Ex1. print (14%4), yields 2 because
      • 14//4 is 3, the integer quotient
      • 3*4 is 12, quotient x divisor
      • 14-12 is 2, the remainder
    • Ex2. print (12%4.5), yields 3.0 because
      • 12//4.5 is 2.0, the float after an integer divide
      • 2.0*4.5 is 9.0, quotient x divisor
      • 12-9.0 is 3.0, the remainder
  • Division by zero does not work

7

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

8 of 19

Key Concepts & Topics...

  • List of Priorities

8

Priority

Operator

1

+, -

unary

2

**

unary

3

*, /, //, %

unary

4

+, -

binary

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

9 of 19

Your Take-Away From These Sections

  • Expression is a combination of values (or variable, operators, function calls. e.g. 1+2
  • Operators are special symbols or keywords that operate on values. e.g. x*y
  • Arithmetic operators in Python:
    • + (add), - (subtract), * (multiplication), / (division, returns as float)
    • % (special symbol for modulus divide, left operand divided by right operand and returns remainder, e.g. 5 % 2=1)
    • ** (exponentiation)
    • // (floor/integer- rounded down. e.g. 3//2.0=1.0)

9

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

10 of 19

Your Take-Away From These Sections

  • Unary operator has one operand, e.g. -1 or +3
  • Binary operator has two operands, e.g. 4+5
  • Hierarchy of priorities
    • unary + and - have highest
    • then: **, then: *, / and %, and lowest priority: binary + and -
  • Subexpressions in parentheses are calculated first, e.g. 15-1*(5*(1+2))=0
  • Exponentiation operators uses right-sided binding, e.g. 2**2**3=256

10

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

11 of 19

Can You Answer These Questions?

  • print(9 % 6 % 2)
  • print(2 * 3%5)
  • print((5*((2513)+100)/(2*13))//2)

Dig Deeper

11

"Mastery" means you can describe why these topics and concepts are important. Can you explain and discuss these ideas? As you read and work the code examples pay special attention to these ideas.

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

12 of 19

Thank You…

Questions?

12

If you are in one of my classes, you can probably send / post questions in:

STEAM Clown ™ Productions

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

13 of 19

Reference Slides

13

STEAM Clown ™ Productions

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

14 of 19

Education Standards

  • California's 2013 CTE Standards
  • Next Generation Science Standards
  • California Math Common Core Standards
  • California English Common Core Standards
  • California History-Social Science Standards
  • California English Language Development Standards
  • Next Generation Science Standards (1)
  • California's 2013 CTE Standards (2)
  • Related Instructional Objectives (SWBAT...)

14

14

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

15 of 19

Quiz Answers

  • print (9 % 6 % 2)��Answer: 1�
  • print (2 * 3%5)��Answer: 1�
  • print ((5*((2513)+100)/(2*13))//2)��Answer: 10.0

15

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

16 of 19

Appendix

16

STEAM Clown ™ Productions

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

17 of 19

Appendix : Primary Sources & Attribution for Material Used

17

Please maintain this slide with any modifications you make

  • <Add Your Logo and Attribution here>
  • Much of this interpretation is primarily the Intellectual Property of Jim Burnham, Top STEAM Clown, at STEAMClown.org
  • My best attempt to properly attribute, or reference any other sources or work I have used are listed below. This presentation and content is distributed under the Creative Commons License and the The programming code found in this presentation or linked to on my Github site is distributed under the GPL and EUPL:

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

18 of 19

Image Reference & Sources

18

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

19 of 19

What To Fix, Add, Or Change

Presentation Planning:

19

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions