1.1. Exercises

Name That Data Type

For the next few questions, name the data type of each value.

Coding questions

Instructions:

Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.

When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.

String Verbs

How many times do the lyrics “Let it be” occur in the Beatles Hit song of the same title?

Tasks:

  • Use some of the string verbs you learned in the lecture to count all the times “let it be” (all upper and lower case versions) appears in the string lyrics.
  • Save it in an object named letitbe_count.
Hint 1
  • Are you converting lyrics to lowercase using .lower()?
  • Are you using .count() with the argument let it be?
Fully worked solution:


Casting Data Types

How can we cast from a string to an integer value?

Tasks:

  • Convert string1 to a float in an object named pi.
  • Convert the object pi now into an int named pi_slice.
Hint 1
  • Are you using float()?
Fully worked solution:


Hint 1
  • Are you using int()?
Fully worked solution: