Back to Browse

The PERFECT Beginner Coding Exercise in Python | Python Programming Tutorial for Beginners

578 views
Jun 28, 2019
11:12

👇 Solution Code provided below This is the perfect beginner coding exercise in Python that will get you familiar with coding fast! A Python Programming Tutorial for Beginners! You can follow along with any online Python 3 compiler. No installation required! Links are in the description below. Subscribe to Apptato for more Python Tutorial for Beginners! Print the following shapes with width n (Where n is an integer greater than or equal to 0) A line, square, right triangle, pyramid, diamond 💻 Solution Code: def printLine(n): print("x"*n) printLine(5) def printSquare(n): for x in range(n): printLine(n) printSquare(5) def printTriangle(n): for x in range(n): printLine(x+1) printTriangle(5) def printPyramid(n): for x in range(n): print(" "*(n-x-1) + "x "*(x+1)) printPyramid(5) def printDiamond(n): printPyramid(n) for x in range(n): print(" "*(x+1) + "x "*(n-1-x)) printDiamond(5) 💻 Output: #1 Line xxxxx #2 Square xxxxx xxxxx xxxxx xxxxx xxxxx #3 Right Triangle x xx xxx xxxx xxxxx #4 Pyramid x x x x x x x x x x x x x x x #5 Diamond x x x x x x x x x x x x x x x x x x x x x x x x x 💻 Reference Code: #Quick Python 3 Refresher #Print print("Hello World") print("Hello","World") print("Hello" + " World") #For Loop for x in range(5): print(x) #Functions def myFunction(n): print("My Function:") for x in range(n): print(x) myFunction(3) 🔗 Links: Online Compiler: https://www.onlinegdb.com/online_python_compiler Apptato Links: Website: http://www.apptato.com YouTube: https://www.youtube.com/apptato Twitter: https://www.twitter.com/apptato Facebook: https://www.facebook.com/apptato Instagram: https://www.instagram.com/apptato #CodingTutorial #pythontutorialforbeginners #PythonForBeginners

Download

0 formats

No download links available.

The PERFECT Beginner Coding Exercise in Python | Python Programming Tutorial for Beginners | NatokHD