Data types
Python Next Steps
Worksheet 1: Data types
Complete the following table:
Data Type Description Example
Integer A whole number 4
Float Number with a decimal place 3.14
string A piece of text “Elephant”
Use this pseudocode algorithm to create a working Python program to split a
restaurant bill
Print "Welcome to the meal price splitter"
value ß Input "How many people need to pay? "
people ß int(value)
value ß Input "How much was the bill? "
bill ß float(value)
priceEach ß str(bill/people)
Print "Each person should pay " + priceEach
Print ("Welcome to the meal price splitter")
value=Input ("How many people need to pay? ")
people = int(value)
value = Input ("How much was the bill? ")
bill = float(value)
priceEach = str(bill/people)
Print ("Each person should pay " + priceEach)
This program doesn’t work correctly. Use your knowledge of casting and data
types to try and fix it.
age = input("How old are you in years? ")
months = age*12
days = age*365
1
Data types
Python Next Steps
print("You are around " + months + " months old.")
print("You are around " + days + " days old.")
age = Int(input("How old are you in years? "))
months = age * 12
days = age * 365
print("You are around " + str(months) + " months old.")
print("You are around " + days + " days old.")