What does this program print?
my_string= "abcde"
my_string= my_string[2:]+ "C" + my_string[3:]
print (my_string)
Wednesday, December 28, 2016
Thursday, December 15, 2016
Blog 35
Which will print AeCl ?
f_name= "Alice"
l_name= "Carmichael"
1) print f_name[0] + l_name[0]
2) print f_name[0] + l_name[0] + f_name[-1] + l_name[-1]
3) print f_name[0] + f_name[-1] + l_name[0] + l_name[-1]
4) print f_name[1:] + l_name[1:]
f_name= "Alice"
l_name= "Carmichael"
1) print f_name[0] + l_name[0]
2) print f_name[0] + l_name[0] + f_name[-1] + l_name[-1]
3) print f_name[0] + f_name[-1] + l_name[0] + l_name[-1]
4) print f_name[1:] + l_name[1:]
Monday, December 12, 2016
Blog 34
What does the find string return if the second string is not found in the first? What does it print?
for example
f_string= "hello"
s_string= "pig"
index=f_string.find(s_string)
print index
for example
f_string= "hello"
s_string= "pig"
index=f_string.find(s_string)
print index
Friday, December 9, 2016
blog 33
What is the result of these program lines?
greeting ="hello"
index= greeting.find('lo")
print index
greeting ="hello"
index= greeting.find('lo")
print index
Tuesday, December 6, 2016
blog 32
Look at the program below.
How do we fix it so it will print the string one letter at a time in the loop?
What one thing can we change to get it to work?
s= "hey dudes!"
for i in range(8):
print s[i]
How do we fix it so it will print the string one letter at a time in the loop?
What one thing can we change to get it to work?
s= "hey dudes!"
for i in range(8):
print s[i]
Sunday, December 4, 2016
blog 31
What does this program print?
my_string = "hello"
bad_index = len(my_string)
print (bad_index)
my_string = "hello"
bad_index = len(my_string)
print (bad_index)
Friday, December 2, 2016
Blog 30
Why does this program not work? What is wrong with it? How do you fix it?
def summ(x,y):
z= x+y
return z
print z
def summ(x,y):
z= x+y
return z
print z
Subscribe to:
Comments (Atom)