Python. Input data (en)

11.1.1.5 organize keyboard inputs;

Python. Input data

Подписаться на канал "Программирование на Python"

The input() function allows the user to enter a value into the program. input() always returns a string value.

print('What is your name?')
name = input()
print('Hello,', name, '!')

When input() is executed, the program will stop and wait for user input. After entering data, the user should press Enter.

name = input('What is your name?')
print('Hello,', name , '!')

If you want to get an integer, then use the data type conversion functions.

For example, number = int(input())

Task 1. Write a simple program to add two integers a and b.

Variant 1

a = input()
b = input()
print(int(a) + int(b))

Variant 2

a = input()
b = input()
print(int(a) + int(b))

Variant 3

a = int(input())
b = int(input())
c = a + b
print(c)

Questions:

 

Exercises:

Ex. 1 Заполни пропуски в программе.

 


Tasks

Tasks on Stepik.org course "Python Programming for NIS"


 

Категория: Programming languages | Добавил: bzfar77 (09.09.2021)
Просмотров: 5440 | Теги: Python, String, variable, Convert, Input | Рейтинг: 4.3/3
Всего комментариев: 0
avatar