Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
44 views

05 Input in Python

The document discusses how to take input from users in Python using the input() function. It notes that input() returns a string by default and shows how to cast the input to an int using int(). Examples are provided of taking single and multiple inputs on one line and using the input in print statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

05 Input in Python

The document discusses how to take input from users in Python using the input() function. It notes that input() returns a string by default and shows how to cast the input to an int using int(). Examples are provided of taking single and multiple inputs on one line and using the input in print statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

05-input-in-python

February 27, 2023

1 Input
• to take the input from the user. In python ‘input()’ function is used to allow this.
• by default it takes str datatype
[10]: n = input()

25

[11]: n

[11]: '25'

[12]: type(n)

[12]: str

[13]: n1 = input('enter your age')


n1

enter your age27

[13]: '27'

[17]: type(n1)

[17]: str

[14]: n2 = int(input('enter your age'))


n2

enter your age26

[14]: 26

[15]: type(n2)

[15]: int

1
[18]: # one more different example
name = input('enter your name')
print('it was nice talking to you ' + name+' !')

enter your namekrishna


it was nice talking to you krishna !

[20]: age = input('enter your age')


print('Hey you are already '+age+' years old '+ name + ' !')

enter your age25


Hey you are already 25 years old krishna !

[24]: # multiple input in a single entry


var1, var2 = input('enter your name: ').split(' ')
print(var1)
print(var2)

enter your name: krishna Gudimella


krishna
Gudimella

You might also like