blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
25920bf9d686f46dd90d56885d4af6c7fa30f868
emassey2/-AI_HW
/AI_HW3_CODE/explorer_merging_attemp.py
17,021
3.53125
4
#!/usr/bin/env python import os import time import datetime import sys # change string color in terminal taken from: # https://stackoverflow.com/questions/2330245/python-change-text-color-in-shell def hilite(string, status, bold): attr = [] if status: # green attr.append('32') else: ...
85d4719fc78de0659d696116ce229b601010b852
MariumAli/S-expression-calculator
/calc.py
5,134
3.796875
4
import sys from functools import reduce from collections import OrderedDict ALLOWED_FUNCTIONS = ['add', 'multiply'] MAX_CAPACITY = 3 ''' LRU Cache for storing pre-computed expression values. ''' class LRUCache: def __init__(self, capacity: int): self.cache = OrderedDict() self.capacity = capacity...
576581b2f889224be6c9ac366124b5093f171099
darkviper999/SmartPlanet
/BACKUP/test.py
408
3.578125
4
##myfile = open("test.txt","r") ##text = [] ##nowe = 0 ##for line in myfile: ## text.append(line) ## ##def render(now): ## if text[now] != '\n': ## print(now,text[now],end = '') ## if now+1 < len(text): ## if text[now+1] != '\n': ## now = render(now+1) ## else: ## ret...
6b31930f763691bd3f0c17879d152c39131cf6e5
03Viraj/Python
/Vikrant/tricks.py
632
4.09375
4
# How to merge two dictionaries in python x = {'a':1, 'b':2, 'c':3} y = {'b':3, 'c':8} z = {**x,**y} print(z) # # Different ways to test multiple flags in python # x,y,z = 1,0,1 # # if x == 1 or y == 1 or z == 1: # print("passed") # # # if 1 in (x,y,z): # print("passed") # # if x or y or z: # print(...
001e43dc15ec8b7175f41042aebf075cfd87c8be
Lievi77/Bioinformatics-Problems
/10Finding Restriction Sites/common_methods.py
1,705
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Common Methods in Bioinformatics to avoid re coding Created on Sat May 2 10:46:47 2020 @author: lev """ #method 1: process dna information in FASTA format # # FASTA FORMAT: # # >DNA_NAME # DNA_STRING # STRING MAY OCCUPY MORE THAN 1 LINE #WORKS WELL def process_dn...
79ca084f1ceea0768b397848f7a09d64c19101d8
Lievi77/Bioinformatics-Problems
/8Finding a Motif in DNA/motif_detector.py
960
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Problem 8: finding a Motif in DNA Created on Sun Apr 26 13:35:19 2020 @author: lev """ #-----------------------methods------------------------------- def occurences(s, t): #finds all occurences of substring t on s indeces = [] for i in range(len(s)): ...
d42c35cf40853e6e1b60742c5c8aadf0a840d573
returnzero1-0/logical-programming
/sp-7.py
315
4.21875
4
# Python Program to Read Two Numbers and Print Their Quotient and Remainder ''' Quotient by floor division // Remainder by mod % ''' num1=int(input("Enter number 1 :")) num2=int(input("Enter number 2 :")) quotient=num1//num2 remainder=num1%num2 print("Quotient is :",quotient) print("Remainder is :",remainder)
5657ba91299a646653890dda79e7c3e3d026f955
returnzero1-0/logical-programming
/sp-1.py
282
4.03125
4
#add 2 nos without using temp variable num1=int(input("enter the num1 :")) num2=int(input("enter the num2 :")) print("before swap num1",num1) print("before swap num2",num2) num1=num1+num2 num2=num1-num2 num1=num1-num2 print("after swap num1",num1) print("after swap num2",num2)
a9356775b5a368568b29edc3b03d8a7f0e4a0a94
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/32_01_PrintTreeFromTopToBottom/print_tree_from_top_to_bottom.py
1,166
4.25
4
""" 面试题32(一):不分行从上往下打印二叉树 题目:从上往下打印出二叉树的每个结点,同一层的结点按照从左到右的顺序打印。 """ class BinaryTreeNode: def __init__(self, val): self.val = val self.left = None self.right = None def connect_binarytree_nodes(parent: BinaryTreeNode, left: BinaryTreeNode, ...
6dba021d3bf0cebc1b129b74dc8cafb4322b1f63
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/47_MaxValueOfGifts/max_value_of_gifts.py
1,619
3.78125
4
""" 面试题 47:礼物的最大价值 题目:在一个 m×n 的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值 (价值大于 0)。你可以从棋盘的左上角开始拿格子里的礼物,并每次向左或 者向下移动一格直到到达棋盘的右下角。给定一个棋盘及其上面的礼物,请计 算你最多能拿到多少价值的礼物? """ def get_max_value1(matrix: list) -> int: """ Parameters ----------- Returns --------- Notes ------ """ if not matrix or no...
21b68ffc8a72b94ee8417b06e7f7a7394b7eb06c
hscspring/The-DataStructure-and-Algorithms
/Stack/stack.py
1,016
3.65625
4
class Stack: def __init__(self): self.data = [] def push(self, v) -> None: self.data.append(v) def is_empty(self) -> bool: return len(self.data) == 0 def pop(self) -> int: if self.is_empty(): print("error") return return self.data.pop()...
19024b911f96130c78a8d053d84758b54b69c20d
hscspring/The-DataStructure-and-Algorithms
/Greedy/406-queue_reconstruction_by_height.py
523
3.609375
4
people = [[7,1],[7,0],[4,4],[6,1],[5,2],[5,0]] # [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] def func(people): peopledct = {} for i in range(len(people)): p = people[i] if p[0] in peopledct: peopledct[p[0]].append((p[1], i)) else: peopledct[p[0]] = [(p[1], i)] ...
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 ...
0f94f3e1030812bf63e75d095d6a5818cb71a030
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/52_FirstCommonNodesInLists/first_common_nodes_in_lists.py
1,397
3.78125
4
""" 面试题 52:两个链表的第一个公共结点 题目:输入两个链表,找出它们的第一个公共结点。 """ def lst2link(lst): root = Node(None) ptr = root for i in lst: ptr.next = Node(i) ptr = ptr.next ptr = root.next return ptr class Node: def __init__(self, val): self.val = val self.next = None def find_first_...
926fd063f8aee6ef41c37c06e24f0ba0ce0155f9
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/43_NumberOf1/number_of1.py
2,096
3.59375
4
""" 面试题 43:从 1 到 n 整数中 1 出现的次数 题目:输入一个整数 n,求从 1 到 n 这 n 个整数的十进制表示中 1 出现的次数。例如 输入 12,从 1 到 12 这些整数中包含 1 的数字有 1,10,11 和 12,1 一共出现了 5 次。 """ def number_of_one(n: int) -> int: """ how many ones between 1 to n. Parameters ----------- Returns --------- Notes ------ given number n, w...
17bb44470f37f1077e3d05ebf1281dd49e24e9f1
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/36_ConvertBinarySearchTree☆/test_convert_binary_search_tree.py
4,407
3.5625
4
from convert_binary_search_tree import convert_bst_to_sorted_doubly_linked_list from convert_binary_search_tree import convert_bst_to_sorted_doubly_linked_list_with_inorder from convert_binary_search_tree import BSTNode, travel_linked_list, connect_bst_nodes def test_full_binary_tree1(): # 10 # 6 ...
15ed731880770774cd96b681393d44913d512c2d
hscspring/The-DataStructure-and-Algorithms
/Graph/base.py
500
3.890625
4
# 二叉树 def traverse_binary_tree(root): if not root: return traverse_binary_tree(root.left) traverse_binary_tree(root.right) # 多叉树 def traverse_multiway_tree(root): if not root: return for child in root.children: traverse_multiway_tree(child) # 图 def traverse_graph(graph,...
fd8f8bb43ed0602c7c7d022d9113e0e1b2707462
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/58_02_LeftRotateString/left_rotate_string.py
1,034
4.125
4
""" 面试题 58(二):左旋转字符串 题目:字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部。 请定义一个函数实现字符串左旋转操作的功能。比如输入字符串 "abcdefg" 和数 字 2,该函数将返回左旋转 2 位得到的结果 "cdefgab"。 """ def left_rotate_string(s: str, index: int) -> str: """ Parameters ----------- Returns --------- Notes ------ """ if not s: re...
d30ef4fe2f71d84f33e76247a4952772ccbbbdb1
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/55_02_BalancedBinaryTree/balanced_binary_tree.py
2,994
4.25
4
""" 面试题55(二):平衡二叉树 题目:输入一棵二叉树的根结点,判断该树是不是平衡二叉树。如果某二叉树中 任意结点的左右子树的深度相差不超过1,那么它就是一棵平衡二叉树。 """ class BSTNode: """docstring for BSTNode""" def __init__(self, val): self.val = val self.left = None self.right = None def connect_bst_nodes(head: BSTNode, left: BSTNode, right: BSTNode) -> BSTN...
6d50fd55e2ed14fe45ca4a8891f4dc69baf1b220
hscspring/The-DataStructure-and-Algorithms
/LeetCode/23-Merge-k-Sorted-Lists/merge_k_sorted_lists.py
2,935
3.78125
4
# Definition for singly-linked list. from functools import wraps import time from typing import List def timethis(func): @wraps(func) def wapper(self, *args, **kwargs): start = time.time() res = func(self, *args, **kwargs) end = time.time() print("cost time: ", end - start) ...
a6c597a8d79fb7911253408904a183c5b72bd6bd
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/58_01_ReverseWordsInSentence/reverse_words_in_sentence.py
1,697
4.0625
4
""" 面试题 58(一):翻转单词顺序 题目:输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。 为简单起见,标点符号和普通字母一样处理。例如输入字符串 "I am a student.", 则输出 "student. a am I"。 """ def reverse_sentence(s: str) -> str: """ Parameters ----------- Returns --------- out: Reversed words in s. Notes ------ """ reverse = "...
95bb0663b6435d33bef9c73e11d40ffc1483883c
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/66_ConstuctArray☆/construct_array.py
1,135
3.640625
4
""" 面试题 66:构建乘积数组 题目:给定一个数组 A [0, 1, …, n-1],请构建一个数组 B [0, 1, …, n-1],其 中 B 中的元素 B [i] =A [0]×A [1]×… ×A [i-1]×A [i+1]×…×A [n-1]。不能使用除法。 """ def build_production_array(arr: list) -> list: """ Parameters ----------- Returns --------- Notes ------ """ if not arr: retu...
b705e8902456262f147ec1987a250cf645e330da
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/46_TranslateNumbersToStrings/translate_numbers_to_strings.py
1,658
3.75
4
""" 面试题 46:把数字翻译成字符串 题目:给定一个数字,我们按照如下规则把它翻译为字符串:0 翻译成 "a",1 翻 译成 "b",……,11 翻译成 "l",……,25 翻译成 "z"。一个数字可能有多个翻译。例 如 12258 有 5 种不同的翻译,它们分别是 "bccfi"、"bwfi"、"bczi"、"mcfi" 和 "mzi"。请编程实现一个函数用来计算一个数字有多少种不同的翻译方法。 1 2 2 5 8 1 22 5 8 1 2 25 8 12 2 5 8 12 25 8 """ def get_translation_count1(num: int) -> int: """ Para...
757fb7a9129c77a8639ebaa1c424e7144f7100fe
zxteloiv/TrialBot
/trialbot/training/updater.py
2,290
3.59375
4
class Updater: """ The most important function of the updater is designed to handle the life term of iterators. A TrialBot is obliged to control the component objects, including runtime args, hyper-parameters, models, datasets, translators, vocab, and so on. It is a easy and straightforward bundle...
b8cb53af21db9186eb41a5586e85ad81347e4a70
Tijanif/hackerrankPyt
/Introduction/division.py
295
3.90625
4
if __name__ == '__main__': a = int(input()) b = int(input()) c = a // b # Divide left operand by the right one (always results into float) d = a / b # Floor division - division that results into whole number adjusted to the left in the number line print(c) print(d)
6bc01fd0034c98aaba1d2f87540e3204d5accd8c
lovemalus/Python
/Prime_numb.py
250
3.8125
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- import math L = range(0,101) def isprime1(n): if n<= 1: return False for i in range(2,int(math.sqrt(n)) + 1): if n % i == 0: return False return True y = filter(isprime1, L ) print y
273b4e7f15c33f681ab2da02b9c9074ace424f7c
lovemalus/Python
/random11.py
614
3.953125
4
import random guesses_made=0 name=raw_input('Hello! What is your name?\n') number=random.randint(1, 20) print 'Well,{0},I am thingking of a number between 1 and 20.'.format(name) while guesses_made <6: guess= int(raw_input('Take a guess:')) guesses_made += 1 if guess <number: print 'Your guess i...
95cbf6c1bb669a525870ce3e98d22bb5cf5b8ae3
lovemalus/Python
/calc_sum_0.py
153
3.671875
4
#!/usr/bin/env python #-*- coding: utf-8 -*- def calc_sum(*args): ax = 0 for n in args: ax = ax + n return ax y = calc_sum(1,2,3,4,5) print y
839f847e5785f1275e4dad2b950c868bc2d5c1e1
JeffKatzy/flask-coursework
/notes.py
238
3.859375
4
# infocomm team = 'eagles' print(team) # assign a variable to a string # write a function that says your name # write a function that takes an argument # doing something def sayHello(aGoodName): print('hello my name is' + aGoodName)
41675fce75e194df97387e986f9048e97968b614
antmelon/lab2-temporary
/lab2.py
619
3.734375
4
import os def main(): weeks = int(input("How many weeks: ")) print(type(weeks)) classes = int(input("How many classes: ")) print(type(classes)) tuition = int(input("How much is tuition: ")) print(type(tuition)) cost_per_week = ((tuition / classes) / weeks) print("Cost per week:", cost_pe...
55ffff92327e8de2093937623f78cd5e42b87c18
ranjiewwen/Everyday_Practice
/Python/Exe04.py
1,577
3.84375
4
# coding: utf-8 var1 = 1 var2 = 10 del var1 #var3=ceil(4.3) var3='hello world!' var4='Python Rundo!' print 'var1[0]:',var3[0] print 'var2[1:5]:',var4[1:5] var5='hello world!' print '更新字符串:-',var5[:6]+'Runoob' a='hello' b='python' print a+b print 'H' in a print 'M' not in a print r'\n' print 'my name is %s and w...
158fd2aa3a684e5c7eb69ed32a161fd2c701fdeb
ranjiewwen/Everyday_Practice
/Python/Exe02.py
1,949
3.6875
4
# coding: utf-8 #算术运算符 a=21; b=10; c=0; c=a+b; print "1-c的值为:",c c=a-b print "2-c的值为:",c c=a*b print "3-c的值为:",c c=a/b print "4-c的值为:",c c=a%b print "5-c的值为:",c #修改变量a,b,c a=2 b=3 c=a**b print "6-c的值为:",c a=10 b=5 c=a//b print "7-c的值为:",c #python 比较运算符 if a==b: print "1-a等于b" else: print "1-a不等于b" if a!=b:...
533516eaf7b44a007b79a9f00e283bfd865ad017
friedaim/ITSE1359
/PSET4/PGM1.py
1,934
4.125
4
# Program to calculate loan interest, # monthly payment, and overall loan payment. def calcLoan(yrRate,term,amt): monthRate = yrRate/12 paymentNum = (pow(1+monthRate,term)*monthRate) paymentDen = (pow(1+monthRate,term)-1) payment = (paymentNum/paymentDen)*amt paybackAmt = payment*term totalInte...
077c14cf78713e63ab9aec2351d4ea381ab4adf8
sayan1995/Competitive-Coding-7
/problem1.py
2,291
3.625
4
''' Binary Search: Time Complexity: O(nlog(high-low)) m is rows Space Complexity: O(1) Did this code successfully run on Leetcode : Yes Explanation: Create a count of all elements of which are less than mid. low initially is first element and high is the last element in the matrix, count all elements less than mid, if ...
2e66cb0dc376fbe161c085d229e2e6d0c20f761b
skathii/blackjack
/Blackjack.py
7,420
3.65625
4
import random import time import sys card_values = {"A":11, "2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8, "9":9, "10":10, "J":10, "Q":10, "K":10} options = ["Hit", "Stand"] class Card: def __init__(self, suit, val): self.suit = suit self.val = val def view(self): print...
425d1e74af2c7028b3d6a20227b73a3bbd37adf8
yamashita-ki/at_coder
/abc144d.py
197
3.6875
4
import math a,b,x = map(int, input().split()) v = a*a*b if 2*x <= v: ans = math.degrees(math.atan(a*b*b/(2*x))) print(ans) else: ans = math.degrees(math.atan((2*a*a*b-2*x)/a**3)) print(ans)
ccee65f5694c85db72eab0fdb257e46ee4527c27
karnapratyush/Python-Password-manager
/hashing.py
1,150
3.640625
4
import random from encrypt import * # creating a function to hash the login password def hash(word): x=random.randint(20,128) y=random.randint(20,128) z=random.randint(20,128) hashed='' for i in word: l=ord(i) p1=l**x p1%=128 p2=l**y p2%=128 p3=in...
f2c92419aff632faa8e24bc1ee6236ee5b6fc08d
karnapratyush/Python-Password-manager
/decrypt.py
348
3.734375
4
def decrypt_password(word): decrypted_word='' key=ord(word[-1])-96 for i in word[:-1]: x=(ord(i)+key) decrypted_word+=chr(x) return decrypted_word def decrypt_name(word): original='' for i in word: x=ord(i)-97 x-=100 x%=26 x+=97 original+...
2b0d55cc3579738aa5e6f37dd3c7d30ef6e38dfa
Elsword24/Python-Objet-B1
/plateau_aff.py
1,090
3.703125
4
def plateau_affichage(plateau,taille,plateau_list,Htaille,plateau_lists = []) : L=taille H=taille for x in range (0,L+1) : print (str(x),(' '), end='') for y in range (0,H+1) : if y==0 : print (' ') else : print (str(y), ) for y in range(H): ...
f3cba253fd0bcb0a1ba046d021a32d92173eb3f8
SahilTikale/UserRecommendationSystem
/03-MovieNeighbors.py
831
3.515625
4
#Movie Recommendation System for data mining project #Preprocessing steps #4.) Calculating similarity between users # for every movie fetching the users list that have rated it. import csv import sys import re import string from scipy import spatial f = open(sys.argv[1]) flines = f.readlines() wf = open("movieNeigh...
5604337f8e1552e7f5fd858a17e0e6db1cf25a12
hamoudaabdrahmen/holbertonschool-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
330
3.796875
4
#!/usr/bin/python3 """This module contains one function island_perimeter(grid):""" def island_perimeter(grid): """Returns the perimeter of the island described in grid""" prm = 0 for row in grid: for nb in row: if nb == 1: prm += 2 if prm > 0: prm += 2 r...
532eb7059007dab0ce39b0e7a53559d12c696d86
mjadair/intro-to-python
/functions/arguments.py
1,473
4.375
4
# Navigate to functions folder and type python arguments.py to run # * 🦉 Practice # ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/" # ? Define a function "sayHello" that accepts a "name" parameter. It should return a string of 'Hello (the name)!' # ? Call and print the result ...
485f7f408cbe0ba4f7ed22f940dfe1da28fc18b4
mjadair/intro-to-python
/control-flow/loops.py
1,190
4.1875
4
# * ----- FOR LOOPS ------ * # ! Navigate to the directory and type `python loops.py` to run the file # * 🦉 Practice # ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/" # ? Write a for loop that prints the numbers 0 - 10 # ? Write a for loop that prints the string 'Hello W...
c567896b4fb1563fcd410d94d50a7f6e864e9671
mjadair/intro-to-python
/control-flow/conditional-operators.py
667
3.59375
4
# * ----- AND/OR, NOT ------ * # * 🦉 Practice # ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/" # ? Comment back in the variable declarations that have been commented out below # milkAdded = True # waterTemp = 100 # brewed = True # ? Write if statements to deal with followin...
afca7c31b72f51f3cf3b96c33dcf0e9da76a4f39
Zahidsqldba07/Python_Practice_Programs
/college/s3p4.py
235
4.1875
4
# WAP to find largest and smallest value in a list or sequence nums = [] n = int(input("How many numbers you want to input? ")) for i in range(n): nums.append(int(input(">"))) print("Max: %d\nMin: %d" % (max(nums), min(nums)))
e94934e06dfc1728e3a2d8da660acd41a9358b1b
Zahidsqldba07/Python_Practice_Programs
/college/t_test.py
101
3.6875
4
test = int(input("Enter something: ")) if test == 1: print("its working!") print("Hello", test)
1d91eda9d5e992d2ba82dd74cec9586b5d0c58b4
Zahidsqldba07/Python_Practice_Programs
/college/p7.py
279
4.375
4
# WAP to read a set of numbers in an array & to find the largest of them def largest(arr): return max(arr) arr = list() num = input("How many elements you want to store? ") for i in range(int(num)): num = input("Num: ") arr.append(int(num)) print(largest(arr))
6c39bdf7ab868326265d9724569004623651d493
Zahidsqldba07/Python_Practice_Programs
/college/s2p7.py
269
4.125
4
# WAP that demonstrates the use break and continue statements to alter the flow of the loop. while True: name = str(input("Name: ")) if name.isalpha(): print("Hello %s" % name) break else: print("Invalid name.\n") continue
b237f52ce5495587b91a32e80c9ab9645fde6c1d
Zahidsqldba07/Python_Practice_Programs
/college/2_9.py
2,585
4.15625
4
relation=raw_input('Enter the relationship:') name=raw_input('Enter the name:') if relation=='parents' and (name=='madd' or name=='sally'): print 'parents are cathy and don' elif relation=='parents' and name=='sarah' : print 'parents are frank and jill' elif relation=='parents' and (name=='frank' or name=='cath...
b2cece558ed3391220af52e1e13b2329bca82ab3
Zahidsqldba07/Python_Practice_Programs
/college/s8p2.py
358
4.1875
4
# Define a class name circle which can be constructed using a parameter radius. # The class has a method which can compute the area using area method. class Circle: radius = 0 def __init__(self, radius): self.radius = radius def displayArea(self): print("Area:", (3.14 * (self.radius ** 2...
1905d855a2b37259c47229175eefec2625df5482
Zahidsqldba07/Python_Practice_Programs
/college/s4p1.py
264
4.1875
4
# WAP to create a function to swap values of a pair of integers def swap(a, b): a, b = b, a return (a, b) in_a, in_b = input("a: "), input("b: ") print("Before swap a:", in_a, " b:", in_b) s = swap(in_a, in_b) print("After swap a:", s[0], " b:", s[0])
e7d3351cbddcfdc70e3ec702492c6d8c33624c7e
mwienands/SurveyOfAlogorithmsProject1
/quickSort.py
1,721
3.859375
4
#coded by michael Wienands and tyler Eggleston #This file is used to fill the requirements for algorithm 2 #This code writes the number of elements and the exuction time for each to a #csv file so that you can easily visualize the expected value based off of N import random import timeit import numpy import csv def ...
6a77a5bca7b96861c6bbd9404ebc467afd28d470
kokilavemula/python-code
/inheritances.py
922
4.25
4
#Create a Parent Class class Person: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def printname(self): print(self.firstname, self.lastname) #Use the Person class to create an object, and then execute the printname method: x = Person("kokila", "vemula") x.printname()...
403e3c0dc245a2f412c3de8ed7d78c3f12fd2e4a
kokilavemula/python-code
/dictionaries.py
611
4.40625
4
thisdict = { "brand": "moto", "model": "2nd gen", "year": 2016 } print(thisdict) #Accessing Items thisdict = { "brand": "moto", "model": "2nd gen", "year": 2016 } x = thisdict["model"] print(x) #Accessing Item in another method thisdict = { "brand": "moto", "model": "2nd gen", "year": 2016 } x = ...
7b2d2d37f5acf56da96b52e0665532969285978c
gnoubir/Network-Security-Tutorials
/Basic Cryptanalysis/basic-analyze-file.py
1,983
4.15625
4
#!/usr/bin/python # # computer the frequency of lowercase letters __author__ = "Guevara Noubir" import collections import argparse import string import numpy as np import matplotlib.pyplot as plt parser = argparse.ArgumentParser(description='Analyze a file.') # ./basic-analyze-file.py file # program has one pa...
6bd0deef0eefcd5340a17da5d933123265f03527
googoles/Python_Algorithm
/Practice/enum_practice.py
141
3.796875
4
a = [1,2,3,2,45,2,5] print(list(enumerate(a))) b = ['a1','b2','c3'] for i,v in enumerate(b): print(i,v) # print(f'{idx+1}:{fruit}')
1af0df260e5b703492e54f1781493c726bea40d9
googoles/Python_Algorithm
/programmers/python_lecture/part3_1.py
276
3.703125
4
# s, n = input().strip().split(' ') # n = int(n) # # # for i in range(0,3): # # print(' '*i*(n-len(s)-2),s) # print(s.ljust(n)) # 좌측 정렬 # print(s.center(n)) # 가운데 정렬 # print(s.rjust(n)) # 우측 정렬 import string a = string.ascii_lowercase print(a[3])
83c9ca28485c2b3e9f48051a5202cc5aeebc99c5
googoles/Python_Algorithm
/Algorithm_basic/review_2d_list.py
925
3.53125
4
#Practice Handling 2nd lists kor_score = [49,79,20,100,80] math_score = [43,59,85,30,90] eng_score = [49,79,48,60,100] midterm_score = [kor_score, math_score, eng_score] # 이 행렬은 5 x 3 행렬이 되었다. print(midterm_score[0][2]) # test code 1행 3열의 있는 값 20이 출력된다. # 사람별 평균을 구해보자. avg_result = [0,0,0,0,0]; for i in range(0, ...
b4433184fc21569f8811412284c61a8f3dba7f1e
googoles/Python_Algorithm
/LeetCode/Array/02_Trapping_Rain_Water.py
1,211
3.5
4
from typing import List # 문제풀이 Stack 이용 # 1. 깊이를 잰다. (어떻게?) # 1.1 갑자기 높아지면 그 전의 높이만큼 + 1 # 1.2 but 그 다음 칸의 높이 고려해서 채워준다. # # class Solution: # def trap(self, height: List[int]) -> int: height = [0,1,0,2,1,0,1,3,2,1,2,1] water = 0 for i in range(1, len(height)): left = height[i] for j in range(i): ...
f4207ae32f65a3bc0411500309b097cf9a4bacf8
googoles/Python_Algorithm
/OOP/data_structure/heap.py
1,898
3.984375
4
class Heap: def __init__(self, data): self.heap_array = list() self.heap_array.append(None) # 인덱스 번호는 1번부터 self.heap_array.append(data) def move_up(self, inserted_idx): if inserted_idx <= 1: return False parent_idx = inserted_idx // 2 if self.heap_a...
dae47466f9762a69105f0a42965fac5a05d18842
googoles/Python_Algorithm
/OOP/Algorithm_practice/recursive_call.py
1,452
3.828125
4
def fac(n): if n>1: return n*fac(n-1) elif n == 1: return n # print(fac(3)) # def multiple(data): # return_value = 1 # if data<= 1: # return data # else: # for index in range(1,data+1): # return_value = return_value * index # return return_value...
28d805b3612fc47a730afab7765cecff9f3c82d5
googoles/Python_Algorithm
/ACMICPC/input/multiplication.py
135
3.5
4
a = int(input()) b = int(input()) print(a*(int(b/1)-10*int(b/10))) print(a*(int(b/10)-10*int(b/100))) print(a*int(b/100)) print(a*b)
b7521892b66e131169042a4d548c683d273a219c
googoles/Python_Algorithm
/ACMICPC/String/2908.py
126
3.53125
4
# print(*list(input().split())) a,b = list(map(str, input().split())) a = a[::-1] b = b[::-1] print(a) if a > b else print(b)
fbd9e487cb4336ab63044ea3f35d298bf5dbe713
Robson-SH/calculadora
/functions.py
847
3.84375
4
def printarTela(): print("***************** Python Calculator *****************\n") print("Selecione o número da opção desejada:\n") print("1 - Soma\n2 - Subtração\n3 - Multiplicação\n4 - Divisão\n") return; def captarDados(): controle = input("Digite sua opção (1/2/3/4): ") num1 = input("Digit...
0ac6cecc092b3d9a683d7b1ddd8aae8294478f98
Soumojit5/Pythonpractice-
/string/HealthyProgrammer.py
1,602
3.640625
4
from pygame import mixer from datetime import datetime from time import time def music(file,stopper): mixer.init() mixer.music.load(file) mixer.music.play() while True: a = input() if a == stopper: mixer.music.stop() break def log_saving(msg): w...
ad993c615db31fd16dbc32caed40c29f51e3a803
joshiyash05/synapse
/Tech Task/Backend/Basic Python code/Snazzy auto.py.py
3,947
4
4
print("#### WELCOME TO THE MOST TRUSTED CAR BUYING SERVICE HELP:- Snazzy Autos!!!!") model = ["1.Hatchback", "2.Saloon", "3.Estate"] optional_extra = ["1.Luxury seats", "2.Satellite navigation", "3.Parking sensors", "4.Bluetooth", "5.Sound system"] model_price = [535000, 495000, 625000] optional_extra_price = [4500...
ae387d8d3e1919a5c27d5a6ac75745afa4af7d53
LearnPhy/oppPhy
/geometry/triangle.py
367
3.609375
4
from geometry.geometry import Geometry class Triangle(Geometry): def __init__(self, height, floor, subject): self.h = height self.f = floor self.s = subject def info(self): return f'calculating triangle {self.s} with height = {self.h} and floor = {self.f}' def calculate_...
bef386aacd3e3be602f5cc659efa058293a36699
DuongPhan45/c4t13
/session8/selected_print.py
254
3.78125
4
danhsach = input("Insert a list: ").upper() for item in danhsach.split(","): if "E" in item: print(item) # In ra list của bài tập trước mỗi phần tử này một dòng, chỉ in ra các phần tử có chứa chữ 'e' hoặc 'E' :
bdb760981d8a83ad038126a674054d1b84f7357b
DuongPhan45/c4t13
/Minihack_II/part_I.py
139
3.71875
4
colorlist = ['black','white','blue'] print(*colorlist) new_color = input("Enter new color: ") colorlist.append(new_color) print(*colorlist)
dbd3d26583ee3f5dfb06cb08ef34dcbff87e4bc4
DuongPhan45/c4t13
/Minihack/part_III/evencheck.py
293
4
4
a= float (input("Enter a number: ")) if a % 2 == 0 : print ("inserted number is devided by 2") else: print ("inserted number is not devided by 2") # Viết chương trình cho người dùng nhập vào một số rồi in ra cho biết số này có phải là số chẵn hay không
bc5645c7438f672db5c14c561dd2307212a28c94
DuongPhan45/c4t13
/Minihack/part_I/fullname.py
173
3.8125
4
name = input ("Enter your name ") print ("Your name is ",name) # Viết chương trình cho người dùng nhập vào tên và họ rồi in ra tên đầy đủ của họ
b6b6be3277eeba1ef5ffe2eb7b8dfd3c3915124b
DuongPhan45/c4t13
/session2/mathassignment.py
432
3.921875
4
# a= float (input ("Hi beauty. Please enter the base of your triangle: ")) # b= float (input ( "Please enter the height of your triangle: ")) c= float (input ("Please enter the radius of your circle: ")) # print ("The area of your triangle is ", a*b/2) # Tat ca nhung phan sau dau sao se duoc may bo qua khi chay chuong ...
c1106d63ec1707bf7dc84146345c1093d5d0f74f
hihiworld/genetic-algorithms
/genetic-examples/traveling-salesman-ex2.py
4,040
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 29 10:13:37 2018 @author: jn107154 """ import numpy as np import matplotlib.pyplot as plt from tqdm import tqdm #x = (1,2,1,3,4) #y = (10, 2,10, 3,1) #plt.plot(x,y) ''' REFERENCES: http://pesona.mmu.edu.my/~ianchai/teaching/ECP1032/greedy.ht...
ec11f00340927e77c23049737f20d5520b8deced
UMBC-CMSC-Hamilton/cmsc201-spring2021
/conway_game_of_life.py
2,740
4.0625
4
import random class ConwayGameofLife: # this is where you can put constants DEAD = ' ' ALIVE = 'X' def __init__(self, board_x, board_y): # False if the board is dead at that position # True if it is "alive" self.the_board = [] for i in range(board_x): row =...
7b327f91ddb00e976333106ce14425d7f0ec7b5a
UMBC-CMSC-Hamilton/cmsc201-spring2021
/recursion_ii.py
3,106
4.21875
4
""" Let's actually do some recursion What is a palindrome? racecar tacocat A man a plan canal panama pop repaper Able was I ere I saw Elba. Do geese see God? <-- heh Gateman sees name, garageman sees name tag. <-- heh^2 How can we write a rec...
ecdc47eba72d0a84f353d65c9afbf2f2d520f944
UMBC-CMSC-Hamilton/cmsc201-spring2021
/conditionals.py
8,684
4.0625
4
# let's do some coding! """ Last week: print() input() 4 basic data types: int, float, bool, str int = integer -10, -9, ..., 0, 1, 2, 3, 4, ... 2,981,123,123 It's possible to store larger values than a standard int "4 byte integer" == standard float = anything with a decimal ...
ae9f2189f73437e8ab24932c8f44108d7cbb467d
UMBC-CMSC-Hamilton/cmsc201-spring2021
/classes_start.py
1,501
4.21875
4
""" A class is a new type ints, floats, strings, bool, lists, dictionaries class <-- not really a type a type maker. What kind of things can types have? data inside of them (member variables, instance variables) functions inside of them. """ class Lion: """ ...
b7a1877dbad13e4caf62c73bd097927b283ae5bc
UMBC-CMSC-Hamilton/cmsc201-spring2021
/lists_and_loops/second_lecture.py
6,026
4.15625
4
if False: my_list = ['someone', 'should', 'have', 'checked', 'obs', 'before', 'he', 'talked', 'to', 'himself'] # for each loop for word in my_list: if word[0] == 's': print(word) # 2-d array, basically operating like that print(my_list[0][0]) # for i loop for i in range...
c5fdec99b30622a08e005055eb5a11b89ea47db5
LoganStalker/learning
/data protection/Hamilton_paths/coder.py
1,538
3.578125
4
# -*- coding:utf-8 -*- ALFAVIT = ('А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К', 'Л','М','Н','О','П','Р','С','Т','У','Ф', 'Х','Ц','Ч','Щ','Ш','Ъ','Ы','Ь','Э','Ю','Я','_',',','.') message = 'МЕТОДЫ_ШИФРОВАНИЯ_С_СИММЕТРИЧНЫМ_КЛЮЧОМ' print('Сообщение: %s'%message) while 1: if len(message) % ...
a1e9e269a7c0b7182e2f6f99cea7d6366b3913c5
gzdnrgltkn/Safety-Deposit-Boxes
/code.py
200
3.796875
4
# converted the given list to separeted list by comma #then used index() func to learn given item's index in that list box=input() box2=box.split(",") item=input() i=box2.index(item) i+=1 print(i*5)
d2dc64e1f43063553f41b7a25012e4bec18b7515
victorvalenca/DataStructLabTest
/Student.py
586
3.796875
4
class Student: """ This is a Student. It has a name, student number, and GPA """ def __init__(self, number, gpa, name): self.student_number = number; self.student_gpa = gpa self.student_name = name def setName(self, name): self.student_name = name def setG...
6fc00c165e3e387e67d93713f5cafb7f068be8a5
ruxtain/algorithms
/自创的开根函数(20210221).py
757
3.828125
4
#!/Users/michael/anaconda3/bin/python import math, sys def my_sqrt(x, precision=2): if x < 0: return None def get_root(x, root, step): i = -step while True: i += step if (x - (root + i) ** 2 > 0 and x - (root + i + step) ** 2 < 0) or (x - (root + i) ** 2 == 0...
9cd2a656692a80e5fa078947a9199e42996a1051
ruxtain/algorithms
/杨辉三角(20180719).py
1,748
3.875
4
#! /Users/michael/anaconda3/bin/python # -*- coding: utf-8 -*- # @Author: ruxtain # @Date: 2018-07-19 11:38:39 # @Last Modified by: ruxtain # @Last Modified time: 2018-07-19 15:06:24 """ 给定一个非负整数 numRows,生成杨辉三角的前 numRows 行。 示例: 输入: 5 输出: [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 1 1 1 1 1+1 ...
3430c1519be599f4c57b804cc5e48fbb19a8670a
Akshive/Exercism-Python-Solutions
/perfect-numbers/perfect_numbers.py
657
3.78125
4
def classify(number): if(number <= 0): raise ValueError('Invalid') num = number i = 2 ans = 1 while(i*i <= number): cnt = 0 while(number%i == 0): number = number/i cnt += 1 #print("{} {} {}".format(i, cnt, ans)) ans = (ans*(i**(cnt+1)-1...
e463051f084961c9010ef1e2529eb3773140252e
seagal123/library_system
/answer_quick_sort.py
1,196
3.953125
4
"""this is answer you know""" import random def swap(lyst, a, b): a1 = lyst[a] lyst[a] = lyst[b] lyst[b] = a1 def quick_sort(lyst): quick_sort_helper(lyst, 0, len(lyst)-1) def quick_sort_helper(lyst, left, right): if left < right: pivot_location = partition(lyst, left, right) ...
0285c70bfe5172d74c28eff0da9b922fd4002fa8
sokoide/fib-bench
/py/main.py
313
3.59375
4
import time def fib(i: int) -> int: if i<=1: return i return fib(i-1) + fib(i-2) def main(): for i in range(40,44): start = time.time() result = fib(i) end = time.time() print("%f, fib(%d)=%d" %( end-start, result, i)) if __name__ == '__main__': main()
3f20d098aafb54099d4ec6b71a3788f0cccecf61
frossi01/bai-tap
/Bai8.4.py
344
3.53125
4
from tkinter import* window = Tk() window.title("Welcome to LikeGeeks app") window.geometry('350x200') lbl=Label(window, text="Hello") lbl.grid(column=0, row=0) def clicked(): lbl.configure(text="Button was clicked !!") btn=Button(window, text="Click Me", command=clicked) btn.grid(column=1, row=0) ...
8b0ddf4b079711c7dc53707a4ae12db8a7ef2296
frossi01/bai-tap
/Bai4.18.py
390
3.984375
4
import math def fibonacci(n): if (n < 0): return -1; elif (n==0 or n==1): return n; else: return fibonacci(n - 1)+ fibonacci(n - 2); n = int(input("Nhập số nguyên dương n = ")); print ("Tất cả các số fibonacci nhỏ hơn", n); i = 0; fin = fibonacci(i); while(fin < n): ...
28c69d28ea28cf70ce3fd1035b82a9ab5e223daa
frossi01/bai-tap
/Bai8.5.py
438
4.0625
4
import tkinter as tk root = tk.Tk() v=tk.IntVar() v.set(1) languages=[("Python",1),("perl",2),("Java",3),("C++",4),("C",5)] def ShowChoice(): print(v.get()) tk.Label(root, text="""Choose your favourite programming language:""",justify=tk.LEFT,padx=20).pack() for val, language in enumerate(languages): t...
b92f73bde7bf6e2937273280f7de00db25746740
Choi-Jinwoo/Algorithm
/그 외/두수의 차이 구하기/main.py
308
3.765625
4
n = 10 def sum_pow(n): n_sum = n * (n + 1) // 2 return pow(n_sum, 2) def pow_sum(n): n_sum = 0 for i in range(1, n + 1): n_sum += pow(i, 2) return n_sum n_sum_pow = sum_pow(n) n_pow_sum = pow_sum(n) a = max(n_sum_pow, n_pow_sum) b = min(n_sum_pow, n_pow_sum) print(a - b)
bedef5857f1eb0021dee77099f6927ec00ec9b74
Choi-Jinwoo/Algorithm
/프로그래머스/1, 2단계/전화번호 목록/main.py
195
3.59375
4
def solution(phone_book): for phone in phone_book: for target in phone_book: if target.find(phone) == 0 and target != phone: return False return True
b887e88db5324aed948e892f846a87f81c346d05
Choi-Jinwoo/Algorithm
/자료구조/스택/main.py
838
4.0625
4
class Node: def __init__(self, data): self.next = None self.data = data class Stack: def __init__(self): self.__top = None def push(self, data): if self.__top is None: self.__top = Node(data) else: new_node = Node(data) p = sel...
1d7c5bf0e3d3e50f92b610828579e42120e6cba4
deveshsety/portfolio
/seating_arrangement.py
1,043
3.75
4
t = int(input()) for i in range(t): seat_no = int(input()) remainder = 12 % seat_no if seat_no == 1 or remainder == 1: print(f"{seat_no+11} WS") elif seat_no == 2 or remainder == 2: print(f"{seat_no+9} MS") elif seat_no == 3 or remainder == 3: print(f"{seat_no+7} AS"...
6264566d19e12a1b51c638379e20abb0174b8e6e
COGS18/LectureNotes-Sp21-Bardolph
/CL7_student_examples/ex02_chapstick/YOLO.py
970
3.5625
4
import random class Chapstick: def __init__(self, brand): self.brand = brand self.size = random.randint(70, 100) self.uses = 0 def use_chapstick(self): self.uses += 1 print(self.brand + ' chapstick has been used ' + str(self.uses) + ' times.') self.uses...
b2005ef4f437259ee0ddc49445003f416d534044
ricrosales/TopCoderProblems
/BreadthFirstSearch/CaptureThemAllDiv2.py
4,265
3.625
4
''' Problem Statement Harry is playing magical chess. In this version of the game, all pieces move the same way as in regular chess, but players can cast some magical spells. Unfortunately, Harry's opponent, Joe, has captured all of Harry's pieces except one knight; Joe, on the other hand, still has a queen and a rook...
eaee5f67a1c402a7f91b14de7b18a52266f0abb2
anoop123gupta/saral_debugging_code
/more_exercise/exercise8.py
283
4.0625
4
list1 = [1, 5, 10, 12, 16, 20] list2 = [1, 2, 10, 13, 16] new_list=[] # def lists(list1,list2): # for i in list1: # if i not in list2: # list2.append(i) # print (list2) # lists(list1,list2) for i in list1: for j in list2: if j not in list1: list1.append(j) print list1
a64c97ea15a005a76cca1565d3d63ccce6981d77
anoop123gupta/saral_debugging_code
/list_python/list1.py
115
3.6875
4
max=0 numbers=[50, 40, 23, 70, 56, 12, 5, 10, 7,90,121] for i in numbers: if i>max: max=i i=i+1 print (max)
3633a71d4d462ae459a66e41f98413bdcb7a5465
Fellenex/practice-problems
/array_rotate/ck-solutions/array_rotate.py
3,464
3.9375
4
import random import time import sys MAX_ARRAY_SIZE = 10 MAX_ROTATIONS = 5 #Moves the last element to the first position, numPushes times. #O(n*k) time, such that k is a constant. # #Parameters: # _rotateMe: The array to be rotated # _numPushes: The number of times that the last element is pushed to the front # #Retu...
cfef5d763890205e4fa1898261d16c0f78745146
Leedokyeong95/PythonWorks
/Ch05/5_3_Module.py
580
3.5
4
""" 날짜 : 2021/02/22 이름 : 이도경 내용 : 파이썬 모듈 패키지 실습하기 교재 p.114 """ #import = 출처 import Ch05.lib.Calc as cal #cal이라고 하겠다. rs1 = cal.plus(1, 2) rs2 = cal.minus(1, 2) rs3 = cal.multi(2, 3) rs4 = cal.div(4, 2) print('rs1 :', rs1) print('rs2 :', rs2) print('rs3 :', rs3) print('rs4 :', rs4) ########################## from Ch05...
106152dc1d428d5a15107a03dd2a771e94328a49
Leedokyeong95/PythonWorks
/Ch02/p.47.py
492
3.859375
4
""" 날짜 : 2021/02/18 이름 : 이도경 내용 : 교재 p.47 외부상수 출력 예 """ # (6) 외부 상수 인수 name = "홍길동" age = 35 price = 125.456 print("이름 : {}, 나이 : {}, data={}".format(name, age, price)) print("이름 : {1}, 나이 : {0}, data={2}".format(age, name, price)) # (7) format 축약형(SQL문 작성) uid = input("id input : ") query = f"select * from member ...