Assignment 1 - Hello, Python!

Due: Thursday, September 18, 2025, at 3pm

You may work alone or with a partner, but you must type up your code yourself. You may also discuss the assignment at a high level with other students. You should list any student with whom you discussed the assignment, and the manner of discussion (high-level, partner, etc.) in top-level comments within your source code file.

Although you can get Python working on your own laptop, you are encouraged for this assignment to work on the computers in Olin 310 or in the lab space in Olin 308. Remember though that the computers wipe clean when you logout, but you can save files in your COURSES folder.

You should complete the welcome survey and then submit your assignment as an intro.py file on Gradescope.


Goals

The primary goal for this assignment is to get you up and running with Python. You will need to make sure you can write and execute Python programs to complete this assignment and test it; the actual code you write will be quite simple.


Parts of this assignment:


Comments and collaboration

# You should be equipped to complete this part after Lesson 1 (Monday Sep. 15).

For each assignment in this course, you are expected to provide top-level comments (lines that start with # at the top of the file) on any .py source code files with your name and a collaboration statement. For this assignment, your program should be named intro.py.

Here is an example of how you can start your file:

# File: intro.py
# Author: Lulu Amert
# Purpose: Assignment #1 - Hello, Python!
#
# Collaboration statement:
# - Milo: partner (worked on code together)
# - Hobbes: discussed issues with spaces in print() output
# - Mal (Course Staff): how to find print() in Python documentation

Here is another example:

# File: intro.py
# Author: Hobbes Amert
# Purpose: Assignment #1 - Hello, Python!
#
# Collaboration statement: I worked alone.

Note: You should not be using search engines or generative AI when completing your assignments (this includes the Copilot extension in VS Code!). You can, however, search within the official Python documentation: https://docs.python.org/3/.


Part 0: Hello, you!

# You should be equipped to complete this part after Lesson 1 (Monday Sep. 15).

As you get started on your assignment, fill out this welcome survey. It should take just a few minutes!


Part 1: Hello, user!

# You should be equipped to complete this part after Lesson 1 (Monday Sep. 15).

For this part, you should write a program that asks the user for their first and last name, and then greets them by name. Your program should also ask their age and give them an estimate on the number of days old they are (assuming exactly 365 days per year). This code should live in a file named intro.py.

Here is an example interaction that your program should be able to mimic:

Hello there!
What is your first name? Lulu
What is your last name? Amert
How old are you, in years? 13

Have a great day, Lulu Amert!
You are approximately 4745 days old.

Here is another example:

Hello there!
What is your first name? Cheddar
What is your last name? Amert
How old are you, in years? 1

Have a great day, Cheddar Amert!
You are approximately 365 days old.

Part 2: Early mornings

# You should be equipped to complete this part after Lesson 1 (Monday Sep. 15).

Python has the ability to group data, for example into pairs (called tuples):

tup1 = ("cat", 3)
tup2 = ("mouse", 5)
tup3 = ("giraffe", 7)

You can even make one of these pairs using variables:

animal = "elephant"
length = 8
tup4 = (animal, length)

There is also a handy built-in function min that can give us the “smallest” of two or more inputs. This behaves logically for numbers, and for strings it compares “alphabetically” (it’s more complicated, but we’ll explore that later). For example:

a = min(4, 2)
b = min(tup1, tup2, tup3, tup4) # defined in the previous code snippets
print(a) # prints 2
print(b) # prints ('cat', 3)

You may also find it helpful to give separate names to the parts of a tuple:

animalName, nameLength = b # ('cat', 3), so animalName = 'cat' and nameLength = 3
print("Animal:", animalName)
print("Length:", nameLength)

For this part, you should extend your program to additionally ask the user to type in three students’ names and earliest class times on Mondays/Wednesdays/Fridays (e.g., the user will type 2a or 6a). You should make pairs for students’ names and class times and use the min function to find the student with the earliest classtime.

Note: For full credit, you must not use any if statements, even if you already know about them from prior CS experience.

For example, if Boris has a 2a, Miyeon has a 3a, and Juan has a 1a, then the program would print out that Juan has the earliest class (1a). In this example, the interaction should look like this:

Please enter three students' names and hit enter after each:
Boris
Miyeon
Juan

Please enter their earliest classtimes and hit enter after each:
2a
3a
1a

Juan has the earliest class (1a).

Here is another example:

Please enter three students' names and hit enter after each:
Alicia
Sven
Ming

Please enter their earliest classtimes and hit enter after each:
2a
5a
4a

Alicia has the earliest class (2a).

Keep in mind that for full credit, you will need to match this interaction exactly, including punctuation and spaces.


Reflection

# You should be equipped to complete this part after Lesson 1 (Monday Sep. 15).

Were there any particular issues or challenges you dealt with in completing this assignment? How long did you spend on this assignment?

Write a brief discussion (a sentence or two is fine) at the bottom of your intro.py file (in comments, so each line should start with #).

Here are some examples:

##### Reflection #####
# I had trouble getting the spaces right in the output.
# I had to look up how to use print() in the Python documentation.
# I spent 4 hours on this assignment.
##### Reflection #####
# I started late, so I had to rush to make sure I knew how to use VS Code.
# It may be good to start early next time.
# I spent 3 hours on this assignment.
##### Reflection #####
# It went fine; I found what I needed in my notes.
# I spent 1 hour on this assignment.

Grading

This assignment will be graded out of 100 points, as follows:

  • 10 points - complete welcome survey (Part 0)
  • 5 points - submit a valid .py file with the right name (intro.py)
  • 5 points - intro.py file contains top-level comments with author name, collaboration statement
  • 10 points - prompt for user first and last name, then print message with them (Part 1)
  • 20 points - prompt for user age in years, then print message with age in days (Part 1)
  • 20 points - prompt for three student-class pairs, then print the earliest time and person (Part 2)
  • 10 points - did not use any if statements (Part 2)
  • 10 points - match example interactions exactly (e.g., punctuation, spaces, etc.; Parts 1+2)
  • 10 points - reflection in comments at the bottom of the intro.py file

What you should submit

You should submit a single intro.py file on Gradescope at this link.