User input variable

Python Programming Python Variable
6 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€59.73
List Price:  €85.34
You save:  €25.60
£51.80
List Price:  £74.01
You save:  £22.20
CA$96.84
List Price:  CA$138.36
You save:  CA$41.51
A$106.75
List Price:  A$152.51
You save:  A$45.75
S$89.95
List Price:  S$128.50
You save:  S$38.55
HK$545.64
List Price:  HK$779.53
You save:  HK$233.88
CHF 55.85
List Price:  CHF 79.79
You save:  CHF 23.94
NOK kr703.17
List Price:  NOK kr1,004.57
You save:  NOK kr301.40
DKK kr445.91
List Price:  DKK kr637.04
You save:  DKK kr191.13
NZ$118.73
List Price:  NZ$169.63
You save:  NZ$50.89
د.إ257.03
List Price:  د.إ367.21
You save:  د.إ110.17
৳8,495.52
List Price:  ৳12,136.98
You save:  ৳3,641.45
₹6,172.17
List Price:  ₹8,817.76
You save:  ₹2,645.59
RM295.67
List Price:  RM422.40
You save:  RM126.73
₦107,084.70
List Price:  ₦152,984.70
You save:  ₦45,900
₨19,808.40
List Price:  ₨28,298.93
You save:  ₨8,490.52
฿2,243.26
List Price:  ฿3,204.79
You save:  ฿961.53
₺2,883.76
List Price:  ₺4,119.83
You save:  ₺1,236.07
B$378.92
List Price:  B$541.35
You save:  B$162.42
R1,231.03
List Price:  R1,758.69
You save:  R527.66
Лв116.90
List Price:  Лв167.02
You save:  Лв50.11
₩97,041.13
List Price:  ₩138,636.13
You save:  ₩41,595
₪234.19
List Price:  ₪334.57
You save:  ₪100.38
₱3,968.43
List Price:  ₱5,669.43
You save:  ₱1,701
¥10,316.87
List Price:  ¥14,739.02
You save:  ¥4,422.15
MX$1,309.87
List Price:  MX$1,871.33
You save:  MX$561.45
QR255.14
List Price:  QR364.50
You save:  QR109.36
P938.51
List Price:  P1,340.79
You save:  P402.27
KSh9,032.87
List Price:  KSh12,904.65
You save:  KSh3,871.78
E£3,400.11
List Price:  E£4,857.51
You save:  E£1,457.40
ብር9,985.48
List Price:  ብር14,265.58
You save:  ብር4,280.10
Kz64,180.83
List Price:  Kz91,690.83
You save:  Kz27,510
CLP$67,522.15
List Price:  CLP$96,464.35
You save:  CLP$28,942.20
CN¥499.22
List Price:  CN¥713.21
You save:  CN¥213.98
RD$4,414.63
List Price:  RD$6,306.89
You save:  RD$1,892.25
DA9,089.11
List Price:  DA12,985
You save:  DA3,895.89
FJ$157.67
List Price:  FJ$225.25
You save:  FJ$67.58
Q535.38
List Price:  Q764.86
You save:  Q229.48
GY$14,604.61
List Price:  GY$20,864.62
You save:  GY$6,260.01
ISK kr8,549.27
List Price:  ISK kr12,213.77
You save:  ISK kr3,664.50
DH634.40
List Price:  DH906.33
You save:  DH271.92
L1,171.66
List Price:  L1,673.87
You save:  L502.21
ден3,674.28
List Price:  ден5,249.20
You save:  ден1,574.92
MOP$561.02
List Price:  MOP$801.49
You save:  MOP$240.47
N$1,234.02
List Price:  N$1,762.97
You save:  N$528.94
C$2,569.13
List Price:  C$3,670.35
You save:  C$1,101.21
रु9,858.12
List Price:  रु14,083.64
You save:  रु4,225.51
S/245.88
List Price:  S/351.28
You save:  S/105.39
K291.36
List Price:  K416.25
You save:  K124.88
SAR262.47
List Price:  SAR374.98
You save:  SAR112.50
ZK1,666.62
List Price:  ZK2,380.99
You save:  ZK714.36
L303.21
List Price:  L433.17
You save:  L129.96
Kč1,456.45
List Price:  Kč2,080.74
You save:  Kč624.28
Ft23,442.21
List Price:  Ft33,490.30
You save:  Ft10,048.09
SEK kr657.57
List Price:  SEK kr939.43
You save:  SEK kr281.85
ARS$95,110.21
List Price:  ARS$135,877.55
You save:  ARS$40,767.34
Bs482.36
List Price:  Bs689.11
You save:  Bs206.75
COP$278,383.76
List Price:  COP$397,708.14
You save:  COP$119,324.37
₡35,369.65
List Price:  ₡50,530.25
You save:  ₡15,160.59
L1,828.90
List Price:  L2,612.83
You save:  L783.92
₲504,728.30
List Price:  ₲721,071.34
You save:  ₲216,343.03
$U2,810.15
List Price:  $U4,014.67
You save:  $U1,204.52
zł253.83
List Price:  zł362.63
You save:  zł108.80
Already have an account? Log In

Transcript

So, welcome up to the Python posts and today let us start doing a program by taking input from the user. So, how to do that. Now suppose here I am creating a variable called n. So, n will be equal to input and then I will write here what is your age? Now, whenever I will write this and I will submit this program, I'll run this program what it will show. So, see what it's asking. It's asking me, what is your age?

It is just showing you a space to write something over there. So suppose I'll write 30. So what is your age? It's asking, so I've provided 30 and I've just pressed enter. So, this is the result. So, what is your age 30.

So, here by using this input function, we can use input from the user. Now, suppose I will write here and the same thing I will write n equal to input, what is your age and then after that, I write, print and here I am write my name, sorry, my age is an outside this code I write in. Now what will be the result? Just run it and see what you get. So, it's asking for the age Now, right, it's 26 and I press enter. So what it gives it gives my age is 26.

So what is happening here? It's basically asking you input, so it's basically asking user to give an input and it will execute in the same way. So, what happening here is whenever it asking for a particular input, what I am providing it, the first time I provided 30, the next time I provide it 26. So, what this is 30 what this 26 is, this is the value of that particular variable in so whenever I'm providing a particular value, it is assigning this particular value to the variable in and then it is just executing the next code accordingly. So whenever I wrote here 30 it is it just assigned 32 n and then again when 26 over here, it assigned this value 26 to In and just print the next statement that is my age is 26. So let us just write in a different way.

So in input so now I'm writing What is your name? Okay, now, in the next steps, I write, print and write hello and give a comma outside quotes and write end over here. Then again give a comma and here I'll give an explanatory sign. Now what it will happen I will write another print statement. So print now I'll write How are you n again, give a comma and within this a writer, question mark because this is a question now in the next day, I will again write a print statement. Now here own right.

I hope life is treating an outside this course leave a coma, right? And again give a coma, right? Give a code and write well. So here now will be a full stop. And I will execute this code. Now what will I get?

Can you guess what I can get in the place of n, I didn't get the value that I will input. So if you don't understand what result will I get, just execute it and see the result and you will understand it very well. So just execute it. So the first thing what it will ask is for is your name. So I'll just write my name over here. So I'm writing my name.

You press enter and see what it does. It just printed the value of that particular n to the every print statement where n is assigned. So what is your name? Reporter? Hello Ruth Aparna. How are you read the corner?

I hope life is treating Ruta borna. Well, so, every time you will assign a new value to that end, you will get a new result to suppose the same thing, I will just copy it and paste it over here. Now, if I execute this code and write a different name here, suppose I write here, submit. Okay, now just press Enter. Now what happens? It just changed the value of n to submit.

So what I got what is your name summit? Hello, summit. How are you summit I hope life is treating summit well. So every time you give an new value to the input statement, it will assign that particular value to the end and it will execute the next steps. accordingly you have learned how to use in how to use or how to get input from the user. So this input function will help you to get input from the users and then it will execute the next steps.

So I'll be ending my video over here. See you in the next video. Thank you

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.