Importance of Using Correct Data Types in Python Programming

Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
Practice these key term spellings!
1.
integer
2.
string
3.
float
4.
calculation
5.
Python
6.
 arithmetic
Spellings-
using your book… Write down
1.
What does a the term  variable
mean?
2.
What does it do in coding?
Programming in Python
Lesson 3- 
Numbers and Arithmetic
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
Silver - 
Understand
how to use
assignment
statements correctly
Gold - 
Perform
arithmetic using the
BIDMAS rule
Platinum - 
Write a
program involving
input, calculation and
output
Understanding how computers are used and
should work is extremely vital. 
Python is a
powerful but easy-to-use high-level
programming language. It is important that
you understand the process of developing
programs, the importance of writing correct
syntax, being able to formulate algorithms for
simple programs and debugging their
programs. Programming is used to create all
the games, social media and apps you use in
your daily life.
Why are you learning about this?
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
Keystone
Word!
Write a definition for the term
arithmetic
. What does it mean?
Where might you have herd it
before?  mean?
 
Arithmetic
Arithmetic
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
What does this program do?
#Animal
animal = 
input
(
"Enter the name of an animal: "
)
description = 
input
(
"How would you describe a "
+ animal + 
"? "
)
print
 (
"A"
,animal,
"is"
,description)
print
(
"You will find it under"
,animal[0],
"in the
dictionary"
)
Look at the code below and describe on a sticky note
what each line does
Include 2 keywords-
Integer     String     Float  Calculation    Python
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
Silver - 
Understand
how to use
assignment
statements correctly
Gold - 
Perform
arithmetic using the
BIDMAS rule
Platinum - 
Write a
program involving
input, calculation and
output
What are the different Data
Types?
String
 holds alphanumeric data as text
Integer
 holds whole numbers
Float
 holds numbers with a decimal point
Boolean
 holds either ‘
True
’ or ‘
False
Python automatically assigns a data type to a
variable
You can override this to manually define or
change the data type using:
 
str
()
  
str
(animal_name)
 
int
()
  
int
(goals_scored)
 
float
()
  
float
(share_price)
This is called 
Casting
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
Choosing Data Types
Download ‘Worksheet 2’ from the
platform and complete the table with
the data types and codes that apply to
each data entry.
Create a variable called 
mynumber
 and
allow the user to input a value to assign
to it
mynumber = 
input
(
"Enter a number"
)
print
 (mynumber + mynumber)
 
What do you think happens?
Try it!
Convert the data type: 
mynumber =
int
(mynumber)
Where would you put this line?
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
The Importance of Data
Types
Create a program to calculate how many
hours per week you sleep
Try this code and find the problem!
 
hourspernight = 
input
(
"How many
hours per night do you sleep? "
)
hoursperweek = hourspernight * 7
print
 (
"You
sleep"
,hoursperweek,
"hours per
week"
)
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
Sleep Calculator
Then add to the problem to find the total
number of hours spent sleeping in a month
Assume an average of 4.35 weeks per month
Hint-
Ask for
‘Worksheet
3’ to help!
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
Sleep Calculator
Now find the equivalent number of days
per month you sleep for!
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
Rounding
hourspermonth = 228.37499999999997
round
(hourspermonth) = 228
round
(hourspermonth,2) = 228.37
 
hourspernight = 
input
(
"How many hours per night do
you sleep? "
)
hoursperweek = 
int
(hourspernight) * 7
hourspermonth = round(hourspermonth)
print
 (
"You sleep"
,hoursperweek,
"hours per week"
)
 
hourspermonth = 
float
(hoursperweek) * 4.35
print
 (
“\nYou sleep"
,hourspermonth,
"hours per month"
)
Finish your program!
Display a title for your program when it first runs
Calculate the number of days per year spent asleep
Include the user’s name to make it more user friendly
 
Learning Objectives-
Understand the
importance of using
correct data types:
string, integer or
float
 
Silver - 
Understand
how to use
assignment
statements correctly
 
Gold - 
Perform
arithmetic using the
BIDMAS rule
 
Platinum - 
Write a
program involving
input, calculation and
output
Calculating Mobile Phone Costs
Create code for an app to do the following:
Accept the user’s name and mobile phone
network
Ask for the number of minutes they have used
this month and multiply that by 0.10 per
minute
Ask for the number of texts that they have sent
in a month and multiply that by 0.05 pence per
text
Display a total bill amount for the month
Displays a new total including VAT of 20%
1.
What 
new 
knowledge or skill have you
learnt this lesson?
 
2.
What knowledge or skills did you use
today that you used in a previous
lesson?
 
3.
How does the knowledge or skill link to
another subject you study?
 
5 minutes
5 minutes
Learning Objectives-
Understand the importance
of using correct data types:
string, integer or float
 
Silver - 
Understand how to
use assignment statements
correctly
 
Gold - 
Perform arithmetic
using the BIDMAS rule
 
Platinum - 
Write a program
involving input, calculation
and output
Slide Note
Embed
Share

Understanding the significance of utilizing the appropriate data types such as string, integer, or float in Python programming is essential for writing efficient code. This content emphasizes the basics of data types, variables, assignment statements, and arithmetic operations in Python. It also highlights the importance of learning programming for developing various applications and the career prospects in computer systems engineering.


Uploaded on Jul 11, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Learning Objectives- Understand the importance of using correct data types: string, integer or float Spellings- Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly using your book Write down 1. What does a the term variable mean? 2. What does it do in coding? Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Practice these key term spellings! 1. integer 2. string 3. float 4. calculation 5. Python 6. arithmetic Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a

  2. Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming Programming in Python Most Be able to write a program in Python Some Create a program that asks the user questions and then prints out information Lesson 3- Numbers and Arithmetic

  3. Learning Objectives- Understand the importance of using correct data types: string, integer or float Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly Why are you learning about this? Understanding how computers are used and should work is extremely vital. Python is a powerful but easy-to-use high-level programming language. It is important that you understand the process of developing programs, the importance of writing correct syntax, being able to formulate algorithms for simple programs and debugging their programs. Programming is used to create all the games, social media and apps you use in your daily life. Computer systems engineers are responsible for identifying solutions to complex applications problems, systems administration issues or network concerns. They work closely with clients or internal stakeholders to understand system needs and collaborate with developers to determine appropriate solutions. This is another programming career that is ideal for business-savvy professionals. Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Computer systems engineer 2017 median salary: 88,5102 Required education:Bachelor s degree2 Projected employment growth (2016-2026):9 percent (as fast as average)2 Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a

  4. Learning Objectives- Understand the importance of using correct data types: string, integer or float Keystone Word! Write a definition for the term arithmetic. What does it mean? Where might you have herd it before? mean? Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly connect 3 Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a Arithmetic

  5. Arithmetic Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming calculation. "arithmetic had never been her strong point" ADJECTIVE- relating to arithmetic. "arithmetic calculations" Word NOUN- the branch of mathematics dealing with the properties and manipulation of numbers. "the laws of arithmetic - The use of numbers in counting and Image Most Be able to write a program in Python Some Create a program that asks the user questions and then prints out information The order of arithmetic operations matters. Brackets , Indices, Division and Multiplication, Addition and Subtraction Examples What it is not Just maths equations All apply to integers BIDMAS

  6. Learning Objectives- Understand the importance of using correct data types: string, integer or float What does this program do? Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly 5 Look at the code below and describe on a sticky note what each line does Silver - Understand #Animal animal = input("Enter the name of an animal: ") description = input("How would you describe a " + animal + "? ") print ("A",animal,"is",description) print("You will find it under",animal[0],"in the dictionary") Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a Include 2 keywords- Integer String Float Calculation Python

  7. Learning Objectives- Understand the importance of using correct data types: string, integer or float What are the different Data Types? String holds alphanumeric data as text Integer holds whole numbers Float holds numbers with a decimal point Booleanholds either True or False Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Python automatically assigns a data type to a variable You can override this to manually define or change the data type using: str() str(animal_name) int() int(goals_scored) float() This is called Casting Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a float(share_price)

  8. Learning Objectives- Understand the importance of using correct data types: string, integer or float Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly Choosing Data Types 5 Examp le Data Type Data Code Silver - Understand int(age ) Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Age 14 Integer Shoe Size 6.5 Float Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Price Postcode 14.99 Platinum - Write a Height Quantity in Stock Download Worksheet 2 from the platform and complete the table with the data types and codes that apply to each data entry. Telephone Number

  9. Learning Objectives- Understand the importance of using correct data types: string, integer or float Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly The Importance of Data Types 5 Create a variable called mynumber and allow the user to input a value to assign to it Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule mynumber = input("Enter a number") print (mynumber + mynumber) Some Create a program that asks the user questions and then prints out information program involving input, calculation and output What do you think happens? Try it! Convert the data type: mynumber = int(mynumber) Where would you put this line? Platinum - Write a

  10. Sleep Calculator 10 Learning Objectives- Understand the importance of using correct data types: string, integer or float Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly Create a program to calculate how many hours per week you sleep Try this code and find the problem! Hint- Ask for Worksheet 3 to help! Silver - Understand hourspernight = input("How many hours per night do you sleep? ") hoursperweek = hourspernight * 7 print ("You sleep",hoursperweek,"hours per week") Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a Then add to the problem to find the total number of hours spent sleeping in a month Assume an average of 4.35 weeks per month

  11. Sleep Calculator 5 Learning Objectives- Understand the importance of using correct data types: string, integer or float Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly Now find the equivalent number of days per month you sleep for! Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a

  12. Rounding 5 Learning Objectives- Understand the importance of using correct data types: string, integer or float Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly hourspermonth = 228.37499999999997 round(hourspermonth) = 228 round(hourspermonth,2) = 228.37 Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule hourspernight = input("How many hours per night do you sleep? ") hoursperweek = int(hourspernight) * 7 hourspermonth = round(hourspermonth) print ("You sleep",hoursperweek,"hours per week") Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a hourspermonth = float(hoursperweek) * 4.35 print ( \nYou sleep",hourspermonth,"hours per month") Finish your program! Display a title for your program when it first runs Calculate the number of days per year spent asleep Include the user s name to make it more user friendly

  13. Learning Objectives- Understand the importance of using correct data types: string, integer or float Learning Objectives Be able to write a program in Python Learning Outcomes All To know what main data types are and what a variable is in programming how to use assignment statements correctly Calculating Mobile Phone Costs Create code for an app to do the following: Accept the user s name and mobile phone network Ask for the number of minutes they have used this month and multiply that by 0.10 per minute Ask for the number of texts that they have sent in a month and multiply that by 0.05 pence per text Display a total bill amount for the month Displays a new total including VAT of 20% Silver - Understand Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule Some Create a program that asks the user questions and then prints out information program involving input, calculation and output Platinum - Write a

  14. Learning Objectives- Learning Objectives Be able to write a program in Python 2.7 of using correct data types: string, integer or float Understand the importance 5 minutes Learning Outcomes All To know what main data types are and what a variable is in programming correctly 1.What new knowledge or skill have you learnt this lesson? Silver - Understand how to use assignment statements Most Be able to write a program in Python Gold - Perform arithmetic using the BIDMAS rule 2.What knowledge or skills did you use today that you used in a previous lesson? Some Create a program that asks the user questions and then prints out information and output Platinum - Write a program involving input, calculation 3.How does the knowledge or skill link to another subject you study?

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#