[vc_row css_animation=”” row_type=”row” use_row_as_full_screen_section=”no” type=”full_width” angled_section=”no” text_align=”left” background_image_as_pattern=”without_pattern”][vc_column][vc_column_text]

Inputs in Python

[/vc_column_text][vc_separator type=”normal” up=”1″][vc_column_text css=”.vc_custom_1570562802712{background-color: #f6f6f6 !important;}”]

If you want to send data (inputs) to the computer that the program can use, inputs are easily made in Python with the function input ().

[/vc_column_text][vc_empty_space height=”20px”][vc_column_text]

WHAT IS AN INPUT IN PYTHON AND WHY DO YOU USE THEM?

Often, a user needs to provide information (inputs) to the program he or she is using. For example, it may be a name, age or other information that the program needs to know to function as intended. For example, you have at some point entered information in a dialog or form. This information must be able to save and interpret the computer. Therefore, Python has pre-programmed functions to easily manage inputs.[/vc_column_text][vc_empty_space height=”10px”][vc_column_text]

[/vc_column_text][vc_empty_space height=”10px”][vc_separator type=”normal” thickness=”2″][vc_empty_space height=”10px”][vc_column_text]

HOW DO YOU CREATE AN INPUT IN PYTHON?

In Python there are preprogrammed functions for managing inputs. With the input () method, you can easily enter values into the program. When using the function, the program will wait until the user has entered something in the console and then continue in the program.[/vc_column_text][vc_empty_space height=”10px”][vc_column_text]

Syntax for Input in Python

You can use the input () function with the following syntax:

 

name = input("Information")

Within the parentheses you write the information to the user, typically the information requested by the user. In this case, the value that the user enters will be saved in the name variable.[/vc_column_text][vc_empty_space height=”20px”][vc_column_text]

When using the function, the program will wait until the user has entered something in the console and then continue with the program

[/vc_column_text][vc_empty_space height=”20px”][vc_separator type=”normal” thickness=”2″][vc_empty_space height=”10px”][vc_column_text]

Example for Input in Python

In the following example, we test how to use the input () function in Python. We ask the user to enter their name. Once the user has entered their name (and pressed enter), the program continues. In this case, the program will print “Hello name, welcome to Programming Python!”.

 

ÖVERSÄTT BILDER TILL ENGELSKA[/vc_column_text][vc_empty_space height=”20px”][vc_separator type=”normal”][vc_empty_space height=”20px”][/vc_column][/vc_row][vc_row css_animation=”” row_type=”row” use_row_as_full_screen_section=”no” type=”full_width” angled_section=”no” text_align=”left” background_image_as_pattern=”without_pattern”][vc_column][vc_column_text]

Previous Page    |    Next Page

[/vc_column_text][vc_empty_space][/vc_column][/vc_row]