Assignment (1)
Assignment (1)
CSC1010H Assignment 2
Python Input/Output, String and Numbers
Introduction
Learning outcomes
Skills
• Construct python programs composed of sequences of simple statements and involving the
input, output, and manipulation of numeric and alphanumeric data.
Knowledge
• The form of variable identifiers, assignment statements, print statements.
• Python data types, operators and operator precedence:
o String: string slicing and concatenation, multiplication,
o Int and float: addition, subtraction, multiplication, division, integer division,
modulus.
• Expressions involving functions, string and arithmetic manipulation, and casting.
• Form of import statement, and functions in the math and random modules.
Write a program called ‘eugenejunior.py‘ that interacts with the user in a conversational
manner by asking questions and responding appropriately. The program should:
1. Ask the user for name, surname, and preferred title, responding with a greeting that
includes their title, first name initial and surname.
2. Ask the user for the course code of their current course and ask what the first three letters
stand for, responding with an expression of interest.
3. Ask the user for their weight in kilograms, responding with the equivalent in US pounds and
ounces.
4. Ask for the current date, expressed as dd/mm/yy, and for the user’s year of birth,
responding with the age they will be in the current year.
Continued
2
MAM1000
So, what does 'MAM' stand for?
Mathematics
Mathematics sounds interesting.
What weight are you in kilograms?
87.5
That's 192 lbs and 14 ounces in the US!
What's today's date (dd/mm/yy)?
12/04/24
And what year were you born?
1967
Okay, so you're 55 this year.
Nice talking to you, bye!
You may assume today’s date is always at least in the year 2000. There are 28.35 grammes in an
ounce.
RECOMMENDATION: Develop your program in stages. Start with a version that respond to a names
and title, then the course code queries, and so on.
Continued
3
3√3
𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴 = 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 2
2
Here is an example of program behaviour:
Enter the length of the side (cm):
12
The area of a hexagon of side 12 is 374.123.
Continued
4
Marking Guide
Question 1 Eugene Junior 25
Question 2 Credit card 25
Question 3 Hexagon area 25
Question 4 Initials 25
Total 100
End