SlideShare a Scribd company logo
1 of 14
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

Similar to Creating Python Variables using Replit software

Week 2 iLab TCO 2 — Given a simple problem, design a solutio.docx
Week 2 iLab TCO 2 — Given a simple problem, design a solutio.docxWeek 2 iLab TCO 2 — Given a simple problem, design a solutio.docx
Week 2 iLab TCO 2 — Given a simple problem, design a solutio.docxmelbruce90096
 
Pj01 1-computer and programming fundamentals
Pj01 1-computer and programming fundamentalsPj01 1-computer and programming fundamentals
Pj01 1-computer and programming fundamentalsSasidharaRaoMarrapu
 
Class[1][23ed may] [algorithms]
Class[1][23ed may] [algorithms]Class[1][23ed may] [algorithms]
Class[1][23ed may] [algorithms]Saajid Akram
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010Skills Matter
 
Small Basic Calculator Apps lesson
Small Basic Calculator Apps lessonSmall Basic Calculator Apps lesson
Small Basic Calculator Apps lessonEdujetage
 
if, while and for in Python
if, while and for in Pythonif, while and for in Python
if, while and for in PythonPranavSB
 
Design & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxDesign & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxJeevaMCSEKIOT
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxSajalKesharwani2
 
Report for DIGITAL CLOCK 12011042 Manoj.pdf
Report for DIGITAL  CLOCK 12011042 Manoj.pdfReport for DIGITAL  CLOCK 12011042 Manoj.pdf
Report for DIGITAL CLOCK 12011042 Manoj.pdfManojKumar533913
 
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 manjurkts
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17manjurkts
 
parellel computing
parellel computingparellel computing
parellel computingkatakdound
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfMMRF2
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)ExcellenceAcadmy
 

Similar to Creating Python Variables using Replit software (20)

Week 2 iLab TCO 2 — Given a simple problem, design a solutio.docx
Week 2 iLab TCO 2 — Given a simple problem, design a solutio.docxWeek 2 iLab TCO 2 — Given a simple problem, design a solutio.docx
Week 2 iLab TCO 2 — Given a simple problem, design a solutio.docx
 
Pj01 1-computer and programming fundamentals
Pj01 1-computer and programming fundamentalsPj01 1-computer and programming fundamentals
Pj01 1-computer and programming fundamentals
 
Class[1][23ed may] [algorithms]
Class[1][23ed may] [algorithms]Class[1][23ed may] [algorithms]
Class[1][23ed may] [algorithms]
 
chapter 1
chapter 1chapter 1
chapter 1
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010
 
Small Basic Calculator Apps lesson
Small Basic Calculator Apps lessonSmall Basic Calculator Apps lesson
Small Basic Calculator Apps lesson
 
C++
C++C++
C++
 
if, while and for in Python
if, while and for in Pythonif, while and for in Python
if, while and for in Python
 
Design & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxDesign & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptx
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptx
 
Report for DIGITAL CLOCK 12011042 Manoj.pdf
Report for DIGITAL  CLOCK 12011042 Manoj.pdfReport for DIGITAL  CLOCK 12011042 Manoj.pdf
Report for DIGITAL CLOCK 12011042 Manoj.pdf
 
Lecture1
Lecture1Lecture1
Lecture1
 
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
 
ELAVARASAN.pdf
ELAVARASAN.pdfELAVARASAN.pdf
ELAVARASAN.pdf
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
 
parellel computing
parellel computingparellel computing
parellel computing
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdf
 
CHAPTER 1
CHAPTER 1CHAPTER 1
CHAPTER 1
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)
 

More from afsheenfaiq2

Anime Display for Weekly Passion Hour Club
Anime Display for Weekly Passion Hour ClubAnime Display for Weekly Passion Hour Club
Anime Display for Weekly Passion Hour Clubafsheenfaiq2
 
Introduction to Declaring Functions in Python
Introduction to Declaring Functions in PythonIntroduction to Declaring Functions in Python
Introduction to Declaring Functions in Pythonafsheenfaiq2
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionafsheenfaiq2
 
GR 12 IOT Week 2.pptx
GR 12 IOT Week 2.pptxGR 12 IOT Week 2.pptx
GR 12 IOT Week 2.pptxafsheenfaiq2
 
Lesson 17 - Pen Shade and Stamp.pptx
Lesson 17 - Pen Shade and Stamp.pptxLesson 17 - Pen Shade and Stamp.pptx
Lesson 17 - Pen Shade and Stamp.pptxafsheenfaiq2
 
AP CS PD 1.3 Week 4.pptx
AP CS PD 1.3 Week 4.pptxAP CS PD 1.3 Week 4.pptx
AP CS PD 1.3 Week 4.pptxafsheenfaiq2
 
2D Polygons using Pen tools- Week 21.pptx
2D Polygons using Pen tools- Week 21.pptx2D Polygons using Pen tools- Week 21.pptx
2D Polygons using Pen tools- Week 21.pptxafsheenfaiq2
 
Chapter 11 Strings.pptx
Chapter 11 Strings.pptxChapter 11 Strings.pptx
Chapter 11 Strings.pptxafsheenfaiq2
 
Lesson 10_Size Block.pptx
Lesson 10_Size Block.pptxLesson 10_Size Block.pptx
Lesson 10_Size Block.pptxafsheenfaiq2
 
Gr 12 - Buzzer Project on Sound Production (W10).pptx
Gr 12 - Buzzer Project on Sound Production (W10).pptxGr 12 - Buzzer Project on Sound Production (W10).pptx
Gr 12 - Buzzer Project on Sound Production (W10).pptxafsheenfaiq2
 
Network Topologies
Network TopologiesNetwork Topologies
Network Topologiesafsheenfaiq2
 
IoT-Week1-Day1-Lecture.pptx
IoT-Week1-Day1-Lecture.pptxIoT-Week1-Day1-Lecture.pptx
IoT-Week1-Day1-Lecture.pptxafsheenfaiq2
 
IoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptxIoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptxafsheenfaiq2
 

More from afsheenfaiq2 (17)

Anime Display for Weekly Passion Hour Club
Anime Display for Weekly Passion Hour ClubAnime Display for Weekly Passion Hour Club
Anime Display for Weekly Passion Hour Club
 
Introduction to Declaring Functions in Python
Introduction to Declaring Functions in PythonIntroduction to Declaring Functions in Python
Introduction to Declaring Functions in Python
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revision
 
GR 12 IOT Week 2.pptx
GR 12 IOT Week 2.pptxGR 12 IOT Week 2.pptx
GR 12 IOT Week 2.pptx
 
IOT Week 20.pptx
IOT Week 20.pptxIOT Week 20.pptx
IOT Week 20.pptx
 
Lesson 17 - Pen Shade and Stamp.pptx
Lesson 17 - Pen Shade and Stamp.pptxLesson 17 - Pen Shade and Stamp.pptx
Lesson 17 - Pen Shade and Stamp.pptx
 
AP CS PD 1.3 Week 4.pptx
AP CS PD 1.3 Week 4.pptxAP CS PD 1.3 Week 4.pptx
AP CS PD 1.3 Week 4.pptx
 
2D Polygons using Pen tools- Week 21.pptx
2D Polygons using Pen tools- Week 21.pptx2D Polygons using Pen tools- Week 21.pptx
2D Polygons using Pen tools- Week 21.pptx
 
Chapter 11 Strings.pptx
Chapter 11 Strings.pptxChapter 11 Strings.pptx
Chapter 11 Strings.pptx
 
Lesson 10_Size Block.pptx
Lesson 10_Size Block.pptxLesson 10_Size Block.pptx
Lesson 10_Size Block.pptx
 
CH05.ppt
CH05.pptCH05.ppt
CH05.ppt
 
Chapter05.ppt
Chapter05.pptChapter05.ppt
Chapter05.ppt
 
Gr 12 - Buzzer Project on Sound Production (W10).pptx
Gr 12 - Buzzer Project on Sound Production (W10).pptxGr 12 - Buzzer Project on Sound Production (W10).pptx
Gr 12 - Buzzer Project on Sound Production (W10).pptx
 
Network Topologies
Network TopologiesNetwork Topologies
Network Topologies
 
IoT-Week1-Day1-Lecture.pptx
IoT-Week1-Day1-Lecture.pptxIoT-Week1-Day1-Lecture.pptx
IoT-Week1-Day1-Lecture.pptx
 
IoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptxIoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptx
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 

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.