blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
42491c75880a588bea1b82f41f9fb1a2e368d957
Kaushik8511/Competitive-Programming
/recursion/sort array.py
351
3.90625
4
a = [0,5,1,2] def insert(A,temp): if len(A)==0 or A[-1]<=temp: A.append(temp) return val = A.pop() insert(A,temp) A.append(val) def sort(A): if len(A)<=1: return temp = A.pop() sort(A) insert...
fdc761f35b513b1fb029b5a0abc47d5a98bf29b9
Kaushik8511/Competitive-Programming
/Trees/CheckIfCousinsOrNot.py
1,245
3.6875
4
class Node: def __init__(self,key=None,left=None,right=None): self.key=key self.left=left self.right=right class NodeInfo: def __init__(self,key=None,level=None,parent=None): self.key=key self.level=level ...
0b999dece596a8bdf04eb3416665de97dcde6ed1
Kaushik8511/Competitive-Programming
/Graph algos/BFS2.py
1,262
3.78125
4
from collections import defaultdict,deque class graph: def __init__(self,V): self.V = V self.adj = defaultdict(list) self.setData() def setData(self): e = int(input("enter number of edges : ")) for i in range(e):...
db5e744e9356aaa2bee4cb8f3d079fd937c5c29a
Kaushik8511/Competitive-Programming
/Codevita/Key programs/Angram substring.py
536
3.8125
4
#check whether any substring of Y is angram of x or not. def isAngram(x,y): m,n = len(x),len(y) if m>n:return False x_h = [0 for _ in range(26)] y_h = [0 for _ in range(26)] for i in range(m): x_h[ord(x[i])-ord('a')]+=1 y_h[ord(y[i])-ord('a')]+=1 if x_h==y_h:return Tru...
79f586460e2fed4ee1082a8b1970e58475cfd66c
18106574249/Programmer-Algorithm-Interview-2019
/2-1-用列表实现栈.py
870
4.0625
4
# -*- coding: utf-8 -*- class MyStack: def __init__(self): self.items = [] # 判断栈是否为空 def isEmpty(self): return len(self.items) == 0 # 返回栈的大小 def size(self): return len(self.items) # 返回栈顶元素 def top(self): if self.items: return self....
ed0a18a5334b4f9c1c90ac9447d8f12d59542301
chenyang1999/lanqiaocup_marcus
/inprovement/水仙花数.py
407
3.625
4
''' 问题描述   求出所有的“水仙花数”。所谓的“水仙花数”,是指一个3位数,其各位数字的立方和等于该数本身。 输入格式   程序使用for循环遍历所有三位数整数,不需要手动输入 输出格式   遇到水仙花数输出 ''' for i in range(100,1000): if int(str(i)[0])**3+int(str(i)[1])**3+int(str(i)[2])**3==i: print(i)
599ffbcd5cd831f75f4bf556e9b1fd0baf61dcc6
chenyang1999/lanqiaocup_marcus
/inprovement/整商问题.py
1,511
4.15625
4
''' 问题描述   提示用户输入被除数(dividend)和除数(divisor), 若除数为0,则提示用户重新输入,直至除数非零为止。 最后输出商。程序建议大家将被除数、除数和商都定义为整形。   输入被除数提示语句为:Please enter the dividend:   输入除数提示语句为:Please enter the divisor:   提示除数为0需要重新输入的语句为: Error: divisor can not be zero! Please enter a new divisor:   建议:大家直接复制上述语句,以免出现不必要的错误。 输入格式   被除数 除数   注:若除数为零,则需要连续...
760499998ba854d5b54a9e564c0959017e80b986
tian3rd/neural_network_practice
/Lab2/lab2_task2_glass_dataloader.py
5,645
3.8125
4
""" This script provides an example of building a neural network for classifying glass identification dataset on http://archive.ics.uci.edu/ml/datasets/Glass+Identification It loads data using a data loader, and trains a neural network with batch training. """ # import libraries import numpy as np import pandas as pd ...
d3095c8de0ddf18a575b27ae43bd273444398187
alluballu1/OOP-tasks
/Tasks/Exercise 2/exercise2task3.py
781
4.03125
4
# File name: exercise2task3.py # Author: Alex Porri # Description: Function that takes the amount of accepted exercises and outputs a grade def grading_function(): # User inputs the amount of accepted exercises. accepted_exercises = int(input("Input the amount of accepted exercises: ")) if accepted_ex...
11732c8755cbc6c92775b025b35d5c8ecdc1c6c5
alluballu1/OOP-tasks
/Tasks/Exercise 4/Exercise4Task6.py
976
3.875
4
# File Name: Exercise4Task6.py # Author: Alex Porri # Description: using two imported classes. Dice is used to roll a number and then printing out the info of the device # with the same ID as the rolled value import DiceClass as Dice import CellPhoneClass as CellPhone # Creating dice object my_dice = Dice.Dice() # ...
12ea95841628b1f1524f1c8587deaac074ce0833
alluballu1/OOP-tasks
/Tasks/Exercise 7/exercise7task4.py
997
4.03125
4
# File name: exercise7task4.py # Author: Alex Porri # Description: Game of cards where 3 players pull from a deck and the highest value wins. import DeckClass # Creating the objects deck = DeckClass.Deck() deck.shuffle() card = deck.drawCard() card2 = deck.drawCard() card3 = deck.drawCard() # Main function def main...
2bea8a17888a41300ba83a6718790b32110485c5
alluballu1/OOP-tasks
/Tasks/Exercise 7/DeckClass.py
718
3.953125
4
# File name: DeckClass.py # Author: Alex Porri # Description: class for creating the deck from which a player can pull cards from CardClass import Card import random class Deck: def __init__(self): self.cards = [] self.build() def build(self): for s in ["Spades", "Clubs", "Diamonds", ...
8910fa5a903fe8fd9720459bcc7d8b40d4f2e7f7
alluballu1/OOP-tasks
/Tasks/Exercise 7/AnimalClass.py
738
3.984375
4
# File name: AnimalClass.py # Author: Alex Porri # Description: Class for creating Animal objects, class Animal: def __init__(self, init_species, init_name): self.__species = init_species self.__name = init_name # Creating the accessor functions def get_species(self): return sel...
7283816067f24b29f5e1340af4da3e1965bcfe13
alluballu1/OOP-tasks
/Tasks/Exercise 8/HouseClass.py
1,681
3.875
4
# File name: HouseClass.py # Author: Alex Porri # Description: a class for a house # creating the class class House: def __init__(self, floors, windows, bed, surfaces, fridge, toilet_paper): self.__floors = floors self.__windows = windows self.__bed = bed self.__surfaces = surfaces...
07cb5512e1abc24883ef8f9f1abf005879c104c9
bmanalive/Election_Analysis
/Python_practice.py
6,315
4.3125
4
#%% from typing import AbstractSet print("Hello World") # %% one = 5+2*3 two = 8//5-3 three = 8+22*2-4 four = 16-3/2+7-1 five = 3**3%5 six = 5+9*3/2-4 print(one,two,three,four,five,six) print(one) print(two) # %% one = (5+2)*3 two = (8//5)-3 three = 8+(22*(2-4)) four = 16-3/(2+7)-1 five = 3**(3%5) six = 5+(9*3/2-4)...
ef420f2c205baaac6da40b1201fd188c014dd0e1
TaquitoTwister/Geometrics
/Cuadrado.py
579
3.640625
4
if figura == "cuadrado": #Diagonal Cuadrado def diag_cuadrado(): dcua=math.sqrt(2)*aristacua return dcua #Área Cuadrado def area_cuadrado(): areacua=aristacua**2 return areacua #Perímetro Cuadrado def perimetro_cuadrado(): pericua=aristacua*...
a3f86be5b0c6c95f0ed5f4b5cf0f37ebcd6d08f4
RommellFlores/Python
/Clase Excepciones/ejemplo.py
241
3.59375
4
# -*- coding: utf-8 -*- class MiError(Exception): def __init__(self): print("Este es nuestro error") try: n = int(input("Ingrese un número: ")) if n < 0: raise MiError except MiError: print("Hola")
4f57e3f1c683845d0ab6a82157f082ffdb309da0
audreyanigbo/proj7
/py-text-adventure-main/play_game.py
5,066
3.875
4
import json import random def main(): # TODO: allow them to choose from multiple JSON files? with open('spooky_mansion.json') as fp: game = json.load(fp) print_instructions() print("You are about to play '{}'! Good luck!".format(game['__metadata__']['title'])) print("...
ca5b60c9651927eb010a34fac12b854181711f7e
weed478/wdi6
/zad16.py
1,085
3.6875
4
from myszka import meszgen # counts vowels in string def vowels(text): count = 0 for letter in text: for a in "aeiouy": if letter == a: count += 1 return count # return (sum of ascii char's dec value, vowels in string) def weight(text): asc_sum = 0 for a in tex...
270cb477264eb5c06d0fceb3a5872915469f83a5
findman/PythonCookbook
/chapter2/p07_shortest_match.py
585
3.5
4
#!/usr/bin/env python3 # -*- coding:utf8 -*- """ Topic:最短匹配,非贪婪模式匹配 Desc: """ import re def short_match(): # 贪婪模式 # 默认 '.' '*' '+' 为贪婪模式 str_pat = re.compile(r'\"(.*)\"') text1 = 'Computer says "no."' text2 = 'Computer says "no." Phone says "yes."' print(str_pat.findall(text1)) print(str_...
db09d6ea6541c49fbf22d35ea2d1f87d0abfadab
findman/PythonCookbook
/chapter3/p02_decimal.py
462
3.6875
4
#!/usr/bin/env python3 # -*- coding:utf8 -*- import math from decimal import Decimal from decimal import localcontext a = Decimal('4.2') b = Decimal('2.1') c = a + b print(c) print((a+b) == Decimal('6.3')) a = Decimal('1.3') b = Decimal('1.7') print(a / b) with localcontext() as ctx: ctx.prec = 3 print(a / b...
7c797712303fca3081f42654eea3294decc45682
findman/PythonCookbook
/chapter1/p1_21.py
305
3.75
4
#!/usr/bin/env python3 # -*- coding:utf8 -*- class User: def __init__(self, user_id): self.user_id = user_id def __repr__(self): return 'User({})'.format(self.user_id) users = [User(23), User(3), User(99)] print(users) users = sorted(users,key=lambda u:u.user_id) print(users)
eab769d13132fe5e2d74c3ea031bdb1bb29e75a5
findman/PythonCookbook
/chapter1/p1_2.py
311
3.578125
4
#!/usr/bin/env python3 # -*- coding:utf8 -*- s = 'Hello' a, b, c, d, e = s print("a = %s, b = %s, c = %s, d = %s, e = %s" % (a, b, c, d, e)) # 使用占位符实现获取部分数据 data = ['ACME', 50, 91.1, (2012, 12, 21)] _, shares, price, _ = data print("shares = %d" % shares) print("price = %f" % price)
804ffde4127065cb01992fa0209c38e7845823c0
findman/PythonCookbook
/chapter2/p16_textwrap.py
655
3.59375
4
#!/usr/bin/env python3 # -*- coding:utf8 -*- """ Topic:格式化字符串为指定宽度 Desc: """ import textwrap import os def reformat_width(): s = "Look into my eyes, look into my eyes, the eyes, the eyes, \ the eyes, not around the eyes, don't look around the eyes, \ look into my eyes, you're under." print(textwrap.f...
bc4e4482894cacfef3cd81597bc1d1e7ce759c95
READYTOSHARE/Machine-Learning-Algorithms
/Descision_Tree_Regression/Descision_Tree_Regression.py
777
3.609375
4
#Descision tree regression #importing libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #import dataset dataset = pd.read_csv("Position_Salaries.csv") x = dataset.iloc[:,1:2].values y = dataset.iloc[:,2].values #fitting the model from sklearn.tree import DecisionTreeRegre...
6f1f1bcd4ec1d0c1050667458d4f8aed30499fe1
Nibicyan/Project-0
/foo.py
125
3.53125
4
t = input("Hello World: ") print("Hello" +t) print("ended") print(t) print(input("what your name?? :")) print("new ff aded")
8fa3a2a700e2a3cfdf231aff6e6a4ae59745a74e
Aarushjoshi95/spychat
/add_friend.py
1,654
3.984375
4
#<--------------IMPORT STATEMENTS-----------> from spy_details import Spy,friends from termcolor import colored from spy_details import spy #<--------FUNCTION FOR ADDING A FRIEND-------> def add_friend(): # Using the class spy new_friend = Spy(" ", " ", 0, 0.0) new_friend.name = raw_input("Please ad...
718b3759ece6a1d330eb12280bf756af8c9936d6
kpkishankrishna/20186029_CSPP-1
/cspp1_practice/m8/power using recursion/power_recr.py
616
4.0625
4
# Exercise: PowerRecr # Write a Python function, recurPower(base, exp), that takes in two numbers and returns the base^(exp) of given base and exp. # This function takes in two numbers and returns one number. def recur_power(a, b): ''' base: int or float. exp: int >= 0 returns: int or float, base^e...
d96aba53f7daae151e50f827d9e6e592dce4714d
kpkishankrishna/20186029_CSPP-1
/cspp1-assignments/m5/p2/square_root.py
418
4.125
4
''' Author@ : kpkkishankrishna This program evaluates the square root of a number. ''' def main(): '''Main function.''' num_1 = int(input()) epsilon = 0.01 step = 0.1 guess = 0 while abs(guess**2-num_1) >= epsilon: guess += step if abs(guess**2-num_1) >= epsilon: print("Faile...
ef98f152c0873bdecd39f91cd06a0391f218d4b7
kpkishankrishna/20186029_CSPP-1
/cspp1-assignments/m6/p3/digit_product.py
541
4.125
4
''' Given a number int_input, find the product of all the digits example: input: 123 output: 6 ''' def main(): ''' Read any number from the input, store it in variable int_input. ''' int_input = int(input()) int_a = abs(int_input) int_n = 0 int_pro = 1 while int_a > 0: i...
c11c61c6a9a9d48c878a16e802cc866df06d76fd
kpkishankrishna/20186029_CSPP-1
/cspp1_practice/m3/rough.py
679
3.78125
4
if __name__ == '__main__': main() # N = int(raw_input()) def main (): list = [] lines = int(input()) for i in range(lines) : thislist = input().split(" ") if (thislist[0] == "insert"): list[thislist[1]] = thislist[2] elif (thislist[0] == "remove"): lis...
06583620ed39b58b501a896e51b5aae72e29aac8
kpkishankrishna/20186029_CSPP-1
/cspp1-assignments/m7/Functions - Assignment-3/assignment3.py
3,856
3.78125
4
''' Author@ : kpkishankrishna # Functions - Assignment-3 - Using Bisection Search to Make the Program Faster # You'll notice that in Problem 2, your monthly payment had to be a multiple of $10. Why did we make it that way? You can try running # your code locally so that the payment can be any dollar and cent amount ...
497e279f6d48fb136c0e8b661ff45128bbff680b
wei9937/Python-training
/test.py
269
3.53125
4
import itertools, random aa=(1,2,3); sub=[1,3,5] deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club'])) #print(aa); random.shuffle(deck) #print(deck[1][0], "of", deck[1][1]) pi = 3.1415926 di=4; ans=(di/2)**2*pi print ("ans="+str(ans));
638f60c9fb5fa55ca441680f2d12b069a4333462
beyzakilickol/Data-and-Algorithms-Practice
/practice.py
340
3.78125
4
# -------------Python------------------------------- def first_non_repeating_letter(str): letter_list = [i.lower() for i in str] print(letter_list) for i in range(len(letter_list)): if letter_list.count(letter_list[i]) == 1: return str[i] return "" print(first_non_repeating_le...
891c92c5da3f2f9a58de242d929a166f35300b20
Ha11ow/CSS340
/Assignment 4/Catalan.py
2,047
4.1875
4
#------------------------------------------------------------------------------- # Author: Ben Khabazan # Date: 5-10/2019 # Class: Catalan # The Catalan is a summation of numbers using the previous numbers before it # the only known case is case 0 where it is equal to 1 #======================...
9f90741039067eadd48ffa8b7c07cbec3105cbe8
Ha11ow/CSS340
/Assignment 5/sort.py
5,991
4.375
4
#------------------------------------------------------------------------------- # Author: Ben Khabazan # Date: 5/19/2019 # Module: sort # the sort mod #=============================================================================== ''' This is the bubble sort where it will compare elements t...
7a00688101b739df602ee373be43b39fe3a29370
Shalabyelectronics/TurtleCrossingGame
/car.py
1,506
3.609375
4
import turtle import random # COLORS = pass class Car(turtle.Turtle): def __init__(self): super().__init__() self.hideturtle() self.position = [] self.generate_position() self.segments = [] self.car_colors = ['yellow', 'gold', 'orange', 'red', 'violet', ...
8b156add610cf53bd175453189448230b4da2a46
isennkubilay/Decimal-to-Binary
/main.py
280
3.890625
4
new_base = 2 num = int(input("Enter a non-negative integer: ")) result = "" q = num r = q % new_base result = str(r) + result q = q // new_base while q > 0: r = q % new_base result = str(r) + result q = q // new_base print(f"{num} in Decimal is {result} in Binary")
4891a36bcfa9b5d49abe024edd607f6bf3ccc01e
kevrodg/lpthw
/ex6.py
1,152
4.34375
4
# assigns x the string in the quotes and puts the number 10 where the %d is. x = "There are %d types of people." % 10 # assigns the string in quotes to binary binary = "binary" # makes the variable do_not into don't do_not = "don't" # assigns x the string in the quotes. Uses the variables binary and do_not. y = "Those ...
bc57a8123eb938811e611ef96f5139095dfda913
jailsonsf/Jailson-Soares
/Teste de Conhecimento Inicial/Número_Triangular.py
296
3.703125
4
n = int(input()) a = 1 b = 2 c = 3 while True: if a * b * c == n: print('{} * {} * {} = {}'.format(a,b,c,n)) print('Verdadeiro') break elif a * b * c > n: print('Falso') break else: a += 1 b += 1 c += 1
3db7b93062d83c46a9c99090b0f1119c9eeba1b3
crusader2000/Convolution-Visualizer
/Convoluter.py
2,209
3.625
4
import math import matplotlib.pyplot as plt def f(x): ## if (x >=0): ## return 1 ## return 0 if (x >= -1 and x <= 1): return 1 return 0 return abs(x) ## if (x >= -1 and x <= 0): ## return 1+x ## elif (x > 0 and x <= 1): ## return 1-x ## return 0 ## ## ...
6f6706447e564cbd6f16fff3fe2b905d2d7e3fdb
ugiacoman/Basics
/02calc/cylinder.py
784
4.6875
5
# CS 141 lab 2 # cylinder.py # # Modified by: Ulises Giacoman # # This program calculates the volume, surface area and circumference of # a cylinder with values for the radius and height provided by the user import math # Prompts and converts to float the radius and height of the cylinder radius = float(input("Enter ...
b7367ff005d85695120775fa6b4ece02b781607e
ugiacoman/Basics
/Proj3/Proj3.py
6,477
4.21875
4
# CS 141 Project 3 # Proj3.py # # Modified by both: Ulises Giacoman (703)-678-6244 ugiacoman@email.wm.edu # Bradley Blount (202)-380-6688 beblount@email.wm.edu #Prologue: # For the first game the objective is to find all the words of a particular # length containing just a single vowel that does no...
43b20bf4e6ed12d522375726d3199588ba56d9b9
ugiacoman/Basics
/10classes/testline.py
2,859
3.859375
4
# CS 141 Lab 10 # testline.py # # A program that tests the line segment class. from line import LineSegment from carpoint import Point # Create two points for the line segment. A = Point(4, 8) B = Point(3, 9) # Create a line segment for testing. line = LineSegment(A, B) print('Testing endPointA() on line (4,8) (3,9...
4192a81233f234e08caaf48b4549f1a6b7c58edf
ugiacoman/Basics
/12linux/countwords.py
1,658
4.65625
5
# CS 141 lab 12 # args.py # # This program is meant to show how to integrate the use of command-line # arguments into a Python program. It takes a filename as a command-line # argument and counts to number of words (separated by spaces) contained # in that file. # The system library is needed in order to access the ...
fb6537c289e05428adb7562234ab84efaa79583c
xiantang/Python-cookbook
/12-thread/12-3.py
2,875
3.515625
4
from queue import Queue from threading import Thread # _sentinel = object() # def producer(out_q): # i = 0 # while True: # i+=1 # print("put data") # out_q.put("data") # if i==100: # out_q.put(_sentinel) # if out_q.qsize()>100: # break # def consum...
4a85d9765e2f15a424bf568d4bb2fa6790d0c22d
vickyrr24/guvi
/area.py
67
3.625
4
a,b=input().split() a=float(a) b=float(b) print(format(a*b,'.5f'))
fad43735a966328ebc9f512126b172dcc195ffd6
vickyrr24/guvi
/hello.py
65
3.671875
4
number=int(input()) for i in range(0,number): print("Hello")
1f55be56fe47da1ab552ea91fed36ab87f118829
vickyrr24/guvi
/inrange.py
122
3.609375
4
n=int(input()) flag=0 for i in range(0,10): if(i==n): flag=1 if(flag): print("yes") else: print("no")
e427a89b6670e9ac7d57742fac98ad2c824e8e4f
vickyrr24/guvi
/bitswap.py
82
3.671875
4
x,y=input().split() y=int(y) x=int(x) x = x ^ y; y = x ^ y; x = x ^ y; print(x,y)
8af08c9ef3e47ad1d665c4cc565af9407a9b0eff
vickyrr24/guvi
/powerof2.py
126
3.703125
4
n=int(input()) flag=1 while(n!=1): if(n%2!=0): flag=0 n=n//2 if(flag): print("yes") else: print("no")
25ea0b7184e0a9f53e3c86a98d83e9d26db3c567
vickyrr24/guvi
/fib.py
168
3.6875
4
def fib(n): f1 = 0 f2 = 1 if (n < 1): return for x in range(0, n): print(f2, end = " ") next = f1 + f2 f1 = f2 f2 = next n=int(input()) fib(n)
a61c1ee43c7af81fa60767ed194612f44a9a76f0
Aysen23/Other
/orion.py
3,606
3.53125
4
# Эта программа наносит звёзды созвездия Ориона, # названия звёзд и линии созвездия. import turtle # Задать размер окна. turtle.setup(500, 600) # Установить черепаху. turtle.penup() turtle.hideturtle() # Создать именованные константы для звёздных координат. LEFT_SHOULDER_X = -70 LEFT_SHOULDER_Y = 200 RIGHT_SHOULDER...
bd2a32812063c091456511426718c6e76c3dd760
doshpit/SortableCodingProject
/match.py
2,563
3.515625
4
#!/usr/bin/python #author: Danylo Shpit from shutil import copyfile import collections import string import json import os products = {} matchings = {} resultFile = "results.txt" # creates a dictionary : product_name -> [manufacturer,model,family] def processProducts(): with open('products.txt') as products_file...
b5b9ecabb7374fc17feaec9f7c237a5e441f3e8d
ivaylom/PythonTues9a_Homework
/ButtonGame/13/ClickerGame.py
1,079
3.609375
4
import tkinter import random window = tkinter.Tk() window.minsize(550,550) label = tkinter.Label(window, fg = 'Blue Violet', text="Score: 0") label.place(x=0, y=0) counter = 0 seconds = 1 label2 = tkinter.Label(window, fg = 'Royal Blue', text="Timer: %s" % seconds) label2.place(x=0, y=20) button = tkinter.Button(win...
e95c5d17b21a23bdf7921aebe155489aada8da8a
naresh-guthula/python-training-samples
/day2/function_call.py
111
3.625
4
def demo(value): value += 1 n = 10 # call by value demo(n) print(n) n = [1, 3, 5] # call by reference
4bbdb08f960e1573f80ac0c865cfa25699256866
naresh-guthula/python-training-samples
/demoforpackages/generatorfunctionex.py
307
3.84375
4
def get_integers(): i = 1 while True: yield i i += 1 squares = (i ** 2 for i in get_integers()) def take_n(count, squares): for element in range(count): yield next(squares) if __name__ == '__main__': n = take_n(5, squares) for square in n: print(n)
14abb1bc27344618c5c162bc7f4f844af835d4c0
Deepak2929/PYTHON_REALWORLD_PROGRAMS
/4.Data_in_File.py
760
3.75
4
scores=[] file_handler=open("RESULTS.txt") # Notice the File Handler which will represent the file(RESULT.txt) throughout our code.It is our File. for each_line in file_handler: (name,score)=each_line.split() scores.append(float(score)) #use float for a decent sort of numb...
507ea0a42475df87a7099f67eed522efabbc9557
12libao/DEA
/Sizing_Method/Other/US_Standard_Atmosphere_1976.py
5,479
3.5
4
# author: Bao Li # # Georgia Institute of Technology # """Reference: 1: U.S. Standard Atmosphere, 1976, U.S. Government Printing Office, Washington, D.C., 1976. 2: Mattingly, Jack D., William H. Heiser, and David T. Pratt. Aircraft engine design. American Institute of Aeronautics and Astronautics, 2002. 3: http...
e8eeaab0715bf9358315d89aed9854eef1ac4516
JamesPagani/AirBnB_clone_V2
/web_flask/2-c_route.py
676
3.796875
4
#!/usr/bin/python3 """C is fun! A bare bones Flask web application. Making a request to '/c/<text>' will print a string along with <text>. """ from flask import Flask app = Flask(__name__) @app.route('/', strict_slashes=False) def hello_hbnb(): """Display a message when making a request to root.""" retur...
0a33edff4f1b5dae5031019f36a7f981b3e91ab0
loudtiger/stuff
/binarysearch.py
799
4
4
#Implement binary search of a sorted array of integers import sys inputValue = sys.argv[1] inputSearch = sys.argv[2] inputList = inputValue.split(",") numberToFind = int(inputSearch) def getMidpoint(rangeStart, rangeEnd): diff = rangeEnd-rangeStart return rangeStart + diff/2 def binarySearch(inputList, numberToFin...
0b7eb6d02d7dbb4a8291c0d16dd3e7519d4f66aa
loudtiger/stuff
/arrays/12/numberOccuringOddNumberOfTimes.py
308
4
4
#Given an array of positive integers. #All numbers occur even number of times except one number which occurs odd number of times. #Find the number in O(n) time & constant space. def numberOddTimes(array): xored = 0 for i in array: xored = xored^i return xored print numberOddTimes([1,2,3,1,2,3,1])
e9a7370650ba804569bd321c671d66455dcab6ef
interd7/ShangKe
/my_class_demo/person.py
1,278
3.734375
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- # @Project :ShangKe # @File :person # @Date :2020/10/21 8:41 上午 # @Author :段益迈 # @Email :dym0822@163.com # @Software :PyCharm ------------------------------------------------- """ class Person: # 属性、字段 name = '张三' _...
9038c569ce1bf891e61f45826e25ad38c5a1d56d
ramkumar2606/traffic-simulation
/build/lib/simulation/simulation.py
4,023
4.0625
4
import time if __package__ is None or __package__ == '': import lights else: from . import lights import turtle class Simulation: def __init__(self): self.red_seconds = None self.green_seconds = None self.yellow_seconds = None self.simulation_stop = False def validate_s...
57f108e60b70803ec783f817086306f393c9c6d5
chase001/Selenium-WebDriver-3.0
/pybase/class_def.py
430
3.9375
4
def add(a=2,b=3): return a +b a = add(6,7) print #类 class jisuan(object): """docstring for jisuan""" def add(self,a,b): return a + b class ClassName(object): """docstring for ClassName""" def __init__(self, arg): super(ClassName, self).__init__() self.arg = arg class ClassName(object): """docstring ...
5a5a51d1d12c183810d82f057cfadaea268cd945
howtoosee/FlappyBirdAI-NEAT
/components/bird.py
2,993
3.609375
4
from components.constants import * class Bird: """ Bird object """ IMGS = BIRD_IMGS # list of images MAX_ROTATION = 25 # maximum tilt angle when in facing up ROT_VEL = 20 # rotation speed ANIMATION_TIME = 5 # time for each animation def __init__(self, x, y): """ ...
50b86b0ff5f57b2de5353aae149955d6789d7203
webclinic017/FSCSW01
/runtest/utils.py
288
3.515625
4
# Utilities def to_date(date_str): # Convert ISO date string into date from time import strptime from datetime import date # ValueError Exception may be raised when input invalid tm = strptime(date_str, '%Y-%m-%d') return date(tm.tm_year, tm.tm_mon, tm.tm_mday)
372cbcf43dd854048793e0a78c4ccfbb7c5f181b
abhishekSen999/Python
/List/copy.py
558
3.84375
4
def copy(lst1, lst2 = []): ''' Objective: To create copy of a list lst1 Input Parameters: lst1, lst2 - list Return Value: lst2 - list ''' if lst1==[]: return lst2 else: lst2.append(lst1[0]) copy(lst1[1:], lst2) return lst2 def main(): ''' Objective: To cr...
279908bcbb767243a43902ef18b80dedd85822a6
xzeck/CodeRepo
/ExceptionHandling.py
275
3.953125
4
res = 0 try: dividend = int(input("Enter Dividend")) divisor = int(input("Eenter Divisor")) res = dividend / divisor except ZeroDivisionError : print("Can't divide by Zero") except ValueError: print("Enter a valid input") finally : print(res)
bb57a54441bfce5796ac9814b077b26e5c0e0348
xzeck/CodeRepo
/CountStrings.py
612
4
4
Words = ["Some", "Random", "Words", "Because", "I", "Have", "To", "Add", "Words", "Into", "This", "List", "I", "Copy", "Pasted", "This", "Lol"] count = 0 WordsThatSatisfy = [] for Word in Words: if len(Word) > 2 : # Just remove the .upper() if you want to make it case sensitive FirstChar = Word[0...
58849331d99ed0c770619e1466c22b0223150274
xzeck/CodeRepo
/mostFrequentWords.py
247
4.28125
4
import nltk Data = input("Enter your string") TokenizedWords = nltk.tokenize.word_tokenize(Data, language='english') commonWords = nltk.FreqDist(w.lower() for w in TokenizedWords) FreqeuntWords = commonWords.most_common(3) print(FreqeuntWords)
949fd6983e621349169a9a604850cc60fdc1e011
xzeck/CodeRepo
/AddLsSomething.py
143
3.921875
4
Userinpt = input("Enter string\n") CheckLs = Userinpt[:2].upper() if CheckLs == 'LS': print(Userinpt) else : print ('ls' + Userinpt)
a6d4461e99d50cd622d2c76d48146f24c8b01445
xzeck/CodeRepo
/FindLongestWord.py
230
4.28125
4
Words = ["Some", "Random", "Words", "Because", "I", "Have", "To", "Add", "Words", "Into", "This", "List"] WordLength = int(input("Enter the word Length")) for Word in Words: if len(Word) > WordLength : print(Word)
8f32c599e9e2ecb59b658f9bcceaff8eecfa64d0
juanto121/codeo.app
/0x60.py
125
3.640625
4
stdin = input().split(" ") a = int(stdin[0]) b = int(stdin[1]) if (a == b): print("=") else: print(">" if a > b else "<")
60878481ed42133731971c49625568340e3a7269
Sakura-lyq/test
/magicians.py
740
3.609375
4
#循环遍历 magicians = ["alice","jone","jack"] for magician in magicians: print(magician) #编写for 循环时,对于用于存储列表中每个值的临时变量,可指定任何名称。 for magician in magicians: print(magician.title() + ", that was a great track!") print("I can't wait to see your next performance, " + magician.title() + ".\n") #缩进内容将针对列表中每...
a8d910d18ad33a470b99f7ed83fca196bb2ce5c1
echel0nn/dirty-but
/Cryptology/crypio_rsa_py3.py
1,107
3.875
4
""" ================================================ Y U B I T S E C ================================================ Created by echel0n_1881 @ 14 Kas 2017 This is a example for decrypt RSA with SQRT. This is not a good approach new RSA. ================================================ Y U ...
29eb84ce717f25c4c68379010bd1cf1d61e87359
adkozlov/python-2014
/homework_04/01.py
961
3.546875
4
#!/usr/bin/env python3 __author__ = "Andrew Kozlov" __copyright__ = "Copyright 2014, SPbAU" def argsToTuple(args, kwargs): return (args, tuple(kwargs.items())) class SingletonType(type): def __init__(self, *args, **kwargs): self.__instances = {} def __call__(self, *args, **kwargs): argsT...
090cedeed9c4050644a45ebbffb8889e314c1c20
ShubhamMMahajan/Alexa-Calorie-Burner
/basic_calculations.py
837
3.703125
4
''' Created on Jul 17, 2017 @author: shubham ''' def duration_minutes(duration): '''returns the number of minutes spent on the exercise assumes the format of alexa's AMAZON.DURATION type''' t_index = duration.index("T") if "H" in duration and "M" in duration: hour_index = duration.index('H') - 1 ...
1ed1256295dcf9ea317fb97b44217693865fed60
XiangLei5833/shiyanlou
/property.py
361
3.734375
4
#!/usr/bin/env python class Bird(object): feather = True class Chicken(Bird): fly = False def __init__(self, age): self.age = age def getAdult(self): if self.age > 1: return True else: return False adult = property(getAdult) summer = Chicken(2) print(summer.adu...
863b1c4219709236025ee78bf9b3f366b83d6f6a
XiangLei5833/shiyanlou
/decorator1.py
371
3.671875
4
#!/usr/bin/env python def decorator(F): def new_F(a, b): print('input', a, b) return F(a,b) return new_F @decorator def square_sum(a, b): return a**2 + b**2 @decorator def square_diff(a, b): return a**2 + b**2 print(square_sum(3,4)) print(square_diff(3,4)) # 相当于 square_sum = decorato...
f9feda849cc62d8528eaf23938d54671d8008be5
LinusU/devnull
/DICE/python.py
903
3.71875
4
#!/usr/local/bin/python3 """ def output_xml(data): print("xml") def output(data, format="xml"): globals()["output_" + format](data) output("hej") """ """ done = False def should(x): if globals()['done']: return False if (x % 2) == 1: globals()['done'] = True return False ...
4cb499ba099c912864edaa12f2d71dc5069febb3
shubhapatil154/PYTHON_1BM18CS419
/divisors.py
192
4.03125
4
def divisors(num): print(f'DIVISORS OF THE NUMBER {num} is') for i in range(1,num+1): if(num%i==0): print(i) num=int(input('ENTER THE NUMBER \n')) divisors(num)
b8e47ee043e0464b12d2f00a48a7993c5d5d00f1
esther1104/myPy
/DAY 20/20B-graph.py
467
3.640625
4
import turtle as t x_min=-5 x_max=+5 y_min=-5 y_max=+5 space=0.1 func_list=["y=x*x","y=abs(x)","y=0.5*x+1"] t.setworldcoordinates(x_min,y_min,x_max,y_max) t.speed(0) t.pensize(2) t.up() t.goto(x_min,0) t.down() t.goto(x_max,0) t.up() t.goto(0,y_min) t.down() t.goto(0,y_max) t.color("green") for func in func_lis...
cdad223907ee13c8076a15ae088a757864a8248b
esther1104/myPy
/DAY 13/13A-line.py
228
3.828125
4
import turtle as t t.bgcolor("black") t.speed(0) for x in range(200): if x %3==0: t.color("red") if x %3==1: t.color("yellow") if x %3==2: t.color("blue") t.forward(x*2) t.left(119)
a76fee02c989c8e4f69d88fab3a429554b9b183f
esther1104/myPy
/DAY 5/05C-sum.py
65
3.5625
4
s=0 for x in range(1,10+1): s=s+x print("x:",x,"sum:",s)
ba25a35390f713afaf4ef087105f9f6763c22f50
esther1104/myPy
/DAY 12/12C-polygon.py
267
3.796875
4
import turtle as t def polygon(n): for x in range(n): t.forward(50) t.lt(360/n) def polygon2(n,a): for x in range(n): t.fd(a) t.lt(360/n) polygon(3) polygon(5) t.up() t.forward(100) t.down() polygon2(3,75) polygon2(5,100)
0b502aaa75b0dd5f59ee6bfd727db0b2477d5c59
336459/Indic-PersoArabic-Script-Converter
/indo_arabic_transliteration/hindustani.py
5,469
3.5
4
URDU_POSTPROCESS_MAP = { # Normalizer to modern Urdu 'ڃ': "ںی", 'ݨ': 'ن', 'ࣇ': 'ل', } urdu_postprocessor = str.maketrans(URDU_POSTPROCESS_MAP) HINDI_TO_URDU_VOWELS_ABJAD = { } INITIAL_HINDUSTANI_MAP_FILES = ['hindustani_initial_vowels.csv'] HINDUSTANI_MAIN_MAP_FILES = ['hindustani_consonants.csv'...
438554a1b8acfb82c06995646aa56b7083c8742d
pablo-cerve/confucio
/file_utils/text_utils/text_file_writer.py
554
3.625
4
class TextFileWriter: def __init__(self, folder, filename, mode="w"): self.filename = filename self.written_lines = 0 self.file = open(folder + "/" + filename, mode) def write_line(self, line): self.file.write(line + '\n') self.written_lines += 1 def close(self): ...
bf220bb778565c6b7472e15678a919f63fc12093
mtn6807/adventOfCode2018
/day1/day1pt1.py
89
3.65625
4
file = open("input.txt") total = 0 for line in file: total += int(line) print(total)
1f332cc262568863a28ddf8168eaa5923d328413
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/String/Trie.py
1,981
3.78125
4
class Trie(object): class Node(object): CharCount = 26 def __init__(self, c, isLast = False): self.child = [None] * (self.CharCount) self.isLastChar = isLast self.ch = c def __init__(self): self.root = self.Node(' ') # first node wit...
1c9565252753f9b8abc650169e59fd38af6cdac7
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/AlgorithmsChapters/DP/LongestCommonSubseq.py
1,098
3.640625
4
def longest_common_subseq(X, Y) : m = len(X) n = len(Y) dp = [[0] * (n + 1) for _ in range(m + 1)] # Dynamic programming array. p = [[0] * (n + 1) for _ in range(m + 1)] # For printing the substring. # Fill dp list in bottom up fashion. for i in range(1, m+1) : for j in range(1...
ee986d7d67c45e7072179e3283876cb306d2a71b
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Heap/Heap.py
3,963
4.03125
4
import math class Heap: def __init__(self, isMin, array=None): if array == None: self.arr = [] else: self.arr = array self.size = len(self.arr) self.is_min_heap = isMin # Build Heap operation over array i = self.size // 2 while ...
6bcaa3789f6c3381c107154ef180dffe137637e4
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Tree/RBTree.py
9,713
3.765625
4
class RBTree : class Node : def __init__(self, data, nullNode) : self.data = data self.left = nullNode self.right = nullNode self.colour = True # New node are red in colour. # true for red colour, false for black colour ...
c8b8aa6d9b630f8e696ace58806f318a40a88261
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Collections/Heap.py
460
3.96875
4
import heapq hp = [3,1,2] # creates heap from list. heapq.heapify(hp) print(hp) heapq.heappush(hp, 6) # pushes a new item on the heap heapq.heappush(hp, 4) heapq.heappush(hp, 5) heapq.heappush(hp, 7) print(hp) print(len(hp)) print(hp[0]) # peek the smallest element of the heap. pr...
6f34bd22b0c321a2cbf44aea881f5b8eaa03407f
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/AlgorithmsChapters/Greedy/JoinRopes.py
891
3.609375
4
import heapq def join_ropes(ropes, size) : ropes.sort(key = lambda x: -x) total = 0 while (size > 1) : value = ropes[size - 1] + ropes[size - 2] total += value index = size - 2 while (index > 0 and ropes[index - 1] < value) : ropes[index] = ropes[index - 1] ...
04ebf323206188105b9b8f9ad4e4a881755a6e5f
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Queue/QueueList.py
1,307
4.21875
4
class Queue(object): class Node(object): def __init__(self, v, n=None): self.value = v self.next = n def __init__(self): self.head = None self.tail = None self.count = 0 def length(self): return self.count def is_empty(self): ...
a31d24c7a5cf24e10fa5bab303ab679b73f9619a
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/HashTable/HashTableExercise.py
2,059
4.03125
4
#!/usr/bin/env python from collections import Counter def is_anagram(str1, str2): size1 = len(str1) size2 = len(str2) if size1 != size2: return False cm = Counter() for ch in str1: cm[ch] += 1 for ch in str2: if cm[ch] == 0: return False else: ...
794313d14a76f1acfaeaed1bd5714965ce87d853
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Introduction/Analysis.py
3,697
3.859375
4
import math def fun1(n): m = 0 i = 0 while i < n: m += 1 i += 1 return m print("N = 100, Number of instructions in O(n)::", fun1(100)) """ N = 100, Number of instructions in O(n):: 100 """ def fun2(n): m = 0 i = 0 while i < n: j = 0 while j < n: ...
a862972e677f4811e1441d9686790a4364e8ccbb
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/String/StringCompare.py
7,625
3.6875
4
from collections import Counter import math def match_exp_util(exp, text, i, j): if i == len(exp) and j == len(text): return True if (i == len(exp) and j != len(text)) or (i != len(exp) and j == len(text)): return False if exp[i] == '?' or exp[i] == text[j]: return match_exp_util(ex...
c8560c3cc381d6d75552149c2a4bf598aff2cf73
reygvasquez/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Collections/Dictionary.py
656
4.03125
4
a = {} a["mango"] = 20 a["apple"] = 40 a["banana"] = 10 print(a) print(a["mango"]) print(a.get("mango")) print("apple" in a) """ {'mango': 20, 'apple': 40, 'banana': 10} 20 20 True """ a = dict() a["mango"] = 20 a["apple"] = 40 a["banana"] = 10 print(a) print(a["mango"]) print(a.get("mango")) print("apple" in a) ...