In Python, there is no difference between using double quotes ("Samson") and single quotes ('Samson') when defining a string. Both represent the same type of string object.
print("Samson") # Output: Samson
print('Samson') # Output: Samson
In Python, __init__ is a special method used in classes. It’s often called the constructor, because it runs automatically whenever you create a new object (an instance) from that class.
In Python, class names are typically written with a capitalized first letter.
Class: A blueprint or template. It defines what attributes (data) and methods (behavior) its objects will have.
Object: A specific instance created from that class. Each object has its own data but follows the structure defined by the class.
machine: a piece of equipment with many parts that work together to do a particular task. The power used to work a machine may be electricity, steam, gas, etc. or human power.
mechanics [uncountable] the science of movement and force
mechanism: a method or a system for achieving something
country in southern Asia bordering the Arabian Sea; originally comprising two parts—West Pakistan (now Pakistan) and East Pakistan (now Bangladesh)—separated by about 1000 miles (1600 kilometers) of northern India; a dominion 1947–56, an Islamic republic since 1956, and a member of the Commonwealth of Nations 1956–72; formed from parts of former British India; capital Islamabad area 307,374 square miles (796,095 square kilometers), population 207,863,000
www.merriam-webster.com/dictionary
巴勒斯坦
Palestine
Palestine, region of Southwest Asia along the eastern Mediterranean, generally regarded as consisting of the southern coastal area between Egypt, where Asia meets Africa, and Tyre, which in ancient times was the most prominent of the Phoenician city-states.
- Runs the current cell and moves to the next one.
- Equivalent to executing code in that cell.
- VS Code (with Python extension)
- By default, it can send selected code to the terminal or Python Interactive window.
- Sometimes it runs code in the terminal instead of the interactive window, depending on your settings.
- You can customize this in Keyboard Shortcuts by mapping Shift + Enter to Python: Run Selection/Line in Python Interactive Window.
In Python, the keyword def is used to define a function. Functions are reusable blocks of code that perform a specific task when called
In Python, the return statement is used inside a function to send a value back to the caller. It’s one of the most important ways to control the flow of data in your program.
Examples
Returning a value:
def square(n):
return n * n
result = square(4)
print(result) # Output: 16
append something (to something) to add something to the end of a piece of writing
def greet(name):
print("Hello,", name)
x = greet("Samson")
print(x) # Output: None
- Use return when you want your function to produce a value that can be used later.
- Skip return when your function’s job is just to perform an action (like printing or updating a file)
- With return → function is like a vending machine (you get something back).
- Without return → function is like a loudspeaker (it just outputs sound, but you don’t get a reusable object).
Unlike many other programming languages, Python uses indentation to define code blocks instead of braces {} or keywords. This makes indentation not just stylistic, but syntactically required.