blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
62149622c7cb41563872862f2246a49a7692ec95
ledelma2/CS474
/HW3/Game.py
1,890
3.921875
4
# The game class houses all the rules for the game in addition to # the players and board import Player import Board class Game(object): def __init__(self): self.board = Board.Board() self.players = [Player.Player('X'), Player.Player('O')] def run(self): while True: winner...
84246bc9ce9cedbc9ff27bb52a84876822e6e025
lizator/Euclidean_Algorithm
/Euklids.py
1,799
3.578125
4
import math import tabula # Python solution to Euklids algorithm for Discrete Mathematics with automated LaTeX code output # does the computing for Euklids algorithm class Euklid: def __init__(self): self.s0 = 0; self.s1 = 0 self.t0 = 0; self.t1 = 0 self.r0 = 0; self.r1 = 0 pass ...
e4936104d77489a25ad08a34ad26684da58b5831
Disunito/hello-world
/python_work/Chap_four/players.py
901
4.46875
4
#Useing slices of lists. Slices are indexed like lists players = ['bear', 'eric', 'kayla', 'thom', 'cristina'] #Starts at the begining of the list of first number listed and ends before the #second argument print("These are my roommates:") for player in players[0:3]: print(player.title()) #Using a neg. index cou...
c845e2e91c01fd28014414ab25840d5f98c25a70
DaHuO/Supergraph
/codes/CodeJamCrawler/16_3_1/ihpk/senate_evacuation.py
3,593
4.0625
4
import string def senate_evacuation(file_name): read_file_name = file_name write_file_name = file_name + ' - answer.txt' read_file = open(read_file_name) write_file = open(write_file_name, "w") cases = int(read_file.readline()) current_case = 1 while current...
01cd589b40119a300d48a8fddded2e21084d81b5
ruidge/TestPython
/Test/com/ruidge/liaoxuefeng/functional/test_functional1.py
266
3.625
4
#coding=utf-8 ''' Created on 2015年2月5日 @author: zhangrui6 ''' def inc(x): def incx(y): return x+y return incx inc2 = inc(2) inc5 = inc(5) print inc2(5) # 输出 7 print inc5(5) # 输出 10 print type(inc2) print type(inc5)
ed08357850e2a1418ac914d297b635fc46fbee6f
jxjk/git_jxj
/python_img_demo/bresenham_line.py
595
3.5
4
# -*- coding: utf-8 -*- """ bresenham画直线 蒋小军 2018.6.26 """ import cv2 import numpy as np def bresenhamLine(x0=0,y0=0,x1=1,y1=1): # 设置x/y偏移量、设置斜率 dx = x1-x0 dy = y1-y0 k = dy / dx e = -0.5 x = x0 y = y0 points = set() for x in range (x0,x1,1): points.add((x,y)) e = e...
2d63d7d54fb8ff954188a1adfe6567e4ba35c5e4
miyamotok0105/ai_chatbot
/team1/neuralNetwork.py
10,238
3.53125
4
#coding:utf-8 #### Libraries # Standard library import random # Third-party libraries import numpy as np import math import sys import MeCab import os import matplotlib.pyplot as plt import numpy as np import pandas as pd import pdb import logging import codecs from sklearn.feature_extraction.text import CountVectori...
aac82444ac7998ed8a737208c3ab5c7d2d53cdcb
Adikanatbek/python2
/problem9.py
165
3.578125
4
a=-100 b= -100 c=0 e=0 while a <= 100: if a %13 == 0 and a % 2 == 0: print (a**2, a) c += 1 a += 1 while b <= 100: if b % 2==1: print (b) e += 1 b += 7
896a68ab417f0271506b8ceb26344544fc4008ff
Aasthaengg/IBMdataset
/Python_codes/p02265/s545227861.py
499
3.671875
4
# -*- coding: utf-8 -*- import sys import os from collections import deque N = int(input()) q = deque() for i in range(N): lst = input().split() command = lst[0] if command == 'insert': v = int(lst[1]) q.appendleft(v) elif command == 'delete': v = int(lst[1]) try: ...
840aac5d747350d938d5de3cfa9d1804161cd275
MarinaLutak/python_homework
/laboratory2/task1.py
477
3.546875
4
""" Обчислення суми """ from validators.validators_library import validator from validators.validators_library import re_float from validators.validators_library import re_plus_int x= float(validator(re_float, 'Введiть значення x')) n= int(validator(re_plus_int, 'Введiть значення верхньої границi суми (лише натуральн...
cf29c5e2869d67a3b56dd55604b9b394051b94dc
Omkar-Atugade/Python-Function-Files-and-Dictionaries
/week5.py
1,428
4.28125
4
#1. Sort the following string alphabetically, from z to a, and assign it to the variable sorted_letters. #ANSWER : letters = "alwnfiwaksuezlaeiajsdl" sorted_letters=sorted(letters, reverse=True) #2. Sort the list below, animals, into alphabetical order, a-z. Save the new list as an...
e36d528d95a5480e7b505f32ca39a2fc4c1995d3
mosihere/hackerNews
/hackernews.py
567
3.53125
4
import requests from bs4 import BeautifulSoup # Send request to fetch data response = requests.get('https://hckrnews.com/') # Parse Needed Data with BS ! soup = BeautifulSoup(response.text, 'html.parser') # Select a special tag that we need --> and use attributes to find that exactly data = soup('a', attrs={'class':...
da77be16b39e67543933a371c1ec163b87e79738
pavlosprotopapas/course-starter-harvard
/exercises/chapter2/exc_02_03/solution_02_03.py
1,179
4.1875
4
# Import the numpy library and name it np import numpy as np # Import the pandas library and name it pd import pandas as pd # import matplotlib.pyplot import matplotlib.pyplot as plt # add the following line in order to have the plots inside the notebook %matplotlib inline # Data set used in this exercise (Advertising...
afe6ff4a7dc556e6d74723234fd9b5221dad675f
alfaroqueIslam/Intro-Python-II
/src/player.py
645
3.625
4
# Write a class to hold player information, e.g. what room they are in # currently. class Player: def __init__(self, player, room): self.player = player self.room = room inventory = [] def check_for_items(self): if not self.room.items: print('You see no items in th...
0ccaf05ee0becbabc0541f6e57f36f5b2e315670
fgirardi/SourcePython
/diversos/ExampleGetAttr.py
304
3.703125
4
class ABC(): x = "Some Value" y = "" def SetY(self, value): print("Debug SetY {0}".format(value)) self.y = value obj = ABC() print("x {0}".format(obj.x)) print(getattr(obj,"x")) getattr(obj,"SetY")("200") print("obj.y={0}".format(obj.y)) setattr(obj,"a","definition of a") print(obj.a)
3399c6c526602b7254e1ca07430c3a46e0aec9af
Frank1963-mpoyi/REAL-PYTHON
/MODULE_AND_PACKAGE/the_dir_function.py
369
3.90625
4
''' The dir() Function The built-in function dir() returns a list of defined names in a namespace. Without arguments, it produces an alphabetically sorted list of names in the current local symbol table: ''' print(dir()) a = "yrs" qux = [1, 2, 3, 4, 5] print(dir())# return the list of the name of all the variable ...
668bc201ffa00c3de32aee5a1d5f17ffc4ba774e
AlanArvizu739/AlanArvizu
/grade book.py
1,158
4.125
4
#Alan Arvizu print ("Enter your grade for average to be calculated") print(" algebra 2") Algebra_2 = float(input("enter your grade: ")) print(" Ap chemistry") Ap_chemistry = float(input("enter your grade: ")) print("computational thinking") computational_thinking = float(input(" enter your grade: ")) print("geom...
0558d54f6cb1e86baf20db508b1b98f9ee7437d4
JerryZhuzq/leetcode
/linked list/206. Reverse Linked List.py
788
3.96875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList_iterate(self, head: ListNode) -> ListNode: if not head: return None dummy = ListNode(0, head) pre...
3985fffaf7eef8d5a7ffe8441fd414c9c3a8f42d
heecheol1508/algorithm-problem
/_baekjoon/1654_렌선 자르기.py
661
3.59375
4
import sys sys.stdin = open('input.txt', 'r') def can_make_n(length): cnt = 0 for i in range(K): t = lines[i] // length if t == 0: return False cnt += t if cnt >= N: return True return False def binary_search(left, right): if right - 1 == left:...
8f70428e96025659ef97b55962da7591e01425b8
ykuzin/amis_python71
/km71/Kuzin_Yuriy/homework_4/task1.py
471
4.09375
4
""" Умова: Дано два цілих числа. Вивести найменше з них. Вхідні дані: користувач вводить ціле число Вихідні дані: вивести ціле число """ x = int(input("ВВедіть перше чило ")) y = int(input("Введіть друге число ")) answer = "" if x<y: answer = y elif x>y: answer = x else: answer = "Числа рівні" print(answ...
e196e7084aa322d37eb20789602fe95d6d5aaa00
apillalamarri/python_exercises
/contacts.py
2,470
3.984375
4
# Challenge Level: Beginner # NOTE: Please don't use anyone's *real* contact information during these exercises, especially if you're putting it up on Github! # Background: You have a dictionary with people's contact information. You want to display that information as an HTML table. # Goal 1: Loop through that dic...
debd8f3b2188b43291f577347b23d79b9bfe6a42
wuworkshop/LPTHW
/ex9/ex9.py
645
4.125
4
# Here's some new strange stuff, remember type it exactly. # Assigns the string to the variable days days = "Mon Tue Wed Thu Fri Sat Sun" # Assigns the string to the variable months # The \n is for adding a new line months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" # Prints the string and the variable days print "H...
deee2d5be1d66df9f017b4573a65d0c47491025c
Zhenye-Na/leetcode
/python/127.word-ladder.py
3,224
3.84375
4
# # @lc app=leetcode id=127 lang=python3 # # [127] Word Ladder # # https://leetcode.com/problems/word-ladder/description/ # # algorithms # Hard (31.55%) # Likes: 4766 # Dislikes: 1402 # Total Accepted: 555.3K # Total Submissions: 1.7M # Testcase Example: '"hit"\n"cog"\n["hot","dot","dog","lot","log","cog"]' # # ...
375249bae94bbbabb1080df93aab447ce4c0c5f9
danish45007/Code-Algo-DS
/Random/Data_Stack.py
1,280
4.09375
4
"""LIFO (Last in First out) Methods: -> Push -> PoP -> Peek -> Size -> IsEmpty """ class Stack(object): def __init__(self): self.items = [] def push(self, item): """Push the Element at the last :return : None """ self.items.append(item) ...
f7ccdf311908e21eccbdf89894c847c85a0cdd69
kyawphyoaung/JCU-Programming-Subj-Tutorial-Exercises
/prac_02/word_generator.py
1,480
4.15625
4
""" CP1404/CP5632 - Practical Random word generator - based on format of words Another way to get just consonants would be to use string.ascii_lowercase (all letters) and remove the vowels. """ import random VOWELS = "aeiou" CONSONANTS = "bcdfghjklmnpqrstvwxyz" ALPHABET = "abcdefghijclmnpqrstuvwxyz" def auto(): ...
9ceacbb23c4c135079670719ff7939e3fb76c630
frankiegu/python_for_arithmetic
/力扣算法练习/day100-二叉搜索树中第K小的元素.py
1,902
3.609375
4
# -*- coding: utf-8 -*-# #------------------------------------------------------------------------------- # Name: day100-二叉搜索树中第K小的元素 # Author: xin # Date: 2019/6/12 # IDE: PyCharm # ------------------------------------------------------------------------------- # 给定一个二叉搜索树,编写一个函数 kthSmallest 来...
f970f2e9eaa71e62c1fb6ab6c0079f912a26c40a
Susmitha0211/ChatBot
/myBot.py
5,738
3.71875
4
import random from datetime import datetime def Greet_n_intro(): print("Hi ! I am Knowledge Bot.") print( "I can help you to know the details like Capital, language, most popular places of respective States in India. ") def get_timeofday(): current_time = datetime.now() timeofday_greeting = "Good...
cc5d7806a42e448b1fd1d11858719e8e68cd7c59
Vattikondadheeraj/python
/1.py
611
3.921875
4
class Sample: def setstudent(self): self.name=input("enter the name") self.no=int(input("enter the number")) self.dob=self.dob() self.dob.setdob() def getstudent(self): print(self.name,self.no) self.dob.getdob() class dob: def setdob(self): ...
7012b03855fd409adee39dc771c33d1ed614b0b3
Tsugunni/pj_algorithm_python
/python_algorithms/sort/heap_sort.py
1,310
3.578125
4
# pattern1 from heapq import heappush from heapq import heappop def linked_heap_sort(nums: list) -> list: heap = [] while nums: heappush(heap, nums.pop()) while heap: nums.append(heappop(heap)) return nums # pattern2 def heap_sort(nums: list) -> list: heapify(nums) index = l...
9ea375160a788fe99be5d6950b1b723aae858db8
guillaume-gomez/basics-python
/variables.py
616
4.0625
4
myint = 7 print(myint) myfloat = 7.0 print(myfloat) myfloat = float(7) print(myfloat) mystring = 'hello' print(mystring) mystring = "hello" print(mystring) mystring = "Don't worry about apostrophes" print(mystring) one = 1 two = 2 three = one + two print(three) hello = "hello" world = "world" helloworld = hello +...
095d7d713c0fa69ca663e4bfac17b09d9d1f97c7
leledada/LearnPython
/test_code/20180327-6-11test.py
401
4.125
4
# 用符号的组合在控制台输出不同大小的矩形图案。 # 要求:写一个输出矩形的函数,该函数拥有三个默认参数,矩形的长5、宽5和组成图形的点的符号“*”,为函数添加不同的参数,输出三个不同类型的矩形; def myRact(l=5, h=5, p='*'): for i in range(l): print(p * h) myRact() myRact(4, 3, '#') myRact(2, 6, "!")
0acb259955ba1e5271e83530c1edc186e5afdbd3
JasonMuscles/All
/Chapter_04/wjs_02_(4.3.4)_summary.py
1,359
3.75
4
# Page-54(4-3) # 使用一个for循环打印数字一到20(含20)。 # for num in range(1, 21): # print(num) # Page-54(4-4) # 一百万:创建一个列表,其中包含数字1到1,000,000在使用一个或循环,将这些数字打印出来。 # numbers = [] # for value in range(1, 1000001): # numbers.append(value) # print(numbers) # Page-54(4-5) # 计算1到1,000,000的总和。 # numbers = [] # for value in range(1, ...
36b848696a214828c71f7e10fc2441a3cc23b5d2
Imsid64/Siddharth
/siddha.py
301
4.21875
4
#!/usr/bin/python3 # guess what this program does???? import random r=random.randint(23,49) # gives random num print(r) if r<35: print(r) print(":is less than 35") elif r==30: print("30 is multiple of 10 and 3,both") elif r>=35: print(r,"is greater than 35") else: print("your nnumber is:",r)
43de3ffab70f9b1f95982e49d2b62dd503e85773
emilianoNM/Tecnicas3
/bubbleSort&StackIsraelFP/bubbleSort.py
468
4
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Mon Sep 10 17:24:35 2018 @author: israel """ #MergeSort to TECNICAS 3 def bubbleSort(A): for i in range(1,len(A)+1): for j in range(len(A)-1): if A[j]>A[j+1]: tmp=A[j] A[j]=A[j+1] A[j+...
ed4cf65c105cfb246b15be6b47cd78f92dcbe180
withchristopher/Tutorials_2015
/tut_convolution.py
473
3.546875
4
#Tutorial 4, Convolution import numpy from numpy.fft import fft,ifft from matplotlib import pyplot as plt #Function def conv(x,i=0): vector=x*0 vector[i]=1 fourierft=fft(vector) xft=fft(x) return numpy.real(ifft(xft*fourierft)) if __name__=='__main__': #Variables x= numpy.arange(-20,20,...
6f0b7f8f8b494d41f541ccb9c5442606e3a66e87
CILIWFES/MyPythonStudy
/Numpy/matrix.py
3,144
3.546875
4
import numpy as np myZero = np.zeros([5, 6]) # 生成一个5x6的矩阵,初始值为0 print(type(myZero)) print(myZero) myOnes = np.ones([5, 4]) # 生成一个5x4的矩阵,初始值为1 print(type(myOnes)) print(myOnes) myRand = np.random.rand(5, 4) # 生成一个5x4的矩阵,初始值为随机值,(0~1) print(type(myRand)) print(myRand) myEye = np.eye(5) # 生成5x5单位矩阵 print(type(myEy...
31b77440bf986e8d65f81a645bcbb5a580a88001
ivanychev/githubers
/src/download_users.py
1,322
3.796875
4
#!/usr/bin/env python3 """ Downloads users data from github.com and stores it in SQLite database. The path of DB is stored in config file. Version: 0.2 Author: Sergey Ivanychev """ import sys import config import githubers as g CONFIG_PATH = "../resources/config.json" def check_args(argv): """ Validates `mai...
99bf0cf32d83b9905ee8e5f3c607cff1529d1723
mitrofanov-m/6_sem_labs
/2l_AVL_map/AVLTree.py
5,628
3.59375
4
class Node: def __init__(self, item): self.item = item self.left = None self.right = None # thanks to groupmate for this feature def __str__(self): return self.diagram(self, "", "", "") def diagram(self, node, top, root, bottom): if node is None: re...
9196cec6298cfd16d70709fc1021e70043ae0bbd
frownytown/cs21a
/account.py
1,168
4.1875
4
class Account(object): """ Represent a bank account. Argument: account_holder (string): account holder's name. Attributes: holder (string): account holder's name. balance (float): account balance in dollars. """ def __init__(self, account_holder): ...
48d2a44ccda408625d6e3135e639fde3b6f29d56
Not-Aryan/42Stuff
/ML-4/BMW-Classifier.py
1,551
3.875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.preprocessing import MinMaxScaler from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split #Preparing the data dataset = pd.read_csv('/nfs/2020/a/ajain/PycharmProjects/MachineLearning/ML...
702c3dd020a000d985bf3aa829b72d910f44f261
zzwshow/python
/learn_python/正则表达式.py
3,245
3.734375
4
#coding=utf-8 import re #findall()可以将匹配到的结果以列表的形式返回,如果匹配不到则返回一个空列表 def re_method(): s1='Hello this is joey' s2='The first price is $9.90 and the second price is $100' print(re.findall(r'\w',s1)) #[a-z-A-Z-0-9] print(re.findall(r'\d+\.?\d*',s2)) #finditer() 可以将匹配到的结果生成一个迭代器 def re_method1(): s2='T...
bf440d9605de2227ab19e0bb2d23ab276c571492
srinaveendesu/Programs
/leetcode/day10.py
990
3.609375
4
# https://leetcode.com/problems/intersection-of-two-linked-lists/submissions/ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: l...
71e3d1d9f9031dc55080d9576c9c75f5ee6f2264
andyc010/JIRA_list_string
/JIRA_list_string.py
835
3.6875
4
class jiraListString(): separator = "" itemList = "" def __init__(self, separator, itemList): self.separator = separator self.itemList = itemList def __init__(self): pass def add_separator_text(self, separator, itemList): long_string = '' if len(itemList) ...
6ca37ec3083f26907c30e406451c862fbc6044e8
mgaravindsai/Python-Projects
/search.py
2,077
3.71875
4
import timeit class search: def __init__(self,target,num): self.nums = num self.target = target def squentical_search_unsorted(self): found = False pos = 0 while pos < len(self.nums) and not found: if self.nums[pos] == self.target: found = Tru...
def6d91a7daa99a060147d43c9b9470c2d8052c7
arizala13/CTCI_Problems
/2.2.py
1,686
4.40625
4
# This is question 2.2 of CTCI # ------ Notes to myself ---------- # Write an algorithm to find the kth to the last # element of a singly linked list # Original solution from: https://www.geeksforgeeks.org/nth-node-from-the-end-of-a-linked-list/ # Time complexity: O(n) where n is the length of linked list. # Space com...
ecf238ac50b04d66bf31d2efbc8682c16610fe87
ds-5/ds
/hw_16_B_sypark.py
2,661
3.5625
4
def count_matches(some_list, value): if some_list == [] : return 0 else : if some_list[0] == value : return count_matches(some_list[1:], value) + 1 else : return count_matches(some_list[1:], value) def double_each(some_list): if some_list == [] : return some_list else : return...
4ea6719791838ed68a7f836235f271a22cb83c53
julimorozova/Coursera_Python_programming_basics
/game.py
507
4
4
import random number = random.randint(0, 101) while True: answer = input('Enter number ') if not answer or answer == 'exit': break if not answer.isdigit(): print('Enter the correct number ') continue user_anser = int(answer) if user_anser > number: ...
d6df1ba2694b85b3b583b9de9a22ff701c62b057
NithinNitz12/ProgrammingLab-Python
/CO1/10_areaofcircle.py
77
3.90625
4
r = float(input("Enter the radius:")) area = 3.14 * r * r print("Area=",area)
860df468f48f1e7b88927292d01c2cb54789b5ec
krrdms/ITP270Codes
/Scratch/week3/22Whilept1.py
119
3.9375
4
n = 5 while n > 0: n -= 1 if n == 2: #notice that code returns before printing... continue print(n)
8f7ecbf41ecad336f5d81fa722b4fbddd009aa67
AlexiaAM/Python-Bootcamp
/Problems/pruebas.py
238
3.90625
4
while True: print("Who are you?") name = str(input()) if name != "Alexia": continue print("Password: ") password = str(input()) if password == "00": break print("Welcome to your computer Alexia")
54b3523bb359e46a956db9fad75e94ab1ae6ef68
RanjitSolomon/python
/day8/greet.py
305
3.9375
4
from datetime import date, datetime def greet(name, loc): print(f"Hello {name} in {loc}") print(f"Today's date is {date.today()} ") print(f"Current date and time is {datetime.now()} ") name = input("What is your name? \n") location = input("What is your location? \n") greet(name, location)
e7da9a776ddde9c8420522e459e55154f3204ee9
ieesejin/algorithm_study
/programmers/위장.py
526
3.734375
4
# https://programmers.co.kr/learn/courses/30/lessons/42578 def solution(clothes): answer = 1 closet = {} # initial dictionary for cloth, kind in clothes: if kind not in closet: # if key is not in dict closet[kind] = 1 else: closet[kind] += 1 for value in closet...
5a9827b316418f865d56c21043583aa49c6052e3
brook1123/git
/4_3.py
848
3.84375
4
# error exception # try: # # with open('f.txt','r') as f: # # for line in f: # # x = int(line.strip()) # x = 5 # except FileNotFoundError as err: # print('沒有檔案',err) # except ValueError: # print('資料錯誤') # else: # print('沒有錯誤') # finally: # print('不管有沒有錯最後定會執行') # try: # ...
e2a8b75443f11b63666b586ab22c4f5afb4316a4
Teldrin89/DBPythonTut
/LtP5.py
1,351
4.4375
4
# Python functions allow us to re-use part of code # This makes the overall code shorter and easier to understand # Function example: simple function that adds two numbers def add_numbers(num1, num2): return num1 + num2 print("5 + 4 =", add_numbers(5, 4)) # Local variables - any variable created inside a # fu...
c953b2072e5d44998f4a555f91f02792933a9944
ijockeroficial/Python
/CursoEmVídeo/Mundo 2/Laços/While/fatorial.py
133
4.125
4
numero = int(input("Informe um número inteiro: ")) x = numero fatorial = 1 while x > 0: fatorial *= x x -= 1 print(fatorial)
10a92f0df7c81b24df058be6c1ec7e44aa77f14b
LucaMarino747/Conway
/Conway's Game of Life.py
962
3.609375
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 31 10:21:26 2020 @author: Luca """ import os import time def display_array(ar): "clear the screen, display the contents of an array, wait for 1 sec" os.system('clear') rows = len(ar) # grab the rows if rows == 0: raise...
994b50861e720486749e851adf45a3c043ca9d3d
thenerdpoint60/PythonCodes
/minmaxvalBT.py
1,129
3.9375
4
class Node: def __init__(self,data): self.data=data self.left=None self.right=None def insertNode(self,data): if self.data: if data<self.data: if self.left==None: self.left=Node(data) else: ...
eb43d5a85e3ba2ad029986d1b2d957c338051f75
bloy/adventofcode
/2017/day2.py
570
3.53125
4
#!env python import itertools import aoc def checksum(row): return max(row) - min(row) def solve1(rows): return sum(checksum(row) for row in rows) def checksum2(row): for a, b in itertools.combinations(row, 2): if a % b == 0: return a // b if b % a == 0: retur...
eb69e6927870caec28557783a280e2b9508b82b7
rohithjallipalli/Leetcode_Toekneema
/LeetcodeSolutions/154. Find Minimum in Rotated Sorted Array II.py
1,706
3.515625
4
class Solution: def findMin(self, nums: List[int]) -> int: #binary search variation #check either left or right side with mid, #since there's duplicates, need to have an extra condition to account for if n[mid] == n[right] #then just return the n[left] ''' ...
d2e6e34372ff073580e9052967068ec4cbb04c19
BorodaUA/cool_scripts
/task_5_numbers_convertor/task_5.py
1,021
3.78125
4
import os import sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from number_2_words import NumbersToWords # noqa HELP_MSG = ( '***Welcome to the Numbers 2 Words converter *** \n' 'Please type in number(s), that will be converted to word(s): ' ) NUMBER_TO_LARGE = ( 'Handling numbers above 9...
6095ebc680ef706d456707364b7eb6eabcc58823
vt0311/python
/ex/ex244.py
595
3.546875
4
''' Created on 2017. 10. 26. @author: hsw ''' ''' LIFE is TOO Short 만들기 * 힌트 : for 구문과 if 구문 사용 짝수번쨰 항은 대문자, 홀수번째 항은 소문자로 변경 join() 함수를 이용하여 특정 문자열에 다른 문자열을 추가 ''' list1 = ['Life', 'is', 'too', 'short'] for i in range(len(list1)): if i % 2 == 0 : list1[i] = list1[i].upper() else : ...
765c8767c1f217c300c7ed27b0f15a71774b6e15
todatech/checkio
/py_checkio_solutions/PyCon TW/express_delivery.py
3,733
3.671875
4
#!/usr/bin/env checkio --domain=py run express-delivery # Our three robots found a few mysterious boxes on the island. After some examination Nicola discovered that these boxes have an an interesting feature. If you place something in one of them, you can retrieve it again from any other box. Stephan figures ...
b816ea98b5ccbf71f26287a6d52022eb135bad2c
meaniechee/level_one
/guesszenumber.py
790
3.75
4
# ==================== # WIN THE LOTTERY # ==================== ''' What you needa doz 1. Random number generated by Python lel 2. Get input from user 3. Loop If else statements 4. Print result ''' # task 1 import random rand = random.randint(1,100) # a random int number will be generated between 1 ~ 99 # task 3 for ...
8070cc817e24a64d7cc43a211934fd1cbb0c842a
anaconda121/General-Python-Projects
/Python Data Analysis/Course Materials/Python/Numpy.py
2,742
3.953125
4
def printLine(): print("\n") import numpy as np np.array([1, 2, 3]) #generating basic numpy array print(np.zeros(3)) #generates an array with three slots, all with value 0 printLine() print(np.ones((4,5))) #generates 2-d array with 4 rows and 5 cols printLine() print(np.full((5,4), 3.14))#generates 2-d array...
41f412a6cd886b0c78cebb68c8e77e446f9db454
imod-mirror/IMOD
/pysrc/imoduntar
1,101
3.5
4
#!/usr/bin/env python # imoduntar - Utility to list or extract all files from a tar file # # Author: David Mastronarde # # $Id$ import sys, os, tarfile dolist = False numStart = 1 if len(sys.argv) > 1 and sys.argv[1] == '-t': numStart = 2 dolist = True if len(sys.argv) < numStart + 1: sys.stdout.write("""Us...
40596014bf1bcf51e119aff281391a961dbf35ae
dileepnsp/Algorithms_Practice
/Assignment/pandas_practice.py
288
3.59375
4
import pandas as pd #1.Create a Datatime index containing all the weekdays days of year 2019 and assign a random number to each of them in a dataframe. #2. Given Pandas series , height = [23,42,55] and weight = [71,32,48] . Create a dataframe with height and weight as column names.
1b0bb552261e40feb4ef28168312a843272ea010
CrisTowi/cracking-the-code-interview
/LinkedList/2-8.py
1,826
3.828125
4
""" Description: Detect if a linked list is a loop and detect the first node that represents the beginning of the loop Author: Christian Consuelo """ class Node: def __init__(self, value): self.value = value self.next = None def append_to_tail(self, value): new_node = Node(value) current_nod...
664c76461db59ab93d9fb056925fcc1174662f4e
CharlotteKuang/algorithm
/LeetCode/156.BinaryTreeUpsideDown/Solution.py
3,035
3.6875
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 recursiveUpsideDown(self, node): if not node.left: self.newNode = TreeNode(node.val) return self.newNode father = self.recursiveUpsideDown(node.left) if n...
d222f2c24f0f042054d12d53353357bf366dab00
dynizhnik/python_home_work
/ua/univer/lesson06HW/chapter10_task01_Programm.py
371
3.875
4
from ua.univer.lesson06HW.chapter10_task01_Pet import Pet def main(): name = input('Enter name your pet: ') animal_type = input('Enter type your pet: ') age = float(input('Enter age your pet: ')) pet = Pet(name, animal_type, age) print('Pet name is', pet.get_name(), ', pet type is', pet.get_anim...
636e6b6d7f94b6edaf31d219a9a1fa90fe59c440
0ssamaak0/CS50X
/pset7/houses/roster.py
782
3.859375
4
# TODO from sys import argv, exit import sqlite3 # Checking the right number of command line arguments if len(argv) != 2: print("Enter a valid number of command line arguments") exit(1) connect = sqlite3.connect("students.db") curs = connect.cursor() curs.execute(f"SELECT first, middle, last, birth FROM stu...
a7792d6927943cf8482bf763f0799a18e98f6d1f
imjaya/Leetcode_solved
/twosigma_missing_words.py
456
3.71875
4
#make a dict of bigger string and then for every word in the second string remove the count in the dict, return the list of remaining words def missingWords(s, t): ls = s.split(' ') lt = t.split(' ') counter = collections.Counter(lt) res = [] for s in ls: if s in counter: counter...
50dbd02175e2aa5c90394538769916471e883b17
soyoung823/Udacity_Adventure_game
/adventure_game.py
5,614
3.75
4
import time import random weapons = ["Magical Sword of Ogoroth", "TNT", " Sharp Knife", "Golden Ax"] creatures = ["Monster", "Gozilla", "Gorgon", "Pirate"] weapon = random.choice(weapons) creature = random.choice(creatures) got_weapon = False def print_pause(message_to_player): print(message_to_player) time....
d14f430996f028786c638b213cd8b707b23c98dd
nook2/LearningSF
/projects/SkillFactory/practice_C1/python_practice/1.10.4.py
808
3.6875
4
class Client: def __init__(self, name): self.name = name def get_name(self): return self.name class Guests(Client): def __init__(self, name, address, status): super().__init__(name) self.address = address self.status = status def get_address(self): ret...
4fc774be860349e6f475720f86633d10bf151fb3
khushal2911/hackerrank-30days-of-code
/lets_review.py
309
3.796875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT if __name__ == '__main__': t = int(input()) for i in range(t): s = input() a = "".join([s[c] for c in range(len(s)) if c%2==0]) b = "".join([s[c] for c in range(len(s)) if c%2==1]) print(f'{a} {b}')
f95d8b727eb01b0520dbda447c72efdcd1a03ee2
KritiMitraD/ga-learner-dsmp-repo
/Projectsby_Kriti/code.py
1,600
3.890625
4
# -------------- # Code starts here class_1 = ['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio'] class_2 = ['Hilary Mason','Carla Gentry','Corinna Cortes'] #Concatenation new_class = class_1 + class_2 print("New class is : ", new_class) #Appending new data new_class.append("Peter Warden") print("Upd...
b6badfed124ec69dafeb6d9353d38825b762de62
Uche-Clare/python-challenge-solutions
/Ekeopara_Praise/Phase 1/Python Basic 2/Day21 Tasks/Task5.py
860
4.1875
4
'''5. There are two circles C1 with radius r1, central coordinate (x1, y1) and C2 with radius r2 and central coordinate (x2, y2). Write a Python program to test the followings - "C2 is in C1" if C2 is in C1 "C1 is in C2" if C1 is in C2 "Circumference of C1 and C2 intersect" if circumference of C1 and C2 intersect, and ...
dcc0c2437211e471c00fd73b2bb25ea3c5a25a32
evbeda/games2
/guess_number_game/test_guess_number_game.py
1,593
3.609375
4
import unittest from guess_number_game.guess_number_game import GuessNumberGame class TestGuessNumberGame(unittest.TestCase): def setUp(self): self.game = GuessNumberGame() self.game._guess_number = 50 def test_initial_status(self): self.assertTrue(self.game.is_playing) def test...
654f9410498780a712fc8c721f3109f4ad787e64
Ethan30749/monthy-python-and-the-holy-grail
/Ejercicio 4 Moodle.py
336
4.0625
4
Vocal=('a','e','i','o','u') Consonante=('b','c','d','f','g','h','j','k','l','m','n','ñ','p','q','r','s','t','v','w','x','y','z',) Letra=(input('ingrese una letra: ')) if Letra in Vocal: print('Su letra es la vocal ',Letra) elif Letra in Consonante: print('Su letra es la consonante ',Letra) else: print('let...
844a8368e9a94efea8ca122e90f18edd956486b9
iluvmusubis/Guessing-Game
/Guessing Game.py
13,640
4.09375
4
import random def main(): print("\nWelcome to the Guessing Game!\n" "\nPlease choose your difficulty level:\n" "\n1. Easy\n" "\n2. Medium\n" "\n3. Hard\n") x = int(input()) if x == 1: easy() elif x == 2: medium() elif x == 3: hard() d...
4b59514edc2483a6f7740925ae4c4fb4824421fc
rajdharmkar/Python2.7
/removedupes1.py
443
3.5625
4
set()={} # holds lines already seen outfile = open("new2.txt", "w")#the text files have to be in same dir as py files infile = open("new3.txt", "r") print infile print lines_seen for line in infile: lines_seen = line print lines_seen #if line not in lines_seen: # not a duplicate ou...
f148d33e95cbaa850a845eec35b675ff3134f6b1
lizebang/think-python-2e-examples
/class/functions.py
592
3.84375
4
class Time: """Represents the time of day. attributes: hour, minute, second """ # pure functions, modifiers and designed development # think python 2e -- chapter16 # designed development def time_to_int(time): minutes = time.hour * 60 + time.minute seconds = minutes * 60 + time.second retur...
f55d67d875af84166ca0af66d531e326228669c4
bluewater18/Euler-Probelms
/euler12.py
393
3.640625
4
from functions import findDiv def euler12(x): """What is the value of the first triangle number to have over x divisors?""" i =1 c=1 while True: #print("i is :"+ str(i)) #print("*************") #print("*************") temp = len(findDiv(i)) #print(temp) ...
ed8969bd34094ea33d2f79ee4f4b94e8cf0ad50a
EnricoChi/algo
/1/1.py
1,956
4.0625
4
# 1. Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь. # Чтобы исключить левый ввод будем использовать регулярки import re # Циклим на всякий, если вдруг не с первого раза будет верный ввод while True: # Принимает пользовательский ввод num = input('Введите трёхзначное число: ')...
47f45a742eb7d89eab3d74b986d10511bc138877
LaplaceKorea/aboleth
/aboleth/prediction.py
2,658
3.609375
4
"""Convenience functions for building prediction graphs.""" import tensorflow as tf from tensorflow.contrib.distributions import percentile def sample_mean(predictor, name=None): """ Get the mean of the samples of a predictor. Parameter --------- predictor : Tensor A tensor of samples, wh...
ddc7af534d8cf07887545b1a5fa27c703ba30678
JerinPaulS/Python-Programs
/SpiralMatrixSP.py
664
3.671875
4
''' 59. Spiral Matrix II Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: Input: n = 3 Output: [[1,2,3],[8,9,4],[7,6,5]] Example 2: Input: n = 1 Output: [[1]] Constraints: 1 <= n <= 20 ''' class Solution: def generateMatrix(self, n): ans = ...
52a9c400341c3697d93944749d1229c45914896f
johnobrien/pyshortz
/solutions/20150802/spooning_animals.py
1,174
3.6875
4
from solver.solver import Solver from solver.lists import get_animals def first_vowel(word): vowels = "aeiou" word = word.lower() for i in range(0, len(word)): if word[i] in vowels: return i class SpooningAnimalsSolver(Solver): def solve(self, animals): candidates = [] ...
eeaa5d914ba863d82b4498b9249537a78908cf3b
xniccum/chorewheel
/utils/date_utils.py
3,407
3.59375
4
from datetime import datetime, timedelta import logging import pytz def get_utc_datetime_from_user_input(tz_str, date_time_str): """Returns a datetime object from a string, taking into account the time zone for that string. Note that the date_time_str must be in the one and only acceptable format %m-%d-%Y %I:%...
3b5677714383568aa1d0b1c65c2e89c5cb1dad08
Siddhant08/Recommendation-System
/norm.py
1,255
3.578125
4
import random #initialize empty lists to store ratings rahul=[] silky=[] #randomly fill lists with ratings in the range 1 to 5 considering Rahul's standards for i in range(10): #randomly fill lists with ratings in the range 1 to 5 considering Rahul's standards rahul.append(random.randint(1,5)) #randomly fill lists ...
d3595bf4c19461539bc16cb6083b2f7e8945e236
belladewusa/Python-MD5-Brute-Force
/passCrack - (Readable).py
5,667
4.09375
4
# Required For The Exit Message That Lets The User Know Their Password Has Been Found import sys # Required for md5!! import hashlib # Global Vars: stringPass = "" # Functions: def intro(): print("Welcome to Password Crack!!!\n\n In this application, you will type a password into the console and Python will return ...
c0c81086e622f6925bfb989845e7275680b29ede
pkitutu/ferry_Terminal
/vehicle.py
513
3.515625
4
class Vehicle(object): """docstring for Vehicle""" __size = '' __price = 0 __current_gas = 0 def __init__(self): super(Vehicle, self).__init__() def set_size(self, size): self.__size = size def get_size(self): return self.__size def set_price(self, price): self.__price = price def get_price(self): ...
1b2251a0eb221ce3b4e17595357bb39fbc3b87d7
AusProtoBell/Hillel_KuzmenkoAlex
/lesson_14/task_1.py
1,932
3.578125
4
import random class City: def __init__(self, street_count): self.streets = [] self.initialize_city(street_count) def initialize_city(self, street_count): for street_id in range(street_count): self.streets.append(Street(street_id)) def population(self): populat...
a88966cedb2e155819cab7ba9e2acfeb5f86da9b
HuipengXu/leetcode
/sumNumbers.py
1,958
3.78125
4
# 129. 求根到叶子节点数字之和 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # 递归 class Solution1: def rec(self, node, sum): if node == None: return 0 if not node.left and not node.r...
140f1ec8e935dcb282b88d26bd9f5e9d778383e7
cpeixin/leetcode-bbbbrent
/geekAlgorithm010/Week01/plus-one.py
950
3.8125
4
# coding: utf-8 # Author:Brent # Date :2020/6/13 6:30 PM # Tool :PyCharm # Describe :给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。 # # 最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。 # # 你可以假设除了整数 0 之外,这个整数不会以零开头。 # # 示例 1: # # 输入: [1,2,3] # 输出: [1,2,4] # 解释: 输入数组表示数字 123。 # 示例 2: # # 输入: [4,3,2,1] # 输出: [4,3,2,2] # 解释: 输入数组表示数字 4321。 # # 链接:https...
345ff211e099b7170ed6d61dea2cd7891f3514b1
dukkipatisamyu5/MultiLinear
/2_linear_regression_multivariate.py
1,065
3.890625
4
# multiple linear regression #Importing the libraries import matplotlib.pyplot as plt import pandas as pd import numpy as np from sklearn import linear_model #Importing the dataset df = pd.read_csv('homeprices.csv') #Finding the missing value import math med_bedrooms = math.floor(df.bedrooms.median()) df.bedrooms = d...
1592ea950b476e6ae3787356fd653b37d9ebb1a9
MadhanChiluka/Python_CheatSheet
/PatternsEx.py
274
3.921875
4
for i in range(4): for j in range(4): print("#" , end = " ") print() print() for a in range(4): for b in range(a+1): print("#", end = " ") print(); print() for m in range(4): for n in range(4-m): print("#", end=" ") print()
ee6300a46759eb0d7785d10bdb8b75ad4463fc66
Serine-T/Hangman_game
/hangman.py
2,449
3.890625
4
import random import os from display_hangman import display_hangman def get_word(): file_path = os.path.abspath(__file__) cur_dir = os.path.dirname(file_path) with open(os.path.join(cur_dir, 'fruits.txt')) as f: word = random.choice(f.readlines()).upper() return word.strip() def play(word)...
381a5b27cb9c47056def3c8bd106fb23dd2c2bae
brutalchrist/test_5rabbits
/3_dise~o/2/Mazo.py
6,004
3.59375
4
#-*- coding: utf-8 -*- """ Problema 2 del Test de diseño para LemonTech.\n <Diseñe un mazo de cartas (orientado a objetos) con propiedades y métodos básicos que considere para ser utilizado en distintas aplicaciones que utilicen cartas.> """ class Mazo(object): def __init__(self, nombreMazo, nCartasMazo=60, list...
48f1d220769b768632c136f21aa9a7dbf6a05b3c
bguenthe/coursera
/week4/pong.py
6,146
3.734375
4
# Implementation of classic arcade game Pong import simpleguitk as simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 20 PAD_WIDTH = 8 PAD_HEIGHT = 80 HALF_PAD_WIDTH = PAD_WIDTH / 2 HALF_PAD_HEIGHT = PAD_HEIGHT / 2 ball_pos = [0, 0] ball...
03a2128b0f9766aa59e6420ab47cbe45a2f954fc
tikogr/NLP100
/01/05.py
276
3.703125
4
def n_gram(target, n: int): result = [] for i in range(0, len(target)-n+1): result.append(target[i:i+n]) return result target = "I am an NLPer" # 単語bi-gram words = target.split(' ') print(n_gram(words, 2)) # 文字bi-gram print(n_gram(target, 2))
36d1bd2b8efc91d48a4ada8e4d7b1e8ab131ed80
amantaymagzum/magzumcs
/1.py
348
4.15625
4
num1=int(input("Введите превое число:")) num2=int(input("Введите второе число:")) num1*=5 print("Results:",num1+num2) print("Results:",num1-num2) print("Results:",num1/num2) print("Results:",num1*num2) print("Results:",num1**num2) print("Results:",num1//num2) word="Hi" print(word*2) word=True