Create a string and assign it to a variable
In [ ]:
Print your string. The print()
command was optional in Python 2.x, but is now required in Python 3.x.
In [ ]:
Get the type of an object.
In [ ]:
Make a comment to yourself and then get the length of your string.
In [ ]:
Remember that a string is just a series of characters, not a word or a sentence
So you can "slice" off pieces of a string based on the index of the characters in it.
Try to slice off the last 5 characters in my_string
In [ ]:
Convert it to lowercase.
In [ ]:
Convert it to uppercase.
In [ ]:
Convert it to titlecase.
In [ ]:
Concatenate strings.
In [ ]:
Split strings.
In [ ]:
Join a list of strings
In [ ]:
Remove a character.
In [ ]:
Strip whitespace.
In [ ]:
Removes only leading whitespace characters.
In [ ]:
Removes only trailing whitespace characters.
In [ ]:
I need help remembering what methods my variable has available.
In [ ]:
I need help on a specific method.
In [ ]:
Create an integer.
In [ ]:
Print your integer.
In [ ]:
Get the type of your integer.
In [ ]:
Do some addition.
In [ ]:
Do some subtraction.
In [ ]:
Do some multiplication.
In [ ]:
Do some division.
In [ ]:
Create a float, assign it a value and print it.
In [ ]:
Divide a float in half.
In [ ]:
Divide an integer in half. If you're used to Python 2.X, this will behave a little bit differently.
In [ ]:
Create a list.
In [ ]:
Create a list, you can use strings, integers, variables, etc
In [ ]:
Print the list.
In [ ]:
Print its type.
In [ ]:
Print its length.
In [ ]:
Create a list of numbers.
In [ ]:
Print the first item in the list.
In [ ]:
Print the last item in the list.
In [ ]:
Print all items from 4 through the end. We call this slicing.
In [ ]:
Print the items from the start to the penultimate position.
In [ ]:
Print the middle 4 items.
In [ ]:
Add an item to the list and see if it was added.
In [ ]:
Delete the last item in the list.
In [ ]:
Set the last value in the list to a variable
In [ ]:
In [ ]:
Create an empty dictionary
In [ ]:
Add a key called "class_size", whose value is my_product
In [ ]:
Add a dictionary key called "nerds" and a value of "at bar".
In [ ]:
Call the value of a dictionary for the key "nerds".
In [ ]:
Take your list or make a new one, loop through it printing out each value
In [ ]:
Create two variables, assign values and compare them
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Create two variables, assign one as a number and one as a string, and compare them
In [ ]:
If x is greater than y, print my_list. Otherwise, print my_dict.
In [ ]:
This barely skims the surface of what you can do in Python, but hopefully this overview will make you comfortable enough to get started.
Now, exit the program.
In [ ]: