Giter Site home page Giter Site logo

dsc-strings-lab-atlanta-ds-062419's Introduction

Introduction to Variables: Strings - Lab

Introduction

Okay, we have learned about our first data type, the String! Now let's do a little practice with strings. We'll use the methods and functions we introduced in the previous lesson to flex our string-manipulating muscles!

Objectives

You will be able to:

  • Apply string methods to make changes to a string
  • Use concatenation to combine strings

Instructions

Follow the steps below to manipulate the strings and assign the values to the variables below.

1. Below, we have a sentence whose cases are all over the place. Let's normalize the cases and make everything lower case except the first letter in the sentence. hint: there is a string method that does this

sentence = "woW WE LOVE cOdInG and strINGS!"
sentence

2. Next, we have our Flatiron mantra, but it's not in title case like it should be! Let's fix that and use another string method that makes all strings first letter capitalized.

flatiron_mantra = "learn. love. code."
flatiron_mantra

3. The next thing we want to do is practice turning other data types into strings. Below, we have a number 1234, which happens to be our street number in our address, which is a string. So, let's turn the number into a string so we can eventually add it to our address. The process of linking different strings together is called concatenation.

num_to_string = 1234
num_to_string

4. Let's take the num_to_string and add it to the beginning of our street address below. We need to concatenate the variable to the beginning of our string so that we have our full address all in one string and assigned to the variable full_address. hint: None is a placeholder in the below code for you to edit

full_address = None + " Abc street, Hometown USA"
full_address

5. Finally, let's replace some of the characters in a string. Let's say Bart is upset with his family and wants to be adopted by the Flanders family. How would you replace his last name?

Hint: We did not directly cover this method in the lesson. Check out the string helper docstring for a list of available methods.

help(str)
name = "Bart Simpson"
name = #Your code here; update the variable name

Summary

Great work! In this lab we practiced our skills with strings. We can now manipulate, coerce, and concatenate strings. Remember if there are any things you can't remember or want to discover about code that isn't mentioned in this material, googling is always a great practice!

dsc-strings-lab-atlanta-ds-062419's People

Contributors

tkoar avatar mathymitchell avatar loredirick avatar peterbell avatar alexjf12 avatar mas16 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.