Python program for beginners - Bakery CakeShake - 10% to @steem.skillshare


Setting 10% of the payout to @steem.skillshare


image.png

Source


Hello everyone, it's my first tutorial in skillshare community. Today I'm going to write a post about a simple program of python named as bakery that uses;

  • print statement
  • Break keyword
  • if and else and elif conditions
  • loops
  • Counter

DISPLAY OPTIONS


This code Displays the options for the user that are available to select.


print('''Welcome to CakeShake!!
We offer the following savouries:
1)Cake(Price: 650/-,Net weight 2lbs
2)Cookie Jars(Price: 240/-,Quantity: 1 jars
3)Sandwitches(Price: 100/-,Serves 1
4) Exit from the market''')


Bill is just a counter that we have set to 0 and a while loop have set. While loop is an infinite loop that can only be finite if you give some conditions.


bill = 0
while True:


The input value must be in integer and that will be assigned to the variable 'n'.


    `n = int(input("Enter your choice number: "))`

The if keyword is a conditional keyword that means in this statement if the user entered 1 then ask the users how many cakes do they want.


`if n == 1:`
    `cake = int(input("How many cakes: "))`

And if they select some amount then proceed with the total amount by incrementing the number of cakes multiple hy the price of it, that we have assigned 6 STEEM. and then print the bill.


    `bill += cake*6`
   ` print("Bill:", bill)`

Elif is used after if when we are conditioning the statements. That statement means if the person selected the 2 option then ask the number of cookies he/she want.


elif n == 2:
cookie = int(input("How many cookie:"))


  `  bill += cookie*2`
 `   print("Bill:", bill)`

And if they select some amount then proceed with the total amount by incrementing the number of cakes multiple hy the price of it, that we have assigned 2 STEEM. and then print the bill.


`elif n == 3:`
   ` sandwich = int(input("How many sandwicch:"))`

That statement means if the person selected the 3 option then ask the number of sandwiches he/she want.


bill += sandwich*100
print("Bill:", bill)


And if they select some amount then proceed with the total amount by incrementing the number of cakes multiple hy the price of it, that we have assigned 1 STEEM. and then print the bill.


If a person want to exit then he/she will choose 4. Then our program will print Thanks for coming and then this break keyword take the user out of the while loop we set above.


elif n == 4:
print("Thanks for coming")
break


Else if a user print anything other than 1,2,3,4 then this will show choose a different number.


else:
print("Choose a different number")


image.png

FULL SOURCE CODE (not intended because steemit wasn't allowing gap)


print('''Welcome to CakeShake!!
We offer the following savouries:
1)Cake(Price: 650/-,Net weight 2lbs
2)Cookie Jars(Price: 240/-,Quantity: 1 jars
3)Sandwitches(Price: 100/-,Serves 1
4) Exit from the market''')

bill = 0

while True:
n = int(input("Enter your choice number: "))
if n == 1:
cake = int(input("How many cakes: "))
bill += cake*650
print("Bill:", bill)
elif n == 2:
cookie = int(input("How many cookie:"))
bill += cookie*240
print("Bill:", bill)
elif n == 3:
sandwich = int(input("How many sandwicch:"))
bill += sandwich*100
print("Bill:", bill)
elif n == 4:
print("Thanks for coming")
break
else:
print("Choose a different number")


image.png

THANKS FOR VISITING
WITH BEST REGARDS,
VVARISHAYY

Sort:  

To make indentation work with markdown you can use:

```
[ code ]
```

or

~~~
[ code ]
~~~


if ( test )
{
    print( "works!" );
}

Thank you. Noted 👍

Thank you for all the supports you have given to Steem Sri Lanka ! This little souvenir to celebrate your generosity... We wish you all the success!

kotiya.jpg

From,
Steem Sri Lanka Community

Wow friend is awesome!

Thank you, I'll share more soon✌️

Wao, @vvarishayy this is good post for beginners wants to learn about python programming, i also have some good knowledge about this,
As i am new on @steemit, i needed some guidelines from seniors,
Regards,
@msalmanjaved

You can contact me on Discord
username vvarishayy#3781

Coin Marketplace

STEEM 0.15
TRX 0.17
JST 0.028
BTC 68761.82
ETH 2460.81
USDT 1.00
SBD 2.38