blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
995313c64b4a2bda48fd45b1d711963259463b41
whitneysattler/python-lists
/Sort.py
875
4.15625
4
# The function for sorting elements in ascending order def selectionSort(lst): for i in range(len(lst) - 1): currentMin = lst[i] minIndex = i for j in range(i + 1, len(lst)): if currentMin > lst[j]: currentMin = lst[j] minIndex = j #Swap ...
481147e4bf3d5815a945d35f7f7d456070359bdc
prajwal17/first_app
/python/ex2.5.py
211
3.8125
4
input=float(raw_input('Enter the temperature in celcius\n')) try : m=(input * 1.80) + 32.00 print ('%0.1f degree celcius is equal to %0.1f fahrenheit ' %(input,m)) print m except : print 'Enter the valid value'
088e7ed96cde08ec1fb24e95890016184cb26a46
softwarefaith/PythonFullStack
/PythonFullStack/000Basic/day06/08-文件的拷贝.py
488
3.71875
4
#1.打开源文件读取数据 #rb:比较通用的方式,可以兼容不同的文件 src_file = open("3.txt","rb") #读取文件中全部的数据(大文件不行) file_data = src_file.read() #打开目标文件准备写入数据 #扩展一下:默认写到pychram里面, # Users/用户名/desktop 我桌面的路径 dst_file = open("/Users/用户名/desktop/5.txt","wb") #把源文件的内容写入到目标文件 dst_file.write(file_data) #关闭文件 dst_file.close() src_file.close()
5f6a9fb58a2200933d19a22041759f04c8dcb867
blguru20/PythonBasics
/PythonPractice/InOut/InOut1.py
434
4.15625
4
a = 0;print(a); b= 1 ; print("value of a : {} and b : {} : ".format(a,b)); print("value of a and b respectively are : {} , {} ".format(a,b)); print("value of b and a respectively are : {1} , {0} ".format(a,b)); print(" name is : {name} , greeting is : {greeting}".format(name = "guru ", greeting = "Hello ")); prin...
8d8c0123025ad3c3c2042183fa815658269736c4
nanax/my_python_tests
/test4.py
2,543
4.28125
4
"""Given two dates, calculate days between the dates.Assumes inputs are valid dates in Gregorian calendar. """ """This is another solution to the Udacity Intro to Computer Science class lesson 2 problem set(optonal 2) problem 2(Days Old),included in lesson 2.5""" def is_leap(year, month, day): if year%4==0: ...
e77974de609274cd8d45f8bdad1f619556493268
ximocoder/CodeExercises
/Project Euler/Python/Exercise22.py
1,001
3.796875
4
# Problem 22 # ========== # # # Using [1]names.txt (right click and 'Save Link/Target As...'), a 46K text # file containing over five-thousand first names, begin by sorting it into # alphabetical order. Then working out the alphabetical value for each name, # multiply this value by its alphabetical position...
8415bf0cd3fcb2b6634bf4e0d6b9d0ef9ed3afa5
jambellops/hRank
/collections/most_com_let.py
620
3.8125
4
#!/bin/python3 from collections import Counter, OrderedDict class OrderedCounter(Counter, OrderedDict): 'Counter that remembers the order elements are first encountered' def __repr__(self): return '%s(%r)' % (self.__class__.__name__, OrderedDict(self)) def __reduce__(self): return self._...
3f7edc1c9a52c3213b1e1a20145d5f0f9051c889
qzy93316/python-lesson
/demoLesson/chap9 集合/demo4.py
570
3.5625
4
# Author : John # @Time : 2021/1/21 16:00 # @Author : John # @File : demo4 # @Software : PyCharm '''集合的数学操作''' #(1)交集 s1={10,20,30,40} s2={20,30,40,50,60} print(s1.intersection(s2)) print(s1 & s2) #intersection() 与 & 等价,交集操作 #(2)并集 print(s1.union(s2)) print(s1 | s2) #union() 与 | 等价,并集操作 #(3)差集 print(s1.dif...
c04503dd408b27df74da71b7ee10b50682480edd
MichaelHawkins338/commandlineeditor
/commandLineEditor.py
659
3.796875
4
import time import os.path from os import path filecheck = input("Enter a filename in current directory:") print("Item exists:" + str(path.exists(filecheck))) filename = input("Create new file with new name:") file = open(filename + ".txt","w+") filewrite = input("What would you like to save to this file?:")...
cc11143a6db325ec83d4ff9891267f8729e008ad
katRoman99/Alien_Invasion
/alien.py
1,363
3.609375
4
import pygame from pygame.sprite import Sprite from pygame.rect import Rect class Alien(Sprite): ''' Class representing a single alien in the alien fleet ''' def __init__(self, ai_settings, screen): super().__init__() self.screen = screen self.ai_settings = ai_settings # Load...
563df9340eaf9a6dce5f36571711f9a241d19198
Krispy2009/advent-of-code-2018
/day2/puzzle-2.py
780
3.78125
4
def off_by_one(line, next_line): diff_letters = {} for idx, (a, b) in enumerate(zip(line, next_line)): if a == b: continue else: diff_letters[a] = idx return len(diff_letters) == 1 with open('day-2-input') as f: data = f.readlines() for idx, line in enume...
b65908658ef1ea51affa458c7253c6bf0f94fbc8
GabrielDiasEstudos/Exercios-Python
/desvios/repeticao.py
559
3.625
4
def mostrar_exemplo(): idades = [17, 38, 70, 80] print(classificar_idade(idades[0], 'Gabriel')) print('\n----------------------------------------------------') for idade in idades: print(classificar_idade(idade, 'Pessoa')) def classificar_idade(idade, nome): if idade < 18: return ...
3c99c9d8c02164449747af81af6971ec742c3154
highballl/LEETCODE
/23_merge_k_sorted_lists.py
247
3.578125
4
import heapq lists = [[1,4,5],[1,3,4],[2,6]] heap_list = [] for idx, list in enumerate(lists): for elem in list: heapq.heappush(heap_list, elem) result = [] while heap_list: result.append(heapq.heappop(heap_list)) print(result)
da640c30980913ebbdeb119aed7e3f7be104ded8
Aduzona/INTRO-TO-PYTHON-DEVELOPMENT
/12 - Loops/while.py
378
4.09375
4
# Looping with a condition # we use while loops when something is going to change automatically names = ['Christopher', 'Susan'] index = 0 while index < len(names): print(names[index]) #Change the condition!! index = index + 1 print() people= ['Diego','Frank','Victor'] index = 0 while index < len(peopl...
2f61edad23612fdfe7e9a3194f4dfc035f934db8
Yehuda1977/DI_Bootcamp
/Week9/Day2/Exercises.py
1,809
4.1875
4
# Exercise 1 : Built-In Functions # Python has many built-in functions, and if you do not know how to use it, you can read document online. # But Python has a built-in document function for every built-in functions. # Write a program to print some Python built-in functions documents, such as abs(), int(), raw_input()....
0f965d082a506e6a11a1a9eea641c84df89a9c4b
dstein64/fenwick
/tests/test_fenwick.py
1,639
3.515625
4
import unittest from fenwick import FenwickTree class TestFenwick(unittest.TestCase): def test_fenwick(self): n = 10 frequencies = range(1, n + 1) # Test a Fenwick tree initialized with existing frequencies fenwick_tree_0 = FenwickTree(n) fenwick_tree_0.init(frequencies) ...
47ca103a00c603d833afe551a4a6001974e4ac12
SymmetricChaos/NumberTheory
/Sequences/BinarySequences.py
7,622
3.640625
4
from Sequences.Simple import naturals from Sequences.MathUtils import factor_out_twos from Sequences.Recurrence import tribonacci from Sequences.Manipulations import offset, make_triangle, sequence_apply from Sequences.Combinatorics import pascal_triangle from itertools import cycle def thue_morse(invert=False): ...
7c0bbb197784b4e3c71c67003859bb76fd7e7255
Matuiss2/URI-ONLINE
/1400- 1599/1436.py
414
3.65625
4
import math loops = int(input()) for i in range(loops): data = input().split() quantidade = int(data[0]) # Pega a quantidade de valores, é nescessário para ver o número do meio metade = math.ceil(quantidade / 2) # math.ceil ja retorna o valor arredondado pra cima em int print("Case " + str(i + 1...
e32d4c0ff6b060534d93f0d05d181de0bb6785d4
theodorp/CodeEval_Easy
/happyNumbers.py
1,204
4.25
4
# HAPPY NUMBERS # CHALLENGE DESCRIPTION: # A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include ...
57983306cd5105e19d97971c9f4db849c93a3cd4
edmolten/codevita2016
/f.py
1,726
3.625
4
import math as m number = input() test = False for i in number: if i == ".": test = True break if not(test): number += "." snumber = number.split(".") numberLeft = snumber[0] numberRight = snumber[-1] divisor = "0" summ = "0" quotient = "0" remainder = "0" dividend = "0" def zeroLeft(number): if len(number)...
e20965effbb7df73bea2c548dc93d0832b7ab379
Molly-l/66
/mounth003/day02/test.py
163
3.734375
4
import time # i=0 # while True: # i+=1 # time.sleep(0.1) # if i<=10: # print(i) # if i >= 10: # break time.sleep(2) print('hello')
99f9378984c505dbe7b2b6a750b33be492d82a77
Pradyumn-101/python-lab
/Pra leap year.py
186
4.125
4
year =int(input("Enter the year")) if year%4==0: if year %100!=0: print ("Leap Year") else: if year % 400==0: print("Not Leap year")
30992cd707bf36b5430ca0a8eeff62012be2d528
kyeshor/assignment
/calc.py
3,762
3.703125
4
from tkinter import * expression = "" # Function to update expression def press(num): global expression # concatenation of string expression = expression + str(num) equation.set(expression) # Function to evaluate the final expression def equalpress(): #Try block for exceptions try: global expression ...
aaff6f5d3842fbd1d93c883dc2d633bb02cc018c
Abhijith-1997/pythonprojects
/flow controls/function/calculator.py
600
4
4
def add(): a=int(input("enter the number")) b=int(input("enterthe number")) print(a+b) def sub(): a = int(input("enter the number")) b = int(input("enterthe number")) print(a - b) def mul(): a = int(input("enter the number")) b = int(input("enterthe number")) print(a*b) def div(): ...
8c85db29ba4867268850f53c9a3c95cbe37b411a
nidhiatwork/Python_Coding_Practice
/LinkedList/sortList.py
1,604
4.03125
4
''' Sort a linked list in O(n log n) time using constant space complexity. Input: 4->2->1->3 Output: 1->2->3->4 Input: -1->5->3->4->0 Output: -1->0->3->4->5 ''' #To do class ListNode: def __init__(self, val, next=None): self.val = val self.next = next def sortList(head): if not head or not he...
ad7b3f4e074b0ffdb31098e56352c23fc5bc4102
danielthorr18/forritun_git
/STRINGS/6.3.py
117
3.96875
4
s = input("Input a string: ") find = s.find("o") for item, o in enumerate(s): if "o" == o: print(item)
8bd0bca469d1684983f9b31e7ab7b48ed879f5b9
RiyaChhadva-2411/python-basic-codes
/listcountvowel.py
490
3.96875
4
str=input("Enter the sentence:\n") vowel=list() vowel.append("a") vowel.append("e") vowel.append("i") vowel.append("o") vowel.append("u") count=0 for i in str: if i in vowel: count=count+1 print("The number of vowels in the sentence are", count) #The other method #str=input("Enter the sentence:") #def v...
0d8aa632dfcc578e50aa75215b6cea838ba6d9c1
GuHao0216/PR-tag-recommendation
/src/dateCompare.py
6,151
3.5625
4
#coding=utf-8 import re class dateCompare: """ 比较日期的大小, model=0,date1 >= date2 返回True model=1,date1 =< date2 返回True model=2,date1 < date2 返回True ;严格小于 """ @classmethod def dateCompareto(cls,date1, date2, mode): date1 = re.sub("[-T:Z]", " ", dat...
c916e77d3292ff866d442dd8b5d78ebcdc48c621
kamalikam/Letsupgrade_Python_Assignments
/Day2/Day2Assgn3.py
1,132
4.40625
4
#Day2 Assignment 3 #Experiment with at least five different functions of dictionary dict1={'Name':'Kam','Age':34,'Address':'Canada'} print('\nDictionary1 is: ',dict1) dict2=dict1.copy() #copy() makes a copy of the dictionary print('\nDictionary2 is a copy of Dictionary1: ',dic...
fe7bf0aa311e0d906c1c7f94a58878188034bcca
yadage/tutorial
/images/upper_maker/uppermaker.py
522
3.546875
4
import sys import logging logging.basicConfig(level = logging.INFO) log = logging.getLogger('uppermaker') def main(): inputfile = sys.argv[1] outputfile = sys.argv[2] log.info('Hello There, we will take the contents of {}'.format(inputfile)) log.info('and make them all UPPER CASE!!') log.info('Fin...
8eedfc12bc63e61dc5422bb1ab7d4ba4bb1477fc
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/6b2916bf3cdf4f2383c1ce8dd3ec1a4f.py
1,536
4.0625
4
# # by LattMongoria 2014/10/02 # def hey(what): import unicodedata import string text = unicode(what) #I found the following 2 line on the internet #They somehow strip diacritics from unicode strings #I don't actually understand how they work text = unicodedata.normalize("NFKD", text) ...
96b353129c00b7b1b961a9b35b90852d15c18f39
vishnoiprem/pvdata
/lc-all-solutions-master/019.remove-nth-node-from-end-of-list/test.py
461
3.5625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def removeNthFromEnd(self, head, n): """ """ dumppy=ListNode(1) fast=slow=head dumppy.next=head while n and fast.next: ...
375594046f795d13dabc21587e6cc82bbd943065
Kenzo-Sugai/Python
/media.py
298
3.796875
4
# inserir números n1 = int(input("Digite o primeiro valor: ")) n2 = int(input("Digite o segundo valor: ")) n3 = int(input("Digite o terceiro valor: ")) n4 = int(input("Digite o quarto valor: ")) # calculo da media8 m = (n1*1 + n2*2 + n3*3 + n4*4)/4 # resultado print("A média é: %d"% (m))
799970942903a04a1e0db31f840e9e28ca9258e4
onearmwonder/blueprint_namer
/misc py files/key_presser_test.py
1,847
3.5
4
from pynput import mouse, keyboard import time ''' #get screen width with tkinter, ONLY READS SIZE OF PRIMARY MONITOR import tkinter as tk root = tk.Tk() tk_screen_width = root.winfo_screenwidth() tk_screen_height = root.winfo_screenheight() print("tk read screen size: {}, {}".format(tk_screen_height, tk_screen_widt...
2896f116555d17c33f9405f4a5769dd927301530
keshavkummari/python-nit-7am
/functions/variable-length-Arguments.py
293
4.21875
4
#!/usr/bin/python # Function definition is here def info( arg1, *vartuple ): #This prints a variable passed arguments print (arg1) for i in vartuple: print(i) return # Now you can call printinfo function info("Welcome to Python World",10,20,30,40,50,"Guido","Van","Rossum")
942740d7848345813b3a7416fe9a42ce5b0e5233
volkir31/university
/lab2/8th_task.py
189
3.78125
4
list_of_digit = input().split() for i in range(1, len(list_of_digit), 2): list_of_digit[i - 1], list_of_digit[i] = list_of_digit[i], list_of_digit[i - 1] print(' '.join(list_of_digit))
523a39f038e041a8963681c38533629efcdacc24
SlidingSteven/Portfolio
/Big_12_Coaches.py
2,056
3.5625
4
#!/usr/bin/env python3 # Anchor extraction from HTML document from bs4 import BeautifulSoup from urllib.request import urlopen import re #List of Big 12 football wikipedias to search through. Yes there are only 10 teams in the big 12... big12 = ["https://en.wikipedia.org/wiki/Oklahoma_Sooners_football", ...
aff2eee0366ea7bc5dbcbcc825f100fe027e4b90
dbinnion/Euler-Problems
/Problem-3/largestPrimeFactor.py
724
3.65625
4
from math import sqrt number = 600851475143 maxPrime = 0 def testPrime(number): numcheck = 3 maxroot = sqrt(number) while numcheck <= maxroot: if not number % numcheck: return False numcheck += 2 return True def isFactor(root): if not number % root: return T...
0cceaa8d8b51673695ea622f36da5e8f570af638
costefan/machine-learning
/1/pandas_train.py
436
3.96875
4
# Какое количество мужчин и женщин ехало на корабле? В качестве ответа приведите два числа через пробел. import pandas data = pandas.read_csv('titanic.csv', index_col='PassengerId') print(data[data['Sex'] == 'male'].count()) print(data[data['Sex'] == 'female'].count()) print(len(data[data['Sex'] == 'female'])) print(le...
033c15f313e8828e7dc106b39e6e5a1c81b986e4
Jihyeonji/Mypython
/ch05/sam05.py
459
3.96875
4
scoreKor=int(input('국어 점수를 입력하세요')) scoreMath=int(input('수학 점수를 입력하세요')) scoreEng=int(input('영어 점수를 입력하세요')) avg=(scoreKor+scoreMath+scoreEng)/3 print('평균:',avg) if avg >=90: print('A학점입니다') elif avg >=80: print('B학점입니다') elif avg >=70: print('C학점입니다') elif avg >=60: print('D학점입니다') els...
0275d83baba501bdd7cb52111df2de6ae62efc17
smpenna3/Python
/grid.py
619
3.640625
4
from Tkinter import * root = Tk() button1 = Button(root, text='top left', width=20).grid(row=0, column=0) button2 = Button(root, text='bottom left', width=10).grid(row=1, column=0, sticky=W) button3 = Button(root, text='top right', width=10).grid(row=0, column=1, sticky=E) button4 = Button(root, text='bottom right', ...
76fdfd4b10d6ccfb0aab90996c7931433b357a94
gokuljs/python-rev
/problem-solving/reversewithoutanother.py
396
4.625
5
# program to reverse an array without another array n=int(input("enter the number of elements")) list=[] for i in range(n): ele=int(input()) list.append(ele) print("array before sorting") for i in range(n): print(list[i]) # 1,2,3,4,5,6,7 reversed_list=[] print("reversed array is ") for i in range(n-1,-1,-1...
be390a9f49ab36b52f0eb42306c53457dcc26fc8
mh-rahman/Programming-Practice
/105. Construct Binary Tree from Preorder and Inorder Traversal.py
1,164
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode: def helper(preorder,inorder,inorder_st,inorder...
402d1ac8ba3bd2ffe81b19c3de6a87a2f355558d
wangzeyao/tutorials
/GUI/tkinter/Canvas.py
1,159
3.515625
4
import tkinter as tk window = tk.Tk() window.title('Canvas') window.geometry('400x400') # 创建canvas canvas = tk.Canvas(window, bg='blue', height=100, width=200, # 长200像素,宽100像素 ) # 读取图片文件 image_file = tk.PhotoImage(file='D:/pythonProject/tutorials/files/ins.gi...
c478989981a943f8df6df3b36021e826862ac62f
nikhilro/daily-coding-problem
/p41.py
1,068
3.640625
4
import bisect def itinerary_naive(routes, start): # not tested, O(n) space, runtime? pre bad but standard backtrack flights = {} def plan(itinerary): if len(flights) == 0: return itinerary cur = itinerary[0] if cur in flights: dest = flights.pop(cur) ...
fab0a58cca5e2aee99135141e02505c5e09b7c37
meganspeir/Interview_Problems
/python/extract_num.py
1,612
4.0625
4
#!/usr/bin/env python ''' Extract Number Input: A list of dictionaries with text that includes time Output: Strip the tmie out of the text, convert to time, calculate the average time and return the mean. Challenge: Account for military time. Account for ''' import re # import regex # Strip out time with Regex de...
ceb4b66725178f55dd3e56736639e449f025bf34
xiaop1987/music_batch_downloader
/music_list_parser/simple_music_list_parser.py
518
3.609375
4
import json class SimpleMusicListParser(object): """An simple music list parser for raw text and one song name a line""" def __init__(self, music_list_input): with open(music_list_input, 'r') as f: self.info_list = json.loads(f.read()) f.close() self.index = 0 de...
e78d95b2cd941b22d6e83a5023baac85f72d8711
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/rna-transcription/c26c2fec7c9e4a9086a778f9ebebfb4e.py
255
3.765625
4
def to_rna(sequence): dna_to_rna = { 'c' : 'g', 'g' : 'c', 'a' : 'u', 't' : 'a' } rna_sequence = "" for i in list(sequence): rna_sequence += dna_to_rna[i.lower()] return rna_sequence.upper()
fddd888076aef50f0ac99f299ee68861983e9279
jwiley84/netCoreClasswork
/Python/ArkhamAsylum.py
1,436
3.625
4
import random; class Patient(object): def __init__(self, name, caseNo, allergies, majorInjury): self.name = name; self.caseNo = caseNo; self.allergies = allergies; self.majorInjury = majorInjury; self.bedNo = "none"; def displayInfo(self): print("Name:", self.na...
1f1a00fbb0a7d9b21bfd159b0ae4665af39370d6
mariaKozlovtseva/Algorithms
/stack_prefix_postfix_notation.py
2,996
3.765625
4
class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items) - 1] def size(self): ...
f2cbc2b4dbb541994822eb70c48b564a865ebcf9
Jackthebighead/recruiment-2022
/algo_probs/jzoffer/jz25.py
1,750
4
4
# 题意:合并两个排序的链表。输入两个递增排序的链表,合并这两个链表并使新链表中的节点仍然是递增排序的。 # 题解1: 本题需要注意三个地方:边界(两个链表是否为空),改变链序,处理不等长链表情况 # 改变链序的过程:首先让l1是头节点val最小的那个(或者也可以新建一个头节点。。这样并不会增加什么空间复杂度),再让l1为l1.next,用while循环依次比较l1和l2的val,谁小reference链谁,链完l=l.next, # 下一个循环开始前reference也要自增。这里要用两个reference一个用来比较修改,一个用来最后返回整体 # 题解2: 用递归写,大同小异,也是比较头节点。 # Definition fo...
ab70e6b01b1bbf3e1a45dec3cd90bd438333b12f
unixbash/CodebugLabs
/StudentLabs/Lab3.py
1,743
4.375
4
""" ***In all labs, students are expected to use Scratch code creator/emulator on CodeBug's website in order to understand the logic of the program, before they run it. In this lab students will learn loops, while and for """ import random import time import codebug_i2c_tether codebug=codebug_i2c_tether.C...
c5b0df46a333befac2aad9d6eacea3cdb18952ed
nortonlyr/PythonFundamentals.Exercises.Part4
/fibonacci_recursive.py
468
4.28125
4
def recur_fibonacci(n): """ Set a fibonacci sequence using recursion method """ if n>= 0 and n <= 1: return n else: return (recur_fibonacci(n-1) + recur_fibonacci(n-2)) n_term = int(input('Enter the integer number between 0 and 30: ')) if n_term < 0: print('Please enter a p...
c3520f20a8104189411c14347f31baceba0b2436
AdityaSharma6/Python
/edabit/2A_return_next_number.py
73
3.53125
4
def nextNumber (num): #return num+1 print (num+1) nextNumber(5)
1142595ce3bdcf33988a616af68160c02881a777
daniel-reich/ubiquitous-fiesta
/jgpfraMtc9nrrPZkL_5.py
391
3.5
4
def switch_gravity_on(lst): block = "#" empty = "-" ​ maxyIndex = len(lst) - 1 maxxIndex = len(lst[0]) - 1 for iteration in range(maxyIndex): for col in range(maxxIndex, -1, -1): for row in range(maxyIndex-1, -1, -1): if lst[row+1][col] == empty and lst[row][col] == block: lst[...
465b2f99a932d6de92a238f20fd07268bc608a0a
TianYuFan1/CodeAcademy
/Basta.py
2,464
3.953125
4
class Menu: def __init__(self, name, items, start_time, end_time): self.name = name self.items = items self.start = start_time self.end = end_time def __repr__(self): return "The {MENU} menu is available between {START} and {END}".format(MENU=self.name, START=self.start...
96717133358d9a9142bbb813879abef0c50d006f
morristheaverage/Spellium
/spellium.py
6,096
4.25
4
"""Can a word be spelt using chemical symbols? Find out with this script """ import sys import os from itertools import product import pandas as pd class Element: """Simple info class to store data about each element """ def __init__(self, series): self.name = series["Element"] se...
331b927cbf289c5652afdaf91066ae8ad9df537b
changyubiao/fisher
/app/libs/helper.py
603
3.53125
4
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- """ @author: Frank @contact: frank.chang@shoufuyou.com @file: helper.py @time: 2018/10/28 上午7:41 帮助函数或者类 """ def is_isbn_or_key_old(q): if q == '111': return 'isbn' else: return 'keyword' def is_isbn_or_key(word): """ """ isbn_or...
9050a56ac74fa9249babd0b1dc41c5ca5db392e2
amitabhadey/texteditor
/references/testGUI.py
6,804
4.5625
5
""" Getting Started with Tkinter ============================================================================= from tkinter import * window=Tk() # add widgets here window.title('Hello Python') window.geometry("300x200+10+20") window.mainloop() """ """ Button Customization ===========================...
f80c8eafe96dc5d0b9ee4ff61043c0f1f8241726
facundolucianna/botR2
/bot.py
3,096
3.5625
4
import numpy as np class Bot(object): """Clase base de robot""" def __init__(self): """constructor de la clase Bot """ """El sensor guarda la ultima deteccion del entorno del robot, cuyo formato es un array de np de dim. 4, donde cada elemento corresponde a una pare...
ec5af999a852f8f508611f17448d714ca97c5443
rangaeeeee/codes-dataStructure-algorithms-python
/chapter 01/R-01-06.py
470
4.28125
4
#!/usr/bin/python3 ''' R-1.6 Write a short Python function that takes a positive integer n and returns the sum of the squares of all the odd positive integers smaller than n. ''' def sumSquare(maxNumber): summation = 0 for i in range(maxNumber): if i & 0x1: summation += pow(i,2) return summation def...
22d54a95f2a6246e757d4d6cc1d9a4cdd3780107
anshulg825/Coursera-Assignments
/Coursera Algorithmic ToolBox/week2_algorithmic_warmup/2_last_digit_of_fibonacci_number/fibonacci_last_digit.py
340
3.828125
4
# Uses python3 import sys def get_fibonacci_last_digit_naive(n): arr = [] arr.append(0) arr.append(1) for i in range(2,n+1): arr.append( (arr[i - 1]%10) + (arr[i - 2]%10) ) return (arr[n]%10) if __name__ == '__main__': input = sys.stdin.read() n = int(input) print(get_fibonacci_l...
88ffd690b0914ba0f58eb9771ffccb1ce00a02c8
Lisa-Mays/CMIS102_Assignments
/caloriesinaday.py
893
4.09375
4
# Write Welcome to the Calorie Counter, a program to calculate calories consumed in one day print ('Welcome to the Calorie Counter!') # Prompt the user for total breakfast calories breakfast_calories = eval(input('Please enter the total calories for breakfast: ')) # Prompt the user for total lunch calories lunch_calo...
9e682d1450f190fdf6937e692433fc568c383cd6
BJV-git/leetcode
/trees/bottom_up_traversal.py
516
3.84375
4
# logic: just traverse and append in first of stack, the right and then the left # return the recursive lc + recursive rc .extend [l.val, r.val] # learned: we can use queue inorder to keep track of the numbers we get at each stage and then append fo later def levelOrderBottom(root): if not root: return [] res,...
03699572684ff335fa1223c93a7bafb49951a45d
super-ru/surui
/pythontask03.py
168
3.640625
4
num01=input('第一次输入数字:') num02=input('第二次输入数字:') num01=int(num01) num02=int(num02) sum=num02+num01 print('两个数字的和为%d'%(sum))
41f00355980f5802a34b200c699ae909771681c6
kawai-yusuke/class_review
/b_2.py
614
3.84375
4
class Customer: def __init__(self, first_name, family_name, age): self.first_name = first_name self.family_name = family_name self.toshi = age def full_name(self): print(f"{self.first_name} {self.family_name}") def age(self): print(self.toshi) ken = Customer(first...
4d3f43ee77bbda1d5f95621451614c133a962fbe
cqr-cryeye-forks/find_js_links
/find_js_files/utils/link_extractor.py
629
3.609375
4
""" Link Extractor module extracts links from html uses BeautifulSoup to perform this operation """ from bs4 import BeautifulSoup from .constants import Types def extract_links_with_beautiful_soup(objects: Types.RESULTS) -> None: """ Private method to extract links from html with help of BeautifulSoup ...
79a705f46b5a9673bb28553f54f65301c577c2f9
shankar7791/MI-10-DevOps
/Personel/kalyani/python/5Mar/prog3/fibonacci.py
418
4.3125
4
# WAP TO solve the fibonacci sequence using recursion. def fibo(n): if n <= 1: return n else: return(recur_fibo(n - 1) + recur_fibo(n - 2)) n = int(input("Enter number of terms:")) print(" fibonacci sequence :") for i in range(i) print (recur_fibo(i)) # Algorithm # create fibonacci functio...
ac552a3f9274c873d68e1c7fac1fa00912a433d9
bylijinnan/pythonLearn
/checkio/repeatingDecimal.py
1,584
3.5625
4
def checkio(fraction): numerator, denominator = fraction if numerator < 0 or denominator < 0: raise argparse.ArgumentTypeError("invalid input, must be positive integer") q, r = divmod(numerator, denominator) quotient = [q] remainder = [r] while r: r *= 10 q, r = divmod(r...
1ae36d18c3718fc978bc42e1a88d3abd1bd099b9
whiteblue0/Prelearnig
/6303.py
144
3.5
4
L1 = [1,3,6,78,35,55] L2 = [12,24,35,24,88,120,155] lst = [] for i in range(len(L1)): if L1[i] in L2: lst.append(L1[i]) print(lst)
3b3841dc9079bd665485cddb05cd2fac93d91163
pump-king/AX802
/class2-3/search.py
574
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sat May 23 09:33:53 2020 @author: marco """ data = [1,2,3,4,5,6] def linearSearch(data,value): a = 0 while data[a] != value: a += 1 return True def binarySearch(data,value): lower = 0 upper = len(data)-1 while lower <= upper: mid = (upp...
1e9bb7bdc399bdd363dd8cff909753b2d0a2ea6d
SplitKrosGT/GeneratPassword
/brute.py
2,353
3.5
4
import hashlib import os import time from Password import Password password = Password() count_symbols = input('ведите количество символов в пароле:') pin_code = input("Введите PIN CODE для шифрования пароля (4 цифры): ") if not pin_code.isdigit(): pin_code = None if count_symbols.isdigit(): p...
db0869a7fcb36bed96665be93c70db3ee3b32eac
Hellofafar/Leetcode
/Hard/72.py
2,130
4.0625
4
# ------------------------------ # 72. Edit Distance # # Description: # Given two words word1 and word2, find the minimum number of steps required to convert word1 to # word2. (each operation is counted as 1 step.) # # You have the following 3 operations permitted on a word: # # a) Insert a character # b) Delete a ...
b2f4070440854b7393f435f6139060181de89905
nishalpattan/DataStructures-Algorithms
/CTCI/Arrays_and_Strings/isUnique.py
1,160
4.1875
4
""" Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? """ def isUnique(Str): """ method uses hash set, by adding chars in it and checking if char already present :param Str: :return: bool Time Complexity : O(N) Space Co...
183d28b1130202b97f36b20e12b8a1fbe1e1a80f
NandaGopal56/Programming
/PROGRAMMING/python practice/example-15.py
484
3.546875
4
class employee: def __init__(self,x,y): self.x=x self.y=y def verify(self): print(self.x) class calculate: def __init__(self,l): self.l=l def check(self,inc): self.inc=inc for i in self.l: i.x=i.x+self.inc print(i.x) ...
ad48574dd650b33fbc77d1c4b4eefbb2e6330be4
tamizhselvan98/Guvip
/positiveno.py
144
4.1875
4
number=int(input("enter the number")) if(number<0): print("positive") elif(number==0): print("zero") else: print("negative number")
81364dae1e1bd4563100546d3adad3280ab61f10
AlexTaguchi/nlp-notes
/examples/train_word_embedding.py
9,024
3.6875
4
# Next Token Prediction with Transformers # ======================================= # https://pytorch.org/tutorials/beginner/transformer_tutorial.html # # Purpose: Train the transformer model described in "Attention Is All You Need" # (https://arxiv.org/pdf/1706.03762.pdf) on a language modeling task to predict # the ...
ba7060abf159d7930c32a0d8e04f6dc5f6236cb8
sapnadeshmukh/More_exercise_python
/password_validation.py
247
4.09375
4
password=input("enter a password") if len(password)>=6 and len(password)<=16 : if "$"in password: if "2"or"8"in password : if "A"or"Z" in password: print ("strong password") else: print("weak password")
94223c868018345921ef93689d8c11f6464238e0
Kola1506/amis_python
/km72/Davidenko_Mykola/task_6.py
307
3.921875
4
x = int(input("Enter the number of students in the first group : ")) y = int(input("Enter the number of students in the second group : ")) z = int(input("Enter the number of students in the third group : ")) X = int((x//2)+(x%2)) Y = int((y//2)+(y%2)) Z = int((z//2)+(z%2)) print(X + Y + Z) input()
6369de05664b449808df359ef04892944aa576be
xususan/apcomp-221
/pset1/src/deidentifier_util.py
5,150
3.671875
4
#!/usr/bin/evn python3 # -*- coding: utf-8 -*- """ Created on 2019-02-18 @author samuelclay xususan """ import random def qi_for_line(line, qi_columns, headers): """ Returns a list of quasi identifiers for a given line, in order that they appear. :param line: A list of entries, represents one row of a CSV ...
84f6bf995ab646b2cdf9235e5586a811c6a21ac6
mao/python_study
/chapter07/02_reservation.py
225
4.125
4
seattings = input('How many people in dinner?\n') if int(seattings) > 8: print('There is no table available now, do you mind confirm later?') else: print('There is an available table, do you like to reserve it now?')
5ecef08dcce09c92776bed13851321d944fd3836
StarRider/Pandas
/SavingDataFrametocsv.py
639
3.921875
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 21 19:43:41 2018 @author: SHALOM ALEXANDER """ import pandas as pd #saving the dataframe to csv my_dict = { 'City':['Delhi','Mumbai','Kashmir'], 'Country':['India','USA','Egypt'], 'River':['Krishna','Ganga','Amazon'] } dict_dat...
56b6018fd01bc4c77e37c06b4b57abd8bd806c04
rajkhub/cert
/LeetCode/MinimumSwapstoMakeStringsEqual.py
899
4.09375
4
# Example 1: # Input: s1 = "xx", s2 = "yy" # Output: 1 # Explanation: # Swap s1[0] and s2[1], s1 = "yx", s2 = "yx". # Example 2: # Input: s1 = "xy", s2 = "yx" # Output: 2 # Explanation: # Swap s1[0] and s2[0], s1 = "yy", s2 = "xx". # Swap s1[0] and s2[1], s1 = "xy", s2 = "xy". # Note that you can't swap s1[0] and...
0ceca4b56f7e3307e82e2977993f3ebeb781546b
jennifersurjono/American_Sign_Language
/American Sign Language.py
6,099
3.59375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #Import all necessary packages import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from IPython.display import Image from sklearn.preprocessing import LabelBinarizer from sklearn.model_selection import train_test_split from tenso...
0f22b249f351bfef7798be6cbf0d567a2c6de9bb
ravikr126/Data-Structures-And-Algorithms-Hacktoberfest18
/python/algorithms/MergeSort.py
697
3.828125
4
def mergeSort(alist): if len(alist) > 1: mid = len(alist)//2 leftSide = alist[:mid] rightSide = alist[mid:] mergeSort(leftSide) mergeSort(rightSide) i=j=k = 0 while i < len(leftSide) and j < len(rightSide): if leftSide[i] < rightSide[j]: ...
f230b62e694e6b5fb69445be355e020b53c4b425
xytill/tic-tac-toe
/Topics/For loop/List from input/main.py
107
3.546875
4
n = int(input()) print_list = [] for _ in range(n): print_list.append(int(input())) print(print_list)
368d51a268756382b9d7038191eb45fd1c05aa48
gsakkas/seq2parse
/src/human_study/program_41/user_fix.py
159
3.84375
4
def primes(n): primes = [] i = 0 while i < n: if i / n == int(i / n) and i == n: primes.append(i) return primes primes(23)
183504eb98584485f90832565e51605def7f3228
marvelous-ikechi/Webscraping
/Python_events.py
1,004
3.53125
4
""" Scraping python events from https://www.python.org/events/python-events/ """ # import libraries. import requests from bs4 import BeautifulSoup def python_events(url): filename = 'Python_events.csv' f = open(filename, 'w', encoding='utf-8') headers = 'Name, Date, Location \n' # creating the csv file ...
058b375e693674d7ccacadcad6c478eddbbbda55
faseehahmed26/Python-Practice
/random.py
107
3.578125
4
import random,math for i in range(10): print(random.randrange(-22,-5)) #print('\n') print(math.pi)
0c67a6a153e3493f781f855fb1c77a8f140b765a
pedroYair/python_practice
/lambda_functions.py
756
4.5
4
"""FUNCIONES LAMBDA: tambien llamadas funciones anonimas permiten simplificar las funciones en unas pocas lineas de codigo. Usualmente se crean para ser pasadas como argumentos en funciones de orden superior como filter y map """ doblar = lambda numero: numero * 2 print(doblar(10)) lista = [1, 2, 3, 4, 5] lista4 =...
84c2aaf842dadb4394c539c6d36d520c8718b6d4
prameshb87/Interviewcodes
/Code/quickSort.py
536
3.703125
4
def quick_sort(a, low, high): def partition(l, h): pivot = a[l] i, j = l, h-1 while i < j: while i < h and a[i] <= pivot: i+=1 while j > l and a[j] > pivot: j-=1 if i < j: a[i], a[j] = a[j], a[i] a[l], a[j] = a[j], a[l] return j if low <...
a7dd72951242b1c4074e22d1f186f0e7b3af4e55
zhenjiaaa/kattis
/okviri.py
600
3.8125
4
def okviri(): row1 = '.' row2 = '.' row3 = '#' line = input() for i, char in enumerate(line): symbol1, symbol2 = '#', '#' if i % 3 == 1: symbol2 = '*' if i % 3 == 2: symbol1, symbol2 = '*', '*' row1 += f'.{symbol1}..' row2 += f'{symbo...
cab1ed30b7d9477e3c382bff2ade0349215b76bd
kayaei/pands-project
/iris_dataset.py
328
3.515625
4
# Etem Kaya 08-Apr-2019 # Iris Data Set Project. # Print Iris Dataset in Tabular format # import pandas library import pandas as pd # import csv file with pandas iris = pd.read_csv('iris.csv') print(iris) # print the entire dataset # convert csv file to a dataframe df = pd.DataFrame(iris) print(df) # print the ...
cbe76809e5323c14232c437c0ae34c77e95e4c72
masonwang96/Backpropagation
/LinearRegression.py
2,304
3.65625
4
import math import numpy as np import matplotlib.pyplot as plt class LinearRegression(): def __init__(self, x, y, learning_rate, num_iterations): self.x = x self.y = y self.learning_rate = learning_rate self.num_iterations = num_iterations self.W = np.zeros(shape=(1, 1)) # m x 1 self.b = np.zeros(shape=...
8a27b2c13bca224997c9c21b178dac954c5f4338
EshwarMuthusamy/python_api_training
/listscript.py
348
3.921875
4
#!/usr/bin/python3 def main(): mylist = [] mylist.append('192.168.23.3') print(mylist) mylist.append('10.0.0.1') print(mylist) mylist2 = ['127.16.23.1', "10.32.21.1"] print(mylist2) mylist.extend(mylist2) print(mylist) print(mylist[-3]) ml3 = [1,2,3] print(ml3) if __name_...
937fb4072d98f166f20a8304f2e1c4caeecbb969
DiasDogalakov/ICT_2020
/task 3/7.py
272
3.671875
4
a = int(input()) #ok s = input() s = s.lower() l = [] uniqList = [] for i in range(0, len(s)): l.append(s[i]) l.sort() for i in l: if(i not in uniqList): uniqList.append(i) if(len(uniqList) == 26): print("YES") else: print("NO")
6ab24d5a50e48cad0968dea15cd4d5961d7831c5
17621251436/leetcode_program
/5深度优先搜索/101 对称二叉树.py
438
3.734375
4
class Solution: def isSymmetric(self, root: TreeNode) -> bool: def issim(node1,node2): if not node1 and not node2: return True if node1 and node2 and node1.val==node2.val: return True else: return False if not root...
c7a161253aba9e0f248cfd97bc0e35a348b3f307
diciwi2016/er-lifesaver
/userdb.py
3,099
3.90625
4
import hashlib ############################## # takes params (username, password) # # to verify if username & password matches # ############################## def verify(u, p, fname): d = {} #dictionary for each user account uname = str(u) pwd = str(p) f = open(fname, 'r').read().str...
540627f3c9eb9065c9f6dd582a1418f62ef723f1
callmexss/learn-python
/python_tips/Pytricks/sorted_dict_by_value.py
752
3.5625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """"""""""""""""""""""""""""""""""""""""""""""" " Filename: sorted_dict_by_value.py " " Author: xss - callmexss@126.com " Description: Sorted dict by value " Create: 2018-08-13 10:46:25 """"""""""""""""""""""""""""""""""""""""""""""" import random import ...
508321cabd704b72ed6e3dcc1884388c8c9bbc21
jimmy623/LeetCode
/Solutions/Palindrome Partitioning.py
1,051
3.640625
4
class Solution: # @param s, a string # @return a list of lists of string def partition(self, s): self.result = [] self.dfs(s,[]) return self.result def dfs(self,s,route): n = len(s) if n == 1: r = list(route) r.append(s) ...