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
3d9abc8e44dccf5964b610e95be724b8964d2185
helaluddin92/Python-Challanges
/how to find average N number in python.py
283
4.25
4
# How to find average N number in python def avg_n(num): total_sum = 0 for n in range(num): number = int(input("Enter any number ")) total_sum += number avg = total_sum / num return avg result = avg_n(int(input("How many number?"))) print(result)
8d4c9598992f0c8d1403cf7a25cbfcfb9880d481
nordmoen/IT3105-quarto
/quarto/test/test_board.py
2,178
3.53125
4
#!/usr/bin/python import unittest from board import Board, PlaceTakenError from piece import Piece class TestQuartoBoard(unittest.TestCase): def setUp(self): self.b1 = Board() def test_place(self): self.b1.place(Piece(), 0, 0) with self.assertRaises(PlaceTakenError): ...
b4e25c7cd24f6dbee240d8febef85cbb8b45e465
jfb125/sortingInPython
/heapSort.py
4,036
3.796875
4
class HeapSort: @staticmethod def heapify(a: list, comparator): if a and len(a) != 0: final_element_in_a = len(a)-1 final_parent = HeapSort.parent(final_element_in_a) for i in range(final_parent, -1, -1): HeapSort.sink(a, i, comparator) @staticme...
9a12ff3fef4c97c9b20a42f96feb21cc3447bbfb
CFStumpf/ud036_StarterCode
/media.py
885
3.875
4
# imports webbrowser module import webbrowser class Movie(): """Creates the class Movie. This is used to store information about a users favorite movie. Each instance of the class will store the title, storyline, cover image, and trailer of the movie. This allows the user to showcase the movies on an ...
85bf70fdf965be00b7b6d8fd737504858ad65932
jgoodbody/Advent_of_Code_2017
/day1/day1p2.py
506
3.5
4
num = open('input1.txt','r') input1 = int(num.readline()[:-1]) def advent1_2(n): digitList = [int(d) for d in str(n)] lengthHalf = int((len(digitList) + 1)/2) stringSum = 0 for i in range(lengthHalf): if digitList[i] == digitList[i+lengthHalf]: stringSum += digitList[i] x = 0 ...
ede3f6354aa80ea763478f78c567d6f5d99fad8e
zacharygilliom/configure-report
/main.py
5,611
3.703125
4
import pandas as pd import numpy as np import workdays as wd import matplotlib.pyplot as plt import seaborn as sns sns.set_style(style="darkgrid") # Excel Data File gets created with blank columns. We want to take those out. def drop_columns(df): for col in df.columns: if "Unnamed" in col: df.drop(columns=col,...
efb6c4d2c21a9ff06eae2ff8b9cfe35ba07ed0a5
joe-antognini/tridentine_calendar
/tridentine_calendar/cli.py
1,874
3.890625
4
"""Command-line interface to `tridentine_calendar`.""" import argparse import os import sys from .tridentine_calendar import LiturgicalCalendar def parse_args(args): """Set and parse the command line arguments. Returns: args: An `argparse.Namespace` object with the parsed arguments. """ pa...
647aa628fd41824c571b980e9808b895214debb2
pushkalnath1216/knn-supervised-learning
/KNN.py
2,220
3.765625
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd #import the dataset and load it into pandas dataframe # Assign colum names to the dataset # Read dataset to pandas dataframe dataset = pd.read_csv('Wine.csv') #Preview the first five observations dataset.head() dataset.shape data...
ac9a0a495b459d907640ce5cf83392d3dc2a080a
Hamberfim/ETL_Python_PostgreSQL
/simple_etl/etl_employees_csv.py
1,209
3.640625
4
# -*- coding: utf-8 -*- """ Created on 8/20/2020 @author: Anthony Hamlin Program: etl_employees_csv.py This program is a simple ETL -- extract, transform and load. """ # import os import pandas as pd # print(os.getcwd()) # used so test and see the dataset/dataframe in the IPython console variable viewer # dir_path = os...
dad4741eb50d795e940ab5b60b2d0144dfcd83a9
kalyaniasthana/algorithms-I
/quick_sort.py
1,469
3.8125
4
from split_inversions import text_file_to_list #form stack overflow def median_of_three(arr, l, r): mid = (l + r - 1)//2 a = arr[l] b = arr[mid] c = arr[r - 1] if a <= b <= c: return b, mid if c <= b <= a: return b, mid if a <= c <= b: return c, r - 1 if b <...
51689ef74336727bfb72fb0f430fc91636ebe579
zemial85/zaawansowany
/abstract_class.py
532
3.984375
4
from abc import ABC, abstractmethod class Restaurant(ABC): @abstractmethod def cook_food(self): pass class Sushi(Restaurant): def cook_food(self): print("Cook rice") class Burgers(Restaurant): def cook_food(self): print("Grill meat") class MuffinHouse(Restaurant): de...
dd4fa204a3bfb85ba656de2d1288ca6ece7491da
zemial85/zaawansowany
/zadanie3.py
795
3.96875
4
from abc import ABC, abstractmethod class Character(ABC): def __init__(self, name, hp, intelligence, strength): self.name = name self.hp = hp self.intelligence = intelligence self.strength = strength @abstractmethod def attack(self): pass class Wizard(Character):...
bf1b8ff2d317ed41c79511bd58bdf2387ecd6eb5
Noiro3940/SML_ReadOut
/Lib/Menu.py
1,575
3.578125
4
#Python 3 ''' Dieses ist eine Lib mit der es möglich sein soll ein Menu für das Terminal zu erstellen. ''' import os,sys from colorama import * class Menu(object): def __init__(self, WelcomeTitle='Willkommen im Hauptmenu'): self.titel = WelcomeTitle def ClearScreen(self): ''' Mit di...
077fefa62018ac9e994f5f91d2f6b57e6552bdb6
amiraliakbari/sharif-mabani-python
/by-subject/mathematics/trigonometric.py
533
3.828125
4
import math def sin(rad, precision): ''' rad is angle in radians precision is a floating point number which defines the maximum precision returns the value of sin(rad) ''' rad = rad % math.pi i = 1 res = rad tmp = rad while 1: tmp = tmp * (-1.0) * rad * rad / (4 * i * i...
4ccfa0d66090ae9c4e828cd54df6ef766cf34a9f
amiraliakbari/sharif-mabani-python
/by-session/ta-921/j6/list11.py
228
3.734375
4
a = [1, 2, 4 , 6, 7, 8, 9] x = a[2] y = a[-2] print type(a) print type(x) b = a[0:2] print type(b) print b print a[2:] print a[:2] print a[1:-1] print a[-100:9] print a[:100] print a[4:1] print a[100]
43aa1137cd86a376477b84b9576e7955798b07bd
amiraliakbari/sharif-mabani-python
/by-session/ta-921/j6/list16.py
267
3.640625
4
s = "Salam abc" if ' ' in s: print 'Fasele darad' print s.find(' ') print s.find('x') c = 's' if s.find(c) > -1: print 'hast' q = 'salAM' print s.find(q) s1 = s.lower() q1 = q.lower() print s1.find(q1) print s.lower().find(q.lower())
93436f142ab59deedeba9e8bb9327b92b4c2ed11
amiraliakbari/sharif-mabani-python
/by-session/ta-921/j3/number2.py
184
3.84375
4
print 'A' x = 3 y = 2 print 'B' if x > 10: print "1" else: print x / y print 'C' print x * 1.0 / y print 2 / (y - 2) print 'D' x = 3.0 y = 2.0 print x / y
24bdd6224291fa6abb1be6b484b3b59ef1a1f32a
amiraliakbari/sharif-mabani-python
/by-session/ta-922/j3/a5.py
164
3.53125
4
def cube(x): return x * x * x print cube(a) print cube(b) print cube(c) #print a * a * a #print a ** 3 #print b * b * b #print c * c * c
3bc686f2f394e42ddc9e612673bbffe14407ae2c
amiraliakbari/sharif-mabani-python
/by-session/ta-932/j2/lists.py
130
3.578125
4
a = [] b = [1, 2, 3] print a print b l1 = len(a) l2 = len(b) print b[0] print b[1] print b[2] print b[l2 - 1]
fb1069d5be120216f85cf4f55fb1a38f0da49fbe
amiraliakbari/sharif-mabani-python
/by-session/ta-922/j3/a2.py
241
3.75
4
n = int(raw_input()) i = 0 while i < n: S = '' while True: s = raw_input() if s == '#': break if s == '1': S += 'a' S += s print S i += 1 x = 2 x = '2'
5a5140f46ce2fa03ed15e104541f85380681de4c
amiraliakbari/sharif-mabani-python
/by-session/ta-922/j6/a3.py
427
3.59375
4
#a = [1, 2, 5, 6, 6] #b = [2, 4, 6, 10] def merge(a, b): #c = a + b #c.sort() #return c i = 0 j = 0 c = [] while i < len(a) and j < len(b): if a[i] <= b[j]: c.append(a[i]) i += 1 else: c.append(b[j]) j += 1 ...
3d73de561e783506799e0f8e8b2f04c341cce51f
amiraliakbari/sharif-mabani-python
/by-session/ta-921/j11/class2.py
369
3.875
4
import math class Circle: def __init__(self, r, x=0, y=0): self.r = r self.x = x self.y = y def get_area(self): return self.r**2 * 3.14 def get_diam(self): return self.r * 2 * 3.14 c1 = Circle(r=1, x=0, y=0) c2 = Circle(3) print c1.get_area() pr...
f8adcc2bdd040963560c5fa96ae48e219b9afe0f
aditmulyatama/pertemuan-6
/tuple.py
868
4.46875
4
# Tuple # Tuple adalah struktur data kolektif sekuensial yang tidak dapat diubah bawaan python # Tuple juga bisa menyimpan banyak tipe data yang berbeda dan mengizinkan duplikasi data this_is_tuple = ("oke", 100, 9.0, "oke") # print(this_is_tuple, " is type of ", type(this_is_tuple)) # Akses data di Tuple # print("F...
514e3e0c3750d43d8977dd410a141ac0d58b73b9
Akiemon/practice
/get_prime_number.py
396
3.671875
4
def get_prime_number(max_val): numbers = [] for i in range(2, max_val + 1): flag = True for j in numbers: if i % j == 0: flag = False break if flag == True: numbers.append(i) numbers.insert(0, 1) ...
b223751246033b81fb3ed0fe499b3897d9bd1b07
kwsjd/CR8
/SR8.py
2,153
3.984375
4
p = '' flag = True while flag: try: p = input('введите в какую систему исчисления вы хотите перевести ваше число: двоичную или восьмиричную?\n: ') except ValueError: print("введите иммено двоичную или восьмиричную") else: if not (p == "двоичную" or p == "восьмиричную"): p...
5eb3a038825afdea132253145e75f233e6e34216
naveentrtumkur/Intermediate-AI
/Missionary_Cannibals_BFS/missionaries_cannibals_BFS.py
5,345
4.09375
4
#This program solves the classical Missionaries and Cannibals problem using breadth-first search technique #Import the operator and Queue library required to solve this problem import operator import Queue #Define the start state of the boat Start = [3,3,1] #Enumerate the values for wrongside, missionary, cannibal a...
2815ec62fa9fc77b6fc3e824a3e010e6435f62d8
DmitryMedovschikov/Generation_Python-Beginner_course
/1.1 Команды print и input/Команды print и input.py
2,163
4.03125
4
# Напишите программу, которая выводит на экран текст «Здравствуй, мир!» # (без кавычек). print('Здравствуй, мир!') # Напишите программу, которая выводит последовательность чисел: 4 8 15 16 23 # 42 с одним пробелом между ними. print('4', '8', '15', '16', '23', '42') # Напишите программу, которая выводит последовател...
a74bb6dbe445cc6fe876243bf15d4258d8da4837
dslasdoce/django-rest-base
/apps/shape/types/rectangle.py
310
3.546875
4
from apps.shape.types import ShapeTypeAbstract class Rectangle(ShapeTypeAbstract): """ This is an equilateral triangle""" parameters = ['length_1', 'width_1'] def area(self): return self.length_1 * self.width_1 def perimeter(self): return 2 * (self.length_1 + self.width_1)
adae805df878caea9798747e38ad673f6d3bad53
WanlinLi/ORIE5270_Homework
/Homework3/dijkstra_folder/find_path_folder/find_path.py
3,124
3.609375
4
import heapq import numpy as np class Graph(object): def __init__(self): pass def neighbor(self, graph, node): """ Return a list of neighbor nodes :param graph: dictionary, the output of read_file :param node: string :return: list of string """ n...
48533b35d60630df2f22f7a184bc7cf2359add0b
iamanx17/dslearn
/Stack/reverse.py
560
3.890625
4
from stack import Stack #move n-1 elements to s2 save last element of s1 #push n-1 elements from s2 to s1 again #append the last element to s1 def reverse(s1, s2): if s1.size()<=1: return while s1.size()!=1: ele=s1.pop() s2.push(ele) lastelement=s1.pop() while s2.size()!=0: ...
0360f18a46acb034f2be565f9593f0091c332fc7
iamanx17/dslearn
/linkedlist/deleten.py
687
3.734375
4
from linkedlist import takeinput, printdata # delete n node after m node def deletemn(head,m,n): save=head if n==0: return head while head is not None: for i in range(m): temp=head if head is None: return save head=head.next ...
9557dbca45f4f5a0b326ea0ff476ab1cb49fffed
iamanx17/dslearn
/Stack/balanced.py
419
3.859375
4
from stack import Stack def balanced(string,s): for i in string: if i in '{[(': s.push(i) elif s.top()=='(' and i==')': s.pop() elif s.top()=='{' and i=='}': s.pop() elif s.top()=='[' and i==']': s.pop() if s.isEmpty(): ...
41a001f1e048b199811b7abdc2465c71ae15ce9c
iamanx17/dslearn
/linkedlist/Append.py
522
3.9375
4
#Append last n to first from linkedlist import takeinput, printdata def length(head): count=0 while head is not None: count+=1 head=head.next return count def append(head, n): count=0 source=head while count<length(head)-n: curr=head head=head.next newh...
d243883c9cd433b729bbf5afb7845a07c2f0e0a9
kushnayak/PyGame
/Tic_Tac_Toe/Tic_Tac_Toe.py
3,704
3.78125
4
def tic_tac_toe(): import pygame,time import numpy as np pygame.init() screen = pygame.display.set_mode((900,900)) red = (255,0,0) carryOn = True board = {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,} over = pygame.font.Font('freesansbold.ttf',160) shape = 'x' def draw(): py...
5e67e02db63fc0f238afc5dc4c5067e40dd0d84a
diophung/common-problems
/algorithms/reverse_string.py
250
3.96875
4
class ReverseString: def reverse(self, input): tokens = input.split(' ') for i in reversed(tokens): print(i) def reverseList(list): for i in reversed(list): print(i) sentence = "This is a test" r = ReverseString() r.reverse(sentence)
e3aa2d09ea6616a34cc96b5943726268e1ea0aab
xuqil/DataStructures
/ProblemSolving_python/three/List/node.py
439
3.515625
4
class Node: """ 实现链表节点 """ def __init__(self, initdata): self.data = initdata self.next = None def get_data(self): return self.data def get_next(self): return self.next def set_data(self, newdata): self.data = newdata def set_next(self, newnext...
84c509cf4a6a433de1e5f8343c9d7b2861990404
xuqil/DataStructures
/第三章线性表/链接表/排序/test.py
335
3.734375
4
def list_sort(lst): for i in range(1, len(lst)): # 开始时片段[0:1]已排序 x = lst[i] j = i while j > 0 and lst[j - 1] > x: lst[j] = lst[j - 1] # 反序逐个后移元素至确定插入元素 j -= 1 lst[j] = x return lst print(list_sort([10, 2, 5, 3, 9, 6]))
6fb43bc12202757f38d6c38e6f16d6f5b1e13fd3
xuqil/DataStructures
/ProblemSolving_python/three/Queue/queue.py
826
4.0625
4
class Queue: """ 使用列表实现队列 """ def __init__(self): self.items = [] def is_empty(self): """ 是否为空 :return: """ return self.items == [] def enqueue(self, item): """ 入队 :param item: :return: """ self.ite...
3da8a1b42d3f9fdee5f9c20839484fb445c9b5c8
ElleuchX1/RandomCodesHere
/parenth.py
350
3.546875
4
def parenth(Start,End,numb,a=[]): if End == numb: print(''.join(a)) return else: if Start<numb: a.append('(') parenth(Start+1,End,numb,a) a.pop() if Start>End: a.append(')') parenth(Start,End+1,numb,a) ...
7272763a96f7cea5606f3609e3123192bc230a38
ZhengTang1120/ISTA457-Final
/str2vec.py
5,531
3.625
4
from typing import Sequence, Any import numpy as np class Index: def __init__(self, vocab: Sequence[Any], start=1): """ Assigns an index to each unique word in the `vocab` iterable, with indexes starting from `start`. """ self.obj_to_idx = dict() self.idx_to_obj =...
12dda19350218d4ad3b9a4bbae13a72101bd44a5
Chithra-Lekha/pythonprogramming
/co5/co5-1.py
346
4.40625
4
# Write a python program to read a file line by line and store it into a list. l = list() f = open("program1.txt", "w") n = int(input("Enter the number of lines:")) for i in range(n): f.write(input("Enter some text:")+"\n") f.close() f = open("program1.txt", "r") for i in f: print(i) l.append(i[...
f10e516974a5b76c49e4158f4051b807d3682877
Chithra-Lekha/pythonprogramming
/prgm2.py
120
3.828125
4
yr=int(input("enter the future year")) for i in range(2021,yr+1): if i%4==0 and i%100!=0 or i%400==0: print(i)
04aea542b7903d07b756e8a7287b720f8938a414
Chithra-Lekha/pythonprogramming
/co2-8.py
335
4.28125
4
list=[] n=int(input("enter the number of words in the list:")) for i in range(n): x=input("enter the word:") list.append(x) print(list) length=len(list[0]) temp=list[0] for i in list: if len(i) > length: length=len(i) temp=i print("the longest word is of length",...
ad6a45383970af277db92294ebb4358d5368bda4
Chithra-Lekha/pythonprogramming
/prgm19.py
137
3.875
4
import math a=int(input("enter 1st number:")) b=int(input("enter 2nd number:")) c=math.gcd(a,b) print("The gcd of ",a,"and",b,"is",c)
a8801fe6f9d8cc39d0769a636f3066653990838e
luizParreira/6.00.1x
/Python/pset01a.py
219
3.78125
4
def num_vowels(string): result = 0 for s in string: vowels = ['a', 'e', 'i', 'o', 'u'] if s in vowels: result += 1 return result a = num_vowels('azcbobobegghakl') print(a)
1d4a3fc6892ccbb7a28c66c00378bd38daba92d9
dannymulligan/Project_Euler.net
/Prob_233/prob_233.py
4,921
3.515625
4
#!/usr/bin/env python # coding=utf-8 # # Project Euler.net Problem 233 # # Lattice points on a circle # # Let f(N) be the number of points with integer coordinates that are # on a circle passing through (0,0), (N,0),(0,N), and (N,N). # # It can be shown that f(10000) = 36. # # What is the sum of all positive integers N...
391c26950767308bc062a61009dacd8b9d0c36d4
dannymulligan/Project_Euler.net
/prob_144/prob_144.py
3,968
3.5625
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 144 # # Investigating multiple reflections of a laser beam. # # In laser physics, a "white cell" is a mirror system that acts as a # delay line for the laser beam. The beam enters the cell, bounces # around on the mirrors, and eventually works its way back ...
1747038f1cd4451e6d41f0b7b5acade2fcc16e23
dannymulligan/Project_Euler.net
/Prob_351/prob_351.py
7,557
3.734375
4
#!/usr/bin/env python3 # coding=utf-8 # # Project Euler.net Problem 351 # # Hexagon orchards # # A hexagonal orchard of order n is a triangular lattice made up of # points within a regular hexagon with side n. The following is an # example of a hexagonal orchard of order 5: # # X . . . . X # ...
cd98b25ea87a1fca7e24db1802c7ef194b867777
dannymulligan/Project_Euler.net
/Prob_683/prob_683.py
3,611
3.75
4
#!/usr/bin/env python3 # coding=utf-8 # # Project Euler.net Problem 683 # # The Chase II # # Consider the following variant of "The Chase" game. This game is # played between n players sitting around a circular table using two # dice. It consists of n−1 rounds, and at the end of each round one # player is eliminated an...
9978e593370dbb860f8f58f69777ef9c256a3938
dannymulligan/Project_Euler.net
/Prob_019/prob_019.py
2,625
3.78125
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 19 # # Counting Sundays # # You are given the following information, but you may prefer to do # some research for yourself. # # 1 Jan 1900 was a Monday. # Thirty days has September, # April, June and November. # All the rest have thirty-one,...
214d2994fac5981b513a2b4f61b3715495a87a61
dannymulligan/Project_Euler.net
/Prob_135/prob_135a.py
3,739
3.515625
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 135 # # Determining the number of solutions of the equation # x^2 − y^2 − z^2 = n. # # Given the positive integers, x, y, and z, are consecutive terms of # an arithmetic progression, the least value of the positive integer, # n, for which the equation, ...
46e1b898bde078a0ac32683754c8125cdae42b4b
dannymulligan/Project_Euler.net
/Prob_613/prob_613.py
2,443
4.0625
4
#!/usr/bin/env python3 # coding=utf-8 # # Project Euler.net Problem 613 # # Pythagorean Ant # # Dave is doing his homework on the balcony and, preparing a # presentation about Pythagorean triangles, has just cut out a # triangle with side lengths 30cm, 40cm and 50cm from some cardboard, # when a gust of wind blows the ...
ff26f3f67d0a5e08ccc4c0332b00747ef24c1fe9
dannymulligan/Project_Euler.net
/Prob_371/test_371.py
1,602
4
4
#!/usr/bin/env python3 # coding=utf-8 # # Project Euler.net Problem 371 # # License plates # # Oregon licence plates consist of three letters followed by a three # digit number (each digit can be from [0..9]). # # While driving to work Seth plays the following game: Whenever the # numbers of two licence plates seen on ...
7753d19e7b1f0ad7610e2c66b1da9ac5d36bf53d
dannymulligan/Project_Euler.net
/Prob_004/prob_004.py
973
4.03125
4
#!/usr/bin/env python3 # # Project Euler.net Problem 4 # # A palindromic number reads the same both ways. # # The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. # Find the largest palindrome made from the product of two 3-digit numbers. def palindrome(candidate_int): # Convert ...
dc8b6d42af99f63c706f7d4121b63486813785f6
dannymulligan/Project_Euler.net
/Prob_307/prob_307d.py
3,100
3.515625
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 307 # # Chip Defects # # 20,000 defects are randomly distributed amongst the 1,000,000 # integrated-circuit chips produced by a factory (any number of # defects may be found on a chip). # # Find the probability that there is a chip with at least 3 defects. ...
d94232fcae4a34c9aadf7c6d8300ae31431311e6
dannymulligan/Project_Euler.net
/Prob_118/prob_118a.py
2,790
3.609375
4
#!/usr/bin/python # # Project Euler.net Problem 118 # # Exploring the number of ways in which sets containing prime elements # can be made. # # Using all of the digits 1 through 9 and concatenating them freely to # form decimal integers, different sets can be formed. Interestingly # with the set {2,5,47,89,631}, all o...
aa7f4f4328080b5f38cc852c7192288fa9c3ec8a
dannymulligan/Project_Euler.net
/Prob_118/prob_118.py
1,752
3.734375
4
#!/usr/bin/python # # Project Euler.net Problem 118 # # Exploring the number of ways in which sets containing prime elements # can be made. # # Using all of the digits 1 through 9 and concatenating them freely to # form decimal integers, different sets can be formed. Interestingly # with the set {2,5,47,89,631}, all o...
29a2c2a520dfad83d106dddf1ce3d7039ac437c6
dannymulligan/Project_Euler.net
/Prob_622/primes.py
1,962
4.125
4
#!/usr/bin/python import time ############################################################ def calculate_primes(limit, prime_table, prime_list): start_time = time.clock() if (limit>len(prime_table)): raise Exception("prime_table is too small ({} entries, need at least {})".format(len(prime_table), lim...
7449d05955c1035de7bf5af3dfb934d89cc2094c
dannymulligan/Project_Euler.net
/Prob_130/prob_130.py
2,896
3.6875
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 130 # # Finding composite values, n, for which n−1 is divisible by the # length of the smallest repunits that divide it. # # A number consisting entirely of ones is called a repunit. We shall # define R(k) to be a repunit of length k; for example, R(6) = 11...
14a999d6636a4b6fc71c0bfb1eb98413817ddf14
dannymulligan/Project_Euler.net
/Prob_347/prob_347.py
2,808
3.671875
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 347 # # Largest integer divisible by two primes # # The largest integer <= 100 that is only divisible by both the primes # 2 and 3 is 96, as 96=32*3=25*3. For two distinct primes p and q let # M(p,q,N) be the largest positive integer <=N only divisible by b...
52ceddba9278cb3f7a7d63aad50c7a4a9df64ca9
dannymulligan/Project_Euler.net
/Prob_188/prob_188.py
2,317
4.03125
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 188 # # The hyperexponentiation of a number # # The hyperexponentiation or tetration of a number a by a positive # integer b, denoted by a^^b or ^(b)a, is recursively defined by: # # a^^1 = a, # a^^(k+1) = a^(a^^k). # # Thus we have e.g. 3^^2 = 3^3 ...
7b33ebd0eac0a00bb33eaf4398fe5d7a1a58471b
dannymulligan/Project_Euler.net
/Prob_187/prob_187.py
2,538
3.859375
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 187 # # Semiprimes # # A composite is a number containing at least two prime factors. For # example, 15 = 3 5; 9 = 3 3; 12 = 2 2 3. # # There are ten composites below thirty containing precisely two, not # necessarily distinct, prime factors: 4, 6, 9, 1...
299c99e32c7816cd34591da88f4cdf8fdbefb7cc
dannymulligan/Project_Euler.net
/Prob_115/prob_115.py
4,256
3.609375
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 115 # # NOTE: This is a more difficult version of problem 114. # # A row measuring n units in length has red blocks with a minimum # length of m units placed on it, such that any two red blocks (which # are allowed to be different lengths) are separated b...
2a43e9ff655eacd2e3b983a6c9e11f93b9d4b4c5
dannymulligan/Project_Euler.net
/Prob_086/prob_086a.py
8,780
3.84375
4
#!/usr/bin/python # # Project Euler.net Problem 86 # # A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 # by 3, and a fly, F, sits in the opposite corner. By travelling on # the surfaces of the room the shortest "straight line" distance from # S to F is 10 and the path is shown on the diagram. # # ...
a3a37c121d9fc02a9b7f95a6ec73a9d243de67e1
dannymulligan/Project_Euler.net
/Prob_001/prob_001a.py
532
3.71875
4
#!/usr/bin/python # # Project Euler.net Problem 1 # # Add all the natural numbers below one thousand that are multiples of 3 or 5. # # If we list all the natural numbers below 10 that are multiples of 3 # or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # # Find the sum of all the multiples of 3 or 5 below...
613135282f40b87763c65809102683c30c11ae1e
dannymulligan/Project_Euler.net
/Prob_307/prob_307a.py
1,459
3.59375
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 307 # # Chip Defects # # 20,000 defects are randomly distributed amongst the 1,000,000 # integrated-circuit chips produced by a factory (any number of # defects may be found on a chip). # # Find the probability that there is a chip with at least 3 defects. ...
3b039fb1abfc81f9f6ed3f6ce4dc4d0cead445ee
RensVan/ai-test
/test.py
981
3.71875
4
from sys import argv import random script, filename = argv print "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." raw_input("?") print "Opening the file..." target = open(filename, 'w') print "Truncating the file. Goodbye!" target.trun...
c984406ddb5de6994247a36fd497dcdbdff453e3
76hrvoje/Python
/Python_Homework_8.1.py
438
4
4
mood = input("Please enter your mood: ") if mood == "happy": print("It is great to see you happy!") elif mood == "nervous": print("Take a deep breath 3 times.") elif mood == "sad": print("Please mate, do not be sad") elif mood == "excited": print ("Nice but be careful not to get over excited")...
20af9a99e4f8e90b6a839b774eb9a942c7851583
microease/runoob-python-100-examples
/OK/016ok.py
225
3.515625
4
# 输出指定格式的日期。 import datetime import time print(datetime.date.today()) print(datetime.date.today().strftime('%Y/%B/%d')) local_time = time.localtime() # print(time.strftime("%Y年%m月%d日", local_time))
771c6cc674e6299c842a3e388bca7cc0f2252bf1
srinijadharani/DataStructuresLab
/02/02_c_delete_duplicate.py
594
4.3125
4
# 2c. Program to delete duplicate elements from an array # import the array module import array as arr array1 = arr.array("i", [1, 3, 6, 6, 8, 1, 9, 4, 3, 0, 4]) # initial array print("Initial array is:") for a in array1: print(a, end = ", ") # function to delete duplicate elements def delete_duplicate(a...
7d5d8c44c14893cd69c75b15e1c4f324370b7d46
srinijadharani/DataStructuresLab
/07/07_circular_linked_list.py
2,218
4.09375
4
''' 07. Program to create a Circular singly linked list for adding and deleting a Node. ''' class Node: def __init__(self, data): self.data = data self.next = None class CircularLinkedList: def __init__(self): self.last = None # This function is only for empty...
1f81e477ec81fde2f1edcbf9a33c2a1580f8d8d6
srinijadharani/DataStructuresLab
/10/10_queue_implementation.py
746
4.15625
4
class Queue(object): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def enqueue(self, item): self.items.insert(0, item) def dequeue(self): return self.items.pop() def size(self): return len(self.items) def display...
5a18eac0d8a069a3a7b38ce9281616e0027fc02c
srinijadharani/DataStructuresLab
/08/08_stack_implementation.py
1,029
4.28125
4
''' 08. Program to create a stack and perform various operations on it. ''' class Stack(object): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, items): self.items.append(items) def pop(self): ...
33fb21c39b4e5df764e4ceecce5a930f617255c0
rheehot/Algorithm-40
/Programmers/Lv1/K번째 수/Lv1_K번째 수.py
409
3.71875
4
def solution(array, commands): answer = [] for l in commands: answer.append(sorted(array[l[0]-1:l[1]])[l[2]-1]) # 새 array를 만들어서 sort 하는 것 보다 sorted로 정렬된 리스트를 반환하는 것이 낫다. return answer # 참고: lambda식 사용 """ def solution(array, commands): return list(map(lambda x:sorted(array[x[0]-1:x[1]]...
456e7f993b2283cca356994bdc939a53b4978c27
T-Cunn/Jahresarbeit-KI
/code/03 physicsSim.py
2,456
3.78125
4
#!/usr/bin/env python3 import numpy as np from turtle import * #setup screen width, height = 600, 600 screen = Screen() screen.setup(width, height) screen.tracer(0, 0) class ball: """ball class""" #size of the circle diameter = 20 def __init__(self, x, y, vx, vy): self.pos = np.array([x, y]) # pos ...
f7b1ac18e887ab7da18476deda21724c5c089988
davesamgv94/FVM-vs-RFB
/Knots.py
1,062
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 18 18:33:23 2018 @author: luiggi """ import numpy as np class Line(): def __init__(self, N, L): self.__N = N self.__NB = 2 self.__NI = N - self.__NB self.__L = L self.__x = np.zeros(N) ...
187e75536463829eebf3cb1b84e88ad48a299f81
davesamgv94/FVM-vs-RFB
/Advection.py
4,150
3.5625
4
""" Created on Tue Mar 6 15:11:05 2018 @author: Dr. Luis Miguel de la Cruz adaptado por: Samuel Garcia """ # Libreria de Python import numpy as np # Importar Script donde se encuentra la parte # de los Coeficienetes from Coefficients import Coefficients # Declaración de la Clase Advección class Advection1D(Coeffici...
f1c8c835ca5b6efbb1e31eafc5ee2a5dc77fde26
mouayadd/TurtleArtDesign
/mydesignfunctions.py
584
4.34375
4
import turtle #brings in turtle bob = turtle.Turtle() #gives turtle the name bob def draw_star(size,color): #creates a function bob.penup #pulls the pen up to make sure no lines are drawn when moving bob.goto(10,15) bob.pendown #drops the pen in order to start drawing again angle=120 bo...
a5fd0fb65394a512da5174acf46dca2d5b817ad6
sohumd96/CTCI
/Chapter1/Problem7/test_rotate_matrix.py
474
3.5625
4
from unittest import TestCase from Chapter1.Problem7.rotate_matrix import rotate_matrix class Test(TestCase): def test_rotate_matrix(self): self.assertEqual(rotate_matrix([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]), [[13,9,5,1],[14,10,6,2],[15,11,7,3],[16,12,8,4]]) se...
37a5bbf3eeac7b5549ace38edf35ad03b47a536c
sohumd96/CTCI
/Chapter2/Problem4/partition.py
471
3.703125
4
from Chapter2.linked_list import * def partition(l1, part): left = LinkedList(0) left_temp = left right = LinkedList(0) right_temp = right while l1 is not None: if l1.data < part: left_temp.next = l1 left_temp = left_temp.next else: right_temp.n...
44d8c4a112329de74260f82f986c5e6075d82869
zxwqxtu/python
/list.py
967
3.625
4
def f(x): return x%2 l = range(0,10) print filter(f, l) l = [] l = ['abc', 'ABD', 'aBe'] l.append('abf') l.extend(['acd']) l = [1,2,3,1] l.remove(1) print l ''' print('old:'+str(l)) l.sort() print(l) l.sort(key=str.lower, reverse=True) print(l) l.sort(key=None, reverse=True) print(l) l.sort(reverse=True) print(l)...
5db231e2a33617c083bc1c7293faf584d978aa04
A-Aishu/PYTHON--PROGRAMMING--SCS1619---PDF-ANS-
/UNIT 2(2).py
203
3.765625
4
string_name = "PythonProgramming" for element in string_name: print(element, end=' ') print("\n") string_name = "PYTHON" for element in range(0, len(string_name)): print(string_name[element])
46e75b978950c3d2251f6f853001313690884b5a
tompika/num_beadando
/problems/M2x2Norma2/main_.py
802
3.75
4
#!/usr/bin/env python3 import math def hypot(a, b): res = 0 if abs(a) > abs(b): res = b / a res = abs(a) * math.sqrt(1 + res * res) elif b != 0: res = a/b res = abs(b) * math.sqrt(1 + res * res) else: res = 0.0 return res def matrix_norm(A, n): resul...
b613dbf0f89ff6d0d88afb61b895c806c7611080
fagan2888/data_skills_for_business_analytics
/week_4/class4.py
949
3.9375
4
def minimum(x,y,z): min = float("inf") for num in [x,y,z]: if num < min: min = num return min # print(minimum(1,2,3)) def trinomial_algo(row,col): if row == 0 and col == 0: return 1 if col < -row or col > row: return 0 upLeft = trinomial_algo(row -...
5b51e76698964de496c5c1334d5dd14b1c121f6d
kashifkhattak/Virtual-Chat
/VCServer.py
2,827
3.5
4
"""Server for multithreaded (asynchronous) chat application.""" from socket import AF_INET, socket, SOCK_STREAM from threading import Thread import sys def accept_incoming_connections(): #Sets up handling for incoming clients. while True: client, client_address = SERVER.accept() #Client and his info g...
2f421c137c416d194f3180e2865bc34ecf9bb400
blairt001/CommentCMD
/user.py
855
3.796875
4
class Comments(): def __init__(self,title,content): self.title=title self.content=content self.comments=[] def create_own_comment(self,title): comment=input("please enter comment:") self.comments.append(Comments(title,comment)) print("successfully created") print(len(self.comments)) def edit_own_comm...
0fd177c919117693228ed03180b848b42d8068e4
manuvazquez/smc_tools
/util.py
479
3.53125
4
from typing import Sequence import scipy.special def log_sum_from_individual_logs(logs: Sequence) -> float: """ Returns the logarithm of the sum of a sequence of numbers given their individual logarithms. TODO: this function is here for backwards compatibility reasons Parameters ---------- logs : array_like ...
1416622f9cf16592646d3ceb93a4c448275cda9c
syjung0130/pythonic
/list_comprehension/list_comprehension.py
1,627
3.765625
4
#-*- coding: utf8 -*- #파이썬에는 '리스트 컴프리헨션'이라는 한 리스트에서 다른 리스트를 만들어내는 간결한 문법이 있다. # 각 숫자의 제곱 계산값들이 저장된 리스트를 예로 들어보자 a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] squares = [x**2 for x in a] print(squares) # 인수가 하나뿐인 함수를 적용하는 상황이라면 lambda를 사용하는 것이 좋다. squares = map(lambda x: x**2, a) # 하지만, 인자를 두 개 이상을 사용할 때는 깔끔해보이지 않기 때문에 리스트 컴...
936a26e72ac5ceb90ca55c39a0167c678fccb317
ahmadalsharef994/Algorithms_and_Data_Structures_In_Python
/Quicksort.py
12,797
4.0625
4
# -*- coding: utf-8 -*- """ ## Problem 1: Design a Correct Partition Algorithm You are given code below for an incorrect partition algorithm that fails to partition arrays wrongly or cause out of bounds access in arrays. The comments include the invariants the algorithm wishes to maintain and will help you debug. Y...
a0ebfb48fa0c19c8e7e34a85c485edf857f7e891
gabrielsscti/competitive-programming
/LeetCode/278/278.py
565
3.5
4
# The isBadVersion API is already defined for you. def isBadVersion(version: int) -> bool: if version >= 2: return True return False class Solution: def firstBadVersion(self, n: int) -> int: start = 0; end = n+1 if n == 1: return 1 while(start < end): mid = (start+end)//2 print(...
fce538f59ab2596ace898f86cc4831bcbb8757a9
BabyNaNaWang/myPythonProgram
/复习.py
2,918
3.75
4
import random #单行注释 #def funcname(parameter_list)pass #多行注释 '''if condition: pass else: pass''' '''#变量 a = 100 print(a) b = 'i love python' print(b) # 输入 c = input('请输入:') print(c) # 运算符 d = 1 d +=1 print(d) e = 3 f = e * 3 f = e%3 print(f) # if 判断 g = 10 h = 100 if g>10 and h<200: print('大了') if not(g>...
934c5a5cdd4ac14017f7064a5ccbf63777caa6f2
BabyNaNaWang/myPythonProgram
/文件读写.py
157
3.703125
4
#文件写入 '''f = open('file.open.txt','w') f.write('hello world /n hello python') f.close()''' #文件读 f = open('file.open.txt','r+') print(f.read())
a36f69ae0e11a20138a5232983d13af4660476dc
BabyNaNaWang/myPythonProgram
/列表排序.py
722
4.25
4
import random #列表排序 nums = [1,34,5,90,80] '''nums.sort(reverse = True) print(nums)''' nums.reverse() print(nums) newNums = [100,20,18,39,90] #newNums.reverse() #倒置 #newNums.sort() #从小到大排序 newNums.sort(reverse = True) #从大到小排序 print(newNums) #列表的常见操作 #1、添加 insert names = ['he','she','his'] names.insert(0,'him') print(...
43dfedb4c505c4c2caadfae563275043ce28e039
BabyNaNaWang/myPythonProgram
/2018-5-7.py
586
3.703125
4
import random secret = random.uniform(1,2) new_sec = round(secret, 2) print('-----let us play a game-----') temp = input('来猜一猜现在我想的一个数字:') guess = float(temp) count = 1 while count <=3: if guess == new_sec: print('w0w') break if count == 3: print('没机会了') break if guess > new...
cafd46886bf1713a537458db19daa24dabd93bc5
BabyNaNaWang/myPythonProgram
/列表循环.py
343
4.125
4
names = ['gaga','didi','gana'] '''print(names[0]) print(names[1]) print(names[2]) for x in names: print(x)''' #查询是否数字在列表内 findFlag = 0 insertName = input('请输入名字:') for temp in names: if temp == insertName: findFlag = 1 break if findFlag ==1 : print('yes') else: print('no')
1a438eb9bd07ebd7c1f1d8906c93571ed85edd4a
Ben-McDaniel/2019-school
/Fun times/crack.py
683
3.515625
4
import math import time def main(): print("Enter Password:") crack_pass = [] user_password = [] user_password = input() start_time = time.time() while crack_pass != user_password: your_list = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&&*()_-=+:.' ...
dd5ebbcf8f1e3912aaf47ca4b19a4f642ad701cb
jkumarinvenco/first2
/ifProgram.py
382
4.0625
4
import sys try: x = int(input("Please enter any number: " )) if x < 0: print("This is negative number") elif x == 0: print("This is Zero, an awesome number") elif x > 0: print("This is positive number") else: print("This is really unknown number...weird") except Valu...
c11b808a074cfead4aa72a0bb2a4f4c94d8ff14e
nojan1/AdventOfCode
/2019/Day3/main.py
1,391
3.578125
4
def buildLineCoordinates(line): changeMap = { 'U': (0, +1), 'L': (-1, 0), 'D': (0, -1), 'R': (+1, 0) } coordinates = [] instructions = line.strip().split(',') for instruction in instructions: direction = instruction[0] distance = int(instruction[1::])...
974bee4ce88c0234d2071a161d0c5d35a6c77e05
nojan1/AdventOfCode
/2019/Day1/b.py
451
3.609375
4
import math def calculateFuelForMass(mass): return math.floor(mass / 3) - 2 def calculateTotalFuelForMass(mass): fuel = totalFuel = calculateFuelForMass(mass) while fuel > 0: fuel = calculateFuelForMass(fuel) if fuel > 0: totalFuel += fuel return totalFuel moduleMa...
5aaa6eb03273843428c71adf0d3c05e1edd4983e
nojan1/AdventOfCode
/2020/10/__init__.py
1,483
3.703125
4
from functools import reduce from itertools import combinations def get_jolts(data): jolts = [int(x) for x in data.split("\n")] jolts.append(0) jolts.append(max(jolts) + 3) jolts.sort() return jolts def part1(data): def find_differences(jolts): differences = dict() for i in ra...