r/madeinpython • • Oct 23 '20

I created my first project by myself :)

https://github.com/RomanAgne/How-Duck-Are-You-
23 Upvotes

21 comments sorted by

3

u/ZincYellowCobruh Oct 23 '20

It tells you how much of a duck you are

4

u/LordViaderko Oct 23 '20 edited Oct 23 '20

A nice start!

Few tips:

if duckPerc == 100:
    print('You are 100% Duck.')
elif duckPerc == 80:
    print('You are 80% Duck.')
elif duckPerc == 60:
    print('You are 60% Duck.')
elif duckPerc == 40:
    print('You are 40% Duck.')
elif duckPerc == 20:
    print('You are 20% Duck.')
else:
    print('You are not a Duck.')

Can be shortened to:

if duckPerc:
    print(f"You are {duckPerc}% Duck.")
else:
    print('You are not a Duck.')

This "if" works, because in Python "0" is false, while other numerical values are true. So if duckPerc is 0, "else" will be executed. I think you definitely want to learn about f-strings in Python. These are very cool and useful, you can basically insert any variable you want into text.

Also, these lines:

Yes == True
No == False

in each question are useless, they can be safely removed.

Also also, this is not how you use a class, it is not necessary here. Just remove "class Duck" and move what's inside one tab to the left.

But overall, nice code for a first project! Well done.

2

u/ZincYellowCobruh Oct 23 '20

Thank you! I figured there was a simpler way of doing it

3

u/hayhay1231 Oct 23 '20

apparently, i am %20 duck 😎 very nice!

2

u/ZincYellowCobruh Oct 23 '20

Which part?

2

u/hayhay1231 Oct 23 '20

what do you mean?

1

u/ZincYellowCobruh Oct 23 '20

I was starting with something simple :)

1

u/ZincYellowCobruh Oct 23 '20

Do you know which question you got right?

3

u/kasauli150 Oct 23 '20

He's probably being watched or going quackers....

1

u/hayhay1231 Oct 23 '20

Feathers? no corkscrew penis? yes caw? yes gone quackers? yes being watched? no i am %20 duck

1

u/ZincYellowCobruh Oct 23 '20

It was the corkscrew penis lmao

2

u/hayhay1231 Oct 23 '20

what can i say ¯_(ツ)_/¯

2

u/kasauli150 Oct 23 '20

So closeeeee..... Damnit

4

u/kasauli150 Oct 23 '20

Quack quack 😂😂

3

u/kasauli150 Oct 23 '20

But seriously, it's good that you're starting something new and hope you'll take it further....

Edit: I meant about programming, I don't think there's anything else left of being a duck.... 😂😂 Nice concept though...

2

u/CraigAT Oct 23 '20

Duck? Duck? No!

2

u/LazaroFilm Oct 23 '20

What does it do?

1

u/CraigAT Oct 23 '20

A quacking start!

Some suggestions: I'd keep the program name simple, move "first program" into comments within the program, there are definitely opportunities to reduce repetition too. Nice effort.

0

u/ZincYellowCobruh Oct 23 '20

Do you know which question?