Skip to content

Instantly share code, notes, and snippets.

View ricardovsilva's full-sized avatar

Ricardo da Verdade Silva ricardovsilva

View GitHub Profile
n = int(raw_input())
students_notes = {} #changed this to be a dictionary instead of list
for i in range(0,n):
aux = str.split(raw_input()) #here we get INPUT and transform it into list of strings.
#For example:
#input -> "Marcela 87 24 33 82"
#aux will have value ["Marcela", "87", "24", "33", "82"]
name = aux.pop(0) #or aux.popleft()
notes = aux
students_notes[name] = notes
@ricardovsilva
ricardovsilva / pop.py
Created February 1, 2016 15:06
Example of pop command in python. It illustrates how get first element of a list.
students_marks = ["Marcela", "87", "45", "22", "100"]
student_name = students_marks.pop(0) #Zero is to get the FIRST element of the list
#pop command retrieve the value and REMOVE it from list
print student_name
# Marcela
print students_marks
# ["87", "45", "22", "100"]
@ricardovsilva
ricardovsilva / map_example.py
Created February 1, 2016 15:19
Example of use of map function. This is usefull to convert a list of some type to other.
string_list = ["92", "27", "45", "23"]
print string_list
#["92", "27", "45", "23"]
print string_list[0] + string_list[1]
#9227
integer_list = map(int, string_list)
print integer_list
n = int(raw_input())
students_data = {}
for i in range(0,n):
#transforms each item of input in a string that contain de name of a student and their notes
aux = str.split(raw_input())
#remove the first item of a list which is the name of a studant
student_name = aux.pop(0)
#take the notes of a studant
@ricardovsilva
ricardovsilva / calculate_average.py
Created February 1, 2016 16:26
Example to calculate average from list in python
def calculate_average(verifide_notes):
float_list = map(float, verifide_notes)
average = sum(float_list)/float(len(float_list))
return average
@ricardovsilva
ricardovsilva / list.py
Created February 2, 2016 12:34
Example of list usage in python
n = int(raw_input())
my_new_list = []
while n >= 0:
my_new_list.insert(0, 5)
my_new_list.insert(1, 10)
my_new_list.insert(0, 6)
print my_new_list
my_new_list.remove(6)
my_new_list.append(9)
@ricardovsilva
ricardovsilva / python-list.py
Created February 2, 2016 13:59
My solution for python-list exercise of hackerrank.com
quantity_commands = int(raw_input())
lines = []
for i in range(0, quantity_commands):
input = raw_input()
lines.append(input)
L = []
for line in lines:
parameters = str.split(line)
@ricardovsilva
ricardovsilva / code_skulptor_timer_example.py
Last active February 3, 2016 13:25
Example of code skulptor exercise that use timer
import simplegui
time = 0
points = 0
def format(time):
A = time // 600
B = time // 60
C = time % 60

If you want to debug HTTPS requests, you must execute, at any point of your code, these command:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

Then, you must add the following lines to your web.config:

<system.net>
	<defaultProxy enabled="true">
		<proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False"/>

Basic Git Commands For Rookies

Comando Descrição
git clone https://myrepositoryurl.com Copia o repositório inteiro para o seu PC
git add . Marca todos os arquivos para serem comitados, este comando não comita os arquivos.
git commit -m "My message here" Comita todos os arquivos adicionados pelo comando git add
git push Envia todos os commits criados para o server
git pull Atualiza o seu repositório de acordo com o repositório do server
git status Mostra todos os arquivos que foram adicionados ou alterados