Difference between revisions of "Coding in python"

(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...")
 
m
Line 6: Line 6:
 
         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:
 
         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]
+
[code][pywindow]input("Hello!")[/pywindow][/code]
  
 
When using input, format it like this:   
 
When using input, format it like this:   
Line 15: Line 15:
 
Print is a function that will send a message to the bottom of your screen.  You format it exactly like input, like this:
 
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]
+
[code][pywindow]print("Hi!")[/pywindow][/code]
  
 
   if and else:
 
   if and else:
Line 21: Line 21:
 
           We all know what if and else mean, but the trick is to format them correctly.  This basic code portrays them quite nicely:
 
           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?")
+
[code][pywindow]q = input("Hi! Can you see this?")
 
if ("yes") in q:
 
if ("yes") in q:
 
     print("Nice!  Hi!")
 
     print("Nice!  Hi!")
 
else:
 
else:
 
     print("What???")     
 
     print("What???")     
[/pywindow]
+
[/pywindow][/code]
 
 
 
   elif:
 
   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.
 
           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?")
+
[code][pywindow]q = input("Do you understand this?")
 
q = q.upper()#Don't worry about this part for now
 
q = q.upper()#Don't worry about this part for now
 
if ("yes") in q:
 
if ("yes") in q:
Line 40: Line 39:
 
else:
 
else:
 
     print("What???")     
 
     print("What???")     
[/pywindow]
+
[/pywindow][/code]
  
 
     practice:
 
     practice:
 
Try making a code with all of these functions!
 
Try making a code with all of these functions!

Revision as of 17:20, 3 December 2024

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!