Aug 10, 2024
.py
.print("hello, world")
python hello.py
.print()
input()
to prompt users for input (e.g., "What's your name?").=
to store values from right to left.name = input("What's your name?")
#
and are ignored by the interpreter.print(f"hello, {name}")
using f-strings for cleaner output.strip()
, capitalize()
, title()
).split()
can break strings into smaller substrings.first, last = name.split()
to separate first and last names.int
) and floating-point numbers (float
).+
), subtraction (-
), multiplication (*
), division (/
).%
) gives the remainder of the division.x = float(input("What's x? "))
y = float(input("What's y? "))
print(x + y)
def
.def hello(name):
to say hello to a specific user.return
keyword.name
variable).