I need help with the basics of python language

Question:


Repl link:

code snippet

Can i have the basics of python like just how it works

1 Like

Hey @LeonCampbell3! Welcome to the community!

You can check out the official Python website for getting started: Python For Beginners | Python.org

Or you can visit Replit’s 100 Days of Python at https://replit.com/learn/100-days-of-python/hub to also learn how to use the Replit IDE while learning Python as @OmegaOrbitals suggested.

7 Likes

I could help you learn python since I am an expert at it!

1 Like

Welcome to the community! You’re in luck as there are many people on Replit that know Python (including me), and many of them know it well or are even masters at it. Finding a tutorial online at a reputable site such as w3schools could help you.

For a really basic overview, here’s my attempt:

# Anything after a hashtag is a comment. The program will
# ignore it and NEVER execute it. Comments are used
# to help people read code.

def main(): # Here, we define a new function called "main".
  greeting = "Hello world!" # This line MUST be indented,
  # as Python relies upon indents. Here, we assign the
  # text "Hello world!" to a variable called "greeting".
  print(f"{greeting} How are you doing?") # Here, we use
  # the "print" function, which displays text. The "f"
  # before the quotes (called an f-string) allows you
  # to use variables inside your string (the text). Thus,
  # by putting the name of our variable ("greeting") in
  # {} in the f-string, it will display that inline with
  # the rest of the text.
main() # Since "main" is a function, we have to call it
# (run it). This is done like so.

# Note that this is meant to overview several concepts
# at once. Normally, this output would be achieved with
print("Hello world! How are you doing?")

# You can also give your function parameters:
def main(greeting): # Create our main function, this
  # time with a parameter ("greeting").
  print(f"{greeting} How are you doing?") # use the
  # same "print" function as before. "greeting" is
  # already a variable now that it is a function
  # parameter and we don't need to define it.

main("Hello world!") # This time, we need to put
# something in our parentheses (that assigns it
# to our parameter "greeting".

All three of these methods display “Hello world! How are you doing?” in the console. This is a very basic overview of how functions and variables work. I suggest finding a tutorial for more in-depth learning. Feel free to come back to Ask with any questions that may arise. That’s what we’re here for.

3 Likes

You can also use Replit’s One Hundred Days of Code Course! https://replit.com/learn/100-days-of-python/hub

4 Likes