blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
46ef97a9715a56b3fc255fbda074468e2ca9c299
Billy-Q/learn_python
/day01/day01_8.py
1,028
3.859375
4
''' ********** Date: 2021-10-28 Author: Billy-Q ********** ''' # 1.我们出拳 定义变量保存用户输入 my = int(input('请输入出拳')) # 2.电脑随机出拳(假定电脑出石头) com = 1 # 3.判断胜负 if (my==1 and com==2) or (my==2 and com==3) or (my==3 and com==1): # 用户胜利 print('用户胜利, my=%d,com=%d'%(my,com)) elif my==com: print('平局,决战到天亮') ...
7e2b4918ca8404278db3fb3e02b690ba578e509e
mak705/Python_interview
/python_prgrams/testpython/if6.py
143
4.09375
4
num = 7 if num == 5: print("HI I AM 5") elif num == 11: print("Number is 11") elif num == 7: print ("i am 7") else: print("not 5 7 11")
1297e534aba2896e3af4d8300b90269e7d1a3e4c
DanecLacey/GUI_Projects
/calculator/simple_calculator.py
2,870
4.0625
4
from tkinter import * import util as ut #Set the root object for tkinter root = Tk() root.title("Simple Calculator") #set the entry object e = Entry(root, width = 35, borderwidth = 5) e.grid(row = 0, column = 0, columnspan = 3, padx = 10, pady = 10) #define buttons button_1 = Button(root, text = "1", padx = 40, pady...
322f4e4bd46165b5440aa67d9328f90d5a17cbed
JLMarshall63/myGeneralPythonCode_B
/SynchronousPython.py
216
3.59375
4
#Example standard synchronous Python #prints hello waits 3 sec the prints world from time import sleep def hello(): print('Hello') sleep(3) print('World!') if __name__ == '__main__': hello()
c701e79927f5b435adb8f281414d1b55a2a04fdb
Skipper609/python
/Sample/class eg/lab questions/2B/4.py
592
3.671875
4
class Account : def __init__(self, accno , name, balance): self.accno = accno self.name = name self.balance = balance def deposit(self, deposit_amount): self.balance += deposit_amount def withdraw(self, withdraw_amount): self.balance -= withdraw_amount ...
7ce5ddf7c1bc2e14ae1ade4fa724f32298867b33
farean/TDDPythonRomanConverter
/consoleinitial.py
3,336
3.546875
4
class NumbersRoman: def __init__(self, arg): super(NumbersRoman, self).__init__() self.arg = arg def ValidateNumber(entervalue): letters=['I','V','X','L','C','D','M'] retvalue=True for x in list(entervalue): if (x not in letters): retvalue=False break return retvalue def RomToDec(entervalue)...
2572e593338c29a8a19bc1dbfefb81969f8401f8
MCBoarder289/PythonArcadeGames
/Chapter 11 - Bitmapped Graphics and Sound/Chapter 11 Lesson.py
2,455
3.8125
4
""" Pygame base template for opening a window Sample Python/Pygame Programs Simpson College Computer Science http://programarcadegames.com/ http://simpson.edu/computer-science/ Explanation video: http://youtu.be/vRB_983kUMc """ import pygame # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN...
87db4d955c9be83ce81db41757cac3285b6ab324
fedorrb/Python
/Prometheus/8/84.py
2,586
3.96875
4
# -*- coding: utf-8 -*- def make_sudoku(size): sudoku = [] size_sud = size ** 2 arr = range(1,size_sud + 1) def moveSize(arr): new_arr = arr[size:] + arr[:size] return new_arr def move1(arr): new_arr = arr[1:] + arr[:1] return new_arr for i in range(size_sud): ...
138cd74945e53d7035ccea5e3a1edc34972f0472
fkfouri/HackerHank_PythonStudy
/30 Days of Code/18 - Queues and Stacks.py
641
3.921875
4
#https://www.hackerrank.com/challenges/30-queues-stacks/problem #https://docs.python.org/2/tutorial/datastructures.html class Solution: def __init__ (self): self.q = [] #Queue self.s = [] #Stack self.reverse = False #Stack def pushCharacter(self, ch): self.s.append(ch) ...
e8f0ccadb4447896140996e552deb8a281427ac2
AdamZhouSE/pythonHomework
/Code/CodeRecords/2111/60708/272746.py
509
3.734375
4
numof=int(input()) i=0 n=1 n1=1 while(i<numof): n=n1 check=True if(n==2 or n==3 or n==5): check=True else: while (check): if (n % 2 == 0): n = int(n / 2) elif (n % 3 == 0): n = int(n / 3) elif (n % 5 == 0): ...
d18213efa9d3286e56a2b9fd9ab05b18604d4243
shalu169/lets-be-smart-with-python
/generator.py
841
4.3125
4
# generator function # Unlike regular functions which on encountering a return statement terminates entirely, # generators use yield statement in which the state of the function is saved from the last call and # can be picked up or resumed the next time we call a generator function. # Another great advantage of the gen...
7777b0e1002aa240eb8544797bf9711bb88abcd3
bitsandpieces-1984/python_samples
/is_armstrong.py
889
4.125
4
""" The k-digit number N is an Armstrong number if and only if the k-th power of each digit sums to N. Given a positive integer N, return true if and only if it is an Armstrong number. Example 1: Input: 153 Output: true Explanation: 153 is a 3-digit number, and 153 = 1^3 + 5^3 + 3^3. Example 2: Input: 123 Outpu...
c24a97de0006a6812cf3cb1fec0a82539dcbfa03
BerilBBJ/scraperwiki-scraper-vault
/Users/S/sym/adnams-pubs.py
4,858
3.515625
4
import csv import re import urllib2 import BeautifulSoup from scraperwiki import datastore from scraperwiki import geo class Outcodes(): def __init__(self): self.download_outcodes() def download_outcodes(self): """ Downloads a CSV file from http://www.freemaptools.com/ and p...
e4d4d066f9e9c0789e4f0a7bf41ad75cd9b28681
dyhwong/projecteuler
/Problem 015.py
248
3.890625
4
def factorial(n): product = 1 for i in range(n): product *= (i + 1) return product def choose(n, k): return factorial(n) / (factorial(k) * factorial(n - k)) rows = 20 cols = 20 n = rows + cols k = rows print choose(n, k)
7697f46c2bd182c2f2aa89ba5a712f4aea69f0a4
sdpy5/pythonlearning
/list_in_dict.py
362
3.9375
4
classes = { 'teachers' : 'srinivas murthy', 'students' : ['sangith','dharshan','sushagh','shravanya'] } print('the class teacher is : ' + classes['teachers'] + '.') print('the students are : ') for student in classes['students']: print('\t' + student.title()) if student == 'sushagh': ...
bce7358927e74e37b27370b59b71b9252361d2e0
nkini/SplitWiser
/SplitWiser.py
2,045
3.75
4
import sys print("Welcome to SplitWiser") def fileinput(): with open(sys.argv[1]) as f: linecount = 1 for line in f: if linecount == 1: amt_list = {k:[] for k in line.strip().split(' ')} else: amt, *patrons = line.strip().split( ) ...
76c69d38bced270526d63b690831b6d16e90a545
sudo-LuSer/Calculate-the-big-factorials
/factorial.py
521
4.125
4
NMAX=10**5 factorial=[1] def plein_the_factorial(): for i in range(1,NMAX+1): factorial.append(factorial[i-1]*i) def title(): print ("-"*(1.5)*10**2) print("\t\t\t\t\t\t\t"+"welcome to my factorial program using dynamic programming you can calculate n! for all 0<=n<10^5 Enjoy") print ("-"*(1.5)*10**2) plein_the_f...
4b988589a32ea55bdc791048768cd38e3dfcbafe
asadugalib/URI-Solution
/Python3/uri 1131.py
674
3.703125
4
#1131 num_game = 0 inter = 0 gremio = 0 draw = 0 new_game = True while new_game: num_game += 1 x, y = list(map(int, input().split())) if x > y: inter += 1 elif x < y: gremio += 1 else: draw += 1 while True: print("Novo grenal (1-sim 2-nao)") d = i...
b17f27d346153766e34373263367ef707f7a77c2
Linerre/LPTHW
/ex33.py
1,087
4.28125
4
i = 0 numbers = [] while i < 6: print(f"At the top i is {i}") # in order: 0, 1, 2, ... 5 numbers.append(i) i = i + 1 print("Numbers now: ", numbers) # [0], [0, 1], [0, 1, 2] ... [0, ..., 5] print(f"At the bottom i is {i}") # 1, 2, 3 ..., 6 print("The numbers: ") for num in numbers: print(nu...
15a5b31a3bb7db24952a879e15d3fc9a6265cf8c
Mropat/ComparativeGenomicsMM
/p8/scripts (copy)/average_connectivity.py
309
3.625
4
def average_con(filename): s = set() with open(filename, 'r') as f: f = f.readlines() for line in f: line = line.split(' ') s.add(line[0]) average = len(f)/len(s) print(average) average_con('test.txt')
01aa3a6882efb2c71547df73c5d0a32673c5f006
krxsky/AlgoData
/compress.py
431
3.78125
4
def compress(h): result = {} #dict to store result def helper(h, acc): #acc keeps track of the keys so far if isinstance(h, dict): #reduction step #list comprehension is used as syntactical sugar [helper(v,acc+"_"+k) for k,v in h.items()] else: ...
0c070931717086aa2456231f9ba27d4e3fda199a
olympiawoj/my-first-blog
/helloworld.py
305
3.9375
4
print('Hello, Django girls!') if 1>2: print('this works') else: print('does not work') def hi(name): print('hi, {}'.format(name)) hi('olympia') girls = ['Andrea', 'Olympia', 'Kendall', 'Courtney'] for name in girls: hi(name) print('Next girl') for i in range(1,6): print(i)
af9f853d66638a96fcd8ec12863c0338eceebefd
museumgeek/likelion_github_session
/word.py
652
4.15625
4
#사용자로부터 인풋이 들어온다 #그 인풋을 받아서 끝자리 음절과 #다음 인풋의 첫 음절이 같아야 통과다 #3글자만 허용 word1=input("끝말잇기를 시작합시다.") #인풋의 값은 기본적으로 string if (len(word1)==3): #계속 진행 while True:#반복문 word2=input() if (len(word2)==3) and (word2[0]==pre_word[2]): print("정답입니다.") pre_word=word2 else:...
0fb038910bacf4f457d4626bf4f4883a43e0cb7e
LeonSubZero/PythonArchive
/sphere.py
1,728
4.40625
4
""" Flavio Leon 3.30.17 sphere.py Menu-driven interface program that allows the user to: 1.Calc the surface area of a sphere. 2.Calc the volume of a sphere. 3. Quit """" import math def main(): print("Geometry Calculator App...") print() option=0 #Menu while option !...
fb42610a1de7885d9a3727277a2ec7d8a21663fe
22pereai/unit-2.1
/python_cookbook/csv_read.py
257
3.78125
4
import csv FILENAME = "trips.csv" spreadsheet = [] with open(FILENAME, newline="") as file: # read from CSV file reader = csv.reader(file) # selected reader for row in reader: # for each row... spreadsheet.append(row) # append it to the list
89281326d18d1b4eba0b2eef187b3dc0f2ec1c80
owain-Biddulph/deep-ail
/utils.py
6,902
3.828125
4
from typing import Tuple, List import math import numpy as np def distance_min(state): """input: state output: la distance minimal entre un de nos groupes et les groupes ennemies""" distances = [] groups = [None, None] for position_nous in state.our_species.tile_coordinates(): distance_ce...
57bad52d9052fe6580d65bf22666462319380e2e
opwe37/Algorithm-Study
/LeetCode/src/1195.py
1,029
3.625
4
import threading class FizzBuzz: def __init__(self, n: int): self.n = n self.b = threading.Barrier(4) # printFizz() outputs "fizz" def fizz(self, printFizz: 'Callable[[], None]') -> None: self.handler(lambda x: x % 3 == 0 and x % 5, printFizz) # printBuzz() outputs "buzz" ...
c2ad347df17df6f686c93b27774a29c8be92b84d
ancuongnguyen07/TUNI_Prog1
/Week11/fraction.py
6,593
3.96875
4
""" COMP.CS.100 Ohjelmointi 1 / Programming 1 Fractions code template """ class Fraction: """ This class represents one single fraction that consists of numerator (osoittaja) and denominator (nimittäjä). """ def __init__(self, numerator, denominator): """ Constructor. Checks that t...
c09a3aced0a9064b309e314921c3414dc8262a74
bishkou/leet-code
/Linked list/flattenLinkedList.py
825
3.640625
4
# Definition for a Node. class Node: def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child class Solution: def flatten(self, head: 'Node') -> 'Node': if head: aux = head while aux: ...
6ca8fe670469dedc4e671fe8914656e70f0b04e7
ryoman81/Leetcode-challenge
/LeetCode Pattern/1. Breadth First Search/111_easy_minimum_depth_of_binary_tree.py
1,350
4.09375
4
''' Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 2 Example 2: Input: root = [2,null,3,null,4,null,5,null...
86b7f5a488bd620063b85bd51f9a7ef03aaf6fdc
ufv-ciencia-da-computacao/CCF110
/lista2/ex4.py
163
3.921875
4
numMes = int(input()) if numMes // 3 == 1: print("1 trimestre") elif numMes // 3 == 2: print("2 trimestre") elif numMes // 3 == 3: print("3 trimestre")
6d2854f0e11794fdd4334f9ae2d184d7d481ad7e
lucasffgomes/Python-Intensivo
/seçao_04/tipo_string.py
1,805
4.21875
4
""" Tipo string Em Python um dado é considerado do tipo STRING sempre que: - Estiver entre aspas simples; 'uma string', '234', 'a', 'True', '42.3' - Estiver em aspas duplas; "uma string", "234", "a", "True", "42.3" - Estiver entre aspas simples triplas; '''uma string''', '''234''', '''a''', '''...
b2398643494506a58170843330de6b3ffe78bfd6
jackcogdill/Learn-Python-Challenges
/06.py
718
3.5625
4
# Translator! Use the following dictionary to # translate a given sentence into leetspeak. # # Reference: https://docs.python.org/3/tutorial/datastructures.html#dictionaries # # Rules: if the word exists, use the word. Otherwise, # Only translate character by character (if it exists in the dictionary). # E.g., 'but my ...
e4a68d13340e23c0533fc93a4d30e3e148e3eb4a
neiljonesdeloitte/sphinx-multimodule-docexample
/module1/classA.py
577
3.765625
4
# -*- coding: utf-8 -*- class classA(object): def __init__(self, a, b): self.a = a self.b = b def func1(param1, param2): """ Args: param1: The first parameter. \n param2: The second parameter. Returns: The return value. True for ...
f5d22c6af829d0ff946103b199858801f033af75
qiuyucc/pythonRoad
/BasicReview/07MethodRecursive.py
1,715
3.75
4
def fac(num): if num in (0, 1): return 1 return num * fac(num - 1) print(fac(5)) # 递归调用函数入栈 # 5 * fac(4) # 5 * (4 * fac(3)) # 5 * (4 * (3 * fac(2))) # 5 * (4 * (3 * (2 * fac(1)))) # 停止递归函数出栈 # 5 * (4 * (3 * (2 * 1))) # 5 * (4 * (3 * 2)) # 5 * (4 * 6) # 5 * 24 # 120 # 函数调用会通过内存中称为“栈”(stack)的数据结构来保存当前代...
271f736be9b3ca2b3c769c779666e5f4076a3a07
sapnashetty123/python-ws
/labquest/q_6.py
124
3.53125
4
inp = input("entr the sen:") for ch in inp: if ch in ['a','e','i','o','u']: inp=inp.replace(ch," ") print(inp)
29610cbd336eb940daff644ac9f28e6a747efcea
sumitpatra6/leetcode
/binary_tree_path_with_sum.py
949
3.71875
4
from binary_tree import BinaryTree # broot force algorithm # sum the path received from all the sub trees # this solution is no optimized for better runtime def path_with_sum(root, value): if root is None: return 0 path_from_root = count_path_with_sum(root, 0, value) path_from_left = coun...
835e634fd6d068ec8968cac65a7856bd665c9f22
AndreeaNenciuCrasi/Programming-Basics-Exercises
/Second SI week/binary_convertor.py
483
4
4
def decimal_to_binary(n): if(n > 1): decimalToBinary(n//2) print(str(n % 2) + ' ') def binary_to_decimal(n): decimal = 0 i = 0 while n != 0: a = n % 10 decimal = decimal + a * (2 ** i) n = n // 10 i += 1 print(decimal) def binary_decimal_convertor(numb...
3e492916112e095a0abacd25e930dd0aa8a8a027
Bitflip-CET/python-real-world
/gamePlayer.py
2,257
4.125
4
import random # Board Creation board = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] def printBoard(): print("\n") for row in board: print(*row) print("\n") # Win Check def winCheck(symbol): # Rows for row in range(3): if(board[row][0] == symbol and board[row][1] == symbol and board[row][2] ...
27b856a50b59ab681a644c49c60f1262ff5339bd
2470370075/all
/面向对象高级方法.py
2,400
3.546875
4
# class List(list): #改装 # # def append(self, obj): # if isinstance(obj,int): # super().append(obj) # else: # print('no') # # @property # def mid(self): # return self[len(self)//2] # # def clear(self): # s=input('...
8d09dc51d5bba7086f0c0c017feb6f3d1cdb80d7
anyadao/hw_python_introduction
/hw105.py
2,387
4.40625
4
# 102. Implement the below function: # # def is_valid_credit_card(credit_card): # """ # Given a value determine whether or not it is valid per the Luhn formula. # The Luhn algorithm is a simple checksum formula used to validate a variety of identification numbers, # such as credit card numbers. # ...
d5561750b687e4700645bf941e7c3e392daffd64
vaseem14/GUVI
/Nhello.py
120
3.6875
4
while True: try: a=int(input()) break except: print("Invalid input") break for x in range(a): print('Hello')
fadfbfac26fa71621b07e41ad6a72f2ea8b3b3eb
secginelif/python_cozumler
/faktöriyel.py
131
3.78125
4
sayi = int(input("Sayıyı giriniz:")) faktoriyel = 1 for i in range(1,sayi+1): faktoriyel = faktoriyel * i print(faktoriyel)
f6f7de9047a5b5ae4e693e4d7cd6516ce9144587
mai-codes/MITx-6.00.1x
/Week_1_-_Python_Basics/pset1.2.py
338
3.8125
4
balance = 42 annualInterestRate = 0.2 monthlyPaymentRate = 0.04 monthlyInterest = annualInterestRate/12 for i in range(12): minMonthPay = monthlyPaymentRate*balance monthlyUnpaidBal = balance - minMonthPay balance = monthlyUnpaidBal + (monthlyInterest*monthlyUnpaidBal) print('Remaining balance: ' + str(rou...
b48dfbf154912f03fbe4cb22849ad6a7b9f1d2dc
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/kindergarten-garden/0b4a92d57e814ecea837e7a774975279.py
1,615
3.828125
4
_DEFAULT_STUDENTS = [ 'Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Fred', 'Ginny', 'Harriet', 'Ileana', 'Joseph', 'Kincaid', 'Larry' ] _PLANT_MAP = { 'C': 'Clover', 'G': 'Grass', 'R': 'Radishes', 'V': 'Violets' } def _get_plant(letter): return _PLANT_MAP[...
51660f1b1678cc948fc4c9b7b89276a9f1a9a4d8
param-choksi/test
/calc.py
338
3.75
4
def add(a, b): """Addition Function""" return a + b def sub(a, b): """Subtraction Function""" return a - b def mul(a, b): """Multiplication Function""" return a * b def div(a, b): """Division FUnction""" if b == 0: raise ValueError('Can not divide with zero') else: ...
10c145648c4eb783aaa0530a2c62e4b67d129546
sahanasripadanna/word-frequency
/word-frequency-starter.py
3,049
4.125
4
#set up a regular expression that can detect any punctuation import re punctuation_regex = re.compile('[\W]') #open a story that's in this folder, read each line, and split each line into words #that we add to our list of storyWords storyFile = open('short-story.txt', 'r') #replace 'short-story.txt' with 'long-story.t...
b004a89f40d7249d75e1ebdb2e15a432397c04b3
mrudulamucherla/Python-Class
/2nd assign/leap yr, 115.py
550
4.28125
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 25 10:47:39 2020 @author: mrudula """ #Write a program to check whether year is leap year or not using conditional operator year = int(input("enter a year")) if (year%4)==0: if (year%100)==0: if (year%400)==0: print("{0}is a leap yea...
6212b2aa6b6c50e4649f954bb07ade9db68c01b2
cristobalvch/CS50-Harvard-University
/pset6/marioless/mario.py
190
3.890625
4
from cs50 import get_int while True: n = get_int('height ') if n >0 and n<=8: break for i in range(n): print(' ' * (n-i-1),end='') print('#' * (i + 1),end='\n')
d6b71bace59b23876dff51690de645ea8eb2ce8b
kaurjassi/pythonnew
/program1.py
344
4.15625
4
def greatest(a,b,c): if c < a > b : return a elif a < b > c : return b else: return c num1 = int(input("enter first number : ")) num2 = int(input("enter second number : ")) num3 = int(input("enter third number : ")) biggest = greatest (num1,num2,num3) print(...
69e30d078537f8dd97f0e6d38ef9847d726d897f
larcat/python_hard_way
/chp_7_8/chp7_ex1_py2.py
1,129
4.03125
4
#Prints print "Mary had a little lamb." #Prints with an inserted value print "Its fleece was white as %s." % 'snow' #Prints print "And everywhere that Mary went." #Prints "." 10 times in a row on the same line. print "." * 10 # what'd that do? -- String multiplication is like R #Let's assign some text to variables end...
9cbd51b5e266ba13e3c85da87dc260ea2701949e
madeibao/PythonAlgorithm
/PartB/Py逆置单链表3.py
675
3.984375
4
class ListNode(object): def __init__(self,x): self.val = x self.next = None class Solution: def reverseNodes(self, head: ListNode) -> ListNode: if head is None or head.next is None: return head pre = None while head: temp = head.next head.next = pre pre = head ...
6ada5df392d72d2e38a33b6dc1a165aca2b8bde6
sayalipawade/Python-Programs
/tictactoe.py
1,271
3.953125
4
import random board=[0,1,2,3,4,5,6,7,8,9] #Variables symbol=0 player=" " cell_count=0 maximum_cell=9 computer="O" user="X" class Tic_Tac_Toe: #Display board def print_board(self): print(board[1],'|',board[2],'|',board[3]) print('----------') print(board[4],'|',board[5],'|',board[6]) ...
c35cbee09b246ef466868f87889b4c89dbba71a0
furutuki/LeetCodeSolution
/剑指offer系列/剑指 Offer 41. 数据流中的中位数/solution.py
1,370
3.5
4
import heapq class MaxHeapObj(object): def __init__(self, val): self.val = val def __lt__(self, other): return self.val > other.val def __eq__(self, other): return self.val == other.val def __str__(self): return str(self.val) class MinHeap(object): def __init__(self): self.h = [] def hea...
2ebc50b7bfd5bbfaca381ea06c5ee7392b7ba9cf
djrff/rpi-enviro-phat
/sensors/display/motion.py
687
3.828125
4
#!/usr/bin/env python import sys import time from envirophat import motion, leds print("""This example will detect motion using the accelerometer. Press Ctrl+C to exit. """) threshold = 0.05 readings = [] last_z = 0 try: while True: motion_detected = False last_reading = motion.accelerometer()...
ddbca93f8dcb398b0b572dd9b0950d8fca1681ce
everbird/leetcode-py
/2015/Subsets_v0.py
532
3.734375
4
#!/usr/bin/env python # encoding: utf-8 class Solution: # @param {integer[]} nums # @return {integer[][]} def subsets(self, nums): nums.sort() return self._subsets(nums) def _subsets(self, nums): if len(nums) == 1: return [nums, []] last = nums[-1] ...
9d8d9f60574e8b12b7974c71e33dbe15c5c45e80
eognianov/PythonProjects
/PythonFundamentals/1.Functions, Debugging and Troubleshooting Code/8. Multiply Evens by Odds.py
457
3.96875
4
def get_multiple_of_even_and_odds(n): return get_sum_of_even_digits(n) * get_sum_of_odd_digits(n) def get_sum_of_even_digits(n): result = 0 while n != 0: result += n % 10 if (n % 10)% 2==0 else 0 n //= 10 return result def get_sum_of_odd_digits(n): result = 0 while n != 0: ...
6bfc8016c69f9ee29380b736b22d0e5076d16b57
udhayprakash/PythonMaterial
/python3/16_Web_Services/f_web_application/a_static_web_pages/d_addition_operation.py
1,326
3.53125
4
def fileToStr(fileName): # NEW """Return a string containing the contents of the named file.""" fin = open(fileName) contents = fin.read() fin.close() return contents # def main(): # person = input("Enter a name: ") # NEW # contents = fileToStr("helloTemplate.html").format(**locals()) # N...
e8e9d2430c56185eb6e7ed754623dcfdc9539a12
nicolascarratala/2020.01
/59098.Davara.Federico/05-trabajo/main.py
1,860
3.875
4
from producto import Producto from productoServices import ProductoService class Menu(): def menu_productos(self): print("""\n\t1 > Ver productos 2 > Agregar un Producto 3 > Modificar un Producto 4 > Eliminar un Producto 5 > Salir """) return int(input("\tSe...
8c30103b04e7720412dd349599a18d1eea199e57
kzhamada/test-repo
/__init__.py
194
3.546875
4
# -*- encoding: utf8 -*- if __name__ == "__main__": print("hello") print("hello, world") print("hello, world") print("hello, world2") for i in range(0, 10): print(i)
6d5dbcfb2736bc50f6f7683de28215d8be3e6870
sandeepkrishnagopalappa/self_study
/InstanceClassStatic.py
1,172
3.703125
4
class Sony: __division = 'Software Architecture Division' def __init__(self, fullname): self.fullname = fullname def email(self): self.first, self.last = self.fullname.split(' ') return self.first + '.' + self.last + '@sony.com' @classmethod def change_dept(cls, division)...
2764833c2d3062119861ce7aec18b66d2e0e52da
FVPukay/work-log
/work_log.py
1,030
3.75
4
import work_log_ui from textwrap import dedent if __name__ == '__main__': while True: work_log_ui.clear_screen() print(dedent("""\ WORK LOG What would you like to do? a) Add new entry b) Search in existing entries c) Quit program\ ...
c81350217ebf22aafde032cf78b9f1400b6c175f
HyperdriveHustle/leetcode
/parserURL.py
1,939
3.53125
4
# -*- coding:utf-8 _*- ''' 深信服2019春招笔试题1 题目描述: 一个百分号%后面跟一个十六进制的数字,则表示相应的ASCII码对应的字符,如 %2F 表示 /; %32 表示 2. %编码还可以进行嵌套,如 %%32F 可以解析为 %2F 然后进一步解码为 /。 输入: 第一行是一个正整数 T ,表示 T 个样例。 对于每个测试样例,输入一个字符串 s ,字符串不包括空白符且长度小于100,000. 输出: T 行,每行一个字符串,表示解码结果,解析到不能继续解析为止。 通过率:70% (还没发现问题出在哪) ''' def parserURL(url): if len(ur...
ec4d32bc7190b83f79f6df3bc554eb4aa7020c5d
hash6490/Python
/Inheritance.py
1,043
3.90625
4
class school_member: def __init__(self,name,age): self.name=name self.age=age print('Initialized schoolmember {}\n'.format(self.name)) def tell(self): print('Name:{} Age:{}\n'.format(self.name,self.age)) class Teacher(school_member): def __init__(se...
401f83bd2ca81883ae29555e92985d5e9bef2323
iceman951/Intro-Python-with-Sadhu-Coding-system
/Basic math and string/เข้ารหัสอย่างง่าย.py
274
3.78125
4
def inv(c): if 'a' <= c <= 'z': return chr(122 - ord(c) + 97) if 'A' <= c <= 'Z': return chr(90 - ord(c) + 65) return c text = str(input("Enter 5 characters: ")) output = ''.join(inv(c) for c in text) print("Encryption is",output.lower())
744f1e08a7e888c141997e295001cb61a24e1180
da-ferreira/uri-online-judge
/uri/1249.py
921
3.578125
4
lower = [ '', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm' ] upper = [ '', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', ...
743beeb4cec639a9254d584e3b289b6bad2df3d6
jatin556/Learn-Python
/DS_assignment11.py
1,542
3.890625
4
#DSA-Assgn-11 #This assignment needs DataStructures.py file in your package, you can get it from resources page from src.DataStructures import Queue def merge_queue(queue1,queue2): list1=[] list2=[] merged_queue=Queue(9) while not queue1.is_empty(): list1.append(queue1.dequeue()) ...
33c1e36b88aab2c08066693f70b00bd1e82c6c83
nin9/CTCI-6th
/Chapter10/11-peaksAndValleys.py
760
4.0625
4
from typing import List """ Time Complexity O(nlogn) Space Complexity O(1) """ # Approach 1 def sortPeakValley(arr: List[int]) -> List[int]: arr.sort() n = len(arr) for i in range(1,n,2): arr[i], arr[i-1] = arr[i-1], arr[i] return arr #################################################### """ Time Complexi...
75ed36add48a51ca5cfa6e7c17ace992a3c6b2fb
ab5tract/rosalind.info
/dna/pycount.py
597
3.515625
4
#!/usr/bin/env python from __future__ import print_function import sys def main(argv): file = argv[0] print('file = ' + file) f = open(file, 'r') seq = f.read().strip() print('seq = ' + seq) count = {} for char in list(seq): if not count.has_key(char): count[char] = 0 ...
84905f9f78000e21092e5797fdba0f5f4ec5f559
SauravAryal49/guessinggame
/guess_game.py
701
3.828125
4
game=["dog", "cat", "rabbit"] print("hint : three pet animals","and you have only five 'wrong' trials options") guess="" guess_number=0 number=[0,1,2] guess_result = False while (guess_number<5) and not(guess_result==True): guess=input("enter the guess") x=False for i in number: if (guess.strip()==g...
e9aaa5a2f17ef0afc64329ff018be2212d084be2
aacharyakaushik/i_code_in_python
/leetcode/Plus_one.py
469
3.65625
4
# -*- coding: utf-8 -*- """ @author: Kaushik Acharya """ from typing import List def plusOne(self, digits: List[int]) -> List[int]: # print(digits[-1]) # print(digits[:-1]) # print(set(digits)) if digits[-1] != 9: digits[-1] += 1 elif set(digits) == {9}: digits = [1] + [0] * len(d...
5448d35b84736e8459c4bcd8b3e3194eecacefac
RashRAJ/Raj_tech
/ping pong game.py
860
3.640625
4
import turtle wn = turtle.Turtle() wn = turtle.Screen() wn = turtle.bgcolor("black") tim = turtle.Turtle() tim.penup() tim.hideturtle() tim.goto(200, 200) tim.pendown() tim.color("pink") tim.width(10) tim.speed(10) for i in range(50): tim.forward(300) tim.left(170) tim1 = turtle.Turtle(...
2abd5204144abbd5b0373cb19506ff81bc8d5071
AnaGVF/Programas-Procesamiento-Imagenes-OpenCV
/Ejercicios - Enero25/Funciones_1.py
763
3.859375
4
# Nombre: Ana Graciela Vassallo Fedotkin # Expediente: 278775 # Fecha: 25 de Enero 2021. # Podemos regresar una expresion def sum(var1, var2, var3): return var1 + var2 + var3 print(sum(19, 20, 30)) print() print() # Función obtenga datos def obtener_datos(): return "python", "basico", "clase" curso, nivel,...
3df4a4b42358e8e0ce96b5cd8a5109fd866e52fe
beidou9313/deeptest
/第一期/成都-MFC/task002/kuaixuepython3/python3_tuple.py
1,995
3.546875
4
# -*- coding:utf-8 -*- __author__ = 'TesterCC' __time__ = '18/1/11 16:31' """ tuple https://mp.weixin.qq.com/s?__biz=MzI0NDQ5NzYxNg==&mid=2247484018&idx=1&sn=44f10b570f3136e584b0935882a9be0b&scene=19#wechat_redirect """ tuple1 = (u'MFCTest', u'测试开发', u'1') tuple2 = (1, 2, 3, 4, 5) tuple3 = ("a", "b", "c", "d", "e")...
26de046c4a8b33b624a8e44a7332f122d08dd8f6
Dmitrygold70/rted-myPythonWork
/Day04/ex23_loops.py
307
3.78125
4
x = [1, 2, 702, 704, 3, 4, 804, 806, 808] print("before removing:", x) print("sorted to help us see:", sorted(x)) # if a number is greater than 300 and even, remove it. i = 0 while i < len(x): if x[i] > 300 and x[i] % 2 == 0: del x[i] continue i += 1 print("after removing:", x)
1409736d7a3cb4be4639ea1fab7537c8474ed023
Tieshia/RESTAPIs_udemy
/if_statements.py
874
4.125
4
# should_continue = True # if should_continue: # print("Hello") ''' known_people = ["John", "Anna", "Mary"] person = input("Enter the person you know: ") if person in known_people: print("You know {}.".format(person)) else: print("You don't know {}.".format(person)) ''' ## Exercise def who_do_you_know():...
f4741aceb7e193f60f8113573610318bf39ca431
ningxu2020/python201
/funnylist3.py
558
4.0625
4
class FunnyList(list): def __eq__(self, other): """Check for equality without concern for order. If the sorted versions of two FunnyLists are the same, then we deem the FunnyLists to be the same.""" return sorted(self) == sorted(other) def __add__(self, thing): ...
20e7ab59626f609fcdb463114803e7ae849ae467
kren1504/Training_codewars_hackerrank
/dir_reduction.py
791
3.71875
4
""" 23 minutos def dirReduc(arr): dir = " ".join(arr) dir2 = dir.replace("NORTH SOUTH",'').replace("SOUTH NORTH",'').replace("EAST WEST",'').replace("WEST EAST",'') dir3 = dir2.split() return dirReduc(dir3) if len(dir3) < len(arr) else dir3 """ def dirReduc(arr): opposite = [["NORTH", "SOUTH"],[...
948530f99a1939f0104abfcb0c26b9a44a091a74
tjmann95/ECEC
/Homework 8/pi_series.py
1,814
4.09375
4
# A generator to find pi. import math print "1. A neverending series to find pi. But it converges really, really slowly." def pi_series(): sum = 0 i = 1.0 # Guarantees division will use floats. j = 1 while True: # The iterator will be infinite! sum += j / i yield 4 * sum i += ...
b539e45709d1495cf8c5966ff65d0f802ec843c3
ksentrax/think-py-2e--my-solutions
/exercise10/exercise10-7.py
386
3.96875
4
"""This script checks the list for duplicates.""" def has_duplicates(li): """Checks if there is any element that appears more than once. :param li: list :return: boolean value """ li.sort() for i in range(len(li)-1): if li[i] == li[i+1]: return True return False if _...
f0d33efd07e1c2168b4b4aea330c0b24d04bf076
samantadearaujo/python
/bioinformatica/listas.py
479
3.71875
4
lista = [32,'Samanta', 4.000] print(lista) print(len(lista)) for e in range(len(lista)): print(lista[e]) lista1 = [1,2,3,4,5,6] lista1.append(7) print(lista1) lista2 = lista +lista1 print(lista2) lista3 = [1,2,3,4,5,6,7,8] removido = lista3.pop(0) print(removido) lista4= [1,2,3,4,5,6,7,8,9] lista4.remo...
0323db2f9633e59fbaccef9c6c168e52bb39ef72
Gaurav-Patil-10/Snake_Game
/snake.py
4,759
3.84375
4
import pygame import random pygame.init() # screen dimensions screen_width = 800 screen_height = 600 # colors black = (0 ,0,0) white = (255 , 255 , 255) red = (255 ,0 , 0) # Game window game_window = pygame.display.set_mode((screen_width , screen_height)) pygame.display.set_caption("SNAKE") pygame.display.upda...
5cce2bd0df081f2f32ab4f5281a365c6d5b855de
snowraincloud/leetcode
/460.py
6,077
3.984375
4
# 设计并实现最不经常使用(LFU)缓存的数据结构。它应该支持以下操作:get 和 put。 # get(key) - 如果键存在于缓存中,则获取键的值(总是正数),否则返回 -1。 # put(key, value) - 如果键不存在,请设置或插入值。当缓存达到其容量时,它应该在插入新项目之前,使最不经常使用的项目无效。在此问题中,当存在平局(即两个或更多个键具有相同使用频率)时,最近最少使用的键将被去除。 # 进阶: # 你是否可以在 O(1) 时间复杂度内执行两项操作? # 示例: # LFUCache cache = new LFUCache( 2 /* capacity (缓存容量) */ ); # cache....
c40f02ed6ae09320221ce9d5f8ebefd7b38e0563
syedmuhammadhassanzaidi/CampaignMonitor
/CampaignMonitorTechTask/PythonScripts/task4.py
455
4.03125
4
def find_duplicates(input): dup_list = [] counter = 1 for i in input: num_rep = input.count(i) if (num_rep >= counter): counter = num_rep dup_list.append(i) return set(dup_list) """ Test cases """ input = [5, 4, 3, 2, 4, 5, 1, 6, 1, 2, 5, 4] #input = [1, 2, 3, 4,...
3ca6af54de82b2114830534eaa9ebe8965073866
zexiangzhang/algorithmAndDataStructure
/data_structure/graph/depth_first_search.py
2,638
3.671875
4
# depth first search # adjacency matrix from adjacency_matrix import AdjacencyMatrix def depth_first_search(graph, i): global vertex_visited vertex_visited[i] = True print(graph.get_vertex_value(i)) for j in range(graph.get_number()): if graph.has_arc(i, j) and not vertex_visited[j]: ...
189158a0718e676060467288f21f9e376f009062
je-castelan/Algorithms_Python
/Python_50_questions/3 Binary Search/binary_tree.py
1,692
3.984375
4
def binarySearchRecursive(arr,obj,initial,final): middle = (initial+final) // 2 if arr[middle] == obj: return middle elif initial > final: return -1 elif arr[middle] < obj: return binarySearchRecursive(arr,obj,middle + 1,final) else: return binarySearchRecursive(arr...
123a3365a015f1ce2bd77f6d907784e6f7759e18
MiroVatov/Python-SoftUni
/Python Advanced 2021/EXAMS_PREPARATION/additional_exams/02_presents_delivery.py
4,758
3.671875
4
def nice_kids_count(matrix, NICE_KID_HOUSE): nice_kids = 0 for row in range(len(matrix)): for col in range(len(matrix[row])): if matrix[row][col] == NICE_KID_HOUSE: nice_kids += 1 return nice_kids def santa_starting_position(matrix, santa): for row in ra...
34c8e2266fe8a0a8cf652ef25c67c8ed7ead19a2
class-archives/ENGR-141
/Fall-2015/Post-Activities/Python-1/task2.py
1,082
4
4
# Activity: Python 1 Post Activity # File: Py1_PA_Task2_katherto.py # Date: September 17, 2015 # By: Kathryn Atherton # katherto # Section: 4 # Team: 59 # # ELECTRONIC SIGNATURE # Kathryn Atherton # The electronic signature above indicates that the program # submitted for evaluation is my individual work. I have # a g...
096c8ff0774d84cfe87080eb15453b6464fca46a
SHGITHUBSH/Basic-Python
/source/Basic-If Statement.py
581
4.34375
4
#If Statements Taller_than_the_other_gender = True More_muscular = False Grow_beard = True if Taller_than_the_other_gender or More_muscular or Grow_beard: print("You have possibility to be a male.") elif Taller_than_the_other_gender and not More_muscular and not Grow_beard: print("You might be a girly man.") el...
1b06fa212a883473b9c055674aeff0076b6518f8
nf-core/ampliseq
/bin/filt_codons.py
3,689
3.640625
4
#!/usr/bin/env python3 ##### Program description ####### # # Title: Filtering ASVs with stop codons # # Author(s): Lokeshwaran Manoharan # # # # Description: The ASVs are filtered if they contain stop codons in the reading frame specified. # # List of subroutines: # # # # Overall procedure: using functions and dictiona...
944fa8f12006ccda60329d6b24a1222fe093cddc
Davidxswang/leetcode
/easy/821-Shortest Distance to a Character.py
1,133
3.875
4
""" https://leetcode.com/problems/shortest-distance-to-a-character/ Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string. Example 1: Input: S = "loveleetcode", C = 'e' Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0] Note: S string length...
712cedf8d8fb7674bf198dae99974f5006904329
DariaPetrovaa/mipt_python
/w6/7.py
1,934
4.25
4
from math import sqrt #Координаты вектора вводятся в виде строки "x,y,z" class Vector: def __init__(self, a): if type(a) is list: a = "".join(map(str,a)) x, y, z = a.split(',') x = int(x) y = int(y) z = int(z) self.x = x self.y = y self.z...
e7f7926e193a9f4d7436384d75467656cbb9f045
weiyang-1/sort_practice
/Insert_sort.py
821
3.65625
4
# -*- coding: utf-8 -*- """ @Created: 2020/10/13 13:50 @AUTH: MeLeQ @Used: pass """ from tools import gene_random_list def insert_sort(random_list: list) -> list: """ 插入排序 保证前面的队列是一个有序的 每次从后面找一个插入到有序的里面去 当后面的数比前面小才需要进行插入 否则跳过当前数 :param random_list: :return: """ length = len(random_list) ...
d480263ae734088e84a8f207e420f2c85babbf91
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/06_PrintListInReversedOrder/print_list_in_reversed_order.py
1,152
4.40625
4
""" 面试题 6:从尾到头打印链表 题目:输入一个链表的头结点,从尾到头反过来打印出每个结点的值。 """ class Node: def __init__(self, x): self.val = x self.next = None def print_list_reverse(node) -> list: """ print_list_reverse(Node) Print a linklist reversedly. Parameters ----------- Node: Node Returns ...
1a621f52b96e4d79b6eef9313d783d648719d97a
TSamCode/Algorithms
/palindrome.py
680
4.1875
4
# Function to see if a string is some permutation of a palindrome from collections import Counter def permPalindrome(string): # creates a list of characters stringChars = [char for char in string.lower() if char.isalpha()] # create a dictionary containing the count of each character in the string charC...
69bb9b6610a91b92c209ced84b91b4ae63d4edd8
deesaw/PythonD-04
/Exception Handling/46_except2.py
425
4.0625
4
while True: try: x = input("Please enter a number: ") y = input("Please enter a number to divide: ") num= int(x)/int(y) print("Result: ",num) break except ValueError: print("Oops! That was not a valid number. Try again...") except ZeroDivisionError as err: ...
33c4711b363b20b4b9c1a0c78009d627ebb66a8a
Cameron-Calpin/Code
/Python - learning/Looping/loop-control.py
358
4.3125
4
list = [1,2,3,4,5,6,7,8,9] # the loop iterates by one until it hits 7; then stops. for int in list: if int == 7: break else: print(int, end=' ') print('\n') # once the loop hits 7, it will continue to 9. # after the loop has finished, the else will print for int in list: if int == 7: continue else: print...
78ed63468ebe0aa5aea8be76b0f018e07b8b0c76
fsym-fs/Python_AID
/month01/day07_function+for_for/test/test01.py
868
3.53125
4
""" test01 1.["齐天大圣","猪八戒","唐三藏"]--->key:字符,value:字符长度 2.["张无忌","赵敏","周芷若"] [101,102,103]-->{"张无忌":101..} 3.将练习二的字典的键与值颠倒 4. 骰子 1--6 骰子 1--6 骰子 1--6 将三个骰子的组合数存入列表 """ a = {'cid': 101, 'count': 1} print(a['cid']) # if 101 in a['cid'] : # print("44") # print(a[1]) try: xy...
e4a288da43c70693fed19c04566de6c80d267743
Oshalb/HackerRank
/insertionp2.py
374
3.859375
4
# Insertion Sort - Part 2 def insertion_sort(n, a): for i in range(1, n): j = i while j > 0 and a[j-1] > a[j]: a[j], a[j-1] = a[j-1], a[j] j -=1 print(*a) if __name__ == "__main__": size_of_list = int(input()) number_list = list(map(int, input().rstrip().sp...
dd2a93e18a3ddf756e13ffefa065a56faef4098f
haewon-mit/Syntax-Analysis
/AC-IPSyn/source/extractPhrases.py
730
3.5625
4
#Purpose: Extract phrases from a parse def extractPhraseLastBracket(parse): i=len(parse) stack=[] for j in range(i-1,-1,-1): if parse[j]==')': stack.append(')') elif parse[j]=='(': if len(stack)!=0: stack.pop() if len(stack)==0: #print parse[j:] return parse[j:] if len(stack) !=0: return ...