Coding in python

Revision as of 17:17, 3 December 2024 by Isaachus (talk | contribs) (Created page with "Welcome to the amazing world of coding! To start, when you are coding on AoPS, use the tag [pywindow][/pywindow]. Here are some of the most basic functions: inpu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Welcome to the amazing world of coding!

         To start, when you are coding on AoPS, use the tag [pywindow][/pywindow].  Here are some of the most basic functions:
 input:
        input will send a pop-up to the top of your screen, and is usually used to ask a question.  Here is a basic example of this term in action:

[pywindow]input("Hello!")[/pywindow]

When using input, format it like this: input("<Text I want to input>")

 print:

Print is a function that will send a message to the bottom of your screen. You format it exactly like input, like this:

[pywindow]print("Hi!")[/pywindow]

 if and else:
         We all know what if and else mean, but the trick is to format them correctly.  This basic code portrays them quite nicely:

[pywindow]q = input("Hi! Can you see this?") if ("yes") in q:

   print("Nice!  Hi!")

else:

   print("What???")    

[/pywindow]

 elif:
         This code term literally means "else if".  It is used when you need to have more than one option of some kind of other function.

[pywindow]q = input("Do you understand this?") q = q.upper()#Don't worry about this part for now if ("yes") in q:

   print("Nice!  Hi!")

elif ("no") in q:

   print("I'm sorry.  D:")

else:

   print("What???")    

[/pywindow]

   practice:

Try making a code with all of these functions!