Default Argument Value

1 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€85.14
List Price:  €119.21
You save:  €34.06
£74.68
List Price:  £104.56
You save:  £29.87
CA$137.64
List Price:  CA$192.70
You save:  CA$55.06
A$150.39
List Price:  A$210.55
You save:  A$60.16
S$128.91
List Price:  S$180.48
You save:  S$51.56
HK$778.15
List Price:  HK$1,089.44
You save:  HK$311.29
CHF 79.60
List Price:  CHF 111.44
You save:  CHF 31.84
NOK kr1,012.71
List Price:  NOK kr1,417.84
You save:  NOK kr405.12
DKK kr636.06
List Price:  DKK kr890.52
You save:  DKK kr254.45
NZ$172.81
List Price:  NZ$241.94
You save:  NZ$69.13
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,214.34
List Price:  ৳17,100.57
You save:  ৳4,886.22
₹9,071.34
List Price:  ₹12,700.24
You save:  ₹3,628.90
RM409.20
List Price:  RM572.90
You save:  RM163.70
₦145,133.48
List Price:  ₦203,192.68
You save:  ₦58,059.20
₨28,011.26
List Price:  ₨39,216.89
You save:  ₨11,205.62
฿3,142.13
List Price:  ฿4,399.11
You save:  ฿1,256.98
₺4,269.71
List Price:  ₺5,977.76
You save:  ₺1,708.05
B$541.91
List Price:  B$758.70
You save:  B$216.78
R1,681.81
List Price:  R2,354.61
You save:  R672.79
Лв166.53
List Price:  Лв233.15
You save:  Лв66.62
₩146,386.44
List Price:  ₩204,946.87
You save:  ₩58,560.43
₪321.04
List Price:  ₪449.47
You save:  ₪128.43
₱5,894.51
List Price:  ₱8,252.55
You save:  ₱2,358.04
¥15,495.23
List Price:  ¥21,693.94
You save:  ¥6,198.71
MX$1,797.13
List Price:  MX$2,516.05
You save:  MX$718.92
QR364.26
List Price:  QR509.98
You save:  QR145.72
P1,324.33
List Price:  P1,854.12
You save:  P529.78
KSh12,892.71
List Price:  KSh18,050.31
You save:  KSh5,157.60
E£4,748.49
List Price:  E£6,648.08
You save:  E£1,899.58
ብር15,617.37
List Price:  ብር21,864.95
You save:  ብር6,247.57
Kz91,205.27
List Price:  Kz127,691.03
You save:  Kz36,485.76
CLP$91,340.86
List Price:  CLP$127,880.86
You save:  CLP$36,540
CN¥704.64
List Price:  CN¥986.53
You save:  CN¥281.88
RD$6,354.07
List Price:  RD$8,895.96
You save:  RD$2,541.88
DA12,968.25
List Price:  DA18,156.07
You save:  DA5,187.81
FJ$225.35
List Price:  FJ$315.50
You save:  FJ$90.15
Q765.53
List Price:  Q1,071.77
You save:  Q306.24
GY$20,910.39
List Price:  GY$29,275.38
You save:  GY$8,364.99
ISK kr12,635.73
List Price:  ISK kr17,690.53
You save:  ISK kr5,054.80
DH919.51
List Price:  DH1,287.35
You save:  DH367.84
L1,689.61
List Price:  L2,365.52
You save:  L675.91
ден5,241.56
List Price:  ден7,338.40
You save:  ден2,096.83
MOP$801.46
List Price:  MOP$1,122.07
You save:  MOP$320.61
N$1,686.27
List Price:  N$2,360.84
You save:  N$674.57
C$3,678.63
List Price:  C$5,150.23
You save:  C$1,471.59
रु14,462.40
List Price:  रु20,247.95
You save:  रु5,785.54
S/336.50
List Price:  S/471.12
You save:  S/134.61
K430.77
List Price:  K603.10
You save:  K172.32
SAR375.15
List Price:  SAR525.23
You save:  SAR150.07
ZK2,306.35
List Price:  ZK3,228.98
You save:  ZK922.63
L433.42
List Price:  L606.81
You save:  L173.38
Kč2,067.88
List Price:  Kč2,895.12
You save:  Kč827.23
Ft32,789.63
List Price:  Ft45,906.80
You save:  Ft13,117.16
SEK kr928.77
List Price:  SEK kr1,300.32
You save:  SEK kr371.54
ARS$144,063.05
List Price:  ARS$201,694.03
You save:  ARS$57,630.98
Bs690.62
List Price:  Bs966.89
You save:  Bs276.27
COP$380,273.94
List Price:  COP$532,398.74
You save:  COP$152,124.79
₡49,997.35
List Price:  ₡69,998.29
You save:  ₡20,000.94
L2,631.45
List Price:  L3,684.14
You save:  L1,052.68
₲671,370.87
List Price:  ₲939,946.08
You save:  ₲268,575.20
$U3,917.97
List Price:  $U5,485.31
You save:  $U1,567.34
zł359.24
List Price:  zł502.95
You save:  zł143.71
Already have an account? Log In

Transcript

Hello, in this video, we are going to take a look at default arguments. So we have this function that just squares a number takes a number. And it could be a hard coded number like that could be a variable that's passing by value doesn't really matter. And he gets it multiplies it by 12, which is squaring it, and it prints it out. So as you can see, for 10, we get 100 if we want it, so if the user doesn't pass in a value, it will have a value by default, then we can just do equals, let's say nine, for example. And as you can see, this doesn't change.

That's because we pass in a value, we don't pass in a value and we run it we get 81 because if no value is passed in for this particular variable, then it will just get the default value, which happens to be nice. That's a great way To have a fallback in, in case you can call a method with some default value, but obviously, that's the only you will the coder. Maybe that default value, you know, might change at a later date, but essentially allows you to create a function that doesn't crash. if let's say a developer calls it without passing in a value, or that value has been passed in is from the user itself, and they say you do default argument values. If you have any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.

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.