generated from mwc/lab_names
	I chnaged and wrote new codes for finding circle area and shapes drawing.
A value is a data that the variable stores like 1 or "hello".A name is a label that shows the value. A situation where its important to distiguish between a name and a value is when buying a drink. The name on the juice tells you ehat type of frink it is and the value is the juice inside the bottle. Its important to use variables in programming because it makes it easier to read and understand the code that is being written. If you just write the value without labeling it, it won't be possible to know what the value stands for if you have more than one. A function is like a variable because both store something in them like a block of code or a value. A function helps to solve a problem in smaller section separetely rather then doing a big problem together. For example, instead of drawing both the triangle and rectangle in one function we did in two separately function to make is simplier to do.
This commit is contained in:
		@@ -4,3 +4,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
print("This program will calculate the area of a circle.")
 | 
					print("This program will calculate the area of a circle.")
 | 
				
			||||||
radius = float(input("What is the circle's radius? "))
 | 
					radius = float(input("What is the circle's radius? "))
 | 
				
			||||||
 | 
					pi=3.14
 | 
				
			||||||
 | 
					circle_area=pi*radius*radius
 | 
				
			||||||
 | 
					print(circle_area)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,17 +7,17 @@ from shapes import triangle, rectangle
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def flyto(x, y):
 | 
					def flyto(x, y):
 | 
				
			||||||
    penup()
 | 
					    penup()
 | 
				
			||||||
    goto(x, y)
 | 
					    goto(x,y)
 | 
				
			||||||
    pendown()
 | 
					    pendown()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
flyto(-100, 0)
 | 
					flyto(100, 0)
 | 
				
			||||||
triangle(40)
 | 
					triangle(90)
 | 
				
			||||||
triangle(60)
 | 
					triangle(100)
 | 
				
			||||||
triangle(80)
 | 
					triangle(90)
 | 
				
			||||||
triangle(100)
 | 
					triangle(100)
 | 
				
			||||||
flyto(100, 0)
 | 
					flyto(100, 0)
 | 
				
			||||||
rectangle(10, 90)
 | 
					rectangle(10, 90)
 | 
				
			||||||
rectangle(20, 80)
 | 
					rectangle(50, 80)
 | 
				
			||||||
rectangle(30, 70)
 | 
					rectangle(30, 70)
 | 
				
			||||||
rectangle(40, 60)
 | 
					rectangle(40, 60)
 | 
				
			||||||
rectangle(50, 50)
 | 
					rectangle(50, 50)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,6 @@
 | 
				
			|||||||
# ------------
 | 
					# ------------
 | 
				
			||||||
# By MWC contributors
 | 
					# By MWC contributors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my_name ="Chris"
 | 
					my_name = input("What is your name?")
 | 
				
			||||||
greeting = "Hello, " + my_name
 | 
					greeting = "Hello, " + my_name
 | 
				
			||||||
print(greeting)
 | 
					print(greeting)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								shapes.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								shapes.py
									
									
									
									
									
								
							@@ -5,7 +5,18 @@
 | 
				
			|||||||
from turtle import *
 | 
					from turtle import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def triangle(side_length):
 | 
					def triangle(side_length):
 | 
				
			||||||
    pass
 | 
					    forward(side_length)
 | 
				
			||||||
 | 
					    left(120)
 | 
				
			||||||
 | 
					    forward(side_length)
 | 
				
			||||||
 | 
					    left(120)
 | 
				
			||||||
 | 
					    forward(side_length)
 | 
				
			||||||
 | 
					    left(120)
 | 
				
			||||||
def rectangle(height, width):
 | 
					def rectangle(height, width):
 | 
				
			||||||
    pass
 | 
					    forward(width)
 | 
				
			||||||
 | 
					    left(90)
 | 
				
			||||||
 | 
					    forward(height)
 | 
				
			||||||
 | 
					    left(90)
 | 
				
			||||||
 | 
					    forward(width)
 | 
				
			||||||
 | 
					    left(90)
 | 
				
			||||||
 | 
					    forward(height)
 | 
				
			||||||
 | 
					    left(90)
 | 
				
			||||||
		Reference in New Issue
	
	Block a user