blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
75d3c17a9fa8df4762cc4836270ca6da70304b0b
olibrook/data-structures-algos-python
/pyalgos/data_structures/heap.py
2,307
3.59375
4
import collections Pair = collections.namedtuple('Pair', ['idx', 'v']) class MinHeap: def __init__(self): self.l = [] def __len__(self): return len(self.l) def __iter__(self): while len(self): yield self.pop() def item_at(self, idx): return 0 <= idx < ...
f49b3ec45e2dd8c2599d1e84a46defdedbebd25b
NeoWhiteHatA/all_my_python
/march/dr_huares.py
1,069
4.25
4
#Эта программа получает от пользователя оценки за контрольные работы #и показывает буквенный эквивалент успеваемости #нижеследующие константы представляют пороги уровней знаний A_SCORE = 90 B_SCORE = 80 C_SCORE = 70 D_SCORE = 60 #получить от пользователя оценку контрольной работы score = int(input('Введите свою оценк...
d5e27b681b7b4a6684c13094541a75ff4db9ef10
kzm1997/pythonDemo
/test/classOne.py
495
3.609375
4
class Person(object): def __init__(self,name,age): self._name=name self._age=age @property def name(self): return self._name @property def age(self): return self._gae @age.setter def age(self,age): self._age=age def play(self): if sel...
0904932b3a2ddc8589dc310a2e9a76c159d0cc74
bam6076/PythonEdX
/quiz3_part5.py
610
4.125
4
## Write a function that receives a positive integer as function ## parameter and returns True if the integer is a perfect number, ## False otherwise. A perfect number is a number whose sum of the ## all the divisors (excluding itself) is equal to itself. ## For example: divisors of 6 (excluding 6 are) : 1, 2, 3 and ##...
38c96698c7a34022dde7e1210387533c223ad672
wngus9056/Datascience
/Python&DataBase/5.13/Python04_09_strFun04_김주현.py
453
3.8125
4
a = " hi " print(a) print(a.lstrip()+'WOW') # ' hi '의 왼쪽 공백을 제거하고 'WOW'를 붙인다. print(a.rstrip()+'WOW') # ' hi '의 오른쪽 공백을 제거한다. print(a.strip()+'WOW') # ' hi '의 양쪽 공백을 제거한다. print('-'*15) b = 'Life is too short' print(b) change = b.replace('Life', 'Your leg') # change변수에 b변수에서 'Life'를 'Your leg'로 바꾼 값을 저장한다. ...
70a8a0a15b77a92f104ff7e72db220b923bf262c
im-jonhatan/hackerRankPython
/numpy/linearAlgebra.py
560
3.90625
4
# Task # You are given a square matrix A with dimensions NXN. Your task is to find the determinant. Note: Round the answer to 2 places after the decimal. # Input Format # The first line contains the integer N. # The next N lines contains the N space separated elements of array A. # Output Format # Print the determina...
222397bc318f79845d6fab4a8476575aea71dc21
ilkera/EPI
/Strings/StrStr/StrStr.py
1,136
4.09375
4
# Problem: Implement Strstr function # (Search for a substring and return the first occurence index) # Function def strStr(str, target): if not str or not target: return -1 if len(str) < len(target): return -1 current_str= 0 while current_str < len(str): if str[current_str] !...
ac40bbb61f30b25c190508a5c2b0b969dd29694f
jonik2909/Tkinter
/buttons.py
494
3.734375
4
from tkinter import * root = Tk() # Funsiyadan foydalanib chiqarish. bunda u buttonga command=berish kk. def myClick(): myLabel = Label(root, text="Look! I clicked") myLabel.pack() #Creating Buttons, # state=DISABLED (Bosilgan turadi), # padx=eni, pady=bo'yi # command buyrug'isiz ishmalaydi. () qoyilsa chi...
ff615b3266fa45d0017d31ebeb64b9e4a4b14945
bryan-lima/python-cursoemvideo
/mundo-03/ex104.py
531
4.21875
4
# Crie um programa que tenha a função leiaInt(), que vai funcionar de forma semelhante à função input() do Python, # só que fazendo a validação para aceitar apenas um valor numérico def readInt(msg): while True: value = str(input(msg)) if value.isnumeric(): value = int(value) ...
6fcc79568e883fd9657708880689a7f6d2b2edfb
nik45/ReplitOnline
/main.py
62
3.515625
4
print("Hello World!!") a = 5 n = 234 c = a + n * 0 print (c)
0906174006c16045d43b5f240d1a2614a87957fb
tmdgh98/replit
/ItsCote/Unit05 DFS,BFS/03재귀함수.py
136
3.828125
4
def recursive_function(i): if i>=10: return print(i,"번쨰 재귀함수") i+=1 recursive_function(i) recursive_function(1)
87e73847e235be7897172a8a7a91b1264e38a005
AgataWa/lab5
/bayes.py
6,243
3.609375
4
import csv import random import math def loadCsv(filename): lines = csv.reader(open(filename, "r")) dataset = list(lines) for i in range(len(dataset)): for x_i, x in enumerate(dataset[i]): dataset[i][x_i] = float(x) return dataset def testLoadCsv(): filename = 'pima-indians-d...
188404d180fdedddcf88c40f080ff3aff2f30682
haribalajihub/balaji
/rock,paper,scissor.py
372
3.546875
4
n,k=input().split() if(n=="R" and k=="P"): print("P") elif(n=="R" and k=="S"): print("R") elif(n=="S" and k=="P"): print("S") elif(n=="S" and k=="R"): print("R") elif(n=="P" and k=="R"): print("P") elif(n=="P" and k=="S"): print("S") elif(n=="S" and k=="S"): print("D") elif(n=="p" and k=="P"): ...
333d90ad08b5cc5bb4fb0f5553beb3aa17dd633f
cmoussa1/sqlite-examples
/py-sqlite/py_sqlite.py
3,303
3.765625
4
''' Python CLI utility/script to parse JSON object and store them in an SQLite database. Author: Christopher Moussa Date: September 10th, 2019 ''' import json import sqlite3 import pandas as pd print("*" * 50) print("\t\t PHASE 1") print("*" * 50) print("Description: Parse JSON file and read from dictionary") p...
542dd1d32912ae9624a68002ac2263be74cb1b67
gomsang/AlgorithmTraining
/acmicpcdotnet/10809.py
82
3.796875
4
str = input() for i in range(26): print(str.find(chr(ord('a') + i)), end=' ')
8b610007edef5073e395c8d56457a38f9588bb19
MihaiPopa01/The-Cornfield-Application1
/Algoritm2_Py/Algoritm2_Python/sort.py
497
3.640625
4
def partition(vector, left, right): i = (left - 1) pivot = vector[right] for j in range(left, right): if vector[j] <= pivot: i = i + 1 vector[i], vector[j] = vector[j], vector[i] vector[i + 1], vector[right] = vector[right], vector[i + 1] return (i + 1) def quick_...
508aa3f26868ef7b56edeab3370afa6b3979260e
ashraf-amgad/Python
/Python Basics/date time/date_time.py
794
4
4
# to get date and time from datetime import datetime, timedelta current_date = datetime.now() print('\n',current_date.day,'-', current_date.month, '-', current_date.year) print('current_date \t\t\t', current_date) current_date_mince_one_minute = current_date - timedelta(minutes=1) print('current_date_mince_one_mi...
438fcebc78ebda70c743b93f41b31141139de531
sosma/rekt
/rekt.py
2,500
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from random import choice from time import sleep different = "qwertyuiopasdfgjklzxcvbnm1234567890+!#¤%&/()=?<>|,;.:-_[]/QWERTYUIOPASDFGHJKLZXCVBNM " while(True): sleep(0.01) letter0 = choice(different) letter1 = choice(different) letter2 = choice(differen...
533598eea11f5eda9c058ce3ef21a37c64a30a86
SigitaD/python_mario
/more/mario.py
600
3.9375
4
from cs50 import get_int # apibreziama pagindine funkcija, kuri yra piesti piramide def main(): # paimamas piramides ausktis is f-cijos get_height n = get_height() for i in range(n): print(" " * (n-i-1), end="") print("#" * (i+1), end="") print(" ", end="") print("#" * (i...
ab88545ccc0b9393eb708bf009814d41de356c10
GotfrydFamilyEnterprise/PythonTraining
/GCF.py
808
3.953125
4
# Greatest Common Factor - the largest number that x and y are divisible by # ommit one from primes as it is goin to mess with our #MATH primes = [2,3,5,7,11,13,17,19] # x = 96 # /(2) => 48/(2) => 24/2 => 12/2 => 6/2 =>(3) # y = 84 # /(2) => 42/(2) => 21/(3) => 7 x = 3*3*5*5*7*7*13*17 y = 2*2*3*5*5*7*19 divisors = [] ...
eee12dc1af94842122b82a5d244dcb77c72fedda
kapteinstein/AlgDat
/div/quicksort.py
688
3.796875
4
def partition(A, lo, hi): pivot = A[lo] left = lo + 1 right = hi done = False while not done: while left <= right and A[left] <= pivot: left += 1 while left <= right and A[right] >= pivot: right -= 1 if left > right: done = True el...
b368d0e2b778978a33fabded7c4fbbb6e27c1b08
VicentePenaLet/RedesNeuronales
/DataLoader.py
4,109
3.875
4
import numpy as np from sklearn.model_selection import train_test_split class Dataset: """This Class defines a dataset and some key utilities for them""" def __init__(self,path, oneHot = False, norm = False ): """The constructor for this class receibes the path to a .csv file with the data :par...
1a4f72b1d46d7f140ce166fdb1105e302799483b
scottwat86/Automate_Boring_Stuff_
/ch2_flow_control/lesson05.py
1,079
4.28125
4
# Automate the Boring Stuff with Python 3 # Vid Lesson 5 - Flow Control # name = 'Alice' # name = 'Bob' # if name == 'Alice': # Starts the if block statement # print("Hi Alice") # Blocks are indented # else: # print('Bob') # print('Done!') # # password = 'swordfish' # if password == 'swordfish': # print('...
f5b3f1baac1501f47e3cb0506415951f6cf1893b
AlexLymar/itstep
/lesson12/only_odd_arguments.py
427
4.09375
4
def only_odd_arguments(func): def wrapper(*args): for i in func(*args): if i % 2: return func else: print('Please add odd numbers!') return wrapper @only_odd_arguments def add(a, b): print(a + b) return a, b add(3, 3) @only_odd_arguments ...
ba265bb9d96f3ceeec3b311c1c36ce36f9c18206
petitepirate/interviewQuestions
/q0028.py
4,685
4.03125
4
# This problem was asked by Palantir. # Write an algorithm to justify text. Given a sequence of words and an integer line length # k, return a list of strings which represents each line, fully justified. # More specifically, you should have as many words as possible in each line. There should # be at least one ...
307b11a20309f31bc0ff52f9c7913403730c5311
BPCao/Assignments
/WEEK 1/THURSDAY/todo.py
968
4.15625
4
choice = '' task_list = [] tasks = {} def menu(): print ("Press 1 to add task: ") print ("Press 2 to delete task: ") print ("Press 3 to view all tasks: ") print ("Press q to quit: ") def user_input1(): user_task = input("Please enter a task: ") user_priority = input("Please enter a priority: ...
ebdad76a640d112fc965f85ec12901769b76240b
shuowenwei/LeetCodePython
/Medium/LC1305.py
2,859
3.8125
4
# -*- coding: utf-8 -*- """ @author: Wei, Shuowen https://leetcode.com/problems/all-elements-in-two-binary-search-trees/ MG: https://www.1point3acres.com/bbs/thread-841626-1-1.html LC1305, LC173, LC21 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=...
563e412c2fed2eb708b57591b0b22fcf0a140cb1
hoju-os/comp-prob-solve
/ClassSeatingV2.py
3,258
4.28125
4
num = "" while num != 'E': print("1 - Find a student's name by entering a row and seat") print("2 - Find a student's row and seat by entering their name") print ("3 - Find all student's in a row by entering a row") print ("4 - Find all student's sitting in a seat across all rows by entering a seat") ...
9b88c929699d064b78799710e831aaa52246bf74
Nirali0029/Algorithms-in-python
/Algorithms/Searching/binary_search.py
276
3.515625
4
a=[3,54,74,6,88,99] key=(int)(input()) a.sort() n=len(a) low=0 high=n-1 mid=0 while(low<=high): mid=(low+high)//2 if a[mid]==key: print(str(key)+"found") break elif key<a[mid]: high=mid-1 elif key>a[mid]: low=mid+1 else: print(str(key)+" Not found")
e01a6745f3fe090c308d4e401d3d26b06978681b
jjennyko/python1
/hw_31.py
848
3.765625
4
#1. #女 #2. def bayes_theorem(p_a, p_b_given_a, p_b_given_not_a): # calculate P(not A) not_a = 1 - p_a # calculate P(B) p_b = p_b_given_a * p_a + p_b_given_not_a * not_a # calculate P(A|B) p_a_given_b = (p_b_given_a * p_a) / p_b return p_a_given_b # P(A): P(女生) # P(not A): P(男生) p_a = 0.1 # P(B...
9191773f87f9ecf49d1b50f30c2d38795ff1025c
nyp-sit/python
/functions/validator.py
273
3.859375
4
def is_number(string): try: float(string) except ValueError: return False else: return True def is_valid_phone(string): if len(string) == 8: if string[0] == '6' or string[0] == '9': return True return False
a03c8a55792d2b3e5432778da8659d031281e252
msitek/sql
/sqld.py
492
3.90625
4
# import from csv # import the csv library import csv import sqlite3 with sqlite3.connect("new.db") as connection: c = connection.cursor() # open the csv file and assign it to a variable employees = csv.reader(open("employees.csv", "rU")) # create a new table called employees c.executescript('''DROP TABLE IF ...
95b533a22375c58adab5c78f94508ec288905f9b
kkloberdanz/Opperating-Systems
/Assignment 1/assignment-1/Problem3/testmult.py
2,023
3.625
4
import random def sum_string(s): tot = 0 for letter in s: digit = int(letter) tot += digit return tot def sum_vector(v): tot = 0 for string in v: tot += int(string) return tot def mult_with_carry(op1, op2, carry, result): op1 = int(op1) op2 = int(op2) re...
a369359537df1b03ac7093b424582c997bed21c4
njiiri12/passwordlocker
/credentials.py
2,034
4.09375
4
class User: """ Class that generates new instances of users """ user_list =[] def __init__(self,first_name,last_name,password): self.first_name = first_name self.last_name = last_name self.password = password def save_user(self): ''' save_user method s...
7cb265ba2946b255560b3ba38c72a7cd7774f29f
ashiqcvcv/Datastructure
/tree_firstapproach.py
3,185
3.671875
4
class node: def __init__(self,key): self.left = None self.right = None self.value = key ''' 10 -> root / \ 5 15 / \ / \ 3 6 13 16 ''' #creating a tree from arr head = node(10) head.left = node(5) head.left.left = node(3) head.left.right = node(6) head.right = node(15) head.right.left = ...
0445968c798e213ec1180b7eeabc79954b897292
zhuyuedlut/advanced_programming
/chapter2/starts_ends_with_exp.py
912
3.8125
4
file_name = 'python.txt' print(file_name.endswith('.txt')) print(file_name.startswith('abc')) url_val = 'http://www.python.org' print(url_val.startswith('http:')) import os file_name_list = os.listdir('.') print(file_name_list) print([name for name in file_name_list if name.endswith(('.py', '.h')) ]) print(any(name...
df5d2017e907e6927efe8ece3cfa8374b6cff522
denizobi/aws-devops-workshop
/python/coding-challenges/cc-011-drawbox/mydrawbox.py
211
4.03125
4
hastag = int(input("Please enter the number")) if hastag == 1: print("#") else: print("#" * hastag) for i in range(hastag-2): print("#" + " " *(hastag-2) + "#") print("#" * hastag)
5d0be30d045c6668fd8784bfa627b303466e2c89
pedroceciliocn/python_work
/Chapter_5_if_statements/toppings_3.py
1,267
4.21875
4
#Checking for special items: requested_toppings = ['mushrooms', 'green peppers', 'extra cheese'] for requested_topping in requested_toppings: print(f"Adding {requested_topping}.") print("\nFinished making your pizza!") # but if the pizzeria runs out of green peppers? requested_toppings = ['mushrooms', 'green peppe...
de6cc09b3fb872fbee34d0016a7e3c3d79fe9940
MengSunS/daily-leetcode
/design/432.py
2,804
4
4
class Block: def __init__(self, val=0): self.val = val self.keys = set() self.before = None self.after = None def insert_after(self, new_block): tmp = self.after self.after = new_block new_block.before = self new_block.after = tmp...
c13ea6d47d1251808b9cd35efca5f65a6ede524d
pskim219/dojang
/ex0303.py
178
3.546875
4
# 코드 3-3 리스트를 만드는 코드 my_list1 = [] print(my_list1) my_list2 = [1, -2, 3.14] print(my_list2) my_list3 = ['앨리스', 10, [1.0, 1.2]] print(my_list3)
7231aaeea5e6fbf42c431d18ab516cd280cda804
jdgsmallwood/ProjectEuler
/project_euler_solutions/problem_25.py
264
3.640625
4
num_of_digits = 1000 index = 2 fnum = 1 fnum_prev = 1 storage = 0 while len(str(fnum))<num_of_digits: storage = fnum fnum = fnum_prev + fnum fnum_prev = storage index +=1 print(fnum) print('Index is %i' % index) # I think the answer is 4782.
7859312f80a3c46efc7a82d3d0e8ea3b6aab119b
ozgecangumusbas/I2DL-exercises
/exercise_04/exercise_code/networks/optimizer.py
1,182
3.59375
4
# Naive Optimizer using full batch gradient descent import os import pickle import numpy as np from exercise_code.networks.linear_model import * class Optimizer(object): def __init__(self, model, learning_rate=5e-5): self.model = model self.lr = learning_rate def step(self, dw): """ ...
9ca7fe11c4cd4a3dd454efe38c60c98d1a631579
vagaganova/homeworks
/hw04092020/HW2.py
292
3.5625
4
my_list = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123] new_list =[my_list[i+1] for i in range(len(my_list)-1) if my_list[i+1]>my_list[i]] print (list(new_list)) # my_list = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123] # new_list =[i*5 for i in my_list if i%3 == 0] # print (list(new_list))
bd26c0a39b147f1be82ff2dd802d55c6d1b03a1b
office1978/python
/konstant.py
381
3.546875
4
# -*- encoding: utf-8 -*- k = {"e":"2.718281828459045235360287471352", "pi":"3.1415926535897932384626433832795028841971"} d=input("Введите константу: ") d=d.lower() if d in k: t=int(input("Введите точность: ")) print ('%.*s' %((1+t+k[d].find(".")), k[d])) else: print ("Вы ошиблись. Попробуйте снова.") ...
80961f6272eacf308068d94c1c5ed9e579ca44dd
pwnmeow/Basic-Python-Exercise-Files
/ex/coinFlip.py
143
3.5
4
import random def coilflip (): coinValue = random.randint(0,1); if coinValue == 1: print("heads") else:print("tails") coilflip()
8316fc4567d4af9951faf51ede04a5568f2824ad
pauliwu/Introduction-to-programming-in-python
/Laboratory 13/answers/wdp_ftopt_l12z02r_B.py
1,100
3.640625
4
""" Wstep do programowania Kolokwium termin 0 9.01.2019 grupa P11-57j imie: nazwisko: indeks: """ ''' Zadanie 2 (15 pkt.) Przygotuj program, w którego zadaniem będzie wydrukowanie alfabetu w porządku malejącym (od z do a). Wykorzystaj informację, że w kodzie ASCI literom z-a odpowiadają liczby od 122 do 97. Sformatuj ...
04313bf78325ac255ec1db93e0ad26a435350e82
he44/Practice
/aoc_2019/24/24.py
3,055
3.703125
4
""" Formulation a scan of the entire area fits into a 5x5 grid (your puzzle input). The scan shows bugs (#) and empty spaces (.). each tile updated every minute, simultaneously (counting for all first, then changing) Maybe need some bit operation: 25-bit number This way, it's easy to check if two layours are the sam...
adb8bc099f0140000ca5bf9ae4dbb898d6c6c57e
Guzinanda/Interview-Training-Microsoft
/03 Data Structures/Linked Lists/linked_list.py
3,323
3.96875
4
""" Linked List (Singly Linked List) HEAD NODE [A | ] -> [B|] -> [C|] -> [D|] -> NULL DATA NEXT """ class Node: def __init__(self, data): # Constructor self.data = data self.next = None class LinkedList: def __init__(self): # Constructor self.he...
73b07c83ccae53743e87f04e500c221c7cf3eae7
linux740305/git-test
/git-test/3-13變量的類型-以及變量的轉換.py
266
3.6875
4
age = input("請輸入年齡")#input輸入年齡 age_num = int(age)#....>整形....去除雙引號之後的值20 if age_num>18:#if 條件:如果年齡大於如果年齡大於18便可進入網咖用if來判斷是否已滿18 print("已成年可以去網咖囉!")
090006de77e98890dc5b76a18ee8f010027d8f80
axg1/Algorithm_Study
/CodeUp/CodeUp_6079.py
80
3.578125
4
a = int(input()) sum = 0 b = 0 while sum<a: b += 1 sum += b print(b)
6f0c0d0b1e159674153b43b36f4920961deb4b26
wazcov/devscover-youtube
/learning_python/unit_testing/pymain.py
544
3.625
4
#! /usr/local/bin/python3 def textStuff(): initdata = ['picard', 'kirk', 'Picard', 'archer', 'janeway', 'picard', 'archer'] mr = {} for word in initdata: word = word.upper() if (word in mr): mr[word] += 1 else: mr[word] = 1 print(mr) print('----') ...
c46851da30843c6e92d53e84490e7de7cb3166d2
imji0319/myProject
/pro1/test1/test1_4.py
357
3.8125
4
''' Created on 2017. 9. 17. @author: jihye ''' #문자 회문(palindrome) 찾기 #-*- coding:utf-8 -*- user_str=input('글자를 입력하시오 :') str_len=len(user_str) for i in range(0,str_len-1): if user_str[i]==user_str[str_len-1+i]: print('palindrome') else : print('not a palindrome') ...
fc43f83d8f5283559289816c22cfab7a41604b37
mbyrd314/cryptopals
/set2_challenge13.py
6,482
3.53125
4
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend from base64 import b64encode, b64decode import os, random, string def parse_cookie(cookie): """ Takes inputs in the form of 'foo=bar&baz=qux' and converts them into a dictionar...
11db707184923941bad481e3b14aa2b4d1d9dd32
Thilagaa22/python-codes
/33.py
79
3.5625
4
a = int() count = 0 for i in a: if (i == ""): count +=1 print(count)
d9f89bb79d0e41d2ef7776f47297d00c872105eb
tonyxiahua/CIS-40-Python
/Labs/Lab2.py
2,879
4.53125
5
''' 1. Write a function named powers that has one parameter named num. This function should always produce 11 lines of output, one for the parameter raised to the 0th power through one for the parameter raised to the 10th power. Show both your function definition and three calls of the function, along with the output ...
4505f3fe72193464c4fe2e0e5374b5a9c41d9d44
cqq03/edu_python
/data04/클래스만들기/트럭.py
578
3.859375
4
class Truck: #클래스: 멤버변수(인스턴스변수)+멤버함수 weight = None company = None def move(self): print(self.weight, '의 짐을 실어나르다.') def own(self): print(self.company, '회사 소속의 트럭입니다.') def __str__(self): return str(self.weight) + ', ' + str(self.company) if __name__ == '__main__': tr...
fea2a2c33607e5efa1372f2addd7fceaed4dd529
ehbaker/WXmunge
/LVL1.py
29,526
3.546875
4
''' LVL1 WX Cleaning Functions ''' import numpy as np import pandas as pd import matplotlib.pyplot as plt def remove_malfunctioning_sensor_data(dat, bad_sensor_dates_dat): ''' Function to set bad sensor data to NAN, during specified timeframes. Returns dataframe with NANs in place, and switched valu...
dd00c8b9af5e888b729c73c36526977d389712d2
woojay/100-days-of-code
/46/game_of_life.py
9,087
3.890625
4
''' Game of Life CLI version by wp 6/13/18 Objective: You'll implement Conway's Game of Life (https://en.wikipedia.org/wiki/Conway's_Game_of_Life) as a CLI tool. Criteria: Conway's Game of Life is displayed in the terminal. Conway's Game of Life plays indefinitely until a user termina...
ef1520b4209a98fa42bd663bfe526368c36f26c3
zuohd/python-excise
/regexpression/multipleCharacters.py
675
3.796875
4
import re r''' (xyz) match "xyz" as the whole part x? match zero or one x x* match any number x x+ match at least one x x{n} match n number x x{n,} match at least n number x x{n,m} match at least n number and max number is m (n<=m) x|y match x or y ''' print(re.findall(r"(soderberg)","soderbergberg is soderberg...
4f5027e3f93050d0bb8b538c15be78f472a03e2a
sebnapo/Python
/TP2/championnat.py
456
3.5625
4
def championnat(N,J,M): if(N%2 == 0): N1 = N else: N1 = N+1 print("Il y aura" + str(N1-1) + "jours de championnat et " + str(N1/2) + " match par jour") if(M == 1): if(N%2 == 0): domicile = N1 if(M > 1): domicile = ((J + M-2)%(N1 - 1)) + 1 deplacement = (((J - M +N1 -1...
d1ca146064cb498b3e3158ee8e04a7fe0636467d
vasanth8455/python27
/sample.py
365
3.609375
4
''' def vasanth(x,y): return x*y,x+y,x%y print vasanth(11,20) #local variable def get(x=10,y=30): return x+y,x*y,x%y print get() #global variable x = 'sekhar' y = 'reddy' def sam(): global x,y x=30 return x+y print sam() ''' #revers of the string s=raw_input('Enter your stirng :'...
6dfffea67ad4a7e06ff1a33392314090fba5bed1
aguscoppe/ejercicios-python
/TP_6_Listas/TP6_EJ12.py
1,619
3.625
4
def leerLista(): n = int(input("Ingrese un número para agregar a la lista o -1 para finalizar: ")) lista = [] while n != -1: lista.append(n) n = int(input("Ingrese un número para agregar a la lista o -1 para finalizar: ")) return lista def calcularProducto(lista): producto = 1 s...
11d929178bcde78efaf29a07dbb0fbdbf46507aa
Mayank-141-Shaw/Python-Repo
/Upload/miniMaxSum.py
543
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 9 12:09:04 2020 @author: MAYANK SHAW """ import sys def miniMaxSum(arr): ct = 0 maxval,minval,maxsum,minsum = 0,sys.maxsize,0,0 while ct != len(arr): for i in range(len(arr)): if i != ct: maxsum += arr[i] ...
c00ca104df59635b5b6ed81e0f6192cb10019421
codewithmodi/Python_Projects
/P0002.py
254
4.125
4
name = input("Enter your name ") age = input("What is your age " + name + "? ") print(name + " your age is " + age) # print(age) if int(age) >= 18: print("you are valid to Vote") else: print("Please comeback in {0} years".format(18 - int(age)))
42ecf77e90630734e195eb2025fafeacf0ae5478
ioannaili/Python-projects
/ergasies/maxsub.py
735
4.1875
4
""" This is a function called maxSequence that takes a list as input and returns the sublist (consecutive items in the list) that has the maximum sum. Example: maxSequence ([- 2, 1, -3, 4, -1, 2, 1, -5, 4]) returns 6: [4, -1, 2, 1] """ def maxSequence(a,size): max_s = 0 max_e = 0 ...
bcdf24aff9fd94b9e49f14175ede5dd11e78751f
Asr1aan/hw3
/hw3.py
2,180
3.53125
4
# Salaries # num_1 = int(input()) # num_2 = int(input()) # num_3 = int(input()) # l = [num_1, num_2, num_3] # print(max(l) - min(l)) # Boring number # num = set(input()) # if len(num) == 1: # print("Boring") # else: # print("Interesting") # Largest Number # num = int(input()) # lst = [] # whi...
f55083b2c2a9e36ecccf91c0b08615df739427e6
DanielCastelo/Manipulacao-de-Strings
/regex.py
770
3.6875
4
import re #re é a biblioteca que lida com expressões regulares email1 = "Meu número é 9848-3865" email2 = "o em 99848-3865 fale comigesse é meu número" email3 = "9948-3865 é o meu celulare" email4 = "afhshfshf 99845-3596 ajfjhfhsd 48579-2585 ahfhafjhdhfj 85595-8957" #padrao = "[0-9][0-9][0-9][0-9][-][0-9][0-9]...
88ce7043a1bff459c3bdfc504d3ab9acedf040b8
ithaquaKr/MLBasic
/MLBasic/exercise1.py
304
3.875
4
def evenDigitsNumber(arr): result = 0 for a in arr: count = 0 mark = a while mark > 0: mark /= 10 count += 1 if count % 2 == 0: result += 1 return result arr = [12,345,2,6,7869] print(evenDigitsNumber(arr))
be85aa3aed6add562b5298ecac3c492088ba48fa
mayamessinger/LinguisticDB-database
/dbLoadFiles/sequences.py
4,163
3.5
4
# -*- coding: utf-8 -*- """ @author: Ryan Piersma """ from nltk.tokenize import RegexpTokenizer import os, fnmatch #Some code from: #https://stackoverflow.com/questions/15547409/how-to-get-rid-of-punctuation-using-nltk-tokenizer #data structure for holding sequences: # Dictionary where key = a word, value = a pair ...
7625b2c42de5d225f78ae060c0a427e3dedb6624
xiashiwendao/leecode
/leecode/785_is-graph-bipartite.py
1,496
3.515625
4
class Solution(object): def isBipartite(self, graph): # 节点着色记录 color = {} # 遍历图节点,注意图在这里是通过二维数组形式进行存储 # 数组的索引代表了节点索引,数组索引所对应元素(N个数) # 代表了和这个节点有连线关系的节点(索引) for node in range(len(graph)): print(node) # 如果当前节点并没有着过色,设置初始化颜色(0),放入堆栈中,这里有一个堆栈对象 ...
20c4e6a9e5e00328c9d6e473c56471e5c669d002
rohanhg91/017-sort-dict-by-value
/build.py
572
3.796875
4
import operator def solution_asc(dic): ''' Enter your code here ''' op = [] for i in range (0, len(dic)): for k, v in dic.iteritems(): output = (k,v) op.append(output) return op def solution_desc(dic): ''' Enter your code here ''' op = [] ...
059453aee1f86bac6a39301f15b24348ac223986
Allegheny-Computer-Science-102-F2020/cs102-F2020-slides
/src/finiteset-operations.py
258
3.75
4
from sympy import FiniteSet set_one = FiniteSet(1, 2, 3) set_two = FiniteSet(1, 2, 3, 4) union = set_one.union(set_two) print("Union:") print(union) print() intersection = set_one.intersection(set_two) print("Intersection:") print(intersection) print()
92095818bba09a2b68fa3f0f341b99115703e13f
lfeng99/Competitive-Programming
/General/3n+1.py
118
3.71875
4
n=int(input()) num=0 while n!=1: if n%2==0: n=n/2 elif n%2==1: n=n*3+1 num+=1 print(num)
6e66884b1d166bd55554b094574bb1680dbb18f0
AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges
/Challenges/braceExpansion.py
1,298
4.375
4
""" Brace Expansion A string S represents a list of words. Each letter in the word has 1 or more options. If there is one option, the letter is represented as is. If there is more than one option, then curly braces delimit the options. For example, "{a,b,c}" represents options ["a", "b", "c"]. For example, "{a,b,...
e7dde24b28f5aa61f2facc90459f3a3e0fe75428
mdhvkothari/Python-Program
/data structure/search_in_binary_tree.py
1,168
3.984375
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None def insert(self,data): if self.data: if self.data>data: if self.left is None: self.left = Node(data) else: ...
d33cdf99116c4283275163a99668591fdca0f630
nkhanhng/nkhanh
/chaper3/month.py
117
3.875
4
month = ["January", "Febr", "March", "April","May"] for i in month: print("One of the months of the year is", i)
5ffe8f8e7fc80e893109ffbffcd2e6f2eaffdaea
karimm25/Karim
/TSIS 2/Lecture6/14.py
178
3.859375
4
# check whether a string is a pangram or not import string, sys def pan(str_): alphaset = set(string.ascii_lowercase) return alphaset <= set(str_) print(pan(input()))
27b656e17b4bb1531e0c5dd9fa0519841eb27f12
DiegoDenzer/exercicios
/src/diversos/funcoes_uteis.py
116
3.53125
4
lista = [1, 2, 3, 0, 2, 1] print(all(lista)) # Todos devem ser true print(any(lista)) # Se um elemento ser True
28b0889a729769b7450fb81d44f19d5a899ccc7b
xiaoyeren/python_high_performance
/JIT_tools/jit_custom_class.py
2,236
3.6875
4
# -*- coding: utf-8 -*- ''' Created on 2019年5月2日 下午7:28:23 Zhukun Luo Jiangxi University of Finance and Economics ''' #JI类 #自定义Node类 import numba as nb class Node: def __init__(self,value): self.next=None self.value=value class LinkedList:#实现链表 def __init__(self): self.head=None def ...
367ca4ec225aaffffa19ad38df191fa5e56c7cd4
SnyderMbishai/Numpy
/concatenation_splitting.py
1,007
3.5
4
import numpy as np # Concatenate two arrays a = np.array([1,2,3]) b = np.array([3,2,1]) np.concatenate([a,b]) print(np.concatenate([a,b])) # Concatenate more than two arrays c = np.array([7,7,7]) print(np.concatenate([a,b,c])) # Multi-dimensional grid = np.array([ [1,2,3], [4,5,6] ]) print(grid) np.conc...
32859640cad6333470d8437b85e6290cef7c8b51
pu-ray/python
/basic ,,,quiz.py
2,263
3.609375
4
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> print("Twinkle, twinkle, little star\n\t How i wonder what you are!\n\t\t Up above the world is so high \n\t\t Like a diamond in the sky\n Twinkl...
0f0a61f12c274b5a2753f8afd5d52957b436463c
corvolino/estudo-de-python
/Atividades-Estrutura-De-Decisao/atividade08.py
615
4.25
4
''' Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar, sabendo que a decisão é sempre pelo mais barato. ''' produto1 = float(input("Informe valor do Primeiro produto: ")) produto2 = float(input("Informe valor do Segundo produto: ")) produto3 = float(input("Informe valor do...
a446f4efc4fb2eb26530f11d8ccc685118d8e78c
SharonFei/python
/test_filter.py
99
3.546875
4
def _odd_iter(): #从3开始的奇数序列 n=1 while True: n=n+2 yield n
8031414f08d7fbc1142eeb6c7c94afeeebccbbbd
knoppanthony/advent-2020
/7/7.py
1,190
3.625
4
import networkx as nx def main(): input = open("input", "r") luggage_list = input.read().splitlines() partOne(luggage_list) def partOne(luggage_list): G = nx.DiGraph() for luggage in luggage_list: #get the bag and a string of the contains bag,contains = luggage.strip().rstrip...
aac69b675143abef640c691ecbf8c52d0d66ebbd
2099454967/wbx
/03day/3-老王开枪/7-子弹杀人.py
1,837
3.65625
4
#人类 class Person(): def __init__(self,name): self.name = name self.gun = None #默认没有枪 self.hp = 100 #默认有100滴血 def zhuangzidan(self,danjia,bullet):#装子弹 danjia.addBullet(bullet) def zhuangdanjia(self,gun,danjia):#装弹夹 gun.addDanJia(danjia) def takeGun(self,gun):#老王拿枪 self.gun = gun def openGun(self,d...
783cf69b2b7e26105582e53163c5dfa915c239e1
xaviBlue/curso_python
/conditionals.py
471
3.9375
4
x=10 if x < 30 : print("x es menor que 30") else: print("x es mayor que 20") color ='blue' if color=='red': print('El color es rojo') elif color == 'blue': print('The color is blue') else: print('es mi color') name = 'Xavier' lastame='Arcia' if name=='Xavier': if lastame=='Arcia': p...
746b2e91ae2650b115321be199a0470e16b78f39
BarrySunderland/code_snippets
/load_csv_as_np_array.py
586
3.5
4
def load_csv_as_array(fpath, datatype=np.int0, skip_header=True): """ load a csv file and return as a numpy array faster than loading using pandas but all cols must be same datatype skips first row by default """ with open(fpath,'r') as dest_f: data_reader = csv.reader(dest_f, ...
333ef316794c7fec0c21daad0d18a16289f0b925
Eltotino/holbertonschool-higher_level_programming
/0x06-python-classes/5-square.py
1,482
4.625
5
#!/usr/bin/python3 """Square class with size""" class Square(): """Square defines the square of a given value Attributes: size: size of the square """ def __init__(self, size=0): """ Init method is a constructor for Square class Args: size (int): t...
410437c2fd94b67fdf2b1147fc2bcd38dcc7d002
AniketGurav/PyTorch-learning
/Official/Getting_Started/A_60_Minute_Blitz/PyTorch_getstarted_1_60minBlitz_3_NeuralNetwork.py
3,972
3.75
4
""" Title: PyTorch/ Get Started/ a 60-min Blitz/ Neural Network Main Author: PyTorch Editor: Shengjie Xiu Time: 2019/3/20 Purpose: PyTorch learning Environment: python3.5.6 pytorch1.0.1 cuda9.0 """ import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim # 1.Define the network # ...
6dcb47bff6308b00c9b2c9db200d3d2a495095fd
Maxence-Labesse/AutoMxL
/build/lib/AutoMxL/Preprocessing/Outliers.py
11,249
3.515625
4
""" Outliers handling functions - OutliersEncoding (class) : identify and replace outliers - get_cat_outliers (funct): identify categorical features containing outliers - get_num_outliers (func): identify numerical features containing outliers - replace_category (func): replace categories of a categorical variable...
6f7e40a56336b882d6f0df2667af83041edfa598
peterlevi/euler
/066.py
799
3.765625
4
#!/usr/bin/python3 # Pell's equation x^2 - Dy^2 = 1 # Solution is given by some hi, ki, where hi/ki are the convergents of the continued fraction for sqrt(D) import math def nextFrac(a, b, c): x = math.sqrt(a) d = math.floor((x + b) / c) b1 = d*c - b c1 = (a - b1**2) / c return (d, a, b1, c1) de...
bfecd012728cc9ff1296d0ba19a6508f2326958e
GabrielNew/Python3-Basics
/World 1/ex003.py
343
4.21875
4
# -*- coding: utf-8 -*- #ex003 -> Crie um programa que leia dois valores e mostre a soma entre eles. num1 = int(input('Digite um número: ')) num2 = int(input('Digite outro número: ')) soma = num1 + num2 print(f'A soma entre {num1} e {num2} é {soma}') # print(f'A soma entre {num1} e {num2} é {num1+num2}') Sem utiliza...
e64c12df13f43383892f8d584030da638c997a9c
carlypalicz/Twitter-Search
/twitter_data.py
4,649
3.609375
4
# Author: Carly Palicz # I pledge my honor that I have abided by the Stevens Honor System # twitter_data.py searches Twitter for tweets matching a search term, # up to a maximun number, and sorts them in order of date posted ###### user must supply authentication keys where indicated # to run from terminal ...
dbdc0f29bd7a6c8f1f9a80e871e9abb447857568
Joe2357/Baekjoon
/Python/Code/2900/2908 - 상수.py
209
3.65625
4
a, b = input().split() for i in range(2, -1, -1): if a[i] > b[i]: for j in range(2, -1, -1): print(a[j], end = "") break elif a[i] < b[i]: for j in range(2, -1, -1): print(b[j], end = "") break
7b813071498ef79396b24eac3c4f9304bb0c3ec6
a2606844292/vs-code
/test2/列表/1.py
1,234
4.09375
4
#列表索引 A_list_of_things=['Hello',1,2,3,4,0,5.0,6.0,True,False] #找到列表中索引值为0的值 print(A_list_of_things[0]) #找到倒数最后一个,从-1开始 print(A_list_of_things[-1]) print(len(A_list_of_things)) print(A_list_of_things[len(A_list_of_things)-1]) #列表切片 #从1开始切到2结束 print(A_list_of_things[1:3]) #从1开始切到3结束 print(A_list_of_things[1...
aefe651205ac1c8ac71b3e1490886ee56e59c4ea
saetar/pyEuler
/done/py/euler_102.py
1,253
4.125
4
# !/usr/bin/env python # -*- coding: utf-8 -*- # Jesse Rubin - project Euler """ Triangle containment Problem 102 Three distinct from_points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed. Consider the following two triangles: A(-340,495), B(-153,-910), C(835...
130a534c86a1726c411c3de1c6df5ce11a87aae9
rafaelperazzo/programacao-web
/moodledata/vpl_data/480/usersdata/311/111140/submittedfiles/Av2_Parte2.py
114
3.96875
4
# -*- coding: utf-8 -*- a=int(input('Digite o numero: ')) c=0 while a>0 : c=c+(a%10) a=a//10 print(c)
96103fc6765e633a6b4046f8b2091edd7d805e0d
f1uk3r/Daily-Programmer
/Problem-12/Easy/string-permutations.py
517
4.4375
4
# python 3 # string-permutation.py # take a string and returns all the permutation # Write a small program that can take a string: "hi!" # and print all the possible permutations of the string: from itertools import permutations import sys if __name__ == '__main__': if len(sys.argv) > 1: string_to_permutation ...
163291585f47743ab15baaefcfccd9b02e71f1df
gitoffdabus/inf1340_2015_asst1
/exercise1.py
1,295
3.796875
4
#!/usr/bin/env python """ Assignment 1, Exercise 1, INF1340, Fall, 2014. Grade to gpa conversion This module prints the amount of money that Lakshmi has remaining after the stock transactions """ __author__ = 'Susan Sim' __email__ = "ses@drsusansim.org" __copyright__ = "2015 Susan Sim" __license__ = "MIT License" ...
9c55a22ed6b935f9e3c7aa987c2a348824c1150d
robbyakakom/20191
/dataengineering_si_2/prg_09.py
342
3.84375
4
isi = "YA" total = 0 while isi == "YA" : kode = input("Kode Barang : ") nama = input("Nama Barang : ") harga = int(input("Harga Beli : ")) total = total + harga print("----------------------------------") isi = input("Isi data lagi? (YA/TIDAK) ") print("----------------------------------") print("Tot...