blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
8eddcd6f8233db0f57f508f7dc69dc7acc870aea
yubaoliu/PythonFromScratch
/basics/directory.py
1,518
3.890625
4
import os import tempfile # define the access rights access_rights = 0o755 print("===========================") print("Creating a Directory ") # define the name of the directory to be created path = "/tmp/year" print("Create directory: %s" % path) try: os.mkdir(path, access_rights) except OSError as error: pr...
753239b3b82d38acc5ef487a3c2b29a0344a7584
SarcoImp682/Zookeeper
/Topics/Program with numbers/Difference of times/main.py
391
3.953125
4
# put your python code here # start time hour_start = int(input()) minutes_start = int(input()) seconds_start = int(input()) # stop time hour_stop = int(input()) minutes_stop = int(input()) seconds_stop = int(input()) # conversion start = hour_start * 3600 + minutes_start * 60 + seconds_start stop = hour_stop * 3600...
9ad802d0eac6567184e459e7ce6f4e82bf8110c0
agupta7/COMP6700
/softwareprocess/test/AngleTest.py
4,471
3.875
4
import unittest import softwareprocess.Angle as A class AngleTest(unittest.TestCase): def setUp(self): self.strDegreesFormatError = "String should in format XdY.Y where X is degrees and Y.Y is floating point minutes" # --------- # ----Acceptance tests # ----100 Constructor # ----Boundary value confidence...
6093dccc4f5ed895fb8f69572589deb55c086102
talivaro/Generadores-aleatorios
/CongruCombinado.py
417
3.8125
4
__author__ = 'Talivaro' xo1=int(input("Ingrese el valor de xo1: ")) xo2=int(input("Ingrese el valor de xo2: ")) xo3=int(input("Ingrese el valor de xo3: ")) repe=int(input("Numero de valores: ")) for i in range(repe): xn1=float((171*xo1)%30269) xn2=float((172*xo2)%30307) xn3=float((173*xo3)%30323) ui=flo...
a6b2127082c3e3eccf8098d8e370d701c5a876db
BlackMetall/trash
/lesson 9 (practice1).py
959
4.1875
4
#Задача 1. Курьер #Вам известен номер квартиры, этажность дома и количество квартир на этаже. #Задача: написать функцию, которая по заданным параметрам напишет вам, #в какой подъезд и на какой этаж подняться, чтобы найти искомую квартиру. room = int(input('Введите номер квартиры ')) # кол-во квартир floor = int...
a40410c97ef48d989ce91b6d23262720f60138dc
rajeshberwal/dsalib
/dsalib/Stack/Stack.py
1,232
4.25
4
class Stack: def __init__(self): self._top = -1 self.stack = [] def __len__(self): return self._top + 1 def is_empty(self): """Returns True is stack is empty otherwise returns False Returns: bool: True if stack is empty otherwise returns False ...
04d70de92bfca1f7b293f344884ec1e23489b7e4
rajeshberwal/dsalib
/dsalib/Sorting/insertion_sort.py
547
4.375
4
def insertion_sort(array: list) -> None: """Sort given list using Merge Sort Technique. Time Complexity: Best Case: O(n), Average Case: O(n ^ 2) Worst Case: O(n ^ 2) Args: array (list): list of elements """ for i in range(1, len(array)): current_num = array[...
a0f2d86b20acd3f19756667801f081902827b8d7
Manoj-sahu/datastructre
/Stack/StackUsingList.py
414
3.875
4
class StackUsingList(): def __init__(self): self.stack = [] def push(self, item): self.stack.append(item) def peek(self): return self.stack[-1] def pop(self): self.stack.pop() if __name__ == '__main__': stack = StackUsingList() stack.push(1) s...
8c7ab2d2161d94f612f7102e05c04c8e4e888a71
Manoj-sahu/datastructre
/LinkedList/1.1.py
1,083
3.53125
4
"""for finding duplicate first approach iterate to loop and maintain count in dictionary and if you find then remove the refrence of that loop. brute force approcah could be take head item and keep checking for all the items""" #import IP.LinkedList.10 #from IP.LinkedList.L import LinkedList import L newLinkedList =...
7d1221ec5c9cdbb8435ecaf0be51a6daa11ae3d2
nishthagoel712/DSA
/Graph/TopologicalSorting.py
575
3.828125
4
from collections import defaultdict visited=defaultdict(bool) stack=[] def topological_sort_util(adj,vertex): visited[vertex]=True for node in adj[vertex]: if not visited[node]: topological_sort_util(adj,node) stack.append(vertex) def topological_sort(adj): for vertex i...
3009a3a33a23b282111c2fc0fba9cf050e0fe599
nishthagoel712/DSA
/Dynamic Programming/Maximum size reactangle of all 1's.py
1,543
3.59375
4
# arr represent given 2D matrix of 0's and 1's # n is the number of rows in a matrix # m is the number of columns in each row of a matrix def rectangle(arr, n, m): maxi = float("-inf") temp = [0] * m for i in range(n): for j in range(m): if arr[i][j] == 0: temp[j...
fc89a46754b7a31c7335517bc4b639aa5eab6e12
darksinge/rmb-search-engine
/bill_files/clean_empty_bills.py
471
3.6875
4
import glob, os """ Simple script to detect and remove files that have no information on them in this folder """ """ files = glob.glob('*.txt') for file in files: f = open(file, 'r') contents = f.read() should_delete = False if 'The resource you are looking for has been removed, had its name changed, o...
93a955fcd9477724d916877075fac5b29227857a
darksinge/rmb-search-engine
/create_sparse_matrix.py
3,142
3.703125
4
""" Creates a sparse inverse dictionary for tf-idf searches. The CSV file produced by bill_data_analysis.py is so large that this file is needed to produce something much smaller to be used for the searches """ import pandas as pd import os import json import pickle import sys from default_path import default_path de...
22e56d8ab2a43434aac7d3c8c5aa589a3af5b2c5
kori07/prak_asd_b
/UAS_044_047_053/aplikasi.py
20,086
3.828125
4
#Program by Kelompok Susi Triana Wati,Program Pencarian Serta Pengurutan dengan Bubble Sort. from Tkinter import Tk,Frame,Menu from Tkinter import* import tkMessageBox as psn import ttk import tkFileDialog as bk from tkMessageBox import * import Tkinter as tk from winsound import * import platform os = platfo...
6705bd7dfa677bd27dbcf200aaa3f7dc6cd6cb55
laurenc176/PythonCrashCourse
/Lists/simple_lists_cars.py
938
4.5
4
#organizing a list #sorting a list permanently with the sort() method, can never revert #to original order cars = ['bmw','audi','toyota','subaru'] cars.sort() print(cars) #can also do reverse cars.sort(reverse=True) print(cars) # sorted() function sorts a list temporarily cars = ['bmw','audi','toyota'...
68654f6011396a2f0337ba2d591a7939d609b3ed
laurenc176/PythonCrashCourse
/Files and Exceptions/exceptions.py
2,711
4.125
4
#Handling exceptions #ZeroDivisionError Exception, use try-except blocks try: print(5/0) except ZeroDivisionError: print("You can't divide by zero!") #Using Exceptions to Prevent Crashes print("Give me two numbers, and I'll divide them") print("Enter 'q' to quit.") #This will crash if second number is ...
b52ad63f303e4160d7a942cad8481f2f77edf1f0
laurenc176/PythonCrashCourse
/Testing your code/testing_a_class.py
3,250
4.40625
4
# Six commonly used assert methods from the unittest.TestCase class: #assertEqual(a, b) Verify a==b #assertNotEqual(a, b) Verify a != b #assertTrue(x) Verify x is True #assertFalse(x) Verify x is False #assertIn(item, list) Verify that item is in list #assertNotIn(item, list) Verify that item is not in ...
4ec62e344d96dbd9db5860338526bb608a702a99
honzaKovar/docker_unittest
/prime_numbers.py
423
3.90625
4
import math from random import randint def is_prime(number): if number < 2: return False for i in range(2, int(math.sqrt(number) + 1)): if number % i == 0: return False return True if __name__ == '__main__': MIN_VALUE = 0 MAX_VALUE = 999 random_number = randint(M...
fbc01f2c549fae60235064d839c55d98939ae775
martinskillings/tempConverter
/tempConverter.py
2,231
4.3125
4
#Write a program that converts Celsius to Fahrenheit or Kelvin continueLoop = 'f' while continueLoop == 'f': celsius = eval(input("Enter a degree in Celsius: ")) fahrenheit = (9 / 5 * celsius + 32) print(celsius, "Celsius is", format(fahrenheit, ".2f"), "Fahrenheit") #User prompt t...
3f6b3832e8c1b33cb1e03ae6a026236f1d82a171
StarryLeo/learnpython
/day0/do_if.py
286
4
4
height = 1.75 weight = 80.5 bmi = weight/height * height if bmi < 18.5: print('过轻') elif bmi >= 18.5 and bmi < 25: print('正常') elif bmi >= 25 and bmi < 28: print('过重') elif bmi >= 28 and bmi < 32: print('肥胖') else: print('严重肥胖')
6d9c2f166469c4767ad6815edccc79f5306ae3c1
est/snippets
/sort_coroutine/mergesort.py
1,417
4.03125
4
import random def merge1(left, right): result = [] left_idx, right_idx = 0, 0 while left_idx < len(left) and right_idx < len(right): # change the direction of this comparison to change the direction of the sort if left[left_idx] <= right[right_idx]: result.append(left[le...
fae09bb082a160bfc2cf1c165250c551d6f70387
cdpruitt/CribbageAI
/GameActions.py
5,135
3.5625
4
from Card import * from itertools import * class History(): def __init__(self, playerToLead): self.rounds = [RoundTo31(playerToLead)] def isTerminal(self): totalCardsPlayed = 0 for roundTo31 in self.rounds: for play in roundTo31.board: if(play=="PASS"): ...
22c396d0cb06c25ea3162191dfa536672be1bd7c
GiPyoK/Sprint-Challenge--Data-Structures-Python
/names/binary_search_tree.py
4,965
3.828125
4
from dll_queue import Queue from dll_stack import Stack class BinarySearchTree: def __init__(self, value): self.value = value self.left = None self.right = None # Insert the given value into the tree def insert(self, value): # This would be only needed if there was deleted...
39a26f9febc2acc3ce0e3291c1dbe45801418275
deep-compute/deeputil
/deeputil/keep_running.py
5,090
3.84375
4
"""Keeps running a function running even on error """ import time import inspect class KeepRunningTerminate(Exception): pass def keeprunning( wait_secs=0, exit_on_success=False, on_success=None, on_error=None, on_done=None ): """ Example 1: dosomething needs to run until completion condition wi...
7011bfd3326ccb843859999aaf89c71a3137cdd4
skylway/leetcode
/python/0344. 反转字符串/solution.py
472
3.71875
4
#!/usr/bin/python from typing import List class Solution: def reverseString(self, s: List[str]) -> None: # s.reverse() # s[:] = s[::-1] i = 0 len_list = len(s) while i < len_list/2: s[i], s[len_list-i-1] = s[len_list-i-1], s[i] i += 1 """ ...
79723bc580e8f7ccd63a8b86c182c783a56d3329
SuzanneRioue/programmering1python
/Lärobok/kap 8/kap. 8, sid. 103 - list comprehensions.py
1,297
4.34375
4
#!/usr/local/bin/python3.9 # Filnamn: kap. kap. 8, sid. 103 - list comprehensions.py # Kapitel 8 - Listor och tipplar # Programmering 1 med Python - Lärobok # Exempeldata listaEtt = [9, 3, 7] # Med listomfattningar (list comprehensions) menas att man skapar en ny lista # där varje element är resultatet av någon op...
417e9bbc0a001695bc2cd7586b71b5a8b89832ee
SuzanneRioue/programmering1python
/Arbetsbok/kap 14/övn 14.1, sid. 36 - söka tal.py
1,443
3.921875
4
#!/usr/local/bin/python3.9 # Filnamn: övn 14.1, sid. 36 - söka tal.py # Sökning # Programmeringsövningar till kapitel 14 # Programmet slumpar först fram 20 tal mellan 1 och 100 och lagrar alla talen i # en lista och sedan skrivs listan ut på skärmen. Därefter frågar programmet # användaren efter ett tal som ska ef...
f38757087bf31b61d8238f3e98798a8799f1b6f8
SuzanneRioue/programmering1python
/Lärobok/kap 8/kap. 8, sid. 104 - sammanfattning med exempel.py
2,712
4.1875
4
#!/usr/local/bin/python3.9 # Filnamn: kap. 8, sid. 104 - sammanfattning med exempel.py # Kapitel 8 - Listor och tipplar # Programmering 1 med Python - Lärobok # Exempeldata lista = [7, 21, 3, 12] listaLäggTill = [35, 42] listaSortera = [6, 2, 9, 1] listaNamn = ['Kalle', 'Ada', 'Pelle', 'Lisa'] # len(x) Ta reda på an...
d5448c074c4419908d4c5246e1d87f792fd28731
SuzanneRioue/programmering1python
/Arbetsbok/kap 14/övn 14.3, sid. 37 - gissa ett tal.py
1,650
3.921875
4
#!/usr/local/bin/python3.9 # Filnamn: övn 14.2, sid. 36 - söka tal med funktion.py # Sökning # Programmeringsövningar till kapitel 14 # Programmet slumpar först fram ett tal mellan 1 och 99 och lagrar det talet. # Därefter frågar datorn användaren vilke tal datorn tänker på och användaren # får gissa tills han/hon...
60febc4082a4c46d7a0da215bc70e5531777ad75
SuzanneRioue/programmering1python
/Arbetsbok/kap 3/övn 3.4 - ange valfri rabatt på vara - kap 3, sid. 5.py
1,098
4.09375
4
#!/usr/local/bin/python3.9 # Filnamn: övn 3.4 - ange valfri rabatt på vara - kap 3, sid. 5.py # Skapa program eller skript # Programmeringsövningar till kapitel 3 - Arbetsbok # Programmet frågar först efter ordinarie pris på en vara. Därefter frågar det # efter en godtycklig rabattprocent # Till sist skriver det ut ...
4ceb64bae252b6c7acd59332297c3ccc02023694
SuzanneRioue/programmering1python
/Arbetsbok/kap 10/övn 10.1 - lottorad.py
1,306
3.546875
4
#!/usr/local/bin/python3.9 # Filnamn: övn 10.1 - lottorad.py # Slumptal i programmering # Programmeringsövningar till kapitel 10 # Programmet slumpar fram en lottorad, 7 tal i intervallet 1 - 35 där samma # nummer inte får uppkomma 2 gånger from random import randrange # Funktionsdefinitioner def lottorad(): ...
a969e3ff963ef2ed1980e8ff48bf4c048dfefde9
SuzanneRioue/programmering1python
/Lärobok/kap 6/kap. 6, sid. 76 - kontrollera innehåll och tomma strängar.py
842
3.703125
4
#!/usr/local/bin/python3.9 # Filnamn: kap. 6, sid. 76 - kontrollera innehåll och tomma strängar.py # Kapitel 6 - Mer om teckensträngar i Python # Programmering 1 med Python - Lärobok # Kontrollera innehåll i en sträng med operatorn in if 'r' in 'Räven raskar över isen': # Kontroll av enstaka tecken print('Bok...
e415fc6296d368d63a75ef1a8a50e7182820a49c
SuzanneRioue/programmering1python
/Arbetsbok/kap 3/övn 3.7 - Additionsövning med formaterad utskrift med flyttal - kap 3, sid. 6.py
759
3.90625
4
#!/usr/local/bin/python3.9 # Filnamn: övn 3.7 - Additionsövning med formaterad utskrift med flyttal - kap 3 # sid. 6.py # Skapa program eller skript # Programmeringsövningar till kapitel 3 - Arbetsbok # Additionsövning med formaterad utskrift # Programmet skriver ut tal i en snygg additionsuppställning # Skriv ut p...
1a6cf574b1498ca03608892dcfe185605b909bd5
SuzanneRioue/programmering1python
/Lärobok/kap 16/kap. 16, sid. 186 - omvandla dictionary till olika listor.py
929
3.609375
4
#!/usr/local/bin/python3.9 # Filnamn: kap. 16, sid. 186 - omvandla dictionary till olika listor.py # Kapitel 16 - Mer om listor samt dictionaries # Programmering 1 med Python - Lärobok # Kodexempel från boken med förklaringar # Skapa en associativ array (dictionary) med namn som nycklar och anknytningsnr # som vär...
38bfae3b5387684afe8dc8b4787087bdd786d2c0
SuzanneRioue/programmering1python
/Arbetsbok/kap 8/övn 8.3 - beräkna summa och medelvärde av lista - kap. 8, sid. 21.py
1,289
4.03125
4
#!/usr/local/bin/python3.9 # Filnamn: övn 8.3 - beräkna summa och medelvärde av lista - kap. 8, sid. 21.py # Listor och tipplar # Programmeringsövningar till kapitel 8 # Programmet frågar efter hur många tal du vill mata in, låter dig sedan mata # in dessa en i taget. Efter varje inmatning läggs det inmatade talet ...
43b89ba2d0757f49a5d86da45c98930f65d600d4
SuzanneRioue/programmering1python
/Arbetsbok/kap 14/övn 14.6, sid. 38 - datorn gissar ett tal.py
2,362
3.78125
4
#!/usr/local/bin/python3.9 # Filnamn: övn 14.6, sid. 38 - datorn gissar ett tal.py # Sökning # Programmeringsövningar till kapitel 14 # Programmet låter dig tänka på ett tal mellan 1 och 99. # Första gången gissar datorn på talet i mitten utifrån det givna intervallet 1 # till 99. Dvs. talet 50. Svarar användaren ...
c183615f347834216b4f3f12cd97e6e22a07d472
SuzanneRioue/programmering1python
/Arbetsbok/kap 4/övn 4.4 - priskoll på bensin - kap 4, sid. 7.py
831
3.671875
4
#!/usr/local/bin/python3.9 # Filnamn: övn 4.4 - priskoll på bensin - kap 4, sid. 7.py # Skapa program eller skript # Programmeringsövningar till kapitel 4 - Arbetsbok # Programmet frågar efter bensinpris och som sedan med villkor talar om # om det är billigt eller inte. # Skriv ut programmets rubrik print('Priskoll...
281e7f4dd1ef0495d3213f59afd0007d0426134a
SuzanneRioue/programmering1python
/Arbetsbok/kap 6/övn 6.4 - vänder på meningen - kap. 6, sid. 15.py
313
3.5
4
#!/usr/local/bin/python3.9 # Filnamn: övn 6.4 - vänder på meningen - kap. 6, sid. 15.py # Mer om teckensträngar i Python # Programmeringsövningar till kapitel 6 # Programmet ber användaren mata in en meninig och skriver sedan ut den # baklänges mening = input('Skriv en mening: ') print(mening[::-1])
e691e8b4c3ad89fdc107b6b9bb2a37f4ba34091d
AmishiBisht/PythonProject
/Calculator.py
6,120
4.1875
4
from tkinter import * from math import * win = Tk() win.title("Calculator") # this title will be displayed on the top of the app #win.geometry("300x400") # this defines the size of the app of window input_box = StringVar() # It gets the contents of the entry box e = Entry(win,width = 50, borderwidth = 5, textva...
3a96ab91401def3cb21863b4eeb3d0f082d07811
zhenya-paitash/course-python-ormedia
/lesson__6_homework.py
4,806
4.34375
4
from math import pi # число ПИ для 2ого задания import random as R # для генерации рандомных чисел в решении заданий # 1. Определите класс Apple с четырьмя переменными экземпляра, представляющими четыре свойства яблока class Apple: def __init__(self, c, w, s, v): self.color = c self.weight = w...
faa30b2222bde8849d6d452736f025f0bd80ecdb
HelloYuiYui/Fun-with-PyTurtle
/Dots.py
759
3.796875
4
from turtle import * import random #setting up the environment. bgcolor("#ffebc6") color("blue", "yellow") speed(10) def dots(): #hiding turtle and pen to avoid creating unwanted lines between dots. penup() hideturtle() dotnum = 0 limit = 200 #change number to create more or less dots. while ...
aefe923d857f9ab74c65429ebfae3d539b7fb007
Snowerest/leetcodeQuestion-Python
/stack.py
399
3.8125
4
class Stack(object): def __init__(self): self.__v = [] def is_empty(self) -> bool: return self.__v == [] def push(self, value: object) -> None: self.__v.append(value) def pop(self) -> object: if self.is_empty(): return None v...
968c16becdcdaaea847617224ea4fb776865d839
Snowerest/leetcodeQuestion-Python
/ball_sort.py
291
3.609375
4
def ball_sort(nums: list) -> list: ln = len(nums) if ln <= 1: return nums i = 0 while i < ln: j = i while j < ln: if nums[j] <= nums[i]: nums[j], nums[i] = nums[i], nums[j] j += 1 i += 1 return nums
78ed8e3e2072193899cc73f9224cbec04e10e593
kushagrasurana/Minuet-server
/app/responses.py
1,429
3.546875
4
from flask import jsonify from . import app def make_response(code, message): """Creates an HTTP response Creates an HTTP response to be sent to client with status code as 'code' and data - message :param code: the http status code :param message: the main message to be sent to client :return:...
17aa9df4e57e711c87f41b3e101d894ce19c50ba
DrakeVorndran/Tweet-Generator
/Code/reaarrange.py
602
3.84375
4
import sys import random def reaarrange(words): for i in reversed(range(1,len(words))): pos = random.randint(0,i-1) words[i], words[pos] = words[pos], words[i] return(words) def reverseString(string, seperator=""): if(seperator == ""): return_string = list(string) else: return_string = string....
be6b2ac375fb83d117835be397d7aa411afb94a8
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/005闰年判断.py
425
3.890625
4
print('------------酸饺子学Python------------') #判断一个年份是否是闰年 #Coding 酸饺子 temp = input('输入一个年份吧:\n') while not temp.isdigit(): print('这个不是年份吧……') year = int(temp) if year/400 == int(year/400): print('闰年!') else: if (year/4 == int(year/4)) and (year/100 != int(year/100)): print('闰年!') else: p...
5eadae3b9e4e99640a7ec52cf0483eaf9c2fbf4b
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/030搜索文件.py
667
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-06-16 23:11:30 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : http://bbs.fishc.com/space-uid-437297.html # @Version : $Id$ import os content = input('请输入待查找的目录:') file_name = input('请输入待查找的目标文件:') def Search(path, file_name): path_list =...
2feef38d5f8ce0751dbecbb098d0936c5df0cf17
SourDumplings/CodeSolutions
/OJ practices/PAT甲级真题练习/1039. Course List for Student-超时.py
1,188
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-12-06 16:05:13 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : https://github.com/SourDumplings # @Version : $Id$ ''' https://www.patest.cn/contests/pat-a-practise/1039 ''' def main(): temp = input().split(' ') N = int(temp[0]) K =...
e33f3ad1ed5312c6c2e9726f243b005719f02ee4
SourDumplings/CodeSolutions
/Book practices/《简单粗暴 TensorFlow 2.0》练习代码/1.基础/2.自动求导机制.py
929
3.53125
4
import tensorflow as tf # 计算函数 y = x^2 在 x = 3 处的导数 # x = tf.Variable(initial_value=3.) # with tf.GradientTape() as tape: # 在 tf.GradientTape() 的上下文内,所有计算步骤都会被记录以用于求导 # y = tf.square(x) # y_grad = tape.gradient(y, x) # 计算y关于x的导数 # print([y, y_grad]) # 多元函数,对向量的求导 X = tf.constant([[1., 2.], [3., 4.]]) y = tf.const...
d070a6c21e6788543c94e042ddc9a1a6e6822029
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/014check.py
1,957
3.859375
4
#密码安全检查 #Coding 酸饺子 # 密码安全性检查代码 # # 低级密码要求: # 1. 密码由单纯的数字或字母组成 # 2. 密码长度小于等于8位 # # 中级密码要求: # 1. 密码必须由数字、字母或特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)任意两种组合 # 2. 密码长度不能低于8位 # # 高级密码要求: # 1. 密码必须由数字、字母及特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)三种组合 # 2. 密码只能由字母开头 # 3. 密码长度不能低于16位 print('-------------酸饺子学Python-----...
3b17c72973b952d716cdd263b5faf377f3ec143c
SourDumplings/CodeSolutions
/OJ practices/牛客网:PAT真题练兵场-乙级/有理数四则运算.py
2,615
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-11-16 10:28:17 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : https://github.com/SourDumplings # @Version : $Id$ ''' https://www.nowcoder.com/pat/6/problem/4060 ''' import math as m def main(): def gcd(a, b): r = a % b w...
5d0e1b4504139b2166783311414a30d8ed0e3be7
SourDumplings/CodeSolutions
/OJ practices/PAT甲级真题练习/1012. The Best Rank.py
2,536
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-11-28 19:18:52 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : https://github.com/SourDumplings # @Version : $Id$ ''' https://www.patest.cn/contests/pat-a-practise/1012 ''' def main(): temp = input() temp = temp.split(' ') N = int(...
00f241c31584d25d9a8eb0c93aeb1fdff2c5a5bc
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/025通讯录.py
1,712
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-06-13 17:22:08 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : http://bbs.fishc.com/space-uid-437297.html # @Version : $Id$ contact = {} print('''|--- 欢迎进入通讯录程序---| |--- 1 :查询联系人资料 ---| |--- 2 :插入新的联系人 ---| |--- 3 : 删除已有联系人 ---| |--- 4 : 退出通讯录...
89a06671ad98cebf5590a4ece8ad192d2954819b
SourDumplings/CodeSolutions
/OJ practices/PAT甲级真题练习/1035. Password.py
957
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-12-05 20:30:26 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : https://github.com/SourDumplings # @Version : $Id$ ''' https://www.patest.cn/contests/pat-a-practise/1035 ''' def main(): N = int(input()) modified = [] flag = 0 ...
ae952d0a06fff2b4f8ced902cd7355a19e0b17a1
SourDumplings/CodeSolutions
/OJ practices/LeetCode题目集/88. Merge Sorted Array(easy).py
943
3.65625
4
''' @Author: SourDumplings @Date: 2020-02-16 19:37:18 @Link: https://github.com/SourDumplings/ @Email: changzheng300@foxmail.com @Description: https://leetcode-cn.com/problems/merge-sorted-array/ 双指针法,从后往前填 ''' class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: ""...
70a075b1fba763f3a12d1baecbc20c50930c0c3d
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/010向列表中添加成绩.py
287
4.21875
4
#向列表中添加成绩 #Coding 酸饺子 print('-------------酸饺子学Python-------------') member = ['小甲鱼', '黑夜', '迷途', '怡静', '秋舞斜阳'] member.insert(1, 88) member.insert(3, 90) member.insert(5, 85) member.insert(7, 90) member.insert(9, 88) print(member)
ebc51cdc6f85317dc3e53bd614184c5b9a15519b
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/064tk2.py
692
3.53125
4
# encoding: utf-8 """ @author: 酸饺子 @contact: changzheng300@foxmail.com @license: Apache Licence @file: tk2.py @time: 2017/7/25 10:00 tkinter演示实例2,打招呼 """ import tkinter as tk def main(): class APP: def __init__(self, master): frame = tk.Frame(master) frame.pack(side=tk.LEFT, padx...
de09ee49797be6b1931cec7a4b4a17c50aa78b0f
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/009输入密码.py
483
4.09375
4
#输入密码 #Coding 酸饺子 print('-------------酸饺子学Python-------------') count = 3 code = 'SourDumplings' while count != 0: guess = input('您好,请输入密码:') if guess == code: print('密码正确!') break elif '*' in guess: print('密码中不能含有*!') print('您还有', count, '次机会') else: count -= ...
6df6963f07c1073e3ae63b8ab99850fe90355a76
SourDumplings/CodeSolutions
/OJ practices/PAT甲级真题练习/1023. Have Fun with Numbers.py
692
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-12-01 20:52:18 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : https://github.com/SourDumplings # @Version : $Id$ ''' https://www.patest.cn/contests/pat-a-practise/1023 ''' def main(): n = input() num = int(n) num *= 2 doubled_...
9348714135c920044a7664b82b4b8648b88a424f
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/042字符串ASCII码四则运算.py
1,054
3.921875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-06-30 18:23:48 # @Author : 酸饺子 (changzheng300@foxmail.com) # @Link : http://bbs.fishc.com/space-uid-437297.html # @Version : $Id$ class Nstr(str): def __add__(self, other): a = 0 b = 0 for each in self: a += o...
6baa21538651c4b215d774f883d17b0824f23a6a
guilfojm/01-IntroductionToPython-201930
/src/m6_your_turtles.py
2,180
3.703125
4
""" Your chance to explore Loops and Turtles! Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher, Aaron Wilkin, their colleagues, and Justin Guilfoyle. """ ######################################################################## # DONE: 1. # On Line 5 above, replace PUT_YOUR_NAME_HERE with ...
a4f4a928befdb63ceaf7f834d6b6641a7922674a
Debonairesnake6/ClashBot
/src/player_ranks.py
2,521
3.75
4
""" This file will gather all of the information needed to create a table showing each player's rank """ from text_to_image import CreateImage class PlayerRanks: """ Handle creating the player ranks table """ def __init__(self, api_results: object): """ Handle creating the player rank...
9d7c247e69d6d3a3f39d5124275746beb844ef77
kaarthikalagappan/sonos-jukebox
/rfidOperations.py
3,561
4.03125
4
#!/usr/bin/env python import RPi.GPIO as GPIO from mfrc522 import SimpleMFRC522 def writeToTag(data): """ Function to write to the tag """ reader = SimpleMFRC522() #Only 48 characters can be written using the mfrc522 library if len(data) > 48: print("""Can accept only string less than 48 ch...
332db90717d18029d34aa1bbca1ce2d43fdd2a1d
InfiniteWing/Solves
/zerojudge.tw/a780.py
361
3.53125
4
def main(): while True: try: s = input() except EOFError: break o, e, a = float(s.split()[0]),float(s.split()[1]),float(s.split()[2]) if(o == 0 and e == 0 and a == 0): break m = o / e f = a / m print('{0:.2f}'.format(round(m...
d3e7eed51bfb47b69c552328c2c584658200f54e
InfiniteWing/Solves
/zerojudge.tw/c082.py
1,507
3.515625
4
alert=[] class Robot: def __init__(self,x, y, d,map,alert): self.x = x self.y = y self.alive = 1 self.alert=alert self.lastLocation = map if(d=='W'): self.d = 1 if(d=='N'): self.d = 2 if(d=='E'): self.d = 3 if(d=='S'): self.d = 4 self.map=map def Action(self,c): if(c=='L'): se...
ec8bf34b460455bd32a2607fa7bab4ee23f15e4a
InfiniteWing/Solves
/zerojudge.tw/c419.py
274
3.546875
4
def main(): while True: try: n = int(input()) except EOFError: break for i in range(n-1,-1,-1): ans = '' for j in range(n): ans += '*' if(j>=i) else '_' print(ans) main()
e7ef5b40ececc2999a68c6873dde147dd5e725e3
gahogg/Cracking-the-Coding-Interview-6th-Edition-Answers
/linked_lists/Return kth to last 2.py
406
3.90625
4
# Implement an algorithm to find the kth to last element # of a singly linked list from singly_linked_list_node import SinglyLinkedListNode # O(n) runtime, O(1) space def kth_to_last(head, k): cur = head while True: k -= 1 if k == 0: return cur cur = cur.next head = Singl...
d5a296818f6bd02b8c03c76b2aa042abbcb4ee17
AlexanderOHara/programming
/week03/absolute.py
336
4.15625
4
# Give the absolute value of a number # Author Alexander O'Hara # In the question, number is ambiguous but the output implies we should be # dealing with floats so I am casting the input to a flat number = float (input ("Enter a number: ")) absoluteValue = abs (number) print ('The absolute value of {} is {}'. format...
027ae9177f91395fd0b224ace53b431bad3af815
BaselECE/Assignment1
/Question_1/B.py
435
4.09375
4
number1 =eval (input ("enter the first number : ")) number2 =eval (input ("enter the second number : ")) process =input ("enter the process(*,/,+,-):") # ask user to type process # test what process to do if (process=='*') : print (number1*number2) elif (process=='/') : print...
11a6a3f01707ad71dd18ea2e9a7bd330791ca7bb
fenghui2018/python
/lesson_9/op_oo.py
929
3.984375
4
#!/usr/bin/python # -*- coding: utf-8 -*- def getup(name): print(name+' is getting up') def eat(name): print(name+' eats something') def go_to_school(name): print(name+' goes to school') def op(): person1 = 'xiaoming' getup(person1) eat(person1) go_to_school(person1) person2 = 'xiaoh...
3c4bf7743c3aa9b70eaf040e8ed461bc6c8d9c6f
kyleedwardsny/monty_hall
/monty_hall.py
627
3.6875
4
import random def monty_hall(size, omniscient, switch): prize = random.randint(1, size) choice = random.randint(1, size) if not omniscient or choice == prize: unopened = random.randint(1, size) while unopened == choice: unopened = random.randint(1, size) else: unop...
607120b19311605f418307cffc49981af62672c5
miker7790/Arcade
/manager/games/hangman.py
3,456
3.734375
4
import os import csv import random class HANGMAN: def __init__(self, word=None, attempts=None): self.word = word.lower() if word else self._selectRandomWord() self.remainingAttempts = attempts if attempts else self._getInitialRemainingAttempts() self.remainingLetters = list(self.word...
d50309f43cb772cdc2f212c0b6437a1c444a24a3
tanmay-raichur/assignment-one
/morrisons/csv_converter.py
4,728
3.84375
4
""" This is a CSV file converter module. It reads CSV file and creates a json file with parent-child structure. """ import sys import pandas as pd import json import logging as log log.basicConfig(level=log.INFO) def csv_to_json(ip_path: str, op_path: str) -> None: """ Converts given csv file into j...
a43ea1df7cbf7ab62ae50e8385d8d70c127d16b4
PhillipDHK/Recommender
/RecommenderMaker.py
1,488
3.546875
4
''' @author: Phillip Kang ''' import RecommenderEngine def makerecs(name, items, ratings, numUsers, top): ''' This function calculates the top recommendations and returns a two-tuple consisting of two lists. The first list is the top items rated by the rater called name (string). The second l...
87b052581e7ad1fe51f8e06fe1658b9d3d69ee26
vdeangelis/Flask
/routes.py
936
3.59375
4
from flask import Flask, url_for, request, render_template from app import app # server/ @app.route('/') def hello(): createLink = "<a href='" + url_for('create') + "'>Create a question</a>" return """<html> <head> <title>Ciao Mondo!!'</title> </head> <body> """ + createLink + """ <h1>Hell...
6859cc2ba2ed3ba969b42861bc701dd1d0ca59fe
Neraverin/codewars-python
/Simple Encryption #1 - Alternating Split/main.py
2,128
3.609375
4
import unittest class KataTest(unittest.TestCase): @staticmethod def decrypt(encrypted_text, n): for i in range(n): first = encrypted_text[:int(len(encrypted_text)/2)] second = encrypted_text[int(len(encrypted_text)/2):] if len(first) < len(second): ...
ddb2e24756117bf6869a1b10b93237566c9d1eae
LavaTime/Envelopes
/forthStrategy.py
1,767
3.78125
4
from envelope import Envelope class N_max_strategy: """ can run the forth strategy on a set of envelops Attributes: envelops (list): list of envelops to run the strategy one N (int): holds the N for the strategy """ def __init__(self, envelops): self.envelops = envelops ...
bfd3fe14514baab0e66c20b18a6ff2e098781415
hamzahibrahim/Projects-with-python
/Tkinter/YouTube video downloader.py
1,236
3.5625
4
from pytube import YouTube print('===================') # ========================= rerun = "y" while rerun == "y": try: url = input('Enter the YouTube link for the video u want: \n') the_video = YouTube(url) # ========================= print('===================') print('you...
faf268ea926783569bf7e2714589f264ed4f3554
Teddy-Sannan/ICS3U-Unit2-02-Python
/area_and_perimeter_of_circle.py
606
4.1875
4
#!/usr/bin/env python3 # Created by: Teddy Sannan # Created on: September 16 # This program calculates the area and perimeter of a rectangle def main(): # main function print("We will be calculating the area and perimeter of a rectangle") print("") # input length = int(input("Enter the length (mm...
c3c084946fd1e0634b9670fc1ef058fbc4c98045
theguythatdoes/coding-assignments
/CreateAcronym.py
381
3.609375
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 22 15:34:58 2020 @author: reube """ def acronym(phrase): y=phrase phrase=phrase.split(' ') mystring=len(phrase) s='' for k in range(0,mystring): n=phrase[k] s+=n[0] return s if __name__=="__main...
3c337c5a29d43444e3b4c51af2dc22ea4284c5e7
theguythatdoes/coding-assignments
/EatingGood.py
499
3.953125
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 27 15:43:53 2020 @author: reube """ def howMany(meals,restaurant): wyt=[] rest=[] numrest=0 for bob in range(len(meals)): if meals[bob] not in rest: rest+=[meals[bob] ] for k in range (len(rest)): wyt+=rest[k]...
a3908afeefdba6d570fdbea0dd5a5b20112a1593
hugessen/Advent-of-Code-2016
/Code/d3q1.py
628
3.53125
4
def is_valid(vals): max_side = max(vals) return sum(vals) > (2 * max_side) pinput = open('Inputs/d3.txt').read().split('\n') ...
17d9bf545ec17e744a53e7adc120100d293f3f40
hugessen/Advent-of-Code-2016
/Code/d1q1.py
951
3.609375
4
def turn(left_or_right): global c_dir if c_dir[X] == 1: c_dir = [0, -1*left_or_right] elif c_dir[X] == -1: c_dir = [0, 1*left_or_right] elif c_dir[Y] == 1: c_dir = [1*left_or_right, 0] elif c_dir[Y] == -1: c_dir = [-1*left_or_right, 0] pinput = open('Inputs/d1.txt').read().split(", ") X = 0 Y = 1 LEFT =...
c4a724e06eda95e28c9ad081698f1c08f0272467
tsixit/python
/PycharmProjects/formation/poo.py
10,517
3.75
4
unite1 = { 'nom': 'méchant', 'x': 12, 'y': 7, 'vie': 42, 'force': 9 } unite2 = { 'nom': 'gentil', 'x': 11, 'y': 7, 'vie': 8, 'force': 3 } def attaque(attaquant, cible): print("{} attaque {} !".format(attaquant['nom'], cible['nom'])) cible['vie'] -= attaquant['force'] ...
38c35c919afd61c749c0c521943d9fd821a44818
Tcake/py_leetcode
/leetcode/Guess Number Higher or Lower II.py
686
3.5
4
class Solution: def getMoneyAmount(self, n): """ :type n: int :rtype: int """ left = 1 right = n result = 0 while right - left >= 6: left = (right + left) // 2 result += left if left is not 1: left += 1 ...
599b529c6e4cfc0e0ce04753c26c2bd543ef3dcb
logotip123/py_merge
/merge.py
799
4.03125
4
"""Two list sort module""" from typing import List def merge(array1: List[int], array2: List[int]) -> List[int]: """ Two list sort function :param array1: first list for sort :param array2: second list for sort :return: array1 + array2 sorted list """ array1index = 0 array2index = 0 ...
95ecfbc9b444f09586e7fa1dbc8a752e846ef8f7
jaaaaaaaaack/xpilot-bots
/old-files/evstrat/neuralNet.py
5,221
3.734375
4
# Jack Beal and Lydia Morneault # COM-407 CI # 2018-05-07 Final project # Based on neuralnet.py by Jessy Quint and Rishma Mendhekar from random import* import math def sigmoid(x): return (1/(1+math.exp(-1*x))) def perceptron(thing, weights): summation = 0 # initialize sum counter = 0 # variable to assi...
9e0cd81ea1e65c22f141d4d08e4177860876a5c6
kutakieu/AI-class
/Assignment-1-Search-master-63318a771170bfa64d905052bc0e733cfd3b576e/code/heuristics.py
4,813
3.828125
4
# heuristics.py # ---------------- # COMP3620/6320 Artificial Intelligence # The Australian National University # For full attributions, see attributions.txt on Wattle at the end of the course """ This class contains heuristics which are used for the search procedures that you write in search_strategies.py. T...
ab79b8c878f465cac0131bf55f802a6b64cfdfb5
MatejBabis/AdventOfCode2k18
/day5/part1.py
799
3.765625
4
def read_input(filename): f = open(filename) # only one line, and remove '\n' output = f.readline().strip() f.close() return output # helper function that checks if two letters are equal are diffent case def conflict(a, b): return a.lower() == b.lower() and ((a.isupper() and b.islower()) or (a...
d5273f7320cae0c86a36327e9defa268b7bca045
MatejBabis/AdventOfCode2k18
/day4/part1.py
2,591
3.5
4
import re import numpy as np # strings to match ASLEEP = 'falls asleep' AWAKE = 'wakes up' GUARD = 'Guard' # process the input file def process_file(filename): f = open(filename) records_list = [] for line in f.readlines(): raw = line[6:-1] # first six letter carry no information month ...
bc7b865e579f10ee6632e9b10099d106727bdd14
petrakov1/foodbot
/dataAnal.py
3,617
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import _json import math def valueByTag(place,arrPerson): value = 0 for tag in arrPerson: if (tag in place): value += place[tag]*arrPerson[tag] return (value) def sortByValue(arr): for i in range(len(arr)): for j in range(l...
158450f4cb59c6890e6de4931de18e66a4f5ef48
FraserTooth/python_algorithms
/01_balanced_symbols_stack/stack.py
865
4.21875
4
class Stack: def __init__(self): self.items = [] def push(self, item): """Adds an item to end Returns Nothing Time Complexity = O(1) """ self.items.append(item) def pop(self): """Removes Last Item Returns Item Time Complexity = O(1)...
9ea5c9748f2a37bf51ed41905b601704b629c2d8
Alver23/CursoPython
/clase1/EjerciciosHechosClase/eres.py
191
4.09375
4
nombre = input("Cual es tu nombre") if nombre == "Alver": print ("Que man tan chevere") elif nombre == "Jorge": print ("Que Onda Jorge") else: print ("Eres Otro que no es Alver o Jorge")
462662bb1d616d434d6df18dabe53e424ac5b297
habc0d3r/100-Days-Of-Code
/Day-5/highest-score/main.py
323
3.75
4
student_scores = input("Input a list of student scores ").split() for n in range(0, len(student_scores)): student_scores[n] = int(student_scores[n]) print(student_scores) heighest = 0 for score in student_scores: if score > heighest: heighest = score print(f"The heighest score in the class is: {heighest}") ...
98b239868170d72f40abdf73dc38172bfaf24f1d
habc0d3r/100-Days-Of-Code
/Day-18/challenge4.py
483
3.5
4
import turtle from turtle import Turtle, Screen import random as rd tim = Turtle() # tim.hideturtle() turtle.colormode(255) def random_color(): r = rd.randint(0, 255) g = rd.randint(0, 255) b = rd.randint(0, 255) final_color = (r, g, b) return final_color directions = [0, 90, 180, 270] tim.spee...
aac8aac901bd84af8b37b384aae3f0607e023c34
habc0d3r/100-Days-Of-Code
/Day-18/challenge3.py
571
3.890625
4
from turtle import Turtle, Screen import random as rd colors = ['chartreuse', 'deep sky blue', 'sandy brown', 'medium orchid', 'magenta', 'royal blue', 'burlywood'] tim = Turtle() tim.shape("arrow") def change_color(): tim.color(rd.random(), rd.random(), rd.random()) def draw_shape(num_of_sides): angle = ...
66c93a7b70637fd2ebbabe192b10d52cca68ee1c
karthikyadav09/deep_learning_for_vision
/ASN3/Solution/ASN3/lstmMNISTStarterCode.py
2,867
3.546875
4
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data from tensorflow.contrib import rnn mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) #call mnist function learningRate = 0.0025 trainingIters = 100000 batchSize = 256 di...
447204f56fb361002c5d1ad231d25d8aaef4ff80
lerandc/project-euler
/python/p29.py
2,179
3.765625
4
""" Luis RD April 12, 2020 ------------------------------------------------ Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, 35=243 42=16, 43=64, 44=256, 45=1024 52=25, 53=125, 54=625, 55=3125 If they are then placed in numerical order, with any repeats...
1f2bf332f201dbede1ce368cb977533ff440bc0d
forest-data/luffy_py_algorithm
/算法入门/merge_sort.py
1,934
3.65625
4
#归并排序 时间复杂度 O(nlogn) # 假设左右已排序 def merge(li, low, mid, high): i = low j = mid + 1 ltmp = [] while i<=mid and j<=high: if li[i] < li[j]: ltmp.append(li[i]) i += 1 else: ltmp.append(li[j]) j += 1 # while 执行完,肯定有一部分没数了 while i <=...
dc55a27810a351d729e80b1ad96d09c5de314db3
forest-data/luffy_py_algorithm
/数据结构/stack.py
1,214
4.0625
4
# 栈: 是一个数据集合,只能在一段进行插入或删除操作 class Stack: def __init__(self): self.stack = [] def push(self, element): self.stack.append(element) # 删除栈顶元素 def pop(self): return self.stack.pop() # 获取栈顶元素 def get_top(self): if len(self.stack) > 0: return self.stack...