Tag Archives: #Mastery26

#Mastery26 #TC1014 #LaNieveDeColimaExploto #PenguinLove #video

En este video les muestro como usar strings

Espero les guste y les ayude 

suscribanse y denle like

http://youtu.be/jOOgdB8aepo?hd=1

Creating and Using Strings in Python

String in Python3 can be created using both pairs of singles and double quotes. They are concatenations or secuences of characters, they can be numbers, letters or special characters as long as they are inside the quotes. 

String can be sliced, this means that you can get substrings from a string using the two slice operators:

  • String[i] This returns the character that is in the position given by i. Remember that strings start at 0.
  • String[i:j] This returns the section of characters between the given range from i to j, whitout including the upper limit. 

Strings can also be used to perform two opperations: 

  • + : this operator is the String concatenation, this means it is used to “attach” the begining of the string at the end of another string. You can make the analogy to the algebraic sum, where the result will be the adition of both components.
  • *: this is the repetition operator; this allow us to repeat the String many times as desired, just like the algebraic multiplicaction, that adds, or in our case concatenates, a certain number of the original String copies. 

For example:

>>>str = "Hello World!"  

>>>print (str)

Hello World!

>>>print (str[0])

H

>>> print (str[2:5])

llo

>>>print (str[-1])

!

>>>Print (str[::-1])

!dlroW olleH

>>> Print(str+"!!")

Hello World!!!

>>>Print(str*2)

Hello World!Hello World!

 

 

As you can see String can be seen as lists in some ways. For example the [-1] index points to the last element of the array. 

As you can see the [::-1] gives you the reversed string, but why? Well as I had said if you check lists in Python you will see that its called slicing, and what we are typing is that you will slice the string with a -1 step, this means from the last to the start. 

Most of the information was extracted from this page.

This is my of my

Mastery 26 Creation and use of strings

In this mastery I will write about strings.What are strings? Strings are characters that are enclosing in quotes. As simple as this:

st1= “Hello World”

we can do many operations with strings beginig with print that maybe is the most use it.

we can know the lenght of our string using the len() statement like this:

1.-print len(st1)—> this will give us an 11, because the string has 11 characters including spaces

 Another operation with strings is performed by the index staement like this:

2.-print st1.index(“o”)—>this will give us a 4, because the letter tell us to where we will count, star of 0.

other is this one

3.- print st1[1:3]—>this will give us “el” starting countig from 0 and end in the position 2, like I say in the last post of range, that mean stop that will stop in (stop-1)

 

Another interesting functions are the following:

4.-print string1.upper()
5.-print string1.lower()

Which will print a new string with all letters converted to uppercase and lowercase respectively.

Also we can create a new string with other string but different, what I mean? just like this:

st1 = “Hello World”

print st1[:6] + “python”—–>this will give us “hello python”.

In this link you can found more operations and information about strings: http://www.tutorialspoint.com/python/python_strings.htm

 

#mastery26

Hi guys, in this video I show you how to use matrixes in C++.

Mastery 26. Creation and use of strings

Strings are bits of text, and the syntax for them is anything written between quotes, as the following example:

>> string1=”Hello World”

In this example we are assigning the string to a variable called string1 which we can print, as we have learned in later posts, but printing it is not the only action we can do with strings, there are many more operations we can perform with strings and I will show you some of them in this post.

One operation that we can do is getting to know the lenght of our string by the len() statement. Example:

>>print len(string1)

This will print 11 because the string is 11 characters long, including spaces.

 

Another operation with strings is performed by the index staement, this will tell us the position of a given letter. Example:

>> print string1.index(“W”)

For this example, it will get printed 6, because W is in the 6th position, if we start counting from 0.

 

Also, a cool operation that we can do with strings is printing just a part of the whole string, for example:

>>print string1[4:8]

This will print “o Wo” because is the part of the string that goes from the 4th letter (starting from 0) to the 7th letter ( the end boundary it is not taken into account)

 

Another interesting functions are the following:

>>print string1.upper()
>>print string1.lower()

Which will print a new string with all letters converted to uppercase and lowercase respectively.

 

There are so many other operations that we can do with strings, such as concatenation, multiplication, etcetera.

If you are interested in learning more about strings, you can check this link: https://docs.python.org/2/library/string.html

 

 

Creation and use of strings in Python

I created a basic program in Python with “string” variables and made a simple example using them.

In phyton, numbers can be called integers or floats, the strings are everything else that is considered as a letter or a word and any operation can not be made with strings as it can with integers, to create strings you just have to enter str() , int() for integers and float() for floats, for example:

str(0)+str(6)       pyhton will print ——–>    06

int(2)+int(5)       python will print ——–>     6

Creation and use of strings in Python #Mastery26

Here’s a video explaining the creation and use of strings in Python: 

https://www.youtube.com/watch?v=Pzo37TJkXXk

 

Oscar Ricardo López López A01229116

#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.