blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a6d4b3e3c6da6d5570b837974f91690f656c5cc8
Raziye-ghafoori/Assignment-1
/assignment2.py
104
3.8125
4
print('enter Radius:') r=int(input()) A=r*r*3.14 C=2*r*3.14 print('Area :',A) print('cricumference :',C)
97ee3b0446e2714372dd685162f0bd4c63558c5e
quinlan-alexander/bioinformaticsAlgorithms
/hamming.py
296
3.8125
4
#!/usr/local/bin/python3 from sys import argv def hamming_distance(p,q): if len(p) != len(q): return -1 hamming_count = 0 for i, val in enumerate(p): if p[i] != q[i]: hamming_count += 1 return hamming_count print(hamming_distance(argv[1],argv[2]))
51cd3cb9c15841b4e5477f4c54d639dca0d8ef51
yogeshasok/Python_Assgn_02
/Ass_29c.py
513
4.1875
4
print "using alpha()" msg = "make of the year" print "String ",msg ,"is alphanumeric", msg.isalpha() msg = "makeoftheyear" print "String ",msg ,"is alphanumeric", msg.isalpha() print "Using isdigit(),islower(),isspace()" msg = raw_input("Enter String to check") if(msg.isdigit()): print "Yes it is digit" elif(msg.i...
242a0f2d9b43e9b3442b79f77bb0c77e4457274d
santoshdurgam/DataStructures
/lists.py
917
4.03125
4
# original list test_list = [1, 5, 3, 6, 3, 5, 6, 1] print ("The original list is : " + str(test_list)) print "remove duplicates" from collections import OrderedDict res = list(OrderedDict.fromkeys(test_list)) print ("The new list is : " + str(res)) print "Number of values greater than k in list" k=4 res...
65bb80a92cded9384f0c9ace9d567b892ec49a60
zhuyuedlut/advanced_programming
/chapter1/array_oper.py
1,047
3.65625
4
x = [1, 2, 3, 4] y = [5, 6, 7, 8] print(f'{x} * 2 is: {x * 2}') # print(x + 10) print(f'{x} + {y} = {x + y}') import numpy as np ax = np.array([1, 2, 3, 4]) ay = np.array([5, 6, 7, 8]) print(f'{ax} * 2 = {ax * 2}') print(f'{ax} + 10 = {ax + 10}') print(f'{ax} + {ay} = {ax + ay}') print(f'{ax} * {ay} = {ax * ay}') ...
83e208bf04c9741ec8cdf4e2b27241f7450a7cb4
yanray/leetcode
/medium/0003Longest_Substring_Without_Repeating_Characters/0003Longest_Substring_Without_Repeating_Characters3.py
535
3.59375
4
""" Version: 1.1 Author: Yanrui date: 06/09/2020 """ class Solution: def lengthOfLongestSubstring(self, s: str) -> int: l,r,m,d=0,0,0,set() while r < len(s): if not s[r] in d: d.add(s[r]) m = max(len(d),m) r += 1 else: ...
f9a49e273c6dc9a25333a695c6feeea7deb68d00
BraedenCu/IMSA_CSI
/python/braedenCullenLinks.py
882
4.15625
4
def chain(x): s = str(x) length = 1 while x!=1: if (x%2)==0: x=x/2 else: x=(x*3)+1 length+=1 s = s + "-" + str(int(x)) return s, length def longestChain(start, end): largest = 0 length = 1 for i in range(start, end): num, lengt...
e0cfa4d78289f41b9d7d6c08a908d0aa3b596348
praxidike97/reinforcement-learning
/dungeon_game/Action.py
205
3.546875
4
from enum import Enum class Action(Enum): FORWARD = 0 BACKWARD = 1 @classmethod def reverse(cls, action): return Action.FORWARD if action == Action.BACKWARD else Action.BACKWARD
bf8822405ca5ceffd8b21295c4406d41304f6c11
darkn3rd/script-tut
/gen_scripts/python/d10.input.py
301
3.796875
4
#!/usr/bin/env python import sys # system library for standard input and output sys.stdout.write("Input a character: ") # output prompt w/o newline character = sys.stdin.read(1) # read one character # output results of character captured print "You entered: >>|%c|<<." % character
ab125712ff091d310363d07463c0e8a02800bf39
rajesh-priyadarshi/python-scripts
/orgnishing_list.py
204
4.15625
4
# program to arrange list in ascending order subjects=['Hindi','Math','English'] print ("\n items are in normal order",subjects) subjects.sort() print( "\n items are in ascending order", subjects)
e63ce3518e5475f97eadb143fafcfe04a751b631
vishnuvishnuvishnu/test
/triangle.py
442
4.21875
4
def is_triangle(a,b,c): p = a + b q = b + c r = a + c if (p < c or q < a or r < b): print "You cant form a triangle with these sides" print a print b print c else: print "Can possible to form a triangle with these sides " print a print b print c x= raw_input("Enter the value of the side a ") y= raw...
5a51a8ad501efb5bcb108597724737668b01edd3
MGarrod1/spotiplaylist_explorer
/analytics_functions.py
3,964
3.71875
4
""" Functions used for processing data obtained from the Spotify API using spotipy. Matthew Garrod """ import ast import operator import numpy as np def data_frame_to_dict(df): """ convert pandas data frame to a dictionary Parameters ----------- df : pandas dataframe Returns ----------- data_dict :...
bf2eaba63aa5892cb2924a937e18a301446cb0a5
lcnodc/wttd_exercicios
/w3resource/tuple/tuple.py
3,719
4.53125
5
#!/usr/bin/env python #-*- coding: utf-8 -*- ''' Exercises: 4 5 6 9 12 13 15 16 19 23 ''' ''' 4. Write a Python program to unpack a tuple in several variables. ''' def unpack_tuples(t): a, b, c, *_ = t return a, b, c, _ ''' 5. Write a Python program to add an item in a tuple. ''' def add_tuple_item(t, i)...
4f32a656fe464660cc85129b5a95c21e9de231ae
LokeshKhanchandani/Housing-Price-Predictions
/datasetSplitAndMerge.py
886
3.59375
4
import pandas as pd data=pd.read_csv('total_dataset.csv',converters={"House ID": lambda x: int(x,16)}) labels=pd.read_csv('house_prices.csv',converters={"House ID": lambda x: int(x,16)}) print (data.info()) print('='*40) print (labels.info()) print ('='*40) # using merge function of pandas library to add Golden Pric...
0247a77b0daf34a6b449c7656ac9fcb3c65f8041
Lairion/PythonPatterns
/creational/Factory/car.py
659
3.59375
4
from abc import ABC,abstractmethod class Car(ABC): """docstring for Car""" @abstractmethod # not necessary def get_label(self): pass @abstractmethod # not necessary def get_transmision(self): pass @abstractmethod # not necessary def get_engine_power(self): pas...
9693ec6e7dca677fdad43f448f37f551a1e9ba97
ParkinWu/leetcode
/python/leetcode/143.py
2,190
3.921875
4
# Definition for singly-linked list. from typing import List import math class ListNode(object): def __init__(self, x): self.val = x self.next = None def __str__(self): s = "" current = self s = s + str(current.val) while current.next: current = cur...
58ef90f5c6624977f9cfa3f1bc6a5364ca40138f
Devtlv-classroom/strings-basics-annasolemani
/list.py
1,066
3.96875
4
list= [825, 262, 627, 826, 285, 221, 730, 340, 750, 989, 272, 842, 383, 575, 810] print("There are {} numbers in the list.".format(len(list))) print("The lowest number on the list is {}.".format(min(list))) print("The highest number on the list is {}.".format(max(list))) print("The sum of the list is {}.".format(sum(l...
cc27b821ba21ea92e8b72f566c6eaef52ad12815
silvuple/Machine-Learning-Titanic-Kaggle
/titanic_knn.py
2,289
3.5
4
import pandas as pd import matplotlib.pyplot as plt from sklearn.neighbors import KNeighborsClassifier from sklearn.model_selection import train_test_split, cross_val_score # Read titanic 'train' and 'test' DataFrames from pickle files. train = pd.read_pickle('train.pkl') test = pd.read_pickle('test.pkl') # Create t...
ac21038ea243113d441293910d32fba68204fe21
tony-andreev94/codewars_repo
/06. Convert to Camel Case.py
1,294
4.46875
4
# Complete the method/function so that it converts dash/underscore delimited words into camel casing. # The first word within the output should be capitalized only if the original word was capitalized # (known as Upper Camel Case, also often referred to as Pascal case). # # Examples: # to_camel_case("the-stealth-warrio...
98c6e3fb69ae621f9ab844f886c504e421261811
lxieyang/leetcode
/2016/algorithm/344_Reverse_String/reverseString-20160505.py
599
3.734375
4
# version 1, time limit exceeded class Solution(object): def reverseString(self, s): ret = "" for i in range(len(s)): idx = len(s) - i - 1 ret += s[idx] return ret # version 2 class Solution2(object): def reverseString(self, s): return ''.join(reversed(s...
0dec9246a89ad94d414c2a0b4037a488aac5a4bc
deebika1/guvi
/codeketa/basis/find_the_minimum_number_in_the_list.py
266
3.953125
4
#getting multiple inputs from single line and cast to list list = list(map(int, input("").split())) #sort function # sort is the fuction which is used to sort the elements in the ascending order list.sort() # list[0] index having the least number print(list[0])
435d0cd34b4d4fb22be524e50a2d33846d392a8f
louisprimeau/esclabs
/newterm/lab0/ex_6.py
787
4.0625
4
class stack: def __init__(self): self.stack = [] def push(a): self.stack += [a] def pop(): a = self.stack[len(self.stack)] self.stack = self.stack[:-1] return(a) class queue: def __init__(self): self.queue = [] def enqueue(a): self.stack += [a...
d4adf8ac17797693e40f83d4def1130ccb3fb134
UmbraVenus/owl
/files.py
3,928
3.609375
4
import streamlit as st from newer_script import * from zipfile import ZipFile import os import base64 from pathlib import Path def save_uploadedfile(uploadedfile): with open(os.path.join("/tmp/", uploadedfile.name),"wb") as f: f.write(uploadedfile.getbuffer()) def app(): #my_json = Path("parsed_json.z...
7e6ceb18c4653c71505ee498742e5c4759addb8c
waewoo/la-formation-complete-python
/chp-010_bases-de-donnees/recuperer-des-donnees/app.py
311
3.6875
4
import sqlite3 conn = sqlite3.connect("database.db") c = conn.cursor() c.execute(""" CREATE TABLE IF NOT EXISTS employees ( prenom text, nom text ) """) c.execute("SELECT * FROM employees WHERE") donnees = c.fetchall() print(donnees) premier = c.fetchone() print(premier) conn.commit() conn.close()
23521db648eae32a9abe20871ad23dc0154ffd0c
Anjana97/python
/pythondatastructures/listprograms/binarysearch1.py
319
3.9375
4
#asending order lst=[2,5,1,8,7,6,3,11,10] #sort the listusing sort function # data=sorted(lst) # print(data) #sort without sorting function for i in range(0,len(lst)): for j in range(i+1,len(lst)-1): if (lst[i]>lst[j]): temp=lst[i] lst[i]=lst[j] lst[j]=temp print(lst)
d677c2fbf9780b021ca4748f86b8e30a0bbf06ab
Mohamed-Albakosh/The-Tech-Academy-Python-Coding-Projects
/database_assignment.py
1,138
3.5
4
import sqlite3 conn = sqlite3.connect('db_files.db') with conn: cur = conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS tbl_Files(\ ID INTEGER PRIMARY KEY AUTOINCREMENT,\ file_Name TEXT\ )") conn.commit() conn.close() fileList = ('information.docx','Hello.txt','myImage.png', \...
682b1acf3a9ce9c3949b1304c9132b380c6e57b6
carlaiau/ML-First-Principles-AdaBoost-and-random-forest
/tree.py
10,548
3.5
4
import numpy as np import time import math import random from helpers import draw, class_counts class Question: """ A Question is used to partition a dataset. This class records the column/feature and the value that we are comparing with or "splitting on" """ def __init__( self, feature, value...
2eca2cf9b1357adca48527d7dc05be1c332fc043
elemanjan/python_01
/week11-dict/task7.py
650
3.9375
4
cards = {'Валет': 11, 'Дама': 12, "Король": 13, "Туз": 14} fstPoint = 0 sndPoint = 0 for i in range(3): card = input('1 игрок: Введите имя карты: ') for c in cards: if card.lower() == c.lower(): fstPoint += cards[c] for i in range(3): card = input('2 игрок: Введите имя карты: ') for ...
497699513ad942e1dd9e443266b557f936feef6e
AleksejMoiseev/data-structures
/my_queue.py
1,047
4.15625
4
from linked_list import LinkedList import time class Queue: def __init__(self): self._linked_list = LinkedList() def enqueue(self, data): self._linked_list.append(data=data) def dequeue(self): return self._linked_list.erase(index=0) def front(self): return self._link...
d0cfc3eeeaf28bf5db0e61f7f4d78b21a16ed1d2
gabriellaec/desoft-analise-exercicios
/backup/user_052/ch27_2020_03_26_14_46_45_110882.py
197
3.875
4
tem_duvidas = True while tem_duvidas: aluno= input("Tem dúvidas na disciplina?") if aluno!= "não": print ("Pratique mais") else: tem_duvidas = False print ("Até a próxima")
38e24cb7b89b2198f170136482034dfc86f36c83
NoserQjh/CodingPractice
/JianzhiOffer/05.py
571
3.65625
4
# -*- coding:utf-8 -*- ''' 入队存在一个栈里,取得时候两个栈来回倒,中间把栈2的栈顶弹出就行 ''' class Solution: def __init__(self): self.shed1 = [] self.shed2 = [] def push(self, node): # write code here self.shed1.append(node) def pop(self): # return xx while (len(self.shed1) > 0): ...
79e99b85b1607709f5d5c257464e6989ef9a4eeb
aggy07/Leetcode
/1-100q/72.py
1,441
4.15625
4
''' Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: Insert a character Delete a character Replace a character Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse ->...
d8a3dc8d6854ea022bc5292c79e9b7153b43dac8
GunjanPande/tutions-python3
/REVISION CONTENT/3. Output/1 print.py
927
4.03125
4
def main(): var = "Harshit Jaiswal" var1 = 23 var2 = 23.5 var3 = True var4 = [1,2,3] var5 = (1,2,3) var6 = { 'name' : "Harshit Jaiswal", 'age' : 23 } print( var ) print( var1 ) print( var2 ) print( var3 ) print( var4 ) print( var5 ) print( va...
e7164d64db106741dada4374989eacd506f3126f
dhruv-kun/CodeForces
/Python/Lucky Division.py
299
3.828125
4
#code number = int(input()) if(number%4==0 or number%7==0 or number%44==0 or number%47==0 or number%74==0 or number%77==0 or number%444==0 or number%447==0 or number%474==0 or number%477==0 or number%744==0 or number%747==0 or number%774==0 or number%777==0): print("YES") else: print("NO")
3907671dabd791e9ebd8a7c7f456e9cc349c5d0b
countone/exercism-python
/nth_prime.py
287
3.640625
4
def nth_prime(positive_number): if positive_number<=0: raise ValueError('ValueError') prime_list=[] i=2 while True: for j in range(2,i): if i%j==0: break else: prime_list.append(i) i+=1 if len(prime_list)>=positive_number: break return prime_list[-1]
59eefab4afc5bdc86d0f75a0ec3176218986d607
ericpauley/Alice
/jython-2.1/Lib/alice/linearalgebra.py
848
3.6875
4
import math class Vec3: def __init__( self, x, y, z ): self.x = x self.y = y self.z = z def __add__( self, other ): return Vec3( self.x+other.x, self.y+other.y, self.z+other.z ) def __sub__( self, other ): return Vec3( self.x-other.x, self.y-other.y, self.z-other.z ) def __mul__( self, other ): return ...
6b43e96c6f5bfdbe28f83f5d7a7bdd70925ab724
Andrecast/holbertonschool-higher_level_programming
/0x11-python-network_1/1-hbtn_header.py
364
3.671875
4
#!/usr/bin/python3 """ Python script that takes in a URL, sends a request to the URL and displays the value of the X-Request-Id variable found in the header of the response """ import urllib.request import sys if __name__ == "__main__": with urllib.request.urlopen(sys.argv[1]) as url: s = url.getheader('X...
6e76651e004b9dc934e16b1f5dfb98d50d75dc40
manutdmohit/mypythonexamples
/pythonexamples/listcomprehnesion3.py
133
3.5625
4
s='the quick brown fox jumps over the lazy dog' words=s.split() print(words) l=[[word.upper(),len(word)] for word in words] print(l)
5186abcf0e31f70dfb4676be7fca4e2045888fa1
TianhengZhao/LeetCode
/[102]二叉树的层序遍历.py
1,261
3.578125
4
# 给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。 # # # # 示例: # 二叉树:[3,9,20,null,null,15,7], # # 3 # / \ # 9 20 # / \ # 15 7 # # # 返回其层次遍历结果: # # [ # [3], # [9,20], # [15,7] # ] # # Related Topics 树 广度优先搜索 # leetcode submit region begin(Prohibit modification and deletion) ...
99381c919688a953dee75835f56d4f9f4c5d1da0
seton-hill-university/weekly-log-2-jpg333
/main.py
16,345
4.34375
4
# Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. # imports import math import random import sys # introductory message print("This program will generate a random array based on parameters you choose." ...
67c8c45e404a022a6a316315cdc3d3db2328ad33
nityamall/Python_Projects
/workspace/HelloWorld/Series/series_8(tribo).py
175
3.546875
4
n=input("ENTER THE NO. OF TERMS") n=int(n) f=0 s=1 l=2 k=0 print("0 1 2") for i in range (4,n+1): k=f+s+l print("%d"%k,end=" ") f=s s=l l=k
09af4a3cd5d0c75278ec33ce17c6257063786ae3
AsimkSatti/DataStructures
/LinkedList_ListShuffle.py
4,922
3.5
4
""" Asim Satti list shuffle Linkedlist """ class DoublyLinkedList: class _Node: __slots__ = 'data', 'next', 'prior' def __init__(self, data=None, next=None, prior=None): """ Field names as they are not being treated as private. """ ...
6db448a05719d517fbfe8eb72d183012f7c9c68c
shdb1/PythonWorks
/com/shadab/python/challenges/diagonal-difference/solution.py
782
3.8125
4
#!/bin/python3 import math import os import random import re import sys # Complete the diagonalDifference function below. def diagonalDifference(count,a): diagonal1=0; diagonal2=0; for n in range(0,count): diagonal1=diagonal1+a[n][n]; # print(n,count,count-n-1); diagonal2=diagonal2+...
97c91c4e142b381c65b81740566e475e18ad2b8c
kuzukawakonayuki/python_scripts
/script/py/暴風域判定.py
504
3.5625
4
#coding: UTF-8 #式:r1=<(x-xc)^2+(y-yc)^2=<r2 list1 = raw_input() list2 = list1.split(" ") xc = int(list2[0]) yc = int(list2[1]) r1 = int(list2[2]) r2 = int(list2[3]) ans1 = r1**2 ans2 = r2**2 n = int(raw_input()) roop = 0 while n > roop: roop += 1 list3 = raw_input() list4 = list3.split(" ") ...
4de3b2089b7aa257cbe2aaf3bda4513dfe5d2620
sabrinachen321/LeetCode
/python/0762-countPrimeSetBits.py
553
3.625
4
class Solution(object): def countBit(self, n): count = 0 while n != 0: count = count + 1 n = n & (n - 1) return count def isPrimeNumber(self, n): primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31] return n in primes def countPrimeSetBits(self, L, R): ...
6fc43bb973055f629941ea3f69f8af56f1f1ece4
Ajit171098/python-lab
/3(b).py
765
4.0625
4
import random import string t=1; def password_generator(password_length): password_characters=string.ascii_uppercase+string.ascii_lowercase+string.digits+string.punctuation return "".join(random.choice(password_characters)for i in range(password_length)) while t: print("Do u want to generate passwo...
13b4ccca4f700a1ed1c7a041fa9f9a9322732e6d
mengnan1994/Surrender-to-Reality
/py/0074_search_a_2d_matrix.py
1,501
3.90625
4
""" Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. Example 1: Input: matrix = [ [1, 3, 5, 7], [10, 11, 1...
32add6d0347629349101ee69aa16fb2d410cc394
stoneeve415/LintCode
/_39_recover_rotated_sorted_array.py
1,982
3.65625
4
""" @title: 39. 恢复旋转有序矩阵 @author: evestone """ ''' 方法一 ''' def search_min1(nums): left, right = 0, len(nums) - 1 while left + 1 < right: mid = (left + right) // 2 if nums[mid] < nums[right]: right = mid elif nums[mid] == nums[right]: right = right - 1 e...
e05031fbac742fd98cefa42545af96d2f25d1eb9
nikuzuki/I111_Python_samples
/TH_3/kadai4.py
472
3.859375
4
# 課題4 # 課題1で使用したバブルソートを利用する data = [37, 12, 25, 9, 87, 33, 65, 3, 29] # バブルソートを行う関数 def bubble_sort(data): # バブルソートで昇順に並べる for i in range(len(data)-1, 0 , -1): for j in range(i): if data[j] > data[j+1]: tmp = data[j+1] data[j+1] = data[j] data...
aa678496a50c18dd72a36b57e6902d0ce89f9366
alimouss/snikeGame
/farisa.py
1,212
3.84375
4
#!/usr/bin/python3 from tkinter import * from random import randrange class Farisa(object): def __init__(self,can,posX=0,posY=0,coul="red",infolist=[]): self.info = infolist self.can=can ## Display screen (canvas) self.coul=coul ## color of Farisa self.xf...
bf760eaf3bd409971a3470edd30390e2b8bb79e7
2099454967/python_wang
/09day/3.钱.py
89
3.75
4
a = 1 while a <= 10: b = 1 while b <= a: print('$',end ='') b+=1 print('') a+=1
43851b5550e3ec1a7bcae97ebb62aa2b743dc5b9
amanhemani/recursiveStaircase
/recursiveStaircase.py
1,086
4.59375
5
# This program tells the user how many ways they walk up a staircase of any size given they take steps in 1, 2, or 3 step incrememnts def main(): num_steps = input("How many steps are on your staircase? ") num_steps = int(num_steps) print "There are", countPaths(num_steps), "ways to walk up", num_steps, "s...
c417b132c0ff4ab1c076c2e8cf5797645371a278
FirstPlaygroundAndThenIcecream/MyEasyID
/databaseOperation.py
1,980
4.125
4
import sqlite3 from sqlite3 import Error def create_connection(db_file): """ create a database connection to a SQLite database """ conn = None try: conn = sqlite3.connect(db_file) return conn except Error as e: print(e) return conn def create_table(conn, create_table_sql):...
c8b08aa8be3add642dd6cbdba14145832287aec8
Jcnovoa1/tallerIntegradorPythonUNLZ
/GuiaEjercicios/Ejercicio2.5.py
762
3.984375
4
""" Ejercicio 2.5 Escribir un programa que llene una lista con 50 números al azar y muestre por pantalla el número (o números) que más se repite. """ #Para obtener números al azar import random #Lista numerosAzar = [] numerosRepetidos = [] #Una manera de hacerlo # numerosAzar = [random.randint(1,50) for _ ...
7203954fc630eaf8c97b82d87b562255b9d4bd8e
ketycossey/htx-immersive-08-2019
/01-week/4-friday/labs/Python_list/problem8_list.py
245
3.6875
4
x = [ 2, 3, 4 ] y = [2, 3, 4 ] z = [0, 0, 0] #z.append ( x[0] * y[0]) #z.append (x[1] * y[1]) #z.append (x[2] * y[2]) #print (z) for i in range(len(x)) : for j in range(len(x[0])): z[i][j] = x[i][j] * y[i][j] for r in z: print(r)
512c0d5457b78d7965bd5ecb677dc8a9d7fac24e
apurvahegde2000/verbose-robot
/Happy-Number.py
1,109
3.859375
4
''' Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycl...
9ac71159915e689b8f2d985cc6523f5e0bbd074b
fbkch/Scripts
/Python/keygen
482
3.78125
4
#!/usr/bin/env python3 import random import sys def checkkey(key): key_sum = 0 for c in key: key_sum += ord(c) sys.stdout.write("{0:3} | {1} \r".format(key_sum, key)) sys.stdout.flush() return key_sum if __name__ == "__main__": key = "" while True: key += random.choic...
4dfaaebc279001efe008277adc462b2ebb6f2758
pvnieo/project-euler-solutions
/python/51.py
1,218
3.828125
4
def sieve(n): is_prime = [True]*n is_prime[0] = False is_prime[1] = False # even numbers except 2 have been eliminated for i in range(3, int(n**0.5+1), 2): index = i*2 while index < n: is_prime[index] = False index = index+i prime = [2] for i in range(...
65a545c90dae94d50db278e57e8a7a90b8995aae
xtofl/checkio
/home/building_base.py
1,183
3.75
4
class Building(object): def __init__(self, south, west, width_WE, width_NS, height=10): self.area = lambda: width_WE * width_NS self.volume = lambda: width_WE * width_NS * height self.corners = lambda:\ { "north-west": [south + width_NS, west], "no...
1fd8aabc336d191698f2ea9264f9747d802006e9
Anna3Nguyen/ATBSW-Python
/Chapter 4/referenceS.py
961
4.125
4
# spam = 42 # cheese = spam # spam = 100 # print(spam) # print(cheese) # integers are immutable # spam = [0,1,2,3,4,5] # cheese = spam # The reference is being copied, not the list # cheese[1] = 'Hello!' # This changes the list value # print(spam) # print(cheese) # The cheese variable refers to the same list # id() o...
3b978c8b43c13bfcaee82febbe998a5252bef838
hsinhoyeh/leecode
/minimum-depth-of-binary-tree/solution.py
854
3.75
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def minDepth(self, root): """ :type root: TreeNode :rtype: int """ if not root: ...
24e30ca98fd890190fe463138e65172faf84ca41
yoviagustian/FP_ProgJar2020_E1
/hur/bingo/game.py
2,270
3.53125
4
class Game: def __init__(self, id): self.p1Went = False self.p2Went = False self.p3Went = False self.p4Went = False self.p5Went = False self.ready = False self.id = id self.moves = [None, None, None, None, None] self.p1Table = False sel...
c3d8c841e9c0cf998068a3861a642cc995b386a3
ThomasTheDane/AlgorithmFun
/stanfordAlgorithms1/week1Lecture.py
1,085
3.53125
4
def multiplyMatrix(X, Y): print X, Y if(len(X) == 1): print 'root root bitches' return X * Y if(len(X) == 2): print 'almost root' print X, Y return X[0][0] * Y[0][0] X1 = [X[:len(X)/2][0][:len(X)/2], X[:len(X)/2][1][:len(X)/2]] X2 = [X[:len(X)/2][0][len(X)/2:], X[:len(X)/2][1][len(X)/2:]] X3 = [X[len(X...
b635fa00baef73d235d1a1512d14f9fb9403271a
juanjoneri/Bazaar
/Interview/Practice/CTCI/Moderate/smallest_difference.py
955
3.96875
4
""" Given two arrays of integers, copute the pair of values with the smallest absolute difference """ import sys def closest_pair(left, right): left, right = iter(sorted(left)), iter(sorted(right)) current_left, current_right = next(left), next(right) smallest_dif = sys.maxsize while any(left) or any...
0500d8b09273eaae6cda4791b786ac62b88cc2d0
do-ryan/athena
/LeetCode/easy/58_Length_of_last_word.py
993
4.0625
4
""" Given a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only. Example 1: Input: s = "Hello World" Output: 5 Explanation: The last word is "World" with length 5. Example 2: Input: s = " fly me to t...
2a2b8865e27029d8a9dd4e764f4100816d8447cc
BStob/Python-programs
/Lab 9/lab9ex1.py
761
4.1875
4
#Ben Stobie #16/04/21 class Student: def __init__(self, fname, lname): self.first_name = fname self.last_name = lname def main(): studentName1 = Student(input("Please enter your first name: "), input("Please enter your last name: ")) studentName2 = Student(input("Please enter your partn...
7a8fca7afb3cafd9c3b024f7f1045287291a3bd4
Gelmes/Peak-Demand-Display
/screen.py
3,270
3.59375
4
""" Author: Marco Rubio Date Created: 9/10/2017 Description: This is a class obeject meant to make it easier fo r me to create renders using pygame thus reducing coding time. """ import pygame, math, random class Screen: def __init__(self, width=1280, height=800): pygame.init() s...
de41144b99ac42bd5f21ec5dac5a689235561cfd
Mozuha/CS-I-Python
/a.py
2,918
3.609375
4
# State Capitals Game import random def main(): state_capitals = {"Washington": "Olympia", "Oregon": "Salem", \ "California": "Sacramento", "Ohio": "Columbus", \ "Nebraska": "Lincoln", "Colorado": "Denver", \ "Michigan": "Lansing", "Massachusetts...
0102fd4cae6363683ef9452768155f8622829aff
mcleu/ProjectEuler
/P024.py
739
4.0625
4
# -*- coding: utf-8 -*- #============================================================================== # A permutation is an ordered arrangement of objects. For example, # 3124 is one possible permutation of the digits 1, 2, 3 and 4. # If all of the permutations are listed numerically or alphabetically, # we call it l...
59a1aa28c519b74e497bd1d43b1934f7ca9697bd
JustinFlames12/Green-Glass-Door-Python
/level1.py
662
3.6875
4
def play(): print('Example: A dell can go through, but an acer cannot go through.') print('Recognize the pattern? Type a word that can go through the Green Glass Door.') answer = input('Answer: ').lower() if(DoubleLetters(answer)): print('Correct! ' + answer + ' can go through the door.\n') ...
d932ab3a6082d506edb9406ccc345f288687af55
CSamuelLents/data-structures-and-algorithms
/duplicate_number.py
663
4.0625
4
""" Given an array of length = n containing integers from 0 to n - 2, with each number appearing in the array exactly once, except for a single duplicate, find and return the duplicate number The time complexity for this problem is O(n), and the space-complexity is O(1). """ import functools def duplicate_number(arr...
1f83f89d1a0108eb563e83dedddf898108e176f6
nsh92/Bigdata-and-Machine-Learning-Education-at-ITWILL
/3_Python/chap09_Database/lecture01_sqlite/step01_sqlite_test.py
1,823
3.5625
4
''' sqlite3 - 내장형 DBMS : 기기 내부에서만 사용 가능 - 외부 접근 허용 안됨 ''' import sqlite3 print(sqlite3.version_info) # (2, 6, 0) print(sqlite3.sqlite_version_info) # (3, 31, 1) try: # 1. database 생성 conn = sqlite3.connect("./chap09_database/data/sqlite.db") # 해당 경로에 db를 만들고, db를 연동할 수 있는 객체를 만든다 # sql문 실행 객체 curs...
dbd240660dd2368d5395819f3ffb5eb0f5ae9934
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/hmpnas001/question2.py
476
3.921875
4
"""program to count pairs nasonkwe hampwaye 2014-05-08""" message=input("Enter a message:\n") count=0 def friendlyletter(message): #base case if len(message)<=1: return 0 #recursive step else: if message[0]==message[1]: return (count + 1) + friendlyletter(message[2:]) ...
0b94d12d26fc7058d63e55a7cfd8a90bf82586fc
MediocreCoder/Learn-Python-The-Hard-Way-Lessons
/ex17.py
975
3.59375
4
from sys import argv from os.path import exists # Now we have another variable added $python ex17.py ex17.py ex17_copy.txt script, from_file, to_file = argv print "Copying from %s to %s" % (from_file, to_file) # we could do these two on one line too, how? input = open(from_file) indata = input.read() print "The in...
86e4765512946a5c65d0fb43ddefd1792fcea1b9
RifatJafrin/House-Price-prediction
/HousePricePrediction.py
11,553
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 17 17:29:37 2019 @author: Rifat Problem Statement: House Prices: Predict the final price of each home Data Source: https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data """ #======================import l...
19f6674524da36fc7c4937374222309c194bcaa3
kyoungmingo/Rangenet_customize
/lidar-bonnetal/train/tasks/semantic/rangenet/test.py
84
3.640625
4
a = 1 b = [1,2,3,4,5] def add(a,b): return a +b for i in b: a = add(a,i)
e0c2fbf0c38b1bebf4a5ca7c4a29505957c5b66c
chenlunyiran/python
/src/com/zimu/python/clazz/Student.py
652
4.0625
4
# class后面紧接着是类名,(object)表示该类是从哪个类继承下来的 class Student(object): # 注意:特殊方法“init”前后有两个下划线!!! def __init__(self, name, score): # 通过定义一个特殊的__init__方法,在创建实例的时候,就把name,score等属性绑上去 self.name = name self.score = score stu = Student("Jack",90) # self不需要传,Python解释器自己会把实例变量传进去 print(stu.name) print(s...
20c0c362abf7ec55b8f168d84a73d212d7498c91
ultranaut/euler
/python/016_power_digit_sum.py
914
4.1875
4
#!/usr/bin/env python3 """ Problem 16: Power digit sum 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ # It's trivial in Python... def easy_sum(base, exponent): num = base ** exponent _sum = 0 while num > 0: _sum += num % ...
a45c9f86c5b9a792bf9b1ac4c605d9c575107140
danhenriquesc/hackerrank
/algorithms/strings/strong_password.py
736
3.8125
4
#!/bin/python3 def minimumNumber(n, password): numbers = "0123456789" lower_case = "abcdefghijklmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" special_characters = "!@#$%^&*()-+" digit = 1 lower = 1 upper = 1 special = 1 for c in password: if c in numbers: ...
2cbeaf0c7f40e1b6e7ab2c21bbaed6bb71bf500f
rahul-1510/Machine-Learning
/MLE_Estimations Of Distributions/MLE.py
2,819
3.640625
4
import numpy as np import matplotlib.pyplot as plt from scipy.misc import factorial import scipy.stats #Maximum Likelihood estimation for Binomial Distribution def bino(n,p): #Function will print p b1 = np.random.binomial(n,p,1000) bins = np.linspace(-30,30,100) #plt.hist(b1, bins,label='Before Perfoming MLE') ...
a5651f33555735487364c2c2e7bae214fcb1ceab
Aasthaengg/IBMdataset
/Python_codes/p02723/s742844472.py
141
3.515625
4
# -*- coding: utf-8 -*- S = list(input()) t=0 if S[2]==S[3]: if S[4]==S[5]: print("Yes") t=1 if t==0: print("No")
0512de279f6ffd74686404bc733ada94cca1bc10
zdhughes/Python
/Gee Parser/parser.py
10,413
3.65625
4
#Recursive descent parser import re, sys, string debug = False dict = { } tokens = [ ] # Expression class and its subclasses class Expression( object ): def __str__(self): return "" class BinaryExpr( Expression ): def __init__(self, op, left, right): self.op = op self.left = left self.right = right ...
092bb8668e776ead01edeee63bb7bdefd7c40136
Keonhong/IT_Education_Center
/Jumptopy/Jump_to_python/Chapter6/lambda.py
456
3.90625
4
def Add(a,b): return a + b def Pow(a,b): tmp = 1 for i in range(b): tmp = tmp * a return tmp print(Add(10,30)) print(Pow(2,3)) print(Add(3,5)) print(Pow(2,10)) print((lambda a,b: a+b)(3,10)) print((lambda a,b: a+b)(100,300)) f1 = lambda a,b : a+b print(f1(30,50)) print((lambda a,b: a**b)(2,3))...
9243c3aeac5ef5d62bcc8805592ed6e6fd6df39b
StaroKep/Python
/Простые задачи/p8.py
539
4.15625
4
# Сформировать массив длинны n из элементов арифметической прогрессии # с заданным первым элементом x и разностью d. # Для проверки a) n = 10, x = 3, d = 3; b) n = 20, x = 105, d = -5; # Надо использовать: "".join(), str(), append(), range() def prog(n, x, d): result = [] for i in range(n): result.ap...
fe0dc7f683b7d25d36cdec06237ac240f6e82f7e
fawwadhussaini/Python_AI_SSUET
/chapter_8_functions.py
4,318
3.96875
4
# 8.1 def display_message (): print ('we are learning about functions') display_message() print ('**********************************') # 8.2 def favourite_book(title): print ('One of my favourite book is ', title) favourite_book('Alice in wonderland') print ('**********************************') # 8.3 def ...
c7d4678157f48d4696bbf406af40d8a2c0ce075b
vinodhmj/projects
/python/sort.py
296
3.96875
4
def insertion_sort(num_list): #program to sort an array list_size=size(num_list) return def main(): num_list = [2,5,7,3,1,8,2,9] insertion_sort(num_list); # This is the standard boilerplate that calls the main() function. if __name__ == '__main__': main()
1f6243ad6ffe15276d72d7be7f03424d54f11758
sandinocoelho/URI-Online-Judge
/1061.py
947
3.6875
4
from datetime import datetime entryDayBegin = input().split() entryHourBegin = input().split(" : ") entryDayEnd = input().split() entryHourEnd = input().split(" : ") dateBegin = datetime(2017, 4, int(entryDayBegin[1]), int(entryHourBegin[0]), int(entryHourBegin[1]), int(entryHourBegin[2])) dateEnd = datetime(2017, 4,...
86b1b6e89e3216f57f834922a30e522bba2bd25b
Sunny199336/my_project
/Text/demo06.py
357
3.78125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- L = [2,5,80,3] #升序排列 count1 = 0 count2 = 0 for i in range(len(L)-1): if L[i]<L[i+1]: count1 += 1 elif L[i]>L[i+1]: count2 +=1 else: count1 +=1 count2 +=1 if count1 == len(L)-1: print "UP" elif count2 == len(L)-1: print "...
b91d57620a56cae8bfe9ab83dba8fcfa858dacb1
KickItAndCode/Algorithms
/DynamicProgramming/knapsack2.py
859
3.9375
4
def knapsack_recursive(profits, weights, capacity, currentIndex): # base checks if capacity <= 0 or currentIndex >= len(profits): return 0 # recursive call after choosing the element at the currentIndex # if the weight of the element at currentIndex exceeds the capacity, we shouldn't process ...
ca95f45954d16ed4b8d5b336821fe39b92d0fe79
erlichdominik/python-programming
/data_science/courses/data_science_from_beginning_oreilly/chapter1.py
2,899
3.515625
4
from collections import Counter from collections import defaultdict users = [ {"id": 0, "name": "Hero"}, {"id": 1, "name": "Dunn"}, {"id": 2, "name": "Sue"}, {"id": 3, "name": "Chi"}, {"id": 4, "name": "Thor"}, {"id": 5, "name": "Clive"}, {"id": 6, "name": "Hicks"}, {"id": 7, "name": "D...
f0f6b907f8a3a3b7dde70be495a8016562413878
zhangguoqinggg/python_web_django
/biji/装饰器.py
469
3.515625
4
#既不想 直接修改原来的函数,也不想修改函数的调用方式,还要增加新功能 #https://www.cnblogs.com/liwenzhou/p/9878885.html def a(func): def b(): print('加点水') func() return b #相当于把被装饰的函数当成参数传给a,然后把返回值再赋值给被装饰的函数名 #create_people = a(create_people) @a def create_people(): print('女娲真厉害,一口气造一个人') create_people()
54c0c9f0d2d8fc51f617ca6d009ca733fc186fb3
YinongLong/Data-Structures-and-Algorithm-Analysis
/leetcode/array/exercise_31.py
1,990
3.5625
4
# -*- coding: utf-8 -*- from __future__ import print_function class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ # 也就是说交换数字序列中的数字,使得数字序列成为紧接着下一个大于当前数字序列的序列 len_num...
aaab3915d623f6f2b72e164d8ce391a3b96ba7d8
jlyoung/hackerrank
/warmups/solvemesecond/solvemesecond.py
446
3.578125
4
from sys import stdin def main(): lines = list() for line in stdin: lines.append(line) num_of_lines = int(lines[0]) for line in lines[1:num_of_lines+1]: string_operands = line.split(' ') int_operands = list() for operand in string_operands: int_operands.append(int(operand)) print sum(int_operands) de...
a7fa89e8368bd813c9551c713bb53edc19970a92
Voprzybyo/Python
/Calculations_And_Algorithms/Determinant_of_the_matrix/DeterminantOfMatrix.py
1,650
3.859375
4
#! /usr/bin/env python import random import numpy as np import math # Checking if algorithm works correctly def check_correctness(detA, detB): detB=math.floor(detB+0.49999999) if detA == detB: print("Algorithm is working fine. Determinant of given matrix is: ", detB) else: print("Determi...
cc58cd0c2d5344dec52a39484ee2c78d2b0f13c5
StephannySena/ExerciciosPython
/ex029.py
243
3.734375
4
velocidade = float(input('Insira a velocidade do veículo: ')) if velocidade > 80: multa = (velocidade - 80) * 7.00 print('Você foi multado por passar {}Km/h acima do limite. A multa a pagar é R$ {:.2f}'.format(velocidade-80, multa))
571717ee328003041381a8410dae32b2f39e4fb7
ejkaplan/isola_python
/isola_game.py
6,569
3.578125
4
''' Created on Nov 9, 2017 @author: eliotkaplan ''' from multiprocessing.pool import ThreadPool import sys, os, time, datetime # Disable def block_print(): sys.stdout = open(os.devnull, 'w') # Restore def enable_print(): sys.stdout = sys.__stdout__ class isola_game(object): def __init__(self, p1, ...
4dec61c465fc7be99914f0b3d4a820981f3d87a9
nLevin13/PingPongFinder
/soundsim/intersections.py
3,099
4
4
import math import numpy as np import matplotlib.pyplot as plt # gets intersections of 2 circles if there are any, otherwise returns None # see here: # http://paulbourke.net/geometry/circlesphere/ # https://stackoverflow.com/questions/55816902/finding-the-intersection-of-two-circles def get_intersections(p0, r0, p1, ...
e829538d2158546c2701b3815d26de8dcd395cd7
vlaksi/OsnovneRacunarstva-BMI
/Predavanja/06 Grananje/Predavanja/Primeri/code06/PR/max.py
397
4.0625
4
def max1(x1,x2,x3): if x1>x2 and x1>x3: print(x1) elif x2>x1 and x2>x3: print(x2) else: print(x3) def max2(x1,x2,x3): if x1>x2: if x1>x3: print(x1) else: print(x3) else: if x2>x3: print(x2) else: print(x3) def max3(x1,x2,x3): m=x1 if(x2>m): m=x2 if(x3>m): m=x3 print(m) def main...
7e605be948dc540b339f981cbd28ee9c4fc3af20
hloliveira/Python_Coursera
/paridade.py
256
3.984375
4
""" Par ou Ímpar Código que recebe um número inteiro na entrada e imprime PAR - quando o número for par ou ÍMPAR - quando o número for ímpar. """ x = int(input("Entre com um número:")) if ((x%2) == 0): print("par") else: print("ímpar")
b7501730ef5358f9012ebbeb6ff4cb1fe0d6d78d
TianrunCheng/LeetcodeSubmissions
/check-if-n-and-its-double-exist/Wrong Answer/6-23-2021, 3:24:41 PM/Solution.py
360
3.765625
4
// https://leetcode.com/problems/check-if-n-and-its-double-exist class Solution: def checkIfExist(self, arr: List[int]) -> bool: dic = {} for num in arr: if num not in dic: dic[num] = 0 for num in arr: tar = num * 2 if tar in dic: ...