generated from mwc/lab_names
	For greetings.py I changed the code so that it
always greets me by name. Now, when I run the program, it automatically prints "Hello Angelo". Checkpoint 1: A value is the acutal data, like the number 5 or the text "Angelo". A name is a label that refers to the value. For example, in my_name = "Angelo", the value is "Angelo" and the name is my_name. An everyday example is a mailbox. The name on the mailbox shows whose mail it is, while the letters inside are the actual content. Changing the name doesn't change the letters so it is important to distinguish between the two. Variables are useful in programming because they let you give a name to a value, making your code easier to read, understand, and reuse. Instead of repeatedly typing the same value, you can use a name that represents it, which makes it easier to update the value in one place if it changes. Checkpoint 2: A function is like a variable because it has a name that refers to a piece of code, just like a variable has a name that refers to a value. Once you define a function, you can use its name to run the code it contains, without rewriting the same instructions each time. Functions are helpful because they let you break a big problem into smaller, easier steps. For example, if you want to find the area and perimeter of many circles, you can make one function to calculate the area and another to calculate the perimeter. Then you can use these functions whenever you need them without rewriting the same code.
This commit is contained in:
		@@ -4,3 +4,8 @@
 | 
			
		||||
 | 
			
		||||
print("This program will calculate the area of a circle.")
 | 
			
		||||
radius = float(input("What is the circle's radius? "))
 | 
			
		||||
 | 
			
		||||
pi = 3.141592653
 | 
			
		||||
circle_area = pi * radius * radius
 | 
			
		||||
 | 
			
		||||
print("The area of the circle is:", circle_area)
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,6 @@
 | 
			
		||||
# ------------
 | 
			
		||||
# By MWC contributors
 | 
			
		||||
 | 
			
		||||
my_name ="Chris"
 | 
			
		||||
my_name ="Angelo"
 | 
			
		||||
greeting = "Hello, " + my_name
 | 
			
		||||
print(greeting)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								poetry.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								poetry.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand.
 | 
			
		||||
package = []
 | 
			
		||||
 | 
			
		||||
[metadata]
 | 
			
		||||
lock-version = "2.1"
 | 
			
		||||
python-versions = ">=3.10,<4.0"
 | 
			
		||||
content-hash = "7b8fc01b274bd807fb00372bbc8e138330f15ae7978ed61e180f3b17ec076725"
 | 
			
		||||
		Reference in New Issue
	
	Block a user