Input - Asking Questions

Now it is time to get input from the user. So far you have only been printing, but you haven’t been able to get any input from a person or change it. You may not even know what “input” means, so rather than talk about it, let’s have you do some and see if you get it. In the next exercise, we’ll do more to explain it. 

To get an input we can use the python input function. The default input format is a string so in case if you want to get integer then you need to define it as int() or in case float then float().

Exercise 1:

I suggest you run it and check the difference your self.

Exercise 2:

Let's get some input, modify and return some value. For this exercise, we will take input in two variable and then do some simple maths on those variable.

Pyghost

Output:

 

You should give some different int like negative or some float values and see the result.

Exercise 3:

Another simple exercise for printing string.

I suggest you, check the output of this code yourself and try creating some new pattern.

About the author

akarperiwal

0 Comments

Please login to comment