Python 3 Tutorial 7 - input Function
Автор: Ken
Загружено: 2025-11-01
Просмотров: 8
Описание:
Getting Input from the User
The built-in input function requests and obtains user input, that is, it tells the user what
to type and waits for the user to respond.
name = input("What's your name? ")
What's your name? John
print(name)
John
name = input("What's your name? ")
What's your name? 'John'
print(name)
'John'
Function input Always Returns a String
value1 = input('Enter first number: ')
Enter first number: 10
value2 = input('Enter second number: ')
Enter second number: 20
print(value1 + value2)
'1020'
Getting an Integer from the User
value1 = int(input('Enter first number: '))
Enter first number: 10
value2 = int(input('Enter second number: '))
Enter second number: 20
print(value1 + value2)
30
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: