blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c9f8feb5dceca65df1e800cdf743dd417983e1d3
candyer/codechef
/September Challenge 2018/MAGICHF/MAGICHF.py
950
3.59375
4
# https://www.codechef.com/SEPT18B/problems/MAGICHF ####################### ###### solution 1 ##### ####################### def solve(n, x, s, actions): boxes = [False] * (n + 1) boxes[x] = True res = x for a, b in actions: if boxes[a]: boxes[a], boxes[b] = boxes[b], boxes[a] res = b elif boxes[b]: bo...
2bc16f43539e10dd76edfafd8c81deb868a8b15d
Kwasniok/Cards
/core/owning.py
721
3.921875
4
from abc import abstractmethod class Owner: @abstractmethod def __init__(self): pass class Owned: @abstractmethod def __init__(self, owner): self._owner = None self.change_owner(owner) def get_owner(self): return self._owner def change_owner(self, owner): ...
877fece738080ab8437571be6664d2c0f50445a7
gitjcart/python
/clinic.py
1,256
4.09375
4
# clinic.py def clinic(): print "you've been chosen to represent the break lounge!" print "pick a number between 1-10" answer = raw_input("!!! ").lower() if answer == "1" or answer == "one": print "was your number %s!?" %(answer) elif answer == "2" or answer == "two": print "was you...
f9145c857320988897d3e8861d551d872cde2358
ericskim/redax
/redax/spaces.py
19,871
3.796875
4
r""" Nomenclature: bv = Bit vector \n box = \n point = element of set \n cover = \n grid = a countable set of points embedded in continuous space \n """ import itertools import math from abc import abstractmethod from typing import Iterable, Tuple from dataclasses import dataclass, InitVar, field import numpy as np...
ce7ef68e60b7f780ecac42666f8a9f553aa9f10f
fatih-iver/Intro-to-Relational-Databases
/Select Where.py
275
3.6875
4
# The query below finds the names and birthdates of all the gorillas. # # Modify it to make it find the names of all the animals that are not # gorillas and not named 'Max'. # QUERY = ''' select name from animals where not (species = 'gorilla' or name = 'Max'); '''
ede469d19908b74e2228406fbeafe13dde9e47d8
RobertMusser/Avent-of-Code
/2019/08/one.py
1,791
3.546875
4
# dumps orbits into list def file_reader(file_name): with open(file_name) as file_pointer: while True: line = file_pointer.read() if not line: break raw_data = line[0:(len(line)-2)] # strips \n\n from end of line print(raw_data) return raw_data ...
fa65c84253e99d411c94cb6463cac4b24ea9d0e2
tmu-nlp/100knock2017
/Shi-ma/chapter01/knock02.py
147
3.5625
4
str1 = 'パトカー' str2 = 'タクシー' str_ans = '' for i in range(len(str1)): str_ans += str1[i] str_ans += str2[i] print(str_ans)
4a110205ff6777bf3a8b66b7c48cbd95e0ee0256
mo-dt/PythonDataScienceCookbook
/ch 2/Recipe_1c.py
649
3.953125
4
# Alternate ways of creating arrays # 1. Leverage np.arange to create numpy array import numpy as np from Display_Shape import display_shape created_array = np.arange(1,10,dtype=float) display_shape(created_array) # 2. Using np.linspace to create numpy array created_array = np.linspace(1,10) display_sha...
556769551dca2921d2a1df940e62088bf323821b
Stevenzzz1996/MLLCV
/Leetcode/链表/1019. 链表中的下一个更大节点.py
744
3.515625
4
#!usr/bin/env python # -*- coding:utf-8 -*- # author: sfhong2020 time:2020/5/8 21:38 # 输入:[1,7,5,1,9,2,5,1] # 输出:[7,9,9,9,0,5,0,0] class Solution: def nextLargerNodes(self, head: ListNode) -> List[int]: nums = [] node = head while node: nums.append(node.val) node ...
879760525cbf51add321e1755a23f021acf92a5c
thamtommy/COMP4Coursework
/Implementation/CLI/create_tables.py
3,099
3.921875
4
import sqlite3 def create_table(db_name,table_name,sql): with sqlite3.connect(db_name) as db: cursor = db.cursor() cursor.execute("select name from sqlite_master where name=?",(table_name,)) result = cursor.fetchall() keep_table = True if len(result) == 1: respon...
977a3354315bbf102ba45d7dd0334d15353202e2
chicory-gyj/JustDoDo
/pre_test/except.py
333
3.890625
4
#!/usr/bin/python try: x=input('enter the first number:') y=input('enter the second number:') print x/y except (ZeroDivisionError,TypeError,NameError),e: print e print 'ddd' try: x=input('enter the first number:') y=input('enter the second number:') print x/y except: print 'Someting mu...
ec1b00a48b23ee6443ad0780db5589fb93877565
Da1anna/Data-Structed-and-Algorithm_python
/leetcode/其它题型/递归/第N个泰波那契树数.py
1,203
3.703125
4
''' 泰波那契序列 Tn 定义如下:  T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2 给你整数 n,请返回第 n 个泰波那契数 Tn 的值。   示例 1: 输入:n = 4 输出:4 解释: T_3 = 0 + 1 + 1 = 2 T_4 = 1 + 1 + 2 = 4 示例 2: 输入:n = 25 输出:1389537   来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/n-th-tribonacci-number 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明...
5881b602039ea8c20e829f13bf024fd66d37a63d
dastous/HackerRank
/The HackerRank Interview Preparation Kit/Search/03. Pairs
744
3.5
4
#!/bin/python3 import math import os import random import re import sys # Complete the pairs function below. def pairs(k, arr): count =0 # Sort array elements arr.sort() l =0 r=0 while r<n: if arr[r]-arr[l]==k: count+=1 l+=1 r...
f615243921d1285495ef15e2625b921a0b92ad28
JJong0416/Algorithm
/Programmers/2Level/StackQueue/Printer/minki.py
580
3.609375
4
def solution(priorities, location): answer = 0 printCount = 0 while len(priorities) != 0: first_item = priorities.pop(0) check = False for item in priorities: if item > first_item: check = True if check: priorities.append(first_item) ...
1a2bafe0b9a1c16cf521fd25077cc43aa6ca9103
Vidhyalakshmi-sekar/LetsUpgrade_PythonAssignment
/primeNumber.py
442
4.15625
4
# getting number as input input_number = int(input('Please enter a number: ')) if input_number > 1: for num in range(2, input_number): if input_number % num == 0: print('The number {} is not a prime number'.format(input_number)) break else: print('The number {...
0034a3442023cbae28e4cdd84f9389cda61b9730
KedraMichal/python-lab
/lab5/shape_classes.py
3,173
3.8125
4
def is_number(number): try: float(number) return True except: return False class Vector_2D: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Vector_2D(self.x + other.x, self.y + other.y) def __iadd__(self, other): ...
6f6d772b5e18173f88b051de5b8121aa37661f4a
fruitynoodles/Python_Examples
/numpy_matplotlib/curvefit.py
458
3.5
4
import numpy as np import matplotlib.pyplot as pl #set up noisy data set based on quadratic datax = np.arange(0,10,0.5) datay =(0.8-0.4*np.random.rand(np.size(datax)))*datax**2 # generate fitted polynomial pfit = np.polyfit(datax,datay,3) #generate polynomial x-y data fitx = np.linspace(np.min(datax),np.max(datax),100...
b0131a522cf297b9dc92b9080e16fa22d6f2e3e3
dbridenbeck/recordexpungPDX
/src/backend/expungeservice/database/database.py
2,645
3.53125
4
"""Database module""" import logging import psycopg2 import psycopg2.extras import os class Database(object): """Database connection class. Example usage: import os password = os.environ['POSTGRES_PASSWORD'] from expungeservice.database import database # Get a connection. db = database.Database(host='db', po...
7d526de5d58f3be976dee9ec24b39fa85fb03ac0
kvombatkere/Enigma-Machine
/Rotorset.py
7,970
3.515625
4
#Karan Vombatkere #German Enigma Machine #October 2017 from string import * import numpy as np Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #function to create a dictionary with letters and their indices #Use this to return the index of a letter (a = 0, .., z = 25) def genDictionary(): letter_index_pairs = [] for...
9758932f9f5ff8b7fd148cd62983aa083b14e434
mihaivalentistoica/Python-Fundamentals
/Curs4/Exercitii_singuri.py
1,805
3.578125
4
''' 1. Creati clasa Animal cu 2 atribute private(mangled): nume si varsta. La initiere se dau valori default. Sa se creeze getteri si setteri pentru ambele campuri. Creati cel putin 2 obiecte si testati proprietatile create. ''' class Animal: def __init__(self): self.__nume = None self.__varsta = ...
c9ac60eeeb2e14534883034e6e6a7d6e8ad5235a
amandashotts/Pig-Latin-Translator
/piglatintranslator.py
370
3.796875
4
# A fun pig-latin translator. pyg = 'ay' original = input('Enter a word:') if len(original) > 0 and original.isalpha(): word = original.lower() first = word[0] new_word = ('%s%s%s' % (word, first, pyg)) new_word = new_word[1: len(new_word)] print(new_word) else: print('Error! T...
51d1dc5ddb4dd6e324206c6d39f7fd0b7f9c916d
cpeixin/leetcode-bbbbrent
/queen/circular_queue.py
842
3.921875
4
class circular_queue(): def __init__(self, size): self.array = [] self.head = 0 self.tail = 0 self.size = size def enqueue(self, value): """入队判满""" if (self.tail + 1) % self.size == self.head: return False self.array.append(value) """...
04db0b6af5dc527281784edc380602b0b3fa23cb
Upasna4/Training
/op.py
688
3.78125
4
import os print(os.getcwd()) #current working dir path=os.getcwd() #gives current working dir print(path) loc=__file__ print(loc) #to check puri location print(os.getcwd()) os.chdir("C:\\Users\\hp\\desktop") #to change loc of rest of the files which will be made later(first method using double...
c33612d749548f5bb305f301ea52624c57dafda4
mayelespino/code
/LEARN/python/sorting/my-merge-sort-01.py
727
3.640625
4
from random import randint listOfRandomInts = [] for x in xrange(1,10): listOfRandomInts.append(randint(0,99)) def mergeSort(listToSort): if len(listToSort) <= 1: return listToSort halfPoint = len(listToSort) / 2 left = mergeSort(listToSort[:halfPoint]) right = mergeSort(listToSort[halfP...
63077f16d214292959d862163c4b07b8449cb9f4
jerkuebler/Pathfinding
/main.py
764
3.765625
4
# Meant to demonstrate a simple pathfinding algorithm with recursion import pygame import grid pygame.init() pygame.display.set_caption('Pathfinding') grid = grid.Grid() BLACK = (0, 0, 0) BLUE = (0, 0, 255) WHITE = (255, 255, 255) RED = (255, 0, 0) grid.screen.fill(BLACK) clock = pygame.time.Clock() done = False st...
513d2ef278bfc9a41f945a64f93dda78b040c61b
cssd2019/mutationplanner
/mutationplanner/read_fasta.py
526
3.515625
4
from Bio import SeqIO, Seq def read_fasta(file_path): """ Reads a fasta file and converts it into a dictionary :param file_path (string): path of the fasta file to read :return: a dictionary of fasta records """ seq_dict = {} for sequence in SeqIO.parse(file_path, "fasta"): # s = str(...
fd05729b587e18a1d80b8491cb5a47a07a645e14
viniciusbonito/CeV-Python-Exercicios
/Mundo 1/ex017.py
374
3.96875
4
#crie um programa que peça os cumprimentos dos catetos adjacente e oposto de um triângulo retângulo e calcule #a hipotenusa import math oposto = float(input('Informe o comprimento do cateto oposto: ')) adjacente = float(input('Informe o comprimento do cateto adjacente: ')) hipotenusa = math.hypot(oposto, adjacente) p...
80556910787d27ff185989190cfc3b5cdd51a7f9
Alekseevnaa11/practicum_1
/52.py
1,003
3.765625
4
""" Имя проекта: practicum-1 Номер версии: 1.0 Имя файла: 52.py Автор: 2020 © Д.П. Юткина, Челябинск Лицензия использования: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/deed.ru) Дата создания: 04/12/2020 Дата последней модификации: 04/12/2020 Описание: Решение задачи 52 практикума № 1 #версия...
f65b20df3c85f9a7aea170a4375a06b542c2725f
aniGevorgyan/python
/sixth.py
1,053
3.671875
4
#! usr/bin/python3.6 # 1. number = int(input("Type number: ")) word = input("Type word: ") list = [] for i in range(number): s = input("Sentence here: ") list.append("%d : %d" %(i, s.count(word))) print("\n".join(list)) # 2. number2 = int(input("Type number: ")) list2 = [] for i in range(number2): s =...
5341b02d3dda6deefda46454bba47ddfa51a40d9
jpardike/lists_ranges
/main.py
2,586
4.25
4
# --------------------- LISTS & RANGES # Lists are mutable (changeable) # Lists can contain similar types of data fruits = ['apple', 'banana', 'pear', 'grapes'] # Get Length # fruits.length # print(len(fruits)) # Accessing Elements first_fruit = fruits[0] last_fruit = fruits[-2] # Adding Elements fruits.insert(l...
7dcf2e243d29ccb080e57088fb637dea20ea9850
sinhdev/python-demo
/basic-programming/loops/for-loop.py
319
4.53125
5
#!/usr/bin/python for letter in 'Python': # First Example print('Current Letter :' + letter) fruits = ['banana', 'apple', 'mango'] for fruit in fruits: # Second Example print('Current fruit: ' + fruit) for index in range(len(fruits)): print('Current fruit :' + fruits[index]) print("Good bye!")
1009bade5f94183511a64795a317e4edf44762d8
warisamin25/Game
/Games.py
2,068
3.90625
4
import Mood from sys import exit from random import randint def main(): while True: #input1 = input("> What's your current mood? (Happy/Angry/Stressed/Sad): " ).lower() if set_mood == "happy": setting = Mood.Happy() break elif mood == "angry": ...
10f2cc80d44941a24f64b4ad63e7cebe3bea7d99
fuburning/lstm_intent
/tensorgou/utils/txtutils.py
1,291
3.53125
4
""" """ import re, string import unicodedata def cleanline(txt): return txt.strip('\n') def to_lowercase(text): return text.lower().strip() def remove_all_punctuations(text): regex = re.compile('[%s]' % re.escape(string.punctuation)) text = regex.sub(' ', text).strip() return " ".join(text.sp...
d0da81523e9ee782e803d9e8b9368865bd87e8de
muadz-mr/python-censor-program
/main.py
318
3.78125
4
watchWords = ["apple", "head", "example", "bend"] message = input("What do you want to say? : ") for word in watchWords: censoredWord = "*"*len(word) if word in message: msgWord = word approvedMessage = message.replace(msgWord, censoredWord) message = approvedMessage print(message)
437ecd0a67cdc1dca2da6e6b32f95aafa585585a
priyapriyam/loop_question
/ankita.py
62
3.578125
4
list=[4,9,8,7,6,3,3] i=1 while i<len(list): i=i+1 print(i)
08e707d07ba2775c5796412cd6603096cacbb310
osnaldy/Python-StartingOut
/chapter13/g_c_d.py
235
3.765625
4
def main(): num1 = int(raw_input("Enter the first number: ")) num2 = int(raw_input("Enter the second number: ")) print gdc(num1, num2) def gdc(x, y): if x % y == 0: return y return gdc(x, x % y) main()
b647da93a9e0d9db30453d8eaaff4c5f9fdee6dc
pk026/competative_pragramming
/Flattening_a_Linked_List.py
1,254
4.3125
4
# Flattening a Linked List # Given a linked list where every node represents a linked list and contains two pointers of its type: # (i) Pointer to next node in the main list (we call it ‘right’ pointer in below code) # (ii) Pointer to a linked list where this node is head (we call it ‘down’ pointer in below code). # Al...
515dfe102a97b9c68ed07b3a7b8bf81c1a39bc02
Arina-prog/Python_homeworks
/homework_9/task_9_1.py
2,603
4.1875
4
# *Create a class for representing book with some attributes (author, owner, pages, price, current page) # # and behavior (change owner, increase price, change current page), create several books and perform operations on them # * Создайте класс для представления книги с некоторыми атрибутами (автор, владелец, страницы...
a4784c49e1ef5e7ba0ec24154650e7c3bbb9f678
dandoan1/CIS-2348-python
/Homework 2/7.25.py
1,792
3.84375
4
# Dan Doan 1986920 # first function will return the amount of times each of the variable was used. def exact_change(user_total): remaining = user_total dol = 0 qua = 0 dim = 0 nic = 0 pen = 0 while remaining > 100 or remaining == 100: remaining -= 100 dol += 1 while remai...
9b2d0d052ccba8adceda379d6b501ad03c971718
ghorutest/GeekBrains
/lesson-02/2. switch_pairs_in_list.py
567
3.9375
4
list_main = input ('Введите спиок через запятую\n').split(',') list_before = list(list_main) list_len = len(list_main) even = True if (list_len % 2) == 0 else False if not even: list_len = list_len - 1 print (f'Нечётная длина, игнорируем последний элемент \'{list_main[list_len]}\'\n') for pair in range(0, li...
6c5a4f0e7daa901fae21bdfd8809227166e2d450
marcinplata/advent-of-code-2017
/day_02.py
2,912
4.4375
4
""" --- Day 2: Corruption Checksum --- As you walk through the door, a glowing humanoid shape yells in your direction. "You there! Your state appears to be idle. Come help us repair the corruption in this spreadsheet - if we take another millisecond, we'll have to display an hourglass cursor!" The spreadsheet consist...
cf957384e33cdc36cab2e2391733797d55b28419
balajichander/tvr-tech
/cal.py
611
4.125
4
def add(x,y): return x+y def subtract(x,y): return x-y def multiply(x,y): return x*y def divide(x,y): return x/y print("selecion operation.") print("1.add") print("2.subtract") print("3.multiply") print("4.divide") choice=input("enter choice(1/2/3/4):") num1=int(input("enter first number:") num2=int(input("enter second...
e281a6c2e97163336c6dd784a3e11699223d1c74
havardnyboe/ProgModX
/2019/37/Oppgave 3.1-3.6.py/Oppgave 3.7.py
508
3.5
4
#Lag et program som løser andregradslikningen 𝑎𝑥^2+𝑏𝑥+𝑐=0, ved å ta 𝑎,𝑏 𝑜𝑔 𝑐 som input. a = float(input("Skriv inn en verdi for a: ")) b = float(input("Skriv inn en verdi for b: ")) c = float(input("Skriv inn en verdi for c: ")) if (b**2) - (4*a*c) == 0: en_losning = -b/(2*a) print(en_losning) elif (b**2 ...
0dbd7e796c295585d5d8df1d8912f15acc046ab1
geomstats/geomstats
/examples/plot_kmeans_manifolds.py
3,583
3.734375
4
"""Run K-means on manifolds for K=2 and Plot the results. Two random clusters are generated in separate regions of the manifold. Then K-means is applied using the metric of the manifold. The points are represented with two distinct colors. For the moment the example works on the Poincaré Ball and the Hypersphere. Comp...
2f71a9f1278fde929186c42723a05f2689fab860
dmitryzhurkovsky/stepik
/python_profiling/example1.py
275
3.75
4
class Iterator(): def __init__(self): self.i = 0 def __iter__(self): return self def __next__(self): if self.i <= 5: self.i += 1 return 0 else: raise StopIteration x = Iterator() print(x[2])
9c13ab78e2d74469b219d534db07f0c3124eb184
panxman/Python-Apps
/Computer-Vision/face_detector.py
618
3.546875
4
import cv2 # Load Cascade face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml") # Load Image img = cv2.imread("Path/to/image.jpg") # Image to Grayscale gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Find the face faces = face_cascade.detectMultiScale(gray_img, ...
66f0f81fd22daa5f9ab32292c252d161493f0aa3
mandyedi/coding-challenge-solutions
/cstutoringcenter-com/programming96.py
206
3.59375
4
import itertools s = "" numbers = [] for i in itertools.permutations([1, 2, 3, 4, 5, 6, 7, 8, 9]): for j in i: s += str(j) numbers.append(s) #for i in numbers: #i[0: s = "hello" print s[0:2]
7cde210322d0ee49ae710ed2c4b6f67427857f25
tongchangbin/python
/zdy.py
133
3.84375
4
#自定义函数 x = input('请输入数字:') x = int(x) def my_abs(x): if x >= 0: return x else: return -x print(my_abs(x))
3591e84a817e1c6139b41b57aa970e5a2cfc1129
WeiyangZhang/deep-learning-tutorial-with-chainer
/src/02_mnist_mlp/train_mnist_1_minimum.py
4,803
3.90625
4
""" Very simple implementation for MNIST training code with Chainer using Multi Layer Perceptron (MLP) model This code is to explain the basic of training procedure. """ from __future__ import print_function import time import os import numpy as np import six import chainer import chainer.functions as F import chain...
e48e5e40effd77a87c23ea484aae07c2ee66e0b3
qq854051086/46-Simple-Python-Exercises-Solutions
/problem_16_alternative.py
325
3.984375
4
''' Write a function filter_long_words()that takes a list of words and an integer n and returns the list of words that are longer than n ''' def filter_long_words(word_list,n): return [word for word in word_list if len(word)>n] word_list = ['abc','defgh','pqrstuvw','','abdghtfd'] print(filter_long_words(word_list...
9eaaf545663fb60629706113b23267f9c771c1d4
ImGoroshik/all-tasks
/masiv2.py
211
3.625
4
import random list = [random.randint(3, 15) for j in range(random.randint(3, 15))] summ = 0 a = 0 for a in range(len(list)): if list[a] % 3 == 0 and list[a] % 2 == 1: summ = list[a] print(list) print(summ)
738bda0ccb17983a4e3e39517315185c7e2bacf4
jmstratton/python-challenge
/PyBank/main.py
2,857
4.3125
4
# create a Python script that analyzes the records to calculate each of the following: # The total number of months included in the dataset # The total amount of revenue gained over the entire period # The average change in revenue between months over the entire period # The greatest increase in revenue (date and amoun...
bd4364047b82fedd7ee90635067a6c7c20f57e59
joebigjoe/Hadoop
/Spark快速大数据分析/第 3 章 RDD 编程/Python OOP Basic/classTest2.py
724
4.0625
4
#_name #__name ##__name__ # __init__ is the self defined methods by python, normally it has special purpose # __init__ is to initialize the instance of a class # __main__ is to show the start poin of a program. # nomally it is for override class Person: def __init__(self): self._name = "Joey" # this is ju...
46967699118df771c18826d0a4624f3a731f1b78
andersongfs/Programming
/URI/URI-1091.py
488
3.734375
4
# -*- coding: utf-8 -*- while True: qtd_casa = int(raw_input()) if(qtd_casa == 0): break x_ponto, y_ponto = map(int, raw_input().split()) for i in range(qtd_casa): x_casa, y_casa = map(int, raw_input().split()) if(x_casa > x_ponto and y_casa > y_ponto): print "NE" elif(x_casa > x_ponto and y_casa < y_po...
e3dce270f41a5505135a8eadbce8e3aba2716923
kuchunbk/PythonBasic
/2_String/String_Sample/Sample/string_ex43.py
594
4.09375
4
'''Question: Write a Python program to print the square and cube symbol in the area of a rectangle and volume of a cylinder. ''' # Python code: area = 1256.66 volume = 1254.725 decimals = 2 print("The area of the rectangle is {0:.{1}f}cm\u00b2".format(area, decimals)) decimals = 3 print("The volume ...
4784097591055b420d9da1df8a650782095d4d57
Amrutha26/100DaysOfCode
/Week2/Day13/Duplicate Character.py
1,382
3.6875
4
''' Duplicate Character Tina is given a string S which contains the first letter of all the student names in her class. She got a curiosity to check how many people have their names starting from the same alphabet. So given a string S, she decided to write a code that finds out the count of characters that occur more...
b39f0c8d5713d59b15ca0c9905ecfbc60de4b3ce
u19046500/280201055
/lab4/factorial.py
107
4.03125
4
n = int(input("Enter the number:")) sum_ = 1 for i in range(1, n+1): sum_ = sum_ * i print("n! =", sum_)
cf7c7dd390ce758150f031d9cd4f9f2c092535c4
erik-bordac/snake_neural_network
/classes/snakeClass.py
1,048
3.890625
4
class Snake(): def __init__(self): self.body = [{"x": 5, "y":5}, {"x": 4, "y":5}, {"x": 3, "y":5},] self.direction = "right" self.ate = False self.moves_left = 400 def move(self): """ Moves the snake in self.direction If snake ate apple in this iteratio...
84feca3a9f4db7181a67df5d99a2df30bbaf6ce2
nurhalfiansilayar/pgame
/pgame-16092/praktikum6.2.py
226
3.8125
4
batas='*'*30 x = 0 while (x < 5): x = x+ + 1 x += 1 print ("Praktikum 6 no.", x) a = 0 while a < 6: print (" no a == ", a) if a == 3: break a +=1 b = 0 while b < 6: b += 1 if b == 3: print("B == ",b) print(b)
88a91b1e4fb86498a0e47eda6a6fe17a5d2c26aa
Kiranc44/DSA-Project
/bankhash.py
4,920
3.734375
4
from banklinkedlist import LinkedList from bankqueue import Queue import datetime stint=0 def h(v): return int(v)%10 class hashtable: def __init__(self): self.T=[None for i in range(0,10)] def chained_insert(self,a,ln): k=h(a) if(self.T[k]==None): self.T[k]=LinkedList() ...
ea01165b8a27e783181912d103cef78b638aaeb5
Weless/leetcode
/python/general/1022. 从根到叶的二进制数之和.py
521
3.5625
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def sumRootToLeaf(self, root: TreeNode) -> int: def dfs(root,path): if root: path += str(root.val) if not root.left and not root.rig...
fb7df606223d91e294d9b599ad27e6d88058dac7
ShivamGupta-08/Oh-Soldier-Prettify-My-Folder
/Oh-Soldier-Prettify-My-Folder.py
1,648
4.375
4
import os def File_Reader(file_read): with open(file_read) as e: read = e.read() s = read.split("\n") return s def Folder_Prettifer(path, file, format): """This function prettify your folder by - 1 - Capitalizing the first letter of the files not folder expect the file names you ...
10e5829568952762fab910c6a43d4c77a1cf2542
Herna7liela/New
/list4.py
404
4.28125
4
# Write a program that asks the user to enter a number from 1 to 12 and # prints out the name of the corresponding month. months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] #months = [January, February, March, April, May, June, July, August, September, October, November, Dece...
10c7332d57801a828f1c1261d143866fcfe7567e
admud/matplotlibPython
/practice1.py
243
3.59375
4
import matplotlib.pyplot as plt x = [1,2,3] y= [5,4,7] x2 = [1,2,3] y2 = [10,11,12] plt.plot(x,y,label = "First") plt.plot(x2,y2,label = "Second") plt.xlabel('x axis') plt.ylabel('y axis') plt.title('cool graph') plt.legend() plt.show()
445aef32fe8b18831ddcb186e4422afbe42696b4
KHP-Informatics/RADAR-scripts
/radar/preprocess/filters.py
3,609
3.828125
4
#!/usr/bin/env python3 import pandas as pd from scipy import signal def butterworth(arr, cutoff, freq, order=5, ftype='highpass'): """ butterworth filters the array through a two-pass butterworth filter. Parameters __________ arr: list or numpy.array The timeseries array on which the filter is ...
eb0767677a68b68a8a0b350eb0393e757d598c8b
beejjorgensen/bgpython
/source/examples/ex_refval.py
190
3.84375
4
a = [1, 2, 3] #b = a # Copies reference to same list b = a.copy() # Makes a new list #b = list(a) # Also makes a new list #b = a[:] # Also makes a new list b[0] = 99 print(a[0])
51608c728ad02bc139b9fdb6e746bc63ec86d9c4
geekpradd/Project-Euler
/problem2.py
242
3.515625
4
__author__ = 'Pradipta' def fibo(): s=[] a,b=1,2 while a<4000001: s.append(a) s.append(b) a=a+b b=b+a return s def main(): total=sum([x for x in fibo() if not x%2]) print(total) main()
05256e312ec693dbaa1e7b30871f44532f2bf686
stemlatina/SI507--HW03--MariluD
/magic_eight.py
2,228
3.921875
4
#<<<<<<< HEAD import random class Magic8: def __init__(self, question): self.question = question pass def ask_question(self, question): question_list = [] q = self.question question_list.append(q) pass def pick_random_ans(self): #List from Wiki: https://en.wikipedia.org/wiki/Magic...
8b3b5da037a838d1d98c4fe3db8eb4f79db642e3
jpchato/data-structures-and-algorithms-python
/challenges/insertion_sort/test_insertion_sort.py
628
3.765625
4
from insertion_sort import insertion_sort def test_insertion_sort(): array_one = [5, 26, 9, 4, 3] actual = insertion_sort(array_one) expected = [3, 4, 5, 9, 26] assert actual == expected def test_negative_insertion_sort(): array_two = [-1, 2, 7, -100, 42] actual = insertion_sort(array_two) ...
a94cd29932db2f2586d321d60ed9a552f050127b
Jeff-ust/D002-2019
/L1/Q4.py
214
4.03125
4
yr = int(input("Please input the year.")) if (yr%4 == 0) and (yr%100 != 0): print("Yes, it is a leap year.") elif (yr%400 == 0): print("Yes, it is a leap year.") else: print("No, it is not a leap year.")
c301f134ea191e2f29cb56b41d00aa1baea7a5fe
singh7h/GeekforGeek
/Basic/Array.py
465
3.921875
4
"""Sum of array""" def _sum(arr): return sum(arr) def splitarr(arr, d): for i in range(d): new_arr = arr x = arr.pop(0) new_arr.append(x) print(new_arr) def largest(arr, d): large = arr[0] for i in range(0, d): if arr[i] > large: large = ar...
3612c0d1e059a647cf5e08c5c9b20fc5bdaf3a99
Celsoliv/Orientacao-Objetos
/OrientacaoObjeto01.py
1,347
4.34375
4
# Criando nossa 1ª Classe em Python # Sempre que você quiser criar uma classe, você vai fazer: # # class Nome_Classe: # # Dentro da classe, você vai criar a "função" (método) __init__ # Esse método é quem define o que acontece quando você cria uma instância da Classe # # Vamos ver um exemplo para ficar mais claro, com ...
2fa6d7a3e3b5e409f383e1c6da83fd421148fc42
sukhesai/algorithms_and_data_structures
/learning docs/testt1.py
181
3.609375
4
import math x = 0 for y in range(1,50): for i in range(1,y+1): #print(i,math.floor(i*math.sqrt(2))-i) x += math.floor(i*math.sqrt(2)) print((2*x)/(y*(y+1)))
81a11b12218b61c724d09fc3aa759f13734893fb
staufferl16/Programming112
/evaluator.py
2,374
3.5
4
""" Author: Leigh Stauffer File: evaluator.py Project 10 """ from tokens import Token from scanner import Scanner from linkedstack import LinkedStack class Evaluator(object): """Evaluator for postfix expressions. Assumes that the input is a syntactically correct sequence of tokens.""" ...
99985d96503ee8b998b736e3bb4aece9b3498293
claraqqqq/l_e_e_t
/139_word_break.py
1,679
4.03125
4
# Word Break # Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. # For example, given # s = "leetcode", # dict = ["leet", "code"]. # Return true because "leetcode" can be segmented as "leet code". class Solution: # @par...
e6000854575fdf45dcf4e37ebe08d0f5fab5430b
TheRealSnuffles/Python-HW
/Boolean.py
333
4.0625
4
test1=float(input('What was your 1st test score?')) test2=float(input('What was your 2nd test score?')) test3=float(input('What was your 3rd test score?')) HIGH_SCORE=95 average=(test1+test2+test3)/3 print('The average score is', average) if average >= HIGH_SCORE: print('Congratulations!') print('that is a grea...
3d4a0f9e37d593bd33e81134633cb428d0bb645f
CatchTheDog/python_crash_course
/src/chapter_4/logical_control_2.py
310
3.96875
4
car = 'subaru' print("Is car == 'subaru'? I predict True!") print(car == 'subaru') requested_toppings = [] if requested_toppings: for requested_topping in requested_toppings: print("Adding "+ requested_topping) print("\n\tFinished making your pizza!") else: print("Are you sure you want a plain pizza?")
244ccff77fdb9b214a04334627cf12b67c4ff50b
lovisgod/TravisCI_With_Python
/work.py
301
4
4
def is_prime (number): if number in (0,1): return False if number < 0: return False """ return true if the *number* is prime""" for element in range(2, number): if number % element == 0: return False return True is_prime(5)
f6bcf54bacf17a73e0f1701aa68ea1e33db1f972
renan-lab/python-study
/part1/exercicios/aula13/ex7.py
653
3.90625
4
#num = int(input('Digite um número: ')) #div = 0 #for c in range(2, num): # if num % c == 0: # div += 1 # #if div > 0 or num == 1: # print('{} não é um número primo.'.format(num)) #else: # print('{} é um número primo.'.format(num)) #código melhorado: num = int(input('Digite um número: ')) div = 0 for c in rang...
d2fb92783986b0850745955c8a271706717f8b6d
mbyrd314/cryptopals
/set1_challenge7.py
1,613
3.609375
4
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend from Crypto.Cipher import AES from base64 import b64encode, b64decode def decrypt_aes_ecb1(ciphertext, key): """ Implementation of AES ECB mode decryption using the Python crypt...
8162e759a06dfe2f82be1edfe4b67e8addbbef42
krishnakpatel/Summer2017
/graphv5.py
5,262
3.640625
4
#add functionality: modifying values import matplotlib.pyplot as plt import networkx as nx import xml.etree.ElementTree as ET from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring # as soon as the program loads circ = nx.MultiDiGraph() node_num = 1 key = 0 def click(type): circ.add_node...
02b6d600fa101af2f04bd6b59e11fca1c18c8775
gerrycfchang/leetcode-python
/google/Abbr/valid_word_abbreviation.py
1,343
4
4
""" Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains only the following valid abbreviations: ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"] Notice t...
a72522154e3dba483f66be75baf4d2da023fa7a6
Engy-22/BaseballSync
/src/utilities/stringify_list.py
313
3.5625
4
def stringify_list(given_list): if len(given_list) > 1: low = str(given_list[0]) high = str(given_list[-1]) if len(given_list) != 2: return 's ' + low + '-' + high else: return 's ' + low + ' & ' + high else: return ' ' + str(given_list[0])
ca3cb64788663f8024317fd9fc0f08c7c627b422
programmingkids/python-level1
/chapter06/work10.py
91
3.53125
4
num = 10 if : print("5以上です") else : print("5より小さいです")
e2c9d337b566b8bb9334ae3959fadd56846b4b85
Xiaowei66/UNSW_COMP9021_S2
/assignment1_q4.py
3,501
3.796875
4
# import related functions import os.path import sys try: filename = input('Please enter the name of the file you want to get data from: ') if not os.path.exists(filename): print('Sorry, there is no such file.') sys.exit() except ValueError: print('Sorry, there is no such file. ') sy...
7b68a911b0858991b4e903ebb05e949fac93c0ba
thraddash/python_tut
/14_ojbect_oriented_programming/oop_golden.py
479
3.90625
4
#!/usr/bin/env python # Class # Global variable restaurant_name = '7 Eleven' restaurant_owner = 'Seven' def restaurant_details(): #function print(restaurant_name, restaurant_owner) def another_restaurant(): #local variable restaurant_address = 'Bogra' print(restaurant_name, restaurant_owner) print(res...
d8d3aa87552863e71e5c60e0ac6ad2eb819e2af6
roshanrobotics/python-program
/triangle.py
282
4.15625
4
a=float(input("Enter the first side: ")) b=float(input("Enter the second side: ")) c=float(input("Enter the third side: ")) if(a==b and a==c): print("Equilateral triangle") elif(a==b or a==c or b==c): print("Isosceles triangle") else: print("Scalene triangle")
c152330bc581d592d7f4bccd2a940bf95ebfc7a2
withinfinitedegreesoffreedom/datastructures-algorithms
/stacks-queues/stack_of_plates.py
1,844
3.84375
4
import unittest class SetOfStacks: def __init__(self,stack_capacity): self.stack_capacity = stack_capacity self.list = [] self.acting_stack = 1 def push(self, data): self.list.append(data) self.acting_stack = (self.length() // self.stack_capacity) + 1 return Tru...
2e5c76ea8a3b5c3fca75619d1761ef5c8bda693a
mathvolcano/leetcode
/0082_deleteDuplicates.py
1,001
3.5
4
""" 82. Remove Duplicates from Sorted List II https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplicates(self, head: ListNode) ->...
e28d1ee207e754bdd522165718622637424c2dd1
armstrong019/coding_n_project
/Jiuzhang_practice/subsets2.py
659
3.734375
4
class Solution: """ @param nums: A set of numbers @return: A list of lists. All valid subsets. """ def subsetsWithDup(self, nums): nums.sort() self.nums = nums self.res = [] self.dfs(0, []) return self.res def dfs(self, index, combination): if ...
2781caeb906a73e6dd3db0330d43409a0775d3bb
rifoolaw/techcamp-raspi
/PiCameraMenuTkS/pcmtks_exec.py
1,530
3.984375
4
print "Importing stuff..." import time import picamera import pcmtks print "done. Welcome to PiCamera Menu!\n\n" while True: print "Welcome to the PiCamera Menu! With this, you can take photos and more with your PiCamera!" print "To make it work, use the commands down here." print "PreviewIt: displays what ...
4256e77254d38cdca7e3402146b32e586ca7adad
ulyssesorz/data-structures
/tree/二叉平衡树AVL.py
6,893
4
4
class Queue: #用于层次遍历 def __init__(self): self.data = [] self.head = 0 self.tail = 0 def isEmpty(self): return self.head == self.tail def push(self,data): self.data.append(data) self.tail = self.tail + 1 def pop(self): temp = self.dat...
ad8378973c531ef5ac0d45afc90507ec09b20c45
kennycaiguo/Heima-Python-2018
/00-2017/基础班/设计蛋糕店类-工厂模式.py
726
3.9375
4
#coding=utf-8 class Cake(object): def __init__(self,taste="默认"): self.taste = taste class AppleCake(object): def __init__(self,taste="苹果味"): self.taste = taste class BananaCake(object): def __init__(self,taste="香蕉味"): self.taste = taste class CakeKitchen(object): def createCake(self, taste): if taste == "苹果...
d41f5482258ede8a2a517ebb5c153555825a2bc6
VerstraeteBert/algos-ds
/test/vraag4/src/isbn/168.py
1,412
3.515625
4
def isISBN_13(code): if type(code) is not str: return False if len(code) != 13: return False try: oneven = 0 i = 0 while i < 11: oneven += int(code[i]) i += 2 even = 0 i = 1 while i < 12: even += int(code[i])...
8699c0036e3bb634217d09f0f93ec6ab18fd7ea3
BohanHsu/developer
/python/classes/classInheritance.py
756
4.40625
4
# in this file we study inheritance in python #define the super class ClassA class ClassA: def doing(self): print('I\'m class A') class ClassB(ClassA): def doing(self): print('I\'m class B') class ClassC: def __init__(self,a): self.a = a def getA(self): return self.a class ClassD(ClassC): def _...
549c511ebc159d13b651c525560db6c9e0db9cd4
zcarc/algorithm
/Programmers/level1/소수 만들기_라이브러리.py
401
3.734375
4
import itertools def solution(nums): nums = list(itertools.combinations(nums, 3)) def is_prime(n): for i in range(2, int(n ** (1 / 2)) + 1): if n % i == 0: return False return True answer = 0 for e in nums: if is_prime(sum(e)): answer ...
a7c55eb5e0b255baa0cb69574914bfa59d348808
pedro-puerta/PYTHON-2021-01
/exemplos POO 3.py
799
3.640625
4
''' Criar uma classe Aluno - Atributos: ra, nome, email, lista de notas. - Métodos: inserir_nota, calcular_media ''' class Aluno: def __init__(self, ra, nome, email): # construtor # atributos self.ra = ra self.nome = nome self.email = email self.lista_no...
0f50cef78a3fce80dc1bff474a59ae2dc4942af8
jonathan-taylor/formula
/formula/sympy_utils.py
1,764
3.703125
4
import sympy def getparams(expression): """ Return the parameters of an expression that are not Term instances but are instances of sympy.Symbol. Examples -------- >>> x, y, z = [Term(l) for l in 'xyz'] >>> f = Formula([x,y,z]) >>> getparams(f) [] >>> f.mean _b0*x + _b1*y + _b...
45c9941345fe881d7ea0c55f1f2b0aada207b4a7
JGraff2821/JuniorDesign
/interviewQ3.py
1,257
4.21875
4
from random import uniform from typing import Tuple # Function gives a random coordinate within a circle of radius one. def random_coordinate() -> Tuple[float, float]: return uniform(0, 1), uniform(0, 1) def calculate_pi(number_of_points: int): # Variable to track in/out of circle. points_in_circle: int...
7ae7fb7bff259c14a2e51e4c819b6b5ea8636287
nicehiro/LeetCode
/divide.py
930
3.640625
4
class Solution: def divide(self, dividend: int, divisor: int) -> int: prefix = 1 if (dividend < 0 and divisor > 0) or\ (dividend > 0 and divisor < 0): prefix = -1 dividend = abs(dividend) divisor = abs(divisor) res = 0 while dividend >= divisor...