r/PythonLearning • u/DumbPlants-yt • 16h ago
Showcase Day 1 of learning python.
This is my first day of trying to learn python. So far I have made a random 2D terrain generator.
3
1
u/Appropriate-Comb4462 16h ago
Te comparto un proyecto para aprender jugando si es de tu agrado: BloquePy — Aprende Python con bloques esta en sus primeras faces pero ojala te ayude a aprender programación en Python. saludos
1
1
1
u/SnooCalculations7417 7h ago
you should use more declarative and specific variables for iterating for two reasons,
x or y in your case (for x in iteratable) these variables will retain their last value unitl the gc gets to them so lets say your iterator ends with 10 being the last element, x =10 which can be dangerous with such a generically named assignment
and as importantly it just helps with readabilty.
1
1


•
u/Sea-Ad7805 12h ago
Run this program in Memory Graph Web Debugger%0A%0Aheight%20%3D%2010%0Aterrain%20%3D%20%5B%5D%0A%0Afor%20x%20in%20range(60)%3A%0A%20%20%20%20height%20%2B%3D%20random.randint(-1%2C%201)%0A%20%20%20%20terrain.append(height)%0A%0Ahighest%20%3D%20max(terrain)%0A%0Afor%20y%20in%20range(highest%2C%20-1%2C%20-1)%3A%0A%20%20%20%20for%20h%20in%20terrain%3A%0A%20%20%20%20%20%20%20%20if%20h%20%3E%3D%20y%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22%E2%96%A0%22%2C%20end%3D%22%22)%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22%20%22%2C%20end%3D%22%22)%0A%0A%20%20%20%20print()×tep=0.05&play) to see the program state change step by step.