Python Tutorial for Beginners 2: Strings – Working with Textual Data




[ad_1]

In this Python Beginner Tutorial, we will begin learning about the string data type. Strings allow us to work with textual data in Python. We will be going over different ways to format strings, and also a lot of useful string methods. Let’s get started.

The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python-Strings

Watch the full Python Beginner Series here:
https://www.youtube.com/playlist?list=PL-osiE80TeTskrapNbzXhwoFUiLCjGgY7

Slicing Video: https://youtu.be/ajrtAuDg3yw
String Formatting Video: https://youtu.be/vTX3IwquFkc

✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms

✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join

✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist
http://a.co/inIyro1

✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer

▶️ You Can Find Me On:
My Website – http://coreyms.com/
My Second Channel – https://www.youtube.com/c/coreymschafer
Facebook – https://www.facebook.com/CoreyMSchafer
Twitter – https://twitter.com/CoreyMSchafer
Instagram – https://www.instagram.com/coreymschafer/

#Python

Source


[ad_2]

Comment List

  • Corey Schafer
    December 12, 2020

    Wow !!! How superbly explained….I understood, but, please explain more about it and make 2nd part of the video …please, please,…

  • Corey Schafer
    December 12, 2020

    Jack World

  • Corey Schafer
    December 12, 2020

    ““““““““““““““““““““““““““*********************************************————————————————,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,…………………………………………………………………………..

  • Corey Schafer
    December 12, 2020

    you are good teacher!!!!

  • Corey Schafer
    December 12, 2020

    My notes:-
    app_name = 'Programming Hero'
    print(app_name)
    #2 or more names are separated by _

    message = 'bBobby's world' # error
    message = "bBobby's world"
    message = 'bBobby's world'
    message = """bBobby's World Was A Good
    Cartoon In The 1990's """
    print(message)
    print(len(message))
    print(message[5])
    print(message[:7])
    print(message[8:])
    print(message.lower())
    print(message.upper())
    print(message.swapcase())
    print(message.count("World"))
    print(message.count("o"))
    print(message.find("W"))
    print(message.find("U"))
    #returns -1 for not existing.
    print(message.replace("World", "Universe"))

    Greeting = "Hello"
    name = "Ani"
    message = Greeting + name
    message = Greeting + " " + name
    message = Greeting + ", " + name
    message = Greeting + ", " + name + '. Welcome !'
    message = "{} , {}. Welcome !" . format(Greeting, name)
    message = f'{Greeting}, {name}. Welcome !'
    #f string formatting method
    message = f'{Greeting}, {name.upper()}. Welcome !'
    print(message)

    print(dir(message))
    print(help(str))
    help(message.lower)

    You can also copy this and paste and then play with the code 😉

    https://docs.google.com/document/d/1oodK52RDCqMs7KTygz5jVMeVjV4KRw5FJIg9WRcrYM8/edit?usp=drivesdk

  • Corey Schafer
    December 12, 2020

    I'm a newbie in Python but your videos help me alot … #aarigato_Sensei ……

  • Corey Schafer
    December 12, 2020

    Liked the part about f strings. Will look more into it

  • Corey Schafer
    December 12, 2020

    Thanks man

  • Corey Schafer
    December 12, 2020

    F strings start at : 17:00

  • Corey Schafer
    December 12, 2020

    some notes:
    ———-

    Strings

    ———-

    example = "this is an example"

    Triple quotes for multiline
    strings

    Slicing:
    string[start:stop:step]
    # stop isn't included, starts at 0

    Useful methods/functions :

    – len(string)

    – string.count(characters_to_count)

    – string.find(character_string_index_to_find)

    – string.replace(replace_this, with_this)

    Concatenating:

    greeting = "Hello"

    name = "Bobby"

    message = greeting + ', ' + name

    print(message)
    # returs Hello, Bobby

    String Interpolation/formatting:

    message = '{}, {}, Welcome!'.format(greeting, name)

    print(message)
    # returns Hello, Bobby. Welcome!

    fstrings:

    message = f'{greeting}, {name}, Welcome!.'

    # returns same as the last one

    # you can also use methods right in the fstring ie. {name.upper()}

    dir(any_var):

    # shows all attributes/methods available for that variable

    help(data_type.any_method)
    # data_type like str, number etc
    . any method or property.
    # shows very detailed information about the data type and its methods and such.

    # any_method can be any method/property the data_type supports.

    # for eg: help(str.lower)) gives info about what lower does

  • Corey Schafer
    December 12, 2020

    Great content Corey. thank you for sharing

  • Corey Schafer
    December 12, 2020

    Video 02/143 done ! Thx for the works you're doing.

  • Corey Schafer
    December 12, 2020

    You are a gem

  • Corey Schafer
    December 12, 2020

    Alright you convinced me to sub and finish the playlist. 🙂
    New to python but not to programming although I never new a lot in the first place and you seem to explain things well.

  • Corey Schafer
    December 12, 2020

    thank you

  • Corey Schafer
    December 12, 2020

    Goldmine!!!

  • Corey Schafer
    December 12, 2020

    what is the IDE you are using ???

  • Corey Schafer
    December 12, 2020

    My sublime text keep building the same string over and over again. need help please

  • Corey Schafer
    December 12, 2020

    too much information in just 20 min

  • Corey Schafer
    December 12, 2020

    super duper for beginners!

  • Corey Schafer
    December 12, 2020

    Trying my hand at expanding beyond Cisco and Juniper, this helps so much.

  • Corey Schafer
    December 12, 2020

    This video covered more about Python strings than a whole "string week" in a popular Coursera beginner python course.

  • Corey Schafer
    December 12, 2020

    tnx man

  • Corey Schafer
    December 12, 2020

    'find' gives us the lowest index of any word or letter that we type but what if those words or letters are repeated and I want to know all the indices of the same? Please help. Thanks.

  • Corey Schafer
    December 12, 2020

    Thanks for the Python videos! I’ve read dozens of programming books, read tons of code examples on the web, read various docs, watched a bunch of videos, and your video tutorials are top of the tree for me. You keep it simple, give good insights into why and how things work, show good examples that illustrate the key points well, present nicely and cleanly, and you anticipate a lot of questions and answer them later in the same video. I hope a lot of kids get to see these videos, which are a perfect springboard into using this amazing language. After dabbling in about 20 different languages, I love Python above all others and want to keep learning and keep coding! Cheers!

  • Corey Schafer
    December 12, 2020

    Thank you so much, your content is the most clearest of all, and it is explained to a certain point, and is not under-explained or over-explained, keep up the good work. I subscribed and saved this playlist for more learning!

  • Corey Schafer
    December 12, 2020

    Good explanation

  • Corey Schafer
    December 12, 2020

    Hi Corey! Im confused with find. Why did it return 6 when 5 was the value of W in World?

  • Corey Schafer
    December 12, 2020

    Do you have live classes? I really wish to join if there is one. Even if there is payment.

  • Corey Schafer
    December 12, 2020

    of all the python tutorialsI have watched, this is the best. am an amateur and ready to learn. I am going to follow all your tutorials to become a coder one day.

Write a comment