Python inputs | Sololearn: Learn to code for FREE!

+11

Python inputs

is input always string even if i dont define it as string and the user input is digit (integer)?

7/1/2018 9:30:29 PM

Goshgar Mikayilov

15 Answers

New Answer

+5

https://code.sololearn.com/cxS0qJTafFg8/?ref=app

+13

Yes. Function input() always return a string. If this string is completely made of numbers (int/float), you can convert it by int() or float().

+10

def inputint(): return int(input("enter a num")) if you need more than once

+6

how do could you define different?

+2

input() always is a string, but int(input()) is always an integer. example: input: 1 2 code 1: var1 = input() var2 = input() print(var1+var2) output 1: 12 code 2: var1 = int(input()) var2 = int(input()) print(var1+var2) output 2: 3

+2

x=1000000 y=0.01*(2**30) print(max(x,y))

0

thanks i got it

0

input() always is a string, but int(input()) is always an integer. example: input: 1 2 code 1: var1 = input() var2 = input() print(var1+var2) output 1: 12 code 2: var1 = int(input()) var2 = int(input()) print(var1+var2) output 2: 3

0

input () function automatically takes inputs as a string. If you want to take integer input then use int(input()) and to take float as input, just use float (input ()). That's it. Pretty simple.

0

I can help you. You need to write: int(input("text"))

0

Yes , you can use int(input()) to define it as integer

0

Yes, because 'string' has been set as default category for input() statement for making or asking integer or float value you may use the following functions alongwith input(): int() for integers float() for floating point literals eval() for both

0

I am new to the platform....please i need more explanations

0

Yes. Function input() always return a string. If this string is completely made of numbers (int/float), you can convert it by int() or float().

-1

How do I use type-conversion to return a char from a string which contains a single letter? word="word" for w in word: letter=char(word)