blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d433a9fdfce3ef469e223c8fba4bc0a691270f3f
xiaodongzi/pytohon_teach_material
/02/exec01-teach.py
150
3.53125
4
# name = raw_input('input your name: ') # name_list = ['wd','pc','reboot'] num_list = [1,2,3,4,5,6] l = 0 for num in num_list: l += 1 print l
56f063a2269cd5ac6f238290e1c14912528a9e16
aelk/loga
/math/lcm.py
345
3.9375
4
from fractions import gcd def lcm(a, b): """Returns the least common multiple of a and b: that is, the smallest positive integer x such that a divides x and b divides x.""" try: if a < 0: a *= -1 return (a / gcd(a,b)) * b except ZeroDivisionError: print("Error: the least common multiple of two zeros is un...
804fe85dd64e4de9df0f01f0d1a792727f885231
YannickBloemen/airHockey
/airHockey.py
11,089
3.578125
4
# sumloky # (Edward) Sum Lok Yu #-------------------- # Import a library of functions called 'pygame' import pygame import random # Initialize the game engine pygame.init() # Define some colors black = ( 0, 0, 0) white = ( 255, 255, 255) green = ( 0, 255, 0) red = ( 255, 0, 0) blue = (...
ee15bf3bf5e03b4b3df3752e3858ac3f231f730f
peterpeng1993/learngit
/script/python/对象例题.py
1,482
3.75
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 26 08:56:37 2018 @author: asus """ class HotDog: def __init__(self): self.cocked_level=0 self.cocked_string='Raw' self.condiments=[]#列表 def __str__(self): #改变对象的打印方式 msg='hot dog' if len(self.condiments)>0:#字符串长...
52967e893653a28cab3e646c3870444eb0b08239
peterpeng1993/learngit
/script/python/12-1列表操作.py
556
4
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 19 19:40:44 2018 @author: asus """ namelist=[] print('Enter 5 names(press the Enter key after each name):') for i in range(5): name=input() namelist.append(name) print('The names are',namelist) new_namelist=namelist[:] new_namelist.sort() print('Th...
f8ba09c54f5b1e2bd5203b31d39065c0711b87fe
peterpeng1993/learngit
/script/python/对象创建.py
773
4.0625
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 22 20:09:38 2018 @author: asus """ class ball:#创建类 def __init__(self,color,size,direction): #初始化 self.color=color self.size=size self.direction=direction def bounce(self):#定义对象属性 if self.direction=='down':...
0532ed96e44fb264d5d204b133a0abaaf1c49451
dashayushman/playground
/binary_tree.py
2,993
3.9375
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def insert(self, value): if value < self.data: if self.left is None: self.left = Node(value) else: self.left.insert(value) el...
28c98481b337463dd9caa925c99399e7a0e075dc
DigitalWarrior/GiftExchangeOnline
/single_selector.py
3,963
3.609375
4
#!/usr/bin/env python # kwidman # 12/1/11 updated April 24, 2013 # Christmas name selector import random from emailer import DEBUG class GiverReceiverPair(object): '''Class to hold a pair of giver and receiver. Note that receiver can be a list of receivers. ''' def __init__(self, giv...
459f04d4feeecec261a3f82a1cf6d4541a476918
Ribiro/Spaces
/service/InputService.py
306
3.6875
4
def process_input(input): to_process = input['input'] upper_case = to_process.upper() with_space = '' if "-" or "_" in to_process: with_space = to_process.replace('-', ' ').replace('_', ' ').replace('&', 'AND') return {'uppercase': upper_case, 'with_space': with_space}, 201
466574d797dd5254b4eca8f3d1f8454c1f4031ae
oguzey/data-mining
/heaps_law/heaps.py
805
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys sys.path.append('helpers') from helpers import * if len(sys.argv) != 3: print "Invalid amount of arguments. Expect two filename." exit(1) input_text = sys.argv[1] output_file = sys.argv[2] words = read_words_from_file(input_text) step = 1000 pairs = [...
26b73ba23c5eb0c1c1d11a27e1670ee5c2f8f301
gustahvo/python_start
/sample_madlibs/madlibs.py
584
4.1875
4
#string cocatenation (how to pu strings together) #suppose we want to create a string that says 'subscribe to _____' youtuber='Gustahvo'#some string variable # a few ways to do this print('subscribe to '+ youtuber) print('subscribe to {}'.format(youtuber)) print(f'subscribe to {youtuber}') adj = input('adjective:') v...
58a90e42d7133eb53101f2b32a88fc844c228a2e
utkini/Sam_bot
/db and other/create_DB.py
642
3.6875
4
import sqlite3 conn = sqlite3.connect('orfDB.db') c = conn.cursor() #c.execute('''CREATE TABLE dictionary # (id integer, name text)''') #Удаление элемента по его айди(если айди повторяется, то все элементы с этим айди будут удалены) #conn.execute("DELETE from dict where name='';") #conn.execute("DELETE FROM di...
0dad437830510ea51187f112a856e43aa925de65
manuelzander/python-recipes
/recipes/Standard_Python/all_elements_equal.py
346
3.984375
4
def all_elements_equal(my_list, check_val=None): ''' Returns true of all elements in the list are equal to a provided value or all the list elements are the same if no check value is provided. ''' if check_val: return all(x==check_val for x in my_list) else: return all(x==my...
a624e05f7fd257e223a37563dd46895aa0e4c2d9
manuelzander/python-recipes
/recipes/Standard_Python/any_elements_equal.py
171
3.5
4
def any_elements_equal(my_list, check_val): ''' Returns true if any value in the list equals the check value. ''' return any(x==check_val for x in my_list)
6fe545c5cf06bd66248db513c7ee2bf33e3def73
sgoldt/deepget
/twolayer.py
3,984
3.546875
4
#!/usr/bin/env python3 # # Simple class for two-layer fully connected neural networks. # # Author: Sebastian Goldt <goldt.sebastian@gmail.com> # # Date: February 2020 import math import torch import torch.nn as nn SQRT2 = 1.414213562 def identity(x): """ Identity function, can be used as an activation func...
bdc92dd1460b57b914454a571bd39fe8e988ad14
patni11/Nand2Tetris
/Downloaded/nand2tetris/projects/07/main.py
1,899
3.828125
4
from Parser import Parser import argparse from Instructions import VMAssembly """ Look at Parser.py for the implementation """ def step1(): # Cleaning the file: Removing whitespaces, empty lines, comments etc parser = argparse.ArgumentParser() parser.add_argument('Path', type=str, help="drag your file h...
7b7482199fc39ddba9beb37c0aa6cede62584953
theharshbhatia/Python-for-software-design-book-solutions
/7_1.py
285
3.875
4
''' Complete soltion of Book "Python For Software Design by Allen B. Downey" by Harsh Bhatia ( www.harshbhatia.net ) ''' ''' Exercise 7.1: Rewrite the function print_n from Section 5.8 using iteration instead of recursion. ''' def print_n(s, n): while n != 0: print s n=n-1 print_n(2,7)
adcb40ce125f099e20ff4058cfbc3743946f3848
theharshbhatia/Python-for-software-design-book-solutions
/9_2.py
236
3.59375
4
def has_no_e(n): for letter in n: if letter == 'e': return False return True fin=open('words.txt') for line in fin: word=line.strip() r=has_no_e(word) if r==True: print(word)
da64cdd1b4276f938aa7e6f8e96f357b49c6168d
theharshbhatia/Python-for-software-design-book-solutions
/10_6.py
307
3.515625
4
def remove_duplicates(lost): lost.sort() k=0 for i in range(0,len(lost)-1): print(i+1) if lost[i]==lost[i+1]: lost[i]='0' k=k+1 for i in range(0,k): lost.remove('0') return lost s=['h','a','r','r','h','h','r'] print(remove_duplicates(s))
d767701f61faf2788a1bb296989ee69e10f814f6
jorgefdelahoz/ih_datamadpt0420_project_m1
/p_wrangling/m_wrangling.py
1,257
3.5
4
import numpy as np import re # In order to be able to analyze more accurately, it's necessary to make a previous data cleaning... # Lets modify values into lowercase... def lower_case(df): df['gender'] = df['gender'].str.lower() df['dem_has_children'] = df['dem_has_children'].str.lower() return df # Repla...
2afecf3fd48a8002db48d2c0fc3141ccc30f1ba8
defraction/python_backup
/1.3.6/Yoo_1.3.6.py
3,131
4.09375
4
import random '''Procedure''' # N/A '''Part 1: Turples, Syntax''' # 4. (3,7,9) # 5. One convention that a teacher requires of sumitted work it is that it must # have your name and period number on it. I am not sure what my teacher wants for # us to follow when it comes to naming python variables, but I assume it is t...
c0bd50a1deac173a90e19f5de12ac0fa6fdaf610
gongruya/Cousera-An-Introduction-to-Interactive-Programming-in-Python
/Mini-project-2-Guess-the-number.py
2,075
4.15625
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random import math maxnum = 100 secret_number = 0 remain = 0 # helper function to start and restart the game def new_game(): # initializ...
bcfacdce481d628ab731ec97b3ef4e3a08989b85
genji10122/python
/delO.py
574
4.125
4
def del_o(): ''' it for loops through the word and immediatley deletes all the o's or O's poop >>>pp ''' word = input("Enter a word: ") ## all the letters that are vowels should be deleted # Hint: for loop through the word and delete the letters # at the index of the vowel ...
7f7fffccdb836b63d051c9111a5faba961d929a4
genji10122/python
/easter.py
489
4.09375
4
name = input('Enter name:') print('Hello', name) ans1 = input('Is it a New Comp Season? (yushhh/nahhh)' ) while ans1 == 'nahhh': print ('awww man not yet!') ans1 = input('Is it a New Comp Season? (yushhh/nahhh)' ) print ('OMG FINALLYYY NEW SEASON!!!!!!') ans = input('Is i...
d5c033d2642861c590a6db0bba3433ae3ab1ca03
Dohwee-Kim/image_merge_tool
/gui_basic/reference_pys/4_text_entry.py
542
3.53125
4
from tkinter import * root = Tk() root.title("My GUI") root.geometry("640x480") txt = Text(root, width=30, height=5) #Text 는 여러줄 txt.pack() txt.insert(END, "글자를 입력하세요") e = Entry(root, width=30) # Entry 는 한줄 e.pack() e.insert(0, "please input here ") def btncmd(): print(txt.get("1.0", END)) #Grab the text ...
80e59411c790aa3dea14d42e987a9e91eafb04f1
devangdayal/Data-Structures-Algorithm
/Sort_Tech/MergeSort.py
1,541
4.34375
4
# In this Code, We will see Merge Sort Algorithm # Config Python3 # Merge Sort Implementation Code def mergeSort(narr,n): if(n>1): # Finding the Center of the Array center=n//2; right_Section=narr[center:] left_Section=narr[:center] # We will call the array again to cut ...
be2057beb759cdd856c29f61adbb4e033421e3b3
bluelotus03/web-scrape-python
/part4.py
417
3.65625
4
from bs4 import BeautifulSoup import requests # Make the request to the url to get its content page = requests.get("https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/") soup = BeautifulSoup(page.content, 'html.parser') # Extract title of the page page_title = soup.title.text # gets yo...
29f1473e89ff4b5d61e611986a5bc1a6ec365990
Natsuki27/pythonclass
/subject.py
7,711
4.46875
4
import os import pickle class Student: """This is a class definition of q student object""" def __init__(self, first_name="", last_name="", ID=0): """This is a class constructor the __init__ is short initialization.a This will create an instance of the class. type subjects: object""" ...
76548b43a1dfa702909f6f8acee4d1af279848b1
sujanchory/Learning-Python
/Table(ForLoop).py
74
3.703125
4
num=int(input()) for i in range (1,21): print (num, "X",i,"=",num*i)
538454cd57c3f3c88dd9dfefb9ac04113139190f
sujanchory/Learning-Python
/Fibonacci_Series.py
250
3.65625
4
def gen_fib(n,a=0,b=1): if n==0: return if n==1: print(a) return print(a,b,end=" ") for i in range(3,n+1): c=a+b print(c,end=" ") a=b b=c n=int(input()) gen_fib(n)#fun call
e06d8f07be4c28a4a5d77dadfa83650b1eab759e
sujanchory/Learning-Python
/Strong_Number.py
268
3.875
4
num=int(input()) temp=num summ=0 while num>0: r=num%10 num=num//10 fact=1 for i in range(r,0,-1): fact=fact*i summ+=fact if summ==temp: print(temp,'is a Strong Number') else: print(temp,'is not a Strong Number')
6192b50c2090d4ff74da5cd8929b244c9a1cd661
jsergiu/daily-coding-problem
/april/day-05.py
1,420
4.25
4
''' This problem was asked by Google. The area of a circle is defined as πr^2. Estimate π to 3 decimal places using a Monte Carlo method. Hint: The basic equation of a circle is x2 + y2 = r2. Monte Carlo methods rely on random sampling. In this case, if we take a cartesian plane and inscribe a circle with radius r ...
3a4957540b9a5c9ccc96d99ca5ad6e63c567acc8
maksymshylo/algorithms_and_data_structure
/Алгоритми і структури даних/Лаба5/test.py
4,501
3.8125
4
#import something class Node: def __init__(self,data): self.right = None self.left = None self.data = data class BinarySearchTree(object): """docstring for BinarySearchTree""" def __init__(self): super( BinarySearchTree, self).__init__() self.twins = [] se...
6b4d4a467f967d4b785e56e42a0d3d11bfafee4f
dailinou/507
/week2/in_class_exercise.py
509
3.75
4
# given a location, return stops in a half a mile radius # param: a location string # return: a list of stops in a half mile radius def stops_in_a_half_a_mile_radius(location): return stop_list # given user’s input of an interested stop, return a list of arrival time for all bus lines come to the stop within the ne...
36ead7fb31d9322fa90fbbde222f04fcb4171eca
debaser990/ml-SwedishInsuranceDataset
/LinearRegress.py
1,707
4.0625
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd #from sklearn.datasets import load_boston ## imports datasets from scikit-learn ''' boston = load_boston() bos = pd.DataFrame(boston.data) bos.columns = boston.feature_names print(bos.head()) print(boston.target.shape) bos['PRICE...
68c713928c2e80999ecd214608ebe6c562300275
james-preston/100daysofcode-with-python-course
/days/01-03-datetimes/code/pomodoro_timer_sleep.py
511
3.890625
4
#!/anaconda3/bin/python3 from time import sleep loopcount = 1 loopmax = 4 # Smaller numbers for testing workmins = 2 #workmins = 20 breakmins = 1 #breakmins = 5 print("Get to work.") while loopcount < loopmax: sleep( workmins * 2 ) #sleep is in seconds #sleep( workmins * 60 ) #sleep is in seconds print("Take a ...
1d7f83e679dee0551eb4376cb0fd75bb5e72c9a6
hideomit/samurai_code
/score.py
384
3.671875
4
class Score: def culc(self): eng = input("英語の成績を入力してください") math = input("算数の成績を入力してください") Sum = (int(eng) + int(math) ) avg = Sum/2 print("合計は{}です".format(Sum)) print("平均点は{}です".format(avg)) score = Score() score.culc()
e472c0d8f9afac9c09fcce547ce3149eaed06a3d
r-sorna/learn-python
/.foramt&input.py
243
4.03125
4
name=input("my name is") cur_age=int(input("current age is")) mar_age=int(input("i want to marriage in my age")) print( " i am {} and my current age is {} and i wnat marriage in {}".format(name,cur_age,2019+mar_age-cur_age))
d213c713ef0e9a33158c219ee433919af1a97b7e
Jaspal7/facs
/facs/readers/read_age_csv.py
311
3.546875
4
import pandas as pd import numpy as np import sys def read_age_csv(csv_name, header_name=""): df = pd.read_csv(csv_name) df.columns = map(str.lower, df.columns) if header_name not in df.columns: header_name = "United Kingdom" ages = df[header_name.lower()].to_numpy() return ages / np.sum(ages)
8ac6e82122c2f455f6369de0b4754424b7249004
emirarditi/IEEEPythonDersleri
/Lecture4/BasicClasses.py
1,161
3.625
4
class Insan: def __init__(self, boy, kilo, grengi, suzun, srengi, yas, cinsiyet, isim, soyad): self.boy = boy self.kilo = kilo self.grengi = grengi self.suzun = suzun self.srengi = srengi self.yas = yas self.cinsiyet = cinsiyet self.isim = isim ...
f4a04c24e91a917ab11990a0115c8a35383044b1
emirarditi/IEEEPythonDersleri
/Lecture4/LibraryProgram.py
2,847
3.859375
4
class Kitap: def __init__(self, isim): self.isim = isim self.mevcutluk = True self.kimde = None def kitabiTeslimVer(self, isim): self.mevcutluk = False self.kimde = isim def kitabiTeslimAl(self): self.mevcutluk = True self.kimde = None def __str...
dda8e0bdd2712e1c71659dd2c44d8bd6aa47ec45
ruoruodefanbu/py_ex
/hello.py
442
3.84375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import tkinter as tk def btnHelloClicked(): labelHello.config(text = "Hello,我的小宝宝!") top = tk.Tk() top.title("我开始写桌面程序啦啦啦") labelHello = tk.Label(top, text = "Press the button...", height = 20, width = 80, fg = "blue") labelHello.pack() btn ...
1d60f848a6da6dbcd84229bd3017b1fd716be45c
jsh854/Hacktoberfest2021_PatternMaking
/Python/downward_traingle_pyramid_pattern.py
478
4.53125
5
rows = int(input("Enter the number of rows: ")) # It is used to print space k = 2 * rows - 2 # Outer loop in reverse order for i in range(rows, -1, -1): # Inner loop will print the number of space. for j in range(k, 0, -1): print(end=" ") k ...
8626be2c1b54e05953119330f88feb3900fe0e65
loczylevi/p1
/f7.py
404
3.609375
4
#a. a = int(input('Első szám: ')) b = int(input('Második szám: ')) print(a, '*', b, '=', a * b) #b, a = int(input('Első szám: ')) b = int(input('Második szám: ')) print(a, '-', b, '=', a - b) #c a = int(input('Első szám: ')) b = int(input('Második szám: ')) print(a, '+', b, '=', a + b) #d a = int(input('Első szám: ...
69a6c07239712478017a984bad6f73619c2ddafa
RickyCaoCao/ProgrammingNotes
/python/python_review/ex22.py
831
3.609375
4
# Exercise 22 - Read from File # str.strip() removes the \n # To add keys, just dict['newkey'] # Original # with open("nameslist.txt", 'r') as open_file: # names_list = {} # name = open_file.readline().strip() # while name: # if name in names_list.keys(): # names_list[name] += 1 # ...
5948493786f04e70d4df081ff78871074f3bd03a
RickyCaoCao/ProgrammingNotes
/python/python_review/ex13.py
422
4.25
4
# Exercise 13 - Fibonacci # Use for i in range(..) than while loop def create_fib(num=1): if num < 1: print('Error: We need positive num.') elif num == 1: return [1] elif num == 2: return [1, 1] else: fib = [1, 1] for i in range(2, num): fib.append(fi...
85f53771d08ba4676b0d9bcb2545aa7e965fcc4e
jaeyun95/Programmers
/level2/level2_ex29.py
695
3.578125
4
#(29) 지어 제거하기 def solution(s): answer = [] for i in s: if not(answer): answer.append(i) else: if(answer[-1] == i): answer.pop() else: answer.append(i) return not(answer) #다른 코드 ''' from collections import deque def ...
5316a024cef224807710b1e36dfc60d99b1db5f5
jaeyun95/Programmers
/level1/level1_ex21.py
232
3.703125
4
#(21) 자연수 뒤집어 배열로 만들기 def solution(n): answer = list(map(int, list(str(n)))) answer.reverse() return answer # 다른 코드 ''' def solution(n): return list(map(int, reversed(str(n)))) '''
e9a7c584963b30f0992c7fea52aebf196d53387b
jaeyun95/Programmers
/level1/level1_ex22.py
293
3.578125
4
#(22) 정수 제곱근 판별 import math def solution(n): if not math.sqrt(n).is_integer(): return -1 return (math.sqrt(n)+1)**2 # 다른 코드 ''' import math def solution(n): if not math.sqrt(n).is_integer(): return -1 return pow((math.sqrt(n)+1),2) '''
82c1a51e89fb72183c1fe5aea69f29ff58c884b3
jaeyun95/Programmers
/level3/level3_ex36.py
1,638
3.65625
4
#(36) 합승 택시 요금 ### dijkstra import heapq def dijkstra(start, graph): distance = {key: float("INF") for key in range(1, len(graph))} heap = [] distance[start] = 0 heapq.heappush(heap, [distance[start], start]) while heap: now_dis, now_node = heapq.heappop(heap) for next_node, next_...
fab080e6aa62b5f73235e07c99b7c7007f854970
CamiloYate09/Python_3_Total
/Functional Programming/map_3.py
582
4.25
4
''' map The built-in functions map and filter are very useful higher-order functions that operate on lists (or similar objects called iterables). The function map takes a function and an iterable as arguments, and returns a new iterable with the function applied to each argument. Example: ''' def add_five(x): retur...
99f9f41229cd288a5bbaa30326c6b81a9d3a4bb0
CamiloYate09/Python_3_Total
/types/Dictionary_Functions.py
763
4.3125
4
''' Dictionary Functions Just like lists, dictionary keys can be assigned to different values. However, unlike lists, a new dictionary key can also be assigned a value, not just ones that already exist. ''' squares = {1: 1, 2: 3, 3: "error", 4: 15} squares[8] = 64 squares[3] = 9 print(squares) #Example:2 primes = {1...
b4e5835ddc76189cb9761585eea0c76d44e194f8
CamiloYate09/Python_3_Total
/Functional Programming/Sets_8.py
772
4.09375
4
''' Sets Sets are data structures, similar to lists or dictionaries. They are created using curly braces, or the set function. They share some functionality with lists, such as the use of in to check whether they contain a particular item. ''' num_set = {1, 2, 3, 4, 5} word_set = set(["spam", "eggs", "sausage"]) pri...
4c33c489116960a92740a75e53a7fd5a4b67c668
wetorek/datastructures
/arrays/sliding_window_max_element.py
720
3.75
4
# Problem URL: https://practice.geeksforgeeks.org/problems/maximum-of-all-subarrays-of-size-k/0 # Solution: https://www.geeksforgeeks.org/sliding-window-maximum-maximum-of-all-subarrays-of-size-k/ from collections import deque T = int(input()) for _ in range(T): N, K = map(int, input().split()) arr = list(ma...
2b1af967a342a7c7122d6b04b962fb085cd429db
denorlov/PythonBeginners
/forloops/3_months.py
197
4.125
4
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] # Display all the months. for i in range(0, len(months)): print('Month number', i, 'is', months[i])
568e40300d9f4dfca2489dd4643f373b939016fc
danbulgarian/PT1
/Test2.py
1,587
4.09375
4
# declare and assign 'My name is' to a new variable called 'myNameIs' myNameIs = ("My Name Is") # define a new function with 1 parameter and print myNameIs and the value # of the function parameter def function1 (): print (myNameIs) function1 () # define a new function with 1 parameter. The function should print th...
4264428f55dacd0a2b65385874113776847da35a
Anfany/Funny-Math-Problem-by-Python3
/Fractal/Koch_curve.py
3,091
3.8125
4
# -*- coding:utf-8 -*- # &Author AnFany # 利用python绘制科赫雪花曲线 from math import cos, sin, radians import numpy as np import matplotlib.pyplot as plt from pylab import mpl # 作图显示中文 mpl.rcParams['font.sans-serif'] = ['FangSong'] # 设置中文字体为新宋体 class KOCH(): def __init__(self): # 设定图像的横纵坐标最大...
e19cc24f86c772b27d909b99078922afbc5242aa
justin-bao/word_acronym_checker
/word_acronym_reader.py
2,065
4.1875
4
#!/usr/bin/env python3 # Program for reading all the acronyms in a .docx file import re from docx import Document from docx.shared import Inches def get_all_acronyms(path): """ Find every (possible) acronym in the document (i.e. in the form of 'An Example Acronym (AEA)') Looks for any alphanumeric tex...
69095eab4a501e60308e676035169b04457af9bf
HackingForGood/Bagdrop
/pythonversion.py
4,941
3.609375
4
def signup(): b = raw_input('Host or Guest? ') if b == 'Host': c = raw_input('Sign in or Sign Up? ') if c == 'Sign in': username = raw_input('Username = ') password = raw_input('Password = ') if verify_username_and_password(username, password, database) == "no...
ce028a82d3aa69cd908fe13c2b1f81ae11281126
Dpka-2003/project-1
/Project 1.py
1,136
3.84375
4
import csv def wcsv(info): with open('studinfo.csv','a',newline='') as csv_file: writer=csv.writer(csv_file) if csv_file.tell()==0: writer.writerow(["NAME","AGE","CONTACT NUMBER","EMAIL ID"]) writer.writerow(info) if __name__=='__main__': condition=Tru...
a62cbc3316058cee6140b3ebba622f48e306e3d1
GabinTEKAM/Blackjack-game
/functions.py
1,864
3.8125
4
def take_bet(chips): while True: try: chips.bet = int(input('How many chips would you like to bet? ')) except ValueError: print('Sorry, a bet must be an integer!') else: if chips.bet > chips.total: print("Sorry, your bet can't...
8f933eb5e141d436c00d4a672bc77bef659428f6
nata2456/praktychna5
/lab4/task2.py
161
4.0625
4
num1 = float(input("a=")) num2 = float(input("b=")) if 1 <= num1 <= 2 or 3 < num1 < 7 and 1 <= num2 <= 2 or 3 < num2 < 7: print('yes') else: print("no")
928c6cfea8e3cf67c675c3e376f8c2b5a6c1254a
nata2456/praktychna5
/lab4/task3.py
501
3.890625
4
import math # the triangle is given by its coordinates # degenerate triangle x1 = float(input("x1=")) x2 = float(input("x2=")) y1 = float(input("y1=")) y2 = float(input("y2=")) z1 = float(input("z1=")) z2 = float(input("z2=")) a = math.sqrt((y1-x1)**2+(y2-x2)**2) b = math.sqrt((z1 - y1)**2+(z2-y2)**2) c = math.sqrt((z1...
9c73fe500bc6d73ab917c993bfabeac7828e4d88
nata2456/praktychna5
/lab5/practice5/task3.py
311
3.734375
4
# variant1 import math epsilon = float(input("epsilon = ")) x = float(input("x = ")) suma = 2 f = 1 n = 1 while True: result = abs((1/f)*((x-1)/(x+1))**(2*n-1)) if result >= epsilon: suma += result n += 1 f *= (2*n-1) else: break print("result = {0} ".format(suma))
2670abf2733b7bed7b5ba83c328d1d42330b7ba8
nata2456/praktychna5
/lab6/task3.py
408
3.78125
4
# x,y є R**n .Знайти суму векторів n = int(input('Кількість елементів векторів = ')) x_list = [float(input('Координата векора Х ')) for x in range(n)] y_list = [float(input('Координата векора Y ')) for x in range(n)] suma = list(map(lambda x, y: x + y, x_list, y_list)) print("сума векторів x i y = {0}".format(suma))
acf9947ef51f668bc986b97444f2f3f927d78aa7
kenji-tolede/Travaux-python
/EXO 16.py
255
3.9375
4
m1 = input('entrez 1er mot') m2 = input('entrez le 2eme mot') def hamming_distance(m1, m2): distance = 0 for i in range(len(m1)): if m1[i] != m2[i]: distance += 1 return distance print(hamming_distance(m1,m2))
7a892030094da2672ebd83374da2fd4bb85e8490
TheBrainGamingSingh/Semester-5
/Software Engineering/triangle.py
1,363
4.21875
4
import math def triangle(): print() #print() a = float(input('Enter length of side a : ')) b = float(input('Enter length of side b : ')) c = float(input('Enter length of side c : ')) if((a <= 0) or (b <= 0) or (c <= 0) or (a + b <= c) or (a + c <= b) or (c + b <= a) ): print('Triangle c...
ef7d0d8dcc043ad7b22b190820cf4451859e1c37
guerrak/Class-works
/ch10.1.py
479
3.609375
4
fname = input('Enter file name: ') try: fhandle = open(fname) except: print('File cannot be opened:', fname) exit() emails = dict() for line in fhandle: if line.startswith('From '): line = line.split() email = line[1] emails[email] = emails.get(email, 0) + 1 emailslist = [] for e...
2997f73c827a6a6ea15091a25d356648a2361f5f
guerrak/Class-works
/done.py
420
3.96875
4
count = 0 total = 0 while True: inp = input('Enter a number: ') # Handle the edge cases if inp == 'done': break if len(inp) < 1: break # Check for empty line # Do the work try: number = float(inp) except: print("Invalid input") continue count = co...
0ad0a5fed41797c7fa5a549ed951c169350023fb
ChallengerCY/Python-ListDemo
/pythonList/listDemo8.py
787
4.21875
4
#10、高级排序 #如果希望用特定的方式排序(python默认的排序方式是升序排列),可以使用compare(x,y)的形式定义比较参数 #compare(x,y)会在x>y时返回正数,在x<y时返回负数,在x=y时返回0,cmp(函数在python3中已经舍弃) #sort方法还有另外俩个可选参数key和reverse,如果要使用,就要通过名字来指定(关键字参数) #key参数必须提供一个在排序过程中使用的函数,为每个元素创建一个键,所有元素按照键来排序(例如长度) x=["c","cccc","cc","ccccccc"] x.sort(key=len) print(x) #另一个关键字参数reveser是简单的布尔值,来指明列...
17ff30f6802a545ad25d5fd750ab52843c191707
sujeet-kr/MLND
/data_preparation.py
8,611
3.546875
4
import numpy as np import re min_line_length = 2 # Minimum number of words required to be in a Question/Answer for consideration in training max_line_length = 30 # Minimum number of words allowed to be in a Question/Answer for consideration in training min_number_of_usage = 1 # minumum number of usage in the questions...
c287c6de105af1b5eb8f59bd6aa8d601784ed6d1
sanashahin2225/Sudoku_Solver
/Sudoku_Solver.py
1,645
4.1875
4
#This function is used to check WHETHER THE NUMBER TO BE PLACED IS VALID OR NOT def is_valid(board,row,col,val): if val in board[row]: return False else: for j in range(9): if board[j][col] == val: return False new_row = row % 3 new_col = col % 3 for i in ...
68d7af12ac71837875942a7b3ecd4c5f0fe9a47b
Zuker-nie/marihacks
/1.py
335
4.1875
4
def IntInput(x,y): while True: try: print(y, end="") x= int(input()) except ValueError: continue if x >= 0: return x break else: continue value = IntInput(int, "Please enter a positive integer:") ...
16fc5e9fcb76a4886e8a21aabc58927088f199d1
jasonfreak/arena
/1008/500/main.py
4,911
3.515625
4
from functools import wraps class BoardFolding(object): def __init__(self): object.__init__(self) def tonumber(self, character): if character.isdigit(): return int(character) if character.islower(): return 10 + ord(character) - ord('a') elif c...
d1ebb8c2ef54bd8a26138d444e7e35d0a8138b5b
jasonfreak/arena
/1028/250/main.py
783
3.546875
4
from itertools import combinations class Decipherability(object): def __init__(self): object.__init__(self) def check(self, s, K): cntOfChar = len(s) indexes = range(cntOfChar) rest = set() for c in combinations(indexes, K): c = sorted(c) ...
ec7c974125cac86ade28b03d6d62468a868209a2
jasonfreak/arena
/1029/250/main.py
502
3.640625
4
class DecipherabilityEasy(object): def __init__(self): object.__init__(self) def check(self, s, t): cntOfS = len(s) cntOfT = len(t) if cntOfS != cntOfT + 1: return 'Impossible' for i in range(cntOfS): if s[:i] + s[i+1:] == t: ...
c13149b36f30c83fc45847e64c448e1cdb658388
areebamunir/Python-Tkinter
/2_Pack,Grid,Place.py
1,233
4.21875
4
# How to create Labels Using Pack, Place and Grid # Uncomment individual system section to obtain particular labels # import tkinter as tk from tkinter import * root=Tk() #here root is an object root.title("Python GUI") #title class is use to give title to window root.geometry("800x400+200+50") #through geometry cla...
86bba2578bf7d29705e71527452b68f2ada66a41
areebamunir/Python-Tkinter
/14_Frame.py
596
3.578125
4
from tkinter import * from tkinter import messagebox root=Tk() root.title("Python GUI") root.geometry("1100x600+150+20") root.config(bg="#262626") #without label frame Window1=Frame(root,bg="lightgray",bd=10,relief=GROOVE) Window1.place(x=50,y=50,height=340,width=450) show=Button(Window1,text="Show").place(x=50,y=50)...
63b0ebebed70249f151a3cd5335ab1ab0bfe88f9
maxacode/youtube_api_practice
/Channel_Stats.py
2,293
3.671875
4
# Program that interacts with Youtube API # importing OS to get ENV vars import os # importing Google build module from googleapiclient.discovery import build # API key from ENV Var api_key = os.environ.get('yt_api_key1') # Building YT API service = build('youtube', 'v3', developerKey=api_key) #Asking user if they ...
4aacd44062e6dca8cab588dcfd1b1642fef799ca
hauwenc/learn-python-the-hard-way-book
/ex33.py
290
4.03125
4
def numbers_less_than (number,skip): i = 0 numbers = [] while i < number: print "At the top i is %d" %i numbers.append(i) i += skip print "Number now: ", numbers print "At the bottom i is %d"%i print "The numbers:" for num in numbers: print num numbers_less_than(30,4)
249ed91dd206cb2d071d096df0da1176a6d60d59
bazilmk/algorithms-and-data-structures
/Simple Programs/Find Max.py
1,169
4.0625
4
''' Name: Bazil Muzaffar Kotriwala Timestamp: 5:35pm 09 Dec 2016 ''' class Country: def __init__(self, cont, lead, pop): self.continent = cont self.leader = lead self.population = pop def leader_most_pop(): ''' This function compares the countries populations and returns the leade...
fd024540ffba9ed4a81bc1c9eb6609a4d063f82d
bazilmk/algorithms-and-data-structures
/Algorithms/Dynamic Programming/Burrows Wheeler Transform & Pattern Matching/quicksort1.py
803
4.03125
4
''' Author: Bazil Muzaffar Kotriwala Timestamp: 30-Mar-2017 6:00PM ''' def quick_sort(array): start = 1 end = len(array) - 1 quick_sort_aux(array, start, end) def quick_sort_aux(array, start, end): if start < end: marker = partition(array, start, end) quick_sort_aux(array, start, marke...
c70a855dfe99263bb34c1f0f56a7f99ee2c4b617
bazilmk/algorithms-and-data-structures
/Abstract Data Types (ADTs)/Arraybased_List/Arraybased_List_UnitTest.py
5,575
3.5625
4
''' Created By: Bazil Muzaffar Kotriwala Student ID: 27012336 ''' import unittest from Task_1 import ArrayOperations class myTest(unittest.TestCase): def test_str(self): obj = ArrayOperations() self.assertEqual(str(obj), "") # Case_1: checks whether the empty lis...
ed1231ace86680aa73aa4ae578388f043026cb9b
bazilmk/algorithms-and-data-structures
/Algorithms/Recursive Algorithms/Fibonacci Sequence/fibonacci_topdown.py
348
3.953125
4
def fibonacci(N): fib_memo = [-1] * (N+1) return fibonacci_memo(N, fib_memo) def fibonacci_memo(N, fib_memo): if N <= 1: return N elif fib_memo[N] != -1: return fib_memo[N] else: fib_memo[N] = fibonacci(N-1) + fibonacci(N-2) return fib_memo[N] if __name__ == '__main...
ec3323b53048e7d101e64152e364b6951126a751
bazilmk/algorithms-and-data-structures
/Algorithms/Min & Max/min.py
201
3.59375
4
''' Author: Bazil Muzaffar Kotriwala Timestamp: 04 May 2017 2:00AM ''' def min_element(array): min = array[0] for i in range(1, len(array)): if array[i] < min: min = array[i] return min
0e492262b71cbed60a1566b7a4937912e067b50b
bazilmk/algorithms-and-data-structures
/Algorithms/Dynamic Programming/Minimum Cost BST/splitter.py
2,622
4.25
4
''' Author: Bazil Muzaffar Kotriwala Timestamp: 25-Mar-17 12:01PM ''' import string def read_file(filename): ''' This function takes any supplied text file and reads through each character of the file & applies specific operations on it. :param: Any supplied text file :precondition: The text file must...
ac103bdeb75cbb7d6bf1769763a8b2c9136cfc24
bazilmk/algorithms-and-data-structures
/Algorithms/CD Store - Search & Sort Program/CD Store - Search & Sort Program.py
9,818
4.1875
4
'''Name: Bazil Muzaffar Kotriwala Student ID: 27012336 ''' print('Welcome to our online CD Store! \n') #This function is to create a database, which reads the contents of a file and stores all the content as a 2D List. #The Title, Artist and Genre is stored as a string inside the list, and the price of each cd ...
32b1796f796b9accd631603b09ad13af96fc9847
bazilmk/algorithms-and-data-structures
/Algorithms/Permutations - Sum base digits, Matrices, Inversions/permute.py
7,314
4.0625
4
''' Created By: Bazil Muzaffar Kotriwala Timestamp: 11 - Mar - 17 2:16PM ''' # Permute accepts integer N as argument # For the given N, program should iterate over N! numbers import string def factorial_iterative(N): ''' This function calculates the factorial for the given N iteratively. :param: An integ...
f1b14aa7c92ec444f2839d0d705334b2f9b66ecf
ravikumarreddy00/pythonscrips
/pythonfunction.py
261
3.875
4
#!/usr/bin/python def printinfo( name, age ): #print("Name%s"%(name)) #return # Only 2 spaces are enough "This prints a passed string in to this function" print("Name:%s" %(name)) print("Age: %d" %(age)) return printinfo( age=50, name="reddy" );
ca2424ca9ce0052e41a5e75cc377ce29daf451fd
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/More Exams/April_2020/2-Лятно_пазаруване.py
612
3.78125
4
budget = int(input()) towel_price = float(input()) discount = int(input()) umbrella_price = towel_price / 3 * 2 flip_flops_price = umbrella_price / 4 * 3 beach_bag_price = (towel_price + flip_flops_price) / 3 disc = discount / 100 final_price = (towel_price + umbrella_price + flip_flops_price + beach_bag_price) final...
d5167adb2226c177e567bc755dccd7187a7b8d9b
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/More Exams/July_2019/3-3-Туристическа_агенция.py
1,120
3.90625
4
town_name = input() packet = input() vip = input() days = int(input()) price = 0 if days < 1: print(f"Days must be positive number!") else: if town_name == "Bansko" or town_name == "Borovets": if packet == "noEquipment": price = 80 if vip == "yes": price = price...
097df0bcaa72c7da7ff0ecfcbb6b6e53bf57429f
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/Test_exam/4-Топки.py
835
3.921875
4
import math balls = int(input()) points = 0 red = 0 orange = 0 yellow = 0 white = 0 black = 0 other = 0 for ball in range(balls): color = input() if color == "red": red += 1 points += 5 elif color == "orange": orange += 1 points += 10 elif color == "yellow": yell...
c1dab69bad485b42cd018d29ecd9a45e26a42555
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/2 Conditional Statements/More/Greater_number.py
148
4.0625
4
num_1 = int(input()) num_2 = int(input()) if num_1 > num_2: print("Greater number is: ", num_1) else: print("Greater number is: ", num_2)
65710179251759bc65bdc3d6f4bf7016098491d7
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/2 Conditional Statements/More/Сумиране_на_секунди.py
261
3.90625
4
time1 = int(input()) time2 = int(input()) time3 = int(input()) sum_time = time1 + time2 + time3 minutes = sum_time // 60 seconds = sum_time % 60 if seconds < 10: print(str(minutes) + ":0" + str(seconds)) else: print(str(minutes) + ":" +str(seconds))
2d92242588519150f64d065a80f1883e133c91c5
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/2 Conditional Statements/More/Фирма_задача_часове.py
467
3.953125
4
import math neededHours = int(input()) days = int(input()) employ = int(input()) av_hours = days * 8 * 0.9 extra_hours = employ * days * 2 all_hours = av_hours + extra_hours if all_hours > neededHours: left_hours = all_hours - neededHours print("Yes! " + str(math.floor(left_hours)) + " hours left.") if al...
6308721c94a4749b3d679dac634e8d2c693c9e76
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/2 Conditional Statements/More/Concatenate_Data.py
494
4.15625
4
# first_name = input("First name: ") # last_name = input("Last name: ") # age = int(input("Age: ")) # city = input("City: ") # # print("You are " + first_name + " " + last_name + ", a " + str(age) + "-years old person from " + city + ".", end= '') # -------------------------------- first_name = input("First name: ")...
cec1f58327e8a1aa8559b1b893c698117cc140a8
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/3 Conditional-Statements Exercise/7-Световен_рекорд_по_плуване.py
461
3.9375
4
import math record = float(input()) distance = float(input()) time_for_1_m = float(input()) distance_time = distance * time_for_1_m slowing = math.floor(distance / 15) * 12.5 total_distance_time = distance_time + slowing if total_distance_time < record: print(f"Yes, he succeeded! The new world record is {total_di...
fd696f5820344ba79b1509431f0bb6e576fa8313
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/More Exams/July_2019/3-Кафемашина.py
950
4.09375
4
drink = input() sugar = input() num_drinks = int(input()) price = 0 if drink == "Espresso": if sugar == "Without": price = (num_drinks * 0.90) * 0.65 if num_drinks >= 5: price = price * 0.75 elif sugar == "Normal": price = num_drinks * 1.00 if num_drinks >= 5: ...
df3ae1bfb2d308eccf4d84559ccffcda94309c35
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/2 Conditional Statements/More/Конвертиране_на_мерни_единици.py
872
4.125
4
num = float(input()) entrance = input() exit = input() if entrance == "mm": num = num / 1000 elif entrance == "cm": num = num / 100 elif entrance == "mi": num = num / 0.000621371192 elif entrance == "inch": num = num / 39.3700787 elif entrance == "km": num = num / 0.001 elif entrance == "ft": ...
5097b2189cff3694f8e6923c376e3c4fbf0a086b
eclipse-ib/Software-University-Entry-Module
/Programing_Basics_with_Python/6 While Loop/Lab/3-Сума_от_числа.py
118
3.78125
4
number = int(input()) count = 0 while number > count: new_numb = input() count += int(new_numb) print(count)