blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
2d1732fbd04e6cd316053b5d6355f14b9fe39c68
andhess/project-euler
/prb-25/fibCount.py
216
3.734375
4
def fibCount(digitLen): fibs = [1,1] while len(str(fibs[-1])) < digitLen: fibs.append(fibs[-1]+fibs[-2]) # need the Nth value, not the number itself! return len(fibs) print fibCount(1000)
179031fa08f7cbf9795b946b982f4d32676bb650
prashantgandhi27/Hackerrank-codes
/Python/Capitalize.py
856
3.5
4
#!/bin/python3 import math import os import random import re import sys # Complete the solve function below. def solve(s): mylist = [] sec_list = [] string_1 = '' string_2 = '' count = 0 for i in s: mylist.append(i) list_len = len(mylist) for x in mylist: if (count !...
576ccdeeecb81c8a1cf170329b55f14d5849d96d
malcolmdimeglio/banking
/statement_handler.py
3,836
3.75
4
#! /usr/bin/env python3 import os import pandas as pd import bank_name def parse_statement(csv_file): """Parse the given statement and apply needed modification Args: csv_file (str): Path to csv file to parse Returns: pandas.core.frame.DataFrame: A parsed and organized dataframe for the...
c42bf85ed3f49405592169da31889c3d85343893
SattVaMonk/object_chasing_robot
/client/piCar.py
1,752
3.515625
4
import requests BASE_URL = "0.0.0.0" def connection_ok(baseUrl): """Check whetcher connection is ok Post a request to server, if connection ok, server will return http response 'ok' Args: none Returns: if connection ok, return True if connection not ok, return False Raises: none """ global BASE_UR...
17e34259c31ea9a2aadec82edd7654c2ed36ec4f
heechul90/study-python-basic-2
/left_hand_coding/미운코딩새끼/If.py
385
3.75
4
### If #if 조건: # 실행할 명령1 # 실행할 명령2 input_name = '이희철' if input_name == '이희철': print('만나서 반가워요,', input_name) ### if ~ else ### if ~ elif ### if ~ elif ~ else name = 'Gayoung' if name == 'Heechul': print('You are Heechul!') elif name == 'Heesun': print('You are Heesun!') else: print('Who ...
6d61e26ef27916f757e7201e4713a3d563a21d4b
heechul90/study-python-basic-2
/left_hand_coding/CheckiO_Elementary/Even_The_Last.py
219
3.53125
4
### Even_The_Last def even_the_last(array): if not array: return 0 return sum(array[::2]) * array[-1] even_the_last([0, 1, 2, 3, 4, 5]) even_the_last([1, 3, 5]) even_the_last([6]) even_the_last([])
baf9c275e887aadcc8f98e350e019e443c04192d
heechul90/study-python-basic-2
/left_hand_coding/미운코딩새끼/List.py
316
3.96875
4
### list(여러개를 모아서 수행하는 것) # 숫자를 저장 my_list = [1, 2, 3] # 이름을 저장 students = ['이희철', '왕가영', '아무개'] print(students) for std in students: print(std) import random print(random.choice(students)) # 추가 하기 print(students.append('최인실'))
f7e22ab0384e1daf719bcaf070c05d680b257eb4
heechul90/study-python-basic-2
/jump_to_python/chapter02/Dictionary.py
2,449
3.640625
4
### 02장. 파이썬 프로그래밍의 기초, 자료형 ## 02-5. 딕션너리 자료형 ## 딕셔너리는 어떻게 만들까? # {Key1:Value1, Key2:Value2, Key3:Value3, ...} # Key에는 변하지 않는 값을 사용하고, Value에는 변하는 값과 변하지 않는 값 모두 사용할 수 있다 dic = {'name':'pey', 'phone':'0119993323', 'birth': '1118'} print(dic) a = {1: 'hi'} print(a) a = { 'a': [1,2,3]} print(a) ## 딕셔너리 쌍 추가, 삭제하기 # 1...
51f3dd387e7437344c43e760f568cd56d8adcc7f
heechul90/study-python-basic-2
/left_hand_coding/CheckiO_Elementary/Second_Index.py
313
3.640625
4
### Second_Index def second_index(text, symbol): if text.count(symbol) < 2: return None first = text.find(symbol) return text.find(symbol, first + 1) second_index('sims', 's') second_index('find the river', 'e') second_index('hi', 'i') second_index('hi mayor', ' ') second_index('I', 'z')
4356ab695c390de328a0ffa8ced619b593651043
heechul90/study-python-basic-2
/left_hand_coding/미운코딩새끼/Formatting.py
166
3.796875
4
### Formatting(문자열을 더 잘 표현하기 위해 하는 함수) my_str = 'My name is %s' % 'heechul' print(my_str) print('%d %d' % (1,2)) print('%f' % 3.14)
3de7efeb2e17aad9d4ffb5c6c86012494819fedc
heechul90/study-python-basic-2
/jump_to_python/chapter04/Practice.py
2,622
4.03125
4
### 04장. 프로그램의 입력과 출력은 어떻게 해야 할까? ## 연습문제 ## Q1 ## 주어진 자연수가 홀수인지 짝수인지 판별해 주는 함수(is_odd)를 작성해 보자. def is_odd(number): if number % 2 == 1: # 2로 나우었을 때 나머지가 1이면 홀수이다. return True else: return False print(is_odd(3)) print(is_odd(4)) ## Q2 ## 입력으로 들어오는 모든 수의 평균 값을 계산해 주는 함수를 작성해 보자. def avg...
2388ffc1748f17b3880bdad6525f9068de3f0ae4
heechul90/study-python-basic-2
/left_hand_coding/미운코딩새끼/String.split.py
150
3.734375
4
### String.split() my_name = 'heechul lee' print(my_name.split()) fruit_str = 'apple melon stawberry berry' print(fruit_str) print(fruit_str.split())
7032f66433f74c0cedb29d48b98cda6b5b69e6b9
heechul90/study-python-basic-2
/left_hand_coding/CheckiO_Elementary/Common_Words.py
282
3.78125
4
### Common_Words def common_words(text1, text2): text1_set, text2_set = set(text1.split(',')), set(text2.split(',')) common = text1_set.intersection(text2_set) return ','.join(sorted(common)) text1 = 'hello,world' text2 = 'hello,earth' common_words(text1, text2)
0238b342318d1f47463fdfd323d78d42d2557bbc
santa-python/python-workshop
/src/LacosDeRepeticao/for/gerador de tabuada.py
119
3.609375
4
n = int(input('Qual tabuada deseja ver?')) for i in range(11): print(str(n) + ' X ' + str(i) + ' = ' + str((n*i)))
5fa0bf7e6653d2fa6b0f8de2b02bee2194334285
santa-python/python-workshop
/src/LacosDeRepeticao/while/Exercicios/exFatorial.py
245
4.03125
4
# Receba um numero e calcule o fatorial dele. num = int(input('Digite um numero para calcular o fatorial: ')) cont = num fat = 1 # Continua até while(cont > 0): fat *= cont cont -= 1 print('O fatorial de {} é {}'.format(num, fat))
39625e138bf40c9c368536fcb38746e56eb0a631
santa-python/python-workshop
/src/LacosDeRepeticao/for/exemplo-for 4-3.py
288
3.734375
4
listaNumeros = [1,2,3,4,5,6,7,8,9,18] for n in listaNumeros: if(n < 1 or n > 9): msg = "Existem numeros invalidos nesse array" break print(n) else: msg = "Array percorrido" print(msg) # 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # Existem numeros invalidos nesse array
3cc043da91546b5edaa33a89e2dd871fdad8fabb
Vaeloc/Spotify-Charts-CSV-Downloader
/SpotifyCharts.py
1,520
3.515625
4
# Need to download Chrome web driver for Selenium at: # https://chromedriver.storage.googleapis.com/index.html?path=2.43/ # Selenium docs: https://selenium-python.readthedocs.io from selenium import webdriver import time import datetime from datetime import timedelta def fix_format(x): if len(x) == 1: res...
d8fbc755a27a42c631663891970d67a5ccf2a3b2
iturricf/clusteris
/clusteris/timer.py
679
3.5625
4
# -*- coding: utf-8 -*- from timeit import default_timer as timer class Timer(object): def __init__(self): self.times = [] self.start = 0 self.end = 0 def AddTime(self, description): t = timer() self.times.append((description, t)) if (description.lower() == "...
8b403b688f8c38480a05efd8921134e66d0a52d5
jianai0330/microbit
/lab19 coin.py
3,062
4.09375
4
def main(): """ This is the main function where the game loop resides """ collectorx = 2 collectory = 2 coins = makeCoins() startScreen(3) shine = 0.0 angle = 0 while True: gx, gy = processEvents() collectorx, collectory = update(collectorx, collectory, gx, ...
244873e7a05768b4804051d078d2f1368273583e
myyyy/myyyy.github.io
/_posts/leetcode/code/61.旋转链表.py
2,302
3.703125
4
# # @lc app=leetcode.cn id=61 lang=python # # [61] 旋转链表 # # @lc code=start # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def length(self,head): #计算链表长度 num = 0; node = head; ...
55394c2bb9060850df6428d2bccea032c854488c
myyyy/myyyy.github.io
/_posts/leetcode/code/189.旋转数组.py
690
3.6875
4
# # @lc app=leetcode.cn id=189 lang=python # # [189] 旋转数组 # # @lc code=start class Solution(object): def rotate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: None Do not return anything, modify nums in-place instead. """ # 可以用额外空间保存数组 ...
2075a86b327fc12699cbf8e6ca71d722346b145e
carzacc/Esperimenti-plotting-dati-serie-a
/tradizionale-subiti.py
294
3.609375
4
#!/usr/bin/env python from matplotlib import pyplot as plt # import numpy as np # import matplotlib import pandas as pd df = pd.read_csv("dati.csv") print (df) y = df['Tradizionale'] x = df['Gol Subiti'] plt.scatter(x, y) plt.ylabel("Punti Tradizionale") plt.xlabel("Gol Subiti") plt.show()
aed07319cf756ec39ef95171e1e3f5816b972362
krishna-prasath/guvi
/not_repeated.py
128
3.921875
4
a=input() a=list(a) z=[a[0]] for i in range(1,len(a)): if a[i] not in z: z.append(a[i]) print("".join(z))
ff51683dc89948e300cd250500a46f6077759efd
krishna-prasath/guvi
/common_divisor.py
248
3.65625
4
a=input() b=input() c=[a[0]] for i in range(1,len(a)): if a[i] not in c: c.append(a[i]) else: break d="".join(c) le=len(a)//len(d) le1=len(b)//len(d) if min(le,le1)<=2: print(min(le,le1)) else: print(max(le,le1)//2)
91789c6f72e8e2d57965d36087020022252adb1d
krishna-prasath/guvi
/stringrev_stack.py
197
3.65625
4
a=input() a=list(a) z,x=[],[] for i in range(len(a)): z.append(a[i]) for i in range(-1,-len(a)-1,-1): x.append(a[i]) if "".join(x)=="".join(z): print("YES") else: print("NO")
2ed2e58b77141c2b44a538a2e07cd69fdd1e92d6
krishna-prasath/guvi
/odeven.py
87
3.703125
4
a1,a2=map(int,input().split()) a1=a1*a2 if a1%2==0: print("even") else: print("odd")
8690423063702ddf39e781e27d48a5a5330931b3
krishna-prasath/guvi
/primenum.py
218
3.5
4
a=int(input()) d=[] if a==2: print(0) else: for i in range(2,a): c=0 for j in range(2,i+1): if i%j==0: c=c+1 if c==1: d.append(i) print(*d)
0905e7f966494e1ccb426c07e0cb07f4457f5ba9
strong-Ting/practice-of-python-and-git
/pi.py
679
3.5625
4
import math def estimate_pi(): k=0 now_k = 1 sum_k = 0 factor = (2*math.sqrt(2)) / 9801 while abs(now_k) > (1e-15): num = fac(4*k)*(1103+26390*k) den = (fac(k)**4)*(396**(4*k)) now_k = num /den now_k = now_k * factor sum_k = sum_k + now_k k = k+1 ...
b5e5774656530ab7b862537afe72e29a5b090ce1
nicholaslivingstone/numerical-integration-methods-fortran
/derivative_plot.py
711
3.71875
4
import matplotlib.pyplot as plt import math import numpy as np def main(): PI = math.pi k = [PI, PI**2] for value in k: x = np.linspace(-1,1,200) y = (value**2) * np.exp(np.cos(value * x)) * (np.power(np.sin(value * x), 2) - np.cos(value*x)) plt.plot(x, y) plt.legend([r"$k...
35dd7df706a90a7223e85d232a21a9f04588d9ed
shdx8/dtwrhs
/D02/dictionary/dictionary.py
193
4.125
4
my_dictionary={ "nama": "Elyas", "tinggal": "Probolinggo", "year": 2000 } print(my_dictionary) my_dictionary= {'warna': 'merah', 1: [2,3,5]} print(my_dictionary[1][-1])
ac9ea2d72c9ff6c204e1da79909827b6dee8edce
shdx8/dtwrhs
/D01/lat1.py
376
4.28125
4
# Buat list untuk menampung nama-nama teman my_friends = ["Anggun", "Dian", "Agung", "Adi", "Adam"] # Tampilkan isi list my_friends dengan nomer indeks 3 print ("Isi my_friends indeks ke-3 adalah: {}".format(my_friends[3])) print() # Tampilkan semua daftar teman print ("Semua teman: {} ada orang".format(len(my_friends...
1b1bd34c682c8dc9a47e4c8f7160c9a146c78792
saul-dogeman/RPS-25-enchanced-edition
/RPS_enchanced.py
2,962
3.71875
4
import random import json rolls = {} # roster.json def main(): player1, player2 = get_names() show_header() load_roster() play_game(player1, player2) def show_header(): print("") print(" ###################### ") print("") print(" Rock Paper Scissors ") pr...
b3e338a9e934587912380074e064cf2cc0e80c13
sjkirkpatrick/EAE2420
/Assignment3MDK/Assignment3MDK/Assignment3MDK.py
2,344
4.09375
4
class Node: def __init__(self,value): self.value = value self.next = None self.previous = None class LinkedList: def __init__(self): self.head = None self.tail = None # Inserts value into a new node # after the given node def insertAfter(self, node, value): newNode = Node(value) node....
c76499a5e5a4c12b1442cbac64691fc30bdef35d
Rednaks69/TP_Python
/TP3/Exe3/Exe3_TP3.py
306
3.734375
4
import math n = 4 fact = 1 for i in range(1, n+1): fact *= i print(" le factorielle de n = ", fact) print(" le 2emme fact est : ", math.factorial(4)) def fact(n): if n == 1: return 1 else: return n*fact(n-1) print(" fontion fact est : ", fact(4))
ef58707520df249b02b444a880da5d48837ef5f2
Rednaks69/TP_Python
/ComplementTP/1-Listes.py
8,917
4.09375
4
#################################################################################################### # * Complement de TP python # * made by : Azer Hasnaoui # * classroom : GLSI-1 # * year : 2020-2021 #################################################################################################### # ...
0f84ab083a92ca896e45e5f76a0c2ca43e389add
lainproliant/ntetris
/test/client_unit.py
815
3.625
4
#!/usr/bin/env python from enum import Enum class MessageType(Enum): REGISTER_TETRAD = 0 REGISTER_CLIENT = 1 UPDATE_TETRAD = 2 UPDATE_CLIENT_STATE = 3 DISCONNECT_CLIENT = 4 KICK_CLIENT = 5 CREATE_ROOM = 6 NUM_MESSAGES = 7 class Message: type = None length = 0 class RegisterTetrad...
d3a104191473f9a2dd1d5992b9b321a938350bd7
Rafael-Hercule/teste_reuniao
/Python/Testes/Teste_lista.py
792
4
4
avioes = ['f-5', 'grippen', 'mirage', 'a-29', 't-27', 'Hércules', 'Bufalo', 't-25'] print("Avões da FAB:") for aviao in avioes: print(aviao) ############################################################################ x = 0 while (x < 100): print(x, end= '; ') x = x+2 print() ###########################...
2bb72d383eda4d71e1b5aac1ca29fe7d513cd5fe
Rafael-Hercule/teste_reuniao
/Python/Testes/teste com todas as funcoes.py
13,135
4.1875
4
situacao = '' while situacao != '5': #situação inicial do sistema: print('1) entrar com os dados da aeronave') print('2) calculadora') print('3) -') print('4) -') print('5) sair do sistema') print() situacao = input('Situação: ') if situacao == '5': print('saindo do sistema...
04c5ff044b7b40bc250d392a4d84f7ae3c792c62
Rafael-Hercule/teste_reuniao
/Python/Exemplos Refeitos/12_Importando_módulos.py
417
3.640625
4
# Importando um módulo x = 2 y = 3 import Funcoes as f print('Soma: ' + str(f.somar(x,y))) import Funcoes as f print('Subtração: ' + str(f.subtrair(x,y))) import Funcoes as f print('Multiplicação: ' + str(f.multiplicar(x, y))) import Funcoes as f print('Divisão: ' + str(f.dividir(x,y))) import Funcoes as f print('...
8afc77c15b385865679fa23cee4aa62b406cdb88
renato1891/Geometria-Computacional
/Fecho/Fecho.py
1,701
3.5625
4
from collections import namedtuple from Classes.Conjunto import Conjunto from ProblemasClassicos.ProblemasClassicos import orientation import copy Point = namedtuple('Point', 'x y') class ConvexHull(object): _points = [] _hull_points = [] def __init__(self, ponto: Conjunto): self._points = copy...
fc929d61503b31cd3056bf4795151e016f62f10f
E-Abu/xiaohudiAI_poster_Englishtestinf
/string_test.py
198
3.59375
4
#name = 'i love you' #print name[:17] #print name.find('you') #print name[:7] #print name.find("o") x = 13.141592 str_x = str(x) dot = str_x.find('.') #print str_x[dot + 1] print 1 + 1 print 0 ** 0
45171d558ba67507340c87391dd73a55d25cda6a
AltafShk/Probaility-and-Statistics-Project
/Task4.py
1,741
3.5625
4
from random import random from random import seed import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import csv def One_D_random_walk(start_pos, steps): fig, axs = plt.subplots() randomWalk = [] randomWalk.append(start_pos) for i...
d19cb3e849ab5d6e7d43843a000d24992e0a3b22
llewyn-jh/codingdojang
/calculate_trigonometric_function.py
1,046
4.28125
4
"""Calculate cosine and sine funtions in person""" import math def calculate_trigonometric_function(radian_x: float) -> float: """This function refer to Taylor's theorm. A remainder for cos or sin at radian_x follows Cauchy's remainder. The function has 2 steps. Step1 get a degree of Taylor polynomial...
1c79b497bb8cd9d30c37875669e6909dc1d578da
koson/CAN-D
/gooey/gooey/models/treeitem.py
1,748
4.0625
4
class TreeItem(object): """ A base class for models that is to be represented as a tree. :param `parentItem`: The parent of the TreeItem. :param `itemModel`: The model which holds the data for the TreeItem. :param `childItems`: The children of the TreeItem. """ def __init__(self, mo...
c5804bc5b5f73d0b4e8346d8a8bd7425f643f51e
nuhfurkan/Programming_and_Mathematical_Thinking
/Chapter-3/Chapter3.py
1,651
4.09375
4
# Print the character '#', for n times (n given in the file "data") def exercise1(): file = open("data") for line in file: sharps = "" for _ in range(1, int(line)+1): sharps += "#" print(sharps + " " + str(line)) # Print maximum 25 '#' character for n times (n given in the ...
a74a47fe4b86111a3b5155132f6c7f2822b230ee
ken1009us/cs50-practice
/Python/credit/credit.py
1,787
3.578125
4
import cs50 # main function def main(): # get the number from user number = cs50.get_string('Number: ') # append the each number to the list and reverse the number list re_number_list = [] for i in number: re_number_list.append(i) re_number_list.reverse() sum_x = 0 sum_y = 0 ...
89354cedc6f44dd1f57052e103bf0ba2bae9450b
kingdomwxl/test666
/newgame/class.py
166
3.90625
4
print("请输入父亲的身高:") a=float(input("数字")) print(a) print("请输入母亲身高:") b=float(input("数字")) print(b) c=a+b d=c*0.54 print(d)
e78bb6f14e5aa6a3fc8e765ac206b458bcaa2fb3
sirobhushanamsreenath/DataStructures
/Stacks/stack.py
1,026
4.21875
4
# Implementation of stack data structure using linkedlist class Node: def __init__(self, data=None, next=None): self.next = next self.data = data def has_next(self): return self.next != None class Stack: def __init__(self, top=None): self.top = top def print_stack(s...
8b363abf939a579a953631dbacee121816d582f0
RahulChowdaryN/Cracking-The-Coding-Interivew-Solutions
/Stacks_Queues/test.py
1,679
4
4
class Stack: def __init__(self): self.stack_one = [] def push(self,item): temp_stack = [] if not self.stack_one: self.stack_one.append(item) return True if item >= self.stack_one[-1]: self.stack_one.append(item) return True ...
49cff1b5855ed04bc034558801c180b53386a3b1
RahulChowdaryN/Cracking-The-Coding-Interivew-Solutions
/Stacks_Queues/3.4_queue_with_stacks.py
694
3.640625
4
class MyQueue: def __init__(self): self.stack1 = [] self.stack2 = [] def add(self,item): self.stack1.append(item) return True def remove(self): if self.stack2: item = self.stack2.pop() return item if not self.stack1: ret...
95087050062b69a1dc97e4c6b55a20d05ecb7c46
RahulChowdaryN/Cracking-The-Coding-Interivew-Solutions
/Arrays_Strings/URLify_1.3.py
413
3.671875
4
def urlify(str1,length): # if length == 0 or len(str1) != length: # return False str1 = str1.strip() str2 = str1.replace(" ","%20") return str2 def urlify1(str1,length): s = "" for i in range(length): if str1[i].isspace(): s = s+"%20" else: s = ...
2859a003479663f28ff045fa7ae318fb811f6677
RahulChowdaryN/Cracking-The-Coding-Interivew-Solutions
/Stacks_Queues/3.3_stack_of_plates.py
1,969
3.53125
4
class Stack_Plates: def __init__(self): self.threshold = 3 self.counter = 0 self.stack_dict = {} def push(self,item): if len(self.stack_dict) == 0: self.stack_dict[self.counter] = [item] return True if len(self.stack_dict[self.counter]) <self.thr...
6e68ed73f4657c7b6f1b167c1161b10a8e53b10d
ronshuvy/IntroToCS-Course-Projects
/Ex9 - Rush Hour/game.py
5,227
3.921875
4
import helper import sys from board import * from car import * # Game constants VALID_CAR_NAMES = {'Y', 'G', 'B', 'O', 'W', 'R'} VALID_CAR_DIRECT = {'u', 'd', 'l', 'r'} VALID_ORIENTATION = [1, 0] VALID_LOCATION_IND = [i for i in range(7)] MIN_CAR_LEN = 2 MAX_CAR_LEN = 4 class Game: """ This class represents ...
c33c1e6d9251779cf6f7f8484d8e431575e8d1fa
ronshuvy/IntroToCS-Course-Projects
/Ex2 - Math/shapes.py
1,529
4.46875
4
# FILE : shapes.py # WRITER : Ron Shuvy , ronshuvy , 206330193 # EXERCISE : intro2cs1 2019 import math def shape_area(): """ Calculates the area of a circle/rectangle/triangle (Input from user) :return: the area of a shape :rtype: float """ def circle_area(r): """ Calculate...
40b8deacf50fcccff812ecb4d974e59f90480a55
ronshuvy/IntroToCS-Course-Projects
/Ex10 - Asteroids/ship.py
738
3.609375
4
from asteroids_config import GameConfiguration as Cfg from game_object import GameObject class Ship(GameObject): """ A class for asteroids game ship """ def __init__(self, x, y, heading=0): GameObject.__init__(self, x, y, speed=(0, 0), heading=heading) self.__lives = Cfg.INIT...
e3a613de2b32756b5a6bad7846b1db69cd134bab
SonnyTosco/HTML-Assignments
/Python/sonnytosco_pythonoop_bike.py
1,603
4.3125
4
class Bike(object): def __init__(self, price,max_speed): self.price=price self.max_speed=max_speed self.miles=0 print "Created a new bike" def displayInfo(self): print "Bike's price:"+ str(self.price) print "Bike's max speed:"+str(self.max_speed)+'mph' pri...
204831652f043b99c2515aaf6c84bf56bff121ed
jdzehr/ReverseString
/reverse_string.py
194
4.15625
4
string1 = input("Type a string \n") string2 = ''.join(reversed(string1)) string3 = string1[::-1] print("You entered: %s" % string1) print(string2) print(string3) print(string1[::-1])
82df475411c6757e492f1cf995ad74c3edd699c8
ytakzk/learnml-exercises
/support/classes.py
3,596
3.53125
4
import numpy as np import sys class Redirect: ''' Redirect standard output to a specified file object. This lets us use print() to write directly to disk. ''' # Set new attribute. def __init__(self, o_new): self.new = o_new # Redirect stdout. def __enter__(self): ...
c0d79d51485bdfd5440b300faa3570b851efbe82
amonroy/practice
/challenge_4.py
2,936
3.8125
4
#challenge #247 [Easy] Secret Santa #Take input, pair random people together, but make sure they are not in the same family. Families will be indicated by people on the same line. import sys import random f = open('santa_file.txt') def make_list(file): list = [] for line in f: list.append(line.strip(...
c6ea0c89013f9c828155d4927c2265575dadeb1f
RochelleGardner/IDF-Programming
/Python/22Apr/accellerate.py
367
3.53125
4
#! /usr/bin/env python3 svel = float(input("What is the starting velocity in peters per second? ")) evel = float(input("What is the ending velocity in meters per second? ")) time = float(input("How long did all that take? (in seconds) ")) accel = (evel - svel)/time print "\nThe average acceleration was ", acce...
2ccceaca710941a613e8983127337e333a0327cc
RochelleGardner/IDF-Programming
/Python/24Apr/CtoPy2.py
1,547
3.953125
4
''' /* Performance Lab 5A * Rochelle Gardner * 6 Feb 2019 * perfLab_5-a.c * Write a program to calculate the hypotenuse of a right triangle * using Pythagorean's Theorem. * Input the two legs (A and B)- Output the hypotenuse (C) */ #include <stdio.h> #inc...
c0cd8780ff4407ddeb8b8c5aa7a4427d1b0d22da
RochelleGardner/IDF-Programming
/Python/29Apr/guessing2-0.py
989
3.6875
4
#! /usr/bin/env python3 import tkinter as tk from tkinter import ttk class CounterProgram: def __init__(self): self.window = tk.Tk() self.guess_counter = None # All attributes should be initialize in init self.create_widgets() def create_widgets(self): self.gues...
00a3bcc2422de0e3f71b5e7320e8fcf4e02d873d
RochelleGardner/IDF-Programming
/Python/23Apr/num2.py
170
3.8125
4
#! /usr/bin/env python3 def main(): i = 1 sq = 0 for i in range(1, 11): sq = i * i print(sq, " ", end = '') i = i + 1 main()
46ac5ac59845851beb33bee903fdfdc699da5d0e
RochelleGardner/IDF-Programming
/Python/13May/hangman.py
5,486
4.21875
4
#! /usr/bin/env python3 ''' Rochelle Gardner 13 May 2019 Hangman Write a hagman game that randomly generates a word and prompts the user to guess on eletter at a time, as shown in the sample run. Each letter in the word is displayed as an asterisk. When the user makes a corr...
13ff32648e515107376972672ac74737c6670379
HanaAuana/PyWorld
/DNA.py
2,807
4.21875
4
#Michael Lim CS431 Fall 2013 import random # A class to hold a binary string representing the DNA of an organism class DNA(): #Takes an int representing the number of genes, and possibly an existing genotype to use def __init__(self, numGenes, existingGenes): self.numGenes = numGenes #If a g...
26de5abafa2715f7e4b353b8b9b044be006efd4e
krisbobo/hackerrank
/algorithms/Python/implementation/cavity map.py
977
3.65625
4
#!/bin/python3 import math import os import random import re import sys # Complete the cavityMap function below. def cavityMap(grid): n = len(grid) new_grid=[] print(new_grid) for i in range(n): temp ="" for j in range(n): if i!=0 and j!=0 and i!=n-1 and j!=n-1: ...
b24db3b363703c2c4c43834437d8cae6c04a3620
krisbobo/hackerrank
/10 Days of Statistics/Day 0- Weighted Mean.py
406
3.671875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT size = int(input()) dataset = list(map(int, input().split())) data_loc = list(map(int , input().split())) weighted = [] weight = 0 for i in range(len(dataset)): weight = dataset[i] * data_loc[i] weighted.append(weight) ...
c83f26f44d1fe4468846006d695572e422faf662
krisbobo/hackerrank
/algorithms/Python/search/sherlock and the array.py
999
3.5625
4
#!/bin/python3 import math import os import random import re import sys # Complete the balancedSums function below. def balancedSums(arr): first = 0 last = len(arr)-1 found = False while( first<=last and not found): mid = (first + last)//2 ls = left_sum(arr,mid) rs = right_su...
557c1642f18318f521f9253444c90eb10f8e0c0c
krisbobo/hackerrank
/algorithms/Python/implementation/sherlock and squares.py
796
3.59375
4
#!/bin/python3 import math import os import random import re import sys # Complete the squares function below. def squares(a, b): upper = 0 lower = 0 for x in range(a,b+1): if math.sqrt(x).is_integer(): lower = int(math.sqrt(x)) break for x in range(b,a-1,-1): ...
acc65ffae4c6b1a937ccceedddfc1ec3719833b8
ongoleen/Hangaroo-Game
/Hangaroo_2.py
398
3.8125
4
# -*- coding: utf-8 -*- secretWord = 'apple' lettersGuessed = ['e', 'i', 'k', 'p', 'r', 's'] def getGuessedWord(secretWord, lettersGuessed): user_guess = '' for letter in secretWord: if letter in lettersGuessed: user_guess += letter else: user_guess += '_ '...
697f05adc3fd045a5d8b4757ba1ceae1a92de41c
DrewStanger/pset7-houses
/import.py
1,595
4.375
4
from sys import argv, exit from cs50 import SQL import csv # gives access to the db. db = SQL("sqlite:///students.db") # Import CSV file as a command line arg if len(argv) != 2: # incorrect number print error and exit print(f"Error there should be 1 argv, you have {argv}") exit(1) # assume CSV file e...
edbc33916a978a70b0167cb46c36f1efe3c116da
nus-sps/workshops.tfi.data-visualisation
/files_python/dummy-class_housekeeping.py
1,494
3.875
4
# %% Result # %% Tasks ''' ```python import pandas as pd df = pd.read_excel('dummy_class.xls') ``` Starting with the code above, answer the questions in the following table using the Pandas command indicated. | | Question | Possible code | | :--: | ---...
e392f4f5891689554546384163a58598f5002c03
nus-sps/workshops.tfi.data-visualisation
/files_python/pandas-explore-EX1.py
930
3.65625
4
# %% Result # %% Tasks ''' 1. Loading in the dataset from https://raw.githubusercontent.com/nus-sps/workshops.tfi.data-visualisation/darren-branch/files/StudentPerformance2.csv 2. What is the shape of the data? I.e how many rows and columns are there? 3. What does the dataframe look like? 4. Drop unnecessary columns t...
487ed99c32a9a44f7a1eb5c8cfeda22e48e06a66
nus-sps/workshops.tfi.data-visualisation
/files_python/matplotlib_filled-plot.py
1,133
3.640625
4
# %% Results # %% Code ''' In this plot: - We generated sine and cosine graphs. - We plotted a $y = 0$ line. - Filled in the spaces where $\cos x > \sin x$ with orange. - Filled in the spaces where $\sin x > \cos x$ with blue. ''' from sys import argv # Hide import numpy as np from matplotlib import pyplot as plt ...
1efae2be67400e33d8c29215a34a5f86896dc0c5
EloiSanchez/Euler
/P46/P46.py
1,372
3.84375
4
""" Goldbach''s other conjecture: https://projecteuler.net/problem=46 Brute force and horrible method Eloi 11/03/2021 """ from time import time def get_prime_list(n, p=[2, 3]): p.sort() while p[-1] < n: is_prime = False m = p[-1] while not is_prime: m += 2 ...
5111c72cbfdc0ea62973c8469876cd7f8f738018
helen-m-he/hangman
/hangman.py
6,467
4.15625
4
# ----------------------------------- # Helper code -- from MITx: 6.00.1x import random WORDLIST_FILENAME = "words.txt" def loadWords(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word list, this function may take a while to finish. "...
202aaa597b0457d9eb1269a97cde383dd2f0a808
Nicolae-Olaru/Python
/equation2grade.py
4,658
4.25
4
#!/usr/bin/python3 import math print("Program to calculate the 2_grade equations..."); variable_A = 0; variable_B = 0; variable_C = 0; delta_result = 0; modulo_result = 0; x1_result = 0; x2_result = 0; result = 0; #Variables ok! print("Insert the value of A\n") #Insert value of a variable_A =int(input()) #Input a print...
b5810dda64cdd275a340ee97c07fd2e17f025cc9
ManuelMeraz/ReinforcementLearning
/rl/agents/reprs/value.py
653
3.53125
4
import pprint class Value: def __init__(self, value: float = 0.0, count: float = 0.0): """ Stores the value of a state and how many times the agent has been in this state :param value: The total accumulated reward computed using temporal difference :param count: The number of time...
eb9fb0590d4327719c614953793a7dde8895d09f
Vinceri/leetcode
/500. Keyboard Row.py
562
3.765625
4
class Solution(object): def findWords(self, words): """ :type words: List[str] :rtype: List[str] """ keyboard_1 = set("qwertyuiop") keyboard_2 = set("asdfghjkl") keyboard_3 = set("zxcvbnm") result = [] for word in words: ...
7008ba8f508c8598a2166e508cb04456f86f496b
Vinceri/leetcode
/258.AddDigits.py
318
3.53125
4
class Solution(object): def addDigits(self, num): """ :type num: int :rtype: int """ snum = str(num) while len(snum) != 1: rsl = 0 for w in snum: rsl += int(w) snum = str(rsl) return int(snum)
d21f7fdf465fccb61e3a9035064b2bd544589691
rroberts1990/pybites
/bite_31/matmul.py
469
3.703125
4
class Matrix(object): def __init__(self, values): self.values = values def __repr__(self): return f'<Matrix values="{self.values}">' def __matmul__(self, other): pass a = [[1, 2], [3, 4]] b = [[11, 12], [13, 14]] x = [(a[0][0] * b[0][0]) + (a[0][1] * b[1][0]), (a[0][0] * b[0][...
23c360849a7e9a3b79050cb559f3dd53b7baed56
xaviave/automate_genetic_car
/srcs/Tools/Genetic.py
2,429
3.703125
4
import datetime import random class Genetic: mutation: int = 0 iteration: int = 0 initial_size: int mutation_count: int = 0 population_size: int crossover_count: int = 0 population: list = [] past_population: list = [] end_time: datetime.timedelta start_time: date...
5bd25149ec783bd7760a566234da24f5e6233049
zztkm/ex-line_profiler
/fizzbuzz.py
315
3.640625
4
def fizzbuzz(n): if n % 3 == 0 and n % 5 == 0: return 'FizzBuzz' if n % 3 == 0: return 'Fizz' if n % 5 == 0: return 'Buzz' return str(n) def main(): for i in range(1, 100): message = fizzbuzz(i) print(message) if __name__ == '__main__': main()
31ccae971da7f37c2364a73ec60a458988d324d9
maheshk172/python-playground
/02-functions/03-file-manipulations.py
912
3.671875
4
file_name = "./data/students-db.txt" students = [] def add_student_to_db(name, rollno): tempStudent = { "name": name, "rollno": rollno } try: file = open(file_name, "a") file.write(str(tempStudent) + "\n") file.close() except Exception as exception: print...
43184d44bab486b44b09f1cdfaa8cc09d4a85ac8
maheshk172/python-playground
/03-oops-and-modules/01-classes.py
1,483
3.9375
4
class Student: # name = "" # rollno = None def __init__(self, name, rollno): self.name = name self.rollno = rollno def toString(self): return f"name:{self.name}, rollno:{self.rollno}" def __str__(self): return "name:{0}, rollno:{1}".format(self.name, self.r...
c0f9cf2c0892c55964561d0db16d2558c8ffd699
manjesh41/gui
/recursive.py
119
3.828125
4
def factorial(n): if n==1: return 1 else: return (n*factorial(n-1)) ans=factorial(5) print(ans)
b982d5403b5334baa6e3ec0af46dee88ac765ead
royanusree17/royanusree
/for-3.py
240
4.15625
4
numbers = [1,2,3,4,5,6,7,8,9] odd_count=0 even_count=0 for a in numbers: if a % 2: odd_count+=1 else: even_count+=1 print("total even numbers is:",even_count) print("total odd numbers is:",odd_count)
ce14a060e4a7de5a16e7f798e106eacd216428d9
Max6411/Python_
/Matplotlib-3-Seting the axis.py
1,087
3.546875
4
import matplotlib.pyplot as plt import numpy as np x = np.linspace(-3, 3, 50) y = x**2 plt.xlim((-2, 2)) # 限制x轴的区间 plt.ylim((-1, 4)) plt.xlabel('i am x axis') # 给x轴命名 plt.ylabel('i am y axis') plt.plot(x, y) plt.show() # show()之后plt所设置的属性都会消除 new_x = np.linspace(-1, 4, 5) # # print(new_x) [-1. ...
eed60b42fafa4e2cd7899d941fe4aa586aa8ac71
Max6411/Python_
/Numpy-7-copy.py
220
3.59375
4
import numpy as np arr1 = np.arange(4) arr2 = arr1 arr1[0] = 10 print(arr2) # [10 1 2 3] 默认的赋值方式是浅复制 arr3 = arr1.copy() arr1[0] = 0 print(arr3) # [10 1 2 3] copy过来的就是深复制
6dc6fe371096690d58e3d95ce261de815ba2169d
Changkyuuu/Chapter2_1
/operator_arithmetic.py
559
3.578125
4
# 사칙연산 print(2 * 3) print(2 + 3) print(2 - 3) print(2 / 3) print(2 / 3.0) print(2.0 / 3.0) # //몫 연산자 **(지수승) % 나머지 연산 print(2 // 3) print(2 ** 3) print(2 % 3) # divmod() 함수 print(divmod(2,3)) t = divmod(2,3) print(t, type(t)) a, b = divmod(2, 3) print(a, b) # 연산자 우선순위 print(2 + 3 * 4) print(-2 + 3 * 4) print(-(2 +...
1d7187a098f352bf1faf46303049e0d53e5efb25
Setorator/AoC_2020
/day_3/day_3.py
1,139
3.640625
4
def main1(): with open("input1.txt") as f: space = [] for line in f.readlines(): space.append(line.rstrip()) row_size = len(space[0]) x_pos = 0 y_pos = 0 count_trees = 0 while y_pos < len(space) - 1: x_pos += 3 x_pos %= row_size y_pos += 1 ...
de2a9e12c9c3a0665168c7b560deb00f2fced2fb
Setorator/AoC_2020
/day_7/day_7.py
1,462
3.609375
4
def main1(): rules = {} with open("input.txt") as f: for line in f.readlines(): contain_ind = line.index(" contain ") contains_bags = line[contain_ind + len(" contain "):].split(", ") contains_bags[-1] = contains_bags[-1][:-2] for i in range(0, len(conta...
44c4c96fdebf57d891513f6faa475ecb62952597
pookie9/capstone
/Sensors.py
12,072
3.625
4
import cv2; import math; import numpy as np; #Eventually will be the real deal class Sensors: def __init__(self): print "Initializing real sensors" #Simulator class SimSensors: #mazePic is the path to the picture that is the background, heights is the corresponding 2D array of heights #initPos is...
ee89a856bf1c898dd2d9766b86693ef5e89057f8
elaineli/ElaineHomework
/Homework-2018-03-18/exercise2.py
180
3.53125
4
# ### ##### def drawTriagle(n): numLoops = n//2 + 1 print(numLoops) for i in range(1, numLoops+1): print((' ' * (numLoops - i)) + ('#' * i)) drawTriagle(7)
5d1b536e761a61a0abc0890e9dbd4327cceb4cd2
elaineli/ElaineHomework
/ListAndDictionary-20180311/hw2.py
454
4.03125
4
d = {"Allison":18, "Benson":48, "David":20, "Erik":20, "Galen":15, "Grace":25, "Helene":40, "Janette":18} # Initialize an empty dictionary d2 = {} # Build dictionary with key of age, value of a list of names for myk, myv in d.items(): if myv not in d2: d2[myv] = [myk] else: d2[myv].append(myk...
0606a46baee937e230d7ae503a69c4724957c3d0
elaineli/ElaineHomework
/Justin/hw2.py
834
4.125
4
ages = { "Peter": 10, "Isabel": 11, "Anna": 9, "Thomas": 10, "Bob": 10, "Joseph": 11, "Maria": 12, "Gabriel": 10, } # 1 find the number of students numstudents = len(ages) print(numstudents) # 2 receives ages and returns average def averageAge(ages): sum = 0 for i in ages.values(): sum += i lengt...
1b7fe13d873855f3e5eb556ac7d14e42c2d00f62
elaineli/ElaineHomework
/ListAndDictionary-20180311/hw3.py
537
3.578125
4
d = ['Bruce Lee', 'Nathan Chen', 'Coby Bryan', 'Shawn White', 'Tyrion Bryan', 'Allison Chen', 'Stan Lee', 'Catelyn Chen', 'Joy Chen', 'Jonathan Lee', 'Bob White', 'Ned Chen'] # Initialize an empty dictionary d2 = {} # Build a new dictionary, with key being last name, count of last name being value for i in d: nam...
193987a5e7be1118b085f97888720d89a34c9260
thaysom22/IAL_exam_module_optimizer
/input_functions.py
812
4
4
#function to input modules and results and return as dict def input_module_results(all_units): completed_module_results = {} print('Enter unit name and UMS score for each unit.\nWhen all results entered enter: \'done\'\n') temp_unit_title = input('Enter unit title: ').upper() while temp_unit_title != 'DONE':...
d05a46a0c6de39669aa68746d6e6b56e6f807ab7
mjrosenberg/data-structures-algorithms
/palandromeLinkedList.py
640
3.640625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def isPalindrome(self, head): """ :type head: ListNode :rtype: bool """ asArr = [] cu...
8e472f11b1d5e9c6d3cec5500c8fb2229f3a6641
Kakadiyaraj/Leetcode-Solutions
/singalString.py
539
4.21875
4
#Write a program that reads names of two python files and strips the extension. The filenames are then concatenated to form a single string. The program then prints 'True' if the newly generated string is a palindrome, or prints 'False' otherwise. name1 = input('Enter a first file name : ') name2 = input('Enter a seco...