Programming
  • Home
  • COVID / McKay Absent
  • Important Notices
  • Assignment Summary
  • Course Details
    • Curriculum Connection
      • Big Ideas
      • Curriculum Competencies
      • Content
      • ADST Connection
    • Course Outline
    • Classroom Expectations
    • Evaluation and Assessment
    • ICTX Site
  • Student Sites
    • 2022 / 2023 Semester 1
    • Showcase
      • Scratch Etch - A - Sketch
  • Theory Assignments
    • Viruses
    • Career Exploration
    • Tynker
    • Intro Activities
      • Name Tag
      • Intro - Portfolio SetUp
      • Tynker Intro
      • Black History Connection
      • Intro - Avatar Assignment
      • Intro - Programming Is Everywhere!
    • Programming Languages
      • Hello World
      • History of Programming
    • Famous Programmers
    • Communication Codes
    • Binary Code
    • Digital Pivacy
  • Pixel Pad Project
  • C++
    • Getting Started
    • Practice 1
    • Arrays
    • For Loops C++
    • Random Numbers
  • Intro To Python
  • Web Development Unit
    • Web Programming - Intro
    • Getting Set Up
    • Sample CodeSandBox
    • Beginners - Web Programming
    • Intermediate Web Programming
  • JavaScript
    • Intro to JavaScript
    • First Programs
    • Next Steps
  • Vex VR
  • Final Project(s) Ideas
  • Game Engine Exploration
    • Getting Started
    • Godot
    • Unity
    • Game Engines
  • Hand In 2020 - Q2
  • Introduction to Programming
    • Computer Science is Changing Everything
    • What is Coding? Programming?
    • Intro - Why Learn to Program
    • Activities
      • Code Master
      • Lego Block Activity
      • Cup Stacking
      • Dice Race Activity
    • Thinking Like A Computer
      • Part 1: Algorithms / Pseudocode
      • Part 2: Structures
      • Part 3: Flowcharts
  • Scratch
    • Intro - Part 1
    • Intro - Part 2 - Sprites
    • Building Blocks - Basic
    • Sprites - Changing Appearances
    • Pen Tool and Key Press
      • Coordinate System
      • Pen Tool Intro
      • Scratch Function
      • Etch a Sketch
    • Car Racing
    • Variables
      • Variables / Broadcasting
      • Variable Assignment
      • Simple programs
    • Future Scratch
      • Scratch Examples
        • Introduction to Music
      • Game Assignment
        • Overview
        • Game Ideas
        • Game Tutorials
    • Scratch Help
  • Swift Programming
    • Swift Part 1
    • Intro Assignments
    • Swift Stuff
  • Python
    • Getting Started New
    • Posting Replit Assignments
    • For Loops
    • Functions (Intro)
    • ASS: Turtle Drawing
    • Turtle - Interactivity
    • ASS Keyboard Control - Turtle
    • ASS - Turtle - Dragging
    • ASS - Spiral Challenge
    • Basic Input / Output
    • ASS - Madlib Game
    • Basic Operations
    • Random Numbers
    • Resources
    • Check these tutorials out
    • Lists
    • Other Python Commands
  • Alternatives
    • LEGO EV3
      • Basic Build Instructions
      • Additional Models
      • Visual Assists
      • Resources:
      • Activities / Challenges
      • Tips
    • Online Programming Tools
    • Other things to try:
  • Colours
  • School Info To Share
    • Course Selection/Careers
  • Programmer
  • Women in Technology
  • Popup Boxes
  • Vex
  • C++ Assignments
    • C++ - Temp Conversion
  • Home
  • COVID / McKay Absent
  • Important Notices
  • Assignment Summary
  • Course Details
    • Curriculum Connection
      • Big Ideas
      • Curriculum Competencies
      • Content
      • ADST Connection
    • Course Outline
    • Classroom Expectations
    • Evaluation and Assessment
    • ICTX Site
  • Student Sites
    • 2022 / 2023 Semester 1
    • Showcase
      • Scratch Etch - A - Sketch
  • Theory Assignments
    • Viruses
    • Career Exploration
    • Tynker
    • Intro Activities
      • Name Tag
      • Intro - Portfolio SetUp
      • Tynker Intro
      • Black History Connection
      • Intro - Avatar Assignment
      • Intro - Programming Is Everywhere!
    • Programming Languages
      • Hello World
      • History of Programming
    • Famous Programmers
    • Communication Codes
    • Binary Code
    • Digital Pivacy
  • Pixel Pad Project
  • C++
    • Getting Started
    • Practice 1
    • Arrays
    • For Loops C++
    • Random Numbers
  • Intro To Python
  • Web Development Unit
    • Web Programming - Intro
    • Getting Set Up
    • Sample CodeSandBox
    • Beginners - Web Programming
    • Intermediate Web Programming
  • JavaScript
    • Intro to JavaScript
    • First Programs
    • Next Steps
  • Vex VR
  • Final Project(s) Ideas
  • Game Engine Exploration
    • Getting Started
    • Godot
    • Unity
    • Game Engines
  • Hand In 2020 - Q2
  • Introduction to Programming
    • Computer Science is Changing Everything
    • What is Coding? Programming?
    • Intro - Why Learn to Program
    • Activities
      • Code Master
      • Lego Block Activity
      • Cup Stacking
      • Dice Race Activity
    • Thinking Like A Computer
      • Part 1: Algorithms / Pseudocode
      • Part 2: Structures
      • Part 3: Flowcharts
  • Scratch
    • Intro - Part 1
    • Intro - Part 2 - Sprites
    • Building Blocks - Basic
    • Sprites - Changing Appearances
    • Pen Tool and Key Press
      • Coordinate System
      • Pen Tool Intro
      • Scratch Function
      • Etch a Sketch
    • Car Racing
    • Variables
      • Variables / Broadcasting
      • Variable Assignment
      • Simple programs
    • Future Scratch
      • Scratch Examples
        • Introduction to Music
      • Game Assignment
        • Overview
        • Game Ideas
        • Game Tutorials
    • Scratch Help
  • Swift Programming
    • Swift Part 1
    • Intro Assignments
    • Swift Stuff
  • Python
    • Getting Started New
    • Posting Replit Assignments
    • For Loops
    • Functions (Intro)
    • ASS: Turtle Drawing
    • Turtle - Interactivity
    • ASS Keyboard Control - Turtle
    • ASS - Turtle - Dragging
    • ASS - Spiral Challenge
    • Basic Input / Output
    • ASS - Madlib Game
    • Basic Operations
    • Random Numbers
    • Resources
    • Check these tutorials out
    • Lists
    • Other Python Commands
  • Alternatives
    • LEGO EV3
      • Basic Build Instructions
      • Additional Models
      • Visual Assists
      • Resources:
      • Activities / Challenges
      • Tips
    • Online Programming Tools
    • Other things to try:
  • Colours
  • School Info To Share
    • Course Selection/Careers
  • Programmer
  • Women in Technology
  • Popup Boxes
  • Vex
  • C++ Assignments
    • C++ - Temp Conversion

Basic Operations

Calculator Assignment:
  • Create a new file and write the code that will do the following:
    • Ask the user to enter two integer numbers (Use while loops to ensure that they are between 1 and 500 or some other range)
    • Have the computer calculate and display the following:
      • Addition
      • Subtraction (2 equations)
      • Multiplication
      • Division
        • Regular Division - float answer (2 equations)
        • Integer and Modulus (remainder) division - Integer answers (2 equations) - (Hint: use x%y) ... type casting may be needed
      • Square each number
        • use x**y such as x**2
        • use pow(x, 2)
      • Cube each number
        • use x**y such as x**3
        • use pow(x, 3)
 
  • Consider ways to complicate this program. Here are some possibilities:
    • Questions that involve BEDMAS / Order of Operations
      • take a number, multiply by three and then add four
      • take a number, add four and then multiply by three.
    • Enter any base and exponent
    • Other operations: square root, cube root, trigonometric functions, factorial, etc._
    • Compare the numbers and display whether it is true or false
    • Mathematical equations (area, perimeter, volume, etc)
    • Try making a calculator.
      • ​Ask for two numbers and then provide a menu that allows the user to decide which of the operations they want to perform.
      • Could also provide an "all" option
      • What about if they want to do another calculation. Is it with the same two numbers or with different numbers.

While loops

A WHILE loop is a way of repeating a section of code. We often use it to control allowable input.
Method 1: using True
- the problem here is what is "true"

Method 2: Using condition statements
while True:
      num1 = int(input("Enter a number > 10: "))
      if (num1 <= 10):
            print ("Please follow instructions.")
      else:
            ​break
​num1 = int(input("Enter a number > 10: "))

​# Error Loop
while (num1 <= 10):
       print ("Please follow instructions.")
       ​num1 = int(input("Enter a number > 10: "))

Python Arithmetic Operations

Python Assignment Operators

Arithmetic operators are used with numeric values to perform common mathematical operations:
Picture
Assignment operators are used to assign values to variables:
Picture

​Python Comparison Operators

Comparison operators are used to compare two values:
Picture

Python Logical Operators

Logical operators are used to combine conditional statements:
Picture
Note:
  • Instead of "or" you can use "|" ... the line above the \ on the keyboard
    • (x<5) or (x>10)   is the same as   (x<5) | (x>10)
    • other languages use "||" .... (x<5) | | (x>10)
  • ​Instead of "and" you can use "&" ... above the 7 on the keyboard
    • (x<50) and (x>10)   is the same as   (x<50) & (x>10)
    • other languages use "||" .... (x<50) && (x>10)
  • Many languages use the "!" to replace "not"
Powered by Create your own unique website with customizable templates.
  • Home
  • COVID / McKay Absent
  • Important Notices
  • Assignment Summary
  • Course Details
    • Curriculum Connection
      • Big Ideas
      • Curriculum Competencies
      • Content
      • ADST Connection
    • Course Outline
    • Classroom Expectations
    • Evaluation and Assessment
    • ICTX Site
  • Student Sites
    • 2022 / 2023 Semester 1
    • Showcase
      • Scratch Etch - A - Sketch
  • Theory Assignments
    • Viruses
    • Career Exploration
    • Tynker
    • Intro Activities
      • Name Tag
      • Intro - Portfolio SetUp
      • Tynker Intro
      • Black History Connection
      • Intro - Avatar Assignment
      • Intro - Programming Is Everywhere!
    • Programming Languages
      • Hello World
      • History of Programming
    • Famous Programmers
    • Communication Codes
    • Binary Code
    • Digital Pivacy
  • Pixel Pad Project
  • C++
    • Getting Started
    • Practice 1
    • Arrays
    • For Loops C++
    • Random Numbers
  • Intro To Python
  • Web Development Unit
    • Web Programming - Intro
    • Getting Set Up
    • Sample CodeSandBox
    • Beginners - Web Programming
    • Intermediate Web Programming
  • JavaScript
    • Intro to JavaScript
    • First Programs
    • Next Steps
  • Vex VR
  • Final Project(s) Ideas
  • Game Engine Exploration
    • Getting Started
    • Godot
    • Unity
    • Game Engines
  • Hand In 2020 - Q2
  • Introduction to Programming
    • Computer Science is Changing Everything
    • What is Coding? Programming?
    • Intro - Why Learn to Program
    • Activities
      • Code Master
      • Lego Block Activity
      • Cup Stacking
      • Dice Race Activity
    • Thinking Like A Computer
      • Part 1: Algorithms / Pseudocode
      • Part 2: Structures
      • Part 3: Flowcharts
  • Scratch
    • Intro - Part 1
    • Intro - Part 2 - Sprites
    • Building Blocks - Basic
    • Sprites - Changing Appearances
    • Pen Tool and Key Press
      • Coordinate System
      • Pen Tool Intro
      • Scratch Function
      • Etch a Sketch
    • Car Racing
    • Variables
      • Variables / Broadcasting
      • Variable Assignment
      • Simple programs
    • Future Scratch
      • Scratch Examples
        • Introduction to Music
      • Game Assignment
        • Overview
        • Game Ideas
        • Game Tutorials
    • Scratch Help
  • Swift Programming
    • Swift Part 1
    • Intro Assignments
    • Swift Stuff
  • Python
    • Getting Started New
    • Posting Replit Assignments
    • For Loops
    • Functions (Intro)
    • ASS: Turtle Drawing
    • Turtle - Interactivity
    • ASS Keyboard Control - Turtle
    • ASS - Turtle - Dragging
    • ASS - Spiral Challenge
    • Basic Input / Output
    • ASS - Madlib Game
    • Basic Operations
    • Random Numbers
    • Resources
    • Check these tutorials out
    • Lists
    • Other Python Commands
  • Alternatives
    • LEGO EV3
      • Basic Build Instructions
      • Additional Models
      • Visual Assists
      • Resources:
      • Activities / Challenges
      • Tips
    • Online Programming Tools
    • Other things to try:
  • Colours
  • School Info To Share
    • Course Selection/Careers
  • Programmer
  • Women in Technology
  • Popup Boxes
  • Vex
  • C++ Assignments
    • C++ - Temp Conversion