Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Integers= are full numbers with no decimals.

Floats= are numbers with decimals, centesimals, etc….

Boolians= are words lol.

1 price =10

2 print( price )

En result is:

10

Input: is used to make a text that will relate to a variable, for example if you make a variable like “age”, you’d input the
command, age = input(‘what is your age? ‘), and then the program when you run it will ask you the same question that
comes inside the parenthesis on input, whatever you write will be determined as your variable, in this case “age”.

1 age = input(‘what is your age? ‘)

2 print(‘You´re ’ + age + ‘ years old’)

End result should be:

You´re 20 years old

If you were to input 20 of course.

Also pay attention to the spaces and commas.

When you want your variable to be an integer, a float or a boolian, you have to put the int=, float=, or bool=, command
before it, for example

1 birth_year = input(‘¿what is your birth year? ‘)

2 age= 2023 – int(birth_year)

3 print(age)

End result is:

“21”

“-“ is for subtracting

“+” is for adding

“*” is for multiplication

If you want to put an apostrophe on a word on a string, you´ll have to put a double apostrophe on the outside so it can
work example: ‘ python’s the best course for beginners’, that will end up as an error, what it should look like is “python´s
the best course for beginners”. But let´s say you want to use apostrophes and double apostrophes multiple times in the
same sentence, you´ll have to alternate between using the apostrophes and the double apostrophes on the outer sides
depending on what you want in your text.
For some reason when you open a bracket inside the parenthesis on print and type a number, it will only show the letter
depending the number for example:

1 variable= (‘suck my cock’)

2 print(variable[0])

End result is:

It starts from 0 and onwards, if you were to put a negative number it would start from the last letter in the sentence. For
example if you were to put “-3” in the bracket the end result would be:

and if you were to put “x number :y number” in the bracket, it would display the characters that in start, in between and
finish relating to the values you placed.

If you were to put print(variable[8:12]) the end result would be:

cock

if you were to put (variable[0:]) the end result would be:

suck my cock

print(variable[1:]) the end result would be:

uck my cock

there are more situations as when you place a negative number, and if you place only a number on the right side of the
“:”, but that will come to you naturally as you practice.

1 course = (‘python suck my cock’)

2 another= course [:]

3 print(another)

The end result would be:

Python suck my cock

I don’t know why that happens, you don’t have any volume in the library you’re at, so whatever, try to figure that out
later. Just figured it out, not as practical as I thought it would be but it´s a discovery

36:26

Use curly brackets “{ }” inside variables so you don’t have to use plus signs on a string to make a text. But you must start
the string with an f’’, or else it won’t work.

1 first= john

2 last= smith

3 msg= f’ {first} {last} is a coder’

4 print(msg)

The end result is:


john smith is a coder

you can use the command “print(len(variable))” so it can tell you the number of characters in a sentence.

And there are also methods that work for example after typing the variable inside print you can place a “.” And it will
show you different methods, one of them could be turning your whole text into upper or lowercase letters, and etc.

Like the method “.find” will help you find the index of the first letter you place in it.

Like if you used it on the phrase “suck my cock” and use the .find(k) method so now what your program will tell you is
“3” because that’s the index value on the first k that appears in the sentence. 44:44

Python does follow arithmetic sign laws.

All signs work well, but the only thing with division is that you use only one dash “/” for float numbers division, and you
use two dashes “//” for integer number divisions.

The percent sign “%” is a modulus sign that will tell you the remainder of a division, for example “print(10%4)” will give
you a “2” because 4 only fits inside of 10 twice and the remainder would be 2, if you were to replace the 4 with a 2 in the
function, the end result would be 0 being that 2 fits perfectly inside of 10 five times.

When you want to multiplicate a number to the power of something, you wont use the “^” sign like in normal math,
you’ll have to use the double multiplication sign “**”, if you were to execute “print(10^3)” the end result would be 9, but
if you were to execute the “print(10**3)” your end result would be “1000”

1 x= 10

2 x= x+3

3 print(x)

The end result would be:

“13”

The value of x changed on the second line making x equal to 13 now

“x= x+3” and “x+= 3” are basically the same command, the “+=” is called an increment and I’m sure that it’s made
specifically for numbers only but I’m not sure, guess I’ll find out later down the line. Also there are decrements “-=”, and
other commands that do the same thing but with other signs.

You’ll learn to see that arithmetic’s and math works pretty much the same in python as in standard math, so that will be
great help.

There are more functions like “print(round())” that will round up any float number you have, if the value of the variable
you place inside has a “,5” and under, it will just round up to the number you’ve placed before the “.”, and if its “.51” and
up, it will round up to the full number like for example “5.51” will round up to 6.

More functions like “print(abs())” will give you’re the absolute value like in math, I-6I would come out as 6.

TRUE and FALSE:

You use these to make a variable true or false and compliment it with the command “if” to give you a result depending
on if you made the variable True or False.

Keep in mind that they are case sensitive and you have you have to make the T and F upper case or they won’t count.

Remember to prest “Shift + TAB” to get at the beginning of the line/ statement

Of you wan’t the end result to print another text if it ends up False, you should use the command “else”
Example:

1 is_hot= True

2 if is_hot:

3 print(“it’s a hot day”)

4 else:

5 print(“it’s a cold day”)

End result would be:

“it’s a hot day”

But if “is_hot=False”:

1 is_hot= False

2 if is_hot:

3 print(“it’s a hot day”)

4 else:

5 print(“it’s a cold day”)

End result would be:

“it’s a cold day”

“elif” statrment is used if you have two or more statements that need to be True or False.

Is_hot= True

Is_cold= False

if is_hot: whatever print you put over here

elif is_cold: whatever print will comeout over here if it ends up true

else: whatever print will comeout if both statements are false . NOTE: if both come out True, it will only care about the
first string with a statement so keep that in mind.

Statements can also be used to make variables worth something different.


1:06:15

Logical operators
Like “if”, “elif” and “else”, we’ll also have an “and”, this will help to make sure if two or more statements are True or false.

Depending if both statements are True in this code, the answer may vary, with only one of them being False we get the
result that appears under the else:.

But here we can see that I add a third option for if we don’t have a good credit but do have high income.

With the “or” statement we can make a code that has two variables that aren’t dependent on each other being True or
False and getting a desired result whether which one you get True.
Here we can see that I can make more situations on the same string to make more case scenarios eligible for a loan.

Now we’ll see the statement “not” that will work for us when we need a variable to be false, like having a criminal record
or being a league of legends player. If these were to be True then that would be detrimental for us, so we need them to
not have some characteristics depending on the code you’re planning to write.

With the variables having the statements they have, the end result would be “you’re not eligible for a loan”, but if we
were to change both of these then we would have a different end result. (my stomach hurts while I’m typing this.

Little exercise I did. 😊

Other exercise :)
More exercises 😊

While loops
The “while” statement is a command that will keep printing until our variable meets the characteristics we need it to, but
if we don’t write the correct line of code it can go on indefinitely.

For example if we give our variable the value of 1 “while” i<= 5 it will keep printing until we get the value of I to atleast
become 5.

If we don’t put the “i= i+1” I the same group as the second string we would never make the code finish. You can also use
expressions like words and signs and repeat them, that’s pretty cool tbh, if I were to change the “I” in print with an
expression it would repeat as much times as the “I” in the code before.

It won’t stop until the variable reaches the value we want it to, it doesn’t necessarily need to print the i.

The “break” command stops any loop happening, for when you want the code to stop after getting the result that you
wanted.

To explain this code, we needed three variables at the start, our secret number equaled 9 was the number we had to
guess so that and the guess count and the guess limit, we used the command “while” to make a condition that while the
guess count variable was less than the guess limit variable the program would still be running, but also there is an
increment under that condition so that the guess count variable would grow each time you made an input. NOTE: that
you have to put an int for integer before the input so that any numbers you input are taken as numbers.

If you were to guess the number well, you would get the text “you won nigga” and under that line the command break
would stop all the loops present, or at least that one.

1:35:34

Theres a “for” command that will help you organize or do certain tasks with characters, “for item in ‘python’” the print of
the “item” will be

But in lower cases, if you open columns, you can make a list of stuff in there “[]” if you make a list of stuff the end result
will be every item in the list one in each column.

To skip over an iteration, you can use the continue keyword, for example

1 for item in python:

2 if item == ‘y’

3 continue

4 else:

5 print(item)

The end result would be

NESTED LOOPS

This code is pretty cool, you can make loops inside of loops, in this the end result would be all the possible combinations
of every coordinate you can make from 0 to 9, on each coordinate, giving you all the combinations.
While practicing with the “for” function, I stumbled into this dilemma where I didn’t understand why I was getting a “10”
as an end result, maximum is equal to 1 for how its laid out but the only problem is the “number” variable, that number
variable turns into one just after I put it in the string after the for function, guess that makes it a dependent variable and
the way it is laid out it automatically turns into the biggest value in the list of the variable from numbers, I don’t know
how that comes to be but I try to work around it and nothing, I’m still perplexed with what to do.

2:06:08

2:19:32

You can use the “->” to map a word to a number or a number to a word.

Use the “def” command to define functions.

What a function does is that if you make a paragraph of code that you want to use in another part in the program you
write, you’ll have to define it so that you can put the function wherever you need it so that it does the task you want. For
example, if you want your code to print a greeting or any other kind of message after each input it makes, you can define
a function to go after each one instead of having to write the same code over and over again.

You might also like