PDA

View Full Version : Short Python intro.



ModSim
01-29-2016, 07:33 AM
EMPTY THREAD. I messed up this tutorial.

VendLolx
01-30-2016, 04:39 PM
Hi guys! I am doing a small introduction to the language of Python! So, this will work on ipad, PC, or Mac. Head over and download Python from their website python.org. So, depending on what you are using it on ( I only use iPad ) you should have a code window. We are going to jump straight into some things.

Function: string (Usage: string("Text")
Function: input (Usage: input("Do you want money? ")

So we will make a dialog system with 2 functions.

String just generates text, input generates text that allows you to type stuff.

So our first line of code, we will do a comment. To do it, simply put a # in front.



#First Python code!


So, we have our comment, now we assign a variable. It's super simple, just do this.



#First Python code!
input_1 = input("Hi, what is your name? ");


So, input_1 is our variable. The code assigned to it is an input. So when you run the console application, it will ask your for your name. Then type it.

Next bit of code, we add strings, another variable with input assigned, and if statements!



#First Python code!
input_1 = input("Hi, what is your name? ");
print("Hello "+input_1+"!");
#Use whatever question you want here.
input_2 = input("Choose 1 for my name, 2 for my mums name, and 3 for my dads name.");


So, we added our print string, and a second variable set with an input, so now we do our if statements t declare what happens when the number is chosen.



#First Python code!
input_1 = input("Hi, what is your name? ");

print("Hello "+input_1+"!");

#Use whatever question you want here.
input_2 = input("Choose 1 for my name, 2 for my mums name, and 3 for my dads name.");

if(input_2 == 1) :
print("My name is Py!");

input_2 = input("Choose 1 for my name, 2 for my mums name, and 3 for my dads name.");

if(input_2 == 2):
print("My mums name is Th!");

input_2 = input("Choose 1 for my name, 2 for my mums name, and 3 for my dads name.");

if(input_2 == 3):
print("My dads name is On!");

print("Bye!");

exit();


Try running it, and play around with the code some. I will start an RTsoft series on making a 2d Python platformer! Stay tuned for more!

I will Try THIS "Python"

VendLolx
01-30-2016, 07:36 PM
I will Try THIS "Python"

THIS "Python" is Very hard.

ModSim
01-30-2016, 08:59 PM
THIS "Python" is Very hard.

This "Python" is the simplest language other than GML. There is alot more to the language than this, but this shows the console functions.

ModSim
01-31-2016, 03:10 AM
I learn python and i guess its the easiest :prophet:

I just started learning Python, this tutorial was stupid. I completely left out the fact that on PC, you can install libraries like pygame, py2exe, cx_Freeze, Panda3D, ect.

MyLegGuy
01-31-2016, 05:54 AM
I just started learning Python, this tutorial was stupid. I completely left out the fact that on PC, you can install libraries like pygame, py2exe, cx_Freeze, Panda3D, ect.

If you just started, why are you already making a tutorial?

ModSim
01-31-2016, 06:57 PM
If you just started, why are you already making a tutorial?

Dude, back off m8. If you don't like my post, then don't look at them. You have an argument about every post I make.