Tag Archives: masteries

#Mastery22 What type of repetition should I use?

When programing, the use of repetition is very usfull, it makes a program shorter, and more efficient.
But there are many types of repetition in Python, witch one should I use?

Here is a qwick guide with my recomendations.

WHILE:

While loops are used when there is a factor that whill be changin ‘n’ times and you want to stop when said factor changes, also if the user is in control of the loop, if the factor is proned to change you use a while loop. (Learn More about While loops).
examples:

#Mastery22 What type of repetition should I use?x=0
while (x==0):
     print(“Hi”)
     x=int(input(“stop?, 0=no 1=yes”)

Another example.

FOR:

#Mastery22 What type of repetition should I use?For loops are used when you want your process to loop for the amount of time inside a range, When the amount of times it will loop is already pre-determined, either by the user or the programmer, you use a For loop.(Learn more about For loops).

1 example.

RECURSION:
Recursion is used when a function will repeat inside itself, func-ception, it will till a certian answer is reached, this one is tricky because you need to build the fuction with recursion in mind.
My most recent WSQs have been using recursion, so why dont you check that out?.

#Mastery22 What type of repetition should I use?


#Mastery26 Strings

Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed in single quotes ('...') or double quotes ("...") with the same result.(Click here to learn more).

You can turn any value into a string with the str( ) function (like seen in this program). you can also use string inputs. 
str(input()). 

When you make a sum of strings it will make a concatenation:

1+1=

2
“1”+“1”=        Concatenation.
“11”
“Hi “+” I´m “+” George”=    Concatenation
“Hi I´m George”.

#Mastery26 StringsString can also be multiplied as seen in this program.

#Mastery26 Strings

Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed in single quotes ('...') or double quotes ("...") with the same result.(Click here to learn more).

You can turn any value into a string with the str( ) function (like seen in this program). you can also use string inputs. 
str(input()). 

When you make a sum of strings it will make a concatenation:

1+1=

2
“1”+“1”=        Concatenation.
“11”
“Hi “+” I´m “+” George”=    Concatenation
“Hi I´m George”.

#Mastery26 StringsString can also be multiplied as seen in this program.

#Mastery26 Strings

Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed in single quotes ('...') or double quotes ("...") with the same result.(Click here to learn more).

You can turn any value into a string with the str( ) function (like seen in this program). you can also use string inputs. 
str(input()). 

When you make a sum of strings it will make a concatenation:

1+1=

2
“1”+“1”=        Concatenation.
“11”
“Hi “+” I´m “+” George”=    Concatenation
“Hi I´m George”.

#Mastery26 StringsString can also be multiplied as seen in this program.

#Mastery24 Tuples

A tuple is the same thing that a list in python. Click here to learn about lists.
But thiferent from lists a tuple uses the “( )” signs to enclose the group rather than the “[ ]” of the lists.

The main difference it has is that Tuples CAN’T BE MODIFIED, so al the append, erase and replace functions that work with lists Wont work with a touple. Click here to learn more about Touples.

#Mastery24 Tuples

#Mastery24 Tuples

A tuple is the same thing that a list in python. Click here to learn about lists.
But thiferent from lists a tuple uses the “( )” signs to enclose the group rather than the “[ ]” of the lists.

The main difference it has is that Tuples CAN’T BE MODIFIED, so al the append, erase and replace functions that work with lists Wont work with a touple. Click here to learn more about Touples.

#Mastery24 Tuples

#Mastery24 Tuples

A tuple is the same thing that a list in python. Click here to learn about lists.
But thiferent from lists a tuple uses the “( )” signs to enclose the group rather than the “[ ]” of the lists.

The main difference it has is that Tuples CAN’T BE MODIFIED, so al the append, erase and replace functions that work with lists Wont work with a touple. Click here to learn more about Touples.

#Mastery24 Tuples

#Mastery23 lists

Learn to use lists.

#Mastery23 lists

Learn to use lists.

#Mastery23 lists

Learn to use lists.