Python How To Program Pt 3

PythonIn this video I cover how to use the list data types in Python (tuples, lists, dictionary’s).

I also review and introduce the While Loop, If then Elif, and a bunch of tricks with Python. All of the code from the video follows the video on this page. If you didn’t watch part 1 of this tutorial watch it here: Python How To Program

If you have any questions or comments, leave them in the comment section below.

NOTE: At the end of the video, I say I don’t know the topic of the next video. It will be on Object Oriented Programming with Python.

All of The Code From the Video

# Whats a tuple? An Immutable List

tupleEx = (‘Derek’, 35, ‘Pittsburgh’, ‘PA’)

for i in tupleEx:
print(i)

print(“First element in the tuple is “, tupleEx[0])

# That’s it tuples don’t have methods

listEx = [‘Derek’, 35, ‘Pittsburgh’, ‘PA’]

for i in listEx:
print(i)

listEx.append(“Joy”)

print(listEx)
print(listEx[4])

listEx.remove(“Joy”)

print(listEx)

listEx.remove(listEx[3])

print(listEx)

listEx.insert(2, ‘PA’)

print(listEx)

listEx2 = [‘f’, ‘e’, ‘c’, ‘d’, ‘a’, ‘b’]

listEx2.sort()

print(listEx2)

listEx2.reverse()

print(listEx2)

listEx3 = [
[‘a’,’b’,’c’],
[‘d’,’e’,’f’],
[‘g’,’h’,’i’],
]

print(listEx3[2][1])

# Dictionary’s are immutable variables that have a key associated with values

dictEx = ({“Age”:35, “Height”:”6’3″, “Weight”:169})

print(dictEx)

print(dictEx.get(“Height”))

print(dictEx.items())

print(dictEx.values())

dictEx.pop(“Height”)

print(dictEx)

# while loop time

a, b = 1, 11

while a < b:
print(a)
a += 1

for x in [1,2,3,4]:
print(x)

listCycle = [1,2,3,4]

listCycle[:] = range(1,201)

for i in listCycle : print(i)

for i in listCycle :
if (i%2) == 0:
continue
elif (i == 101):
break
else:
print(i)

3 thoughts on “Python How To Program Pt 3”

  1. The link says pt3 but in the vid you call it pt 4? can you clear this up for us or did you skip pt3?.
    -confused
    Thanks

  2. The last bit of code doesn’t seem to be working properly for me. The part that counts up to 200 but only the odd numbers, when I run the code it still just runs through all the odd and even numbers.

Leave a Reply

Your email address will not be published. Required fields are marked *