More loops, loops everywhere, FOR LOOP.

--Originally published at Newbie Programmer

giphy
Me when i see a loop

Welcome to another post, and another loop.

In this case we explain the FOR loop. The for loop is used for the same things as the While Loop, but the for loop is for finite loops.

You can use Lists.

untitleduntitled2

If you put, for example the print (“A value”) into the loop, the words “A value” can be printed with every number.

f3f4

Range function.

f5f6

If you put a third number in the (), this number activates a function that says steps of 2 in the range.

f7f8

And you can use slices (strings) for the for loops.

f9f10

Source: https://www.youtube.com/watch?v=xtXexPSfcZg&list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M&index=7

 

 


Strings

--Originally published at Newbie Programmer

giphy
Welcome to a new post

In this post we have an introduction to strings of python 3.

First, the strings can be enclosed in single quotes (‘ ‘) or doble quotes (” “).

strings1strings2

You can put \ to scape single quote or put instead double qoutes ” “

doesnt

The print () function

print.gif

printprint2

\n Character

nn2

If you dont like to expect a new line, you can put letter r before the quotes.

r1r2

Operator \t

t1 t2

If you want to span in multiple lines , you can put triple quotes( ¨¨¨     ¨¨¨)

triple1triple2

Properties of the strings.

p1p1-1

Indexed

i1i1-1

Slicing

s0-1s1

Strings learned.

before

And its the end.

 

 

 


My new calculator

--Originally published at Newbie Programmer

giphy

Using python 3 as a calculator

I can use python 3 as a calculator using the interpreter of python, you can do the basic math functions.

numbers

The  integer numbers ( 23 , 45, 4) have type int , and the others numbers with a fractional part ( 2.5 , 4.34, 3.141592653….) have type float

The division (/) always returns a float number, to do a division to get a type int number you need to put // instead of / , and to calculate the remainder use the %.

paiton

In python is possible to use the ** operator to calculate powers, 2**2  is equal to write 2² (At a real calculator).

paitontri

You can use the equal sign = to assign a value to a variable, if you dont assing a variable, you cant use, and you accredit an error.

error65663545

In the interactive mode the last printed expression is assigned to the variable

taxes

And, you can round the number if you put the function round(AValuue,Numberofdecimals)

And now, a gif of a taco.

tacos