Basic user input -Lewandowski and his goals as example

The INPUT function is used to gather input from the user. So you can ask the user to give the program some information, data, etc. (=input).

If you want the user to enter a value or a string and store it to a variable you can do it in this way:

In this Blog I already talked about different data types. So what we can do with the INPPUT function is to determine a wished data type for our input, because for example if you want the user to input the average number of goals from Robert Lewandowski per game, which probably might be a float number (Go to the end of this post to see the solution) . You can do it like this:

So the value for Lewagoals will be stores as a float number in this example.

In case you want the user to assign multiple values to variables you can add the split () function. It breaks the given input by the specified separator. If the separator is not provided then any white space is a separator. If you want to determine the amount of goals that Robert Lewandowski scored angainst the last 3 opponents you can do it like this:

For more information on splits go to this website: https://www.geeksforgeeks.org/taking-multiple-inputs-from-user-in-python/

Furthermore, I can recommend this guy, who provides high quality output:

As promised above here the solution: Lewandowski scores 1.29 goals per game during the creation of this post.

#Mastery 06

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s