Lab 1 - Challenge 1

  • Due Jan 21, 2024 at 11:59pm
  • Points 4
  • Questions 2
  • Available Jan 14, 2024 at 12am - Jan 24, 2024 at 11:59pm
  • Time Limit None
  • Allowed Attempts Unlimited

Instructions

Knightro was showing you a program he just wrote.  His goal is to find how large his average step is. However, he noticed that when he goes to divide those numbers together it doesn't work! 

In his program he wants to take in the number of steps he has taken as an integer and the distance as a floating point number.   He will then use those variables to calculate the average distance traveled per step in inches.

His program is shown below: 

# Knightro
# Lab 1: Challenge 1
# COP 2500
# Aug 28, 2023

# Ask for input
steps=input("How many steps?\n")
distance=input("Total feet traveled?\n")

# Calculate Steps
pace=distance*12/steps

# Output paces as inches
print("Your average step is",pace,"inches")

He is getting this error.  

pace=distance*12/steps
TypeError: unsupported operand type(s) for /: 'str' and 'str'

This is because distance and steps are not numeric data but strings.   How can we correct his program so it can run? 

Only registered, enrolled users can take graded quizzes