blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
022d1d89d419686f2ecf256f9e9a67aff141f13b
he44/Practice
/leetcode/35.py
822
4.125
4
""" 35. Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. """ class Solution: def searchInsert(self, nums, target) -> int: size = len(nums) # no element / smaller than f...
eb9651d9844134f7cbf28fff5e49ddf062110ef1
he44/Practice
/leetcode/2020_08_challenge/0808_closest_bst_value.py
707
3.796875
4
from typing import * # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def closestValue(self, root: TreeNode, target: float) -> int: closest = root.val ...
bf877c40c64b334d60be973c60d4f43452c9b62f
AltafHussain4748/Python3-Data-structures-and-Algorithms
/tests/linked_list/test_singly_linked_list.py
1,103
3.78125
4
from linked_list.doubly_linked_list import DoublyList from linked_list.singly_linked_list import LinkedList """Siingly Linked list test cases""" def test_singly_linked_list(): linked_list = LinkedList() linked_list.insert_at_first(10) assert list(linked_list.get_list()) == [10] linked_list.insert_at_...
13686c72ebf364d6eaa299569aa0d6c2ef5cd75c
iarzt/general
/TicTacToe.py
2,494
3.890625
4
from tkinter import * class TTT_Label(Label): def __init__(self, row, col, *args, **kwargs): super().__init__(*args, **kwargs) self.row = row self.col = col class Tic_Tac_Toe: def __init__(self): window = Tk() window.title("Tic Tac Toe") window["backgro...
87779df486ce62c1f00cf0b316fc3868bc36dfa3
grokcore/dev.lexycross
/wordsmithed/wordfrequency.py
6,031
3.84375
4
''' This class stores in a file the count of the words used by all players in all games. It can load and update the word frequency file wordfreq.txt ''' import dictionarywords, math class WordFrequency: FILENAME = "wordsmithed/media/wordfreq.txt" DICTIONARY = "wordsmithed/media/scrabblewords_usage.txt" def __i...
8f5dced4f85b9a5bacfd09757abff86db7784b4c
skongala/comp110-21f-workspace
/exercises/ex01/numeric_operators.py
444
3.9375
4
"""EX01 numeric operators.""" __author__: str = "730236986" left: int = int(input("Left-hand side: ")) right: int = int(input("Right-hand side: ")) print((str(str(left) + " ** " + str(right) + " is " + str(left ** right)))) print(str(str(left) + " / " + str(right) + " is " + str(left / right))) print(str(str(left) +...
bc870a6a0d768dfa7e2d09703686916d52fdf512
Gayathri200/gaya05
/facteve.py
116
3.734375
4
x1= int(input()) for i in range(1, x1 + 1): if x1 % i == 0: if i % 2 == 0: print(i,end=" ")
ef1286981bd1c27f2943c53e847bacdf22a74ebe
elee0004/ciss441
/Report3.py
817
4
4
import sqlite3 dbfile = 'payroll_dc_small.db' #database file conn = sqlite3.connect(dbfile) # connect to db # give me a new line print("Heather is a beast") def main(): #this is my header now print("{0:<25} {1:<10} {2:10}".format( "work_schedule", "salmax", "salmin")) cursor = conn.execute(""" ...
4677578c06216fc2ac7cf55c416d2e503133fcba
sdamico/m422
/quantize.py
13,619
3.890625
4
""" quantize.py -- routines to quantize and dequantize floating point values between -1.0 and 1.0 (" signed fractions ") """ ### ADD YOUR CODE AT THE SPECIFIED LOCATIONS ### import numpy as np import math ### Problem 1.a.i ### def QuantizeUniform(aNum,nBits): """ Uniformly quantize signed fraction aNum with ...
c67d78034867f9e12a716157ebb4795b0574adef
brady-wang/mac_home
/python/test/test_yield.py
333
4.03125
4
# *_*coding:utf-8 *_* def test(n): print("start") for i in range(1,n+1): print('yield start') yield i*i print("=======i*i========",i*i) print("yield end") item = test(2) item.__next__() item.__next__() a = [1,2,3,4] b = ['a','b','c','d'] print(zip(a,b)) for i,j in zip(a,b): ...
41a2dd5ef69107860ae66b46df40c7ab6f78f9b9
brady-wang/mac_home
/python/sort_test/bubble_sort.py
697
3.84375
4
# *_*coding:utf-8 *_* #对于一个长度为N的数组,我们需要排序 N-1 轮,每 i 轮 要比较 N-i 次。对此我们可以用双重循环语句,外层循环控制循环轮次,内层循环控制每轮的比较次数 def bubble_sort(sort_list,sort='asc'): if len(sort_list) <= 0: return [] count = len(sort_list) sorted_list = sort_list for i in range(0,count-1): print('第%d趟排序:' % (i + 1)) for...
bd9619986d8e78fba05a95ab9a5fe58deada7867
khinds10/CarTripComputer
/button.py
818
3.5625
4
#! /usr/bin/python # Car Trip Computer - button manager # Kevin Hinds http://www.kevinhinds.com # License: GPL 2.0 import time, commands, subprocess, re, json, sys, os, json import includes.data as data from gpiozero import Button from datetime import datetime # setup up button GPIO connections tripButton = Button(18)...
570be9729f4c8735e3fdd3aa7d474495d8605efa
zuffiiee/Python-bootcamp
/SimpleBanking.py
856
3.796875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: class Account: def __init__(self,owner,balance=0): self.owner=owner self.balance=balance def __str__(self): return f"Account owner: {self.owner}\nAccount balance: ${self.balance}" def deposit(self,amt): self.balance=self.b...
a47a53e05be4f0f4e99de9ee6aba6500bab3facd
llweston/SciSlice
/arc.py
2,276
3.78125
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 03 17:08:13 2015 A small module for easily creating arcs and circles. @author: lvanhulle """ from linegroup import LineGroup as LG import math from point import Point from line import Line import constants as c class Arc(LG): def __init__(self, start, end, dir...
e5d350fffdfda98da94c53e06d4ef0918832a41d
RobotTeam2/rMule
/motion_ctrl/gaits/tripod.py
1,874
3.78125
4
import time def forward(n_cycles, pause_time): """ Moves the robot forward n_cycles: int - The number of cycles to move foward pause_time: int - The number of seconds to wait between motions """ for i in range(n_cycles): motion_a() motion_b() def backward(n_cycles, pause_time):...
210b11d779fa8a22e8dab9835d4aa936d6bf8e33
Anjalics0024/GitLearnfile
/ListQuestion/OopsConcept/OopsQ6.py
633
3.890625
4
#Inheritance class A: def feature1(self): print("I am feture1 method") def feature2(self): print("I am feture2 method") class B(A): def feature3(self): print("I am feture3 method") def feature4(): print("I am feture4 method") #multi level inheritance clas...
158ebdaca82112ce33600ba4f14c92b2c628a2b8
Anjalics0024/GitLearnfile
/ListQuestion/OopsConcept/OopsQ10.py
880
4.3125
4
#Method Overloading :1. Compile time polymorphisam 2.Same method name but different argument 3.No need of more than one class #method(a,b) #method(a,b,c) class student: def __init__(self,m1,m2): self.m1 = m1 self.m2 = m2 def add(self,a= None, b=None, c=None): s = a+b+c return...
1cb7c37d3330c00ea3e891f68612b71c9380a73f
Anjalics0024/GitLearnfile
/python/PythonFile/stringQ1.py
740
4.09375
4
''' def checkString(string): flag_l = False flag_N = False for i in string: if i.isdigit(): flag_l = True if i.isalnum(): flag_N = True return flag_N and flag_l string = input("Enter a string : ") print(string) ''' def checkString(str): # intializing flag v...
b92a85bf2b03dae486c581bb5e370092be424f85
adrielvel/uip-prog3
/laboratorios/QUIZ2.py
1,257
4.03125
4
#Laboratorio #El Emperador está celebrando aniversario y ofrecerá a sus clientes una serie de ofertas que se traducirán en un incremento de sus ventas. #Las reglas de las ofertas se basan en un porcentaje de descuente sobre el total de la compra, que estarían variando dependiendo del monto adquirido. #Por un monto may...
7fdd98b1ce5a53755c91481870c9d0203496a0f2
ZxSnow/DLexercise
/keras/Course2.py
1,517
3.953125
4
""" keras教程2: CNN手写数字识别 """ import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten from keras.layers import Conv2D, MaxPooling2D from keras import backend as K (x_train, y_train), (x_test, y_test) = mnist.load_data() if K.image_data_format()...
5c68f00daf4d10c5b7fe36471f921d176c78671f
johndevera/sample_code
/python/engque dequeue.py
651
3.6875
4
#enqueue dequeue class person: numInLine = 0 def __init__(self): person.numInLine += 1 self.myNumberInLine = person.numInLine print(myNumberInLine) class bank: def __init__(self, line): if (line == None): self.line = [] self.line = line def enqueue(self, person): self.line.append(person) def...
e3dd2619d0c377c93bb531a0bee1d409eaeb48a0
johndevera/sample_code
/python/palindrome.py
295
3.921875
4
#prove string is palindrome #even or odd length does not affect resutl def isPalindrome(sen): length = int(len(sen) / 2) j = len(sen) - 1 for i in range(0, length): if(sen[i] == sen[j]): j -= 1 else: return False return True sen = "asbbsa" print(isPalindrome(sen))
fa3266def8de7675451c4e41a087de4def0158de
johndevera/sample_code
/python/twostacks.py
1,260
3.78125
4
class twoStacks: def __init__(self, n): self.size = n self.arr = [None] * n #list of nones for size n self.top1 = -1 self.top2 = self.size def push1(self, value): #there is at least one empty space #check if top1 is less than top2, that's less than half if(self.top1 < self.top2 - 1): self.top1 = s...
ccaaa8990f94cd7a875b6f8464e5b0fb5b1ad6f6
pavel-maru/lesson_07
/time_graf.py
3,736
3.921875
4
from random import randint import timeit # from matplotlib import pyplot as plt # вариант без индексов и с коротким if def mediana(array): for item in array: less = more = equal = 0 for el in array: if el < item: less += 1 elif el > item: ...
174848e6b0314ca5b149ccd87d38479a3436d5a3
eduardomartinsgit/otimizacaoemgrafos
/Trabalho.py
17,212
3.5625
4
import json import time import timeit #INICIO DA IMPLEMENTAÇÃO DE UMA FILA COMO ESTRUTURA AUXILIAR class Fila(): def __init__(self): self.dados = [] def insere(self, elemento): self.dados.append(elemento) def remove(self): return self.dados.pop(0) def length(self):...
2b49b6345403fc91b9dd06280c140c85f9fa47b5
sheepover96/deep_gui_othello
/game/base_game.py
3,638
3.5
4
from board.board import Board from user.user import User import numpy as np class BaseGame(): """ in this class, game process is written オセロゲームの処理を書いています. 先攻ユーザと後攻ユーザ,ボードのオブジェクトを与えて動かす. bowはblack or whiteの略です """ def __init__(self): #preceding attack user 先攻ユーザ self._user1 ...
2bbb958ee418fef7724d0a8f6cbe209e245b701b
wyfok/Solve_Sudoku_with_Crook_algorithm
/main.py
1,589
3.859375
4
from function import read_question_from_excel, loop_basic_rule, loop_algorithm, check_box_eliminate_others import copy # Input excel file path and sheet name excel_path = input("Input the file path of excel file: ") sheet_name = input("Input the sheet name: ") question = read_question_from_excel(excel_path, sheet_name...
21c9ea7b974ff026380fba48731a2421a14fc5d0
CROliveira/University-of-Toronto
/slabsmasher_final.py
6,145
3.671875
4
VHS_GRACE_DAYS = 7 DVD_GRACE_DAYS = 5 GAME_GRACE_DAYS = 2 VHS_FINE = 0.99 VHS_REWIND_FEE = 1.99 DVD_FINE = 2.99 GAME_FINE = 5.99 VHS_COST = 11.99 DVD_COST = 14.99 GAME_COST = 23.99 #grace period: VHS 7 DAYS #grace period: DVD 5 DAYS #grace period: Game 2 DAYS def get_late_days(days_checked_out:int, grace_period:int)->...
14dbe0c943976e274d4f5e40a49d51ae61c53786
unix1998/unix1998
/py_src/x02.py
101
3.90625
4
#! /usr/bin/python def f(x,l=[]): for i in range(x): l.append(i*i) print(l) f(3)
3cb296039455437fcb5e99b64b44963d01d6af28
axblueblader/model-evaluation
/tokenizer.py
515
3.53125
4
strip_chars = ',.\n\t()[]{}\\|\'\"<>*.-' def termize_doc(doc): tokens = set() for token in doc.lower().split(): tokens.add(token.strip(strip_chars)) return tokens def tokenize_str(str): tokens = list() for token in str.lower().split(): tokens.append(token.strip(strip_chars)) ...
bd3b2db019ce6b1231773fb0ddf44a750bea0414
zhuxiuwei/LearnPythonTheHardWay
/ex39.py
1,584
3.953125
4
# create a mapping of province to abbreviation provinces = { 'Jilin': 'jl', 'Beijing': 'bj', 'Shanxi': 'sx' } # create a basic set of states and some cities in them cities = { 'jl': 'Bai Shan', 'bj': 'Hai Dian' } # add some more cities cities['sx'] = 'Yan An' print cities.get('sss') #result: None print cities.g...
0cc3fb7a602f1723486a9e3f4f4394e7b4b89f90
zhuxiuwei/LearnPythonTheHardWay
/ex33.py
572
4.3125
4
def addNum(max, step): i = 0 numbers = [] while(i < max): print "At the top i is %d" % i numbers.append(i) i += step print "Numbers now: ", numbers print "At the bottom i is %d" % i return numbers numbers = addNum(10, 2) print "The numbers: ", numbers for num in numbers: print num # below is add point...
63bd71ef05186a5044f058159ec3896fb65c8b62
zhuxiuwei/LearnPythonTheHardWay
/ex18.py
480
4.03125
4
# this one is like your script with argv def print_two(*args): arg1, arg2 = args print "arg1: %r, arg2: %r" % (arg1, arg2) # ok, that *args is actually pointless, we can just do this. def print_two_again(args1, args2): print "arg1: %r, arg2: %r" % (args1, args2) # this just takes one argument def print_one(a): pr...
d0bc495402ab79e95cd45f459fc154bb1a34bf5f
zhuxiuwei/LearnPythonTheHardWay
/ex40_me.py
216
3.8125
4
lyrics = ['hello','world'] class Song(object): def __init__(self): self.a = lyrics b = lyrics def sing(self): for line in self.a: print line songA = Song() songA.sing() songA.a = ['b','c'] songA.sing()
c9ff052ce44b156a9669a9ac500f5849e94ea7e0
MinHyungChae/CodeUp
/1050.py
178
3.53125
4
# a와 b가 같으면 1을, 같지 않으면 0을 출력하는 프로그램을 작성해보자. a, b = input().split() if int(a) == int(b): print('1') else: print('0')
d3bb4a18c8ccd75083ee4d242d12ef7e78d31054
MinHyungChae/CodeUp
/1063.py
305
3.53125
4
# 입력된 두 정수 a, b 중 큰 값을 출력하는 프로그램을 작성해보자. # 단, 조건문을 사용하지 않고 3항 연산자 ? 를 사용한다. # [true_value] if [condition] else [false_value] // 파이썬 지원 a, b = input().split() print(int(a) if int(a) > int(b) else int(b))
4224dc6aa8a9c6e051e4192875ca0b956ae84dbf
MinHyungChae/CodeUp
/1076.py
104
3.59375
4
a = ord(input()) start = ord('a') for i in range(start, a+1): print(chr(i), end=' ', flush = True)
00e62904a51b2f5c3a92a0d55f3488e43ce9ef74
qzslz/Algorithm-Python
/Algorithm/Algorithm/SourceCode/Sort/InsertionSort.py
471
4.09375
4
""" 插入排序 """ def insertion_sort(list): list_len = len(list) for i in range(0,list_len): pre_index = i-1 for j in range(0,i+1): if pre_index >= 0 and list[pre_index+1] < list[pre_index]: list[pre_index],list[pre_index+1] = list[pre_index+1],list[pre_index] ...
bede35885a431b0785455c1bc986f467c887a462
pi-track/euler
/014/Euler14.py
667
3.796875
4
#problem 14 #longest collatz sequence #takes 10 seconds import time #function that takes some number a, and returns the length of the collatz chain def collatz(a): chain=1 while a != 1: if a%2==0: a=a/2 chain+=1 else: a=3*a+1 chain+=1 return ...
946f932c1088352ae82bfff95c000e1a1a9a4ba9
zhangyt3/advent-of-code
/2019/04/4.py
1,011
3.765625
4
start = 359282 end = 820401 def two_adjacent_digits(num): num = str(num) for i in range(len(num) - 1): if num[i] == num[i + 1]: return True return False def just_two_adjacent_digits(num): num = str(num) for i in range(len(num) - 1): if num[i] == num[i + 1]: ...
262f4ad2a7534908c7b4e73d4b842cf4e0b9a193
PaolaCNacif/Actividad-02
/cuenta.py
556
3.875
4
#encoding: UTF-8 # Autor: PaolaCastilloNacif, A01376654 # Descripcion: El programa mostrará el IVA, la propina y el total de una comida. # A partir de aqui escribe tu programa a=float(input("Costo de su comida")) print("Costo de la comida:$",a) b=0.15 c=(a*b) d=(a+c) print ("IVA:$",c) e=0.16 f=(a*e) print ("Propi...
c3e3f80c7a68a65eceba38ffb1b3b81d13543965
opaliss/classification
/ml_lib/decision_tree_support.py
5,134
3.640625
4
from ml_lib.ml_util import argmax_random_tie, best_index class DecisionFork: """ A fork of a decision tree holds an attribute to test, and a dict of branches, one for each of the attribute's values. """ indent = 4 # Tab size for printing def __init__(self, attr, distribution, attr_name=None,...
230f959d35d8e8f8e3d7fa98045d73896691f7dc
Pankaj-GoSu/Python-Data-Structure-Exercises
/450 Questions Of Data Structure/Qu3 Array.py
713
4.125
4
#====== Find the kth max and min elelment of an array ========= ''' Input --> N = 6 arr[] = 7 10 4 3 20 15 k = 3 output : 7 Explanation: 3rd smallest element in the given array is 7 ''' # kth smallest element list = [7,10,4,3,20,15] k = 3 asceding_list =[] def kth_min_element(list): i = list[0] if len(list...
0249f8cb4fce6702f631c51de53449e0e80b5fde
sidhanshu2003/LetsUpgrade-Python-Batch7
/Python Batch 7 Day 3 Assignment 1.py
700
4.3125
4
# You all are pilots, you have to land a plane, the altitude required for landing a plane is 1000ft, #if less than that tell pilot to land the plane, or it is more than that but less than 5000 ft ask pilot to # come down to 1000ft else if it is more than 5000ft ask pilot to go around and try later! Altitude = inpu...
4d4534b3d37204e1c3420ed4bd36fdb090b464ce
jreiher2003/MIT-computer-science
/11 testing and debugging/lecture11.py
457
4
4
# # # not a good program # just had to make a copy of the list before alisising it def silly(): res = [] done = False while not done: elem = raw_input('Enter element. Return when done. ') if elem == '': done = True else: res.append(elem) print 'res should be [1, a, 2] ', res tmp = res[:] print 'tmp',...
1c5d80a5243fb8636f82ca76f0cb1945d25627ec
ash8454/python-review
/exception-handling-class20.py
1,414
4.375
4
###Exception handling """ The try block lets you test a block of code for errors. The except block lets you handle the error. The finally block lets you execute code, regardless of the result of the try- and except blocks. """ try: print(x) except NameError: print("Variable x is not defined") except: p...
7e8cf8455bbc07fbe9e46c10a6f26dd188d599bc
ash8454/python-review
/if-else-class8.py
1,168
4.1875
4
#if else a = 3 b = 200 if b > a: print('b is greater than a') #if-elif-else a = 36 b = 33 if b > a: print('b is greater than a') elif b == a: print('b and a are equal') else: print('a is greater than b') #short hand if else c = 30 d = 21 if c > d: print('a is greater than b') #short hand if elif e ...
2e64a80c0b70d87e16d57ca235657d16cffa45f4
Cadesh/RandomForest
/RFLoop.py
4,567
3.671875
4
# SETUP ENVIRONMENT # conda install -c anaconda pandas # conda install -c anaconda numpy # conda install -c conda-forge matplotlib # conda install -c anaconda scikit-learn # https://chrisalbon.com/machine_learning/trees_and_forests/random_forest_classifier_example/ import pandas as pd import numpy as np # THIS CODE E...
0f26b50662decd207ceaf2ce4367b138a9644ee7
saad-ahmed/Udacity-CS-101--Building-a-Search-Engine
/hw_2_6-find_last.py
617
4.3125
4
# Define a procedure, find_last, that takes as input # two strings, a search string and a target string, # and outputs the last position in the search string # where the target string appears, or -1 if there # are no occurences. # # Example: find_last('aaaa', 'a') returns 3 # Make sure your procedure has a return stat...
f220465ff6e7ab0a46a8a47e8e38123b652a139c
saad-ahmed/Udacity-CS-101--Building-a-Search-Engine
/unit_3_25-measure_udacity.py
565
3.875
4
#Define a procedure, measure_udacity, #that takes its input a list of Strings, #and outputs a number that is a count #of the number of elements in the input #list that start with the letter 'U' #(uppercase). #For example, #measure_udacity(['Dave','Sebastian','Katy']) => 0 #measure_udacity(['Umika','Umberto']) => 2 ...
d62e68474da1fd1ab3b4930f25ea4e7bf496d129
arslan-asghar/Employee-Management-System
/triangle.py
667
3.921875
4
h = int(input("enter hypotenuse ")) row = 1 while row <= h: col = 1 while col <= row <= h: if col == 1 and row == 1: print("*", end=" ") col = col + 1 row = row + 1 break elif col == 1 and row < h: print("*", end=" ") col...
304209e430b17dad7f95bc66ce90801e8058c4d7
jxluo/Tiantian
/jx/log.py
3,383
3.71875
4
# The simple logger # This logger base on logging module import logging from time import localtime from time import strftime """ There are two log target: standard print and file system. Standard print means logging will print message at the console. File system means logging will save as a log file in the disk. The t...
4b2ea96d6bfe633a44f2e4e0358e6507fc03fd0b
Oslinjohn20/python-test
/numbers.py
111
4.34375
4
number= int(input("enter number: ")) if number % 2 == 0: print("Even") if number % 3 == 0: print("Odd")
6cac7771d33b28c6b010aa88ec90b1ae01cfa635
cesardlinx/aquatik
/models/database.py
1,461
3.84375
4
# -*- coding: utf-8 -*- import sqlite3 class Database(object): """Clase que se encarga del manejo de la base de datos, crea las tablas y la conexión """ @classmethod def connect(cls): """Crea la conexión a la base de datos""" try: db = sqlite3.connect('db.sqlite3') ...
cc7d73f41fa470481409b567808ec7197c7b7344
dekemurphy/EW432_Battleship
/main.py
2,492
3.5625
4
import pygame from pygame.locals import * import sys import colors import sprites import human from game_board import GameBoard import utilities BLOCK_SIZE = 30 NBLOCKS = 11 TOP_MARGIN = 30 PADDING = 10 def main(): pygame.init() screen: pygame.Surface = pygame.display.set_mode(((BLOCK_SIZE * NBLOCKS) * 2 +...
0793e9df4262195fb293c21fcdd22a4d42d0179a
brivonfeldt/Python_Challenge
/PyBank/main_pybank.py
1,517
3.59375
4
import os import csv csvpath = os.path.join('.', 'PyBank.csv') with open(csvpath, newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=",") print(csvreader) csv_header = next(csvreader) print(f'CSV Header: {csv_header}') reader_as_list = list(csvreader) number_of_months = len(read...
4949d64eecfd5606b84c490c93f1fcb73ccaf080
tyr924/CSC1002-LAB
/Week 5/Shift Cipher/shift2.py
476
4.03125
4
# Return the character after "value" positions def shift(ch, value): if ch.isalpha() and ch.isupper(): val = ord(ch) + value if val > ord('Z'): # Makes it work for Z, because otherwise it would be larger than the ascii limit val -= 2 elif val < ord('A'): # Somehow this and the pr...
fbb01c8dc5dc969f599e6638b1d6751faa1ba457
lapisanlangit/belajarpython
/5_komparasi.py
418
3.53125
4
a=4 b=2 hasil= a>b print(hasil) hasil= a<b print(hasil) hasil= a>=b print(hasil) hasil= a<=b print(hasil) c=4 hasil=c == 4 print(hasil) c=4 hasil=c != 5 print(hasil) # is adalah object identity x=5 y=5 print ('nilai x =',x,'id : ',hex(id(x))) print ('nilai y =',y,'id : ',hex(id(y))) hasil = x is y # hasil = x ...
33ef0e89097804aa27177186ac1bc03fabdc4db9
lapisanlangit/belajarpython
/8_asignment.py
105
3.515625
4
a=5 a+=1 #sama dengan a=a+1 print(a) a-=1 #sama dengan a=a-1 print(a) a*=2 #sama dengan a=a*1 print(a)
cdb7b7ba096285c5c6e732820544bd43c2e36a2b
varunkamboj11/python_project
/wheel.py
1,255
4.125
4
#create the account #print("1>:signup") #print("2>:create the acoount") a=int(input("1>: Create the account \n 2>: Signup ")) if(a==1): b=input("Firstname: ") print("Avoid using coomon words and include a mix of letters and numbers ") c=input("Lastname: ") print("PASSWORD MUST CONTAIN 1 NUMERIC 1 CHARAC...
fbf5d59a8a2ea7cadfc9c8868f39ea470c5b1b4e
willmeng98/Digital-Signatures
/visualwords/kmeans.py
4,421
3.765625
4
text_file_name = "kmeanstest.txt" text_file = open(text_file_name, "r") needtoremovecomma = False number_of_clusters = 2 writedata = False #write the data to file? final_file_name = "kmeanseval.txt" #final file to add to final_file_centers = 'kmeans_centers.txt' #file with the found centers of clusters from random ...
60653f32ea9ac907d26480a952ad23dfa2f29773
tokongs/TDT4110
/assignment_2/strings.py
800
4.09375
4
#a) thing1 = input("Matvare 1: ").lower() thing2 = input("Matvare 2: ").lower() print("Sammenligner", thing1, "og", thing2) if(thing1 == thing2): print("Dette er samme matvare") else: print("Dette er to forskjellige matvarer") name1 = input("Første navn: ") name2 = input("Andre navn: ") print("Under følger n...
1323912fba54f9ce1fbeb1bc9017fcc0a121249d
Xiaodong-Bran/python-algorithm
/bubbleSort.py
560
4.09375
4
# bubbleSort with python def bubbleSort(Mylist): # input a list # return a list with decreasing order n = len(Mylist) # print(n) for i in range(0,n-1): # outside loop from Mylist[0] to Mylist[n-2] for j in range(i+1,n): # inside loop from Mylist[i+1] to Mylist[n-1] / ...
80669245dda2bc39aced8d5b928d7d0c982bb2bb
aditisrinivas97/Pokerman
/helper scripts/gencsv.py
763
3.546875
4
''' usage: gencsv.py [-h] filename Generates CSV files for a given text file delimited by commas positional arguments: filename The text file which is to be converted to a CSV file optional arguments: -h, --help show this help message and exit ''' import csv import sys, os, argparse parser =...
11f72b91397f402434569481453f0d47a88ab0e3
NikolOlga/exam
/task2.py
392
3.96875
4
x = input("Введите х:") y = input("Введите y:") z = (int(x) % int(y)) print("Остаток от x деленого на y:", z) m = int(z*13) print("Увеличенный в 13 раз результат:" , m) n = (float(m))**0.5 print("Квадратный корень из результата:" , n) l = int(abs(n)) print("Модуль от результата:" , l)
c054dac317727cf04c830a7035a9821a124c7f73
LoyolaChicagoDigitalHumanities/case
/filter.py
3,149
3.546875
4
""" filter.py is a work in progress to rewrite input files containing hyphenation and dashes into a form that PC-Case can handle without generating false positives. This is documented by Peter Shillingsburg in a Google Drive document that I will turn into Markdown. This script is not at all ready for p...
dc9b1a84f866bceaf184db8d81c10b0bc6cfc0e2
acabar9/acabar9
/day18/심화2_약수.py
90
3.515625
4
yaksu = [] n=input() for x in range (1,n+1): if n % x == 0: yaksu.append(x) print yaksu
be3ef64864130be33c1f02d59f2979661ae96b9c
acabar9/acabar9
/day11/nine.py
97
3.546875
4
for a in range (1,10) : for b in range (2,10) : print b , "*" , a, "=" , a*b, " " , print
cb0c884ca9f505cf5c11e2fd977ac6f5799434a3
ghas-results/baklava
/examples/8-non-python-files/non_python_files/train.py
1,306
3.59375
4
""" Train ===== Defines functions which train models and write model artifacts to disk. """ from __future__ import print_function import pickle import pandas as pd from sklearn.tree import DecisionTreeRegressor from non_python_files import paths def train(x, y): """ Train a decision tree regressor using a ...
3bcb9d31e0fc5c7763201d84a7580ba187099e62
NandoSerrano85/python_workshop
/Project_4/hangman.py
5,349
3.90625
4
#!/usr/bin/env python2 # Project 4 class game: answer = "" show = list() guess = 0 player_1 = {"Name": "", "wins": 0, "loses": 0,} player_2 = {"Name": "", "wins": 0, "loses": 0,} def __init__(self, answer, players): self.answer = answer if len(players) == 1: self.pla...
adc17630c137191673b24d614a361bbf0e4a8f64
intershull/python
/ege.py
677
3.6875
4
# !(y->(x equil w)) and (z->x) # полная таблица истинности для этой логической функции def implic(a,b): if a==True and b==False: return False else: return True def equival(a,b): if a==b: return True else: return False def invers(a): if a==True: return False else: return Tru...
5abf37d31f6b3c89e3423b2e110d0c473876a8fa
garritfra/Practice-Projects
/Projects/Numbers/FindPiInNthDigit.py
374
3.84375
4
import math import sys input_length = input("Wie viele Nachkommastellen von Pi wollen Sie berechnen?: ") n = input_length def calculate_Pi(n): if(n > 10): print("Dieses Programm kann leider nur 10 Nachkommastellen berechnen") sys.exit() pi = math.pi pi_rounded = round(pi, n) ret...
16ea140345b98ce8cf06fe2b5248dda3a4980b23
yuki-machino/atcoder
/AGC037/A.py
237
3.5
4
S = input() count = 1 strings = [] strings.append(S[0]) stack = '' for s in S[1:]: stack += s if strings[-1] == stack: continue else: strings.append(stack) stack = '' count+=1 print(count)
ddee1127f7540095de43347235fca28660c3c9e0
yuki-machino/atcoder
/0622/OrdinaryNumber.py
378
3.5625
4
num = int(input()) numbers = [ int(i) for i in input().split()] count = 0 for i in range(len(numbers)): if i == 0: continue elif i == num-1: continue else: if numbers[i] < numbers[i-1] and numbers[i] > numbers[i+1]: count +=1 elif numbers[i] > numbers[i-1] and num...
970bb45354cccfa5689552ef3a662895180f3da1
vijayv500/Hyderabad-Housing-Prices
/streamlit.py
2,053
3.890625
4
import pandas as pd import streamlit as st from wordcloud import WordCloud import matplotlib.pyplot as plt from collections import Counter st.set_option('deprecation.showPyplotGlobalUse', False) st.title('Find Out Builders In Your Locality: Hyderabad') st.markdown(""" This app displays list of builders in your loc...
0bf1ee8257be00fae97b90537e9d7be87aee794f
KadirEmreOto/hackerrank
/greedy/grid-challenge.py
438
3.53125
4
T = int(raw_input()) for _ in xrange(T): N = int(raw_input()) matrix = [] for _ in xrange(N): matrix.append(sorted(list(raw_input()))) for j in xrange(N): check = True for i in xrange(N-1): if matrix[i][j] > matrix[i+1][j]: check = False ...
c8ff811265dfef6ff4f8b7b29f3544d417fe4204
KadirEmreOto/hackerrank
/dynamic-programming/maxsubarray.py
1,154
3.53125
4
def NonContiguous(array): m = max(array) if m <= 0: return m c = 0 for i in array: if i > 0 : c += i return c def Shrink(array): temp = [] mid = array[0] result = max(array) if result <= 0: return [result] for i in xrange(array.count(...
0c8292d2bf37f8031cd1dfd9fa327b0a78842e7b
KadirEmreOto/hackerrank
/game-theory/alice-and-bobs-silly-game.py
374
3.5625
4
from bisect import bisect def sieve(n): sieve = [True] * n for i in xrange(3,int(n**0.5)+1,2): if sieve[i]: sieve[i*i::2*i]=[False]*((n-i*i-1)/(2*i)+1) return [2] + [i for i in xrange(3,n,2) if sieve[i]] p = sieve(10**5 + 10) for i in xrange(input()): n = int(raw_input()) t = ...
2db68b07ba0f7967dfcf511dd73013ed657aa42e
wangtao664/pythonLean
/pythonBasics/support.py
275
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def print_func( par ): print "Hello : ", par return # 可写函数说明 def sum( arg1, arg2 ): # 返回2个参数的和." total = arg1 + arg2 print "函数内 : ", total return total; #print(str(sum(10,5)));
d7a51f2eabba8da6c74a184e518dacf683a0651a
Gioia31/tuttainfo
/es25p293.py
1,684
4.1875
4
''' Crea la classe Triangolo, la classe derivata TriangoloIsoscele e, da quest'ultima, la classe derivata TriangoloEquilatero. ''' class Triangolo(): def __init__(self, lato1, lato2, lato3): self.lato1 = lato1 self.lato2 = lato2 self.lato3 = lato3 def info_scaleno(self): ...
dd7e75369f7682dd1f594a259e096800dc012ac0
josflesan/txtfilemanager
/main.py
11,598
3.796875
4
# txtFileManager.py module # Module used to manipulate text files # Coded by Lemur from contextlib import contextmanager # https://docs.python.org/2/library/contextlib.html import os # https://docs.python.org/2/library/os.html def help(): # Visual output of all the functions and brief description ...
3b60c921a0097aa46bfda6dda00f1e5cfcf7488e
longluo/Python
/basic/set.py
305
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Set # 2015年07月21日05:29:45 s = set([1, 2, 3]) print s # No Same Values s = set([1, 1, 2, 2, 3, 3]) print s # Add Key s.add(5) print s # Remove Key s.remove(2) print s # s1 = set([1, 2, 3]) s2 = set([2, 3, 4]) print s1 & s2 print s1 | s2
c074584b6de97d7fe5d46b22e98f9b65e8488655
longluo/Python
/oop/human.py
417
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # OOP Extendsion # 2015-08-05 02:56:01 class Human(object): laugh = 'hahahaha' def show_laugh(self): print self.laugh def laugh_100th(self): for i in range(100): self.show_laugh() li_lei = Human() li_lei.laugh_100th() def HappyMan(Human): def __init__(self,...
080455c64bc9a4d2ccf19f871e7ea8416ebf8369
themadgnomeking/ch5_atbs
/fantasy_game_inventory/add_to_inventory.py
1,246
3.875
4
def display_inventory(inventory): print("Inventory:") item_total = 0 for k, v in inventory.items(): print(str(v) + " "+ k) item_total += v print("Total number of items: " + str(item_total)) def addToInventory(inventory, addedItems): # your code goes here #receive the inventory a...
af2f0346e4c759079384c545b9debacb21fe095b
fc-wsd/s6-attendance
/nsw9211_attendance1.py
467
3.765625
4
from datetime import datetime students = ["차경묵","김지훈","손형우","남시욱"] attendances = {} #key = name , value = time def attend(name,is_attend): if is_attend == 'True': attendances[name] = datetime.now() else: attendances[name] = "출석안함" for student in students: print(student,"님 출석 하셨습니까?") ...
0a931ec8893f5c703395e86122de35fedb205e1c
fc-wsd/s6-attendance
/zeropol2_attendance2.py
2,324
3.609375
4
# 홍창우 # class를 사용한 출석부 class Attendee: name = "" status = False def __init__(self, name): self.name = name def attend(self, status): self.status = status class Attendance: # 상수 정의 USER_ACTION_PRINT = 1 USER_ACTION_ATTEND = 2 USER_ACTION_EXIT = 3 _user_action = ...
bf09bf3e7d108a794beaefad5402778ed4733d81
mikeodf/Python_3D_Graphics
/ch3_prog_6_2d_concatenated_transforms_1.py
5,310
4.0625
4
""" ch3 No.6 Program name: 2d_concatenated_transforms_1.py Objective: Demonstrate concatenated transforms. Keywords: 2d objects, concatenated operations. ============================================================================79 From the book "Python Graphics for Games: Working in 3 Dimensions" Comments: The...
eb0caef6ad1a088d72a44e46997ca7b1ebf75518
mikeodf/Python_3D_Graphics
/ch9_prog_5_opengl_boxy_triangles_1.py
7,358
3.9375
4
""" ch9 No.5 Program name: opengl_boxy_triangles_1.py Objective: Use variable parameters to define multiple objects. keywords: opengl, glut, triangles, boxes, color control ==============================================================================79 From the book "Python Graphics for Games: Working in 3 Dim...
87cc5f04de0614b9ed6c5f2fbc79b83fec82a3c2
mikeodf/Python_3D_Graphics
/ch4_prog_3_3d_2d_shape_conversion_and_rotation_1.py
3,709
4.1875
4
""" ch4 No.3 Program name: 3d_2d_shape_conversion_and_rotation_1.py Objective: Rotate a shape about X, Y, Z or all selected axes in any position. Keywords: 3d projections, 2d shapes, transforms, arbitrary rotation.. ============================================================================79 From the book "Pyth...
e0d2b60a9c98b95f012ff78a14ae00df2ac9447f
mikeodf/Python_3D_Graphics
/ch8_prog_5_opengl_perspective_rotations_1.py
5,407
3.859375
4
""" ch8 No.5 Program name: opengl_perspective_rotations_1.py Objective: Construct a general cube. Demonstrate independent rotation of multiple instances of the cubes. keywords: opengl, points, lines, variable cube, independent rotation ============================================================================...
402ae00f80fcf9cba596e44c5299ae4c044281ad
mikeodf/Python_3D_Graphics
/ch10_prog_4_tri_centroid.py
1,461
3.859375
4
""" ch10 No.4 Program name: tri_centroid.py Objective: Locate the centroid of a triangle. Keywords: OpenGL, triangle, centroid. ============================================================================79 From the book "Python Graphics for Games: Working in 3 Dimensions" Comments: This is a precursor to mak...
cf77842de243ca7510395a2136be2b7282e6dca3
VIPersaud/calculator
/calculator.py
1,676
4.09375
4
import time ############################### def start_menu(): time.sleep(1) start_choice = input('Start? (y/n) ') if start_choice == ('y'): choose_menu() else: start_menu() def choose_menu(): print('1. Sum') print('2. Substraction') print('3. Multiplication. ') print(...
49789b6c77e92366bad954c702df6cf6f7ec3c45
DroogieDroog/pirple_python_is_easy
/hw11/main.py
1,503
3.640625
4
""" pirple/python/hw11/main.py Homework Assignment #11 Play around with error handling """ import statistics as stat def stats_table(test_data, mean, mode, med, std, var): print ('The sample data is: ') print(test_data) print() print('STATISTICS') print('----------') print('Mean: ', mean) ...
8f541c53b39934fb36bf6e70284ea0fb613f9d0f
DroogieDroog/pirple_python_is_easy
/project2/main.py
8,231
4.25
4
""" pirple/python/project2/main.py Project #2 Create a hangman game """ from os import system, name from time import sleep from random import randint import string def clear_screen(): # for windows if name == 'nt': _ = system('cls') # for mac and linux(here, os.name is 'posix') else: ...
c2684645de8398459d8fb0c969c6511f670ffee3
jingxa/CS131_release
/hw4_release/seam_carving.py
12,518
3.546875
4
""" CS131 - Computer Vision: Foundations and Applications Assignment 4 Author: Donsuk Lee (donlee90@stanford.edu) Date created: 09/2017 Last modified: 10/19/2018 Python Version: 3.5+ """ import numpy as np from skimage import color def energy_function(image): H, W, _ = image.shape out = np.zeros((H, W)) ...
58b9a3af3aafb856075bf66f8e29d73aee1d28b5
HereticFy/Sorting_Algorithm_Visualization
/venv/bubbleSort.py
4,770
3.796875
4
import time ''' 冒泡排序算法的运作如下: 1、比较相邻的元素。如果第一个比第二个大(小),就交换他们两个。 2、对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。这步做完后,最后的元素会是最大(小)的数。 3、针对所有的元素重复以上的步骤,除了最后已经选出的元素(有序)。 4、持续每次对越来越少的元素(无序元素)重复上面的步骤,直到没有任何一对数字需要比较,则序列最终有序。 (1)时间复杂度 在设置标志变量之后: 当原始序列“正序”排列时,冒泡排序总的比较次数为n-1,移动次数为0,也就是说冒泡排序在最好情况下的时间复杂度为O(n); 当原始序列“...
67cc4a85ba761e3e87347856a0a499ac45fd2cd1
PreetiLo/loop
/26febloop.py
3,266
3.578125
4
# h=int(input("enter an integer")) # i=0 # while i<=h: # j=1 # while j<=i: # print(j,end="") # j+=1 # i+=1 # i=1 # j=1 # while i<4: # while i<4: # print(i,",",j) # j=j+1 # i=i+1 # rows=5 # i=1 # while i<=rows: # j=1 # while j<=rows: #...
4be4c565d885651c732d497bfef82ff4e631bce0
PreetiLo/loop
/edurekapyathonforloop.py
1,685
3.765625
4
# company = ['E','D','U','R','E','K','A'] # for x in company: # if x == "R": # break (countinu) # print(x) # # color = ["blue", "white"] # vehicle = ['car', 'bike', 'truck'] # color_comb = [(x,y) for x in color for y in vehicle] # print(color_comb) # res = 1 # for i in range(...
39b570c85a33be3885fc4cd43f40277f755ebc66
PreetiLo/loop
/Pattern2.py
109
3.828125
4
i=1 while i<=1: print("5"*5) print("4"*5) print("3"*5) print("2"*5) print("1"*5) i+=1
ab752a46ff44668f1ba0205bd107e528add960f9
PreetiLo/loop
/anypattarn.py
1,220
4
4
# n=5 # for i in range(n,0,-1): # for j in range(i): # print('* ', end="") # print('') # In this pattern for right angle # n=5 # for i in range(n): # for j in range(i): # print ('* ', end="") # print('') # In this pattern for down angle # i=1 # while i<=10: # j=1 # while ...