blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
346571a905ef308aab64d7977ef07c59b2f7057c
goanpixie/python_learning
/main.py
830
3.5
4
from mymodule import test import json from test() # f = open('fake_fruits.json', 'r') # print(f.read()) # f.close() #with statement - with open('fake_fruits.json', 'r') as f: # open the JSON file for reading data = json.load(f) # de-serialise the JSON into data print(data) data['Fruit'][1]['Name'] = 'wrong' ...
de7464851f7ba9bc4e6a98b973c202b8fb8dae03
SimoneSigillo/labPy
/elementi_base/tuple.py
2,102
4.09375
4
''' Una tupla è una sequenza ordinata e immutabile di valori non necessariamente dello stesso tipo e si racchiudono tra parentesi tonde ''' tupla = (7, 4, 16, 34) parole = ( 'foglia', 'casa', 'pompieri', 'albero' ) numero = 100 tupla_mista = (numero, 'foglia', 'casa', 'pompieri', 'albero' ) print ('tupla: ', tupla, '...
bf980a5e004b1c2a47ed5edc04853a9c5f3b79cc
SimoneSigillo/labPy
/contributions/if.py
187
3.703125
4
num1=700 num2=700 if num2>num1: print('correct') elif num1==num2: print('both number are same') else: print('invalid expression')
2986817b76355efad44263725700ba316e51d12e
SimoneSigillo/labPy
/turtle/turtle-istruzioni-base.py
1,572
3.734375
4
''' per tutte le istruzioni relative al modulo turtle si faccia riferimento alla documentazione della libreria https://docs.python.org/3/library/turtle.html ''' from turtle import Turtle, Screen # inizializzo la tartaruga tarty = Turtle() # per visualizzare una tartaruga al posto della freccia tarty.shape('turtle')...
d64b7d899ed8f320880b02ff6692ae83ab52c9aa
SimoneSigillo/labPy
/elementi_base/tipi.py
389
3.921875
4
#python3 #tipi di variabili ''' e commenti molto lunghi ''' numero = 3 stringa = "casa con virgolette" stringa2 = 'casa con apici' booleano = False reale = 3.14 #float print(numero,type(numero)) print(stringa,type(stringa)) print(stringa2,type(stringa2)) print(booleano,type(booleano)) print(reale,type(reale)) pr...
c2882c626bd12cec134949ad1bc760dba11b708b
SimoneSigillo/labPy
/elementi_base/esempio-08-liste-cicli.py
1,127
4.28125
4
#liste e cicli di for #una lista è un insieme ordinato di elementi e si rappresentano # chiuse tra parentesi quadre separati da virgole settimana = ['LUN', 'MAR', 'MER', 'GIO', 'VEN', 'SAB', 'DOM'] #posso stampare un elmenento in particolare print ("primo giorno: ",settimana[4]) #se voglio stampare tutta la lista p...
3eac20b9bce8e2a00020d7433e0eb6bdc490e85a
SimoneSigillo/labPy
/oop/auto.py
1,409
3.734375
4
''' Python3 Programmazione ad oggetti ''' class auto: # Attributi di Classe garanzia = 1 assicurazione = True parcoAuto = 0 #Metodo costruttore def __init__(self,proprietario, marca, modello, cilidrata, cavalli, colore): # Attributi di Istanza self.proprietario = proprietario...
8dfb51b8ee1a4776306790c12d3e5de7e62fdf4c
bigbag01/leetcode
/树/145.二叉树的后序遍历.py
2,515
3.859375
4
# # @lc app=leetcode.cn id=145 lang=python3 # # [145] 二叉树的后序遍历 # # https://leetcode-cn.com/problems/binary-tree-postorder-traversal/description/ # # algorithms # Hard (68.83%) # Likes: 208 # Dislikes: 0 # Total Accepted: 45.4K # Total Submissions: 65.3K # Testcase Example: '[1,null,2,3]' # # 给定一个二叉树,返回它的 后序 遍历。 ...
9abe6175c46c6750ee870a4f63f10f804adae444
bigbag01/leetcode
/栈和队列/20.有效的括号.py
603
3.578125
4
# # @lc app=leetcode.cn id=20 lang=python3 # # [20] 有效的括号 # # @lc code=start class Solution: def isValid(self, s: str) -> bool: if s == '': return True stack = [] match={')':'(',']':'[','}':'{'} for l in s: if l in ['(','[','{']: stack.append(...
a6628c3875c243c47abeb966ca7a40e5e01f02c1
bigbag01/leetcode
/哈希表/30.串联所有单词的子串.py
2,226
3.765625
4
# # @lc app=leetcode.cn id=30 lang=python3 # # [30] 串联所有单词的子串 # # https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/description/ # # algorithms # Hard (28.02%) # Likes: 206 # Dislikes: 0 # Total Accepted: 21.7K # Total Submissions: 75.1K # Testcase Example: '"barfoothefoobarman"\n["foo",...
9f27847440aac003b8f7d231d9c44b4aab78df6a
bigbag01/leetcode
/链表/19.删除链表的倒数第n个节点.py
1,411
3.765625
4
# # @lc app=leetcode.cn id=19 lang=python3 # # [19] 删除链表的倒数第N个节点 # # https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/description/ # # algorithms # Medium (36.53%) # Likes: 670 # Dislikes: 0 # Total Accepted: 114.1K # Total Submissions: 306.5K # Testcase Example: '[1,2,3,4,5]\n2' # # 给定一个链表,删除链表...
39d4315e76401dd6c6d7b3f112787518fb34fe7c
bigbag01/leetcode
/查找和排序/4.寻找两个有序数组的中位数.py
2,958
3.578125
4
# # @lc app=leetcode.cn id=4 lang=python3 # # [4] 寻找两个有序数组的中位数 # # https://leetcode-cn.com/problems/median-of-two-sorted-arrays/description/ # # algorithms # Hard (36.31%) # Likes: 2065 # Dislikes: 0 # Total Accepted: 135K # Total Submissions: 368.8K # Testcase Example: '[1,3]\n[2]' # # 给定两个大小为 m 和 n 的有序数组 nums1...
5335cdcfea92e52d393540eca4e58d2a9edfea0d
vinayak15/Encrypted-K-Means-
/main.py
2,701
3.609375
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset=pd.read_csv('Mall_Customers.csv') X = dataset.iloc[:, [3, 4]].values dataset.describe() m=X.shape[0] n_iter=100 from Kmeans import Kmeans #to find optimum number of clusters use elbow method WCSS_array=np.array([]) for K in range(1,11): ...
b2906ae39fb9bad5605b40b1b5fac2a04ee35d22
biysw11/Extracting_vizualize_stock_data
/Final Assignment.py
10,867
3.75
4
#!/usr/bin/env python # coding: utf-8 # <center> # <img src="https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/Logos/organization_logo/organization_logo.png" width="300" alt="cognitiveclass.ai logo" /> # </center> # # <h1>Extracting and Visualizing Stock Data</h1> # <h2>Descriptio...
91c136cdfc669d4841b5db720599a7f003514c56
syeomans/3b1b-neural-network
/neuralNetwork.py
3,189
3.78125
4
# Video series this is based on: https://www.youtube.com/watch?v=aircAruvnKk # Book the video is based on: http://neuralnetworksanddeeplearning.com/ from random import random import pickle import math import numpy # Dependency: pip install numpy def sigmoid(x): # Sigmoid "Squishification" function return 1 / (1 + m...
2de2d8974ee960f8d311d3fc945935df92ab41e2
suraj19/Python-Assignments
/program7.py
296
3.984375
4
#Date: 26-07-18 #Author: A.Suraj Kumar #Roll Number: 181046037 #Assignment 7 #Python Program to Find the Smallest Divisor of an Integer. n=int(input('Enter any Number:')) a=[] for i in range(2,n+1): if(n%i==0): a.append(i) a.sort() print('the samllest divisor of given number',+n,'is:',+a[0])
7e56e3d9cbe27e6443705f17225817f03a87f08c
suraj19/Python-Assignments
/program5.py
252
4.25
4
#Date: 26-07-18 #Author: A.Suraj Kumar #Roll Number: 181046037 #Assignment 5 #Python Program to Print Odd Numbers Within a Given Range. n= int(input("Enter a range for Odd Numbers: ")) n=n+1 for i in range(0, n): if (i%2!=0): print('Odd Integers:', +i)
311fd614ea01802b4be65e08a1e5075803eb6733
suraj19/Python-Assignments
/program21.py
439
3.921875
4
#Date: 28-07-18 #Author: A.Suraj Kumar #Roll Number: 181046037 #Assignment 20 #Python Program to Calculate the Number of Upper Case Letters and Lower Case Letters in a String. str_1= input('Enter your conbination of String: ') count_1=0 count_2=0 for i in str_1: if i.isupper(): count_1=count_1+1 if i.islower(): ...
14a701a26aa2da2f00bf4609f30977c985faa617
suraj19/Python-Assignments
/program6.py
277
4
4
#Date: 26-07-18 #Author: A.Suraj Kumar #Roll Number: 181046037 #Assignment 6 #Python Program to Find the Sum of Digits in a Number. n=int(input("Enter a number:")) a=0 while(n>0): A=n%10 a=a+A n=n//10 #floor division of operands print("The total sum of digits is:",a)
66eeb54b4796ba8e1e4501c68e2f35d9537d23e1
panayiotask/python
/ex08.py
664
3.984375
4
# 1 def double_it(number): return number*2 print(double_it(7)) print(double_it(4.76)) print(double_it('hi')) # 2 def calc_hypo(a,b): # function calculating the hypotenuse hypo=(a**2+b**2)**1/2 return hypo print(calc_hypo(3,4)) # checking the function # 3, Adding checks to the function def calc_hypo(a,b)...
c0ade742b363101e2fe201d5fed481b9dbed8726
mafengjames/snake-game-with-python
/snakepla.py
1,668
3.6875
4
import turtle import time import random # creating screen screen = turtle.Screen() screen.title("hungry viper") screen.setup(width=1000, height=1000) screen.bgcolor("cyan") screen.tracer(0) #creating the snake head head = turtle.Turtle() head.penup() head.shape("circle") head.color("green") head.goto(0,0) head.direct...
062ccbe7194f7602d510e070a1dcc62b8771bc5f
matthewrcarpenter/saxpy
/dfmsax.py
2,891
3.515625
4
import numpy as np import pandas as pd import saxpy.msax as msax class DataFrameInfo: """ This class is used for encapsulating information for a time-series contained in a pandas.DataFrame object. """ def __init__(self, dataframe, time_col, value_col) : assert isinstance(dataframe, pd.Data...
e7de15c6f84e0f62e5187857e8a9a515c5d0dbd5
Leenug/advent-of-code-2020
/day01/calculate.py
1,234
4
4
def calculate(file: str, target: int) -> int: """ Finds 2 numebrs that sum up to target and returns the product""" numbers = getFileLines(file) for a in range(numbers.__len__()): for b in range(numbers.__len__()): if a != b and numbers[a] + numbers[b] == target: return n...
085d02c150913d8857f9e462fc494afaeea57678
kylkletz/Raspberry-PI
/BlinkingLEDandIntensityLED.py
2,784
3.625
4
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) def setup(): sleepTime =.01 ##Assigning the GPIO pins to a variable for readability lightpin = 13 buttonpin = 18 pwmpin = 23 changepin = 26 ##The while loop conditional keepgoing = True ## Initial blinking speed for...
8f168af14bf8f8c40b869af6acb18e7792e96b86
eduard-cojocea/TeFacProgramator_G2_M3_08-20
/Curs_3/exemplu_curs_3_5.py
170
4.03125
4
values = [1, 2, 3, 4, 5, 6, 7] it = iter(values) print(next(it)) print(next(it)) print(next(it)) print(next(it)) print("starting the for") for val in it: print(val)
77e54d43f1dc1f4f9236ac66de5ba75da791cd6d
eduard-cojocea/TeFacProgramator_G2_M3_08-20
/Curs_7/exemple_curs_2.py
1,540
3.6875
4
class Parinte_1: atribut_parinte = 78 def __init__(self): print("Constructor parinte 1") def metodaParinte1(self): print("Metoda parinte 1") def Sulla_Felix_epitaph(self): print("No better friend, no worse enemy") class Parinte_2: atribut_parin...
63d4a5ff103145af869301766fcd3cd8aa01e59d
lein-hub/python_basic
/programmers/gcd_and_lcm.py
222
3.53125
4
def solution(n, m): def gcd(n, m): if m == 0: return n return gcd(m, n % m) def lcm(n, m): o = gcd(n, m) return o * (n / o) * (m / o) return [gcd(n, m), lcm(n, m)]
b21d8c55699592d799af5b6718e4dc1c2c7f849a
lein-hub/python_basic
/test/operator.py
3,515
3.53125
4
# a, b, c, d = 20, 30, 6, 2 # print(a+b) # print(a-b) # print(a*b) # print(a/d) # print(a % c) # print(c**d) # print(a//c) # a, b, c = True, False, True # print(a and b) # print(a and c) # print(a or b) # print(not a) # num = int(input()) # if num < 0: # print('NG') # else: # print('OK') # str = input() # i...
80b4e0163c99e2b06abdf679584a9ce91544a824
sureshrmdec/codeFights
/arcade/kingdomRoads/newRoadSystem.py
1,968
4.03125
4
from collections import defaultdict def newRoadSystem(roadRegister): numOfCities = len(roadRegister) # defaultdict is used for counting the number of incoming and outgoing # edges for each city. incoming = defaultdict(int) outgoing = defaultdict(int) for i in range(numOfCities): for j ...
1d85ef48d2949c198769d89afacb4aa14a2ab4ae
bhavyapathak20/LHD_Snakes
/6. Max Min Mean.py
759
3.9375
4
def num(): lis=[23,55,27,19] print("lis=[23,55,27,19]") print("1. Maximum value") print("2. Minimum value") print("3. Mean value") user=int(input("Enter your choice:")) if user==1: mx=max(lis) print("Maximum value is",mx) elif user==2: mn=min(lis) ...
136ce9ee4fd631a9158ba0e5bdcd16fb6325577f
lil-val/animal_parsing
/scraping_from_wiki.py
1,690
3.859375
4
from wikipedia_page_scraper import WikipediaPageScraper from output_to_html import OutputToHtml """ The variables below allow to retrieve data from a requested table in a wiki page. The requested attributes (columns) can be also changed. """ url = 'https://en.wikipedia.org/wiki/List_of_animal_names' position_of_table_...
6a420b0b97782f89757ebce529d66c32124c5695
Brownbull/ud_aiml
/Part 8 - Deep Learning/Section 40 - Convolutional Neural Networks (CNN)/GC_cnn.py
3,172
3.734375
4
# Convolutional Neural Network # Data is ready - no Preprocessing needed # Build the CNN # Importing the Keras libraries and packages from keras.models import Sequential # Initialize NN from keras.layers import Conv2D # Convolution step from keras.layers import MaxPooling2D # Pooling step from keras.layers imp...
46c61e5f5793e3c49a7a89f8b915c51a9d35c949
HayatoSempai/Learn2plan
/constraint.py
2,217
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Feb 2 14:56:24 2020 @author: yoyoman """ class Constraint : ''' Super-class for all types of constraints ''' def __init__(self, name, weight): ''' Constructor Input : name weight : float > ...
387d7cefa6912b66fbb6274e8d028e0aae225430
Barrymuch/PythonAlgorithms
/BestPractice.py
193
3.921875
4
from collections import defaultdict A = [1,2,3,4] # To create the dict of index vs value dict = {i: A[i]for i in range(len(A))} print(dict) # To use the default dict: d = defaultdict(int)
16041ddff82943fd088fcd97232672058992a50a
bomzuan/first_project
/hren'/appendList.py
116
3.6875
4
nums = [1, 2, 3, 6] a = [4, 4] nums.extend(a) print(nums) nums += a print(nums) nums.insert(0, "sadas") print(nums)
c79d718de3c9e894e8db82645c8f05bd827410ca
AntonGitOrlov/codewars_Anton
/8kyu/grasshopper_summation.py
1,233
4.0625
4
# https://www.codewars.com/kata/55d24f55d7dd296eb9000030 def summation(num): return sum(range(1, num+1)) print(summation(1)) print(summation(2)) print(summation(5)) # https://www.w3schools.com/python/ref_func_range.asp # Syntax # range(start, stop, step) # Функция xrange() в Python очень похожа на функцию ran...
c5e101e8db27f5408b65cd5691bd943bff77041a
juliakimchung/bangazon.py
/bangazon.py
3,054
3.609375
4
class Department: """Parent class for all department Method: __init__, get_name, get_supervisor """ def __init__(self, name, supervisor, employee_count): self.name = name self.supervisor = supervisor self.size = employee_count def get_name(self): """Returns the name of the department""" return self....
f76dd9a5d6d44b7aa8b7e8f7c3de3faaaf411d49
Chandreshmukundh/Letsupgrade-Day-2-Assgment
/overlapping.py
232
3.703125
4
#overlapping list1 =["acer","tesla","hcl","dell","bmw","lenovo","asus","bmw"] list2 =["microsoft","google","facebook","instagram","tesla","bmw"] overlapping = set.intersection(set(list1), set(list2)) print(overlapping)
00760a76a137a77965b76b805ca897e5265b1c3a
danny128373/Critters-and-Croquettes
/Petting_Zoo/animals/alligator.py
453
3.5
4
from animals import Animal from datetime import date from movements import Walking, Swimming class Alligator(Animal, Swimming, Walking): def __init__(self, name, species, food, chip_num): Animal.__init__(self, name, species, food, chip_num) Walking.__init__(self) Swimming.__init__(self) ...
0cf01f275ab3a773d6cd4b9def1975d4ab2745c2
Costadoat/Informatique
/Olds/TP_2020/TP04 Boucles et complexité/Documents/cadeau_tp_boucles.py
304
3.953125
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 20 11:52:38 2013 @author: stephane """ from math import sqrt def est_premier(n): if n <= 1: return False if n <= 3: return True for k in range(2,1+int(sqrt(n))): if n % k ==0 : return False return True
84150bc306fa0d06f8b7a745799fecaf68983fa2
Costadoat/Informatique
/Olds/ScriptAuProgramme.py
3,962
3.609375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Tue Aug 31 09:31:15 2021 @author: jg """ #============================================================================== # Recherche séquentielle dans un tableau unidimensionnel : recherche du 2eme max #====================================================...
7a52d6e777cc4e331bf019050dbac14db78276fb
Costadoat/Informatique
/Cours/C15 Pivot de Gauss/Code/I-C15.py
1,308
3.5
4
# -*- coding: utf-8 -*- """ Éditeur de Spyder """ import numpy def permutation(A,i,j): t = A[i] A[i] = A[j] A[j] = t def transvection(A,i,j,x): # si vecteur if type(A[0]) != list: A[i] = A[i] + x*A[j] else: n = len(A[0]) for k in range(n): A[i][...
2cf148478a1dc4206daaea9e6a9141ef1a536b01
Costadoat/Informatique
/Cours/C02 Introduction à la programmation/Code/I-C02.py
497
3.5625
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 16 11:16:07 2015 @author: Renaud """ def Euclide_PGCD(a,b): q=a/b r=a%b print("q=%s" % q) print("r=%s" % r) while r!=0: # tant que ce reste est non nul : a=b # b devient le nouveau a b=r # r devient le nouveau b ...
8d3dccdf29fbdeeed5fbd94abc1ebc70927671f7
Costadoat/Informatique
/DS/Annees_precedentes/2015-2016/DS04/DS04.py
3,970
3.625
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 24 09:20:35 2015 @author: Renaud """ import numpy as np import matplotlib.pyplot as plt print "EXERCICE 1:" def permutation(A,i,j): t = A[i] A[i] = A[j] A[j] = t def transvection(A,i,j,x): # si vecteur if type(A[0]) != list: A[i] ...
d863424ef7c219cf54fdf3a75670306d5d41279b
Costadoat/Informatique
/DS/Annees_precedentes/2022-2023/DS02/Code_questions/q04.py
257
3.5625
4
### Donnée ### compteurs=[] for ligne in lignes[1:-1]: data=ligne.split(';') if [data[0],data[1],data[7],0] not in compteurs: compteurs.append([data[0],data[1],[float(d) for d in data[7].split(',')],0]) # Question 4: print(len(compteurs))
ddcabe026f0de4df7d0a57dfd0e6329a7f3a4fcc
ljz888666555/eventlet
/eventlet/proc.py
23,001
3.59375
4
""" This module provides means to spawn, kill and link coroutines. Linking means subscribing to the coroutine's result, either in form of return value or unhandled exception. To create a linkable coroutine use spawn function provided by this module: >>> def demofunc(x, y): ... return x / y >>> p = spaw...
85c5a5f685f00a5dead0c0def75983f49ad42999
ElvisZYang1110/Battle-Battle-
/battle.py
7,936
3.796875
4
from referential_array import ArrayR, T from stack_adt import ArrayStack from queue_adt import CircularQueue #CircularQueue from army import Army class Battle: def __init__(self): # time complexity: min and max O(1) pass def gladiatorial_combat(self, player_one: str, player_two:...
51a07fb7713968b2c41f7b8b23cc0e7541260382
akshat-harit/ds-algo
/sort/merge_sort.py
999
3.984375
4
import random def merge(array1, array2): result=[None]*(len(array1)+len(array2)) index1 = 0 index2 = 0 for i in range(len(result)): if index1 == len(array1): result[i] =array2[index2] index2+=1 elif index2 == len(array2): result[i] = array1[index1] ...
d33e7d7d1f68a8dd96d3ecb7613b8904342d74a9
lanngo27/data-structures-algorithms
/bst_remove/bst.py
5,752
4.4375
4
''' In this exercise, you are given an implementation of a binary search tree. The class ``BST``, found in the exercise package, contains the methods ``insert`` and ``find`` which can be used for inserting and finding key-value pairs. These methods utilize two recursive helper methods ``_inserthelp`` an...
80f2a25bc82b729418f5d2b71ae1cabd09b4221b
songyang-dev/comp520-golite
/prettyChecker.py
911
3.84375
4
#!/usr/bin/python3 from __future__ import print_function """ This script compares the content of two files. It prints to stderr if the two files are not the same """ import sys # taken from # https://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python def eprint(*args, **kwargs): print(*args, f...
3f7e2ad8ac3e001c148d5ff45e6fdd50ec113013
keisukee/atcoder
/20210313/contestC.py
1,651
3.625
4
# 問題文 # 高橋君は整数を書くとき、下から # 3 # 桁ごとにコンマで区切って書きます。例えば # 1234567 # であれば 1,234,567、 # 777 # であれば 777 と書きます。 # 高橋君が # 1 # 以上 # N # 以下の整数を # 1 # 度ずつ書くとき、コンマは合計で何回書かれますか? # 制約 # 1 # ≤ # N # ≤ # 10 # 15 # N # は整数 N = int(input()) def calcComma(N): totalCount = 0 num = 1 boundary = 1000 nextBounda...
fcb3f508c39446e95d814f14bad409b181d8298f
NHRD/Atcoderpractice
/Atcoder_problems/ABC002/atcoder_wana.py
139
3.59375
4
w = input() res = "" for i in range(len(w)): if w[i] not in ["a", "i", "u", "e", "o"]: res = res + w[i] print(res)
75be059044328106003362c637a1ec68ba0685ee
NHRD/Atcoderpractice
/AOJ_courses/ITP1_3_B.py
196
3.515625
4
num = 0 cases = [] a = 0 while True: a = int(input()) if a == 0: break cases.append(a) a = 0 for i in range(len(cases)): print("Case {}: {}" .format(i + 1, cases[i]))
64c3ab0c7abc99f4ca3051101d888de25577d1f4
NHRD/Atcoderpractice
/atcoder_interactive_sorting.py
2,111
3.875
4
from string import ascii_uppercase def comp(a, b): print("? "+a, b) return input() def sort5(l): a, b, c, d, e = l if comp(a, b) == ">": a, b = b, a if comp(c, d)== ">": c, d = d, c if comp(a, c) == ">": a, b, c, d = c, d, a, b if comp(c, e) == "<": if comp(d...
e11a6e52453c8de32c1431bc41d0b322c7faf863
NHRD/Atcoderpractice
/AOJ_courses/ITP1_9_A.py
319
3.578125
4
word = input() sents = "" while True: sent = input() if sent == "END_OF_TEXT": break sents = sents + " " + sent words = list(map(str, sents.split())) counts = 0 for w in words: w = w.lower() if w[len(w) - 1] == ".": w = w[:-1] if w == word: counts += 1 print(counts)
4939c89eb77c8a096fcb6983c24ac411a8f521e0
N-Shiva-Ganesh/Olympics_Codes
/171046026_N.ShivaGanesh/Ques_4.py
363
3.765625
4
#Top 10 Medalists import pandas as pd import matplotlib.pyplot as plt import numpy as np frame = pd.read_csv('summer.csv') df = frame.Athlete.value_counts(ascending = False) print (df.head(10)) df1 = df.head(10) df1.plot(kind = 'bar', color = 'grgggrgrr') plt.xlabel('Athlete Name') plt.ylabel('No of Medals Won') plt...
026378213df98006a4a2f5c2ba76c9a482ea93c1
N-Shiva-Ganesh/Olympics_Codes
/171046026_N.ShivaGanesh/Ques_1.py
393
3.84375
4
#Which olympics had the most medals won? import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.read_csv('summer.csv') counts = df.Year.value_counts(ascending=True) y = sorted(set(df.Year)) df1 = pd.DataFrame(counts,y) #print(df1.head()) df1.plot(kind = 'bar') plt.xlabel("Year") plt.ylabel(...
a5f67d2b153cec410fb337c38e87f595f39ba975
ComradYuri/Graphs-Basic_Graph_Search
/script.py
2,529
4.21875
4
# recursive dfs function. DFS is a quick way to check IF there is a route between A and B def dfs(graph, current_vertex, target_value, visited=None): if visited is None: visited = [] # creates path of visited vertices visited.append(current_vertex) # base case if current_vertex is target_v...
e13e82f12e1b9658ec1e3564a49ad53a8d583fd5
abohashem95/Uri-Online-Judge
/1014_consumption.py
287
3.71875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 18 21:46:18 2020 @author: abohashem """ def Consumption(): x = int(input()) y = float(input()) consumption = x/y print("{:.3f} km/l".format(consumption)) Consumption()
c89883156c7044408122b1ab8b0bc6b3c15ba911
abohashem95/Uri-Online-Judge
/1011_sphere.py
259
4.125
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 17 13:30:05 2020 @author: abohashem """ def sphere(): pi = 3.14159 r = float(input()) volume = (4/3) * pi * (r**3) print("VOLUME = {:.3f}".format(volume)) sphere()
7ca317c0bcc2d58d9fb8bcb678e10fc8ad27c067
subratsinha/Python-Programming
/Function Overloading/addnum.py
140
3.78125
4
def addition(*num): count=0 for i in num: count=count+i print (count) addition() addition(10) addition(10,20,30)
f3c7cd96c7d3996adc0a0a40a812bd62e673e332
daalgi/data-structures
/tests/test_priority_queue.py
7,112
3.53125
4
import unittest from priority_queue import PriorityQueue, parent_node_index class Test(unittest.TestCase): def test_parent_node_index(self): i = 0 p = parent_node_index(i) self.assertIsNone(p) i = 1 p = parent_node_index(i) self.assertEqual(p, 0) i = 2 ...
3225246f627bf33202efe2d18fa5f771bf34c57c
pavdemesh/hackerrank
/day_08_dicts_maps.py
1,682
3.859375
4
"""Input Format The first line contains an integer, n , denoting the number of entries in the phone book. Each of the subsequent lines describes an entry in the form of 2 space-separated values on a single line. The first value is a friend's name, and the second value is an 8-digit phone number. After the n lines of p...
f1a55afd5ba74a1c9d444c664148903f1b5f3a9c
FelipeLarsen/SocketWithPY
/Socket.py
266
3.640625
4
#!/usr/bin/python import socket ip = raw_input("Digite o IP: ") port = input("Digite a porta: ") mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if mysocket.connect_ex((ip, port)): print "- status [FECHADA]" else: print "- status [ABERTA]"
a67f8e635e05401807ca52bfe537027c293e4872
gurveerdhindsa/facial-recognition
/main.py
887
3.84375
4
# import OpenCV import cv2 def grayscale(img): """Apply a grayscale filter to an image""" return cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) def detectFacesWithRectangle(img, faces): """Draw a rectangle around faces found""" for (x, y, w, h) in faces: cv2.rectangle(img, (x, y), (x + w, y + h), (25...
c74aba28ac9bc2cb8c2a9f50ea5cdaf871b98a3f
jlincollective/graph-project
/connected_components.py
1,184
3.65625
4
from graph_constructor import GraphConstructor class ConnectedComponents: def __init__(self, file_path): self.constructor = GraphConstructor() self.graph = self.constructor.construct_graph(file_path, directed=False) # returns the number of connected components in the graph def num_connect...
15006428839460d35fac7418ab7ae615e4827fdc
uberalex/spacepirates
/engine.py
2,376
3.53125
4
import pygame, sys, math from pygame.locals import * from pygame.sprite import Sprite class Ship(Sprite): def __init__(self, name): #superclass constructor Sprite.__init__(self) #create the surface for the image self.surface = pygame.Surface([180,57]) self.surface.fill((25,...
f791b9d73fee8ee816dc32d7d118ed9fbf2410fb
surajkarki66/Advance-Python
/sockets/Web Status/app.py
1,058
3.546875
4
from status import Status class Menu: def __init__(self): self.status = Status() self.choices = { "1": self.show_ip, "2": self.show_page, "3": self.quit } def display(self): print(""" Menu 1. Show the ip address 2...
18cd33f760ccd599ef0943fe1e4bd3f34b2bde44
surajkarki66/Advance-Python
/decorators/decorator_class.py
607
3.671875
4
class decorator_class(object): def __init__(self, original_function): self.original_function = original_function def __call__(self, *args, **kwargs): print("Call method executed this before {}".format( self.original_function.__name__)) return self.original_function(*args, **...
6583c8ed2286a823363b32b7d9e14f39409b3117
surajkarki66/Advance-Python
/sockets/server.py
782
3.578125
4
import socket class Server: Host = '127.0.0.1' Port = 65432 def __init__(self): self.s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.s.bind((Server.Host,Server.Port)) # associate the socket with a specific network interface and port number self.s.listen() ...
e50ac29fb5f4af34218385b4c80ef6566ebc6430
IhopRocks/Jeopardy
/msgbox-example.py
2,250
4.28125
4
import dialog import sys def handle_exit_code(d, code): """Sample function showing how to interpret the dialog exit codes. This function is not used after every call to dialog in this demo for two reasons: 1. For some boxes, unfortunately, dialog returns the code for ERROR when the user pr...
6c2fd4e041ccb788858c41639aa748a262eb9dc7
khjtony/Proj_Python
/PHY102/Lab 6/lab_6.py
6,763
4.0625
4
# lab_6.py # # Author:He Bai # Student ID:997677931 # # This library was written as part of Physics 102: Computational Laboratory # in Physics, Fall 2014. # import required libraries import math import numpy as np import scipy.integrate as integrate import matplotlib matplotlib.use('TKAgg') import matplotlib.pyplot as...
cd1e5b32f1f40236e90346c4ada6d0f355ebd23d
Dishit79/DisPydactyl
/dispydactyl/responses.py
2,488
3.921875
4
"""Classes used for creating responses.""" class PaginatedResponse(object): """An iterable API response that returns paginated results.""" def __init__(self, client, endpoint, data): self._client = client self._initial_data = data['data'] self.data = data self.endpoint = endpo...
cf10016016ae364d702ac73062bec74b066bdcbb
Gammaalpha/udemy-ds-and-a-in-python
/data-structures-and-algorithms/binary-search.py
1,630
4.09375
4
"""You're going to write a binary search function. You should use an iterative approach - meaning using loops. Your function should take two inputs: a Python list to search through, and the value you're searching for. Assume the list only has distinct elements, meaning there are no repeated values, and elements are in...
0eb3865fff644108f65a82ba65afd427b3bb92ec
GabrielaPC/Simulador
/simulacao.py
7,098
3.53125
4
from random import randint,random from arquivo import * from operacao import * ## armazena informações sobre cada simulação class simulacao: def __init__ (self,n,nome_arq=""): if nome_arq !="": self.arq = arquivo(nome_arq) self.n = self.arq.n # quantidade de qbits ...
5366d79eff0421df99ad097f4f5aba08a58c8cd3
DasHache/Pacman
/graphicsShapesExt.py
1,538
3.6875
4
class Shape(): def __init__(self, canvas, pos): self.c = canvas self.x = pos[0] self.y = pos[1] self.color = 'black' self.size = 10 self.items = [] self.__draw__() def __draw__(self): pass def __delete__(self): for l in self.items: ...
40f85c4ee9c0f43c2d4d41f878dee2d7c058a774
kajal8512/python
/meraki_q1.py
2,210
3.90625
4
# names_list= ["rahul","rohit","ishita","shivani","sonam"] # print(names_list) # print (type(names_list)) # visit_list=["canada","new york","london england","Bangloar"] # print(visit_list) # expense_list=["jan",2000,"feb",3000,"march",4000,"April",5000] # print(expense_list) # mixed_list=["ronak",24,2.5,"komal","aka...
9d5922f738077030628900a9b3818ddf40935b6e
kajal8512/python
/common.py
178
3.734375
4
list= [1, 1, 3, 4, 5, 6, 7] list1=[0, 1, 2, 3, 4, 5, 7] list2=[0, 1, 2, 3, 4, 5, 7] i=0 k=[] while i<len(list): a=list[i]=list1[i]=list2[i] k.append(a) i+=1 print(k)
b2bb2caafdb862cb593d621be1f0b0701564e26f
kajal8512/python
/KBC.2.PY
927
3.9375
4
print("Welcome to K.B.C...\U0001F911..\U0001F911") quest_l=["What is the capital of up?", "Which is the largest temple in the Delhi?", "who is the finance minister of India?"] option_l=[["lukhnow","Gorakhpur","Kanpur","Delhi"], ["nilam mata","lotus","yogmaya temple","Akshardham temple"], ["Narendra Modi","Kejarival","...
286add6838b4c856fb160e6eadebca9d470e1680
antonkuzmenkov/Home_work
/Lesson_01/Home_task_1.py
3,838
4.03125
4
# 1. Поработайте с переменными, создайте несколько, выведите на экран, # запросите у пользователя несколько чисел и строк и сохраните в переменные, выведите на экран. a = int(input()) b = input() c = int(input()) d = a + c print(b, c, a, d) ########################################## # 2. Пользователь вводит время в ...
b18b80d6d8892ca43394061b41cfca983328eb27
ayyelle/CodeEval-Solutions
/StepwiseWord.py
688
3.734375
4
#I solved the Stepwise word challenge on @codeeval. #programming #hiring http://www.codeeval.com/browse/202 import sys with open(sys.argv[1], 'r') as test_cases: for test in test_cases: inputList = test.strip().split(" "); maxIndex = 0; for i in range(0,len(inputList)): if (len(...
c51727bcd61844fe41b15939545e9a3ccea8767f
ayyelle/CodeEval-Solutions
/HiddenDigits.py
652
3.59375
4
#I solved the Hidden Digits challenge on @codeeval. http://www.codeeval.com/browse/122 import sys test_cases = open(sys.argv[1], 'r') for inputString in test_cases: inputString.strip(); dictionaryValues = {"a":0,"b":1,"c":2,"d":3,"e":4,"f":5,"g":6,"h":7,"i":8,"j":9} listofKeys = dictionaryValues.keys(); ...
02fcaab7d01b27130ebe67a8cbbc03b1f6a289de
MCoyne01/Chapter_8
/Challenge 2.py
928
3.921875
4
class Television(object): def __init__(self, volume, channel): self.volume = volume self.channel = channel def volumeUp(self): volume = self.volume volume += 1 return volume def volumeDown(self): volume = self.volume volume -= 1 return volum...
5df949949327cd80d4945cd5461cde35ff3fcc52
Kebsiula2007/Klasa-2
/Klasa 2/zajecia 8/lotto.py
2,404
3.78125
4
from random import randint class Lotto: def __init__(self): self.__wylosowane_liczby = [] self.losowanie() def losowanie(self): for _ in range(6): liczba = randint(1, 49) while liczba in self.__wylosowane_liczby: liczba = randint(1, 49) ...
7297348301586afd8daab9db92ee18bd26c3e838
liyi-1989/neu_ml
/code/data/sample_polynomial.py
2,181
4.3125
4
import numpy as np def sample_polynomial(n_points=1, cos=None, domain_range=None, var=0, domain_locs=None): """Randomly sample a (noisy) polynomial This function is used to generate random noisy samples from a polynomial. The user can specify the coefficients of the desired polynomia...
2c58d1318a9c9a36399351ff47c886ac1fb8fc24
addrob/practicepython
/ex4.py
223
3.90625
4
def divisors(number): x = range(1, number+1) divisors_list = [] for n in x: if number%n == 0: divisors_list.append(n) return divisors_list number = int(input()) print(divisors(number))
230feeb423c8661f7a85fe6e4ac241f2bcb2ab71
j-tyler/learnProgramming
/LearningGo/py-strings-q4.py
565
4.5625
5
#!/usr/bin/env python # 1. Create a program that counts the number of characters in the string: # This is a String. # 2. Change the 3 runes at position 4 to abc # 3. Reverse the string s1 = "This is a String." s2 = "abc" print(s1) print("The number of characters =", len(s1)) s1 = s1[0:4] + s2 + s1[7:] print(s1) # ...
1a6185e56f3a3e864a4e0ff9b4bed86c3ed4bf98
mendescelso/APRENDENDOPYTHON
/equacao.py
445
4.0625
4
# -*- coding:utf-8 -*- print("#-----Vamos calcular as raízes de uma equação do segundo grau -----#") a = float(input("Digite o coeficiente a= ")) b = float(input("Digite o coeficiente b= ")) c = float(input("Digite o coeficiente c= ")) delta = b ** 2 - 4*a*c print("delta = ", delta) raizdelta=delta ** 0.5 print...
08112961ad72f13fe40e5c5e0fc0973af2144987
egaoneko/dsar
/donghyun/data_structure/Algorithms/Sort/RadixSort/RadixSort.py
815
3.625
4
# -*- coding: utf-8 -*- __author__ = 'Donghyun(egaoneko@naver.com)' __version__ = '1.0' import Queue def RadixSort(l): buckets = list() maxLen = len(str(max(l))) divfac = 1 # Init Buckets for i in range(10): buckets.append(Queue.Queue()) # Longest data length for pos in range(m...
a0d8e7ded22a9b58842262912ebf49c569a78998
egaoneko/dsar
/jisung/list/Linkedlist_norm.py
2,744
3.828125
4
__author__ = 'jeonjiseong' #node = dict(0:"value") class node: def __init__(self,data=None,nextNode=None): self.data = data #self.preNode = preNode self.nextNode = nextNode def __str__(self): return 'Node ['+str(self.data)+']' class LinkedList: def __init__(self): ...
8c97e2e0aa190f8b9197257e2f6c5ca93fa5b1b6
SinigribovS/Introducere_Afi-are_Calcule
/8.py
152
3.8125
4
a=int(input("Dați un nr: ")) b=int(input("Dați un nr: ")) c=int(input("Dați un nr: ")) print(a,c,b," ",a,b,c," ",c,b,a," ",c,a,b," ",b,a,c,sep="")
82112852bb310a64e2593213d49a0ec9e1f6c9de
Jawwad18B/LAB-10
/Programmin Exercise LAb 10 Q1.py
322
3.5625
4
print('Jawwad 18b-007-CS(A)') print('LAB10 Programming Exercise q1') dict = {'father':'Wayne','mother':'MRs Wayne','Me':'Rooney'} print(dict) dict['Maternal Grand Father'] = 'Jim' dict['Maternal Grand Mother'] = 'Mrs Jim' dict['Paternal Grand Father'] = 'Alex' dict['Paternal Grand Mother'] = 'Mrs Alex' print(di...
d6b06b96f63c9b8b641eb9e4832b81cbdd35d00a
Shivanshprogramer/space-invaders
/space_invaders_group.py
8,570
3.671875
4
from pygame import * import random init() width = 1200 height = 720 screen = display.set_mode((width, height)) display.set_caption("Space Invader") invaderImage = image.load('alien.jpg') lives_image= image.load('heart.jpg') playerImage= image.load('ship.png') #colors palette BLACK = ( 0, 0, 0) WHITE = (255, 255, 2...
7aa57d8c068be44bcb0fd1d0aeffa0dcdd69b671
alexandrafren/ds-graphs
/ud_graph.py
11,574
3.96875
4
# Course: CS261 - Data Structures # Author: Alexandra Fren # Assignment: Six # Description: This program creates an undirected graph, with methods to add a vertex or edge, remove a vertex or edge, # get a list of all vertices or edges, do a dfs or bfs, check if a passed path is valid, check for cycles, and returns # th...
80918e7001e5460d8e77292245b0c8e812d3cfab
Tsibulnikov/Checkio_tasks
/Home/Sum Numbers.py
2,000
4.1875
4
''' In a given text you need to sum the numbers. Only separated numbers should be counted. If a number is part of a word it shouldn't be counted. The text consists from numbers, spaces and english letters Input: A string. Output: An int. Example: sum_numbers('hi') == 0 sum_numbers('who is 1st here') == 0 sum_numbe...
1587102fca36392101b37f7a5936cff82f133162
Tsibulnikov/Checkio_tasks
/Elementary/Is Even.py
1,039
4.40625
4
""" Check if the given number is even or not. Your function should return True if the number is even, and False if the number is odd. Input: An int. Output: A bool. Example: is_even(2) == True is_even(5) == False is_even(0) == True How it’s used: (math is used everywhere) Precondition: both given ints should be be...
0e75eab69eb74d9b5c9e6ea16ebc10342b0dfc9e
zkbt/transit2pi-experiments
/transit2pi/planetplotlib.py
2,427
4.09375
4
''' This is a small set of tools that extends matplotlib to be a bit better for making plots that look nice in a planetarium dome. ''' from __future__ import print_function import matplotlib.pyplot as plt import numpy as np def create_dome_plot(dpi=100, hideticks=True): ''' This function creates a matplotlib...
ea5c1376aa5e0906de30bb24ec2eda0c2a544983
tessied/turtle_crossing
/car_manager.py
1,027
3.765625
4
from turtle import Turtle import random COLORS = ["red", "orange", "yellow", "green", "blue", "purple"] STARTING_MOVE_DISTANCE = 5 MOVE_INCREMENT = 0.5 class CarManager: def __init__(self): self.all_cars = [] self.car_speed = STARTING_MOVE_DISTANCE def new_car(self): car = Turtle(sh...
6a7a5770d70fdf6c9c6c1d860cba2ee829b22064
Khristofor11/algorithms
/task2.8.py
346
3.578125
4
a = int(input("Сколько будет чисел? ")) b = int(input("Какую цифру считать? ")) count = 0 for i in range(1, a + 1): m = int(input("Число " + str(i) + ": ")) while m > 0: if m % 10 == b: count += 1 m = m // 10 print(f'Цифра {b} встетилась {count} раз')
b3bc41cf61f9590b1250940c3dd475c282f8dd6b
lmbonnefont/design_patterns
/patterns/decorator.py
1,416
4.21875
4
# Decorator design system from abc import ABC class Beverage(ABC): def cost(self): raise NotImplementedError class Coffee(Beverage): def cost(self): return 4.3 class Espresso(Beverage): def cost(self): return 3 class BeverageDecorator(Beverage): def __init__(self, beverage...