Understanding more about variables

Python Programming Python Variable
11 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
€65.22
List Price:  €93.18
You save:  €27.95
£56.04
List Price:  £80.07
You save:  £24.02
CA$96.09
List Price:  CA$137.28
You save:  CA$41.18
A$106.44
List Price:  A$152.07
You save:  A$45.62
S$94.93
List Price:  S$135.63
You save:  S$40.69
HK$547
List Price:  HK$781.46
You save:  HK$234.46
CHF 63.65
List Price:  CHF 90.94
You save:  CHF 27.28
NOK kr765.05
List Price:  NOK kr1,092.98
You save:  NOK kr327.92
DKK kr486.48
List Price:  DKK kr695
You save:  DKK kr208.52
NZ$116.68
List Price:  NZ$166.69
You save:  NZ$50.01
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,685.71
List Price:  ৳10,980.05
You save:  ৳3,294.34
₹5,844.71
List Price:  ₹8,349.95
You save:  ₹2,505.23
RM331.80
List Price:  RM474.03
You save:  RM142.22
₦98,423.43
List Price:  ₦140,610.93
You save:  ₦42,187.50
₨19,474.95
List Price:  ₨27,822.55
You save:  ₨8,347.60
฿2,584.73
List Price:  ฿3,692.63
You save:  ฿1,107.90
₺2,255.06
List Price:  ₺3,221.65
You save:  ₺966.59
B$356.31
List Price:  B$509.04
You save:  B$152.73
R1,298.99
List Price:  R1,855.78
You save:  R556.79
Лв127.57
List Price:  Лв182.26
You save:  Лв54.68
₩95,950.21
List Price:  ₩137,077.60
You save:  ₩41,127.39
₪261.40
List Price:  ₪373.45
You save:  ₪112.04
₱4,015.50
List Price:  ₱5,736.67
You save:  ₱1,721.17
¥10,912.42
List Price:  ¥15,589.84
You save:  ¥4,677.42
MX$1,187.01
List Price:  MX$1,695.81
You save:  MX$508.79
QR254.79
List Price:  QR364.01
You save:  QR109.21
P956.45
List Price:  P1,366.42
You save:  P409.96
KSh9,168.69
List Price:  KSh13,098.69
You save:  KSh3,930
E£3,313.80
List Price:  E£4,734.21
You save:  E£1,420.40
ብር4,020.93
List Price:  ብር5,744.43
You save:  ብር1,723.50
Kz58,536.36
List Price:  Kz83,626.96
You save:  Kz25,090.59
CLP$65,519.73
List Price:  CLP$93,603.63
You save:  CLP$28,083.90
CN¥505.79
List Price:  CN¥722.59
You save:  CN¥216.80
RD$4,064.05
List Price:  RD$5,806.04
You save:  RD$1,741.98
DA9,434.16
List Price:  DA13,477.95
You save:  DA4,043.79
FJ$159.43
List Price:  FJ$227.77
You save:  FJ$68.34
Q544.12
List Price:  Q777.35
You save:  Q233.22
GY$14,659.33
List Price:  GY$20,942.80
You save:  GY$6,283.47
ISK kr9,804.19
List Price:  ISK kr14,006.59
You save:  ISK kr4,202.40
DH702
List Price:  DH1,002.91
You save:  DH300.90
L1,236.68
List Price:  L1,766.77
You save:  L530.08
ден4,019.08
List Price:  ден5,741.79
You save:  ден1,722.70
MOP$563.89
List Price:  MOP$805.60
You save:  MOP$241.70
N$1,302.92
List Price:  N$1,861.40
You save:  N$558.47
C$2,577.98
List Price:  C$3,682.99
You save:  C$1,105
रु9,357.62
List Price:  रु13,368.60
You save:  रु4,010.98
S/260.83
List Price:  S/372.63
You save:  S/111.80
K271.34
List Price:  K387.65
You save:  K116.30
SAR262.49
List Price:  SAR375
You save:  SAR112.51
ZK1,913.50
List Price:  ZK2,733.69
You save:  ZK820.18
L324.50
List Price:  L463.60
You save:  L139.09
Kč1,630.34
List Price:  Kč2,329.15
You save:  Kč698.81
Ft25,331.89
List Price:  Ft36,189.97
You save:  Ft10,858.07
SEK kr764.93
List Price:  SEK kr1,092.80
You save:  SEK kr327.87
ARS$61,714.55
List Price:  ARS$88,167.42
You save:  ARS$26,452.87
Bs483.86
List Price:  Bs691.26
You save:  Bs207.40
COP$272,553.83
List Price:  COP$389,379.31
You save:  COP$116,825.47
₡35,845.57
List Price:  ₡51,210.15
You save:  ₡15,364.58
L1,730.57
List Price:  L2,472.36
You save:  L741.78
₲523,213.21
List Price:  ₲747,479.48
You save:  ₲224,266.27
$U2,704.33
List Price:  $U3,863.50
You save:  $U1,159.16
zł280.23
List Price:  zł400.34
You save:  zł120.11
Already have an account? Log In

Transcript

In a previous video we have learned about variables. Now today we will learn more about variables and how to use this print function in different ways. So today I'll be using three T's. Now what are these T's nothing but three variable. So first I'll use T one. So suppose T one here, I'm 70.

So I will save Cimarron in T one. So, okay. Now print T one, it will display you the value. So, displaying Simran in T two I will display one more name so Here I write a note and again, I'm right print T two. So, I notice then, now, again I write t three and again I will type a name over here, which will be Sam. So print d3.

So display Sam. Now what I will do is I will use this print function now in this print function here I will write hello and then within this condition only I will write T one and just run this what it will display it will display Hello T one. So, everything you write within this code it will be printed As it is, but now suppose I want to print in a different way. So, suppose I want to print this Hello sorry Hannah will be within coats then outside the coat give a comma and write d one what it will print run this it prints Hello Simran So, here T one is considered as a variable name and here T one is considered as a text. So, anything you write within this code is displayed as a text or a string, but anything you write in this way it will be considered as a variable name.

So, here I have printed hello and then outside this code I have written T one which means hello and the value that contains in T one so, it contains similar so it has printed Hello Simran In the same way if I print hello, and we outside this code I write T two and run it. It prints Hello, I don't know the third one print hello and then outside righty three what it will print it prints Hello Sam. Now if I want to print in this way, so print within quotes right hello and outside this give a comma and write T one. Again give a comma right T two. Again give a comma right t three. So what it will print it will print hello Simran ology and say So, it will print all the three variables that I have created previously.

So, first I created T one T two t three symbol and a new Jensen. And now here I printed the variable names like hello T one T two t three, so it printed Hello symbol a note Sam. Now suppose I want to print something more. So write, print here, write Hello. And again give a comma, right? T one comma t two comma t three.

And he came here and give a comma. And here's suppose I want to write something like how are you all So I've pre written however you want. Now print this. So what it prints it prints Hello Simran a note Sam, how are you all now suppose I've used the first name over here. Now suppose similar ones that I want to print my full name over here, that is the first name and the last name both. So what to be done.

So first I'll write T one is equal to i right Simran. Car. So I've written similar code and just run this code. I've run it. Now if you want to view the result just write print T one. If it prints similar, and now if I want to write print, and within this Hello And outside this write T one comma two, comma t three.

And again give a comma, right within quotes. How are you on now print this and see the result? It prints Hello Simran cor a note, Sam, how are you on now as I've given space over here, so it may just sound like I have just written a different name. So if you want don't want to give space just give a underscore and now run it and see its result and now see the new result. So hello Simran car a note Sam, how are you all it just what happens? Because here I have assigned a new value to the variable t one.

So first it was similar and now I've replaced the value of T one With similan core, so it just replaces the value whenever you use the same variable name. So here I have used the same variable name. So the first value is replaced with a new value. Now again, suppose I want to print in a different way. So here I write Hello. And then outside this quotes, I write T one comma t two.

And now here for the last name I want to print and so what I want is Hello, Simran, car, and Sam. So I want to give an end over there. So what I will do, give a comma and within quotes, right and an outside again, give a comma, right? D three, again, give a comma and right are you on? Now, I want to give a full stop after the earnings that is Hello Simran called a news and Sam then full stop. And then how are you on.

So before this how I will give a full stop, and I will print it in this way. So just run this code and see what happens. It prints Hello Simran core a note and Sam. first job, how are you on so it printed the way I wanted to be printed. So you need to just think first what you want. Then set your program like it is so this look at this code and just understand what I have done.

I've just written the text in this coat, the variable names simply and then again, the text within this variable names and then again the text in quotation so whenever you will write in this way you will get your result. Now, suppose here I want suppose here I am writing age is equal to 30 Okay. So, whenever you print age, so print age first print age, you will get 30 Now whenever I will print in this way ease, coma, then right age, so what I've written is print my ages and outside this age, I've written age so just print it what it will print it will print my ages 30 Now, if I write it is equal to 14 and now I'm right Print. Suppose My age is age. Now printing. So it's prints My age is 40, though my age is not 40 but I'll just give an example like this.

So what happened here is it just replaces the value of the previous value with a new value. So B string be numeric, it always represents the value if you use the same variable name. So here I've used the same variable name. So it just replaces the value of each of which was previously 30 and it replaced with 14. Now suppose if you write H is equal to h plus one, what it will do, print it and see what is the result. What it prints, it prints 41.

So it takes the lead This value of age and prints 41 because I've written eight is equal to x plus one, so it will increment the value of age by one, and then it will give you the result. So I hope you have understand the concept of print and how to use it in different way. So don't worry so much about what this variables are, you will become very clear with them with time. So variable is more like house where you store some entity, you store your books in a car book. So variables is like that car book. And the book is like the value that you assign to it.

If you see it like this way, it will be very much easier to you to understand. So today, 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.