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
€86.14
List Price:  €120.60
You save:  €34.46
£75.77
List Price:  £106.09
You save:  £30.31
CA$140.05
List Price:  CA$196.08
You save:  CA$56.02
A$152.75
List Price:  A$213.86
You save:  A$61.10
S$129.79
List Price:  S$181.71
You save:  S$51.92
HK$778.59
List Price:  HK$1,090.06
You save:  HK$311.47
CHF 80.48
List Price:  CHF 112.68
You save:  CHF 32.19
NOK kr1,015.54
List Price:  NOK kr1,421.80
You save:  NOK kr406.25
DKK kr643.39
List Price:  DKK kr900.77
You save:  DKK kr257.38
NZ$175
List Price:  NZ$245.02
You save:  NZ$70.01
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,228.73
List Price:  ৳17,120.71
You save:  ৳4,891.98
₹8,994.18
List Price:  ₹12,592.21
You save:  ₹3,598.03
RM413.15
List Price:  RM578.43
You save:  RM165.28
₦144,745.52
List Price:  ₦202,649.52
You save:  ₦57,904
₨28,176.09
List Price:  ₨39,447.65
You save:  ₨11,271.56
฿3,203.67
List Price:  ฿4,485.27
You save:  ฿1,281.60
₺4,242.17
List Price:  ₺5,939.21
You save:  ₺1,697.03
B$537.12
List Price:  B$751.99
You save:  B$214.87
R1,712.97
List Price:  R2,398.23
You save:  R685.25
Лв168.52
List Price:  Лв235.93
You save:  Лв67.41
₩146,901.96
List Price:  ₩205,668.62
You save:  ₩58,766.66
₪325.43
List Price:  ₪455.62
You save:  ₪130.18
₱5,865.61
List Price:  ₱8,212.09
You save:  ₱2,346.47
¥15,602.16
List Price:  ¥21,843.65
You save:  ¥6,241.48
MX$1,831.60
List Price:  MX$2,564.31
You save:  MX$732.71
QR366.07
List Price:  QR512.51
You save:  QR146.44
P1,336.69
List Price:  P1,871.42
You save:  P534.72
KSh12,928.70
List Price:  KSh18,100.70
You save:  KSh5,172
E£4,753.35
List Price:  E£6,654.88
You save:  E£1,901.53
ብር15,640.38
List Price:  ብር21,897.16
You save:  ብር6,256.77
Kz91,234.01
List Price:  Kz127,731.27
You save:  Kz36,497.25
CLP$92,959.70
List Price:  CLP$130,147.30
You save:  CLP$37,187.60
CN¥706.90
List Price:  CN¥989.70
You save:  CN¥282.79
RD$6,257.36
List Price:  RD$8,760.56
You save:  RD$2,503.19
DA13,031.68
List Price:  DA18,244.87
You save:  DA5,213.19
FJ$227.30
List Price:  FJ$318.23
You save:  FJ$90.93
Q767.59
List Price:  Q1,074.66
You save:  Q307.06
GY$20,952.92
List Price:  GY$29,334.92
You save:  GY$8,382
ISK kr12,766.72
List Price:  ISK kr17,873.92
You save:  ISK kr5,107.20
DH926.11
List Price:  DH1,296.60
You save:  DH370.48
L1,699.08
List Price:  L2,378.78
You save:  L679.70
ден5,308.64
List Price:  ден7,432.31
You save:  ден2,123.66
MOP$803.45
List Price:  MOP$1,124.87
You save:  MOP$321.41
N$1,710.78
List Price:  N$2,395.16
You save:  N$684.38
C$3,685.51
List Price:  C$5,159.87
You save:  C$1,474.35
रु14,346.56
List Price:  रु20,085.75
You save:  रु5,739.19
S/336.70
List Price:  S/471.40
You save:  S/134.69
K430.39
List Price:  K602.56
You save:  K172.17
SAR375.34
List Price:  SAR525.50
You save:  SAR150.15
ZK2,295.99
List Price:  ZK3,214.48
You save:  ZK918.49
L438.46
List Price:  L613.87
You save:  L175.40
Kč2,081.70
List Price:  Kč2,914.46
You save:  Kč832.76
Ft32,846.48
List Price:  Ft45,986.39
You save:  Ft13,139.90
SEK kr945.94
List Price:  SEK kr1,324.36
You save:  SEK kr378.41
ARS$145,114.23
List Price:  ARS$203,165.73
You save:  ARS$58,051.50
Bs694.55
List Price:  Bs972.40
You save:  Bs277.84
COP$375,380.15
List Price:  COP$525,547.23
You save:  COP$150,167.07
₡49,318.20
List Price:  ₡69,047.45
You save:  ₡19,729.25
L2,637.25
List Price:  L3,692.26
You save:  L1,055
₲700,071.99
List Price:  ₲980,128.80
You save:  ₲280,056.80
$U3,927.20
List Price:  $U5,498.24
You save:  $U1,571.03
zł365.38
List Price:  zł511.55
You save:  zł146.16
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.