blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0591fd5c94b4f7f0637d2f175c8c4fcda0d8c82c
ostapstephan/codeB
/src/traceMap.py
1,032
3.671875
4
# keep track of all mines and wormholes import globals def traceMap(mines, wormholes): #input bomb mine and wormhole locations from our scan for i in range(len(mines)): #check if already in list with proper name if mines[i] in globals.KNOWN_MINE_LOC: #the mine is in the global list ...
c3375948009b909d397b760a8ae25fe9c762a7fe
ricky-J-Li/Concordia-Course
/COMP472/Comp472-Assignment2/output_writer.py
2,325
4.125
4
class OutputWriter: """ This class is responsible for writing to the output files for a particular algorithm and heuristic. For example, the SOLUTION output for the first "Greedy Best First Search" algorithm, using heuristic 1, should output to the following path: "outputs/solutions/0_gbfs-h1_solution.t...
c0553a334f83cfcf82fcefcc8f6fa95e2124a86d
Harveyj7/pythontextgame
/game_project.py
6,733
3.890625
4
# SPACE PYTHON import random balance=100 def startgame(): Start_Game = input ("Would you like to Start Game? ") if Start_Game[0].lower() == "y": print ("Great") greet() elif Start_Game[0][0].lower() == "n": endgame() else: print("Please write yes or no")...
3aecd4a120f9abae11ec03209b3a1bb517bef1c2
effyhuihui/leetcode
/linkedList/reverseNodesInKGroups.py
3,336
4.0625
4
__author__ = 'effy' ''' Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in the nodes, only nodes itself may be changed. Only constant mem...
fae64b2c9cec3d6c73794ee3860fd17dc753db12
RenatoCPortella/estruturasRepeticao
/ex8.py
167
4.09375
4
num1 = 0 for i in range(5): num = int(input('Digite um número: ')) num1 += num media = num1/5 print(f'A soma dos 5 números é {num1} e a média é {media}')
89034085518550bbcf7dfe01336c30edd8801262
cdgrundy/science-fair-2019
/triangle.py
864
4.03125
4
from common import Quit_Exception, ready_to_quit def triangulate(): base=None height=None print('Je peut calculer l\'aire d\'une triangle pour toi') while not isinstance(base,float): try: base=input('\nc\'est quoi vos base') base=float(base) except Value...
0f623d2b12596799b5091ed69cf62e742a8cc462
Aasthaengg/IBMdataset
/Python_codes/p02594/s319483478.py
67
3.5625
4
data = int(input()) if data>=30: print("Yes") else: print("No")
ef85ac016ce6443f8595387fb44d96cfa9a751f7
kafkalm/LeetCode
/LeetCode/57.py
1,752
3.71875
4
#!/usr/bin/env python # encoding: utf-8 ''' @author: kafkal @contact: 1051748335@qq.com @software: pycharm @file: 57.py @time: 2019/2/15 015 10:36 @desc: 给出一个无重叠的 ,按照区间起始端点排序的区间列表。 在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。 示例 1: 输入: intervals = [[1,3],[6,9]], newInterval = [2,5] 输出: [[1,5],[6,9]] 示例 2: 输入: ...
860fbec606a06940f61adee4815461411adc7924
Davinism/python-recursion_exercises
/exponent.py
489
4.15625
4
import pdb; def exponent(base, power): if power <= 0: return 1 return base * exponent(base, power - 1) def main(): print "2^0: %d" % (exponent(2, 0)) print "2^1: %d" % (exponent(2, 1)) print "2^2: %d" % (exponent(2, 2)) print "2^3: %d" % (exponent(2, 3)) print "3^1: %d" % (exponent(3, 1))...
a6b7e0d80a3e92266cddfa4ac23846bb42856d86
azimsyafiq/Mini_Projects_Python
/dice_roll.py
839
3.859375
4
import random import time start_roll = input("Do you want to roll the dice? ").lower() while start_roll in ('y', 'ye', 'yes'): if start_roll in ('y', 'ye', 'yes'): roll_result = random.randint(0,6) print("Throwing the dice...") print("rolling...") time.sleep(0.5) ...
9617a580441c6785e837d8edfe9b8331173963eb
plammfish/HackBulgaria-Programming101
/week0/is_int_palindrome/solution.py
232
3.875
4
def is_int_palindrome(n): n = abs(n) return n == reverse(n) def reverse(n): result = 0 n = abs(n) while n != 0: work = n % 10 result = result*10 + work n = n // 10 return result if __name__ == '__main__': main()
b2aa7803fa0c2b1a88e1a71ee8ceec0ff6a04d2f
charlottetan/Algorithms-2
/Recursion/get_nth_fib.py
493
3.640625
4
#recursive solution def get_nth_fib(n, memoize = {1: 0, 2: 1}): if n in memoize: return memoize[n] else: memoize[n] = get_nth_fib(n - 1) + get_nth_fib(n - 2) return memoize[n] # iterative solution def get_nth_fib_1(n): last_two = [0, 1] counter = 3 while counter <= n: ...
56b6f93bfe8749890982f6fb8f82754f2a4d2bef
janiszewskibartlomiej/Python_mid-course
/resorces_for_app/12-14/Main.py
503
3.515625
4
#I sposób - dziesięć dziesiątek lista = [] for i in range(10): lista.append(10) print(lista) #II sposób lista2 = [10]*10 print(lista2) napis = "abc" * 7 print(napis) #III sposób - Wyrażenia listowe lista3 = [10 for i in range(10)] print(lista3) #lista = [wyrażenie for element in kolekcja] lista4 = [litera for ...
ed5ec050b1e57fd8cd3d06e70696556fea639aa9
JJongminPark/project_decision_tree
/dt.py
1,402
3.546875
4
#dt.py import sys import pprint class sample(dict): def __init__(self, data): super().__init__(data) def parse_data(file_name): ''' This function reads a file and parses data finally, return a list: [{attribute:value, a:v, ...}, {a:v, ...}, {a:v, ...}, ...] The operation is: ...
a2e01e388712bd3cedceca43db39d9e3013a23f4
yaraleo/100daypython
/lpthw/ex33.py
171
3.75
4
def make_numbers(n, m): numbers = [] for i in range(0,20,2): numbers.append(i) print numbers make_numbers(50, 2) #for i in numbers: # print i
afcd9dc0d051cedfe1923d240f3e69d463054564
Hamng/hamnguyen-sources
/python/LeetCode/unique_sort_in_place.py
4,402
3.875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 14 08:53:27 2021 @author: Ham LeetCode #26. Remove Duplicates from Sorted Array Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra space for another array, you...
69ef24c94cf0993ecf99a61f0a7f7df0a253a2fb
D0SA2019/Learn_Code_Study_Notes
/CodeCademy/Python/Notes/6_Student_Becomes_The_Teacher.py
1,674
3.9375
4
print("") print("------ 6. Student Becomes The Teacher ------") print("") print("------ EXAMPLE CODES ------") print("------ 6.1. Lesson Number One ------") animal = { "name": "Mr. Fluffles", "sounds": ["meow", "purr"] } print(animal["name"]) print("") print("------ 6.4. For The Record ------") animal_sounds = { ...
35014ee8fc59a23520ff09ccfbbb2c7820c4d0ac
xiangshaojun/pythonProject1
/006 继承/01 继承基础.py
208
3.5625
4
# 继承:继承父类的属性和方法 class A(object): def __init__(self): self.num = 1 def info_print(self): print(self.num) class B(A): pass test = B() test.info_print()
1de23434dff1c69ad75f50925721ee17984b3b0f
wils0n/runtime-decorator
/lib/RunTime.py
670
3.8125
4
# -*- coding: utf-8 *-* import time class Time: def __init__(self, a): self.a = a self.__ini = 0.0 self.__fin = 0.0 def __call__(self, *args, **kwargs): print ".......iniciando el analisis" self.__iniciar() self.a(*args, **kwargs) self.__finalizar() ...
d766ac31084fc7a6bc4b16e2226d614b540146b5
vikrant1998/Python-World
/Tree/N-ary_MaxDepth.py
704
3.65625
4
# Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children class Solution(object): def maxDepth(self, root): return self._maxDepth(root) def _maxDepth(self, root): if root == None or root.children == No...
bec3ff907cbbe2a38047ba4ada9ae6d1b4578853
nicktaylor20/Intro_to_Programming
/templist.py
536
4.375
4
#DSC510 #Assignment6.1 #Dominick Taylor #1/22/2021 #This program will allow users to enter temps and using list, report back information temperature = [] while True: inp = input(" Please enter a temperatures. Type done when finished. ") if inp == 'done': break values = int(inp) te...
f0177fbd0e3300466775794c4ef45cde9b2cc5e0
brainmentorspvtltd/PythonML_VIPS
/PythonLoop.py
141
3.609375
4
for i in range(20): print("Value of i is",i) print("Inside Loop") print("Outside Loop") print("I also want to get printed")
e7b317ae92ad5c74b7b3e45df8894d732582559c
JoeshGichon/News-App
/tests/news_source_test.py
562
3.53125
4
import unittest from app.models import News_Source class NewsSourceTest: ''' Test Class to test the behaviour of the News_Source class ''' def setUp(self): ''' Set up method that will run before every Test ''' self.newsSource = News_Source("abc-news","ABC News","our trus...
94f24e5770a672e8f608b80260ae28944bdcc6f8
edwardmasih/Python-School-Level
/Class 11/11th Project/Assignment By Edward/Que 13.py
456
4.125
4
# To calculate the sum of a particular series print("To calculate the sum of (x)-(x^3)/(3!)+(x^5)/(5!)-(x^7)/(7!).......upto n terms : ") x=int(input("Enter the value of x : ")) n=int(input("Enter the value of number of terms : " )) s=0 fact=1 for i in range(1,n+1,1): fact=fact*(i*2-1) if i%2!=0: ...
a8a0e1e20f0e469061233e00da8ec87f86a3307c
tomxland/advent-of-code
/2015/DAY_19/PART_01.py
1,010
3.671875
4
import re string = "CRnCaSiRnBSiRnFArTiBPTiTiBFArPBCaSiThSiRnTiBPBPMgArCaSiRnTiMgArCaSiThCaSiRnFArRnSiRnFArTiTiBFArCaCaSiRnSiThCaCaSiRnMgArFYSiRnFYCaFArSiThCaSiThPBPTiMgArCaPRnSiAlArPBCaCaSiRnFYSiThCaRnFArArCaCaSiRnPBSiRnFArMgYCaCaCaCaSiThCaCaSiAlArCaCaSiRnPBSiAlArBCaCaCaCaSiThCaPBSiThPBPBCaSiRnFYFArSiThCaSiRnFArBCaCa...
e2e6cb84aa424cea3ea765e1845411cc25322862
FernandaVieira/Python
/PythonExemples/Cours/IFT-1004-A17_Semaine 03/Contenu diversifié/ordre_3.py
551
3.8125
4
# Auteur: Honore Hounwanou <mercuryseries@gmail.com> # Description: L'ordre est parfois important def premier(n): est_premier = True candidat = 2 while candidat <= n - 1 and est_premier == True: if diviseur(n, candidat): est_premier = False candidat += 1 # équivalent...
0146dd4890afbc055166d06be4c9380fc69cfdd9
SuperTigerPlusPlus/Euler
/2/2.py
277
3.765625
4
result_sum = 0 # used to store the current fibonacci numbers fib_num1 = 1 fib_num2 = 2 while fib_num1 < 4000000: if fib_num1 % 2 == 0: print fib_num1 result_sum += fib_num1 tmp = fib_num2 fib_num2 += fib_num1 fib_num1 = tmp print "Result is: %s" % result_sum
4bf4ed69fa064619c44e18404e12285413fc5d36
daniel-reich/turbo-robot
/ZT2mRQeYigSW2mojW_9.py
3,684
4.28125
4
""" Haikus are poems formed by three lines of 5, 7, and 5 syllables. Your task is to write a function that determines if a given poem scans as a Haiku. How to count syllables: * Every syllable must contain at least one vowel. * If two or more vowels appear back to back, they should be counted as a single vowel...
3790845dcb84b5a1d54bb4bee6bcd34308e0aaed
vral-parmar/Basic-Python-Programming
/String and Dictionary /sting.py
660
4.21875
4
string printing using diffrent string operations str = "HelloWorld" print("string = ", str) print("String[0]=", str[0]) print("String[-1]=", str[-1]) print("String[1:5]=", str[1:5]) print("String[5:-2]=", str[5:-2]) #Multi line my_string = """Hello, Welcome to the World of python""" print(my_string) #find number o...
c8a9f71d288ddd55e7adc64df0c6c645e234b539
meenanegi/Taurus
/Shital/Assignment-1/Assignment1-Program1.py
269
3.890625
4
Name = input("Enter Student Name: ") Age = int(input("Enter student's age: ")) if Age == 19 and Name == "Yogesh": print(Name+" is "+str(Age)+" years old and He is new in the class") else: print(Name+" is "+str(Age)+" years old and He is not new in the class")
2d444e712f23a5769eec6518c46d259656995392
hoik92/Algorithm
/algorithm/work_6/quick_sort.py
454
3.5
4
l = [6,5,4,3,2,1] def quick_sort(l, begin, end): if begin < end: p = partition(l, begin, end) quick_sort(l, begin, p) quick_sort(l, p+1, end) def partition(l, begin, end): pivot = begin i = begin for j in range(i+1, end): if l[pivot] >= l[j]: i += 1 ...
d2210f36e150738a9d2954478db6f50b7a84adbe
HoYoung1/backjoon-Level
/backjoon_level_python/14444.py
574
3.515625
4
import sys input = sys.stdin.readline def expand(left: int, right: int) -> str: while left >= 0 and right <= len(S) and S[left] == S[right - 1]: left -= 1 right += 1 return S[left + 1:right - 1] def solve(s): if len(s) <= 2 or s == s[::-1]: return s result = '' for i i...
6391d22044b0b873e669cf7841135db51b0eb46b
AK-1121/code_extraction
/python/python_2937.py
302
3.828125
4
# need help with splitting a string in python &gt;&gt;&gt; import nltk &gt;&gt;&gt; nltk.word_tokenize("Hello! Hi, I am debating this predicament called life. Can you help me?") ['Hello', '!', 'Hi', ',', 'I', 'am', 'debating', 'this', 'predicament', 'called', 'life.', 'Can', 'you', 'help', 'me', '?']
d5effc5f88375c39a869f2e27395a3f5a28ab268
shangguanouba/python
/python/下载文件案例/文件下载_client.py
860
3.59375
4
import socket def main(): # 1.创建套接字 tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 2.获取服务器ip和port server_ip = input("请输入服务器ip:") server_port = int(input("请输入服务器port:")) # 3.连接服务器 tcp_socket.connect((server_ip, server_port)) # 4.获取下载文件名 download_filename = input("请...
d95e98cadeed391a2398b57d52611394c270d7d5
elmeriki/PythonAppsEx
/corepython/userinput.py
561
3.921875
4
import sys as meriki # x = int(input("Please enter first number ?")) # y = int(input ("Please enter first number ?")) # print(x + y) # x = input("Enter your Name ? ") # print("Hello Mr " + x ) # x = int(input ("Enter Num 1 ")) # y = int(input ("Enter Num 2 ")) # answer = x + y # print(answer) # demo =eval(input("En...
4272e0b657d57bc8a5119fe498d309f41f4c9ec3
abdullahhmd/odev
/odev1.py
650
3.671875
4
print ("kar etmismi etmemismi") finansman_gelir=int(input("finansman gelir yazınız")) pazar_gelir=int(input("pazar gelir yazın")) kira_gelir=int(input("kira gelir yazın")) ucret=int(input("ucret girin")) finansman_gider=int(input("finansman gider yazın")) pazar_gider=int(input("pazar gider yazın")) kira_gider=in...
6470080d91e8e6c9ddd37571a8d31cf22d67c796
gabriel19913/examples_pygal_matplot
/random_walk.py
1,038
4.25
4
from random import choice class RandomWalk(): '''A class that enerates a random walk''' def __init__(self, num_points=5000): self.num_points = num_points # The walks start in the coordinate 0,0 self.x_values = [0] self.y_values = [0] def get_step(self): '''Calculat...
b8d9537a4f63bb4a92a32a18c75eaa26547b4bc7
ManuelCanelon/project_1
/project_1_subtraction.py
160
3.875
4
print("Welcome to project_1_subtraction: This app is an app to subtract two numbers.") a = 134 b = 77 c = a - b print(str(a) + " - " + str(b) + " = " + str(c))
59d4b30ef06ad903a5b736edfa712a9fb5ccf5ad
idiotfenn/useless-project-example
/source/grades.py
1,198
4.15625
4
#!/bin/python import pickle grades = {} if input("Do you have an existing grade file? (Y/n)")[0].lower() == "y": try: grades = pickle.load(open(input("What is the name of the file?"), "rb")) print("Current grades:") for name in grades.keys(): print(name + "'s grade is '" + grad...
3f46584b89d3eda12ac9c451fc3ad820bcd1fb5b
fiffu/arisa2
/utils/feedback.py
1,089
3.703125
4
"""feedback.py Utility classes for fetching externalized strings stored as dicts. Example: FEEDBACK = { 'hello': 'Hello World!', 'breakfast': 'Menu: {}, {}, {}' } fb = FeedbackGetter(FEEDBACK) print(FEEDBACK.hello) # 'Hello World!' print(FEEDBACK.breakfast('spam', 'eggs', 'ha...
5ee524b78ddb813a6b77c9241ad15498916bcfa1
apromessi/interviewprep
/ariana_prep/set.py
1,220
4
4
#!/usr/bin/env python from hash_table import HashTable, HASHING_CONSTANT from random import shuffle class Set(HashTable): def add(self, key): self.insert(key, None) def contains(self, key): index = hash(key) key_value = self.get_key_value_at_index(key, index) if key_value: ...
13ad645f6c90a4ecfb4a010f149e92b37102170d
NetworkingGroupSKKU/network_theory_and_applications
/Assignment02/WordFrequencyChecker.py
3,491
3.90625
4
# -*- coding:utf-8 -*- import re, csv, os class WordFrequencyChecker: def __init__(self): pass def isEnglishWord(self, word): """ Checking English word Return True if word is English word. Otherwise, return False. >>> isEnglishWord("The") True >>> isEnglishWord("the f...
3c8609dcc5d9b210a5ea52247720bc3d8f0537e0
15194779206/practice_tests
/education/A:pythonBase_danei/3:模块包异常处理/before/5:迭代器和生成器/6:enumerate.py
322
3.828125
4
names=['中国移动','中国电信','中国联通'] for t,n in enumerate(names,1): print(t,'--->',n) # 1 ---> 中国移动 # 2 ---> 中国电信 # 3 ---> 中国联通 it =iter(enumerate(names,1)) while True: try: k,n=next(it) print(k,'--->',n) except StopIteration: break
d88597936cb737e9a270a5ebe6c79456285abb54
vit-ganich/useful-scripts-py
/python_refresher/Student.py
1,001
3.9375
4
class Student: def __init__(self, name, school): self.name = name self.school = school self.marks = [] def average(self): average = sum(self.marks) / len(self.marks) print(f"{self.name} average: {average}") return average def go_to_school(self): ...
e19b4e9c56957e6cdc9400726649d125aa5c8b3f
KRudraksh/Aerove_Training_Rudraksh
/Python/1.py
657
3.796875
4
import math def twinprime(n): n=10 ** n prime = [True for i in range(n + 2)] p = 2 while (p * p <= n + 1): if (prime[p] == True): for i in range(p * 2, n + 2, p): prime[i] = False p += 1 for p in range(2, n-1): if prime[p] and prime[p +...
68dc1bb6c8e5be8c22de2be4eaec640cfa933021
YuJuanWen/Python_Exercise
/Test/Function_homework.py
851
3.796875
4
#编程实现9*9乘法表 n=1 while n<10: m=1 while m<=9: print(n,"*",m,"=",n*m) m+=1 print("--------------------------------------") n+=1 #用函数实现求100-200里面所有的素数 num=[]; i=2 for i in range(2,100): j=2 for j in range(2,i): if(i%j==0): break else: num.append(i) ...
69f55b269a06e845d2d675c927a4ba72e67fdbf2
tohfaakib/python_playground
/global & return/global_&_return_example_1.py
362
3.734375
4
# ================================ Normal Case =========================== def addition(val1, val2): return val1 + val2 result = addition(10, 20) print(result) # ================================= Global ================================== def addition_g(val1, val2): global result_g result_g = val1 + ...
1467c554061fb01f5ae794716230ebb5b1d92e76
kim4t/Baekjoon-Online-Judge
/Baekjoon Algorithm (ktkt508)/5543번 상근날드/Answer.py
205
3.734375
4
minham = 2000 for i in range(3): l = int(input()) if(l<minham): minham = l minbev = 2000 for i in range(2): l = int(input()) if(l<minbev): minbev = l print(minham+minbev-50)
5fcd85f447c68726b3ad240e4924dcb863a07d1f
joohy97/Jump-to-Python
/2장/02-2-VarString1.py
745
4.03125
4
#문자열 표현 : " ", ' ', """ """, ''' ''' food = "Python's favorite food is perl" say = '"Python is very easy." he says.' food2 = 'Python\'s favorite food is perl' say2 = "\"Python is very easy.\" he says." #여러 줄 multiline = "Life is too short\nYou need python" multiline2 = ''' Life is too short You need python ''' print(m...
85d9a601cb61c3b81e6a06ed95400aaa36666e29
PurplePenguin4102/ark-thremar
/main.py
1,852
4
4
import math, random class Main(object): '''The Main class handles all global effects that happen across turns. It also handles combat, the turn ticker and global rolling. Only have one main class active at a time, unless you have a death wish ''' def __init__(self): self.turn = 1 self.is_combat = ...
7244365cb929db8e04872827d116b41c4c57b0e0
FatihMalakci/Youtube-Alarm-Clock
/init.py
2,404
3.59375
4
import time import random import webbrowser Trigger = False t0 = time.time() current = time.strftime('%H:%M:%S', time.localtime(t0)) print("⏰ Welcome to The Youtube Alarm Clock!\nCurrent Time is: {0} ⏰ ".format(current)) ## Alarm Sounds for ringing later. def sounds(): with open('alarms.txt','r') as f: a...
4cc2e2eea2a5bcdb4520bc80d4094bf17658fd02
czkiam/python-std-lib
/namedTuples.py
956
3.84375
4
#!/usr/bin/env python """sample script for namedtuple""" from collections import namedtuple ServerAddress = namedtuple('ServerAddress', ['ip_address', 'port']) LOCAL_WEB_SERVER = ServerAddress('127.0.0.1', 80) print LOCAL_WEB_SERVER print LOCAL_WEB_SERVER.ip_address LOCAL_SSH_SERVER = ServerAddress(port=22, ip_addre...
46a99078489f2134b2c61aec5d92b45b1055155f
Nipicoco/Cosas-Uni
/Lab 4/Pregunta 7.py
1,640
4.1875
4
''' Analisis Entradas: Numero_letra Salidas: valor_adecuado proceso: si numetra=1,2,3, 4,5,6,7,8,9,0 Pseudocodigo: Algoritmo numero Escribir "Ingresa un caracter: " leer numetra si numetra = "1" Escribir "El caracter ingresado es un numero" sino si numetra = "2" Escribir "El caracter ingresad...
8cb5c50f658ce662d41f4e1d6cbf52788e1babeb
qq516249940/learnning-python
/ele/4/time_module.py
465
3.53125
4
#!/usr/bin/env python #coding: utf-8 import time print time.localtime() #返回当前时间的9个状态元组 print time.time() #当时时间戳 print time.gmtime() #UTC事件的9个状态元组 print time.ctime() #返回一个本地的可读的时间 print time.mktime(time.localtime()) #根据9个时刻返回时间戳 print time.strftime('%a %b', time.localtime()) print time.asctime(time.localtime()) print ...
f7ad64a7077d024ae5168f7c0125a2e6fd3e3e72
Punttikarhu/Hy-Data-analysis-2019
/sum_equation.py
360
3.640625
4
#!/usr/bin/env python3 from functools import reduce def sum_equation(L): if (len(L) == 0): return "0 = 0" else: str = "" for i in range(len(L) - 1): str += "".join(f"{L[i]} + ") str += f"{L[-1]} = {sum(L)}" return str def main(): sum_equation([1,5,7])...
1fc9b80b103f7b70f21a055c837539f0c3dd7d92
veyu0/Python
/les_7/les_7_task_1.py
752
3.765625
4
class Matrix: def __init__(self, arr): self.arr = arr def __str__(self): res = '' for els in self.arr: el_str = '' for el in els: el_str += str(el) + ' ' res += el_str + '\n' return str(res) def __add__(self, other): ...
2a193480c8dd51f428ae976a1a2e97b57e358eae
MalayCreates/DailyProblem
/test.py
7,143
3.71875
4
#HW3 #Due Date: 07/12/2020, 11:59PM ######################################## # # Collaboration Statement: # ######################################## class Node: def __init__(self, value): self.value = value self.next = None def __str__...
061ef2a05cd2ef8103ea4d6d37849d65aa06c0b6
timothyb9526/rental_store_timothybowling
/shell.py
4,022
3.78125
4
import core import disk import time def customer(inv, customer_employee, rent_or_return): while True: print(inv) print() rental = input( 'Which would you like to rent today?(First letter of rental) ') print() time.sleep(.5) name = input('What name wou...
b68677c967f8e61742f7d1ec209fa6b5cbfeab7e
jgerstein/FinalProject19
/examples/objects/categories.py
524
3.8125
4
class Animal: def __init__(self, type, name): self.name = name self.type = type if type == "cat": self.sound = "meow" self.size = "small" elif type == "dog": self.sound = "woof" self.size = "medium" elif type == "hippo": ...
6eddbb6bbcbb61f606bacad2801b6f6990c15db1
taitran97/0.-Python-
/3. Input.py
222
3.90625
4
# 1. Input # <class 'str'> # inputAnything = input() # print("Output: " + inputAnything) # 2. Change Type # <class 'str'> --> <class 'int'> # changeType = int(input()) # changeType = changeType + 10 # print(changeType)
c67f8c96dfa2784f2e7b4747c375b88198d29f3d
adichouhan14/DataScience
/assignment6/ass6.3.py
215
3.640625
4
import pandas as pd import numpy as np dict={"name":["ravi","tarun","mayur"],"salary":[10000,20000,15000],"experience":[1,2,3], "joining year":[2000,2001,2002]} x=pd.DataFrame(dict) print(x["salary"].mean())
65cd771c821925eafe39afcb9b64c458c61d2000
jovanibrasil/interactive-python
/courseraprojects/mini_project_2.py
1,647
4
4
import simplegui import random import math high = 100 def new_game(): """initialize global variables""" global int_guess, secret_number, high, guesses secret_number = random.randrange(0,high) int_guess = 0 guesses = int(math.ceil((math.log(high - 0 + 1))/(math.log(2)))) print "New game. Range ...
c5cbe0a434dcf5fc9b627a76fddf03ab4a85b2d0
moazsholook/ICS3U-Python
/IDLE-exercises/exercise_10.py
480
3.828125
4
import random while True: first_roll = random.randint(1,6) print(f"Your first roll and point value is: {first_roll}") count = 0 while True: next_roll = random.randint(1,6) print(f"Your next roll is: {next_roll}") count += 1 if next_roll == first_roll: print(f"It took {count} times to get y...
a5c4e8a5e795c970549a9cc47658e1364a9cdbfb
EvanSMartin/oop
/d02/ex01/add_tail.py
1,418
4
4
# **************************************************************************** # # # # ::: :::::::: # # add_tail.py :+: :+: :+: ...
d9e59273a9fd25056e2866021031399823ab3aeb
kumawat0008/Data-Structures-Algorithms
/LinkedList/reverse.py
766
4.03125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self,data): node = Node(data) node.next = self.head self.head = node def reverse(self,node): if no...
0fb11e67d0a63f59f29b79dc804076e4d15e8b19
amiraliakbari/sharif-mabani-python
/by-session/ta-932/j5/recursive2.py
999
3.53125
4
a = [1, 2, 6, 7, 9, 10, 20, 30] def search_linear(a, x): for y in a: if x == y: return True return False def search_linear_index(a, x): for i in range(len(a)): if a[i] == x: return i return -1 def search_binary(a, x): n = len(a) if...
214b1ff0937f261b88100de27e2012c8e49fa645
jdiodato/turtle
/snake.py
1,566
4.15625
4
''' A simple snake game using Python's Turtle module Created by Joseph Diodato (diodato.org) ''' import turtle, random, time # Setting up the screen scn = turtle.Screen() scn.bgcolor("green") scn.setup(600, 600) scn.title("Snake! by @joe_diodato") head = turtle.Turtle() head.shape("square") head.speed(1) head.pen...
61cd0615e01d83fffe6146bd71044d1a261f51e6
LokeshNaidu8/Python-development
/pythonStringPatter.py
111
3.625
4
str="python" for i in range(0,len(str)+1): for j in range(i): print(str[j],end=" ") print()
930412775aec337a8428ce0064bfc78692761a60
yzl232/code_training
/mianJing111111/Google/有一些set of names, 比如first name, middle name, last name,写个iterator打印.py
1,078
3.921875
4
# encoding=utf-8 ''' 有一些set of names, 比如first name, middle name, last name,写个iterator打印名字的组合 ''' #G家很喜欢这种题目。 dfs用一个pointer就好了。 #不过这次是iterator #可以一个arr of pointers。 class Solution: def __init__(self, arrs): self.arrs = [x for x in arrs if x] self.n = len(self.arrs) self.pointers = [0 ]*le...
0262fda60bcd0c6293702b667e5b7ad2c7e97cab
nowacki69/Python
/Udemy/Python3Bootcamp/Functions/Lambdas/MapTimeExercise.py
278
3.625
4
def decrement_list(list_numbers): new_nums = list(map(lambda num: num - 1, list_numbers)) return new_nums # OR for i in range(len(list_numbers)): list_numbers[i] = list_numbers[i] - 1 return list_numbers nums = [1,2,3,4,5] print(decrement_list(nums))
4b9680712bba40249e36f659452e9ddc6c62598e
strongheart/pyEyedMilestones
/bj/BlackJack.py
8,883
3.65625
4
#!/usr/bin/python # -*- coding: utf-8 -* ## ☘♣♥♦♠♤♡♢♧☹☺☠ from Deck import Card, Hand, Deck from Player import Player class BlackJack(object): QM='\n\t?' """neg numbers are return codes, positive numbers are parsed values """ rcLeave=-10 rcPass=-20 rcQuit=-90 rcNo=-128 rcYes=-127 ...
cd7c789cab6c3305143b9af03fdebf1ca307407d
waxlamp/aoc2020
/day2/go.py
728
3.65625
4
import sys def parse_line(line): parts = line.split() count_range = [int(x) for x in parts[0].split("-")] letter = parts[1][0] password = parts[2] return (count_range[0], count_range[1], letter, password) def letter_count(s, l): return len([x for x in list(s) if x == l]) def valid(entry):...
fafe197be778410d32b898220f1137776c46ce67
whchoi78/python
/함수의 구조.py
494
3.6875
4
#함수 선언 부분(매개 변수o, 반환값o) def sum(a, b): return a+b #메인 코드 부분 result = sum(1, 2) print(result) #함수 선언 부분(매개 변수x, 반환값o) def sum2(): return 1+2 #메인 코드 부분 result2 = sum2() print(result2) #함수 선언 부분(매개 변수o, 반환값x) def sum3(a, b): print(a+b) #메인 코드 부분 sum3(1, 2) #함수 선언 부분(매개 변수x, 반환값x) def sum4(): print(...
d20b0feff64ba16c1e8fc0ccc897dd0af24019b8
CSI-280/Pandoras-Bot
/utils.py
427
3.8125
4
"""Holds functions that don't really belong elsewhere.""" def rgb_to_hex(rgb): """Convert rgb tuple to hexcode string.""" return "#%02x%02x%02x" % rgb def hex_to_rgb(value): """Convert hexcode string to rgb tuple.""" value = value.lstrip('#') if len(value) == 3: value = u''.join(2 * s fo...
7fdcad423ad1f7510e45f661f197447fac4cb193
harpreet11707946/Python11707946
/lab1.py
296
4.25
4
#program to print Grades according to marks n=float(input("enter the marks")) if(n>=90): print("Grade A") elif(n>=80): print("Grade B") elif(n>=70): print("Grade C") elif(n>=60): print("Grade D") elif(n>=40): print("Grade E") else: print("Fail")
1fa5e3beb32f146e7af3b682aa7ac5e34e8b0eac
zmx8901/untitled
/test9 用filter求素数.py
1,313
4.21875
4
# 用filter求素数 # 用Python来实现这个算法,可以先构造一个从3开始的奇数序列:注意这是一个生成器,并且是一个无限序列。 def _odd_iter(): # 先构造一个从3开始的奇数序列 n = 1 while True: n = n + 2 yield n # 这是一个生成器,并且是一个无限序列。 # 定义一个筛选函数,筛选新的素数: def _not_divisible(n): return lambda x: x % n > 0 # 定义一个生成器,不断返回下一个素数:这段不是很懂 def primes(): yield 2 i...
f47a2aaeb6311e135f7ae79d7acd8a9f5baf86a0
TJRklaassen/ProgrammingTK
/Les6/pe6_3.py
328
3.71875
4
list = "5-9-7-1-7-8-3-2-4-8-7-9".split('-') list.sort() for i in range(len(list)): list[i] = int(list[i]) print("Gesorteerde list van ints:",list) print("Grootste getal:",list[-1],"en kleinste getal:",list[0]) print("Aantal getallen:",len(list),"en som van de getllen:",sum(list)) print("Gemiddelde:",sum(list)/len...
22cfa66bbb277570f8441e244e6937a8dc9682f6
AdityaShidlyali/Python
/Learn_Python/Chapter_7/8_copy_method.py
473
4.1875
4
# copy method in python dictionary d = {'name' : 'Aditya', 'age' : '21'} d2 = d.copy() print(d2) # if we assign the dictionaries like d2 = d then the both the variables are pointing to same dictionaries # if we assign d2 = d whatever the changes made to d2 are reflected in d as well # to check the if the dictionarie...
590b3ba00c5ffc790b2fb7c7d78f79b329dee43c
LeonardoLems/projeto_teste
/main.py
631
4.03125
4
from conta import Conta print("******* MENU *******") print("(1) criar conta - (2) editar conta - (3) deletar conta - (4) mudar saldo - (5) sair") opcao = 1 while opcao == 1 or 2 or 3 or 4 or 5: opcao = int(input("Escolha uma opção: ")) if opcao == 1: print("criar conta") Conta.criar_conta() ...
1aae93d406218a793b354a38bf8a7467c23311e7
AppiGarg/Number-Guesser-V1
/main.py
237
4
4
import random number = random.randint(1, 10000) Guess = int(input("Guess the number! ")) while Guess != number: if Guess < number: Guess = int(input("Guess the number! ")) print("Higher") if Guess > number: print("Lower")
366f9310cb7bdf0d96aa2e491199d4f3f028bd5c
zh-12345/jainzhioffer
/jianzhioffer1/18_2 deleteduplicated.py
8,121
3.984375
4
from typing import List class SingleNode(object): """单链表的节点""" def __init__(self, val): # val存放数据元素 self.val = val # next 存放下一个节点的标识 self.next = None class SingleLinkList(): # 对象属性 def __init__(self, node=None): # 可以设置默认参数 self._head = node def is_...
44034a33e1cc375d1f909ac229c5669684873bcc
ferminhg/adventofcode
/day1.py
1,804
4.28125
4
import itertools import numpy from typing import List, Tuple # Specifically, they need you to find the two entries that sum to 2020 and then multiply those two numbers together. # For example, suppose your expense report contained the following: # 1721 # 979 # 366 # 299 # 675 # 1456 # In this list, the two entries ...
b44e6d068da97fa3e3dde3be4a6f0f1c0c785bc4
2tom/python_study
/shinyawy/09_hello.py
291
3.78125
4
# coding: UTF-8 # No.2 Python Study 2015/06/18 # リスト sales = [50,100,80,45] # sort / reverse sales.sort() print sales sales.reverse() print sales # 文字列とリスト d="2015/6/18" print d.split("/") a=["a", "b", "c"] print "-".join(a) aaa=[50,"50",100,"100"] aaa.sort() print aaa
7b9aa4e5ec1d09006fa6c372978ea2ffab870e51
modris1/DMI
/python/sin_caur_summu_ver2.py
555
3.734375
4
# -*- coding: utf-8 -*- from math import sin # float (1.) * float (2.) = float (2.) # float (1.) * int (2) = float (2.) # float(input()) = float x = 1. * input("Lietotāj, lūdzu, ievadi argumentu (x): ") # print type(x) y = sin(x) print "sin(%.2f)=%.2f"%(x,y) a0 = (-1)**0*x**1/(1) S = a0 print "a0 = %6.2f S0 = %6.2f"%...
f394c866f8565c0e95a968e215f91e3116fd153b
cozyo/algo-learn
/python/linkedlist/leetcode/linked_list_cycle.py
693
3.921875
4
# 判断链表是否有环 # https://leetcode-cn.com/problems/linked-list-cycle class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # 使用一个set def hasCycle_1(self, head: ListNode) -> bool: s = set() while head: if head in s: re...
51c617cfffd57b00a1b0faf672c8ee4e074dc946
Naoya-abe/siliconvalley-python
/section15/lesson192.py
1,743
3.75
4
""" キュー スレッド間でデータの受け渡しが可能 """ import logging import queue import threading import time logging.basicConfig( level=logging.DEBUG, format='%(threadName)s: %(message)s' ) def worker1(queue): logging.debug('start') while(True): item = queue.get() if item is None: break ...
7b70b04e6ff7a3d224e2fbbe3ca745f6cf05316a
ngoldsworth/Proj-Euler
/p023.py
728
3.625
4
from p021 import divsum import itertools def det_abundant(num: int): ''' Determine if a number `n` is an `abundant` number. :param num: Input integer :return: True or False ''' for i in range(num + 1): if divsum(num) > num: return True else: return False ...
3746989f7866fc69d420f007f2453e1dee92006f
infinite-Joy/programming-languages
/python-projects/algo_and_ds/wordcount_engine_using_orderedict.py
2,305
3.625
4
from collections import OrderedDict from typing import List, Tuple from itertools import accumulate def counter(freqs, maxval): counts = [0] * (-1*maxval) print(freqs) print(counts) for s, f in freqs: print(s,f) counts[f] += 1 return counts def build_solution(freqs, counts): s...
51c8d77199a1f3e4f698576161a01d6e987d37a0
danielor/Structures
/test/LinkedListTest.py
1,729
3.890625
4
import unittest from ds.linear.LinkedList import LinkedList class LinkedListTest(unittest.TestCase): """ A function that unit tests the Linked List object """ def _build(self): """ A function that builds a basic linked list """ ll = LinkedList(None) ...
a0e2494b202dfbda33a8c807cd5fed408ec9f8d8
shafaypro/AndreBourque
/calc.py
821
4.46875
4
print("This is a a Calculator") # this is a print statment number = 3 # this is a variable names number number2 = 3 # this is a variable named number2 which has 20 value sum = number + number2 # this is the sum variable holding the sum of number and number2 p = number * number2 # this is the p variable holding th...
26293d9102452543b0e26dc52f1a2642db5b322b
paulacodes/AdventOfCode2020
/day1.py
1,646
4.71875
5
def multiply_two_numbers_that_sum_to_value(numbers, value): """ multiply_two_numbers_that_sum_to_value finds the two numbers in a list that sum to a certain value and returns the multiplied values :param numbers: list of numbers :param value: the value that the two numbers shuld sum up to """ subset = set() fo...
dfd46d94f14f87df5da11837dc2cbc255aca3802
direct2nnp/ctci6th
/chap_1/5.py
1,088
3.71875
4
''' One Awapos_b - There are three tpos_bpes of edit can be performed on string. insert a char remove a char replace a char Given two string, Write a function to check if thepos_b are one edit or zero edit awapos_b EXAMPLE pale, ple -> true pales, pale -> true pale, bale -> true pale, bake -> false '''...
1aae2ed913f41ab7604fd96372ad0f52683e0b74
pullyl/open-data-workshop
/pandas_intro.py
763
3.984375
4
#!/usr/bin/env python # coding: utf-8 # This is a simple Python notebook demonstrating the power of pandas # In[1]: import pandas as pd df = pd.read_csv('2018_General_Election_Returns.csv') len_df = len(df) print(f'Imported {len_df} rows') # In[2]: #printing all offices offices = list(df['Office'].drop_dupli...
97a920f7b7978c2060e026533c52aedd547f535f
Indra-Ratna/LAB6-1114
/Lab6_problem3.py
275
3.90625
4
#Indra Ratna #CS-UY 1114 #12 Oct 2018 #Lab 6 #Problem 3 n = int(input("Enter a positive integer: ")) for i in range(0,n): for k in range(1,i+1): print("#",end="") print("%",end="") for b in range(n-1,i,-1): print("$",end="") print()
66bf6daadbb7c7fd0b08a7e255a57f140929938c
EscapeB/LeetCode
/Multiply Strings.py
1,874
4.125
4
# Given two non-negative integers num1 and num2 represented as strings, # return the product of num1 and num2, also represented as a string. # # Example 1: # # Input: num1 = "2", num2 = "3" # Output: "6" # Example 2: # # Input: num1 = "123", num2 = "456" # Output: "56088" # Note: # # 1、The length of both num1 and num2 ...
fe5362b08fbaa62ebfeb5530b1ab1a809e297c0d
albertoiur/Codility
/Lesson3/FrogJmp.py
1,715
3.875
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 6 14:47:22 2017 @author: Rui FrogJmp: Count minimal number of jumps from position X to Y. A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. ...
df0605535dbeb4d0bda79b12bacd5479ece7c45b
rookieygl/LeetCode
/leet_code/lt_tiku/461.hammingDistance.py
1,072
4.03125
4
""" 汉明距离 两个整数之间的汉明距离指的是这两个数字对应二进制位不同的位置的数目。也就是记录1的个数 给出两个整数 x 和 y,计算它们之间的汉明距离。 两个等长字符串s1与s2之间的汉明距离定义为将其中一个变为另外一个所需要作的最小替换次数。例如字符串“1111”与“1001”之间的汉明距离为2。 """ class Solution(object): def hammingDistance(self, x, y): # 取异或值得到明汉值 0 相同 1 不同 1的个数就是明汉距离 s = x ^ y ret = 0 while s: ...
23267a3f78dcbc0fe5100d292ccff4c8dbeb2c70
chetakkadam/Assignment-1
/Assignment4_3.py
685
3.796875
4
from functools import *; def AcceptData(): arr = list(); n = int(input("Enter Number of Elements : ")); print("Pl enter elements:"); for i in range(0,n): print("Pl enter number ", i+1); element = int(input()); arr.append(element); return arr; def main(): rawlist = AcceptData(); print(rawli...
563b2f7a88b621aa812fc1340fcd7cd44a948bfe
ihunter2839/game_of_life
/game.py
4,374
3.78125
4
import sys, random, copy from graphics import * colors = ['black', 'white', 'red', 'blue', 'yellow', 'green','purple'] def tick(win, colored, old_colored, squares): #generate some random colors to make the game look interesting c1 = colors[random.randint(0,6)] c2 = colors[random.randint(0,6)] #c1 and c2 should no...
9f3feafdfaea8a3ac7e78aaa1eccaebe13bb7ec7
ariana124/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
260
4
4
#!/usr/bin/python3 """ Module that contains the function search_replace """ def search_replace(my_list, search, replace): """ replaces all occurences of an element by another """ return ([elem if elem is not search else replace for elem in my_list])