We will learn here about giving inputs:
syntax:
variableName = input()
// This will assign the input value to the variableName
variableName = input("Enter a number: ")
E.g.:
>>>a=input()
10 //entering input
>>>print a
10 //output value of a
//Output will be of the form - Enter a number:
//Entering a number will assign the value to the variableName
*/ However entering a string to this will give an error
for this we have another command know as raw input*/
variableName = raw_input()
// this will assign the input as string to the variable name
variableName=raw_input("Hello: ")
E.g.:
>>>FirtstName = raw_input("Hello! ")
Hello! ABC
>>>FirstName
ABC
syntax:
variableName = input()
// This will assign the input value to the variableName
variableName = input("Enter a number: ")
E.g.:
>>>a=input()
10 //entering input
>>>print a
10 //output value of a
//Output will be of the form - Enter a number:
//Entering a number will assign the value to the variableName
*/ However entering a string to this will give an error
for this we have another command know as raw input*/
variableName = raw_input()
// this will assign the input as string to the variable name
variableName=raw_input("Hello: ")
E.g.:
>>>FirtstName = raw_input("Hello! ")
Hello! ABC
>>>FirstName
ABC
No comments:
Post a Comment