Coding in python

Revision as of 17:20, 3 December 2024 by Isaachus (talk | contribs)

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:

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

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:

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

 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:

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

   print("Nice!  Hi!")

else:

   print("What???")    

[/pywindow][/code]

 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.

[code][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][/code]

   practice:

Try making a code with all of these functions!