Lesson 2 - part A


Input

Every good program should be able take in inputs from the user. For example, let's say we have a function that can take in two integers and return the sum. We want to make sure that it is user friendly enough such that we can type in two values where the function will take them as its parameters.

Look at the diagram below.



Mountain View


The input() function would do two things. The first is to display the string inside the bracket. The second is to receive the inputs from the user. Let's say we input 5 from our keyboard, then x will now refer to string “5”. Note that we have to convert each string input into integer by using int() function since input value will always in the form of string.




Go to Lesson 2 Part B

Back to Lesson 2 Part A

Back to Index