blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3246b2551a80c79a137c52714ead55ee3b813bca
sudhirshahu51/projects
/Assignment/Assignment-1/11. Prime or not.py
350
4.21875
4
# To find a given number is prime or not print("enter the no. to be checked of prime or not") n = float(input()) f = 0 x=int(n/2) for i in range(2,x): if n % i == 0: f = f + 1 else: continue if f == 0: print('the given no. is prime') else: print('the given no. is not prime')...
6077a1ab4bcd3a8e66387ddc224f66856adfe76a
Calahown/ML_python
/ex5/ex5.py
5,698
3.875
4
import scipy.io import matplotlib.pyplot as plt import numpy as np from scipy.optimize import minimize def main(): # =========== Part 1: Loading and Visualizing Data ============= print("Loading and Visualizing data") data = scipy.io.loadmat('ex5data1.mat') X = data['X'] y = data['y'] Xtest = data['Xtest'] ...
3afd23eaee221a1fa3dd056afe4ae877361f7c7f
finbarr91/Mnist-datasets-on-Neural-networks
/code.py
3,913
3.515625
4
# Mnist-datasets-on-Neural-networks keras, python, tensorflow # Importing the library import keras import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn from keras.datasets import cifar10 from keras.layers import Conv2D, MaxPooling2D, AveragePooling2D,Dense, Flatten,Dropout from keras.op...
6579329fbf0d40a8a456c10b65e31b2061606f97
brarajit18/Credit-Card-Fraud-Detection
/analyzeData3_New.py
17,019
3.984375
4
# -*- coding: utf-8 -*- """ Credit card fraud detection This notebook will test different methods on skewed data. The idea is to compare if preprocessing techniques work better when there is an overwhelming majority class that can disrupt the efficiency of our predictive model. You will also be able to see how to appl...
939c202d8e9192f0b1791223268bfbbd09337488
brunoharlein/training_Python
/test5.py
231
3.890625
4
import math age = int(input("votre age")) if age <= 0 : print("erreur") if age >= 21 : print("ok") if age%2 == 0: print("age pair") else: print("pas pair") if math.sqrt(age).is_integer(): print("age carré")
c77bb34bfb35479082a1e79cf8e8c51c77fda1a6
FrancescoSRende/FrancescoSRende.github.io
/Python Contest Questions/CCCProblems/speedFinesAreNotFine_CCC.py
346
4.125
4
limit = int(input()) speed = int(input()) diff = speed - limit if diff <= 0: print("Congratulations, you are within the speed limit!") elif 1<= diff <= 20: print("You are speeding and your fine is $100.") elif 21<= diff <= 30: print("You are speeding and your fine is $270.") else: print("You are speedin...
7facec59b3bf9c4f3b018dfb96456dfd8a55d197
charlesdong/cpppp6py
/3/4.py
251
4.03125
4
secs = int(input('Enter the number of seconds: ')) temp = secs N1 = 60 N2 = 24 s = temp % N1 temp //= N1 m = temp % N1 temp //= N1 h = temp % N2 temp //= N2 d = temp print('%d seconds = %d days, %d hours, %d minutes, %d seconds' % (secs, d, h, m, s))
d1ccd1750f1be2fcbc9cfe2ee8b0dd306a8f0cc9
pohily/checkio
/skew-symmetric-matrix.py
298
3.796875
4
def checkio(matrix): for i in range(len(matrix)): for j in range(len(matrix)): if matrix[i][j] != -(matrix[j][i]): return False return True print(checkio([ [0, 1, 2], [-1, 0, 1], [-2, -1, 0]])) """ """
a43d47eb46b1b88f973b36525c6d93ab04a2d497
strycore/game-of-life
/engine/game.py
996
3.546875
4
class World(object): def __init__(self, seed): self.cells = seed def cell_at(self, position): return position in self.cells def _iter_cells(self, position): for x in range(-1, 2): for y in range(-1, 2): yield (position[0] + x, position[1] + y) def n...
7e12ea03cc19d7fb0ab6e121578252d9913a7d27
lufffffeng/ai-navigation
/cart_planning/scripts/simple_gps_util.py
3,327
3.59375
4
#!/usr/bin/env python import math import numpy from geometry_msgs.msg import Point """ This file is a modified version of the AlvinXY method produced by WHOI """ def latlon2xy(lat, lon, lat0, lon0): x = (lon - lon0) * mdeglon(lat0) y = (lat - lat0) * mdeglat(lat0) return x, y def xy2latlon(x, y, lat0...
d8f941c49bada52d2866f5f4da1c502e1064d00c
sungheeyoon/quizPy
/baekjoon/10818.py
321
3.609375
4
numbers = int(input ()) number_list = list(map(int,input().split()[:numbers])) max_number = number_list[0] min_number = number_list[0] for number in number_list: if(max_number <= number): max_number = number if(min_number >= number): min_number = number print("%d %d" % (min_number, max_number))...
cad727c9623a524769fe6f524bc2a3b295d15d6d
knair99/python_teaching_meetup
/fibonacci.py
621
3.578125
4
#x: 1 2 3 4 5 6 7 #fib(x): 1 1 2 3 5 8 13 #fib(x) = fib(x-1) + fib(x-2) def fib(x): if x <= 2 : return 1 result = fib(x-1) + fib(x-2) return result print fib(7) def add_data(*args): sum1 = 0 for each in args: sum1 = sum1 + each print args lis = list(args) print lis lis.append(sum1) return ...
0c9dffbeb2d16f36ade2654b4439803abd77bd4e
billykim618/Python
/Chapter 4 - Selections/DayOfWeek.py
932
3.9375
4
import math year = int(input("Enter year (e.g., 2018): ")) m = int(input("Enter month (1-12): ")) if m == 1: m = 13 year -= 1 if m == 2: m = 14 year -= 1 q = int(input("Enter day of the month (1-31): ")) j = (year // 100) k = year % 100 h = (q + ((26 * (m + 1)) // 10) + k + (k // 4) + (j // 4) + (5 *...
95ce1b3e6095158d7cf5c47ae58d70b0093d772f
BeeNeal/data_structures
/buy_and_sell_stock.py
703
4.09375
4
# lesson learned - when might think an O(n^2) is necessary, see if you can # simply hold onto the current comparable value, and go down to O(n) def max_stock_profit(prices): """Take in list of stock prices, return max profit possible from 1 trade >>> max_stock_profit([7,1,5,3,6,4]) 5 >>> max_stock...
6a667f9e687ef3df3a7c12710db74fa1b905d569
raman934/python-2019
/ce28.py
240
4.125
4
# RG # 3.5 N = int(input("Enter value of N :\n")) num1 = 0 num2 = 1 print(num1, end=' ') print(num2, end=' ') num = 0 while (num1 + num2) < N: num = num1 + num2 print(num, end=' ') num1 = num2 num2 = num
05b5e559852315b9e29b9ac2137b4dbed3ea9437
nehertz/algorithm-implementations
/search_in.py
3,887
4.28125
4
import os import re """ Helper functions that collect input for searches """ def manual_in(): """ Reads and returns user-entered input list and search term from command line """ confirm = 'n' while (confirm == 'n'): # Collect input in_str = input("> Please enter a list of numbers, charac...
cd6271e0037e72f37b81ecbed68cbe3fc6357c82
kanishkagarwaal/Object_Oriented_Programming
/OOP.py
3,835
4.4375
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 3 11:38:05 2018 @author: kanagarw """ #objects have attributes and methods #classes are factories that create objects. Blue prints #class names follow camel casing class NameOfClass(): def __init__(self, param1, param2): self.param1=param1 sel...
c3ecae9f7f6b2b43b321b33a682b711bf920e298
mmweber2/adm
/selection_rank/select.py
2,197
3.984375
4
from time import sleep def get_rank(array, k, start=0, end=None): """Returns the kth smallest item in array. Args: array: list of comparable items to search. Does not need to be in sorted order, and duplicate elements are permitted. This function modifies the list. k: ...
61948bcd87234d6459e4bf3c882571d5077a6f06
sajjo79/Design_and_Analysis_of_Algorithms
/Code/11-RandomizedQuickSort.py
758
3.671875
4
# The algorithm is code by # Ishtiaq Ahmed - MSCS ISP Multan def Partition(A, p, r): x = A[r] i = p-1 for j in range(p, r): if A[j] <= x: i = i+1 A[i], A[j] = A[j], A[i] A[i+1], A[r] = A[r], A[i+1] return (i+1) def Randomized_Partition(A,p,r): from r...
acd24f7c48532db26a37511b5cb88cf4157ca2c0
otherland/python-challenges
/Challenges/LadyBugs.py
677
3.65625
4
from collections import Counter def solution(board): cells = [0] + [i for i in board if i.isalpha()] + [0] c = Counter(cells) if any(i < 2 for i in c.values()): return "NO" for i in range(1, len(cells)-1): if (cells[i-1] != cells[i]) and (cells[i] != cells[i+1]): if not "_" ...
f097a30fa017b3ac0fb9551a2550aa0ee7716ece
mageecd/Socket-Programming
/ClientSocket.py
1,051
3.875
4
"""This is the Client Side for my networking socket programming project. Socket project guide: https://www.techbeamers.com/python-tutorial-essentials-of-python-socket-programming/""" import socket def Main(): host = '127.0.0.1' #localhost #host = '165.22.150.177' #server should be at this IP port = 4001 #s...
d5f9a4baed73112fdc0c4269b0950af9312d5f54
blankxz/LCOF
/数据流中的中位数/hello.py
1,015
3.671875
4
class MedianFinder: def __init__(self): """ initialize your data structure here. """ self.arr = [] def addNum(self, num: int) -> None: if not self.arr: self.arr.append(num) else: ind = self.binary(0,len(self.arr),self.arr,num) ...
e7e8bbd3917ae3be05093f32a85b4696356de831
TheAlgorithms/Python
/dynamic_programming/edit_distance.py
3,423
3.84375
4
""" Author : Turfa Auliarachman Date : October 12, 2016 This is a pure Python implementation of Dynamic Programming solution to the edit distance problem. The problem is : Given two strings A and B. Find the minimum number of operations to string B such that A = B. The permitted operations are removal, insertion...
5621e4fe70236d9bf44079987a3b75e369830190
ioneliabuzatu/TicTacManu
/playGame.py
9,088
3.640625
4
"""Tic Tac Toe Game between two lovers: input()""" import random import argparse import tqdm import numpy as np import matplotlib.pyplot as plt from copy import deepcopy import functools # import pandas as pd import os.path import functools def pick_random_move(board): row = random.randint(0, 2) column = rand...
15e937a4e52027fb87101f8e1153aa4e3833af13
zhengwen-w/Machine-Learning
/bm_classify.py
5,801
3.84375
4
import numpy as np def binary_train(X, y, loss="perceptron", w0=None, b0=None, step_size=0.5, max_iterations=1000): """ Inputs: - X: training features, a N-by-D numpy array, where N is the number of training points and D is the dimensionality of features - y: binary training labels, a N dimension...
f5e3bbfdcf86edb20d39420e7a845546f44bfbc6
Cr0n1c/google_foobar
/dont_get_volunteered.py
1,984
3.6875
4
# Work in progress... accidentally forgot to submit during 72 hours class UnitTest: def __init__(self, src, dst, expected_result): self.src = src self.dst = dst self.expected_result = expected_result def find_point(number): x = number / 8 y = number % 8 coordinate = (x, y) ...
832ed6836b116e64315210423704f622f2de7cd1
sagynangare/advanced_practice
/Coding_Test/que-3.py
425
3.578125
4
"""Write the code to Initialize a dictionary in python and save json of the dictonary in a file?""" exDict = {} exDict['Sagar']={ 'name':'Sagar', 'address':'Mumbai, MH', 'phone':9094785475 } exDict['Vinay']={ 'name':'Vinay', 'address':'Pimpri,Pune, MH', 'phone':9092346534 }...
26c760e397dea82d004f902af3c90c54df3ee14c
shike-me/python
/test/ex1.py
716
3.765625
4
#!/usr/bin/python # Filename: ex3.py print "I will now count my chickens:" print "Hens", 25+30/6 print "Roosters", 100-25*3%4 print "Now I will count the eggs:" print 3+2 + 1 - 5 +4%2 - 1 / 4 + 6 print "Is it ture that 3+2<5-7?" print 3 + 2 < 5 - 7 print "What is 3 + 2?", 3 + 2 print "What is 5 - 7?", 5 - 7 pr...
dd93f1cd33fbb6496b019a2ee3b0684921efbef3
jihun-yoon/cv-utilities
/scripts/utils/json_handler.py
594
3.609375
4
import json def dump_json(save_fpath, data): """Dump json. Args: save_fpath (str): json file path to dump data data (dict): data to dump """ with open(save_fpath, "w") as write_f: json.dump(data, write_f) print(f"json has been dumped : {save_fpath}") def load_json(load_...
d7607001ce36fa09eb292586edd8eb32492262f5
Kevin-Howlett/edabit-problems
/simplify_2.py
761
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 1 03:08:15 2020 @author: kevinhowlett """ #Function returns the simplified version of a fraction def simplify(txt): num_1 = int(txt.split('/')[0]) num_2 = int(txt.split('/')[1]) if num_1 < num_2: smallest = num_1 else: ...
423078766614ba5c4f3596b8475aabd19528999e
IkeyBenz/TradingAlgo
/build_model.py
2,407
3.75
4
''' The plan here is to design an evolutionary stock trading algorithm. Basically the idea is that if we have thousands of randomly generated "trading strategies," and test them all out in the stock market, we'll be able to see which strategies worked the most, and so we can then redo the simulation but this time the t...
6e2e03cbf6574af57ac9bbf63195172bfe14a2d8
cclandrew/s362f_project
/online_shopping/init.py
1,470
3.53125
4
import sqlite3 conn = sqlite3.connect('shop.db') cur = conn.cursor() ### PRODUCTS # cur.execute("""CREATE TABLE products( # productID integer, # productDesc text, # unitPrice integer, # quantityInStock integer # )""") # cur.execute("INSE...
e2a3e2023ba9bc567ce9c9d381886fadf4dda465
daniel-reich/ubiquitous-fiesta
/z9tnydD5Fix3g3mas_18.py
705
3.53125
4
def check_pattern(lst, pattern): d={} z="" m=[] for l in range(len(lst)): for e in lst[l]: z=z+str(e) if l==len(lst)-1: if z in d.keys(): if d[z] != pattern[l]: return False else: break else: if pattern[l] in m and z not in d.keys(): ...
c051b679defe8d4fb2bc30634865ff5eb7e79c91
ihf-code/python-bites
/rock-paper-scissors/code/5.py
824
4.03125
4
import random print("Welcome to Rock, Paper, Scissors") user_choice = input("What is your move? (rock, paper, scissors) ") computer_choice = random.choice(["rock", "paper", "scissors"]) print("You picked " + user_choice) print("The computer picked " + computer_choice) if user_choice == "rock": if computer_choic...
c18d402cadade7b2614c63a5edb47f08f600a5e2
ShantanuBal/Code
/euler_copy/31c.py
622
3.59375
4
import time def brute_force_coin(): step = 0 coin = 200 for i in range(coin,-1,-200): for a in range(i,-1,-100): for b in range(a,-1,-50): for c in range(b,-1,-20): for d in range(c,-1,-10): for e in range(d,-1,-5): ...
fb087a25f972d5c8fc3483ce411e8a59e524a97e
Sophie-WH/exercises
/chapter-5.2/ex-5-15.py
2,423
4.65625
5
from Table import print_three_header # Programming Exercise 5-15 # # Program to find the average of five scores and output the scores and average with letter grade equivalents. # This program prompts a user for five numerical scores, # calculates their average, and assigns letter grades to each, # and outputs the...
11dff24c940ee6f87b6077ab3fe0aed9d6aa137a
wsh231314/IntelligentOperation
/sikuli_StuffContainer/testScripts/testSikuliPy/testPopup.sikuli/testPopup.py
744
3.921875
4
popup("Hello World!\nHave fun with Sikuli!") popError("Uuups, this did not work") answer = popAsk("Should we really continue?") if not answer: pass #exit(1) name = input("Please enter your name to log in:") print "input:", name name = input("Please enter your name to log in:", "anonymous") print "inputPreset:", ...
1a5eeccb8187dae590a1993d2f25fafe8a8862cf
yatingupta10/Coding-Practice
/LeetCode/905_Sort_Array_By_Parity.py
323
3.609375
4
class Solution(object): def sortArrayByParity(self, A): """ :type A: List[int] :rtype: List[int] """ even = [] odd = [] for i in A: if i%2 == 0: even.append(i) else: odd.append(i) return even + ...
9bb719227b705a476eae7aa5fd43a5326cdab3b2
jaipersr/Advanced-Chemical-Reactions
/Project4 - Non Isothermal Reactor/RJHW4.py
16,410
3.546875
4
# -*- coding: utf-8 -*- """ Ryan Jaipersaud Advanced Chemical Reactions 11/1/2018 The following code solves for the concentration profile of hydrocarbons as along the z direction of a non isothermal tubular reactor. The reactor is 95 meters long with a diameter of 0.1 meters. The product of interest is ethyl...
ec827883d04539a7265bd7ff1cc2174afa92b820
pirhoo/python-course-fr
/exercises/23_parsing.py
663
3.625
4
# -*- coding: utf-8 -*- import urllib2 # Si BeautifulSoup n'est pas installé: pip install beautifulsoup4 from bs4 import BeautifulSoup # L'URL pour trouver le pays correspondant à une ip ou un nom de domaine infourl = 'http://ip-api.com/xml/pirhoo.com' # On ouvre l'autre URL et on stock le resultat dans response xml ...
b8d1acf92df7af0f6c84fa220bc5de1ed01649b9
michaelzap94/mz-python
/Tests/assertAndDoctest.py
1,741
4.15625
4
# Example 1 def add_positive_numbers(x, y): assert x > 0 and y > 0, "Both numbers must be positive!" return x + y print(add_positive_numbers(1, 1)) # 2 try: add_positive_numbers(1, -1) # AssertionError: Both numbers must be positive! except AssertionError as e: print(e.__repr__()) # Example 2 def eat_j...
266106ea52ddc9f29b67755f48ceed8de78427e5
Phani-Khandavilli/Code
/Codechef/XYSTR.py
292
3.671875
4
t=int(input()) for _ in range(t): string=input() numPairs=0 length=len(string) i=0 while(i<length-1): # print(i,length) if(string[i]=='x'and string[i+1]=='y'): numPairs+=1 i+=2 elif(string[i]=='y' and string[i+1]=='x'): numPairs+=1 i+=2 else: i+=1 print(numPairs)
82a0ba63cd6242e5d1b745f789572f8ee91a572e
praveshtayal/pinception
/tuples/2978s.py
200
3.640625
4
def differentNames(l): # Please add your code here pass # Main names=input().strip().split() m=differentNames(names) if m: for name in m: print(name, m[name]) else: print(-1)
6a46cd32b4fcf8b26787e48ad84876e425aef810
dm488/Physical_Tic-Tac-Toe_Arduino
/tictactoe.py
3,203
3.6875
4
# Tic Tac Toe import random import sys import serial def emptyBoard(): return [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '] def getBoard(board): # Draw game board print(' | | ') print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3] + ' ') print('---|---|---') print(' ' + board[4] + ' |...
4fdaabca3a004afddb9c4e42dab965c8bf8510d2
will8889/binus
/25-11-2019/no6.py
83
3.6875
4
def palindrome(text:str): return text[::-1] == text print(palindrome("radar"))
c1562872c38c18d61cf4cef070135961b8f94d67
2016jtm2086/manoj-singh
/manoj.py
396
3.859375
4
counter = 100 miles = 1000 name = "manoj" a = b = c = 1 p,q = 10, "ajay" var1 = 5 print a, b, name print var1 str = 'Hello World!' print str # Prints complete string print str[0] # Prints first character of the string print str[2:5] # Prints characters starting from 3rd to 5th print str[2:] # Prints string starting fro...
afd623a0f43beca650e8cc8c39a6c8fae8403c3f
rammsteiner71/Python-practice-3
/parampampam.py
408
3.546875
4
import math def new_point(pi): x = R * (math.cos(pi) ** 3) y = R * (math.sin(pi) ** 3) length = math.sqrt((x_const - x) ** 2 + (y_const - y) ** 2) return round(length, 6), x, y R = 1 x_const = 0.75 y_const = 0 i = 0 answer = 111, 0, 0 while i <= 44: t = i / 7 tmp = new_point...
ff15d3ef3485c643c5267304929bf6640a2b5460
AdamZhouSE/pythonHomework
/Code/CodeRecords/2534/60773/299512.py
234
3.59375
4
s=input() #print(s) s=s[2:len(s)-2] l=s.split("],[") res=[] #print(l) for i in range(len(l)): str=l[i] l1=str.split(",") #print(l1) for j in range(len(l1)): l1[j]=int(l1[j]) res=res+l1 res.sort() print(res)
c36c399ba3d39a375627a27caec88e04d22e534e
clvnkhr/Text-Flappy-Bird
/flap.py
6,216
3.609375
4
#flap.py #Calvin Khor #First game ever! #learned how to use curses, sort with basic lambda function key import copy as cp import time, math, random, curses def newCol(): #make the next column that will appear #height should be the height of the game screen newColumn = ['*' for _ in range(height)] x = random...
207468f9b4c712b4301b688c71a245fa5a71e329
vijaychirag/EcommerceWebsite_V001
/pythonBasics/Oops1.py
1,046
4.25
4
''' # self is keyword : self is a object reference, who is calling you # instance and class variables have a whole different concepts # Constructors is a methods, which is automatically called or created, when we creats objects for any classes # syntax for constructors: __init__(self) # class variables ...
06e94b107a485126b1521fec4fc18bb5452df7ec
paulredman-/word_play
/word_utils.py
1,219
3.5625
4
""" Common routines for analysing words (c) Paul Redman 2014 """ import os import sys import urllib2 import zipfile # make sure we are in the script dir sdir = os.path.dirname(os.path.abspath(sys.argv[0])) os.chdir(sdir) def get_url(url): """ return the contents of a URL """ urlh ...
72a6bb5b1abe0223a7720994216e68d53b1c9c94
zahra-zarrabi/seri_3
/8.py
364
3.59375
4
import turtle import time def draw_shape(turtle, radius, sides): turtle.penup() turtle.sety(-radius) turtle.pendown() turtle.circle(radius, steps=sides) shapes = [(20, 3), (40, 4), (60, 5),(80, 6), (100, 7), (120, 8),(140, 9), (160, 10), (180,11),(200,12)] for shape in shapes: draw_...
2a4aff3b02bfdf40d1ad1fc773f2011e1590c066
Nehr/adventofcode2020
/Day6/day6p2.py
1,005
3.65625
4
#! python3 import os #import re path = os.getcwd() #FILE_NAME = 'day6test.txt' FILE_NAME = 'day6input.txt' theFile = os.path.join(path, FILE_NAME) fileExists = os.path.isfile(theFile) def check_freq(x, group_size): freq = {} for c in x: if c != '\n': freq[c] = x.count(c) return_number ...
a851e326ee220ea9312dee75e207738412e3107d
edithclaryn/march
/while5.py
630
4.4375
4
""" Use a while loop to let the user keep guessing so long as guesses_left is greater than zero. Ask the user for their guess. If they guess correctly, print 'You win!' and break. Decrement guesses_left by one. Use an else: case after your while loop to print You lose.""" from random import randint # Generates a numbe...
797826327bb5344f550dc0c2b8e67a3097d60588
pierrebai/Inspiria-2021
/pure_ascii.py
993
3.5625
4
import sys def main(filenames): for fn in filenames: verify_pure_ascii(fn) def verify_pure_ascii(fn): # Note: opening in binary mode reads a stream of bytes. # read() returns a list of byte. data = open(fn, 'rb').read() zero_count = 0 zero_offset = 0 for i, d in enumerat...
7ba921f56439a47a1be329be41a3942104cf51d4
deniskokarev/practice
/c/hr/hr_word_order.py
394
3.625
4
#!/usr/bin/env python # # hackerrank https://www.hackerrank.com/challenges/word-order # from __future__ import print_function import sys from collections import defaultdict n = int(raw_input()) lst = sys.stdin.read().splitlines() cnt = defaultdict(int) for l in lst: cnt[l] += 1 print(len(cnt)) for l in lst: i...
e1372b082f937a438fa3ec3081ca4a5d31c429a7
DwaynesWorld/deeplearning
/review/data_vis_cc.py
514
3.625
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt x = np.arange(0, 10) y = x**2 print(x, y) plt.plot(x, y, 'r--') plt.xlim(0, 4) plt.ylim(0, 10) plt.title("Title") plt.ylabel("Y Lable") plt.xlabel("X Label") plt.show() mat = np.arange(0, 100).reshape(10, 10) print(mat) plt.imshow(mat, cmap='coo...
909c313ba590459fef268e64f897db54c4b46ad9
suanmj18/Python-Debugger
/python debugger/Condition_check.py
2,695
3.78125
4
#only in form of if(condition): or if condition:, codition should have space in between like a <= b def variable_check(ind,codes,var): if var.isnumeric(): return True while(ind): if 'def ' in codes[ind] or "if __name__=='__main__':" in codes[ind]: return False search1 = ' ' + var + ...
501e9a48a25996f903f241d741fb59c86f16508f
marcogmaia/ode_solver
/src/main.py
20,345
3.53125
4
# see: https://faculty.washington.edu/heathml/2018spring307/euler_method.pdf # the Inverse Euler method is wrong because the book solves the implicit equation # I should fix this... import matplotlib.pyplot as plt import parser import numpy from prettytable import PrettyTable from math import * table = PrettyTable() ...
d8a152cfc8c6a85e6f573f242b5956449b7788a9
the-carpnter/codewars_level_6_kata
/format_words_in_a_sentence.py
223
3.765625
4
def format_words(words): if not words: return '' words = [*filter(lambda x: x, words)] if len(words) >= 2: return ', '.join(words[:-1]) + ' and ' + words[-1] return words[0] if words else ''
8215de5167f2ec22a49965f730108be4599be03f
Aargonian/CSC310-Homework
/Homework 1/src/hamming.py
2,455
4.53125
5
#!/bin/python3 # Author : Aaron Helton # Date : 01/26/2019 # Class : CSC 310 # Purpose : This program calculates the hamming distance of any two integer # : numbers up to 32 bits long. The hamming distance is defined as # : the number of bits that are different between the two numbers. def calcu...
e35cc2f65d3decac6bdce38e35715a4e1c60536b
mbrodziak/polyline-length
/polyline_length.py
982
3.859375
4
import numpy as np import random from sklearn.metrics.pairwise import euclidean_distances def calculate_polyline_length(): n = int(input("Enter the number of points on the plane: ")) print() points = [] result = 0 for i in range(n): points.append([random.randint(0, 9), random.randint(0, 9...
cc9ec0b45e6558916e0363ba7ab27b00006c6401
UniqueDavid/Python
/day6/demo-screen.py
499
3.71875
4
#Screen里面有width和height,还有一个只读属性resolution class Screen(object): @property def width(self): return self.__width @width.setter def width(self,value): self.__width=value @property def height(self): return self.__height @height.setter def height(self,value): self.__height=value @property def resolution(se...
38322ac49f903b7c43d6d747c49cc7a1d9af1879
CincyPy/webscraping-demo
/demo.py
3,557
3.890625
4
""" demo.py - a web scraping demo using Beautiful Soup and Requests by Brian Sauer for CincyPy """ import requests from bs4 import BeautifulSoup import datetime class KenoDrawing(object): """KenoDrawing: a class to hold a specific Keno drawings""" def __init__(self, date, ID, numbers, booster): """ ...
0efd201cf64312907612b686eb590d6497439395
ckallum/Daily-Coding-Problem
/solutions/#051.py
692
3.609375
4
""" Proof: Each element's final position from positions n-1 to 0 has a probability of 1/(it's index) = 1/n * 1/n-1 ... 1/1 = 1/(n!) which means the total probability of a single permutation = 1/(n!) which is correct as there is a total of n! permutations so each permutation should have equal probability/ """ from ...
11f14213b5f2f50b72ce458e4bc7dc08554f7a2d
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/meetup/776af504f9264f3987eaa4218b013e3a.py
796
3.96875
4
from calendar import monthrange from datetime import date def meetup_day(year, month, weekday, type): weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] # the first day of the seven 1sts, 2nds, teenths and so on weekdays index = {'1st': 1, ...
5950e49c8ff6ac0292d68fd870c2a2739f7a5126
kumarshoki/TutorialGit
/Tutorial 8(Classes & Objects).py
4,881
4.375
4
# Classes and Objects # A user-defined prototype for an object that defines a set of attributes that characterize any object of the class. # The attributes are data members (class variables and instance variables) and methods, accessed via dot notation. # A class is a code template for creating objects. # Objects a...
cac145f8ae18c0404a4aad3d51b5791feb701342
yiren/python_flask_testing
/db_test.py
748
4
4
import sqlite3 connection = sqlite3.connect('data.db') cursor = connection.cursor() create_users_table = 'create table if not exists users (id INTEGER PRIMARY KEY, username text, password text)' create_items_table = 'create table if not exists items (id INTEGER PRIMARY KEY, name text, price real)' cursor.execute(c...
3c2e04b15a613dc6f0a49d21259a821de65c890f
JIiminIT/Segmentation_torch_multi_debugging
/tinycat/system.py
1,170
3.875
4
"""system 및 os 단에서 파일 및 명령등에 접근하는 모듈""" import os import sys import platform from typing import Optional, List # find absolute current working directory CWD = os.path.dirname(sys.argv[0]) if platform.system() == "Windows": CWD = CWD.replace("/", "\\") CWD = os.path.realpath(CWD) def find_executable(executable:...
eb2649823e9beed29d5913edb845e96379abd394
qhdong/fluent-python
/chap03/StrDict.py
467
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from collections import UserDict class StrKeyDict(UserDict): def __missing__(self, key): if isinstance(key, str): raise KeyError(key) return self[str(key)] def __contains__(self, key): return str(key) in self.data def __s...
e23f23b1bc54248fd1a6a79270300ec813d97ca4
BaijingML/leetcode
/No476 Number Complement.py
124
3.546875
4
def findComplement(num): a = ''.join(str(1-int(i)) for i in bin(num)[2:]) return int(a, 2) print(findComplement(5))
ad22f75dcd7e15c84cc3c7b5e4c0f406b1c933df
CS207-AD20/AD20_GUI
/ADnum_rev.py
12,396
4.0625
4
"""Module to wrap numbers into ADnum object and do basic calculations. Take value and specified derivative as given, wrap up as ADnum object, and return ADnum object for each basic calculation function. """ import numpy as np class ADnum: """ Class to create ADnum objects on which to perform differentiation. A...
fe21b6d6d6abb9220c5857863313a6ce699edb07
SCCroix/techdegree-project-2
/app.py
4,859
4.03125
4
import constants def add_player_to_team(player, team): player['team'] = team def average_height_of_team(team, players): heights = [] for player in team_players(team, players): heights.append(player["height"]) return sum(heights) / len(heights) def balance_teams(teams, players): """ Dist...
6d82e6b154546e30666e8ea0e87015ac5b721fbc
RadkaValkova/SoftUni-Web-Developer
/Programming Fundamentals Python/26 Dictionaries Exercise/courses.py
436
3.875
4
course_info = {} while True: line = input() if line == 'end': break course_name, student_name = line.split(' : ') if course_name not in course_info: course_info[course_name] = [] course_info[course_name].append(student_name) for key, value in sorted(course_info.items(), key=lambda x...
714c3fb2d1f8362e0597039befd7c57742954331
aimhigh53/AlgoWing
/MoonYeol/6회차/sw_advanced_graph_min_cost1.py
1,051
3.765625
4
def getParent(parent,node): if parent[node] == node: return node; return getParent(parent,parent[node]) def union(parent, x, y): x = getParent(parent,x) y = getParent(parent,y) #작은 수를 부모로 삼음 if x <y: parent[y] = x return x else: parent[x] = y return y...
7fdce15fb0942111c648c1a0dbb42f55d27d3833
qh997/PythonLearning
/BeginningPython/Chapter02.py
1,861
3.640625
4
#!/usr/bin/python # -*- coding: utf-8 -* # 第二章 列表和元组 edward = ['Edward Gumby', 42] john = ['John Smith', 50] database = [edward, john] print "database = " + `database` greeting = 'Hello' print greeting[0] print greeting[-1] numbers = [0,1,2,3,4,5,6,7,8,9] print "numbers[3:6] = " + `numbers[3:6]` print "numbers[3:] =...
b45552fc0de55992be361cb4932f5fd4a1569599
Suraksha-sachan/tathastu_week_of_code
/day2/program2.py
176
3.875
4
num=int(input("Enter number of term in Series :")) a = 0 b = 1 if num > 1 : for i in range(num): print(a,end=" ") c = a + b a = b b = c
21619665d6cee966b58310795dfd59fe29dcebe7
YangXinNewlife/LeetCode
/easy/get_maximum_in_generated_array_1646.py
796
3.53125
4
# -*- coding:utf-8 -*- __author__ = 'yangxin_ryan' """ Solutions: 题意其实就是给定一个数据n,然后在长度为n的大小数组中找到计算后元素最大的值, 将n的数据从2开始分奇数和偶数进行计算。 偶数:result.append(result[i // 2]) 奇数:result.append(result[i // 2] + result[i // 2 + 1]) 最后返回最大的即可 """ class GetMaximumInGeneratedArray(object): def getMaximumGenerated(self, n: int) -> in...
f0a892adc94d8dde6342fe6ffaed10b8bdf6cebc
ruozhizhang/leetcode
/problems/segment_tree/Count_of_Range_Sum.py
1,976
3.5
4
''' https://leetcode.com/problems/count-of-range-sum/ Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), inclusive. Note: A naive algorithm of O(n^2) is trivial. You MUST do...
29f19f044cd9af9dd571fc2ffc236af757605b33
kgalloway2/Project-Euler-stuff
/old project euler/seive.py
1,042
4.40625
4
def seive_of_eratosthenes(n): composite_list = [] # Create list of composites (initially empty) prime_list = [] # Create list of primes (initially empty) # cycle through numbers from 2 to n (bound is exclusive) for i in range(2, n+1): # if i is not in the list of composites if i not in...
7aa9501107142c29c900d9fbf0d92f0bd35b871c
Dasmez/BI_2019_Python
/hw3/flat_list.py
186
3.78125
4
def flat_list(array): c = [] for element in array: if type(element) is list: c += flat_list(element) else: c.append(element) return c
a407efbbaebfdd6bf51197c0bb3af25220aa0bfa
adeoriolowo/bootcamp-oop
/oop.py
1,077
3.828125
4
class Person: def __init__(self, first_name, last_name, age): self.first_name = first_name self.last_name = last_name self.age = age def get_name(self): names = self.first_name + " " + self.last_name return names def set_name(self, first_name, last_name): se...
5406fd3d63bc1b4d9618ba44ad0fb94a733bc57b
smahmud5949/All-code
/18.py
74
3.59375
4
num1 = 2 num2 = 3 num3 = 4 result = num1 + num2 * num3 print(result)
a1ba5e1734e4f65f9fd5070271d5e713736ff4bd
Chillu1/PythonUiS
/Oving9/Part2/main.py
3,465
3.8125
4
import tkinter, random class Gui: def __init__(self): self.window = tkinter.Tk() self.random_number = random.randint(1, 1000) self.is_number_guessed = False self.previous_guess = None self.index = 1 self.number_status_text = tkinter.StringVar() self.number_s...
df68e0263527b61f80fda409686dc43171016d10
paullianyang/practice
/codility/lessons/02_CyclicRotation/main.py
430
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def solution(A, K): # Since shifts beyond the array length just wraps around # max shift is determined by the length of the array # and any further extra can be reduced to the modulo array_len = len(A) rotation = array_len % K return A[rotation:] + ...
a61139d33b89fe1b4a8451ef7f458359d3bddb66
mudit2103/courserapython
/stopwatch.py
1,952
3.578125
4
# template for "Stopwatch: The Game" import simplegui # define global variables time = 0 times_stopped = 0 times_won = 0 isStopped = True # define helper function format that converts time # in tenths of seconds into formatted string A:BC.D def format(t): A = t/600 t %= 600 B = t/100 ...
4c21ebf5df810aff110896c18d06c97699f3cff8
ijurk/PythonProgramming_Script_OOP_Advanced
/classes_2.py
9,616
4.09375
4
# 1. In the BankAccount class that you had created in the previous exercise, # delete the set_details() method and create an __init__ method. class BankAccount: def __init__(self, name, balance=0): self.name = name self.balance = balance def display(self): print(f'Bank Account Name: {...
e83ea453b39664ca70320f6c3a48014c310a8b9f
Dongyalin/123
/test.py
121
3.625
4
#! python3 import re begins = re.compile('H\\w{2}l') mo = begins.search(r'Hello word') res = (mo != None) print(res)
9535bffae9a2d6f65dbb0239c84af5cddd9be9fd
Saptarshidas131/NPTEL
/Joy of Comuting using Python/programs/fibonacci.py
519
3.96875
4
""" Description: Fibonacci series, using recursion. A series whose starting numbers are 0 and 1 and then the next number is found by adding the previous two numbers. @author: Saptarshi Das """ def fibonacci(n): if n<2: return n else: return fibonacci(n-1) + fibonacci(n-2) #input ...
972ee6f8aec595a89f8428136ca2e6ec9f9021ca
nathanlo99/dmoj_archive
/done/ccc06j2.py
280
3.59375
4
a = int(input()) b = int(input()) c = sum(1 for i in range(1, a + 1) if 10 - i in range(1, b + 1)) if c == 1: print("There is 1 way to get the sum 10.") elif c <= 0: print("There are 0 ways to get the sum 10.") else: print("There are", c, "ways to get the sum 10.")
e60374e748cec73296dd7a38e66365d7e3cd28ec
aaronzweig/third-person
/arsenal/datastructures/orderedset.py
751
4.09375
4
""" OrderedSet -- a set which remembers insertion order. """ class OrderedSet(object): """ Set which remembers insertion ordering allowed iteration while changing size and determinism. """ __slots__ = 'set', 'list' def __init__(self): self.set = set() self.list = [] def __co...
aa5922713581b12a908d3a56cf1181047278c928
tosha96/euler-solutions
/approxe.py
340
3.53125
4
import euler def approxE(error): x = 1 previous = 1 current = 2 while current - previous > error: x += 1 previous,current = current, current + 1/euler.factorial(x) return current print(int(approxE(0.000000000000000000000000000000000000000000000000000000000000000000000000000000001)*100000000000000000000000000...
fabdf9bef92c77a7d290249f53c92fb32270183e
raynerng/raspberrypi3
/pushLED.py
1,314
3.84375
4
import threading import time import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) class Button(threading.Thread): """A Thread that monitors a GPIO button""" def __init__(self, channel): threading.Thread.__init__(self) self._pressed = False self.channel = channel #set up pin as input GPIO.setup(self.channel,GPI...
58cc3a0000063ee863ad5e34835d57f5590f3ea3
SanyaBoroda4/Hillel_Homeworks
/Lesson 8 (Functions)/9.py
323
3.953125
4
def even(a): if a % 2 == 0: print(f"Number {a} is even number.") else: print(f"Number {a} is not even number.") for i in range(1, 50): even(i) x = int(input()) y = int(input()) if x > y: def example(): print("HELLO!") else: def example(): print("hello.") example...
8c50304327cafbcc4be331a4820dbc6b6bbe191d
xvrlad/Python-Stuff
/Lab 4 Q1.py
752
3.859375
4
""" Lab 4: """ def main(): feedback = get_feedback(15, 20) print(feedback) ## print(get_feedback(100, 200)) ## print(get_feedback(65, 90)) ## print(get_feedback(30, 30)) def get_feedback(mark, out_of): percentage = (mark / out_of) * 100 percentage_rounded = round(percentage) if percentage...
43e3ea5e73d038e3f269d0de944d617934c7f540
AleksanderGorazda/pp1
/05-ModularProgramming/During Class 04.py
153
3.546875
4
import math x=3.7 y=4 print(math.sqrt(x)) print(math.pow(x,y)) print(math.pow(x,1/y)) print(math.pi*(y**2)) print(math.factorial(y)) print(math.floor(x))
7b73b71a79b71ceafbfc5d9c86ca31ee21b8ce59
chinitacode/Python_Learning
/ByTags/Tree/BT/Path_Sum_II.py
2,284
3.546875
4
''' 113. 路径总和 II [中等] 给定一个二叉树和一个目标和,找到所有从根节点到叶子节点路径总和等于给定目标和的路径。 说明: 叶子节点是指没有子节点的节点。 示例: 给定如下二叉树,以及目标和 sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1 返回: [ [5,4,11,2], [5,8,4,5] ] [Method 1]: 迭代(前序遍历) [时间复杂度]:和递归...
a5714749722091a0a167551e6ef113a1b035bf79
kalaiyarasan-it19/myprograms
/prog47.py
121
4.0625
4
breadth=int(input("enter the area:")) length=int(input("enter a length:")) area=length*breadth print("the area is",area)
a64114f6cb5b138bcd5070a84fd3c7d3bb5e6dbe
shygg/mega-project
/Numbers/unit conversion/unit conversion.py
692
4.03125
4
print("-" * 20) print("type number + space + unit", "type: 'kg' to convert to lbs","'lbs' to kg", "feet/meter") raw_user = input() def make_sense_of(raw_user): try: raw = raw_user.split() if len(raw) != 2: print("you goofed 1") number = float(raw[0]) from_unit = str(ra...
f238920f5b1eda5af631e3c8cc38d9a714105407
KrishAjith/Python
/findnum.py
253
4.25
4
Num = int(input("Enter your Number : ")) if( Num != 0): if(Num < 0): print("\n *** Given number is Negative *** \n") else: print("\n *** Given number is Positive ***\n") else: print("\n *** Given Number is zero ***\n ")