Python. Input data 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




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


Exam questions:


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