The Simple Console Rocket Animation in Python
I have implemented a C/C++ Rocket that launches a rocket in the console in this post: Simple C/C++ Rocket Animation. My sons recently start learning Python programming and I think it would be cool to make a Python rocket version:
Here we go:
# save this as rocket.py
from time import sleep
def printRocket():
print(
"""
_
/^\\
|-|
| |
|N|
|A|
|S|
|A|
/| |\\
/ | | \\
| | | |
`-\\"\\"\\"-`
""")
printRocket()
delay = 300
for i in range(60):
print()
sleep(delay/1000)
delay = delay * 0.9
And here is how it looks like when you launch the rocket simulation by python3 rocket.py
https://helloacm.com/wp-content/uploads/2020/11/rocket-simulation-in-python.mp4
It is a very simple rocket launching code ever. We just wait and print empty lines (that pushes the rocket upward). The time interval between two blank line printing is shorter and shorter (multiplier by 0.9 because the rocket is accelerating faster and faster until it is fully into the sky then we can't see it anymore after 60 empty lines)
--EOF (The Ultimate Computing & Technology Blog) --
Reposted to ALGORITHMS, BLOCKCHAIN AND CLOUD
Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com
My contributions
- Steem Blockchain Tools
- Computing & Technology
- Download Youtube Video
- Find Cheap & Bargin VPS: VPS Database
- Online Software and Tools
Support me
If you like my work, please:
- Buy Me a Coffee, Thanks!
- Become my Sponsor, Thanks!
- Voting for me:
https://steemit.com/~witnesses type in justyy and click VOTE
Alternatively, you could proxy to me if you are too lazy to vote! and you can also vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy
👍
[WhereIn Android] (http://www.wherein.io)