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
6de0a068235ee5423cc658421f624739ec854e25
lytenica/Zadachi
/11count_substrings/solution.py
382
3.859375
4
def count_substrings(haystack, needle): start = haystack.find(needle) count = -1 if start != -1: count = count + 1 while start != -1: count += 1 start += len(needle) start =haystack.find(needle, start) return count def main(): print(count_subst...
b5f7d395170917f85107fa631904ce1e6817ef04
lytenica/Zadachi
/18Increasing_ sequence/solution.py
151
3.703125
4
def is_increasing(seq): for x in range(1,len(seq)): if seq[x - 1] < seq[x]: return True else: return False
0be25618ef13dd00e2e090f2cde0fb8d7a614d2e
lytenica/Zadachi
/13count_consonants/solution.py
440
3.859375
4
def count_consonants(str): vlowels = len(str) for item in str.lower(): if item == 'a': vlowels -= 1 if item == 'e': vlowels -= 1 if item == 'i': vlowels -= 1 if item == 'o': vlowels -= 1 if item == 'u': vlowels -= 1 if item == 'y': vlowels -= 1 if item == ' ': vlowels -=1 if item ...
3695661c954293f8c27fd7f1ea75e22e4003c377
ulicqeldroma/MLPython
/basic_slicing.py
696
4.15625
4
import numpy as np x = np.array([5, 6, 7, 8, 9]) print x[1:7:2] """Negative k makes stepping go toward smaller indices. Negative i and j are interpreted as n + i and n + j where n is the number of elements in the corresponding dimension.""" print x[-2:5] print x[-1:1:-1] """If n is the number of items in the dimens...
fb0acfb0a055d553462a2399c26483d9db03841f
ulicqeldroma/MLPython
/matplotlib_simple.py
359
3.734375
4
import numpy as np import matplotlib.pyplot as plt # simple bar and scatter plot x = np.arange(5) # assume there are 5 students y = (20, 35, 30, 35, 27) # their test scores plt.bar(x,y) # Bar plot # need to close the figure using show() or close(), if not closed any follow up plot commands will use same figure. plt....
6d5be3e7cd396d8fb831540a92201cf7c50a1c12
taurusyuan/python
/Matplotlib/02_figure.py
234
3.6875
4
import matplotlib.pyplot as plt import numpy as np x = np.linspace(-3, 3, 50) y = 2*x + 1 z = x**2 plt.figure() plt.plot(x, y, color='red', linewidth=1.0, linestyle='--') plt.figure(num=3, figsize=(8, 5)) plt.plot(x, z) plt.show()
87a25a3b48d0d74b4ec7baf22aa163084155732d
taurusyuan/python
/Numpy/08_assignment.py
436
3.609375
4
import numpy as np a = np.arange(4) b = a c = a d = b a[0] = 11 # 改变a的第一个值,b,c,d同时都会发生变化,四个变量是关联的 print(a) print(b is a, c is a, d is a) # 如果不想改变b,c,d, 即不想要关联各个变量的话,则使用copy() b = a.copy() # deep copy print(b) # array([11, 22, 33, 3]) a[3] = 44 print(a) # array([11, 22, 33, 44]) print(b) # a...
a7b2d9b9cf7dd5e12eb838b3f21906987a334307
farpeek/easychair2acm
/easychair2acm.py
1,585
3.609375
4
import pandas def splitAuthors(authorString): subauthors = authorString.replace(' and ',', ') subauthors = subauthors.split(', ') return [x for x in subauthors if "and" not in x] def findAuthor(name, authors): for row in authors.iterrows(): fname = row[1][1] sname = row[1][2] i...
f6a1bf77e71453c6b2ed2aa81de6b780161a1b9d
kir-one/dominoMaster
/Tablero.py
18,038
3.640625
4
import random from Ficha import Ficha from Jugador import Jugador class Tablero: ArrayFichasCabeza=[] ArrayFichasCola=[] cola=0 cabeza=0 def inicia(self,ficha): cola=ficha.valorA cabeza=ficha.valorB ficha.spin=0 self.ArrayFichasCabeza.append(ficha) ...
1d5ccbb95e0349fc57250eb232d8bbcc64774d0b
quantviews/option-pricing-models
/option_pricing/base.py
924
3.84375
4
from enum import Enum from abc import ABC, abstractclassmethod class OPTION_TYPE(Enum): CALL_OPTION = 'Call Option' PUT_OPTION = 'Put Option' class OptionPricingModel(ABC): """Abstract class defining interface for option pricing models.""" def calculate_option_price(self, option_type): """Cal...
50e52b1558a4a2b6d6ac47d05cfa6ee1836b3c62
DenisKalinin/python_cns
/homework/lesson 2/1-3.py
218
3.875
4
#Пользователь вводит температуру в градусах Цельсия. Вывести температуру в градусах фаренгейта C = float(input()) print((C * 1.8) + 32)
63e92b7405175aceb8ba6dc5af79eb4f3599b93a
GabrielTimponiFranca/Estudos
/Python/Youtube - Gustavo Guanabara/Excercicios/ex009.py
509
4
4
n1 = int(input("Digite um numero: ")) s1 = n1 * 1 s2 = n1 * 2 s3 = n1 * 3 s4 = n1 * 4 s5 = n1 * 5 s6 = n1 * 6 s7 = n1 * 7 s8 = n1 * 8 s9 = n1 * 9 print("A tabuda de {}, é:".format(n1)) print("{} x 1 = {}".format(n1, s1)) print("{} x 2 = {}".format(n1, s2)) print("{} x 3 = {}".format(n1, s3)) print("{} x 4 = {}".format(...
f93e9e7585c16ec936eaf16713c14fa2ecfe6159
shevisj/unbeatable_tictactoe
/Game.py
42,872
4.03125
4
#CPCS 230-06 Final Project #Name: William Shevis Johnson #Date: 11/20/14 #Description: Tic Tac Toe game, using a combination of command line and turtle graphics. Has player v player and player v computer with three different computer difficulty levels. from turtle import * from random import randint import copy #draw...
e21b6e52249bd0f3a9cc67b8d4d6fad423e53ad3
saurabhkashyap/PyRSMQ
/examples/producer.py
3,739
3.5
4
''' Example Producer for a queue In this example we create RedisSMQ controller and using it to send messages to that at regular intervals ''' import argparse import logging import random import sys from threading import Thread import time from rsmq import RedisSMQ from rsmq.consumer import RedisSMQConsumer LOG = ...
c56608f470afa459d21c23474261ffb4f40dc7a7
RoyOtten/werken-met-condities
/sollicitatie.py
1,316
3.640625
4
print ("sollicitatie roy otten") print ("we gaan je een paar vragen stellen om erachter te komen of jij geschikt bent voor deze baan") vraag1 = input ("heb jij praktijkervaring met dieren-dresuur?") vraag2 = input ("ben jij in bezit van een MBO-4 ondernemen?") vraag3 = input ("ben jij in bezit van een geldig vrachtwag...
787f123451bd07722ca54042b82e9e3dbab5c26b
e-rabello/algorithms
/Manber/Chapter6/insertionSort.py
452
4.03125
4
def insertRec(A, n): # InsertionSort designed by weak induction # Base case, one element the array is already sorted if n == 1: return else: # By induction we know how to sort the array A[n - 1] insertRec(A, n - 1) key = A[n - 1] i = n - 1 - 1 ...
d339f200ed92082a729146f343481b885fcf7931
vchaoxi/dangyuanjifen
/dangyuanAPI/docs/images/27-357 (1).py
2,812
3.921875
4
class Stones(): '''石子类''' def __init__(self): self.stones = {'A': 3, 'B': 5, 'C': 7} def remove(self, which, num): if which not in ['A', 'B', 'C']: print('只能在 A B C 中做选择!') return False if not self.can_remove(which, num): print(f'不能从{which}中拿{num...
1eff17368f5b7c56786fa6961ffc565065d52209
eBucher/minesweeper_class_project
/minesweeper_phase_3.py
15,295
4.0625
4
''' CS115 Project 3 - Minesweeper Author - Erich Bucher ''' from graphics import * import random TILE_IMAGE = 'tile.gif' FLAG_IMAGE = 'flag.gif' MINE_IMAGE = 'mine.gif' LOSE_IMAGE = 'lose.gif' SMILEY_IMAGE = 'smiley.gif' BLANK_CELL = 0 EXPOSED_CELL = 10 MINE_CELL = 13 MAX_ADJACENT_MINES = 8 WIDTH_OF_IMAGES = 32 HEIG...
817eb8a8844d89e0bc5c93ec9dfa277091e835cf
artick95/machine-design
/Profile Shift.py
6,157
3.515625
4
import math print('insert the module') m = float(input()) print( 'insert alfa_w[deg]\n(use graphical methods to find it)\n inv(alfaw)=inv(alfa)+ 2(x1+x2)/(z1+z2)*tan(alfa) \n inv(alfa)=tan(alfa)-alfa (p.s. alfa in radiants)') alfa_w = float(input()) print('insert alfa[deg]') alfa = float(input()) pr...
0e5e182ae737ef16942679c4ca56685a4b4dba02
madziejm/dl-in-iot-course-1
/dl_in_iot_course/misc/metrics.py
1,734
3.59375
4
import numpy as np def accuracy(confusion_matrix: np.ndarray): """ Computes accuracy of the classifier based on confusion matrix. Parameters ---------- confusion_matrix: ArrayLike The Numpy nxn array or nxn list representing confusion matrix Returns ------- float : accuracy v...
5a30f84ddc0999fc6ad5f6c964eb18447ffba7a3
tenedor/SourceFlowPlotter
/tracers/test.py
401
4.15625
4
def double(x): x *= 2 return x def triple(x): x += double(x) return x def recursive_1(x, i): if i > 0: x += i x = recursive_2(x, i - 1) return x def recursive_2(x, i): if i > 0: x *= i x = recursive_1(x, i - 1) return x def recursive_start(n): m = recursive_1(1, n) print m if __...
6d0b13e0007a0c3189921d48c883a9a8389518a1
wernersbacher/pythonSnippets
/jsonDB.py
2,109
3.640625
4
""" This project was made for saving of a few data locally with json with key: value It's in no way meant to be fast, reliable, threadsafe or well tested - it's only easy to use for some special cases. Behaves a little bit like webbrowser's localStorage system """ import json class LocalData: """ saves so...
a2a552ae419ef6f0b71a2fec3bcb201d191ac0bf
eduardagoulart/TSP
/pcv.py
3,721
3.546875
4
from math import sqrt from PIL import Image, ImageDraw, ImageFont from pyevolve import (G1DList, GSimpleGA, GAllele, Mutators, Crossovers, Consts) import random PIL_SUPPORT = True #Calcula a distancia eucliadiana dos pontos def cartesian_matrix(coords): """ A distance matrix """ matrix = ...
4f850f2b41d99b4beac088670f1576592bf25f4a
deeppatel1842/AI
/marble solitaire/python/env.py
6,855
3.59375
4
import heapq class HeapQueue(): def __init__(self): self.elems = [] self.index = 0 def put(self, elem, priority): heapq.heappush(self.elems, (-priority, self.index, elem)) self.index += 1 def get(self): return heapq.heappop(self.elems)[2] def __c...
5d9274f0ad338e164b982f714ebb3e2bb2fbac47
jdelaney1/TicTacToe
/test_ticTacToe.py
1,594
3.828125
4
import unittest import copy from ticTacToeGame import * class ticTacToeTest(unittest.TestCase): def test_game_eval_blank(self): ''' the game should not be over with a blank board ''' self.assertEqual(game_eval(board),False) def test_game_eval_one(self): '''the game should not be o...
6c59c50b3e356abe679d60bf4c302d1dee052e63
JIANG09/LearnPythonTheHardWay
/ex11.py
579
4.0625
4
print("How old are you?", end=' ') age = input() print("How tall are you?", end=' ') height = input() print("How much do you weigh?", end=' ') weight = input() print(f"So, you're {age} old, {height} tall and {weight} heavy.") # practice print("What are you doing right now?", end=' ') doing = input() print("Why are y...
da2a27e14b2e98b13c25310fea2ea62af5f9e07c
JIANG09/LearnPythonTheHardWay
/ex33practice.py
354
4.125
4
def while_function(x, j): i = 0 numbers = [] while i < j: print(f"At the top i is {i}") numbers.append(i) i = i + x print("Numbers now: ", numbers) print(f"At the bottom i is {i}") return numbers numbers_1 = while_function(7, 10) print("The numbers: ") for ...
30df140d2f24af77d445448fb9809c3d950ccdf6
JIANG09/LearnPythonTheHardWay
/ex18.py
508
3.75
4
# this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print(f"agr1: {arg1}, arg2: {arg2}") # ok, *args is pointless, we can just do this def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2: {arg2}") # this just takes one argument def print_one(arg1): print(f"arg1:...
5ba499f494a9e6ba1f33b3806e8c7a3636b840c2
drippydik/finnSchool
/lesson1.py
1,128
3.5625
4
#!/bin/python # you can ignore the top line it is just to tell the file where to find the python App on your # computer. # it is called the She-bang and it is a special type of comment # a comment is anything after a "#" symbol like this line and all the ones above. # Comments are there to help other programmers un...
e396c4b142875c63e810fac7f0b28a53b376995a
prince3453/python
/p29.py
125
4
4
import re str = input('Enter the string to be validated:') if re.match('^a',str): print('YES') else: print('NO')
941fbfb3deb5061a0f9a6678a939093d87a4f00f
prince3453/python
/p13.py
278
4.09375
4
#prime number or not. def prime(a): count=0 for i in range(1,a): if a%i==0: count=count+1 if count==1: print(a,' is a prime number') else: print(a,' is not a prime number') a=int(input('Enter a number : ')) prime(a)
6ccae93dbd5025206c6b7f20c5e97cbaf188fb72
prince3453/python
/p22.py
237
4.09375
4
final_list = [] line = input("Enter the list of key value pairs (press enter twice for end):\n") while (line != ""): final_list.append(tuple(line.split())) line = input() print(sorted(tuple(final_list),key = lambda x:x[0]))
85bbd544a86334d58fb08652364ce01834d295c4
Aanand98/Python---CodeKata
/oddeven.py
75
4.0625
4
n = int(input()) if n%2 == 0: print("Even") elif n%2!= 0: print("Odd")
1444388ff1a12d6c285c8042109a20058a5660db
Aanand98/Python---CodeKata
/swap.py
139
3.625
4
list = [int(x) for x in input().split()] temp = list [0] list[0] = list[-1] list[-1] = temp for ele in list: print(ele,end = ' ')
ba511144b9371d52e5cf38f0cb5f3b88c1da2c08
Aanand98/Python---CodeKata
/AP.py
306
3.546875
4
list_values = input() list_values = list_values.split() list = [] for num in list_values: num = int(num) list.append(num) N_time = list[0] Start = list[1] Difference = list[-1] num = Start n = [] while N_time > 0: N_time = N_time - 1 n.append(num) num = num + Difference print(sum(n))
277aaf5ba27b809cafc6aa12695f264055ab3278
Aanand98/Python---CodeKata
/count.py
87
3.53125
4
x,count = int(input()),0 while(x!=0): count = count + 1 x = int(x/10) print(count)
9c5972ac2e420c0debc016981c0f23bd40c1c3cd
Aanand98/Python---CodeKata
/sort.py
231
3.890625
4
import numpy as np n = int(input()) list_values = input() list_values = list_values.split() list = [] for num in list_values: num = int(num) list.append(num) list = np.sort(list) for num in list: print("",num,end = '')
8264d53c631a0e4ee0d5fa0440468e2500a0803c
ucgmsim/slurm_gm_workflow
/workflow/calculation/hf2bb.py
3,394
3.578125
4
"""Converts the contents of an HF binary file to a BB binary file at a given location.""" import argparse import numpy as np from qcore.timeseries import BBSeis, HFSeis def hf2bb(hf_bin, bb_bin, dt=None): """Converts a given HF binary file to a BB binary file at the given location. Writes the header using any...
fd811f5b05ea446b4a4bcc6bf6bd733a88dcd833
edgeweb/CosySE
/main.py
942
3.828125
4
#Realiza una función separar(lista) que tome una lista de números enteros y devuelva dos listas ordenadas. # La primera con los números pares y la segunda con los números impares. import random def separaLista(lista_new): lista_pares =[] lista_impares=[] for pares in lista_new: #recorre la lista c...
682ba35cf537e583b0b8fc12016a723652d3a174
trautmannmatt/Simulation
/Sprint-3-Monte_Carlo_Simulation/Deliverables/poisson.py
2,019
3.921875
4
# Les Poisson Problem # CMS 380 # Matthew Trautmann Fall 2020 # Standard matplotlib import import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt import math from random import randint def simulate(): """ Simulate one trial for Les Poison inputs: none outputs: Numb...
faeecb5a82949899a8faecd93841275bbc92b17e
trautmannmatt/Simulation
/Sprint-3-Monte_Carlo_Simulation/Deliverables/ticket.py
1,310
4.0625
4
# The Ticket Problem Solution # CMS 380 # Matthew Trautmann Fall 2020 from random import randint, choice def simulate(): """ Simulate one train trip inputs: none outputs: Returns true If passanger 99 got to sit in seat 99 """ # Make a list of passangers passangers = list...
12d29c3d7eae962cbd5eddc08c4b6b23537586fa
araijn/pythonSample
/unittest/mocktest.py
2,433
3.515625
4
# -*- coding: utf-8 -*- import unittest from unittest.mock import patch class Person: def __init__(self, family_name, name, age): self.family_name = family_name self.name = name self.age = age def full_name(self): return self.family_name + " " + self.name def is_adult(self): ...
7e0ba25b4fa38ba1c40281ba0d80361b80308f0b
Anukesh07/CN-LAB
/Lab9/LeakyB.py
683
3.796875
4
size=int(input("Enter the size of the bucket : ")) out=int(input("Enter the output rate : ")) n=int(input("Enter the number of inputs :" )) store=0 for i in range(n): inc=int(input("Enter the incoming packet size : ")) print("Incoming packet size is : {}".format(inc)) if(inc<=(size-store)): ...
ba800d61d6f33dd639ccf0cdb187c196aea63515
mayank26saxena/advent-of-code-2016
/3/first.py
531
3.6875
4
with open('input') as f: content = f.readlines() possible = 0 not_possible = 0 for line in content : l = line.split() n1 = l[0] n2 = l[1] n3 = l[2] num1 = int(n1) num2 = int(n2) num3 = int(n3) print 'num 1 = ' + str(num1) print 'num 2 = ' + str(num2) print 'num 3 = ' + str(num3) if (num1 + num2 > ...
79429f3b403cf35640dd4d1be1c05934dd03b4cc
Doomlash/Flashcard-app
/logic/Card.py
405
3.890625
4
from abc import ABC, abstractmethod class Card(ABC): def __init__(self): super().__init__() self.deck = None self.name = None self.question = None self.answer = None self.id = self.generate_id() @abstractmethod def generate_id(self): pass class Text...
3d9c1775029b6c32d2dd3e9e46f3f669853c6006
sunshine-mtt/Selenium
/which_day_v1.0.py
971
4.03125
4
""" 作者:sunshine 功能:输入日期,显示其是一年中第几天 版本:1.0 """ from datetime import datetime def main(): """ 主函数 """ input_value_str = input('请输入您要查询的日期(yyyy/mm/dd): ') #把字符串转换为datetime类型 input_value = datetime.strptime(input_value_str,'%Y/%m/%d') #获取年、月、日 year = input_value.year mo...
2e7006010fc2f97639312023fee7eb08147fb829
sunshine-mtt/Selenium
/52_week.py
602
3.828125
4
""" 作者:sunshine 功能:52周存钱法 版本:1.0 日期:04/22/2019 """ def main(): """ 主函数 :return: """ i = 1 #第一周 total_week = 52 #总周数 money_value = 10 #第一周存钱金额 increase_value = 10 #每周递增金额 saving_value = 0 #存入总金额 while i <= total_week: saving_va...
9b57012b0fa30d844faf71c260706285ae5bebe9
aeifkz/Algorithm
/sort/sort.py
4,421
4
4
import random def select_sort(x) : '''select sort O(n^2)''' for to_fill in range(len(x)) : min_pos = to_fill for step in range(to_fill,len(x)) : if x[step] < x[min_pos] : min_pos = step #python swap skill x[to_fill] , x[min_pos] = x[min_pos] , x[to_fi...
2f1bd276d97037bd62fdba9791e8a5077165b7f2
JerryLead/AndroidGCProfiler
/src/main/python/statistics/ThreadPause.py
716
3.765625
4
import datetime as datetime class ThreadPause: def __init__(self, time, threadPauseTime): self.time = time self.threadPauseTime = threadPauseTime def getTime(self): return self.time def getThreadPauseTime(self): return self.threadPauseTime def println(self): ...
140c4b16850436cccaae0823a9a761363557c290
vaibhav1236/Pass_generator
/pass.py
381
3.703125
4
import string import random i=int(input("Enter the integer value for your no of characters in password\n")) v=[] s = string.ascii_lowercase u = string.ascii_uppercase p = string.punctuation k = string.digits v.extend(list(s)) v.extend(list(u)) v.extend(list(p)) v.extend(list(k)) random.shuffle(v) #print("".join(v[0:...
bc7ffcf84e286fbbe4e51baa584ef370f9651bfd
frostyfeet909/testingFoam
/plotCases/dataInterface.py
733
3.625
4
# modifies and retrieves entries from files from csv import reader from os.path import join def get_data(case): # Get the data from the csv rows = [] file_name = "DataSummary.csv" path = join("..", "resources") file_loc = join(path, case, file_name) with open(file_loc, 'r') as file: p...
620a67cbe340ace45f2db953d28b110f9fb0ac3d
timwilson/base30
/base30/base30.py
2,528
4.4375
4
#!/usr/bin/env python3 """ This module provides two functions: dec_to_b30 and b30_to_dec The purpose of those functions is to convert between regular decimal numbers and a version of a base30 system that excludes vowels and other letters than may be mistaken for numerals. This is useful for encoding large numbers in...
c7a5ab89ed0ee49fb3dc6104ac8aa1ff2c1905b2
shimaokasonse/xling-USE-demo
/translate_dataset.py
813
3.640625
4
from google.cloud import translate import pandas as pd def transform(dataset_df, target_language): """ dataset_df: pandas dataframe which has columns [label, text]. target_language: target language code to translate """ translate_client = translate.Client() translated_texts = [] for text in...
b47bbc3a83ca70eb5945af4391cb7121b5455999
cash2one/TTEngine
/windows/_xtPlatform/script/python/Timer.py
1,024
3.5625
4
# -*- coding:utf-8 -*- import time import threading import traceback class Timer(threading.Thread): def __init__(self, interval, name, bSetTitle = False): threading.Thread.__init__(self) self.__interval = interval self.__name = name self.__stop = False self.__bSetTitl...
2edbff91dbd2ace244961a3d8c17a52912641e86
Ankita-3107/Bank_Atm
/Atm.py
1,469
3.9375
4
class atm: def __init__(self,pin): self.pin = pin def checkBalance(self): print("Your current balance is INR 50000") def withdrawCash(self,amount): newAmount = 50000 - amount print("You have withdrawn"+str(amount) + ". Your remaining balance is "+ str(newAmount)) ...
b7ce2f7ea2af2ea9991e855df39d5789cec69a71
JulianaCapador/Ejercicios-
/palindroma.py
192
3.6875
4
def palindromo(n): if len(str(n))<=1: return True elif str(n)[0]==str(n)[len(str(n))-1]: return palindromo(str(n)[1:len(str(n))-1]) else: return False
d0ad02b9f4c825b85aba1e32872269e34c75e48e
aaronlai1027/Data-Structure
/week1_basic_data_structures/check_brackets.py
707
3.90625
4
# python3 def find_mismatch(text): stack = [] dict = {")":"(","]":"[","}":"{"} for i, char in enumerate(text): if char not in dict.values() and char not in dict.keys(): continue if char in dict.values(): stack.append((char,i)) elif not stack: return i + ...
beb2f3f251ccf3caaefa9eebbb494f63e0637f15
OctoberGOD/leetcode
/删除链表的倒数第n个结点/vanilla.py
607
3.734375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: start=ListNode(0) start.next=head mark=[] this=start while t...
52fe5af5fbbca4ec1b502beeeb4eafa17de5c19f
alexandr573/abcdefg
/ruffier.py
1,462
3.8125
4
# Модуль для расчета результатов # Здесь должен быть твой код def index_ryf(x1, x2, x3): a = (4 * (x1 + x2 + x3) - 200) / 10 return a def test_ryf(v, a): if (v >= 15 and a >= 15) or (13 <= v <= 14 and a >= 15.5) or (11 <= v <= 12 and a >= 18) or (9 <= v <= 10 and a >= 19.5) or (7 <= v <= 8 and a >= ...
0da52f8fa4c714f703278e37207fb8ede9c93847
ZkDragonZk/calular-KM-de-uma-cidade-para-outra
/km.py
641
3.703125
4
import time import os print('====== PAINEL DE KM ======') print('') # SUA ESCOLHA DE CIDADE cidadeatual = (input('Digite Sua Cidade: ')) cidadequevai = (input('Digite A Outra Cidade: ')) print('') os.system('cls') # SEGUNDA PARTE DE CALCULO kminicial = int(input('Digite a KM Inicial: ')) kmfinal = int(in...
c59f05b1e79f1ee50c633253c1f9c36ff477224c
SamP-S/PyScripts
/PyRay/vectors.py
5,356
3.71875
4
import math # 2D - Vector class vec2: def __init__(self,x=0,y=0): self.x = x self.y = y self.v = [self.x, self.y] # string return for printing def __str__(self): return "v2: x=" + str(self.x) + " y=" + str(self.y) # overload + operator def __add__(self, v): ...
ca67267e30238efb12eae4ccfec79d59ecd94d04
SamP-S/PyScripts
/PyPhysics/rigid_sim.py
3,057
3.65625
4
from simulator import Simulator as Sim from random import randint, uniform from circle import * from numerical import * import time import math class Rigid_Physics_Simulation: NUM_CIRCLES = 100 CIRCLE_MIN = 10 CIRCLE_MAX = 12 VEL_MIN = 50 VEL_MAX = 100 def rand_circle(self): r = randi...
c12e5c7d3d71712f5b4cd7b83fec51c2ba8a334e
SamP-S/PyScripts
/PyPhysics/sphere_collision.py
933
3.78125
4
# collision detection for spheres or quick light detection # much quicker as only a distance/radius is required # then 3d pythagoras can be used import math # 3d vector for position and direction class vec3: def __init__(self, x,y,z): self.x = x self.y = y self.z = z def v3_normalise(a): ...
0e8b85676b6edfabcf03a79b551c0cf1d47a47eb
SamP-S/PyScripts
/PyPhysics/numerical.py
281
3.5
4
from random import randint def randneg(a): r = randint(0, 1) if r == 1: return a else: return -a def positive(a): if a >= 0: return a else: return -a def negative(a): if a <= 0: return a else: return -a
1ab0d678898181dafb564ce94fde1586bf560012
hschen0307/Grammar-analyzer
/grammar.py
2,063
3.65625
4
__author__ = 'Hsuan-Chih, Chen' import json class grammar: grammar = {} def __init__(self, file_name): self.grammar = json.load(open(file_name)) def parser(self,input_string): stack = [] string_list = [] for ch in input_string: st...
40635f124110803dfa9a0f31239c6146704fcb24
MonySOEURN/scrap_data_to_mysql
/first-scraper.py
2,343
3.609375
4
from urllib.request import urlopen from bs4 import BeautifulSoup import csv #convert word number to integer def word2num(word): lWord = word.lower() if lWord == "one": return 1 elif lWord == "two" : return 2 elif lWord == "three" : return 3 elif lWord == "four": ret...
593cab584c21b4754daa1abf44a583a2a83927f5
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/if_example1_safer_better.py
283
4
4
while True: try: age = float(input("How old are you?")) break except ValueError: print("You didn't give me a number") if age<0: print("Nobody can be that young") elif age<10: print("You are still a child") else: print("You old fart")
b441fe8a944dc8e9ecd2dad64bc70dbd7c9eeb0d
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_lists_dictionaries_modules/list_examples3.py
308
3.78125
4
from random import shuffle a = list(range(1,11)) # a = [1, 2, 3…10] print("Sum:", sum(a)) # 55 print("Smallest:", min(a)) print("Largest:", max(a)) shuffle(a) print("Shuffled;", a) a.sort() print("Sorted:", a) a.reverse() print("Reversed", a) a.sort(reverse=True) # more efficient way to do reverse sort
8f3a98e1aad0dde6b3860912b726521135d3b120
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/slots_example.py
419
3.6875
4
class MyClass(object): def __init__(self, name, identifier): self.name = name self.identifier = identifier m = MyClass("name", "id") m.age = 100 print(m.age) # Same with slots class MyClass2(object): __slots__ = ['name', 'identifier'] def __init__(self, name, identifier): self.name...
26bad3514de2798958e0d8e7e524d09081cb46b4
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/numbers_statistics1.py
366
3.984375
4
numbers = [] while True: s = input("Give me a number (enter to stop)?") if not s: break try: n = float(s) numbers.append(n) except ValueError: print("Invalid number. Please give me valid floating point numbers.") print(f"Number of numbers: {len(numbers)}") print("Numbers sorted:...
859f01470c4df8c3f032293d9f1d02d07c46799e
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/function_returning_function.py
212
3.65625
4
# A function returning a function def make_adder(n): def adder(x): return x+n return adder # More concise version def make_adder(n): return lambda x: x+n inc2 = make_adder(2) print(inc2(4))
15525d4523af939e5a903858f9c4807af3e10a11
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/writefile5.py
249
3.625
4
with open("test.txt", "w", encoding="utf-8") as f: while True: line = input("Give me a line?") if not line: break # print(line, file=f) print(line, file=f, flush=True) # alternative: you can use f.flush()
400b14f32ee96af63ee8fbf4c750443ec51c1532
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/side_effect.py
629
4.375
4
# WARNING! DO NOT PROGRAM LIKE THIS # THE FOLLOWING FUNCTION HAS AN UNDOCUMENTED SIDE EFFECT def mymax(a): """Return the item of list a, which has the highest value""" a.sort() # sort in ascending order return a[-1] # return the last item a = [1, 10, 5, -3, 7] print(mymax(a)) print(a) # a is sorted as ...
15495c3277b583b06d78fc9bb487a3c5931aaf3e
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/json_example3.py
150
3.625
4
import json d = {"name": "example ÄÖ", "number": 123, "list": [1, 2, 3]} s = json.dumps(d) # s is string in JSON format containing data from d print(s)
c44ec6723bb73d20e2adb2e68b74a4d5018b6a9f
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_lists_dictionaries_modules/lotto2.py
216
3.578125
4
from random import shuffle numbers = list(range(1, 41)) # create numbers 1...40 shuffle(numbers) # shuffle numbers to random order row = numbers[:7] # take first 7 row.sort() print(", ".join([str(x) for x in row]))
cfb4d5c4bfeeb729969a5cd3169d09ee8c63e079
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/typing_hints.py
779
4.125
4
from typing import List, Dict, Tuple, Union, Any def square(x: float) -> float: return x*x def is_negative(x: float) -> bool: return x < 0 def print_many(s: Union[str, int, float], n: int = 5) -> None: for i in range(n): print(s) def multiply_list(a: List[float], n: float) -> List[float]: re...
e0a53a5280694db364f5607a74fdb3386c9c1a2d
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/sum_numbers1.py
157
3.625
4
path = input("Give me file path?") sumx = 0 with open(path) as f: for line in f: n = float(line.rstrip()) sumx += n print("sum =", sumx)
a171053dd141100ade24dbafdaa22ad26d42ad85
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/timing_things.py
442
3.703125
4
from timeit import Timer # manually construct a list of squares print(Timer('a=[];\nfor x in range(1,100001): a.append(x*x)').timeit(number=5)) # use list comprehension print(Timer('[x*x for x in range(1,100001)]').timeit(number=5)) # use generators print(Timer('list(x*x for x in range(1,100001))').timeit(number=5)) # ...
e499d64a713706ac756077b6e2c5e825b687d3c7
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/default_parameters2.py
858
3.75
4
def ask(question, choices, correct, retries=2): i = 1 print(question) for c in choices: print(i, c) i += 1 while retries>0: try: guess = int(input("?")) except ValueError: continue if guess==correct: print("right") b...
047fe4c0903be5318f414cff2ce4fbb295768f58
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/ask_float_safely.py
533
4.15625
4
def ask_float(question): """display the question string and wait for standard input keep asking the question until user provides a valid floating point number. Return the number""" while True: try: return float(input(question)) except ValueError: print("Please giv...
8b3498cef391bc920ca5d9db2966bd3cbe71bcfd
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/closure.py
322
4.21875
4
# Example of a closure def make_multiplier(x): # outer / enclosing function def multiplier(y): # inner / nested function return x*y return multiplier mul10 = make_multiplier(10) # mul is the closure function print(mul10(5)) # 50 print(mul10(10)) #100 mul2 = make_multiplier(2) print(mul2(10)) # 2...
f174cf7b86406bfb371b89278d03a2252b2dc8ca
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/if_example0.py
170
3.796875
4
password = input("What is the correct password?") if password == "secret": print("Access granted") else: print("Forbidden. Wrong password.") print("The end")
65b535dfa58de6e14ad4d052ed19948bf2d1e12b
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_regular_expressions/using_regular_expression_groups.py
812
3.5625
4
import re zip_re = re.compile(r"\d{5}") print(zip_re.findall("Here are some zip codes: 11100 and 11130")) phone_re = re.compile(r"(\d{2,4})-(\d{1,10})") print(phone_re.match("050-1234567").groups()) # ('050', '1234567') print(phone_re.match("050-1234567").group(0)) # '050-1234567' print(phone_re.match("050-1234567").gr...
f6f6ffa96639370c4f6c69d7cb20880f238007be
CalumGM/Traffic-Light-Simulation
/Car.py
5,259
3.65625
4
from random import randint STEP_DISTANCE = 2 class Car: def __init__(self, canvas, position=1, is_turning=False, colour='blue'): self.canvas = canvas self.position = position self.is_turning = is_turning self.colour = colour self.car_rectangle = None def __str__(self)...
f52d79585a39bf8a4be6f030388af3788a27f119
TDhondup/Unit_4_Lesson_4
/Lesson 4/pythonproblem1.py
226
3.546875
4
from turtle import * me = Turtle() me.color("red") me.pensize(6) me.speed(7) me.shape("turtle") me.forward(80) me.left(50) me.forward(200) me.right(150) me.forward(50) me.circle(25) me.backward(30) me.circle(50) mainloop()
f162f9720be4566474fcd6e09731c5f43a727059
sterlingb1204/EOC2
/HW4.py
998
4.5
4
#-- Part 2: Python and SQLite (25 Points) #-- #-- Take your Homework 1, Part 1 module and re-write #-- it to so that it queries against the sqlite3 #-- babynames database instead. #-- #-- The beauty of this approach is that, because #-- your original code was in a module, you can #-- change how the module fulfills the...
8edaa240bfa299858af517274fd043a0b9dd2ab9
sukanta-27/OneStopWeather
/DataClass/WeatherSearchResult.py
1,698
3.578125
4
from datetime import datetime from util.Helper import Country class WeatherOfTheDay: """ Contains weather data for a specific day For referrence: https://openweathermap.org/forecast5#parameter """ def __init__(self, daySpecificData:dict): if not isinstance(daySpecificData, dict...
25084c5c2c5bed0f90a1e9769fae32ba51258931
thk-lightman/AIFFEL
/FUNDAMENTALS/exercises/06-1.py
182
3.546875
4
import time start = time.time() # 시작 시간 저장 a = 1 for i in range(10000000): a += 1 # 작업 코드 print("time : ", time.time() - start) # 결과는 '초' 단위
6b2f0f9454303e4009461e8459d33e898ab5ed4c
thk-lightman/AIFFEL
/FUNDAMENTALS/exercises/06-5.py
247
3.65625
4
import time num_list = ["p1", "p2", "p3", "p4"] start = time.time() def count(name): for i in range(0, 100000000): a = 1 + 2 print("finish : ", name) for num in num_list: count(num) print("time : ", time.time() - start)
577a1123a09de77875d2f9ca599f85974af850ce
tanaya1708/capcode
/hungry.py
100
3.78125
4
hungry = input("Enter input = ") if hungry == "yes": print("eat") else : print("get lost")
6407a4ae08d50cd651b36a04f8c9adcca364be0c
tommyshere/python-data-structures
/duplicates_in_array.py
697
4.03125
4
from collections import Counter def one(arr): value = Counter(arr) for key in value: if value[key] > 1: return "DUPLICATES" return "NO DUPLICATES" # this way only works if the values in the array are less than len(arr) def two(arr): for num in arr: # if the value is pos...
0b2d40f708687f188417e692b07dfcbab6b79824
sofia-adzhiniiazova/Python
/homework06.py
5,771
3.828125
4
# 1.Светофор import time class TrafficLight: __color = ["Красный", "Желтый", "Зеленый"] def running(self): while True: print(self.__color[0]) time.sleep(7) print(self.__color[1]) time.sleep(2) print(self.__color[2]) ...
837bcf6aa63992895566fabffb67865c94262913
samgarcia3/MY-CS50
/pset6/credit.py
768
3.5625
4
from cs50 import get_int from math import floor # Prompt user for positive int def main(): while True: card_number = get_int("Card Number: ") if card_number > 0: break return card_number # Check the legnth of CC number i = int(card_number * 1) counter = 0 ...
c56417fb430acceb398e46d628dc6dd5932375ad
PapaKIRA/PythonExamples
/PythonExamples/blabla/src/Binary.py
203
3.671875
4
''' Created on Nov 29, 2012 @author: Andrei ''' print("Hello binary world") y = 2 b = bin(y) x = hex(y) o = oct(y) print("Decimal=",y, "Bin=",b, "Hex=",x, "Octal=",o) print ("End of program")
76b3dca27d60584a7cd9a3569b23ff4156ee88f6
inesghl/taquinAstarPython
/main.py
1,584
3.6875
4
import numpy as np from jeuDeTaquin import * from AStarGeneral import AStar def saisieMatrix(d): initList = [] for i in range(d): v = True print("ligne[", i, "]") while (v): x = list(map(int, input("Enter les valeurs séparés par un espace: ").split())) v = len...
827056fba8340cd8acb260488f2ece3d36f9abcc
edwinsuubi/FINDING-BIRTHDAY-
/programming assignment.py
1,488
4.03125
4
import calendar a=input("Input your year of birth?\n") b=input("Now input your birth month using numbers from 1-12:\n") c=input("Now input the day of the month on which you were born also using numbers from 1-31:\n") x=calendar.weekday(year=int(a), month=int(b), day=int(c)) #prefix= ['st','nd','rd']+ 17*['th'...
9e5ddf22d5b55ace91a97029ab600ac49bb5ad97
StevanCakic/ORS-UDG
/Nedelja 6/files_p2.py
3,601
3.90625
4
# Zadatak 2 # U fajlu studenti nalazi se lista studenata sa ocjenama oblika # ime, prezime, ocjena za zadati predmet. Svaki student se cuva u novom redu # Ocjene: 10, 9, 8, 7, 6, 5 # Napisati funkciju koja vraca prosjecnu ocjenu ostvarenu na ispitu. # E [6 - 6.5), D [6.5, 7.5), C [7.5, 8.5), B [8.5, 9.5), A [9.5, 10] ...
e553ccf12acddce9e8675e686e73c2d3931d1abc
aarongilman/fypy
/fypy/fit/Objective.py
828
3.78125
4
from abc import ABC, abstractmethod import numpy as np class Objective(ABC): def __init__(self, strength: float = 1.0): """ A generic calibration objective, e.g. the price targets or some penalty to combat overfitting, arbitrage, etc. A calibration problem is a set of objectives, each give...
5864fa3fb3a7eb1120bc1efa5caa3d39a341107a
yvrjsharma/RNN
/Sentiment_analysis_word_embeddings_on_the_fly.py
4,792
3.65625
4
# ## Sentiment analysis using word embeddings learned on the fly and Dense RELU # In[ ]: #Creating Training(25,000)+Validation(15,000) and Test(10,000) sttartefied dataset - a split of 50-30-20% respectively #First splitting dataset of 50,000 instances into training (80%) and test (20%) from sklearn.model_selection...
72a57873e6b76e6b36216c988795c0edd8cc1cce
natimoreno/challenges
/j2logo/chall8.py
587
4.09375
4
# Implementar una función llamada ordena_ciudades(ciudades) que reciba como argumento # un diccionario con ciudades y su población y devuelva una lista con los nombres de las # ciudades de más de 200.000 habitantes. La lista devuelta debe estar ordenada de mayor # a menor según el número de habitantes de cada ciudad....