How to LEARN PYTHON the COOLJAMES way (Lesson 1 - Sequence)
Welcome to another @CoolJames1610 tutorial :P :P :P
Now, I am going to teach you how to PYTHON the COOLJAMES way
(which is cool)
Lesson 1 - Sequences
So, the first lesson will be about sequences.
But first let's go over some key terms.
- Declaring variables.
Unlike other PL's, in Python you do not need to add BOOL, or STR, or INT before you declare a variable. Python automatically knows which data type you enter in.
Arithmetic is mainly the same across PL's.
These are a few of the keywords in Python. You cannot declare these variables
etc... I can't remember all xD
Okay, I think that is all for the basics, now onto sequences...
A sequence is just commands all after each other
So in this program, Python will output 'Hello World', then assign '"James"' to x and then out put 'Hello" added with the value attached to x
Python is quite simple xD
Now let's move onto input from the user.
All you have to do to get input from the user is:
This will prompt your user to enter something.
Now this wouldn't be very helpful as nothing is telling the user to input something.
We can add text to the input
As you can see, I have left a space after the colon. This is better to do as the program will look neater.
See? :D Much neater :P
I'm tired of people not adding a space or something lol
Okay now, I'll talk briefly about concatenation.
This is combining different data types together.
Say I asked the user for their age and I wanted to say: "Oh nice, I am also " (user's age), most people may just do:
Here we would get an error.
In Python, if you are outputting to the screen, everything has to be the same data type.
"Oh nice, I am also" is a string
x is an integer.
To get round this problem, we can
cast x to a string so that we can use it to say something.
All we need to do is
str(x). This changes x to a string and can be used.
Ahaha no error ;)
We can cast a string to an integer but only if it is a whole number (e.g. not a decimal)
Here, x is a whole number so we can cast it as an integer.
(Would output 340 in case you wanted it :P)
There are also the
I think that is it for today's tutorial
I know this isn't good and not in depth but I DON'T CARE xD
This is how I kinda learnt Python and I've learnt a lot xD
Erm, please upvote so that
amasd can comment again people can see and learn :)
Lesson 2 will be about Selection (if, elif, else)