generated from mwc/lab_names
	name refers to something else. For example. your name refers to you, but you are not the same as your name, being able to change your name and staying as the same person. Variables could be useful in programming when you have to write a lot of code for a specific thing. A function is like a variable, as it assigns a name to a block of code, like how a variable is a name that refers to a value. Functions can be useful when you have to run a specific code block a lot, like when you have to draw a triangle 5 times. Instead of writing the code block 5 times, you can define a function with the triangle code block and you will only have to write the code block once, and will only have to write the function 4 more times.
		
			
				
	
	
		
			24 lines
		
	
	
		
			381 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			381 B
		
	
	
	
		
			Python
		
	
	
	
	
	
# shapes.py
 | 
						|
# ---------
 | 
						|
# By MWC contributors
 | 
						|
 | 
						|
from turtle import *
 | 
						|
 | 
						|
def triangle(side_length):
 | 
						|
    forward(side_length)
 | 
						|
    right(120)
 | 
						|
    forward(side_length)
 | 
						|
    right(120)
 | 
						|
    forward(side_length)
 | 
						|
    right(120)
 | 
						|
 | 
						|
 | 
						|
def rectangle(height, width):
 | 
						|
    forward(height)
 | 
						|
    right(90)
 | 
						|
    forward(width)
 | 
						|
    right(90)
 | 
						|
    forward(height)
 | 
						|
    right(90)
 | 
						|
    forward(width)
 | 
						|
    right(90) |