In this video, learn how to use Python's built-in input and print functions to get input from the user while the program is running, and give output back based on given conditions.
- Throughout the course, we've been outputting…information to the user, even if we didn't know it.…We've been using the print statement, and so…we just go print, and then whatever we want to…print or output to the user, and so we can say…hello to the user.…In a previous video, we got initial input from…the system module and the command line arguments.…But what if we need input from the user…throughout the program's execution?…That's where the built-in input function comes in.…To use it, we'll just go input, and then…whatever we want to prompt the user to input.…
So say we want the users favorite color.…Well, we would write, What is your favorite color?…And then the user would input their favorite color.…Now this is great to get that color, but we're not…saving it anywhere.…If we want to use the users favorite color somewhere…else in the program, we need to save it in a variable.…So here, we'll say color and that will save whatever…the user inputs as their favorite color.…So if we run this, we see hello as our output,…
- Working with logical and comparison operators
- Getting a list of numbers with the range() and list() functions
- Using mathematical functions such as round(), abs(), and pow()
- Calculating a given input's length
- Importing and using the math module
- Reading a user's command-line arguments
- Getting the current time
- Formatting dates and times with datetime
- Creating a timer
- Using urllib to get content from the Internet
- Using the JSON module to decode content
Skill Level Intermediate
1. Python: What's Built-In?
2. Python: Math
3. Python: Input/Output
4. Python: Date & Time, HTML Parsing, and HTTP
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.