SlideShare a Scribd company logo
Resources created by Andy Colley (@MrAColley)
Learning Goals/Objectives
Be able to read, comprehend, trace, adapt and create
Python code that:
• Performs simple maths (addition, subtraction, multiplication,
division and integer division) using fixed numbers
• Performs simple maths using numbers stored in variables
• Converts strings to integers
• Gets number input and uses it in calculations
Resources created by Andy Colley (@MrAColley)
Maths - Operators
2 + 2
Resources created by Andy Colley (@MrAColley)
Maths - Operators
+ addition
- subtraction
* multiplication
/ division (with decimal)
// division (integer result)
Resources created by Andy Colley (@MrAColley)
Input
Data is collected and sent to the
computer
Process
Carrying out instructions.
Output
Presenting the results of
processing back to the user
Storage
Saving data that is not in use.
Resources created by Andy Colley (@MrAColley)
Programming – Operators - Predict & Run
https://repl.it/@MrAColley/21-Maths-part-1
Resources created by Andy Colley (@MrAColley)
Maths With Variables
num1 = 5
num2 = 10
result = num1 + num2
print(result)
Assign numbers
to your variables.
Perform the calculation.
Assign the result to a NEW
VARIABLE.
Don’t forget to
output the result
Resources created by Andy Colley (@MrAColley)
Variables - vary - changing data
favColour
“blue”
Resources created by Andy Colley (@MrAColley)
Programming – Variable Maths – Modify & Make
score = 0
print(score)
score = 10
print(score)
Resources created by Andy Colley (@MrAColley)
Changing Variables With Maths
score = 0
print(score)
score = 10
print(score)
score = 0
print(score)
score = score + 1
print(score)
score = 0
print(score)
score += 1
print(score)
lives -= 1
Resources created by Andy Colley (@MrAColley)
Programming – Input & Variables - Integers
Input works with strings. Strings are text.
Computers can’t do maths/logic with text. They have to use
numbers.
Whole numbers are called integers (ints for short).
We have to write code to convert our string input to an int
before we can do maths with it.
Resources created by Andy Colley (@MrAColley)
Programming – Input & Variables - Integers
num1 = int(input("Enter a number"))
Tells the computer
to convert to an
integer.
Tells the computer
to convert to an
integer.
BRACKETS!
Because syntax!
Resources created by Andy Colley (@MrAColley)
Programming – Input & Variables - Integers
print(str(num1)
Tells the computer
to convert an
integer variable to a
string
Resources created by Andy Colley (@MrAColley)
Task 5 - Homework Challenge - Area
Calc
Create a program that allows the user to enter 2 numbers representing
the width and length of a rectangle. The program calculates and
displays the area of the rectangle.
Example solution -
https://repl.it/@MrAColley/25ChallengeExampleSolution
Resources created by Andy Colley (@MrAColley)
Extra Credit Challenges
Perimeter Calc
Create a program that allows the user to enter 2 numbers representing the width and
length of a rectangle. The program calculates and displays the perimeter of the
rectangle.
Restaurant Tip Calculator
Create a program that allows the user to enter the price of a meal at a restaurant. The
program calculates the amount of the tip to be paid at 20%. The tip and total price are
then displayed separately.
Volume and Surface Calc
Create a program that allows the user to enter 3 numbers representing the height, width
and length of a cuboid. The program calculates and displays the volume and total
surface area of the cuboid.

More Related Content

PDF
introduction to python programming course 2
FarhadMohammadRezaHa
 
PPT
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
KhanhPhan575445
 
PPTX
Brixton Library Technology Initiative Week0 Recap
Basil Bibi
 
PPTX
Revision-of-thehki-basics-of-python.pptx
PraveenaFppt
 
PPTX
An Introduction To Python - Python Midterm Review
Blue Elephant Consulting
 
PPTX
03 Variables - Chang.pptx
Dileep804402
 
PDF
Python-Cheat-Sheet.pdf
Mohd Aves Malik
 
PDF
Introduction to Python Programming | InsideAIML
VijaySharma802
 
introduction to python programming course 2
FarhadMohammadRezaHa
 
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
KhanhPhan575445
 
Brixton Library Technology Initiative Week0 Recap
Basil Bibi
 
Revision-of-thehki-basics-of-python.pptx
PraveenaFppt
 
An Introduction To Python - Python Midterm Review
Blue Elephant Consulting
 
03 Variables - Chang.pptx
Dileep804402
 
Python-Cheat-Sheet.pdf
Mohd Aves Malik
 
Introduction to Python Programming | InsideAIML
VijaySharma802
 

Similar to Creating Python Variables using Replit software (20)

PDF
Some hours of python
Things Lab
 
PDF
Python Objects
MuhammadBakri13
 
DOCX
Python Math Concepts Book
Rohan Karunaratne
 
PPTX
Introduction to Python Programming
VijaySharma802
 
PPTX
An Introduction To Python - Variables, Math
Blue Elephant Consulting
 
PPTX
Revision-of-the-basics-of-python. concepts
mahalakshmi902878
 
PDF
Introduction to python programming
Rakotoarison Louis Frederick
 
PDF
"Solutions for Exercises" in Starting Out with Python 4th Global Edition by T...
solution9159
 
PPT
python fundamental for beginner course .ppt
samuelmegerssa1
 
PPTX
Presentation1 (1).pptx
BodapatiNagaeswari1
 
PPTX
Programming python quick intro for schools
Dan Bowen
 
PPT
Python programming unit 2 -Slides-3.ppt
geethar79
 
PDF
The python fundamental introduction part 1
DeoDuaNaoHet
 
PDF
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
PPTX
CODING WITH PYTHON PART 1
Buxoo Abdullah
 
PDF
Class 2: Welcome part 2
Marc Gouw
 
PPTX
Review old Pygame made using python programming.pptx
ithepacer
 
PPTX
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
PDF
Python Training in Chandigarh(Mohali)
ExcellenceAcadmy
 
Some hours of python
Things Lab
 
Python Objects
MuhammadBakri13
 
Python Math Concepts Book
Rohan Karunaratne
 
Introduction to Python Programming
VijaySharma802
 
An Introduction To Python - Variables, Math
Blue Elephant Consulting
 
Revision-of-the-basics-of-python. concepts
mahalakshmi902878
 
Introduction to python programming
Rakotoarison Louis Frederick
 
"Solutions for Exercises" in Starting Out with Python 4th Global Edition by T...
solution9159
 
python fundamental for beginner course .ppt
samuelmegerssa1
 
Presentation1 (1).pptx
BodapatiNagaeswari1
 
Programming python quick intro for schools
Dan Bowen
 
Python programming unit 2 -Slides-3.ppt
geethar79
 
The python fundamental introduction part 1
DeoDuaNaoHet
 
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
CODING WITH PYTHON PART 1
Buxoo Abdullah
 
Class 2: Welcome part 2
Marc Gouw
 
Review old Pygame made using python programming.pptx
ithepacer
 
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
Python Training in Chandigarh(Mohali)
ExcellenceAcadmy
 
Ad

More from afsheenfaiq2 (20)

PPTX
Number Guessing Game using Artiifcal intelligence
afsheenfaiq2
 
PPTX
Sentiment Analyzer using Artificial Intelligence
afsheenfaiq2
 
PPTX
object oriented porgramming using Java programming
afsheenfaiq2
 
PPTX
Object oriented programming design and implementation
afsheenfaiq2
 
PPTX
Anime Display for Weekly Passion Hour Club
afsheenfaiq2
 
PPT
Introduction to Declaring Functions in Python
afsheenfaiq2
 
PDF
Sample Exam Questions on Python for revision
afsheenfaiq2
 
PPTX
GR 12 IOT Week 2.pptx
afsheenfaiq2
 
PPTX
IOT Week 20.pptx
afsheenfaiq2
 
PPTX
Lesson 17 - Pen Shade and Stamp.pptx
afsheenfaiq2
 
PPTX
AP CS PD 1.3 Week 4.pptx
afsheenfaiq2
 
PPTX
2D Polygons using Pen tools- Week 21.pptx
afsheenfaiq2
 
PPTX
Chapter 11 Strings.pptx
afsheenfaiq2
 
PPTX
Lesson 10_Size Block.pptx
afsheenfaiq2
 
PPT
CH05.ppt
afsheenfaiq2
 
PPT
Chapter05.ppt
afsheenfaiq2
 
PPTX
Gr 12 - Buzzer Project on Sound Production (W10).pptx
afsheenfaiq2
 
PPT
Network Topologies
afsheenfaiq2
 
PPTX
IoT-Week1-Day1-Lecture.pptx
afsheenfaiq2
 
PPTX
IoT-Week1-Day1-Lab.pptx
afsheenfaiq2
 
Number Guessing Game using Artiifcal intelligence
afsheenfaiq2
 
Sentiment Analyzer using Artificial Intelligence
afsheenfaiq2
 
object oriented porgramming using Java programming
afsheenfaiq2
 
Object oriented programming design and implementation
afsheenfaiq2
 
Anime Display for Weekly Passion Hour Club
afsheenfaiq2
 
Introduction to Declaring Functions in Python
afsheenfaiq2
 
Sample Exam Questions on Python for revision
afsheenfaiq2
 
GR 12 IOT Week 2.pptx
afsheenfaiq2
 
IOT Week 20.pptx
afsheenfaiq2
 
Lesson 17 - Pen Shade and Stamp.pptx
afsheenfaiq2
 
AP CS PD 1.3 Week 4.pptx
afsheenfaiq2
 
2D Polygons using Pen tools- Week 21.pptx
afsheenfaiq2
 
Chapter 11 Strings.pptx
afsheenfaiq2
 
Lesson 10_Size Block.pptx
afsheenfaiq2
 
CH05.ppt
afsheenfaiq2
 
Chapter05.ppt
afsheenfaiq2
 
Gr 12 - Buzzer Project on Sound Production (W10).pptx
afsheenfaiq2
 
Network Topologies
afsheenfaiq2
 
IoT-Week1-Day1-Lecture.pptx
afsheenfaiq2
 
IoT-Week1-Day1-Lab.pptx
afsheenfaiq2
 
Ad

Recently uploaded (20)

PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PDF
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Landforms and landscapes data surprise preview
jpinnuck
 
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 

Creating Python Variables using Replit software

  • 1. Resources created by Andy Colley (@MrAColley) Learning Goals/Objectives Be able to read, comprehend, trace, adapt and create Python code that: • Performs simple maths (addition, subtraction, multiplication, division and integer division) using fixed numbers • Performs simple maths using numbers stored in variables • Converts strings to integers • Gets number input and uses it in calculations
  • 2. Resources created by Andy Colley (@MrAColley) Maths - Operators 2 + 2
  • 3. Resources created by Andy Colley (@MrAColley) Maths - Operators + addition - subtraction * multiplication / division (with decimal) // division (integer result)
  • 4. Resources created by Andy Colley (@MrAColley) Input Data is collected and sent to the computer Process Carrying out instructions. Output Presenting the results of processing back to the user Storage Saving data that is not in use.
  • 5. Resources created by Andy Colley (@MrAColley) Programming – Operators - Predict & Run https://repl.it/@MrAColley/21-Maths-part-1
  • 6. Resources created by Andy Colley (@MrAColley) Maths With Variables num1 = 5 num2 = 10 result = num1 + num2 print(result) Assign numbers to your variables. Perform the calculation. Assign the result to a NEW VARIABLE. Don’t forget to output the result
  • 7. Resources created by Andy Colley (@MrAColley) Variables - vary - changing data favColour “blue”
  • 8. Resources created by Andy Colley (@MrAColley) Programming – Variable Maths – Modify & Make score = 0 print(score) score = 10 print(score)
  • 9. Resources created by Andy Colley (@MrAColley) Changing Variables With Maths score = 0 print(score) score = 10 print(score) score = 0 print(score) score = score + 1 print(score) score = 0 print(score) score += 1 print(score) lives -= 1
  • 10. Resources created by Andy Colley (@MrAColley) Programming – Input & Variables - Integers Input works with strings. Strings are text. Computers can’t do maths/logic with text. They have to use numbers. Whole numbers are called integers (ints for short). We have to write code to convert our string input to an int before we can do maths with it.
  • 11. Resources created by Andy Colley (@MrAColley) Programming – Input & Variables - Integers num1 = int(input("Enter a number")) Tells the computer to convert to an integer. Tells the computer to convert to an integer. BRACKETS! Because syntax!
  • 12. Resources created by Andy Colley (@MrAColley) Programming – Input & Variables - Integers print(str(num1) Tells the computer to convert an integer variable to a string
  • 13. Resources created by Andy Colley (@MrAColley) Task 5 - Homework Challenge - Area Calc Create a program that allows the user to enter 2 numbers representing the width and length of a rectangle. The program calculates and displays the area of the rectangle. Example solution - https://repl.it/@MrAColley/25ChallengeExampleSolution
  • 14. Resources created by Andy Colley (@MrAColley) Extra Credit Challenges Perimeter Calc Create a program that allows the user to enter 2 numbers representing the width and length of a rectangle. The program calculates and displays the perimeter of the rectangle. Restaurant Tip Calculator Create a program that allows the user to enter the price of a meal at a restaurant. The program calculates the amount of the tip to be paid at 20%. The tip and total price are then displayed separately. Volume and Surface Calc Create a program that allows the user to enter 3 numbers representing the height, width and length of a cuboid. The program calculates and displays the volume and total surface area of the cuboid.