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
cf093d566a930799df7dd85bd5a646007cbde935
diddle-doo/Python
/Leet-code-add-num.py
307
3.640625
4
# Check all the combinations in a list if it matches to target and return the result # [1,2,3] #target=4 #(1,3),(3,1) num_list=[1,4,6,5,3,7] target=10 result=[(num_list[i],num_list[j]) for i in range(len(num_list)) for j in range(len(num_list)) if num_list[i]+num_list[j]==target and i!=j] print (result)
bf2c72e370d85132853b2bfe4c7ed3484704f194
prasertcbs/matplotlib
/src/plot_heart.py
875
3.71875
4
import numpy as np import matplotlib.pyplot as plt def heart(): # http://mathworld.wolfram.com/HeartCurve.html t = np.linspace(0, 2 * np.pi, 360) # print(t) x = 16 * np.sin(t) ** 3 y = 13 * np.cos(t) - 5 * np.cos(2 * t) - 2 * np.cos(3 * t) - np.cos(4 * t) plt.plot(x, y) plt.plot(x + 10, y)...
449593b62be360dcddbc40c8ac67ba069e5a2cf6
choyai/Final-FRA142
/BubbleSort.py
983
4
4
from LinkedList import LinkedList from Node import Node from StackClass import StackClass from Queue import Queue import datetime import time import random def BubbleSort(list_linked): done = False while done == False: swap = False for i in range(list_linked.size - 1): item = list_l...
f33da90ea9f9939424fd736c72f7ea42d387ce58
kq5-vcd/Online-Othello
/Bot/Board.py
3,320
3.5625
4
class Board: DIR = [[0, 1], [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1]] def __init__(self, rows, cols): self.rows = rows self.cols = cols self.new_board() def new_board(self): self.board = [[0] * self.cols for x in range(self.rows)] self.init_piec...
99dced585546ba0b549506e71edc5d055826d095
xu1718191411/AT_CODE_BEGINNER_SELECTION
/AT_CODE_BEGINNER_SELECTION/ABC086C.py
1,248
3.625
4
import math def main(): n = int(input()) #多少个点 coordinates = [[0, 0, 0]] for i in range(n): coordinates.append(convert(input().split(" "))) if checkNode(coordinates): print("Yes") else: print("No") def checkNode(coordinates): for key,arr in enumerate(coordinates): ...
979e3a174ea5dba42414119f1e73932d83f38cfb
xu1718191411/AT_CODE_BEGINNER_SELECTION
/CONTEXT_159/string_palindrome.py
428
3.859375
4
def isOK(x): return x == "".join(reversed(x)) def calculate(S): if isOK(S) == False: print("No") return arr = list(S) length = len(arr) s1 = arr[0:(length-1)//2] if isOK("".join(s1)) == False: print("No") return s2 = arr[(length+2)//2:length] if isO...
286556aeecd6c8c24cc34cd140be28872193f5dc
xu1718191411/AT_CODE_BEGINNER_SELECTION
/AT_CODE_BEGINNER_SELECTION/ABC049C.py
206
3.671875
4
def main(): S = input() arr = ['eraser', 'erase', 'dreamer', 'dream'] for s in arr: S = S.replace(s,"") if len(S) == 0: print('YES') else: print('NO') main()
81a2828a384ca365ae75a18a47e625ee65058f18
xu1718191411/AT_CODE_BEGINNER_SELECTION
/CONTEXT_125/gcd_blackboard.py
784
3.59375
4
import fractions import math def gcd(a,b): return fractions.gcd(a, b) # def gcd(a,b): # return math.gcd(a,b) def calculate(arr): # L length (N) L = [arr[0]]*len(arr) # R length (N) R = [arr[-1]]*len(arr) for i in range(len(arr)): if i == 0: continue L[i] = ...
1139c48fa02298099bcfeede19595544123dd8e3
xu1718191411/AT_CODE_BEGINNER_SELECTION
/CONTEXT_125/flipping_signs.py
680
3.640625
4
import math def calculate(arr1,arr2,zeroExist): if (len(arr1) % 2 == 0) or (zeroExist == True): return sum(arr2) + sum(arr1) else: return sum(arr2) + sum(arr1) - 2 * (calculateAbsSmallest(arr1,arr2)) def calculateAbsSmallest(arr1,arr2): arr1.sort() arr2.sort() if len(arr2) == 0: ...
96effd5e4f1063a6f30c74cd9760748702e5c0e3
xu1718191411/AT_CODE_BEGINNER_SELECTION
/CONTEXT_160/golden_coins.py
142
3.6875
4
X = int(input()) def calculate(x): a = x // 500 b = x % 500 c = b // 5 d = b % 5 print(a * 1000 + c * 5) calculate(X)
dd323705edf7b328ef861127b2deeaea874266d7
xu1718191411/AT_CODE_BEGINNER_SELECTION
/CONTEXT_161/abc_swap.py
143
3.53125
4
S = input().split(" ") X = int(S[0]) Y = int(S[1]) Z = int(S[2]) tmp = Y Y = X X = tmp tmp = X X = Z Z = tmp print("{} {} {}".format(X,Y,Z))
923dddc9653a1d246a4922c2514b11fe8f506573
xu1718191411/AT_CODE_BEGINNER_SELECTION
/CONTEXT_152/comparing_strings.py
244
3.640625
4
def calculate(a,b): s1 = list([str(a)]*b) s1 = "".join(s1) s2 = list([str(b)]*a) s2 = "".join(s2) arr = [s1,s2] arr = sorted(arr) print(arr[0]) S = input().split(" ") a = int(S[0]) b = int(S[1]) calculate(a,b)
b40406ef722ec48aad4624c5814d850d9d7154eb
naderifard/Mench
/classes.py
1,957
3.515625
4
from data import * boarddic={} for i in mainboard: boarddic[i]=None class Piece: def __init__(self,color): self.color=color self.place="out" @property def path(self): i = colors.index(self.color) home=Homes[i] path=[home] for j in Path[i...
e40c1a1235616b50f4eee5211d52146eb15d2234
rugved-mahamune/interview-practice
/fibo.py
273
4.1875
4
'''def fibonacci(n): if(n == 1 or n == 2): return 1 else: return fibonacci(n-1) + fibonacci(n-2) num = 8 print(fibonacci(num))''' list1 = [0,1] n = 8 curr = 2 while(curr < n): list1.append(list1[curr-1] + list1[curr-2]) curr+=1 print(list1)
34240540291efd51e1ed1073c1c4c8c9e9eb265e
victorbonomi16/Exercicios
/exercicio16.py
152
3.765625
4
polegadas = float(input("informe o comprimento em polegadas? ")) centimetros = polegadas* 2.54 print("o comprimento em centimetros é : ", centimetros)
16c38968d92bc2a9259d7eaf9e855bb73daa9415
victorbonomi16/Exercicios
/exercicio12.py
108
3.640625
4
milhas = float(input("Qual a distancia em milhas? ")) km = 1.61*milhas print("A distancia em km é ", km)
6ab7516511bba7f6ee6ee9b7386c786ee43f8c30
TiagoCaldaSilva/FEUP-MNUM
/Exames/Estudar_exame/Exame_2017/main.py
4,435
3.609375
4
import math as m B = (m.sqrt(5) - 1) / 2 A = B ** 2 def f1(x, a): return (x - a) ** 2 + x ** 4 def ex1(x1, x2, a, function, error): while abs(x1 - x2) > error: x3 = x1 - A * (x2 - x1) x4 = x1 - B * (x2 - x1) if function(x3, a) > function(x4, a): x1 = x3 else: ...
13357178d2b47ddc425007b9669b5fb566d8742d
TiagoCaldaSilva/FEUP-MNUM
/Práticas/TP11/main.py
7,211
3.5625
4
import math as m # import numpy as np def f(x): return x * m.exp(x**2 - 4) - 1 def df_dx(x): return m.exp(x**2 - 4) - 1 + x*(2*x*m.exp(x**2 - 4)) def bisection_method(a, b, function, error): xn_ = (a + b) / 2 xn = xn_ + 1 counter = 0 while abs(xn_ - xn) > error: xn = xn_ if...
bb08eadd97d6962e66197eb897b94b6fb0123502
TiagoCaldaSilva/FEUP-MNUM
/Exames/Estudar_recurso/Teste1_2017/main.py
584
3.625
4
import math as m def newton(guess, function, diff, error, it): _it = 0 new_guess = guess guess += error * 10 while abs(new_guess - guess) > error and _it != it: print(guess, new_guess, function(new_guess), _it) guess = new_guess new_guess = guess - (function(guess) / diff(guess...
a90bf1dae1bad97f8a0844f9a6a95a0f1ebacd2f
ChristianCampos-55/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/base.py
798
3.578125
4
#!/usr/bin/python3 """ Module that hosts the class Base """ import json class Base: """ Simple Base class """ __nb_objects = 0 def __init__(self, id=None): if id is not None: self.id = id else: Base.__nb_objects += 1 self.id = Base.__nb_objects @...
b7ea0d6141067119b39163ae70e1d56f153021af
faliona6/PythonWork
/OOP/characters.py
615
3.59375
4
class Character: def __init__(self, health, name): self.health = health self.name = name def __str__(self): healthInfo = " Health: " + str(self.health) nameInfo = "Name: " + self.name return nameInfo + healthInfo def changeName(self, newName): self.name = newN...
286b12caeb30c56d501ed7e7a81df3491a834bc2
faliona6/PythonWork
/misc.py
637
3.8125
4
import copy #7/21/17 """ def printList(theList): for x in range(len(theList)): print("-" + str(theList[x])) myList = [0, 1, 2, 3, 4, 4, 3, 4, 4, 7, 7, 6] hello = ["oops", "I", "did", "it", "again"] """ """ print(myList[0]) myList.sort() myList.insert(5,"hello") myList[4] = str(myList[3]) + " HEEEEE" pri...
0b5ce13bcb253816f93f40949150a0fc47b2dddd
faliona6/PythonWork
/letter.py
404
4.125
4
word = input("What is the magical word?") def Dictionary(word): dictionary = {} a = 0 for letter in word: if letter in dictionary: dictionary[letter] = dictionary[letter] + 1 else: dictionary[letter] = 1 return dictionary dictionary = Dictionary(word) for let, ...
4202958f0e556de11b126b74cc083ec21fad754b
ramanchawla1290/Snake.pygame
/snake.py
5,408
4.125
4
""" SNAKE Game A take on the classic snake game using Python 'pygame' module In case of Game Over: press 'ENTER' to Start a New Game press 'ESC' to Exit """ import random import pygame # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) ORANGE = (255, 127, 0) # Dimensi...
7d68f461be3e8144e36a2faaf0ee3f9d65edbbe8
chionglai/euler
/q032.py
2,445
3.5625
4
#!/usr/bin/env python import time import itertools as it """ q032: We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing mult...
77ec11ca1af78ae8eee689439574b062ae9b4111
chionglai/euler
/q038.py
1,813
3.90625
4
#!/usr/bin/env python import time import numpy as np """ Take the number 192 and multiply it by each of 1, 2, and 3: 192 x 1 = 192 192 x 2 = 384 192 x 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be ach...
96c6d360087689a90867c53712f9e8b2e99c8ccc
chionglai/euler
/q071.py
1,210
3.96875
4
#!/usr/bin/env python import time """ Algorithm: There is a pattern here. The explanation will be based on the example given in the problem. We want to find what is numerator of the proper fraction directly left to 3/7. Notice that from the example given, the fraction left to 3/7 is 2/5, i.e. ..., 2/5, 3/7, ... As ...
90a7e6f4b8757177cbee894804fad83e99cabb17
wangchen8118/-..-
/新建文本文档.py
246
3.859375
4
import turtle q=turtle.Pen() turtle.bgcolor("black") sides=7 color=["red","orange","yellow","green","cyan","blue","purple"] for x in range(360): q.pencolor(color[x%sides]) q.forward(x*3/sides+x) q.left(360/sides+1) q.width(x*sides/200)
7b14801d22dc3b8aedb276b27d5e636634fc25c7
Darshan1917/Data_analysis
/titanic.py
1,330
4.28125
4
# -*- coding: utf-8 -*- import pandas as pd import numpy as np titanic = pd.read_csv('train.csv', delimiter = ',') ''' ## checking the datatypes #print (titanic.info()) ## or #print (titanic.dtypes) ## Describe gives mean total number , median etc #print (titanic.describe()) ''' # print (type(titanic)) ''' ...
4d77f50fd32835aecfdf86daa59857ca1206032c
charlesarnaudo/natural_language_processing
/lab-1/spellcheck.py
807
3.671875
4
import argparse import spellfuncs import pprint if __name__ == '__main__': # ArgumentParser parser = argparse.ArgumentParser(description='spell checker') parser.add_argument('-f', type=str, metavar='', help='file to spell check', ...
55ee9eebc3f475dece61f263dcb5f73562c22d95
j33mk/PythonSandboxProdVersion
/pythonsandbox/ScrapyProject/main.py
275
4
4
def hello_jamal(name): if name == 'jamal': print('hey jamal how are you?') else: print('hey '+name+' i am good how are you?') def print_fruits(): fruits = ['apple','oranges','mangoes'] for fruit in fruits: print(fruit) print_fruits()
1b536c7de215a6511df46e606f059fef64529533
j33mk/PythonSandboxProdVersion
/pythonsandbox/sandbox/newpython/dopamine.py
872
4.1875
4
#i was thinking how can i link my dopamine with programming, get back to programming and learn datascience, machine learning, and make myself expert in everything that i come across # what is stopping me? What are the things that are stopping me # this is the question that i am searching the answer print('dopamine re...
eff5e1ac079573feb1d0cf78aacd4f2088e8c845
turalss/Python
/day_2_a.py
1,299
4.40625
4
# Write a string that returns just the letter ‘r’ from ‘Hello World’ # For example, ‘Hello World’[0] returns ‘H’.You should write one line of code. Don’t assign a variable name to the string. hello_world = 'Hello World' print(hello_world[8]) # 2. String slicing to grab the word ‘ink’ from the word ‘thinker’ # S=’hel...
778b4ccd0b13b25406192b82f4655c03cf5ba44b
Joe-Darling/Programming_Challenges
/Easy/challenge 291 - Goldilocks' Bear Necessities.py
2,201
3.859375
4
""" Challenge: Goldilocks' Bear Necessities Description: Once upon a time, there lived an adventurous little girl called Goldilocks. She explored the world with abandon, having a lot of fun. During her latest foray into the woods, she found another bear home -- though this one is home to many more bears. Having learne...
411f57127450866ca75dc04d68d0a13917edbfdc
mm909/LeetCode
/226. Invert Binary Tree/solution.py
802
3.9375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def invertTree(self, root: TreeNode) -> TreeNode: if root == None: return None temp = root.left if ro...
e58f94aacad93340a42a45fc95e1692eeaeb5ad7
DianaPLC/oh_hell
/game_tester.py
4,589
3.515625
4
import math def get_play_order(player_name,play_order_base): name_list = play_order_base.copy() #print(play_order_base is name_list) #print(name_list) leader_position = name_list.index(player_name) if leader_position == 0 or leader_position == len(name_list)-1: name_list.remove(player_name)...
92412722b1d87f3a1dea10072d3c6856e20692c9
ABFdata/Homework
/PyChallenge/PyPoll/main.py
2,235
3.5625
4
# coding: utf-8 # In[2]: # read csv file import csv with open('election_data_2.csv', 'r') as csv_file: csv_reader = csv.reader(csv_file) # use to skip header next(csv_reader) # set empty lists for columns Candidate_List = [] # variable for candidates (finding the candidates in ...
3cf235e39d0e6ca61d7f0d3f0a80457de94cc331
nurawat/python_excercise
/multiple_7_not_5.py
365
3.828125
4
# # Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, # between 2000 and 3200 (both included). # The numbers obtained should be printed in a comma-separated sequence on a single line. # __author__ = 'nurawat' for number in range(2000,3200): if number % 7 ==0 and...
4952593f8c1a8b00ba400233e99a22c142149ec8
MichaelLinn/ml_assignment
/clustering/method/plotHeart.py
556
3.6875
4
# -*- coding: utf-8 -*- # @Time : 29/10/2017 10:23 PM # @Author : Jason Lin # @File : plotHeart.py # @Software: PyCharm Community Edition """ import numpy as np import matplotlib.pyplot as plt T = np.linspace(0 , 2 * np.pi, 1024) fig = plt.figure() plt.axes(polar = True) plt.plot(T, 1. - np.sin(T),color="r") pl...
2d696d8ae731fce4e5d33ac2412aad5f92f3a0f0
amandaklase/escapetheroom
/main.py
27,300
3.578125
4
import random import time import sys import textwrap import story_text import first_choice_text import search_room_text import search_door_text import search_bed_text import search_end_table_text import search_art_text import search_tablet_text from check_exit import check_exit ############# BIG HOUSE BREAKOUT #######...
22f4209e322ce835d669e3636bb593ca4034b528
Sunny-Dong/learning-python
/爬虫/beautiful.py
1,303
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 18 15:56:26 2017 @author: sunnyday """ from bs4 import BeautifulSoup #Beautiful Soup,有了它我们可以很方便地提取出HTML或XML标签中的内容 html = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="title" name="dromouse"><b>The Dormouse's story</b></p> <p class="story"...
28e64909ca39186a7e89ad569eafe709382649ff
devashish89/BubbleSort
/main.py
694
4.0625
4
### Bubble sort ##### # pass1 # 9,8,7,6,5,4,3 # 8,9,7,6,5,4,3 # 8,7,9.6.5.4.3 # 8,7,6,9,5,4,3 # 8,7,6,5,9,4,3 # 8,7,6,5,4,9,3 # 8,7,6,5,4,3,9 # after full loop highest no. is bubbled to last # #pass2 # 7,8,6,5,4,3, 9 # 7,6,8,5,4,3, 9 ####### lst = [9,8,7,6,5,4,3] def swap_list_ele(lst,i,j): lst[i], lst[j] ...
f811c780b2b1595121440c018f6738f76026d7a9
kulvirs/concurrency-problems
/queue/q-lock.py
2,294
3.875
4
# Naive implementation of a thread-safe queue. import threading import random import time ENQUEUES = 100 # Number of items that will be inserted in the queue. NUM_TRIALS = 100 startTimes = [0]*ENQUEUES endTimes = [0]*ENQUEUES class ThreadSafeQueue: def __init__(self): self.mutex = threadin...
af4179841bb94db4e2c71bc526f942d1e8c1d2ed
Ryan-Scarbrough/ProjectEuler
/14.py
303
3.546875
4
def collatz(n): times = 1 while n != 1: if n % 2 == 0: n = n/2 else: n = n*3 + 1 times += 1 return times max = 0 ans = 0 for i in range(1, 1000000): # 1 m fred = collatz(i) if fred > max: max = fred ans = i print(ans)
61d88c80c569d89ff785f88ec77c24b0326a7847
Ryan-Scarbrough/ProjectEuler
/1.py
153
3.671875
4
# Ryan Scarbrough # Last Edited: 9/30/21 fred = [] for i in range(1000): if i%3 == 0 or n2[-1] == 0: fred.append(i) print(fred) print(sum(fred))
3fc7517234a698cd6bbb61a47e2c194951ea9b38
mlgatech12/SearchAlgorithms
/submission.py
74,410
4.15625
4
# coding=utf-8 """ This file is your main submission that will be graded against. Only copy-paste code on the relevant classes included here. Do not add any classes or functions to this file that are not part of the classes that we want. """ import heapq as hq import os import pickle import math import itertools i...
e2fecae7307ab30bebf43e7455d4a53cff5884d1
mtianyan/LeetcodePython
/234-palindrome-linked-list.py
3,521
3.875
4
class Solution: """ 作者:LeetCode-Solution 链接:https://leetcode-cn.com/problems/palindrome-linked-list/solution/hui-wen-lian-biao-by-leetcode-solution/ """ def isPalindrome(self, head: ListNode) -> bool: if head is None: return True # 找到前半部分链表的尾节点并反转后半部分链表 first_half_e...
a757dc495692626f93b0c577cb69091f3f583fa6
mtianyan/LeetcodePython
/139-word-break.py
762
3.984375
4
class Solution: """ 作者:irruma 链接:https://leetcode-cn.com/problems/word-break/solution/python3-dong-tai-gui-hua-by-irruma/ 思路:把字符串看错一个小人跳动的过程,字典内的单词看作小人跳跃的规则。 把小人能够跳跃的过程作为路径,查看所有可能的路径,如果有一条路径能够达到最后,则表示能够拆分。 """ def wordBreak(self, s: str, wordDict: List[str]) -> bool: dp = [False f...
3b88d5b3bfbcc8c77d62bdcaf5a4dbeeac9062c0
mtianyan/LeetcodePython
/344-reverse-string.py
843
3.859375
4
from typing import List class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ s.reverse() class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in...
fdba465ca9a021285ffea0c6e52bb15661c2e4cd
mtianyan/LeetcodePython
/92-reverse-linked-list-ii.py
3,719
3.875
4
class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: """ 作者:raptazure 链接:https://leetcode-cn.com/problems/reverse-linked-list-ii/solution/shuang-zhi-zhen-xu-ni-tou-jie-dian-python3-9420-fa/ """ if m == n: return head dummy ...
a0c930e51abb6a4dba8d521eed86ce4dffda850d
mtianyan/LeetcodePython
/easy/4-0703/94-binary-tree-inorder-traversal.py
1,585
3.5625
4
class Solution: def inorderTraversal(self, root: TreeNode) -> List[int]: def inorder(root: TreeNode): if not root: return inorder(root.left) res.append(root.val) inorder(root.right) res = list() inorder(root) return res...
e753d391e23e320b6f01299eeacd056d693516bc
mtianyan/LeetcodePython
/116-populating-next-right-pointers-in-each-node.py
2,256
3.921875
4
import collections class Solution: def connect(self, root: 'Node') -> 'Node': if not root: return root # 从根节点开始 leftmost = root while leftmost.left: # 遍历这一层节点组织成的链表,为下一层的节点更新 next 指针 head = leftmost while head: # ...
08ccbab63bcd579c89026c893d74946cf8df5700
mtianyan/LeetcodePython
/78-subsets.py
1,622
3.515625
4
class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: # 回溯,以[1, 2, 3]为例 # 1.加入空数组[] # 2.枚举长度为1的子集 # 3.递归进入枚举长度为2的子集 # 4.递归进入枚举长度为3的子集 # 5.tmp + [nums[i]]不对tmp本身做修改,自动完成选择与释放选择 res = [] def dfs(index, tmp): res.append(tmp) ...
22d1290a837df78fe92b85d9ccedfb417325c926
iostruhl/struhl-section-code
/section-6/2-conditions/conditions.py
130
3.53125
4
from cs50 import get_int i = get_int() if i < 0: print("negative") elif i > 0: print("positive") else: print("zero")
8a0f30ee317b6c12efc4c7e26546c082038470d2
MrMoustach/HexaPawn
/main.py
2,211
3.671875
4
from learning import * from mechanics import * import os clear = lambda: os.system('cls' if os.name == 'nt' else 'clear') b=1 game = json.loads('{"A1":"O", "A2":"O", "A3":"O","B1":" ", "B2":" ", "B3":" ","C1":"H", "C2":"H", "C3":"H"}') placeholders = ["A1","A2","A3","B1","B2","B3","C1","C2","C3"] msg = "BITCH PL...
3b153b67bbcf0c770870b339239370469e6055f9
A01746540/Tarea-04
/01 Numeros Romanos.py
1,263
4.0625
4
#encoding: UTF-8 # Autor: Edgar Alexis González Amador, A01746540 # Descripcion: Programa que permite convertir los numeros digitales del rango 0, 10 en números romanos. #Esta función convierte el numero digital ingresado a un numero romano. def convertirDigitalARomano(numeroDigital): if numeroDigital > 10: ...
df25b586caff6d1a82dff965b47e1dd88e33b391
YounessHABACH/Machine-Learning-Projects
/Deep learning/ANN/ann.py
2,237
3.609375
4
# Artificial Neural Network """ Part1 : Data preprocessing """ # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('../../../datasets/Churn_Modelling.csv') X = dataset.iloc[:, 3:-1].values y = dataset.iloc[:,...
0f832c5187a4cdf1397375318756e5166e20275d
YounessHABACH/Machine-Learning-Projects
/Data Pre Processing/data_process_template.py
859
3.5
4
# data pre processing import numpy as np import pandas as pd import matplotlib.pyplot as plt # import and split the data and classes dataset = pd.read_csv("../../datasets/Data.csv") X = dataset.iloc[:, :-1] Y = dataset.iloc[:, 3] """ # preprocess take care of missing data from sklearn.impute import Simp...
482a76866a787c02dad35e9ba3d4afc7397ae740
sairatabassum/Semester-Registration
/semester registration.py
9,094
3.515625
4
from tkinter import * import os.path from os import path from tkinter import ttk from tkinter import messagebox def main(): if __name__== "__main__": main() #----Add new registration data---- def add_f(): file=ID_entry.get()+'.txt' c=str(path.exists(file)) if(ID_entry.get()==...
f57de28a170cdc21398fa2dd82b9e502dff2bf1b
escape0707/usaco_trainings
/zerosum.py
1,222
3.5625
4
""" ID: totheso1 LANG: PYTHON3 TASK: zerosum """ from itertools import count from typing import Any, List fin = open("zerosum.in", "r") fout = open("zerosum.out", "w") def fprint(*args: Any, **kwargs: Any) -> None: print(*args, file=fout, **kwargs) # Code start def generate(i: int) -> List[int]: res = [] ...
f913a68c68589128e96bbe65680712d7d712eb40
escape0707/usaco_trainings
/transform.py
1,965
3.53125
4
""" ID: totheso1 LANG: PYTHON3 TASK: transform """ from itertools import chain, islice fin = open("transform.in", "r") fout = open("transform.out", "w") def fprint(*args, **kwargs) -> None: print(*args, file=fout, **kwargs) # Code start def equal(start, step_outer, step_inner): start = list(start) for...
8c4f0158e801cb77e85555ac6283c78f44c99ce9
AISWARYAK99/Python
/tuples.py
952
4.65625
5
#tuples #they are not mutable my_tuple=() my_tuple1=tuple() print(my_tuple) print(my_tuple1) my_tuple=my_tuple+(1,2,3) print(my_tuple) my_tuple2=(1,2,3) my_tupple4=tuple(('Python','Java','Php',1)) print(my_tuple2) print(my_tupple4) my_tuple5='example', #add comma if we want tuple with single elements pri...
b3fd5e9b71657eeb1333aa465f429d511ba27a2f
AISWARYAK99/Python
/start1.py
1,685
4.28125
4
#python beginning ''' There are 6 data types in python. 1.Numeric(not mutable) 2.List(mutable) 3.Tuples 4.Dictionary 5.Set 6.String ''' print('hello users welcome to the basics') a=int(input('Enter num a:'))#input is read as a string so converting it to int. b=int(input('Enter num s:'))#type conversion of s...
6b7a4283368efc2aa16c2ae56d5534c590901f6f
dougwt/dougwt-twitter
/dougwt_twitter.py
2,349
3.5
4
import urllib import urllib2 import json import os.path import time def fetch_tweets(username, quantity=1, cache_expiration=60): """Returns a list of a user's most recent tweets in the form of dictionaries""" # format the proper url for the api call url = 'https://api.twitter.com/1/statuses/user_time...
f6c8c613e93613d5df8f5d06809d8b3470f349ec
andrebestrada/Python-Challenge
/PyBank/Main.py
2,126
3.96875
4
# Your task is to create a Python script that analyzes the records to calculate each of the following: # The total number of months included in the dataset # The net total amount of "Profit/Losses" over the entire period # Calculate the changes in "Profit/Losses" over the entire period, then find the average of those c...
a6dc2ce673892aec4769ac2b13b4cf0999fccb2c
lifeoftheone/python-program
/pythoncode/add element of list.py
185
3.765625
4
a=int(input("enter value seperated by ,")) data_list=[] c=0 for i in range (a): b=int(input("enter the values")) data_list.append(b) for j in data_list: c+=j print(c)
625880ab20cd0fe092db682bb30ef42def6080d0
lifeoftheone/python-program
/pythoncode/odd pryamid star.py
94
3.859375
4
a=int(input("enter a value")) for i in range(1,a+1,2): print((' '*a)+(i*'*')) a=a-1
e84a90bba6d2593e94a6a8509c5087091b4ed82a
lifeoftheone/python-program
/pythoncode/decorators.py
590
3.59375
4
#spcl case '''a=int(input ("enter a value")) b=int(input("enter a value")) def sub(func): def inner(p,q): c=p-q return c return inner @sub def add(a,b): print("hi") return(a+b) print (add(a,b))''' #2 '''a=int(input("enter total number of names")) l=[] for i in range (...
68fff2bec40884ea57ae4073794a7685fe589813
lifeoftheone/python-program
/pythoncode/star print.py
131
3.828125
4
a = int(input("enter a value")) for i in range(1, a + 1): for j in range(1, i +1): print("*", end='') print()
e5425c14937b326188a9e66121b5069e5e8288ab
k-motohashi51/hangman
/pkg/wordClass.py
1,075
3.671875
4
class wordClass: def __init__(self, data): self.__word = data # 正解の単語 self.__length = len(self.__word) - 1 # 単語の長さ self.__passed = [False] * self.__length # 正解文字のboolリスト def word(self): return self.__word # 単語の任意の要素を返す def ind...
827ea0ea32f60e73caf0ae85f44f1399a03b78de
ChanElizabeth/Assignment---ITP-lab
/hotel.py
5,521
4
4
#Chan Elizabeth (2201797001) #Program for hotel management system #define the Rooms class class Rooms: def __init__(self, d, s): #initialize values of the class self.doublefee = int(d) self.singlefee = int(s) def Roomfee(self,rtype): #method to define the room fee rtype.lower() ...
93e8f4da4a93be605a57bcee27eb4a393d388d3f
simonjobs/holiday_data_api
/scraping.py
3,682
3.5625
4
import pandas as pd import requests from bs4 import BeautifulSoup # Starting point for data collection url = 'https://www.officeholidays.com/countries' # Scrape list of all countries available on the site r = requests.get(url) html = r.text soup = BeautifulSoup(html) columns = soup.find_all('div', {"class": "four ome...
c6b1294968b2f54e54faebfafdcfb799274db7f0
saurijal2054/1BM17CS140
/3a_divisor.py
133
4.0625
4
n=int(input("ENTER A NUMBER FOR WHICH YOU WANT THE DIVISOR")) for i in range (1,(n+1)): if(n%i==0): print(i,end=" ")
b1884fc71d538e92874239bede3a8289f6de5a4f
Declerc/Infograph
/Python/essai.py
373
3.515625
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 31 15:55:53 2020 @author: gomesdat """ import tkinter as tk def callback(event): print(event.widget['text']) print(event.widget.extra) main = tk.Tk() switcher = tk.Label(main, text="click here") switcher.grid() switcher.bind("<Button-1>", callback) switcher....
6ab3023d7be758d741975b3271ec5216a16d4c14
leocasarsa/home
/webscraping.py
805
3.515625
4
import urllib2 from contextlib import closing from bs4 import BeautifulSoup def get_resources_affectiva(): """ Get all the youtube video addresses for the affectiva emotional ai summit. """ address = "http://go.affectiva.com/emotionai-summit-content?submissionGuid=3ca70c23-cf92-4dfc-bb9c-1e1742442494"...
5c5a888cb93d0787676e50e78cc3afd352e4bd07
lancryter/Exercicios-de-python
/Exe_Bhaskara.py
536
3.859375
4
# coding: utf-8 # In[1]: # Calculo de Bhascara # In[12]: import math a = float (input ( " Digite o valor de a ")) b = float ( input (" Digite o valor de b ")) c = float ( input (" Digite o valor de c ")) delta = (b ** 2 - 4 * a * c) if delta == 0: raiz1 = (- b + math.sqrt (delta)) / (2 * a) print (...
f292c153bd924c53526dbe10f0f3a281210a9c55
victorgrubio/head-first-design-patterns
/factory/simple_factory/simple_pizza_factory.py
734
4.03125
4
"""Simple pizza factory to create pizzas""" # The job of this class is to extract the creation process from main.py from simple_factory.pizza import Pizza, CheesePizza, PepperoniPizza, ClamPizza, VeggiePizza class SimplePizzaFactory(object): def create_pizza(pizza_type: str) -> Pizza: """Creates a pizza based ...
f50ab386c11bd597fc008168b91b72bc7e4e33da
victorgrubio/head-first-design-patterns
/strategy/weapons/weapon.py
219
3.53125
4
import abc class WeaponBehaviour(metaclass=abc.ABCMeta): @abc.abstractmethod def use(self, enemy_character): """Use the weapon to cause damage to another character""" raise NotImplementedError
5fe5077565626015531ac1a06496f95ea58df4b9
shravan097/NYCHS-Data-Analysis
/datasets.py
2,757
3.5625
4
""" You can import this file as: from datasets import * to get the datsets in pandas dataframe. Functions: - get_SATScores() - get_Demographic() """ ####################################### ####################################### # These can be helpful if our dataset is not CSV # I didn't know you can get csv fo...
13ec65cc001f15029f7e6c809111a18d4a77f4d9
lukasberger/evolution-game
/evolution/dealer/dealer.py
18,411
3.90625
4
""" This file implements the Dealer for the Evolution game. In the game world, a Dealer configuration is expressed by a Configuration. A Configuration is [LOP+, Natural, LOC]. where LOP+ is a list of Player+, defined in Player Natural is a natural number as defined in DataDefinitions ...
b6cee02312f0717cd32c23063b154f9184995378
hippensteele/python-course
/Databases/contacts2.py
642
3.890625
4
#! /usr/local/bin/python3 __author__="tom" __date__ ="$Apr 22, 2018 6:58:35 AM$" import sqlite3 new_email = "newemail@email.com" phone = input("Please input a phone number: ") # 1234 db = sqlite3.connect("contacts.sqlite") update_sql = "UPDATE contacts SET email = ? WHERE phone = ?" update_cursor = db.cursor() upda...
a3f97e15806b3a830335fc7c49dcda006a871b8c
hippensteele/python-course
/GenComprLambda/listcomp_examples.py
256
4
4
#! /usr/local/bin/python3 __author__="tom" __date__ ="$Apr 28, 2018 10:04:35 AM$" text = "what have the romans ever done for us" capitals = [char.upper() for char in text] print(capitals) words = [word.upper() for word in text.split(' ')] print(words)
b8e83a70a22638c7dd289480fee53ebc8d9a0c42
hippensteele/python-course
/ModulesAndFunctions/timechallenge.py
1,158
3.625
4
#! /usr/local/bin/python3 __author__="tom" __date__ ="$Apr 8, 2018 7:25:23 AM$" import datetime import pytz import random zones = list(pytz.all_timezones) options = [] while len(options) < 9: n = random.randint(1, len(zones)) if zones[n] not in options: options.append(zones[n]) print("Please choose ...
c8e271cefc1c763bbf3feb070b23f4b9076b622b
hippensteele/python-course
/ProgramFlow/ifProgramFlow.py
2,016
4.09375
4
#!/usr/bin/python3 # name = input("Please input your name: ") # age = int(input("How old are you, {}? ".format(name))) # if age >= 18: # print("You are old enough to vote.") # print("Please put an X in the box.") # else: # print("Please come back in {} years.".format(18-age)) # print("Please guess a numbe...
f04607cfbb138c39c13c0b13c2883d55afb03d4e
hippensteele/python-course
/FileIO/pickling.py
1,332
3.65625
4
import pickle file = "/home/ec2-user/environment/CPMC/FileIO/imelda.pickle" imelda = ('More Mayhem', 'Imelda May', '2011', ((1, 'Pulling the Rug'), (2, 'Psycho'), (3, 'Mayhem'), (4, 'Kentish Town Waltz'))) # with open(file, 'wb') as pickle_file: # pi...
5d48ff34a519e78d5f4aebcce03baa1680a3e706
hippensteele/python-course
/Databases/ExceptionHandling/get_ints.py
1,227
4.03125
4
#! /usr/local/bin/python3 __author__="tom" __date__ ="$Apr 22, 2018 3:28:43 PM$" #try: # int1 = int(input("Please type in a number: ")) # int2 = int(input("Please type in a number to divide it by: ")) # try: # print(int1 / int2) # except ZeroDivisionError: # print("Can't divide by zero.") #ex...
a6f654b33175d091fcc197c95762966058cf94c6
Rxted/Codewars-Projects
/midPerm.py
1,298
4
4
''' You are given a string s. Every letter in s appears once. Consider all strings formed by rearranging the letters in s. After ordering these strings in dictionary order, return the middle term. (If the sequence has a even length n, define its middle term to be the (n/2)th term.) Example For s = "abc", the re...
3f1b32beb9a7740c0aa0c8474ef199b191eafc56
pallavininawe/sample_repo_arpit
/Python day 2/Q10.py
180
3.703125
4
i = int(raw_input("Enter matrix size")) j = int(raw_input("Enter matrix size")) for k in range(1,i+1): if k==i: print('*'*j) else: print('*')
b3090aa32744ef6399d76cc296d1e314c4649d1e
pallavininawe/sample_repo_arpit
/Assessment/Q13.py
152
4.03125
4
n = int(raw_input("Enter any number \n")) while (n!=1): if n%2 ==0: n = n/2 print(n) else: n = 3*n + 1 print(n)
a8cbde55ad36cca2235d6c8351513d614aa75fb5
frolovilya/machine-learning
/optimize.py
2,382
3.5625
4
from scipy import optimize import numpy as np def gradient_descent(coefficients_count: int, hypothesis_function_derivative, args, learning_rate: float, max_iterations: int = 1000): """ Calculate regression coefficients in vect...
d3272c30383d880bcc6d279173b93fd8e27250ef
bhi5hmaraj/APRG-2020
/Assignment 2/rbtree.py
6,361
3.765625
4
# This is an implementation of a Red Black tree from CLRS global RED, BLACK RED = 0 BLACK = 1 class Node: # 0 - red , 1 - black def __init__(self, val, left=None, right=None, parent=None, size=1, color=RED): self.val = val self.left = left self.right = right self.parent = pa...
a3d91f71441746edfea152c8b40990fa0198cbbd
bhi5hmaraj/APRG-2020
/Assignment 2/solutions/BMC201911/BMC201911.py
5,176
3.53125
4
class Node: def __init__(self,value=0,c=0): self.val=value self.col=c self.lc=None self.rc=None self.p=None self.size=0 class RBtree: def __init__(self,root=None): self.root=root def search(self,r,x): if self.root==None: return False elif r==None: return False ...
aa5af823d4e929d26ce0a6dc5dd3b6fc0e199008
bhi5hmaraj/APRG-2020
/Assignment 2/solutions/BMC201958/BMC201958.py
4,451
3.5
4
class Color: black = 0 red = 1 class Node: def __init__(self,info=None,color=None): self.info = info self.color = color self.l = None self.r = None self.p = None self.size = 1 class RedBlackTree: def __init__(self): self.ext = Node(-1,Color.black...
f312b9c2339f349fb1addb777ce8ab68ad4b65ca
bhi5hmaraj/APRG-2020
/Assignment 3/flood_fill_solutions/BMC201908/BMC201908.py
1,771
3.53125
4
color = 0 def isWhiteAvailable(M, N): for i in range(0,N): for j in range(0,N): if M[i][j] == 0: return "N" return "Y" def fillUtil(M, xw, yw, N): ''' global color color = color - 1 M[xw][yw] = 2 if (xw-1>=0 and xw-1<N and yw>=0 and yw<N and M[xw-1][yw]!=...
abfc5e6bef3218a104b71084a37f08cb40bb426a
bhi5hmaraj/APRG-2020
/Assignment 4/the-journey-solutions/BMC201902/BMC201902.py
2,214
3.6875
4
from collections import defaultdict class Graph: def __init__(self): self.nodes = set() self.edges = defaultdict(list) self.distances = {} def add_node(self, value): self.nodes.add(value) def add_edge(self, from_node, to_node, distance): self.edges[fr...
4f010efa829f5f6352be1df518dfb1cf7282d947
bhi5hmaraj/APRG-2020
/Assignment 4/second-shortest-path-solutions/BMC201946/BMC201946.py
1,204
3.75
4
import heapq def dijkstra(src): distance = [-1] * n distance[src] = 0 pq = [(0,src)] while len(pq) > 0: dist,u = heapq.heappop(pq) if dist > distance[u]: continue for temp in graph[u]: v = temp[0] w = temp[1] temp_dist = dist + w...
d21f522f1a163f75d066f90eb06f200da9e4d7fe
bhi5hmaraj/APRG-2020
/Assignment 4/second-shortest-path-solutions/BMC201917/BMC201917.py
1,341
3.84375
4
from collections import defaultdict import heapq def Dijkstra(graph): distances={vertex:float('Inf') for vertex in graph} distances[1]=0 path={} pq = [(0,1)] while len(pq)>0: current_distance,current_vertex=heapq.heappop(pq) if current_distance > distances[current_vertex]: ...
78ccaacefa7b0901924806332aee29cbe5d3739d
bhi5hmaraj/APRG-2020
/Assignment 2/solutions/BMC201930/BMC201930.py
4,556
3.5625
4
class Node: def __init__(self, initval = None): self.value = initval self.right = None self.left = None self.parent = None self.size = 1 self.colour = 1 class RedBlackTree: def __init__(self): self.root = None def isLeft(self, node): if nod...
eadc78f6241176af767fed72ac5fbf14b5440c4f
Ivasuissa/python1
/isEven.py
246
4.1875
4
def is_even(n): if (n % 1) == 0: if (n % 2) == 0: print("True") return True else: print("False") return False else: print(f"{n} is not an integer") is_even(-4)
eb0146449cf4c1038ba3107983fbed12bb9db675
mdmcconville/Solutions
/validPalindrome.py
683
4.15625
4
import string """ This determines whether a given string is a palindrome regardless of case, punctuation, or whitespace. """ class Solution: """ Precondition: s is a string Postcondition: returns a boolean """ def isPalindrome(self, s): # Case: string is empty if not s: ...