Making input statements is vitally important because, of course, we might someone on the outside to give information, you know, like in a survey or whatever. Anyway, input statements aren't much in Python and probably not much in other languages either.
Getting Our Feet Wet
Let's dive into this topic with some examples. Notice that aside from strings, you need to declare the datatype so things don't mess up. I was wondering, though, as I'm not an expert, only a learner, can you also declare the str type?
This is quite straightforward. Any questions? Have you run into Python applications where this stuff was probably used? How did it go?
Getting Our Feet Wet
Let's dive into this topic with some examples. Notice that aside from strings, you need to declare the datatype so things don't mess up. I was wondering, though, as I'm not an expert, only a learner, can you also declare the str type?
Code:
your_gpa = float(input("What is your gpa?"))
print("Your gpa was recorded as" + " " + str(your_gpa) + ".")
your_age = int(input("What is your age?"))
print("Your age is recorded as" + " " + str(your_age) + ".")
your_school = input("What is your school?")
# Notice we didn't have to declare the str type.
print("Your school is recorded as" + " " + (your_school) + ".")
do_you_play_sports = bool(input("Do you play sports, true or false?"))
print("It is recorded that it is" + " " + str(do_you_play_sports) + " " + "that you play sports." + ".")
This is quite straightforward. Any questions? Have you run into Python applications where this stuff was probably used? How did it go?
Last edited: