blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b0d8ab9678fb8de1c6d9b0563f38bef122dca31e
brittneyexline/euler
/problem12.py
1,194
3.921875
4
#!/usr/local/bin/python #coding: utf8 import math # The sequence of triangle numbers is generated by adding the natural numbers. # So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # Let us list the factors of the first seven tr...
a80e9f698c30765bce2f0a1179d4786a33add3c5
brittneyexline/euler
/problem10.py
739
3.78125
4
#!/usr/local/bin/python #coding: utf8 import math # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # Find the sum of all the primes below two million. MAX_PRIME = 2000000 prime_cache = {2:1, 3:1, 5:1, 7:1, 11:1, 13:1, 17:1, 19:1} prime_index = 8 not_prime_cache = {1:1} def is_prime (i): if (i in prime_cache)...
40108a8fa88fd65cb6fdbb98dc0ce29b4336fd25
brittneyexline/euler
/problem25.py
860
4.21875
4
#!/usr/local/bin/python #coding: utf8 import math # The Fibonacci sequence is defined by the recurrence relation: # Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. # Hence the first 12 terms will be: # F1 = 1 # F2 = 1 # F3 = 2 # F4 = 3 # F5 = 5 # F6 = 8 # F7 = 13 # F8 = 21 # F9 = 34 # F10 = 55 # F11 = 89 # F12 = 144 # The ...
c86d12aabaf5bdd2cf82660fcde65bea7ff0c409
xingmin860818/My_Res
/checking_code.py
1,231
3.8125
4
#!/usr/bin/env python #-*-coding:utf8-*- import random import string def gener_list(): #生成一个包含大写,小写字母和数字的列表 L = [] #将ASCII码转换为对应字母和符号 chars = map(chr,range(65,123)) for words in chars: #通过isalpha函数过滤掉非字母字符 if words.isalpha(): ...
bf966aeb42dadb8e971b91a758894db04fb4bc38
NandaGopal56/Programming
/PROGRAMMING/LIT-Python/set operation.py
260
3.9375
4
s=set([1,2,3,4,5]) s1=([4,5,6,7]) s.union(s1) print(s) print(s.difference(s1)) #here s in not updated print(s) s.difference_update(s1) #here s is updated with the operation value print(s) s=set([1,2,3,4,5]) s1=([4,5,6,7])
25c98f57e6ea7b2c43d5223f65c628aa7e82213f
NandaGopal56/Programming
/PROGRAMMING/python practice/list deep copy.py
153
3.640625
4
x=[11,22,33,44,55] y=x y[0]=1111 print(x) print(y) from copy import deepcopy m=[1,2,3,4,5] n=deepcopy(m) n[0]=100 print(m) print(n)
67a5f452c1c081643b68051e85d2f1a3f5786bea
NandaGopal56/Programming
/PROGRAMMING/python practice/string-22.py
698
4
4
""" Write a Python program to remove a newline in Python """ str="""In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which ea...
cd99b97602e1f280c4ff28ca50332c196d31fcc8
NandaGopal56/Programming
/PROGRAMMING/LIT-Python/sum of two numbers-2.py
98
3.890625
4
a=eval(input("enter value of a :")) b=eval(input("enter value of b :")) print(a,"+",b,"=",a+b)
230fe4850ffe3aceb6c31b0871dc0762e6cec574
NandaGopal56/Programming
/PROGRAMMING/LIT-Python/student with second lowest mark.py
871
3.859375
4
if __name__ == '__main__': d={} list1=[] list2=[] list3=[] for _ in range(int(input())): name = input() x = float(input()) d.update({name:x}) for i in d: list1.append(d[i]) x=len(list1) for i in range(x): for j in range(i+1,x): #list1[i], list1...
9e5de8be61b68ab064263ce32449081f79dbde90
NandaGopal56/Programming
/PROGRAMMING/python practice/feb-25 assesment.py
702
3.90625
4
def check_prime(n): counter=0 if n<=1: return 0 else: for i in range(1,n+1): if n%i==0: counter+=1 if counter == 2: return 1 else: return -1 def composite_prime_list(l): prime = [] compsite = [] ...
ba31b5a37250b1e1e45958701ed5a7ef08c14d46
NandaGopal56/Programming
/PROGRAMMING/python practice/example-2.py
594
3.609375
4
class stock: def __init__(self,name,type,choice): self.name=name self.type=type self.price=price def check(self,ch): self.ch=ch if self.type==ch and self.price>=500: print(self.name) if __name__=='__main__': l=[] for i in range(int(input('...
5572b3863b76fb53bc8d9d06fd9b5ea11cbbab07
NandaGopal56/Programming
/PROGRAMMING/python practice/validating phone numbers.py
652
3.578125
4
def check(l): check = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'] for no in l: count = 0 if len(no) == 10: if no[0] == '7' or no[0] == '8' or no[0] == '9': for digit in no: if digit in check: count += 1 ...
74e1de5dcecde6339ac9078f0408153e36998579
NandaGopal56/Programming
/PROGRAMMING/python practice/list checking.py
740
3.9375
4
''' Return the sum of the numbers in the array, returning 0 for an empty array. Except the number 13 is very unlucky, so it does not count and numbers that come immediately after a 13 also do not count ''' def sum13(nums): if len(nums)>=1: sum=0 i=0 while (i<=len(nums)-1): ...
d5fd4330c095a2fe820d2dbbb3b6403a24e93616
NandaGopal56/Programming
/Q2-Find-Pairs.py
662
4.1875
4
#Write a prgram to find all pairs of integers whose sum is equal to a given number ''' #Possible questions 1. Does array contain only positive numbers ? 2. What if the same pair repeats twice, should we print it two times 3. Do we need to print only distinct pairs ? does (3,3) is a valid pair given a sum of 6 ...
d59abfffb3b277f4a47a0cc1e11732a4f58146d2
NandaGopal56/Programming
/RecursiveRnage-recursion.py
187
3.828125
4
def RecursiveRnage(n): if n == 1: return 1 else: return n + RecursiveRnage(n-1) print(RecursiveRnage(6)) print(RecursiveRnage(4)) print(RecursiveRnage(5))
7fd15241b65f365cbfa76b52ac4acbd3cbcfc329
NandaGopal56/Programming
/PROGRAMMING/python practice/str expression evaluation having '%' operation.py
1,306
3.515625
4
operator='56%' operator=operator.split('%') symbol=['+','-','*','/'] operator_list=[] for expression in operator: if expression != '': print(expression) x='' if len(expression) > 1: for i in range(len(expression)-1,-1,-1): if expression[i] not in s...
2a8dd65d5ed7dd4c2f3c9a80d5aec079e62dbef6
NandaGopal56/Programming
/PROGRAMMING/python practice/assesment test-1 1st.py
611
3.609375
4
class emp: def __init__(self,basic,hra,ita): self.basic=basic self.hra=hra self.ita=ita class emp2: def __init__(self): self.a=10 def highestpf(self,l): temp=[] for i in l: temp.append(int(0.12*i.basic)) return max(temp) if __n...
07ec6cf1b402c645f77bb3c48dfd6a1127e3856b
NandaGopal56/Programming
/PROGRAMMING/LIT-Python/call by reference 2.py
459
3.671875
4
def main(): actual_parameter=[11,22,33] print("actual_parameter",id(actual_parameter),actual_parameter) bbsr(actual_parameter) print(actual_parameter,id(actual_parameter)) def bbsr(formal_parameter): print("formal parameter",id(formal_parameter),formal_parameter) formal_parameter.appe...
294480b8bf802bc6dee9f671f8303dd9b3b080c7
NandaGopal56/Programming
/PROGRAMMING/python practice/string-5.py
306
3.8125
4
""" Write a Python program to get a single string from two given strings, separated by a space and swap the first two characters of each string. Go to the editor Sample String : 'abc', 'xyz' Expected Result : 'xyc abz' """ s1='abc' s2='xyz' n1=s2[:2]+s1[2:] n2=s1[:2]+s2[2:] print(n1+' '+n2)
604edbdbf501ca5c773e1a3d65ead2ada7b6aeae
NandaGopal56/Programming
/PROGRAMMING/python practice/bracket-balancing.py
935
3.8125
4
str = "{}]()[]" print("string is: ",str) l = [] opening = ['{', '[', '('] closing = ['}', ']', ')'] flag = True for i in str: if i in opening or i in closing: if i in opening: l.append(i) elif i in closing: if len(l) >= 1: last = l[le...
ca50d11dd2404a77b34ed0379e18f738e3aeee62
NandaGopal56/Programming
/Q5-Rotate-matrix-by-90degree.py
909
3.984375
4
#Rotate a given matrix by 90 degree import numpy as np myArray1 = np.array([ [1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16] ]) myArray2 = np.array([ [1,2,3], [4,5,6], [7,8,9] ]) def rotateMatrix(matrix): print(matrix, end='\n\n') n = len(matrix) for layer in range(n//2): first = ...
2f77dbc7f22d990e4745c93c704312c5f1a95960
scotthosking/ML_Examples
/Linear_Regression/single_var.py
6,323
4.09375
4
''' Linear Regression with one variable using Gradient Descent Steps: 1/ Calculate the Hypothesis: h = X * theta 2/ Calculate the error: err = h - y 3/ Calculate the gradient: (X' * err)/ m 4/ Update the fitting parameters: theta = theta - alpha * gradient where: h is the hypothe...
93612c4313d34f4fe55ab3b95c4d0ae243389e27
kvin15/feature_engineering_project
/q02_outlier_removal/build.py
654
3.5
4
# Default imports import pandas as pd import numpy as np # Data ny_housing = pd.read_csv('data/train.csv') # Selecting 4 most relevant variables from the dataset fot the Cleaning and Preprocessing. housing_data = ny_housing[['MasVnrArea', 'GrLivArea', 'LotShape', 'GarageType', 'SalePrice']] # Write your code here: d...
97da052c8d3effc3e199c9f925d522f743599007
akuchling/book-diary-tools
/books.d/best
1,217
3.671875
4
#!/usr/bin/env python3 # -*-Python-*- # # Description: Prints a list of the best books for each year. # import sys import reviews def get_entry_html(entry): """Returns HTML code for a link to the given entry.""" authors = entry.fields.get('A') def flip (a): L = a.split(',', 1) if len(L) =...
e0cf147dd6dd1333ce3f21a528b7653b8287b7f3
akapkotel/top-down-multiplayer-shooter
/src/game.py
8,831
3.71875
4
#!/usr/bin/env python from __future__ import annotations import math import arcade from typing import List, Tuple from arcade import is_point_in_polygon from geometry import move_along_vector, calculate_angle GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) GREY = (0, 200, 200) YELLOW = (255, 255, 0) PLAYE...
408e39545aa9b03eac9703ce5b41e1e074aca272
AP-MI-2021/lab-2-RaulT8
/main.py
2,267
4.03125
4
import datetime def isPrime(x): if x<2: return False for i in range (2,x//2+1): if x%i==0: return False return True def get_largest_prime_below(n): ok=True m=n-1 while ok==True: if isPrime(m)==True: ok=False else: m=m-1 return m def test_get_largest...
3dc28044e9fbcdcbecee5bfb844007220ffa35ef
cagriyalniz/python_ikinci_kurs
/ucuncu_gun/donguler_genel.py
1,414
3.71875
4
cumle1 = "eğer şu şekilde başlasaydım her şey farklı olurdu: size söyleyeceklerimi söylemeye değecek mi bilmiyorum, çünkü beyni sulanmış bir aptal kitlesine sesleneceğimi çok iyi biliyorum; ama salonda bulunan, aptal çoğunluğun dışında kalan iki üç kişiye olan saygım nedeniyle konuşuyorum" cumle2 = cumle1.split(" ") ...
3ee7b8821fb37a477a94f66c9a24552183ccc33b
cagriyalniz/python_ikinci_kurs
/dorduncu_gun/dosya_islemler.py
485
3.59375
4
f = open("musteriler.txt") #print(f.read()) #ustteki kod ile okuma islemini gerceklestirdikten sonra #alttaki kod hicbir sey print etmiyor cunku #ustteki kod ile okuma islemini tamamladi, okunacak bir sey kalmadı # print(f.read(1)) # print(f.readline()) # print(f.readline()) # for l in f: # print(l) f.close() ...
b9ea02b17f55fc3a469d43a23abca40eda772548
cagriyalniz/python_ikinci_kurs
/ikinci_gun/dictionary.py
269
3.8125
4
my_dict = {"isim": "cagri", "soyisim": "yalniz", "numara": 345} print(my_dict) my_dict["isim"] = "akif" my_dict["soyisim"] = "şakir" print(my_dict) my_dict2 = dict(a = "apple", b = "samsung") print(my_dict2) del(my_dict2["a"]) print(my_dict2)
6525dc243b432def428ae9835a5ca0b02d6de63f
DomenZero/DevOps_BigData
/16_Python/4task.py
712
3.859375
4
''' Task 4 We took a little look on os module. Write a small script which will print a string using all the types of string formatting which were considered during the lecture with the following context: This script has the following PID: <ACTUAL_PID_HERE>. It was ran by <ACTUAL_USERNAME_HERE> to work happily on <...
9c1badea5ecb7df2f8ce311d114f6a3b4927fc02
immortalbard/AoC
/2019/Day 22/22-1.py
1,191
3.65625
4
#! python3 class Deck: def __init__(self, card_num): self.cards = [x for x in range(card_num)] self.length = len(self.cards) def deal(self): self.cards=self.cards[::-1] def cut(self,n): self.cards=self.cards[n:]+self.cards[:n] def n_deal(self,n): deck=['' for _ in range(self.length)] ...
dcb9a6c794297659c80c7419ec3d01d8793f84f8
jagnahe1/python-function
/function_stdoutput.py
391
4.25
4
#!/usr/bin/env python #Author: Josie B. Agnahe #Date: March 9, 2016 #Purpose: Python Script for displaying output in three ways def FuncOut(name, age): print "Hi! My name is ", name + "and my age is", age print "Hi! My name is %s and my age is %d" %(name, age) print "Hi! My name is {} and...
5af94e9eaca788d9404ac3098d5c808f9c4d1c56
NashBoyGit/ift-1004
/pymafia/__main__.py
2,596
3.703125
4
""" Module principal du package pymafia. C'est ici le point d'entrée du programme. Ce module définit 3 fonctions ainsi que les commandes principales qui lancent le jeu. """ from pymafia.partie import Partie def demander_nombre_joueurs(): """ Fonction qui demande à l'utilisateur combien de joueurs entre 2 et 8...
76e8f2bcecaa8fad1136d39241dff615859a1dea
adityasubathu/my-programs
/Python/untitled-1.py
612
4.0625
4
def add(x, y): return x + y def sub(x, y): return x - y def mul(x, y): return x * y def divi(x, y): return x / y def main(): print("Hi! Welcome to Python Calculator Program") a = int(input("Please enter the first number: ")) o = str(input("Please enter operation sign: ")) b = in...
1392aba8a70102b8e7bdd56f85b83aea6a2875fb
Ziaeemehr/miscellaneous
/ictp_workshop/euler/17.py
967
3.78125
4
#!/usr/bin/env python from sys import exit, argv num_dict={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six', 7:'seven',8:'eight',9:'nine',11:'eleven',12:'twelve', 13:'thirteen',14:'fourteen',15:'fifteen',16:'sixteen', 17:'seventeen',18:'eighteen',19:'nineteen', 10:'ten',20:'twenty',30:'thirty',...
df07bc35b85329ba123cc2d75afda740104cb581
AlenaGB/6hw
/4.py
2,366
4.03125
4
class Car: def __init__(self, speed, color, name, is_police): self.speed = speed self.color = color self.name = name self.is_police = is_police def go(self): return f'{self.name} в джижении' def stop(self): return f'{self.name} остановилась' def turn_r...
bf8546ff600592763647e16cef1fd5414c4bd782
andy3278/github-upload
/num_guess/num_guess.py
878
4.125
4
from random import randint lowest = 0 highest = int(input("The range you want to guess: ")) answer = randint(lowest, highest) #重複猜數字,直到猜對為止 while True: guess = input('number bewteen :' + str(lowest) + '-' + str(highest) + ':\n>>') try: guess = int(guess) #把字串轉換成整數 except ValueError: #轉...
540e2e38e424ded7db917d10443756c81fc10079
sushantchauhan/programming-python
/codility/6.1-DistinctValuesInArray.py
683
4.34375
4
def DistinctValuesInArray(A): """ given an array A consisting of N integers, returns the number of distinct values in array A. For example, given array A consisting of six elements such that: A[0] = 2 A[1] = 1 A[2] = 1 A[3] = 2 A[4] = 3 A[5] = 1 the function should return 3,...
bafc86a5ed3cdebf0369eb590dca091254b1f0fe
zhouchengrui/COMS4701_AI
/hw1_search/treeNode.py
2,937
4.1875
4
#!/usr/bin/env python3 class TreeNode(object): """ This class represents the search tree node """ def __init__(self, state, parent_move = None, parent = None): self.state = state self.parent_move = parent_move self.parent = parent self.cost = parent.cost + 1 if parent els...
57f830826ffa7bb1efc72b7edb1fe564630b5e37
syedq707/list-of-rationals-binary-tree
/rationals.py
1,675
3.71875
4
def all_rationals(n): class Queue: def __init__(self): self.items = [] def enqueue(self, item): self.items.insert(0, item) def dequeue(self): if not self.isEmpty(): return self.items.pop(-1) def isEmpty(self): ...
de662b4f4866ce5431cd9a3106e7243ca3677675
type812/practice
/RemoveDuplicateFromList.py
305
3.5625
4
#Approach 1 t = [1, 2, 3, 1, 2, 5, 6, 7, 8] s = [1, 2, 3] print(list(set(t) - set(s))) #Maintaining order from collections import OrderedDict print(list(OrderedDict.fromkeys(t))) #Approach 2 myList = [1, 2, 3, 1, 2, 5, 6, 7, 8] cleanlist = [] [cleanlist.append(x) for x in myList if x not in cleanlist]
f400e9be2810e8b017ad3d4b472ea3c34088a1c8
type812/practice
/arrayPairSum.py
440
3.78125
4
''' pair_sum([1,3,2,2],4) would return 2pairs: (1,3) (2,2) ''' def pair_sum(arr,k): if len(arr)< 2: return print("too small to perform pair sum") seen = set() output = set() for num in arr: target = k-num if target not in seen(): seen.add(num) else: ...
bf7abfd162d9eabe53e39780e40f0dc677d168ba
type812/practice
/mostFrequentlyOccuringElement Array.py
400
4.09375
4
''' given an array find out most frequent occuring element ''' def most_frequent(list): count = {} max_count = 0 max_item = None for i in list: if i not in count: count[i]= 1 else: count[i]+=1 if count[i] > max_count: max_count= count[i] ...
e1118e7c461824966734d57cbc42b350d0515c8e
type812/practice
/commonElementsInTwoArrays.py
467
4.03125
4
''' return the common elements between two arrays as [1,3,4,6,7,9] and [1,2,4,5,9,10] are [1,4,9] ''' def common_elements(a,b): p1=0 #pointers p1 and p2 p2=0 result=[] while p1< len(a) and p2 < len(b): if a[p1] == b[p2]: result.append(a[p1]) p1+=1 p2+=1 ...
57f58bd92e2585bb8100ba0a3a493782bcc6dc18
Bowrna/AdventOfCode
/src/Day1_sum2020.py
3,327
3.75
4
import pdb from itertools import combinations from functools import reduce import operator def find_subset(input_list, size): return list(combinations(input_list, size)) def prod(iterable): return reduce(operator.mul, iterable, 1) def find_the_three_numbers_sum2020(input_content): size = 3 input_c...
0873c5e9ca57c7df5e56754347abf3761ad66ab5
razzlestorm/LS-Data_Structures
/singly_linked_list/singly_linked_list.py
2,295
4.0625
4
class Node: def __init__(self, value=None, next_node=None): # the value at this linked list node self.value = value # reference to the next node in the list self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.n...
8ac31b2f5ac9d0bad246e7a9ce63412eb6596131
RossT18/CPP-Linked-List
/Python/Driver.py
592
3.90625
4
from LinkedList import * def main(): myLinkedList = LinkedList() myLinkedList.pop() myLinkedList.push(2021) print(f"2021 in list: {2021 in myLinkedList}") myLinkedList.pop() print(f"2021 in list: {2021 in myLinkedList}") print(f"2024 in list: {2024 in myLinkedList}") myLinkedList....
33f32ae4eb0b8892ac80c3fcf3f2e8f6a8bbab35
Joshuaren/python
/lxf-puthon/ziti.py
126
3.921875
4
#-*- coding:utf-8 -*- while True: Str = input('-----------\n: ') print(":> ") for i in Str: print(i)
b91aa4d0948137958b20a5a2ff8db0b6fcb26024
SamRabling/pythonPrep
/dictionarybase.py
446
3.625
4
aboutMe = {'name':'Sam', 'age':'24', 'country of birth':'Mexico', 'favorite language':'javascript'} # print "My name is " + (aboutMe.get('name')) # print "My age is " + (aboutMe.get('age')) # print "My country of birth is " + (aboutMe.get('country of birth')) # print "My favorite language is " + (aboutMe.get('favorite ...
bfe6e3ae75d1fbd48c2872a8825cad2ea37af6cf
SamRabling/pythonPrep
/oopMathDojo.py
895
3.734375
4
class MathDojo(object): def __init__(self, num): self.num = num def add(self, *nums): for nmbr in nums: if isinstance(nmbr, int) or isinstance(nmbr, float): self.num += nmbr elif isinstance(nmbr, list) or isinstance(nmbr, tuple): self....
52d2875431e8e8c6b64bdf0292f90185191a34e8
SamRabling/pythonPrep
/oopCallCenter.py
1,316
3.53125
4
class Call(object): def __init__(self, i_d, caller_name, caller_number, time_of_call, reason_for_call): self.id = i_d self.caller_name = caller_name self.caller_number = caller_number self.time_of_call = time_of_call self.reason_for_call = reason_for_call def callAttribu...
3e0d95c1840cae5fbd6689f5bf5e8a44f9944187
MaximNoba/PythonLabs2021
/Turtle 1/10 Цветок.py
377
3.796875
4
import math as np import turtle r=20 n=40 i=0 for i in range(3): for i in range(n): turtle.shape('turtle') turtle.forward(2*r*np.sin(180/n)) turtle.left(180-180*(n-2)/n) for i in range(n): turtle.shape('turtle') turtle.forward(2*r*np.sin(180/n)) tur...
7fd03b00be1fd494cae34a70c8b3c8086a596d67
MaximNoba/PythonLabs2021
/Turtle 1/11 Бабочка.py
359
3.59375
4
import math as np import turtle r=5 n=40 i=0 for i in range(10): for i in range(n): turtle.shape('turtle') turtle.forward(2*r*np.sin(180/n)) turtle.left(180-180*(n-2)/n) for i in range(n): turtle.shape('turtle') turtle.forward(2*r*np.sin(180/n)) tur...
f15b82f3d83e8c7e9acb25864b8671572fd6ffca
stefan-scott/CS20---Python-Demos-2019
/12 turtle confusion demo.py
1,039
3.953125
4
import turtle, random roscoe = turtle.Turtle() reginald = turtle.Turtle() wn = turtle.Screen() def plus(side_length, a_turtle): """A function for having a turtle draw a plus sign. side_length -> int a_turtle -> turtle """ for i in range(4): a_turtle.fd(side_length) a_turtle.right(90) ...
2031d8d22d83bf6eb798814a8e571b841830e8fa
stefan-scott/CS20---Python-Demos-2019
/03 Functions with Arguments.py
422
4.40625
4
# Functions with Arguments Practice def multiplier(num1, num2): # a function that multiplies two inputed values # and prints the result to the console. result = num1 * num2 print(result) #Start by asking the user for two input values input1 = float(input("Please Enter a Number: ")) input2 = float(inpu...
e3e4ba1df5e8f5a6bcde111b409566f359b56295
stefan-scott/CS20---Python-Demos-2019
/21 Text Adventure.py
3,198
4.5
4
#Choose Your Own Aventure Demo import random #CHAPTER ONE - Wake Up! print("Welcome to this game. You're a high school student") clothing = input("You wake up - what will you wear? (dressy) (preppy) (super casual)") #CHAPTER TWO - Get to School! print("Each day you either walk to school, or take the bus") transport =...
10c5df346f63ff794fd97c983145af64061db138
murtazahatim/sorting_algorithms
/python_codes/heap_sort.py
838
3.765625
4
def heap_sort(lst): heap_lst = [None] * (len(lst) + 1) for ind in range(len(lst)): heap_lst[ind + 1] = lst[ind] length = len(heap_lst) for n in range(length - 1, 1, -1): heap_lst[:n+1] = heapify(heap_lst[:n + 1]) heap_lst[1], heap_lst[n] = heap_lst[n], heap_lst[1] return h...
0761fbb18fed11f07528447fb2c3d9930904ec61
murtazahatim/sorting_algorithms
/python_codes/insertion_sort.py
236
3.859375
4
def insertion_sort(lst): for i in range(1, len(lst)): for k in range(i, 0, -1): if lst[k-1] > lst[k]: lst[k - 1], lst[k] = lst[k], lst[k - 1] else: break return lst
9b38757571056db5c49323f76e122f78b2aaa22b
Polydynamical/cpuzpy
/py.py
1,943
3.828125
4
import PySimpleGUI as sg """ Demo - Drawing and moving demo This demo shows how to use a Graph Element to (optionally) display an image and then use the mouse to "drag" and draw rectangles and circles. """ def main(): sg.theme('Dark Blue 3') col = [[sg.R('Move Stuff', 1, True, key='-MOVE-', en...
f2d9565999908a0f0ed637848f9682d2ed3fddc3
Boltinov/-2
/дз1/1.py
290
3.703125
4
a = 10 b = 20 c = a + b print(c) name = input("введите ваше имя") age = input("введите ваш возраст") s = input("ваше любимое число") print('привет '+ name , "вам " + age, "лет") print("ваше любимое число " + s)
d1b2161ca1b51c72ff20c9b6e0a9aee26e6c33ea
Boltinov/-2
/дз1/5.py
757
3.78125
4
sales = int(input("введите вашу выручку")) invest = int(input("введите ваши издержки")) if sales > invest: print("вы в плюсе!") a = sales - invest rent = a / sales * 100 print("выша прибыль составила" , a ," а рентабельность " , int(rent) , "%") elif sales < invest: print("вы в минусе") b = in...
b928b022c2b5edcf5f1925fb0ec709100d3a834b
liadbiz/ai_books
/machine_learning_algorithms_from_scratch/code/chapter_12/probabilities_by_class.py
2,442
3.640625
4
# Example of calculating class probabilities from math import sqrt from math import pi from math import exp # Split the dataset by class values, returns a dictionary def separate_by_class(dataset): separated = dict() for i in range(len(dataset)): vector = dataset[i] class_value = vector[-1] if (class_value not...
e3fb7eacbe77988b99b3382b478bc6802d91a80d
liadbiz/ai_books
/machine_learning_algorithms_from_scratch/code/chapter_15/predict.py
1,592
3.703125
4
# Example of making predictions from math import exp # Calculate neuron activation for an input def activate(weights, inputs): activation = weights[-1] for i in range(len(weights)-1): activation += weights[i] * inputs[i] return activation # Transfer neuron activation def transfer(activation): return 1.0 / (1.0 ...
6f53006f8f41a9b5ba666877186f41a059bfade0
liadbiz/ai_books
/machine_learning_algorithms_from_scratch/code/chapter_12/summarize_by_class.py
1,635
3.796875
4
# Example of summarizing data by class value from math import sqrt # Split the dataset by class values, returns a dictionary def separate_by_class(dataset): separated = dict() for i in range(len(dataset)): vector = dataset[i] class_value = vector[-1] if (class_value not in separated): separated[class_value]...
1085fc17d1391b42b495ced68dbbec30a9b78223
shivammishra12345/Code-on-DSA
/doubly linkedlist.py
1,448
3.921875
4
class node: def __init__(self,data): self.data=data self.next=None self.prev=None class DL: def __init__(self): self.head=None def ad(self,data): newnode=node(data) current=self.head if(self.head): while(current.next): ...
31b40a7da318aced9d65d5b92856bd6075c235ac
rex56/costco_scrapy
/costco.py
1,591
3.765625
4
print ("Scraping COSTCO") # 如果先前沒安裝過requests 則這邊會失敗, 因此需要先安裝, 可用這個指令: pip install requests import requests # 指定要抓取的網頁URL url = "https://www.costco.com.tw/Appliances/Cooling-Heating-Dehumidifiers/c/306" url = "https://www.costco.com.tw/Electronics/Apple-Devices/iPhone/c/10704" # 使用requests.get() 來得到網頁回傳內容 r = reque...
177eeb5467efa67794cc52bb1b9cdefab202f3cc
vladislavkovalskyi/SecondsConverter
/secondsconverter.py
1,735
3.796875
4
# Конвертирует секунды в разные единицы времени from typing import List class Converter: def __init__(self, intervals_name: List[str] = None) -> None: """ intervals_name: Должен содержать 7 элементов. Пример: ["сек", "мин", "часов", "дней", "недель", "месяцев", "лет"] """ if len(intervals_name) != 7: se...
37f9f345173a7765017b34312ddd2e740f85e939
zthroo/numconverter
/binconverter.py
4,005
3.59375
4
import math import argparse def bin2dec(length, num_str): # converts binary to decimal num = 0 for index in range(length): num = num + (2 ** (length - index - 1)) * int(num_str[index]) return num def bin2hex(length, num_string): offset = 4 - length % 4 # determine how many 0s needed to mak...
b79b3dcb24e8e0329440218ba52807a542df41ae
ScarletMoony/py_from_scratch_to_top
/AllPyCode/string_methods(Lesson).py
4,977
4.3125
4
x = "Hello" x.lower() # возвращает новую строку с нижним регистром print(x) print(x.capitalize()) # возвращает все символы с маленькой и первый символ с большой print(x.count('l')) # возвращает количестао символов в строке print(x.center(100, "|")) # возвращает строку по центру, первое это сколькими символами ...
eb0ad73d0aafe48fa4fb5737017683f1965fb8d4
ScarletMoony/py_from_scratch_to_top
/Work_with_errors/02.py
248
4.15625
4
def divide(x, y): if y == 0: raise ZeroDivisionError("Cannot divide to zero") # Выдаст ошибку return x/y # которую нам надо с нашим описанием print(divide(2, 0))
fb99eb42b4c421c5817c50c4f4927d93d136a9a2
ScarletMoony/py_from_scratch_to_top
/Functions/08_decorators_2.py
721
3.796875
4
from functools import wraps # Здесь мы импортируем (wraps) из модуля (functools) def func_log(func): @wraps(func) # Так мы делаем чтобы функция (hello) считалась сама собой def wrap(*args, **kwargs): # Также в (wraps) желательно использовать: print(f'Started {func}') # (*args...
2a5885926d26247e1b89036dfffd5dc04020b3b0
ScarletMoony/py_from_scratch_to_top
/Set/01.py
870
4.375
4
set1 = set() set1 = {1, 2, 3, 4, 5} # Множество, имеет неповторяющиеся элементы print(set1) set1.add(6) # Добавление элемента, если он еще не существует print(set1) set1.add(1) print(set1) set2 = {1, 2, 3, 4, 5, 6, 7, 8} print(set1.issubset(set2)) # Проверяет есть ли все значения set1 в set2 print(set2.issuperse...
cee5b3c9a5cedc29609364e5861990177c85fb27
ScarletMoony/py_from_scratch_to_top
/Tuples/02.py
439
3.875
4
from collections import namedtuple x = namedtuple('C', 'g b c') # Именованый кортеж y = [x('N', 1, 8), x('Br', 8, 14)] # Создание обьекта по namedtupl'у print(y[0]) print(y[0].g) # Вывод элемента # Именованые кортежи можно описать как классы без функций, грубо говоря: # Контейнер неизменяемых данных
26d4c9029c2061f1ec475d1dda2f647d3762116e
jiwon111/python_for_coding_test
/chapter15/28.py
427
3.734375
4
n = int(input()) data = list(map(int, input().split())) def binary_search(array, start, end): if start>end: return None mid = (start+end)//2 if array[mid] == mid: return mid elif array[mid]>mid: return binary_search(array, start, mid-1) else: return binary_search(ar...
4bfdb643c01fb3a9a894ea4b00d15bf041bed414
jiwon111/python_for_coding_test
/chapter14/26.py
482
3.578125
4
'''import heapq n = int(input()) heap = [] for i in range(n): data = int(input()) heapq.heappush(heap, data) result = 0 while len(heap)!=1: one = heapq.heappop(heap) two = heapq.heappop(heap) sum = one+two result += sum heapq.heappush(heap, sum) print(result)''' n = int(input()) card ...
fd65fad6822109fa4b697bc7eceb80438643d99f
abhishekir/DoublePendulum_Simulation
/main.py
2,895
3.5
4
from constants import * def initialize(): # Initialize pygame pygame.init() # create the screen screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption(GAME_CAPTION) icon = pygame.image.load(GAME_ICON) pygame.display.set_icon(icon) return s...
ba30bff5d232d3395bca8800c8655ef41c6c918a
dennissv/aoc-2020
/12.py
2,651
3.578125
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 12 15:32:39 2020 @author: dennis """ import numpy as np class Position: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Position(self.x + other.x, self.y + other.y) def __mul__(self, sca...
7bc0f7bff3955e505a0aa835241487ec616c56da
fernandesd/minicurso-python
/aula2.py
140
3.96875
4
num = input('Digite um número: ') if float(num) % 2 == 0: print('{} é par.'.format(num)) else: print('{} é ímpar'.format(num))
d9c6d9a8331a220edc9016279e55fc722966c324
Lao-Tzu-Taoism/EasierLife
/Plugins/ProgressBar/ProgressBar.py
1,161
3.546875
4
import sys, time class ProgressBar: def __enter__(self): return self def __init__(self, count=0, total=100, width=50): self.count=count self.total=total self.width=width def move(self, i=1): self.count+=i return True def move_to(self,count): ...
290432ecdd9d378c28a77dac9ca6409160dd3cad
SWKANG0525/Algorithm
/BaekJoon/BOJ 2869.py
242
3.59375
4
# Author : Kang Ho Dong # Date : 2020 - 07 - 01 # Title : BOJ 2869 # Language : Python 3 import math up_var,down_var,height = map(int,input().split()) if up_var>=height: print(1) else: print(math.ceil((height-up_var)/(up_var-down_var)+1))
ab780a68346de7acb97c471401287e0833621e2f
SWKANG0525/Algorithm
/BaekJoon/BOJ 1002.py
699
3.578125
4
# Author : Kang Ho Dong # Date : 2020 - 07 - 03 # Title : BOJ 1085 # Language : Python 3 import math T = int(input()) for i in range(0, T): xpos1, ypos1, radius1, xpos2, ypos2, radius2 = map(int, input().split()) distance = math.sqrt((xpos1 - xpos2) * (xpos1 - xpos2) + (ypos1 - ypos2) * (ypos1 - ypos2)) ...
67448a189295d13f3fb4f0a86dbb8d20b559bde0
SWKANG0525/Algorithm
/BaekJoon/BOJ 6064.py
1,299
3.796875
4
# Author : Kang Ho Dong # Date : 2019 - 01 - 18 # Title : BOJ 6064 # Link : https://www.acmicpc.net/problem/6064 # Language : Python 3 def GCD(_big, _small): # Greatest Common Divisor : Euclidean Algorithm while True: remainder = _big % _small if remainder != 0: _big = _small ...
b803d6de6e8a65638d91d59e9cdcfaf43d998031
SWKANG0525/Algorithm
/BaekJoon/BOJ 15652.py
414
3.515625
4
# Author : Kang Ho Dong # Date : 2020 - 07 - 18 # Title : BOJ 15652 # Language : Python 3 def func_backtracking(n,m,ls,idx): if len(ls) == m and len(ls) != 0: for i in ls: print(i,end=" ") print() return for i in range(idx,n+1): ls.append(i) func_bac...
b0274e9ae234429e1ba16573c01f0f92075b9994
SWKANG0525/Algorithm
/LeetCode/2. Add Two Numbers.py
1,778
3.984375
4
""" You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itse...
c27593e5d26325ff33ac4c5776d7aa9971945cc3
khmahmud101/Data-Structure-Algorithm
/stack.py
631
4.15625
4
li = [] li.append(1) print(li) li.append(2) print(li) li.append(3) print(li) li.pop() print(li) li.pop() li.pop() print(li) if li != []: li.pop() class Stack: def __init__(self): self.items = [] def push(self,item): self.items.append(item) print("push item",self.items) def pop...
8aba97780f934d6c90023ded74508866a8b5af60
khmahmud101/Data-Structure-Algorithm
/table_driven_test.py
691
3.625
4
def average(L): if not L: return None return sum(L)//len(L) def test(): test_cases = [ { "name": "simple case 1", "input":[1,2,3], "expected": 2 }, { "name": "simple case 2", "input": [1, 2, 3,4], "expe...
43eeca0fc9152c4023b82c28e9cc788a3aeee53b
bbchristians/ShiftScheduler
/ShiftScheduler/ShiftTime.py
4,587
4.15625
4
from enum import Enum import datetime def make_time(hour, min): """ Returns a properly formatted time given an hour and a minute :param hour: An integer representing the hour in military time :param min: An integer representing the minute in military time :return: a 'time' object containing an hour...
8c117994d94cb675a90167b4da2cb1cffe37ef20
AID1904/studyInTarena
/练习/6.26_GIL/with_lock_hans.py
1,001
3.671875
4
from threading import Thread, Lock class Solution: def __init__(self, target_tuple, interval): self.list_result = [] self.lock = Lock() self.index_ = 0 self.characters = target_tuple self.interval = interval def add_num(self): with self.lock: for i ...
b64cd6c47a069c68469b75e022dc66ea65ca354a
damianpud/sda_tasks
/SDA_python_basics/tasks/task_8.py
313
3.828125
4
def factorial(cyfra): i = 1 iloczyn = 1 if cyfra == 0: return 0 else: while i <= cyfra: iloczyn = iloczyn*i i += 1 return iloczyn if __name__ == '__main__': number = int(input('Podaj liczbe: ')) result = factorial(number) print(result)
467b8ff9fa6d7c9f6a53ad137fde1aae08a07206
damianpud/sda_tasks
/SDA_python_basics/tasks/task_1.py
931
4
4
""" 1. Napisz funkcję prime_numbers, która przyjmować będzie liczbę quantity. Jej zadaniem jest wyświetlenie quantity liczb pierwszych. Liczba pierwsza to taka liczba, która jest podzielna tylko przez 1 oraz samą siebie. Pomocniczo, opracuj funkcję is_prime, przyjmującą liczbę number, która będzie sprawdzała, czy dana ...
85edf92fc7ec43b2824bee725020bf9c7a778fc3
damianpud/sda_tasks
/SDA_python_basics/tasks/task_12.py
526
3.96875
4
def compute_bmi(weight, height): bmi = weight / height ** 2 if bmi < 18.5: result = 'undrweight' elif bmi > 25: result = 'overweight' else: result = 'normal' return result if __name__ == '__main__': user_weight = float(input('Your weight [kg]: ')) user_height = floa...
a0422663141e57cad1905e8ba2b5b893b4f87021
fla4112/crsphysics
/cons_moment.py
2,577
3.796875
4
# Conservation of Momentum: Collisions ''' Question 1 Consider the following for questions 1-6. A bullet of mass 0.096 kg traveling horizontally at a speed of 200 m/s embeds itself in a block of mass 2.5 kg that is sitting at rest on a nearly frictionless surface. ''' import math m1= 0.096 m1vxi= 200 mblock= 2.5 #kg...
397711aa02cfbfc6dfd91c76a4abb0709d5e60da
gigerbits/PythonProjex
/Clock.py
1,960
3.625
4
import time import calendar from tkinter import * from tkinter import ttk from tkinter import font import winsound #9/27/2019 h = 0 m = 0 s = 0 t = "am" def current_time(): global h global m global s global t total_seconds = calendar.timegm(time.gmtime()) current_second = total_seconds%60 ...
8bbb982c2ec7423dde772bf7eec4c9418f7af82e
gigerbits/PythonProjex
/Stopwatch.py
299
3.71875
4
#Logan Cannon #9/5/2019 #Stopwatch floats = 0 timer=0 minu = 0 sec = 0 hour = 0 while True: timer+=0.0025 floats+=0.0025 sec = floats // 1 if sec == 60.0: minu+=1 floats-=60 if minu==60: hour+=1 minu-=60 print(str(hour)+":"+str(minu)+":"+str(sec))
4d3e620b391a76ccd683bbdf21ac2217b9a2c5b7
DevonZhao/Python_Project
/Test/py3.6/demo20180122.py
778
3.5
4
#!/usr/local/env3.6/bin/env python # -*- coding: utf-8 -*- # @File : demo20180122.py # @Author : devon # @Date : 2018/1/22 # @Platform: Mac # @version : # @Desc : d = {'x':1,'y':2,'z':3} print(d) for key in d: print(key,d[key]) ''' urllib is a package that collects several modules for working with U...
a0c07d7f29ec752ef8a52340f04f956e28e99a49
LavinaKathambi/Data_Structures_and_Algorithms
/twoNumberSum.py
1,803
4.125
4
''' You are given a function that takes in two parameters: 1. An Array 2. A sum The goal is to find two numbers in the array that add up to the sum You are to return an array of these 2 numbers and an empty array if otherwise NB: Assume there will be at most a pair that makes this sum ''' # Solution 1 Brute Force # O...
eda2188a965fff3e2c5328273551de27671b8144
JoshuaKodhe/Store-Manager-Api-V2
/app/models/products_model.py
4,232
3.625
4
from app.utils.db_connection import connect class Product: def __init__(self, name, category, price, quantity, description): self.name = name self.category = category self.price = price self.quantity = quantity self.description = description def save(self): '''...
7247ef873a243a1923b42c4b455c769850b2537d
adawang06/Paper-Graph
/src/postgres/postgre_connection_test.py
1,007
3.546875
4
import psycopg2 try: connection = psycopg2.connect(user="postgres", password="wangda10", host="127.0.0.1", port="5432", database="citation_pairs") cursor = connection.cursor() ...
9f7083d0db78fc8c7d7caf7c39e66bbc68d21312
Vencislav-Dzhukelov/101-3
/week3/3-Panda-Social-Network/panda_test.py
1,079
3.640625
4
from panda import Panda import unittest class TestPanda(unittest.TestCase): def setUp(self): self.my_panda = Panda("Name", "panda@gmail.com", "male") self.your_panda = Panda("Name", "panda@gmail.com", "male") def test_init(self): self.assertTrue(isinstance(self.my_panda, Panda)) ...
36ea4b1686d7d7c2e373e520137d3f1c56cad4cb
Vencislav-Dzhukelov/101-3
/week2/4-Fractions/fraction.py
1,528
3.671875
4
from fractions import gcd class Fraction: def __init__(self, numerator, denominator): g_c_devisor = gcd(numerator, denominator) self.numerator = numerator / g_c_devisor self.denominator = denominator / g_c_devisor def __str__(self): if self.denominator == 1 or self.numerator =...