r/madeinpython • u/ZincYellowCobruh • Oct 23 '20
I created my first project by myself :)
https://github.com/RomanAgne/How-Duck-Are-You-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 == Falsein 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
3
1
1
u/ZincYellowCobruh Oct 23 '20
Do you know which question you got right?
3
1
u/hayhay1231 Oct 23 '20
Feathers? no corkscrew penis? yes caw? yes gone quackers? yes being watched? no i am %20 duck
1
4
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
2
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
3
u/ZincYellowCobruh Oct 23 '20
It tells you how much of a duck you are