blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ccaf24653c74db54244d886057a9a25d5a7dbc2b
Python-Repository-Hub/Learn-Online-Learning
/Python-for-everyone/03_Web_Scraping/11_Regular_Expression/01_string_pattern.py
197
3.625
4
import re # To Use a Regular Expression hand = open('box-short.txt') for line in hand: line = line.rstrip() if re.search('From:', line) : print(line)
cb0497b2316bea804caf4a7773f7be8aeef39f80
MariaOkrema/bot
/Function.py
144
3.671875
4
price = 100 discount = 5 price_with_discount = price - price * discount/100 print (price_with_discount) a = 10 b = 5 c = a + b print (c)
2862e372f077efa63b712d50da6aa56089a30a1a
yangqu/TreasureHouse
/demo/pandas_read_csv.py
2,244
4.1875
4
# import the function pandas to format the dataset as a table called dataframe # 导入pandas包,起一个别名pd import pandas as pd # import the package os to read some folder to list files # 导入os包 import os def main(): # input dir ,if your files in this folder,the name will be listed,you can change it # input为输入路径,r代表字符串...
ffbf170e7ec54bb8c3cad5a1ca2c48eaa9017b21
wjdwls0630/2018-1-Web-Python-KHU
/Week6/Week 6.py
1,278
4.09375
4
#String method name="jungjin" print(name.capitalize()) print(str.capitalize(name)) print(name.upper()) print(str.upper(name)) print(len(name)) print(name.count("g")) #String methond find name="tomato" print(name.isalpha()) help(str.find) print(str.find(name,"o")) print(name.find('o')) print(name.find('o',str.find(name...
33aa5694714a5ac67dc3c115ae5716d33b5c515e
MateuszMazurkiewicz/CodeTrain
/InterviewPro/2019.12.09/task.py
1,331
3.953125
4
''' Given a list of words, group the words that are anagrams of each other. (An anagram are words made up of the same letters). Example: Input: ['abc', 'bcd', 'cba', 'cbd', 'efg'] Output: [['abc', 'cba'], ['bcd', 'cbd'], ['efg']] Here's a starting point: ''' import collections def create_word_signature(word): ...
d4c939b593196fa89158f180d6b8bfdaa0fd846a
gregseda/Python-Programming-Fundamentals
/Homework 7/re_order.py
619
3.578125
4
"""Homework 7 for CSE-41273""" # Greg Seda import sys def re_order(in_file, out_file): with open(in_file, 'r') as current_file: lines = current_file.read().split('\n') while '' in lines: lines.remove('') new_file = open(out_file, 'w') for line in lines: colu...
7b25a160c8ff0ffa5cb57df42dc954d3ec842159
RunTheWave/Python
/main.py
484
3.734375
4
ask = input("Are you encrypting or decrypting? Enter 'e' or 'd'") string = input("Enter message!") alphabet = "abcdefghijklmnopqrstuvwxyz" newstring = "" key = int(input("Enter Key")) i = 0 while i < len(string): letter = string[i] whereisletter = alphabet.find(letter) if ask == 'e': newlett...
79dd75bf652f4452b71ae10f59e9cc264e15f8bd
TweetPete/ProjectIMU
/lib/GeoLib.py
836
3.859375
4
""" Geodetic Library """ from math import sqrt, sin, cos from MathLib import toValue, toVector def earthCurvature(a,f,lat): """ calculates radius of curvature in North and East takes ellipsoidal parameters as argument """ e = sqrt(f*(2-f)) Rn = a *((1-e**2)/(1-e**2*(sin(lat))**2)*...
ff489667025b3e9b9080debf15640ccc080f9349
matthewyoon/rangers59-homework
/projects/rental-property-roi-project/rental-property-roi-project.py
6,934
4.0625
4
""" ROI calculator Start with a general property class: (# Units, Income, Expenses, Cash Flow, Cash on Cash ROI) Include various methods for calculating income, expenses, cashflow, and a method to calculate ROI using the other calculated variables """ from IPython.display import clear_output class Rental_Property(): ...
da2575d739bd1a8c1d25afbf775b8f68c03a0499
Larc-Asgard/LPTHW
/ex31/ex31.py
1,007
3.9375
4
print "You are in a room with two doors in front of you. Would you enter door #1 or door #2?" door = raw_input("> ") if door == "1": print "There is a bear eating a cheese cake. What would you do?" print "1. Take the cake.\n2. Scream at the bear." bear = raw_input("> ") if bear == "1": print...
da113b76c5a844a37c42c024104f5b312ed7df7a
cr646531/Blackjack
/card.py
197
3.5
4
''' Card class ''' class Card(): def __init__(self, rank, suit, value): self.rank = rank self.suit = suit self.value = value def __str__(self): return f'| {self.rank} of {self.suit} |'
b719f682bf3b49d3fe553dd55b0a264520e76ee5
yuuuhui/Basic-python-answers
/梁勇版_6.16.py
407
3.953125
4
year =int(input("Enter the year:")) def numberofDaysInAYear(): print("year \t number of days") for i in range(2010,2021): print(i,end ="\t\t") k = 365 if i % 4 == 0 and i % 100 != 0: k = 366 elif i % 400 == 0: k = 366 else: ...
754a6aa3c68f2941d6080f77b331d7736648ebac
mikeyball/classwork
/class/exception.py
337
3.765625
4
''' def main(): try: x=input("give me your age") print(x+5) except: print("Why you don't give me number") main() ''' def main(): newlist=[] try: x=input("give me your age") newlist.append(x) print(newlist[4]) except: print("Why you don't give m...
12cdd52588da4ba7fe962e17fe51ddb8d4a03d7e
XrossFox/GuideScrapper
/GuideScrapper.py
3,574
3.5
4
import urllib.request from bs4 import BeautifulSoup import pdfkit import os from fileinput import filename from _codecs import decode import codecs import shutil ''' It recives an url Reads the source code of the page/s Parses the pages Outputs Temporal pages in temporal folder1 Gets all the pages, then fu...
763c60155502ef80be56326982300dbde029bf52
noh-yj/algorithm
/Data_Structure/recursive_func.py
604
4.0625
4
# 재귀 함수: 자기 자신을 다시 호출하는 함수 # 특정 깊이에서 탈출하는게 중요 즉 종료 조건을 꼭 명시해야 함 # def recursive_function(): # print('재귀 함수를 호출합니다.') # recursive_function() # recursive_function() # def recursive_function(i): # if i == 100: # return # print(i, '재귀 함수를 호출합니다.') # recursive_function(i + 1) # print(i, '...
75be460138fa574c46b47fc9a6ba44ea6ce6439d
FabioDPires/Blackjack
/deck.py
575
3.703125
4
from card import Card import random class Deck: def __init__(self): self.cards = [] def fill_deck(self): for x in range(4): # values 0,1,2,3 of cards' suit for y in range(13): card = Card(y + 1, x); self.cards.append(card); random.shuffle(...
07db599dbaebab813b223f4719e478497ca429f6
chrisleewilliams/github-upload
/Exercises/Chapter3/exercise14.py
470
4.0625
4
# program to find the average of a list of numbers a user provides # Author: Chris Williams def main(): print("Hello, If you provide a list of numbers I can find the average of the numbers.") y = int(input("How many numbers will you be providing? ")) total = 0 num = 0 for i in range(y): nu...
dd9539a9604118a7e94ea087b7f7eeb886485745
ajeetsinghparmar/loan_approval_prediction
/predict_loan.py
963
3.546875
4
from loan_predict import model import numpy as np while True: a_name = input('Enter Your Name ') a_income = input('Enter Your Income ') c_income = input('Enter Your Coapplicant Income ') l_amount = input('Enter Loan Amount ') l_term = input('Enter term of loan ') c_hist = input('Enter credit h...
ab49fe4062eaaf4b6e2028a17b61a0985c88f185
Janik-ux/minecode
/rnaBeispielEventverarbeitung.py
551
3.609375
4
from tkinter import * def linksklick(event): event.widget.config(bg='green') def rechtsklick(event): event.widget.config(bg='blue') def doppelklick(event): event.widget.config(bg='white') liste=[(x,y) for x in range(10) for y in range(10)] fenster = Tk() for (i,j) in liste: l=Label(fenster, width=2, hei...
7e9e3e6c2b79020326940756ada799834d26c26d
Lomaev2/python1
/python/Координатные четверти.py
155
3.703125
4
x1 =int(input()) y1 =int(input()) x2 =int(input()) y2 =int(input()) if (x1>0 and x2>0) and (y1>0 and y2>0): print('YES') else: print('NO')
3b048cab9b7e9e9ff344846fe96ebafcbb12fe3e
diegoserodio/Contests
/IEEExtreme 2018/commom_3_pair.py
500
3.765625
4
parity = False done = False a = 0 b = [] pairs = 0 def get_numbers(): global parity, done, a, b if parity == False: a = int(input()) parity = True else: b = list(input().split(' ')) parity = False done = True return a, b while True: index, numbers = get_numbers() if done == True: for i in range(inde...
fd00a3aec92b4bbc146aeb3b4292ecd6644c461a
kapoor-rakshit/pyfiddle
/elementTree_XML_API.py
3,515
4.1875
4
# REFERENCE : https://docs.python.org/3.7/library/xml.etree.elementtree.html # The xml.etree.ElementTree (ET) module implements a simple and efficient API for parsing and creating XML data. # ET has two classes for this purpose - ElementTree represents the whole XML document as a tree, # ...
85c318a4d7e31966fb62fe7d7debe9f4199feb75
lucassilva-dev/codigo_Python
/ex075.py
439
4
4
n = (int(input('Digite um número: ')), int(input('Digite um número: ')), int(input('Digite um número: ')), int(input('Digite um número: '))) print(f'Você digitou os valores {n}') print(f'O valor 9 apareceu {n.count(9)} vezes') print(f'O valor 3 apareceu na {n.index(3)+1} posição') print(f'Os val...
f2c9d012d840d3c68ec318863b9e2648f254eaec
4workspace/Python-calisma-notlari
/2_format.py
1,075
4.4375
4
""" Burada süslü parantez {} yerine format icine yazilan deger gelir süslü parantezin içine ilkine 0 diğerine 1 yazıldığında sıralı şekilde yerleştirilir ancak {} içine 1 ve 0 yazıldığında 2. yazı ilkinin yerine 1. yazı ise ikinciinin yerine yazılır """ name = "Ahmet" surname = "CETIN" age = 27 """ print(...
c720aa5fbedb00ea2d6bd7cad5b29eff90f790e2
kalehub/tuntas-hacker-rank
/designer-pdf.py
714
3.78125
4
from string import ascii_lowercase def design_pdf_viewer(char_height, word): word = word.lower() list_of_words = list() # dictionary to know the alphabet ALPHABET = {letter: str(index) for index, letter in enumerate(ascii_lowercase, start=0)} numbers = [ALPHABET[w] for w in word if w in ALPHABET] ...
a8c62809d2c403679ad5a85cd5ed4f396594bfb3
Crypto-Dimo/textbook_ex
/checking_usernames.py
309
3.53125
4
current_users = ['cryptodimo', 'fedefio', 'dimix', 'jackking', 'minus'] new_users = ['ildimo', 'fedefio', 'karamella', 'dimix', 'Ada'] for user in new_users: if user in current_users: print("Username already in use, please try another one.") else: print("The username is available.")
09281756052bad7f673e84386792352f2843f4c7
drahmuty/Algorithm-Design-Manual
/03-10.py
1,438
3.71875
4
""" For best-fit scenario: - Each bucket is a node on the tree. - For each new item, find the maximum node that can hold the new item. This takes O(n log n) time worst case. - Add the new item to that node and update the total value of the node. - Rebalance the tree. - Return the total number of nodes as the final ste...
9480532b7f8fce2dd7ab84a359a70b186102ad4c
lixinxin2019/LaGou2Q
/homework002.py
3,385
3.859375
4
# 课后作业:自己写一个面向对象的例子 # 描述: # 创建一个类(Animal)【动物类】,类里有属性(名称,颜色,年龄,性别),类方法(会叫,会跑) import yaml class Animal: def __init__(self, name, color, age, gender): self.name = name self.color = color self.age = age self.gender = gender def shout(self): print(f"{self.name} 会叫") ...
dee6b58bec5e18ada5417e80c7b156b177739b8a
cxs7650/Unit-1
/script.py
1,303
3.734375
4
import codecademylib from matplotlib import pyplot as plt unit_topics = ['Limits', 'Derivatives', 'Integrals', 'Diff Eq', 'Applications'] middle_school_a = [80, 85, 84, 83, 86] middle_school_b = [73, 78, 77, 82, 86] def create_x(t, w, n, d): return [t*x + w*n for x in range(d)] # Make your chart here school_a_x =...
dda59ff66d1ae110e39095a3c0fd596ecb10df82
PengJi/python-code
/pythonic/decorator/intro.py
1,159
4.0625
4
# -*- coding: utf-8 -*- """ 装饰器介绍 """ # 简单装饰器 def my_decorator(func): def wrapper(): print('wrapper of decorator') func() return wrapper # 第二种调用方式 def greet(): print('hello world') greet = my_decorator(greet) greet() # 第二种调用方式:更优雅的调用方式,使用@ @my_decorator def greet(): print('hello ...
f9c1c83a0c19aa6c0dc923b9c8456ac52ed12443
bhculqui/Curso-python-bhculqui
/input.py
195
3.796875
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 13 18:53:32 2019 @author: BLUEIT-PARTICIPANTE """ firstname = input("what is your first name?") a=input() print("Hello "+ firstname ,a+3)
91821332878f273d752c4a3da6fcebd623a72d0f
newpheeraphat/banana
/Algorithms/List/T_FindIndex.py
353
3.5
4
class Solution: def search(self, lst : list, item : int) -> int: try: result = lst.index(item) return result except: return -1 if __name__ == "__main__": p1 = Solution() print(p1.search([1, 2, 3, 4], 3)) print(p1.search([2, 4, 6, 8, 10], 8)) print...
f4e743e6e0c5d72c4638c8efb13dfa086158052d
blubbers122/Python-LeetCode-Problems
/Easy/Find_Numbers_with_Even_Number_of_Digits.py
250
3.53125
4
class Solution: def findNumbers(self, nums) -> int: evens = 0 for num in nums: if len(str(num)) % 2 == 0: evens += 1 return evens s = Solution() print(s.findNumbers(nums = [555,901,482,1771]))
cea5b206d17df68d37b427195388f5454412cd55
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_155/1880.py
1,091
3.765625
4
#!/usr/bin/python3 import sys from collections import namedtuple def case(line): max_shyness,syness_str = line.split(' ') shyness = dict(zip(range(int(max_shyness) + 1), (int(c) for c in syness_str))) return shyness def cases(lines): return (case(line) for line in lines if line) def main(filename): with o...
2312488fb0c9b07dbc94ef61d9363441ffafb0df
sharepusher/leetcode-lintcode
/math/double_factorial.py
652
3.65625
4
## Reference # https://www.lintcode.com/problem/double-factorial/description ## Easy - Recursion ## Description # Given a number n, return the double factorial of the number. # In mathematics, the product of all the integers from 1 up to some non-negative integer n that have the same parity (odd or even) # as n is c...
0a65ab5a12172e052d8c73d2630d95c396280272
stsewd/ucuenca.py
/examples/mean.py
845
3.5
4
""" Script para calcular el promedio de todas las materias aprobadas de un estudiante. """ from statistics import mean from ucuenca import Ucuenca student_id = input('Cédula: ') uc = Ucuenca() for career in uc.careers(student_id): career_id = career['carrera_id'] career_plan = career['placar_id'] curri...
11974492da5e2e52d4d157539d942329d771a46d
Daisythebun/Module-4
/Main.py
4,179
4.375
4
#Movie Store where user can add, remove and delete and Edit movies. Use can also search the movie name. User can see the list of all movies as well. class Movies: global movieStore movieStore=["intersteller","the great gatsby","12 angry men","requiem for a dream","death note"] #Search movie def search...
eefde76eeff5520289088010e92bee9d7df1cc77
mygithello/python_test
/pythonbase/09python的函数.py
5,356
4.375
4
print(""" --------1----------------------定义一个函数------------------------------------- 你可以定义一个由自己想要功能的函数,以下是简单的规则: 函数的特点: 1.函数代码块以 def 关键词开头,后接函数标识符名称和圆括号()。 2.任何传入参数和自变量必须放在圆括号中间。圆括号之间可以用于定义参数。 3.函数的第一行语句可以选择性地使用文档字符串—用于存放函数说明。 4.函数内容以冒号起始,并且缩进。 5.return [表达式] 结束函数,选择性地返回一个值给调用方。不带表达式的return相当于返回 None。 """) print(""" 常...
1a280541ce0d5321c12bd5823fa6579b384213c0
veltzer/pytimer
/pytimer/pytimer.py
599
3.515625
4
import time class Timer: def __init__(self, do_print=True, do_title=None): self.start_time = None self.end_time = None self.print = do_print self.title = do_title def __enter__(self): self.start_time = time.time() def __exit__(self, itype, value, traceback): ...
def6a6e3228434919e8f5dc9f88f13215696988d
juancq/character-evolver
/app/vertex_shader/pygene/gamete.py
1,699
3.90625
4
""" Implements gametes, which are the result of splitting an organism's genome in two, and are used in the organism's sexual reproduction In our model, I don't use any concept of a chromosome. In biology, during a cell's interphase, there are no chromosomes as such - the genetic material is scattered chaotically throu...
1b5544ff00f086b08e3d0f9e2e76e276118aa17d
kumarravindra/leetworld
/ltc_python_topics/com/lc/easy/Add_String.py
649
3.796875
4
''' https://leetcode.com/problems/add-strings/ ord function : https://www.geeksforgeeks.org/ord-function-python/ ''' def add_String(str1, str2): numlist1 = list(str1) numlist2 = list(str2) carry = 0 res = [] while len(numlist1) > 0 or len(numlist2) > 0: n1 = ord(numlist1.pop()) - ord('0') ...
41fc8e627d7b82698c4bef8988c99407d8ae8ea0
RickArora/Algo-practice
/dynamic-programming/rodCutting.py
1,150
3.875
4
# Given a rod length n inches an an array that contain prices of all pieces of size smaller then n. # Determine the maximum value obtainable by cutting up the rod and selling the pieces import sys INT_MIN = -sys.maxsize-1 #min is initialized to negative numbers def cutRod(price, n): # defining cut rod with 2 para...
cdf2b987524a798de728fa89676187ff95398d3d
302wanger/Python-record
/Learn-code-note/Python/Head-First-Python/Chapter-1/version-1.py
1,502
4.21875
4
# -*- coding: utf-8 -*- # 这个是第一章的列表的知识 # 向列表中添加新的元素 # 这是老的列表 movies = ["The Holy Grail","The Life of Brain","The Meaning of Life"] print(movies) # 方法1 # 添加新元素 movies.insert(1,1975) # 将1975添加到第2个位置 movies.insert(3,1976) # 将1976添加到第4个位置 movies.insert(5,1983) # 将1983添加到第6个位置 print(movies) # 方法2 # 直接在列表中进行更新 movies...
4740471cc305cf94af154a869aa5215b5aa92b59
QPromise/DataStructure-UsingPython
/3.链表/CH03_02.py
2,801
3.75
4
import sys class employee: def __init__(self): self.num=0 self.salary=0 self.name='' self.next=None def findnode(head,num): ptr=head while ptr!=None: if ptr.num==num: return ptr ptr=ptr.next return ptr def inser...
7dd6dca92ac3db2b95fa6afc5f4ff609e31b00c4
rickmur/pyCrashCourse
/foods.py
290
4.03125
4
my_foods = ['pizza', 'falafel', 'carrot cake'] friend_foods = my_foods[:] my_foods.append('cannoli') friend_foods.append('ice cream') print("My favorite foods are:") for mf in my_foods: print (mf.title()) print("\nMy friend's favorite foods are:") for ff in friend_foods: print ff
25e124489b378f87d1a903a1c8f4edad7b001c3f
TheNeuralBit/aoc2017
/10/sol1.py
792
3.5
4
def tie_knots(l, lengths): idx = 0 skip = 0 for length in lengths: knot(l, length, idx) idx = (idx + length + skip) % len(l) skip += 1 return l def knot(l, length, idx): halflen = int(length/2) lindices = (i % len(l) for i in range(idx, idx+halflen)) rindices = (i %...
36ca99728c21ecdae5457e5a601a0225a46e77b7
AnkitaJainPatwa/python-assignment1
/Testapp/Complex number.py
310
4.15625
4
#Addition of two numbers print("For Addition of two complex numbers :",(4+3j)+(7+9j)) #Subtration of two numbers print("For Subtraction of two complex numbers :",(4+3j)-(7+9j)) # print("For Multiplication of two complex numbers :",(4+3j)*(7+9j)) # print("For Division of two complex numbers :",(4+3j)/(7+9j))
5a335fe149db393ad44e9eddac468479d9eace84
charliegriffin/GraduateUnschool
/SWE001/crackingTheCodingInterviewPython/sortingAndSearching/mergeSort.py
1,090
4.125
4
import numpy as np # merge sort for integers def mergeSort(list): '''sorts the input list using merge sort''' if len(list) <= 1: return list mid = len(list)//2 left = mergeSort(list[:mid]) # slice 1st half right = mergeSort(list[mid:]) # slice 2nd half return merge(left, right...
46aa0c9c5a77af6ee5c1fcb54681f6fff1e14b44
riziry/MeLearningHelloWorld
/Py/branch_apple.py
1,133
3.984375
4
# Python 2 print('====Branch Apple====') inp = input("How much money do you have? ") money = int(inp) print("money = " + str(money) + " dollars") Aprice = 2 print('Apple Price = ' + str(Aprice) + " dollars") print("=============================================") while inp != "exit": if money > 0: inp = input("Ho...
0091a7b3c6e2da9149b2837272cc85f03663f509
pnd-tech-club/Python-Exercises
/ex42.py
831
3.6875
4
# is-a class Animal(object): pass # is-a class Dog(Animal): def __init__(self, name): # has-a self.name = name # is-a class Cat(Animal): def __init__(self, name): # has-a self.name = name # is-a class Person(object): def __init__(self, name): # has-a self.name = name # has-a self.pet = Non...
2502a3448805b66ca11b78806d74dea95cdb13ed
ba-java-instructor-zhukov-82/ma-python-module-six-build-in-system-modules
/labs/work_6_6/solution_6_6.py
729
3.5625
4
#! coding: utf-8 import time # import time module import datetime # import datetime module time.clock() # Set clock start print(time.ctime()) # print current time in format 'Tue May 24 14:09:17 2016’ print(time.localtime().tm_year) # Current time year print(time.localtime().tm_yday) # Current year day print(ti...
1691ad9cbfa4d50cafe1b3572af37cc05535e6e9
yashaswini87/Latest_Projects
/Bayes Classifier/tagger.py
7,726
3.796875
4
import collections from collections import defaultdict import nltk import pdb def document_features(document, tagger_output): """ This function takes a document and a tagger_output=[(word,tag)] (see functions below), and tells you which words were present as 'words' (as opposed to 'tags') in tagger_o...
860586f6d9d1e52314836911eabab03f9485941e
itsolutionscorp/AutoStyle-Clustering
/assignments/python/61a_hw4/code/18.py
201
3.640625
4
def num_common_letters(goal_word, guess): total = 0 count = 0 while count < len(goal_word): if goal_word[count] in guess: total += 1 count += 1 return total
f263101c785af554f4d88991e0347ca89ddd03aa
SergeantMini/SmartTry
/algo.py
73
3.53125
4
print("Hello man") var x: Int var x = 4 var y:Int var y = 3 print (x*y)
26b38bb7f86f2141d29ade240fb3570d35375480
ziul123/truth-table-generator
/truth-table.py
7,501
3.984375
4
"""Print the truth table of a user input expression. Fixed values for propositions can be set by comma separated <proposition>=<value> pairs. Symbols ------- propositions: any letter followed by any combination of letters, numbers and underscores (except "v" or "tmp") not: the symbol "¬" and: the symbol "^" or: the sy...
03f30c6e3de602c031e1a0a497d9d8d4424dd802
BentGunnarsson/LL_Hangman
/hangman_sll.py
1,714
3.8125
4
class Node: def __init__(self, data=None, nexd=None, found = False): self.data = data self.next = nexd if data == " ": self.found = True # Not gonna have the players guessing for spaces else: self.found = found class LinkedList: def __init__(self): ...
8728f270c5f1ef36da673ab0763f4493f8834290
K4cp3rski/Programowanie-I-R
/Ćwiczenia 23.03/zad4.py
407
3.53125
4
import time start = time.process_time() lista = [1, 2, 3] def numDiff(lista): dl = len(lista) rozne = [] for i in range(dl): if lista[i] not in rozne: rozne.append(lista[i]) else: continue return len(rozne) print("Liczba różnych elementów w liście to:", numDiff...
7a8ce5d1299ba726a2de9773531fff57f8ebca01
kerryhuang1/tree-visualizer
/draw.py
4,190
3.953125
4
from trees import * width, height = 1280, 640 radius = 16 h_offset = 16 v_offset = -64 window = GraphWin("Tree Visualizer", width, height, autoflush=False) window.setCoords(0, 0, width, height) def visualize(tree, animate=False): ''' Provide the full visualization of the tree and its __repr__. Can highlight both t...
83ca0c73bf480918b254810c2c929adbef91ef56
coin-or/pulp
/pulp/sparse.py
3,360
3.703125
4
# Sparse : Python basic dictionary sparse matrix # Copyright (c) 2007, Stuart Mitchell (s.mitchell@auckland.ac.nz) # $Id: sparse.py 1704 2007-12-20 21:56:14Z smit023 $ # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"...
d0d6fbe5e7478f4547f4d88c7e17f4dc5dcf05a0
michaelssavage/Advanced_Algorithms
/Dynamic_Programming/greedy_ks.py
2,311
4.5
4
""" In this exercise, you will solve the KnapSack Problem using a greedy algorithm. The basic strategy is to just find the most valuable item per unit weight, place that in the knapsack and repeat the procedure until there is no room in the knapsack. Your method should return the total value of the items added....
cfc630c97205a1f767ecf4b7b09ab737137ee68b
Sameer2898/Data-Structure-And-Algorithims
/Placement Prepration/Stack/sort_a_stack.py
408
3.8125
4
def sorted(s): return s.sort(reverse = True) if __name__=='__main__': t = int(input('Enter the number of test cases:- ')) for i in range(t): n = int(input('Enter the size of the stack:- ')) arr = list(map(int, input('Enter the element of the stack:- ').strip().split())) sorted(arr) ...
5e8d0ebf14e9d7690a5b0028cb05a959f3cdfa54
reb33/-algorithms_2021
/Урок 5. Практическое задание/Урок 5. Коды примеров/OrderedDict_ex/task_7.py
729
4.15625
4
"""Класс collections.OrderedDict()""" import collections NEW_DICT = {'a': 1, 'b': 2, 'c': 3} # -> с версии 3.6 порядок сохранится print(NEW_DICT) # -> {'a': 1, 'b': 2, 'c': 3} # а в версии 3.5 и более ранних можно было получить и такой результат # {'b': 2, 'c': 3, 'a': 1} # и вообще любой, ведь порядок ключей не с...
f27817d68897edcdaa1f08dbc333ade4c3deaf8f
psemchyshyn/IMDB_research
/top_authors_visualisation.py
1,559
4.25
4
import matplotlib.pyplot as plt from literature_manag import * # Module for visualisation of data # A program asks user to enter the number n of authors and will create a bar with n authors, on whose works there was the biggest amount of films shot. films, books = read_file("literature.list") bokauth = book_autho...
511c7717ebc22c118c481c73ffefc364ddc9a844
sumin3/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
352
3.984375
4
#!/usr/bin/python3 def is_same_class(obj, a_class): """function check if obj and a_class are exact the same object Args: obj: the object a_class: the class Return: returns True if the object is exactly an instance of the specified class ; otherwise False. """ ...
5644602b1da736494b3064dfb260465451a46828
marshallhumble/Coding_Challenges
/Code_Eval/Easy/SetIntersection/SetIntersection.py3
851
4.28125
4
#!/usr/bin/env python from sys import argv """ SET INTERSECTION CHALLENGE DESCRIPTION: You are given two sorted list of numbers (ascending order). The lists themselves are comma delimited and the two lists are semicolon delimited. Print out the intersection of these two sets. INPUT SAMPLE: File containing two lis...
1cba4ee4d2c3abf618b980083b2fdd239c1c4cd3
DylanDelucenauag/cspp10
/unit5/ddelucena_ap_create.py
2,606
4.21875
4
#Mcdonalds Simulator #use lists #big mac = $4 #Quarter pounder with cheese = $3.79 #Hamburger = $2.49 #cheeseburger = $2.79 #mcchicken = $1.29 #mcwrap = $4 #filet o fish = $3.79 #mcrib = $3 def get_p1_order(): p1_order = input("Welcome to Mcdonalds, What would you like to order\nThis is our menu today:\n(1)Big Mac...
4383298ad04b3949e63975138421827956c10d07
CamilaTermine/programitas
/Python/Parte1/11-07-2021/ejercicio4.py
1,025
4.15625
4
cantAlumnos = int(input("ingrese cantidad de alumnos: ")); mensaje = ""; notaMenor = 0; notaMayor = 0; nombreAlumnoNotaMenor = ""; nombreAlumnoNotaMayor = ""; sumaNotas = 0; for i in range(0, cantAlumnos): nombreAlumno = input("ingrese el nombre del alumno: "); notaAlumno = int(input("ingrese la nota del alum...
88cb615a3215780fa14173b59a0d3f411b5cf1b1
mliu/googlemapz
/algo.py
831
3.875
4
# Tests various algorithms for finding the ideal destination by some combination of distances in a selection of potential destinations. distances = [ [28,29,30], [35,35,45], [15,15,45], [7,7,60], [1,1,60], [7,7,90], [1,1,120], [1,60,60], [7,45,45], [20,20,20], ] def rankSum(distances): return sum(distances...
6a9c54ca0d4c3007d4f3121418cbc6b3a0824250
MihirVaidya94/Sorting-Algorithms
/quicksort.py
1,213
4.0625
4
#Function for swapping the two integers that are being compared def swap(x,y): temp = x x = y y = temp return (x,y) def quicksort(arr,l): if len(arr)%2 == 0: t = [arr[0], arr[len(arr)/2 - 1], arr[len(arr)-1]] t.sort() if t[1] == arr[0]: pivot = 0 elif t[1] == arr[len(arr)/2 - 1]: pivot = len(arr)/2 ...
27e14bd0416f92289684d4da3961c3e87036d05d
globlo/CyberSecurityHW1
/HW1.py
3,829
3.515625
4
import sys import traceback import Crypto.Cipher # BEGIN SOLUTION # please import only standard modules and make sure that your code compiles and runs without unhandled exceptions from Crypto.Cipher import AES # END SOLUTION def problem_1(): with open("cipher1.bin", "rb") as cipher_file: # rb means "read only ...
72197a6f7f0701734924fafde88e8f1bb4bf9fd0
erjan/coding_exercises
/minimum_cost_of_buying_candies_with_discount.py
1,059
4.0625
4
''' A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free. The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought. For example, if there are 4 candies with ...
4c26639e65c3adcd9032d8f0794bcbda3700240b
programhung/learn-python
/PythonCode/Number/updatefrancais2.py
1,141
3.9375
4
import random def play(min,max): print("Donc, le numero secret est entre "+str(min)+" et "+str(max)) print("Entrez le maximum de fois pour deviner") a=input() a=int(a) userchoice=2 counter=0 while userchoice!=1: if counter>=a: print("GAME OVER.") break counter=counter+1 x=random.randint(min,max) pr...
204c3da8f86100df264acb4a0f03f5c75ca83cf6
Dragon-Boat/PythonNote
/PythonCode/Python入门/Set/访问set.py
878
3.921875
4
#coding=utf-8 #author: sloop ''' setʶСд֣Ľsetʹ 'adam' 'bart'ܷTrue ''' # s = set(['Adam', 'Lisa', 'Bart', 'Paul']) temp = set() for k in s: l = k.lower() temp.add(l) for k in temp: s.add(k) print 'adam' in s print 'bart' in s print s ''' set set洢򼯺ϣûͨʡ setеijԪʵϾжһԪǷsetС 磬洢˰ͬѧֵset >>> s = set(['Adam', ...
ce859a4552935aa06ea2847d0353e6b9995fd57a
KaterinaMutafova/SoftUni
/Python Advanced/1. Stack_and_queues/SQ_lab_ex1_reverse.py
149
3.9375
4
text = list(input()) reverse_text = [] for ch in range(len(text)): reverse_text.append(text.pop()) print(''.join(reverse_text))
3f12bb16fe477a688e2eda8de7e15270b4414a39
ZhuoyiZou/python-challenge
/PyBank/main.py
1,721
3.671875
4
# Import module import csv import os import numpy as np # Select the csv file through directory pybank_data = os.path.join(".", "PyBank_Resources_budget_data.csv") column_1 = [] column_2 = [] total_amount = 0 # Read the csv file with open (pybank_data, newline = "") as csvfile: pybank_data_reader = csv.read...
5484eaa2350116455179ffaadb17f01ab2cddb8a
saran1211/rev-num
/avg.py
148
3.96875
4
n=int(input('enter the no of elements')) l=[] for i in range(1,n+1): a=int(input('enter the elements')) l.append(a) avg=len(l)//2 print (avg)
5749847612f3b1904fc8ca679436be2ec3cd93b4
skhan75/CoderAid
/DataStructures/Graphs/number_of_islands.py
1,956
3.796875
4
class Graph: def __init__(self, r, c, g): self.row = r self.col = c self.graph = g # Function to check if a given cell (row, col) can be included in DFS def is_safe(self, i, j, visited): # row number is in range, column number # is in range and value is 1 ...
212daf118b37eca829d86e7502d407df2c8a9472
jeffrey0601/uda-project1
/Task2.py
2,491
3.578125
4
""" 下面的文件将会从csv文件中读取读取短信与电话记录, 你将在以后的课程中了解更多有关读取文件的知识。 """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ 任务2: 哪个电话号码的通话总时间最长? 不要忘记,用于接听电话的时间也是通话时间的一部分。 输出信息: "<telephone number...
523d5a682363fa4b0ad6807d38a9d69bbee4e389
KantiMRX/calculator
/calc.py
496
4.1875
4
print("პროგრამა შექმნილა Kanti-ის მიერ, ისიამოვნეთ.") x = "symbols" x = float(input("შეიტანეთ x: ")) oper = input("აირჩიეთ ოპერაცია: +, -, /, * ...> ") y = float(input("აირჩიეთ y: ")) if oper == "+": print(x + y) elif oper == "-": print(x - y) elif oper == "/": print(x / y) elif oper == "*": pr...
0fdaa63ddaac440ed2def666f238e9dbac311538
ErnestoSiemba/Python-for-Everybody
/Chapter 7 Exercise 3.py
424
3.65625
4
fname=input('Enter file name to find # of "Subject" lines: ') if fname=='': fname='mbox.txt' if fname=='na na boo boo': print('NA NA BOO BOO TO YOU - You have been cock slapped') exit() try: hand=open(fname) except: print('File cannot be opened:', fname) exit() count=0 for line in hand: if ...
6853646f8599664940f0096c2e55a9b7009eaeab
Guzinanda/Interview-Training-Microsoft
/01 Arrays/rotateArray.py
826
4.15625
4
''' Rotate an Array @ Problem Given an array of integers, and a 'k' number indicating the number of times the arrays must be rotated, totate that number to the right. @ Example Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] @ Template I want to move the last item of the list ...
d83f9bdbc0231735e1538d9ac1dd9314e0aa6133
jonathalfc/exercicios_uri_python3
/1013_o_maior_13.py
333
4.03125
4
#coding: utf-8 def funcao_abs(valor1,valor2,valor3): valor1 = valor1 valor2 = valor2 valor3 = valor3 maior_ab = (a+b+abs(a-b))/2 maior_ab_c = (maior_ab+c+abs(maior_ab-c))/2 print('%d eh o maior'%maior_ab_c) valores = input("").split(" ") a = int(valores[0]) b = int(valores[1]) c = int(valores[2]) funcao_...
86e286b264daae5b06ca4eb995de4702c1eb8da2
40013395/Python
/assignment1.py
196
4.3125
4
#change the first character occurence in a string to "$", except the first character itself my_str = input("Enter the string: ") print((my_str.replace(my_str[0], "$")).replace("$", my_str[0], 1))
6bbf6972449c914b5268114595bff0705bd0732a
ivanstewart2001/projects
/Numbers/Exercise1.py
552
4.09375
4
""" Let's assume you are planning to use your Python skills to build a social networking service. You decide to host your application on servers running in the cloud. You pick a hosting provider that charges $0.51 per hour. You will launch your service using one server and want to know how much it will cost to operate ...
7da12768036bddd2e4870b67a88096c53d19dfeb
LuisGPMa/my-portfolio
/Coding-First-Contact_With_Python/Fahrenheit_to_Celsius.py
268
4.0625
4
celsius= float(input ("What's the temperature in Celsius? ")) fahreinheit= ((celsius*9)/5)+32 print (celsius,"º in celsius is the same temperature as", fahreinheit, "º in fahreinheit.") if fahreinheit>90: print("It's hot") else: print("It's not hot")
94d6783b96acb2c37fc463d586095bf4608a36af
mukund7296/Python-Brushup
/27 Class obeject.py
806
3.96875
4
'''Python Classes/Objects Python is an object oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects. Example :- Any table is like template and we use object to store data in row wise u...
20b7b515b1481a0487fc0b447cf7f93bb7a8cba1
mingming733/LCGroup
/Sen/Unique_Paths.py
713
3.5
4
class Solution(object): def uniquePaths(self, m, n): """ :type m: int :type n: int :rtype: int """ if m == 1 and n == 1: lst = [[1]] elif m == 1 and n > 1: lst = [[1 for i in range(n)]] elif m > 1 and n == 1: lst = [[1 for i ...
ea0049c717885acb16b5536b74c9bc92937cde14
TomEdwardBell/PycharmProjects
/ALevel/ReversePolish/infix2reversepolish.py
1,019
3.59375
4
# Precedence rules # ( # + - ) # * / # ^ def infix2polish(str): items = str.split(' ') precedence = { '+': 1, '-': 1, '*': 2, '/': 2, '^': 3, } def calc_reverse(str): stack = [] for item in str.split...
595c2dbeeba2c98d884fed7f8373d606768cbd6d
wolfgang-azevedo/python-tips
/tip15_enumerate/tip15_enumerate.py
468
4.09375
4
#!/usr/bin/env python3.8 # ######################################## # # Python Tips, by Wolfgang Azevedo # https://github.com/wolfgang-azevedo/python-tips # # Enumerate Built-in Function # 2020-03-13 # ######################################## # # routers = ['ROUTER01', 'ROUTER02', 'ROUTER03', 'ROUTER04', 'ROUTER02'] ...
c28b1337b555209c42e7633be8e4f63080b55093
elrion018/CS_study
/beakjoon_PS/no10828_2.py
710
3.796875
4
def push(x): return stack.append(x) def pop(): if len(stack) == 0: return print(-1) else: return print(stack.pop()) def size(): return print(len(stack)) def empty(): if len(stack) == 0: return print(1) else: return print(0) def top(): if len(stack) =...
ac04a421b785675f44ee77ce2564c91fae4497fd
ii0/algorithms-6
/Sort/inset_sort.py
371
3.703125
4
""" author: buppter datetime: 2019/8/27 20:14 插入排序 时间复杂度: O(n*n) """ def inset_sort(alist): if not alist: return None for i in range(len(alist) - 1): for j in range(1 + i, 0, -1): if alist[j] < alist[j - 1]: alist[j], alist[j - 1] = alist[j - 1], alist[j] ...
debf8a46598a7f428cdbd96b89e2959f419e43f8
sayalijo/my_prog_solution
/geeks_for_geeks/Arrays/searching/search_missing_element/search_missing_element.py
327
4.25
4
def missing_element(arr): x1 = 1 x2 = 1 n = len(arr) for i in range(n): x1 ^= arr[i] for i in range(n+2): x2 ^= i print(x1, x2) return x1^x2 arr = list(map(int, input("enter your array").split(" "))) result = missing_element(arr) print("Your missing element is array is", r...
164675b714842c342e0ef001352aa5bf49f30761
YaroslavaMykhailenko/Laboratory-1_Mykhailenko
/Task3.py
8,644
3.5
4
import random import math import pandas as pd import numpy as np import matplotlib.pyplot as plt from prettytable import PrettyTable from scipy.stats import chisquare from scipy.stats import shapiro import seaborn as sns n = 100 # Task 3 def pos_value(a): a = float(a) if a < 0: print("\nErorr, incorr...
d959f4de2e8e948792b54dd7cd52cbe3a8db8c96
Christine1225/Leetcode_py3
/14.py
1,871
3.5625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 6 18:36:39 2018 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入: ["flower","flow","flight"] 输出: "fl" 示例 2: 输入: ["dog","racecar","car"] 输出: "" 解释: 输入不存在公共前缀。 说明: 所有输入只包含小写字母 a-z 。 @author: Abigail """ class Solution: def longestCommonPrefix(self, strs): ...
755273ac19faf2740da588ca41c607846ca03797
netfj/Project_Stu02
/e100/e038.py
666
3.609375
4
#coding:utf-8 """ @info: 题目:求一个3*3矩阵 主 对角线元素之和。 @author:NetFj @software:PyCharm @file:e038.py @time:2018/11/5.22:08 """ import random # a = random.randint(-100,100) m=3 a = [[random.randint(0,10) for n in range(m)] for n in range(m)] for x in a: print(x) # 主对角线 s=0 h=len(a[0]) for n in range(h): s += a[n][n] prin...
f9bf9633d75bf991e9bc17eb1dcc3c3ed672c2a1
donghL-dev/Info-Retrieval
/lecture-data/PythonBasics/003_list.py
577
3.59375
4
L=[] L=['a','b','c','d'] print(L) print(L[0]) print(L[-1]) print(len(L)) L.append('e') del L[0] s='-'.join(L) print(s) s='ZZZ ABC DEF GHI JKL' print(s) L=s.split() print(L) if 'ABC' in L: print('ABC is in L') else: print('ABC is not in L') for e in L: print(e) # end for print() for e in sorted(L): print(e) # end...
e14413048f057f81da4b7e81513b365c10282aca
lpozo/pyadt
/pyadt/array.py
1,807
3.875
4
"""Array abstract data type.""" import ctypes from typing import Any, Generator, Optional class Array: """Array abstract data type based on ctypes.py_object. >>> a = Array(5) >>> a Array(size=5) >>> len(a) 5 >>> a[0] = 42 >>> a[0] 42 >>> print(a) Array(42, None, None, Non...
a0cb7b77dc819031743f0ce779cbbf11f07008f7
MIPLabCH/nigsp
/nigsp/operations/laplacian.py
10,863
3.625
4
#!/usr/bin/env python3 """ Operations for laplacian decomposition. Attributes ---------- LGR Logger """ import logging from copy import deepcopy import numpy as np LGR = logging.getLogger(__name__) def compute_laplacian(mtx, negval="absolute", selfloops=False): """ Compute Laplacian (L) matrix from a ...
bc1a314e19da0b9f0a4ca12ca1d3bc8e540baa8f
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/binary/905d373b04574f0d9a7c91efde4ca60f.py
286
3.796875
4
def parse_binary(bin): bin = list(bin) dec = 0 cur = 0 while bin: dig = bin.pop() if dig == '1': dec += 2**cur elif dig != '0': raise ValueError('Input string must contain only 0s and 1s.') cur += 1 return dec
2cb593e1006667e62a9b1aedac63edc480d69da1
annamalai0511/ATM-Banking-Interface
/Main.py
18,456
3.53125
4
#demo account login credential given below #Account Number : 0000 ------------ Password : demo # modules used from tkinter import * from tkinter import messagebox import sqlite3 import time import math, random,smtplib #global font ARIAL = ("arial",10,"bold") class Bank: # login page def __i...