This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rotate(arr,index) | |
rotated_array = [] | |
arr.each_with_index do |a,i| | |
new_index = i + index | |
if new_index >= arr.length | |
while new_index >= arr.length do | |
new_index = new_index - arr.length | |
end | |
rotated_array.insert(new_index, a) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = ("John", "Doe", 53.44) | |
format_string = "Hello %s %s. Your current balance is %.2f$." | |
print format_string % (data[0],data[1],data[2]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = [1,2,3] | |
strings = ["hello","world"] | |
names = ["John", "Eric", "Jessica"] | |
# write your code here | |
second_name = names[1] | |
# this code should write out the filled arrays and the second name in the names list (Eric). | |
print(numbers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = object() | |
y = object() | |
# change this code | |
x_list = [x] * 10 | |
y_list = [y] * 10 | |
big_list = x_list + y_list | |
print "x_list contains %d objects" % len(x_list) | |
print "y_list contains %d objects" % len(y_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# change this code | |
mystring = "hello" | |
myfloat = 10.0 | |
myint = 20 | |
# testing code | |
if mystring == "hello": | |
print "String: %s" % mystring | |
if isinstance(myfloat, float) and myfloat == 10.0: | |
print "Float: %d" % myfloat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phonebook = { | |
"John" : 938477566, | |
"Jack" : 938377264, | |
"Jill" : 947662781 | |
} | |
# write your code here | |
phonebook["Jake"] = 938273443 | |
phonebook.pop("Jill") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mov AH,04H | |
int 1AH | |
mov bh,10h | |
mov al,dl | |
div bh | |
mov bl,al | |
add bl,30h |