Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alejandra Cernas emerak

🏠
Working from home
View GitHub Profile
View rotate_arrar.rb
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
@emerak
emerak / StrFormat.py
Created Feb 6, 2013
String Formatting - LearnPython.org
View StrFormat.py
data = ("John", "Doe", 53.44)
format_string = "Hello %s %s. Your current balance is %.2f$."
print format_string % (data[0],data[1],data[2])
@emerak
emerak / Lists.py
Created Feb 6, 2013
Lists - LearnPython.org
View Lists.py
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)
@emerak
emerak / BasicOperators.py
Created Feb 6, 2013
Basic Operators - LearnPython.org
View BasicOperators.py
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)
@emerak
emerak / Exercice2.py
Created Feb 6, 2013
Variables and Types - LearnPython.org
View Exercice2.py
# 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
@emerak
emerak / Dictionaries.py
Last active Dec 12, 2015
Dictionaries - LearnPython.org My answer to the excercise
View Dictionaries.py
phonebook = {
"John" : 938477566,
"Jack" : 938377264,
"Jill" : 947662781
}
# write your code here
phonebook["Jake"] = 938273443
phonebook.pop("Jill")
@emerak
emerak / gist:1850635
Created Feb 17, 2012
Gettting the hour of the system without DOS interruptions
View gist:1850635
mov AH,04H
int 1AH
mov bh,10h
mov al,dl
div bh
mov bl,al
add bl,30h