Categories
Python programming

The basics of the Python programming language

Here is some code to help you start programming in python

print('Hello World')

This prints the text you put in the single or double quotes, it can also be written as

X='Hello World'
print(X)

X is the name of the variable. A variable stores data which can be text, numbers, a charecter / letter or booleans (true or false). A variable can have any name from a short name like (A or X) or a long name like (Amazing_variable). Python variables are case sensitive so X would be a diffrent variable from x.

Y = 11
X = 12
if Y > X:
 print ("Y is bigger than X")
else:
 print ("Y is smaller than X")

This is an if / else statement. It says that if the conditions are met to the if statment it will do the command or it will use the else command. If statments don’t need else to function you can also write.

Y = 11
X = 12
if Y > X:
 print ("Y is bigger than X")

But in our case as the conditions don’t meet, it will not print anything. There is also elif which says else if the first contion is not met it will try the second condition

Y = 12
X = 12
if Y > X:
 print ("Y is bigger than X")
elif Y == X:
 print ("Y is equal to X")
else:
 print ("Y is smaller than X")

Because Y and X are equal than it prints Y is equal to X . I will make more python programming post soon.

Leave a Reply

Your email address will not be published. Required fields are marked *