Crosspoint Intro to Computer Science
Monday, January 23, 2017
Saturday, January 21, 2017
Blog 42
What is the printout of the program below?
my_dict={}
my_dict["Jon"]=1000
my_dict["Bob"]=2000
my_dict["Sue"]=3
print my_dict[my_dict["Bob"]]
my_dict={}
my_dict["Jon"]=1000
my_dict["Bob"]=2000
my_dict["Sue"]=3
print my_dict[my_dict["Bob"]]
Tuesday, January 17, 2017
Blog 41
Write a program that starts with an empty dictionary and adds the pairs below. Then print the dictionary.
"Bob":4, "Sue":5
"Bob":4, "Sue":5
Thursday, January 12, 2017
Blog 40
Write a short program using the given dictionary that prints out the key and value for each pair in the dictionary using a for loop.
The printout should look like this
key: abc
value: 4
key: bdc
value: 5
given dictionary
my_dict = {"abc":4, "bcd":5}
The printout should look like this
key: abc
value: 4
key: bdc
value: 5
given dictionary
my_dict = {"abc":4, "bcd":5}
Wednesday, January 11, 2017
Blog 39
What do these programs print? What is significant about the output of the two programs?
Program 1
list=[1, 2, 3, 1, "hi", "hello"]
list.sort()
print list
list.reverse()
print list
Program 2
list=[1, 2, 3, 1, "hi", "hello"]
list.reverse()
print list
list.sort()
print list
Program 1
list=[1, 2, 3, 1, "hi", "hello"]
list.sort()
print list
list.reverse()
print list
Program 2
list=[1, 2, 3, 1, "hi", "hello"]
list.reverse()
print list
list.sort()
print list
Saturday, January 7, 2017
Blog 38
What does this program print?
list =[1,2,3,1,2,1,2]
number_of_ones= list.count(1)
print number_of_ones
print list
list =[1,2,3,1,2,1,2]
number_of_ones= list.count(1)
print number_of_ones
print list
Thursday, January 5, 2017
Blog 37
What are these called? What are they used on?
count()
reverse()
remove()
sort()
append()
extend()
count()
reverse()
remove()
sort()
append()
extend()
Subscribe to:
Comments (Atom)