All language subtitles for 033 [Interactive Coding Exercise] Pizza Order Practice.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

1

All right, guys, are you ready for another challenge? In this challenge,

2

you are going to be building a Pizza Order program.

3

So we're going to ask the user what size pizza they want, small, medium,

4

or large, whether if they want to add pepperoni to it and whether

5

if they want extra cheese.

6

So based on the user's input for each of these variables, and the inputs going to

7

come in the form of a single capital letter, S, M, or L, Y or N.

8

Based on their input,

9

we're going to try and figure out what the final bill is going to come to.

10

And you can take a look at the prices over here.

11

So, if you want to add pepperoni for a small pizza, it's a $2, medium,

12

or large pizza is $3, and an extra cheese is $1 for any size.

13

So you're going to use what you've learned about multiple if statements,

14

as well as everything from previously in order to be able to create this so that

15

if the user types in, for example, this input,

16

large, pepperoni with no extra cheese, then it should print out

17

Your final bill is $28. Have a look at the examples and the hints

18

and go ahead and solve this coding challenge.

19

All right,

20

so this one shouldn't be too hard and we're going to start off by creating our

21

first if statement where we're going to check out what is the size of the pizza

22

that they chose so we can assign the price to that pizza.

23

If the size is equal to S, that means they ordered a small pizza,

24

well in this case, the price should be $15, right? Now,

25

we're going to create a variable up here before the if statement so that we can

26

keep track of the bill.

27

So size S, the bill is going to be increased by $15.

28

Now you can, of course, simply just set the bill to $15 in this case,

29

but because we've got a lot of things that can change the bill,

30

it's easier to simply just add 15 to what it is currently using the plus equal

31

sign that you learned about.

32

Then we're going to check with an elif. Elif

33

the size is equal to M, so if they chose a medium pizza instead,

34

then the bill is going to increase by $20 instead.

35

And finally, for all other cases, namely,

36

if they'd got a large size pizza,

37

then we're going to increase the bill by, um,

38

$25. Now,

39

notice how here you could have also used an elif and said elif size equal

40

to L, um, well, in that case,

41

the bill increases by $25 and you don't actually need an else statement.

42

It's not required.

43

If you feel like it's easier to read like this, small,

44

medium, large, and what should happen for each case,

45

then you can just leave it like this. But of course,

46

there is an argument to be made that the user might have typed something wrong,

47

right? They might've typed a lowercase letter,

48

they might've typed a completely different letter. So in future lessons,

49

we're going to show you how you can catch these cases and how you can deal with

50

it. But for now, let's just keep our program as simple as possible.

51

If they type the wrong letter, instead of S, M, or L,

52

then we're just going to overcharge them.

53

So now that we've established what the basic price for their pizza is,

54

we're going to look through the ad-ons.

55

We're going to see if they said they wanted to add pepperoni.

56

So if add pepperoni is equal to Y, well,

57

in that case,

58

we're going to need to check if they have a small pizza or a medium,

59

or large pizza, 'cause the price is different.

60

So we're going to have a nested, if function in here.

61

We're going to say if add pepperoni is equal to Y,

62

and then if the size is equal to S, well,

63

in this case, we're only going to add, um, $2 to the bill.

64

But if the size was any other size, basically medium or large,

65

so we can catch that using just an L statement

66

instead of creating three separate, if sizes S, if sizes M, et cetera.

67

And in this case, we're going to add $3 to the bill.

68

So now we've got this case covered.

69

The final thing is whether if they said they wanted extra cheese or not.

70

So if they did, in fact, want extra cheese,

71

well,

72

in that case, all we have to do is just add $1 to the bill.

73

So these are three separate sets of if statements;

74

this one, this one, and this one.

75

And by the end of all of these if statements,

76

as long as we're at the right indentation level

77

namely right next to the gutter here,

78

then we can go ahead and calculate their bill and print it out for them.

79

So we can say print,

80

and I'm going to use an f-string to insert the bill in here, print

81

Your final bill is,

82

and then I'm going to add a dollar sign, and then inside the curly braces,

83

I'm going to put it in the current value of the bill after all of these

84

calculations. So did you manage to get it right?

85

Did you manage to use a combination of if statements and elif statements,

86

um, nested if statements, or did you do it in a different way?

87

And it's totally cool if you did. As long as it does what it's supposed to do,

88

then it doesn't really matter whichever format of your code

89

you decide to go for it. And as a matter of fact,

90

there's loads of ways that you could have written this code to get this

91

functionality. Some of them will be slightly more readable,

92

some of them will be slightly less readable.

93

So, it's a case of you making a good judgment on that and choosing the code that

94

makes the most sense to you. Now in the next lesson,

95

I want to talk a little bit about combining different conditions so that we can

96

use something called a logical operator to check for multiple conditions in the

97

same line of code. So, for all of that and more, I'll see you on the next lesson,

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.