Skip to content

Coding Assignment 1

Note: You should only begin this assignment when you have completed Step 4 of the Learning Path.

This assignment will test your understanding of the concepts covered up to Step 4 of the Learning Path. You will be asked to write Python code to solve a series of problems.

Because what we've learned so far is limited, I will ask you to write a block of code that will end with a certain result/functionality. As a part of your assignment, you might need to explain how the resulting functionality is useful.

Problem 1: Odd or Even?

Write a Python program that takes in an input_integer and then prints some information that would tell us if that number is odd or even.

The code block should look something like this:

# We should be able to enter *any* integer here 
# and get the correct answer
input_integer =  

# ... your code here ...

print(output_information) 
# This can be a string, a boolean, or a number
# it should tell us if the input_integer is odd or even. 
# Explain why this output is useful in a comment.

Problem 2: Temperature Conversion

Write a Python program that takes in a temperature in Celsius and converts it to Fahrenheit.

Print the result.

The code block should look something like this:

# We should be able to enter any temperature 
# (likely a float, not an integer) in Celsius here 
# and print the correct answer in Fahrenheit
celsius_temperature =  

# ... your code here ...

print(fahrenheit_temperature) 
# This should print the temperature in Fahrenheit.

Problem 3: String + How Many Characters?

Write a Python program that takes an input_string and prints a statement that includes the string itself and its length. Use the length function (len()) function to determine the length of the string.

If our string was "Bearcat", the printed result should be something like:

"The string 'Bearcat' has 7 characters."

To generate a more complex print statement, you can use the + operator to concatenate strings, or you can explore the f-string print method.

f-strings are really cool, and is super useful!

The code block should look something like this:

# We should be able to enter any string here 
# and get the correct answer
input_string =  

# ... your code here ...

# Print the string and its length in a descriptive statement
print(... your code here ...)
# This should print the input string and its length.
# Explain why this output is useful in a comment.

If you are taking this class for credit at UC...

Save all of your problems as an .ipynb file and submit it to the appropriate assignment on Canvas.