Generators Coding Exercise

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
$69.99
List Price:  $99.99
You save:  $30
€60.93
List Price:  €87.05
You save:  €26.11
£52.77
List Price:  £75.39
You save:  £22.61
CA$96.25
List Price:  CA$137.51
You save:  CA$41.25
A$101.09
List Price:  A$144.42
You save:  A$43.33
S$90.03
List Price:  S$128.62
You save:  S$38.59
HK$548
List Price:  HK$782.89
You save:  HK$234.89
CHF 55.55
List Price:  CHF 79.37
You save:  CHF 23.81
NOK kr684.16
List Price:  NOK kr977.42
You save:  NOK kr293.25
DKK kr455.29
List Price:  DKK kr650.45
You save:  DKK kr195.15
NZ$121.35
List Price:  NZ$173.37
You save:  NZ$52.01
د.إ257.03
List Price:  د.إ367.21
You save:  د.إ110.17
৳8,601.02
List Price:  ৳12,287.70
You save:  ৳3,686.67
₹6,582.43
List Price:  ₹9,403.88
You save:  ₹2,821.44
RM275.72
List Price:  RM393.91
You save:  RM118.18
₦95,753.31
List Price:  ₦136,796.31
You save:  ₦41,043
₨19,571.19
List Price:  ₨27,960.05
You save:  ₨8,388.85
฿2,311.48
List Price:  ฿3,302.26
You save:  ฿990.78
₺3,102.70
List Price:  ₺4,432.63
You save:  ₺1,329.92
B$375.01
List Price:  B$535.75
You save:  B$160.74
R1,202.98
List Price:  R1,718.62
You save:  R515.64
Лв119.15
List Price:  Лв170.23
You save:  Лв51.07
₩106,116.29
List Price:  ₩151,601.20
You save:  ₩45,484.90
₪220.49
List Price:  ₪315
You save:  ₪94.51
₱4,230.75
List Price:  ₱6,044.19
You save:  ₱1,813.43
¥11,172.27
List Price:  ¥15,961.07
You save:  ¥4,788.80
MX$1,265.31
List Price:  MX$1,807.67
You save:  MX$542.35
QR256.32
List Price:  QR366.19
You save:  QR109.86
P955.83
List Price:  P1,365.54
You save:  P409.70
KSh9,070.70
List Price:  KSh12,958.70
You save:  KSh3,888
E£3,656.83
List Price:  E£5,224.27
You save:  E£1,567.44
ብር11,046.94
List Price:  ብር15,782.03
You save:  ብር4,735.08
Kz63,840.04
List Price:  Kz91,203.97
You save:  Kz27,363.93
CLP$65,411.21
List Price:  CLP$93,448.59
You save:  CLP$28,037.38
CN¥483.73
List Price:  CN¥691.08
You save:  CN¥207.34
RD$4,160.88
List Price:  RD$5,944.37
You save:  RD$1,783.49
DA9,292.91
List Price:  DA13,276.16
You save:  DA3,983.24
FJ$156.37
List Price:  FJ$223.39
You save:  FJ$67.02
Q536.93
List Price:  Q767.08
You save:  Q230.14
GY$14,664.98
List Price:  GY$20,950.87
You save:  GY$6,285.89
ISK kr8,747.35
List Price:  ISK kr12,496.75
You save:  ISK kr3,749.40
DH654.99
List Price:  DH935.74
You save:  DH280.75
L1,224.57
List Price:  L1,749.46
You save:  L524.89
ден3,755.43
List Price:  ден5,365.14
You save:  ден1,609.70
MOP$565.79
List Price:  MOP$808.31
You save:  MOP$242.52
N$1,182.46
List Price:  N$1,689.30
You save:  N$506.84
C$2,579.27
List Price:  C$3,684.83
You save:  C$1,105.56
रु10,484.81
List Price:  रु14,978.94
You save:  रु4,494.13
S/242.34
List Price:  S/346.21
You save:  S/103.87
K302.57
List Price:  K432.26
You save:  K129.69
SAR262.82
List Price:  SAR375.47
You save:  SAR112.65
ZK1,368.62
List Price:  ZK1,955.26
You save:  ZK586.63
L310.66
List Price:  L443.82
You save:  L133.16
Kč1,494.21
List Price:  Kč2,134.68
You save:  Kč640.47
Ft24,015.94
List Price:  Ft34,309.96
You save:  Ft10,294.02
SEK kr664.43
List Price:  SEK kr949.24
You save:  SEK kr284.80
ARS$97,394.05
List Price:  ARS$139,140.33
You save:  ARS$41,746.27
Bs484.35
List Price:  Bs691.95
You save:  Bs207.60
COP$259,186.05
List Price:  COP$370,281.66
You save:  COP$111,095.60
₡32,740.71
List Price:  ₡46,774.45
You save:  ₡14,033.73
L1,855.37
List Price:  L2,650.65
You save:  L795.27
₲457,825.21
List Price:  ₲654,064.06
You save:  ₲196,238.84
$U2,851.34
List Price:  $U4,073.52
You save:  $U1,222.17
zł261.23
List Price:  zł373.20
You save:  zł111.97
Already have an account? Log In

Transcript

Now a simple exercise for you. I hope now all things related to generator are very clear. The exercise is also not going to be very complex, it's rather simple. What you're required to do, you're required to actually test about what you have learned and how you're required to write a generator function which returns the key series. They are calculated using the following formula, the first two numbers of the series is always equal to one, and each consecutive number returned is the sum of the last two numbers. So the first two numbers are one, the first number is one, the second number is one.

The third number is the sum of the first two numbers that is one plus one, two, then the fourth number is two plus one, three, and so on. And you can easily do it the hint is, can you use two variables in the generator function? Yes, you can do it easily. And the second hint is the assignment of variables can be done simultaneously. So at a time you can assign two values to two different variables together. And this is the hint.

It's something very easy to do within three to four lines of code, you can easily do it

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.