blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
4623e61cab1988254991eb7f87ce22a0d2197830
Khushisomani/codes
/38949141.py
132
3.59375
4
# cook your dish here t=int(input()) for case in range(t): d = int(input()) print(2*d) print('a'*d + 'b'*d)
85ca4f931598799d324befbefab0bd3ed318f3f0
Khushisomani/codes
/Max Contiguous Subarray.py
268
3.546875
4
def maxsubarray(arr,size): max1=0 max2=-100000000000 for i in range(len(arr)): if max1+arr[i]>0: max1=max1+arr[i] if max2<max1: max2=max1 else: max1=0 print(max2) maxsubarray(a,len(a))
0ff1cfdb53a63d7f8b8263d151fcf6a3a3036e6c
Khushisomani/codes
/Reverse LinkedList.py
917
3.859375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: if head==None: return head else: prev=N...
9e811d2d77e8e85813fb1b3c0af96c793ce92eb4
niutyut/author-topic-modeling-project
/src/mallet/parser.py
1,851
3.609375
4
''' Created on Sep 23, 2014 @author: dbhage Module to parse mallet generated files into another format ''' def keys_to_csv(keys, csv_file_name): ''' Write keys as csv where a row is a topic number followed by its words @param keys: list of Key objects @param csv_file_name: file in which to output dat...
95cf086d64ad77d5e92896353e36d220f1a3e2f3
Incognito514/test
/douban_score_analysis.py
595
3.5
4
# -*- coding: utf-8 -*- import pandas as pd from collections import Counter #读取csv文件 df=pd.read_csv('douban_movie.csv') #统计打分数量 score_list=df['score'].values.tolist() num_count=Counter(score_list) #显示热评中不同分值的评论数量 print(num_count) #分组求平均 grouped = df.groupby('score').describe().reset_index() score=grouped['score'].v...
42662f2bb7ac1341b32060855a41aa8676565183
Apocklington/Logic-Gates
/logic gates.py
1,184
3.796875
4
# Logic Gate # Aaron Poclington # 5/2/2019 # imports import time # Main Code def Main(): logic = (input("Enter the logic gate type:\n>> ")).lower() input1 = input("Enter First input:\n>> ") input2 = input("Enter Second input:\n>> ") if (logic == "and"): if (input1 == "1" and i...
66de1a567e05f07f9b9339a8ee82d15d0a71c97a
phamhoaiThanh/hoaithanh_practical_3
/broken_score.py
358
3.890625
4
def is_score(): score = float(input("Please enter your score: ")) if score < 0 and score >= 100: print(f"Invalid number") elif score > 20 and score < 50: print(f"Bad") elif score == 50: print(f"Passable") elif score >= 90: print(f"Excellet") elif score < 10: ...
3a324647696c906ff6c44387f1afca893e86904a
matplotlib/cheatsheets
/scripts/animation.py
294
3.5625
4
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation T = np.linspace(0, 2*np.pi, 100) S = np.sin(T) line, = plt.plot(T, S) def animate(i): line.set_ydata(np.sin(T+i/50)) a=animation.FuncAnimation( plt.gcf(), animate, interval=5) # plt.show()
7b210bbdd11ee383ed036aee8ed8e7b28005e34d
WillyMwangi/Word-Count
/wordCount.py
661
3.890625
4
""" WORD COUND LAB ANDELA For example for the input "olly olly in come free" """ def words(input): """ This function takes an input string inputseparates them from each other using the whitespaces between them. """ resultingDict = {} # dictionary to hold the results separated = input.sp...
98b663b1eb646df7527649a015612236251fcd1b
prachiprakash26/Play-with-Numbers
/PlayWithNumbers.py
3,470
4.03125
4
import tkinter import random from random import randint from tkinter import Button import matplotlib.pyplot as plt import numpy as np #create a GUI window. root = tkinter.Tk() #set the title. root.title("Are you smart!!") #set the size. root.geometry("400x200") #Global variables correct_result=0 correct...
d243d3979f8f0c93d1f5949343455b9015d5743b
hezl1592/Daily-Python
/剑指offer/JZ3-从尾到头打印链表.py
847
3.78125
4
# -*- coding: utf-8 -*- # Time : 2020/8/5 18:31 # Author : zlich # Filename: JZ3-从尾到头打印链表.py # -*- coding:utf-8 -*- class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # 返回从尾部到头部的列表值序列,例如[1,2,3] def printListFromTailToHead(self, listNode): out = ...
62803ecfde2e7afaa0212401f5d6b85aa7011352
hezl1592/Daily-Python
/剑指offer/最长定等差子数列.py
1,025
3.59375
4
# -*- coding: utf-8 -*- # Time : 2020/8/19 14:40 # Author : zlich # Filename: 最长定等差子数列.py def printarray(arr): print('--' * 10) for ar in arr: print(ar) def solve(arr, diff): dp = [[1 for j in range(len(arr) + 1)] for i in range(len(arr) + 1)] for i in range(1, len(arr) + 1): dp[i]...
dd2ddb73b6e8eaecc14660829585ab4a882c14ae
leighjpeter/python
/unit_test.py
1,757
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 单元测试 # 文档测试 # # # # class Dict(dict): ''' Simple dict but also support access as x.y style. >>> d1 = Dict() >>> d1['x'] = 100 >>> d1.x 100 >>> d1.y = 200 >>> d1['y'] 200 >>> d2 = Dict(a=1, b=2, c='3') >>> d2.c '3' >>> d2['empty'] Traceback (most recent...
964bffe519d1a845dfdeaaa70270f1bea2cce6d8
leighjpeter/python
/demo_dict.py
2,327
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- alien_0 = { 'color':'green', 'point':5 } print(alien_0['color']) alien_0['x_position'] = 0 alien_0['y_position'] = 25 print(alien_0) alien_0 = {'x_position': 0, 'y_position': 25, 'speed': 'medium'} print("Original x-position: " + str(alien_0['x_position'])) ali...
20f90abd73a76dde614f8333d31314d4fbde590d
leighjpeter/python
/retry_demo.py
831
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random from retrying import retry @retry def do_something_unreliable(): if random.randint(0, 10) > 1: raise IOError("Broken sauce, everything is hosed!!!111one") else: return "Awesome sauce!" print (do_something_unreliable()) @retry(stop_max_delay=10000...
520a8edac90a989d3a71ed08bddd4ef1a9cd6b48
leighjpeter/python
/re_match.py
621
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 正则 # # import re # re.match() # 切分字符串 # re.split(r'[\s\,]+', 'a,b, c d') # 分组 # re.group() # 贪婪匹配 # re.match(r'^(\d+?)(0*)$', '102300').groups() #('1023', '00') # 编译 re_tel = re.compile(r'^(\d{3})-(\d{3,8})$') re_tel.match('001-121').groups() # 作业一验证邮箱 # re_email = r...
f09c699d0bf7d7486a1f0f881eee9f61686d6403
axentom/tea458-coe332
/homework02/generate_animals.py
1,713
4.34375
4
#!/usr/bin/env python3 import json import random import petname import sys """ This Function picks a random head for Dr. Moreau's beast """ def make_head(): animals = ["snake", "bull", "lion", "raven", "bunny"] head = animals[random.randint(0,4)] return head """ This Function pulls two random animals fr...
ad87e5b2bceff5cf69780733ddc3c89fa4b2f46b
bookpark/Fastcampus
/python/python-practice/class_practice/class_sample.py
1,166
3.703125
4
class Shop: description = 'Python Shop class' def __init__(self, name, shop_type, address): self.name = name self._shop_type = shop_type self.address = address def show_info(self): print(f'상점정보: ({self.name})') print(f' 유형: {self._shop_type}') print(f' ...
1bbc213172dea011ef304a8ed531e63c1efc135b
bookpark/Fastcampus
/python/python-practice/statement_practice/comprehension.py
109
3.546875
4
l = [item for item in range(1, 6)] l2 = [item for item in range(1, 6) if item % 2 == 0] print(l) print(l2)
f577d4ff4ce1bdc9f40404de7478d1d523076547
bookpark/Fastcampus
/python/python-practice/statement_practice/practice6.py
471
3.8125
4
# 7의 배수이거나 9의 배수인 정수를 담을 list result = [] # 1부터 99까지를 순회, 각 순회 아이템은 x변수에 할당 for x in range(1, 100): # x가 7로 나누어지거나 9로 나누어질 경우에는 if x % 7 == 0 or x % 9 == 0: # 결과 list의 마지막에 해당 x변수를 삽입 result.append(x) print(result) # List comprehension result = [x for x in range(1, 100) if x % 7 == 0 or x % 9...
7f144bde2f64982723ea6b0b1e77567eb2e29ca2
bookpark/Fastcampus
/python/python-practice/class_practice/practice.py
169
3.8125
4
import re result = re.match('Hello', 'Hello, can you hear me?') import re source = 'Lux, the lady of Luminosity' m = re.match('Lux', source) if m: print(m.group())
de341d96b9dbcee075c45a5265dd361c264a81d5
bookpark/Fastcampus
/python/python-practice/statement_practice/practice3.py
166
3.5625
4
for x in range(7): for y in range(4): if x % 2 == 0: print((x, y)) l = [(x, y) for x in range(7) for y in range(4) if x % 2 == 0] print(l)
6a2c3b9a6cad0059d6893a87d98d686dbf1f09e3
bookpark/Fastcampus
/python/python-practice/lamda.py
279
3.953125
4
def upper_if_gt_i(char): if char > 'i': return char.upper() else: return char import string for char in string.ascii_lowercase: print(upper_if_gt_i(char)) for char in string.ascii_lowercase: print((lambda x: x.upper() if x > 'i' else x)(char))
0a1763b2b1a72dd79ce52408ed47098b964ef4e5
Huqingnan123/learn_python
/primer_finder.py
1,724
3.8125
4
def odd_iter(): # 从3开始的奇数序列生成器,无限序列,偶数直接不考虑 n = 1 while True: n = n+2 yield n def not_devisible(n): return lambda x: x % n != 0 # 用匿名函数lambda来表示是否整除 # 更好地理解 def not_devisible_new(n): def fn(x): return x % n != 0 return fn # fn闭包函数,一个闭包就是你调用了一个函数A,这个函数A返回了一个函数B给你。 ...
4996ad3f12410518a20a2b152b0bb936f1c55b5c
Huqingnan123/learn_python
/understand_closure.py
925
3.609375
4
def count(): fs = [] for i in range(1, 4): def f(): return i*i fs.append(f) return fs f1, f2, f3 = count() # 此处count()的返回值是一个fs列表,对应赋值给f1,f2,f3 print(f1(), f2(), f3()) # 因为最后返回的时候i的值已经变成了3,所以调用函数时内部的i都成为了3 # 返回闭包时牢记一点:返回函数不要引用任何循环变量,或者后续会发生变化的变量。 # 返回一个函数时,牢记该函数并未执行,返回函数中不要引...
03d226e9535787d0fac45116363a25d8a280a0ac
Gladdos1337/GladdosPublic
/sieve.py
1,202
3.546875
4
#Sieve of eratosthenes v1.0 def sieve(the_list): counting_list = list(range(1, 50000)) new_list = [] for num in the_list: if num % 2 != 0: new_list.append(num) # Appends the even numbers to new list new_list.insert(0, 2) # Adds two to begging of the list i = 1 j = 0 w...
d6bcec02ed98e0734c4613c1361a3c7c9abc3b37
Gladdos1337/GladdosPublic
/idk.py
1,220
3.9375
4
import random class Account(): def __init__(self, name): self.balance = 1500 self.name = name self.account_no = self.generate_acc_no() def generate_acc_no(self): return random.randint(1000, 9999) def account_creation(self): name = input("Welcome to <Random Bank Nam...
e5a7db285842cd57846dea7d12a22b3c533b712e
OluwoleCo/LeetCodeExercises
/university_career_fair/university_career_fair.py
789
3.625
4
# https://leetcode.com/discuss/interview-question/algorithms/374846/twitter-oa-2019-university-career-fair # https://www.codespeedy.com/interval-scheduling-in-python/ # print(universityCareerFair([1, 3, 3, 5, 7], [2, 2, 1, 2, 1])) # 4 # print(universityCareerFair([1, 2], [7, 3])) # 1 def universityCareerFair(arrival,...
28c356a9651c437613f0ed9ec987574e9ce88eba
boguslaw-chojecki/codewars
/Palindrome chain length.py
416
3.890625
4
def palindrome_chain_length(n): # parameter n is a positive integer # your function should return the number of steps n = str(n) result = 0 while True: n = str(n) if n != n[::-1]: result += 1 n_1 = int(n) n_2 = int(n[::-1]) n_3 = n_1 + ...
56582652054ea21294d0ccf4d11095606ae78bd3
LydP/database
/database.py
9,575
3.96875
4
"""database.py: create an SRS database file using SQLite from a CSV file. Database can contain images or text for front of cards.""" import sqlite3 import os import pathlib import csv class DatabaseManager: """ A class for creating and initializing a DB file with values from a CSV file """ ...
4bd997e8f99340dd158716ebb3b144e36f5b4b6a
saulwesty/Saul-s-stuff
/Countdown numbers game.py
4,066
3.515625
4
import random,time,datetime from operator import add,mul,sub,truediv ints = [] p=0 cole = 1000000 bignumbers = [75,25,100,50] smallnumbers = [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10] operators = {"+": add, "-": sub, "*": mul,"/":truediv,} keys=list(operators) biz=[] fiz = [] o=0 while o<1: try: ...
e8ebbfb45ea8455b488fe36bbede3b7bbb5bfae0
Rapha-Y/My_Python_Studies
/Basic_Python/NinthClass.py
1,264
3.578125
4
import shutil def write_file(text): path = 'C:/Users/Anni/Documents/Projects/My_Python_Studies/teste.txt' file = open(path, 'w') file.write(text) file.close() def update_file(file_name, text): file = open(file_name, 'a') file.write(text) file.close() def read_file(file_name): file = o...
1b265d30ab4bfd49a687f87062c4eda8883e6a49
Rapha-Y/My_Python_Studies
/Basic_Python/SeventhClass_Television.py
699
3.71875
4
class Television: def __init__(self): self.on = False self.channel = 5 def power(self): self.on = not self.on def channel_up(self): if self.on: self.channel += 1 def channel_down(self): if self.on: self.channel -= 1 print(__name__) if ...
84db20f7bfcaa6dd31784c4b6b23739fdc1a249d
Arjun-Pinpoint/InfyTQ
/Programming Fundamentals using Python/Day 3/Assignment 22.py
557
4.125
4
''' Write a Python program to generate the next 15 leap years starting from a given year. Populate the leap years into a list and display the list. Also write the pytest test cases to test the program. ''' #PF-Assgn-22 def find_leap_years(given_year): list_of_leap_years=[] count=0 while(count<15): i...
1865d73948fd61456461bc10d4079d36ef1efea8
Arjun-Pinpoint/InfyTQ
/Programming Fundamentals using Python/Day 2/Assignment 19.py
2,002
4.03125
4
''' FoodCorner home delivers vegetarian and non-vegetarian combos to its customer based on order. A vegetarian combo costs Rs.120 per plate and a non-vegetarian combo costs Rs.150 per plate. Their non-veg combo is really famous that they get more orders for their non-vegetarian combo than the vegetarian combo.Apart fro...
030f3b5229cd74842dd83ad861f3463d5e1681e6
Arjun-Pinpoint/InfyTQ
/Programming Fundamentals using Python/Day 7/Assignment 47.py
1,317
4.3125
4
''' Write a python function, encrypt_sentence() which accepts a message and encrypts it based on rules given below and returns the encrypted message. Words at odd position -> Reverse It Words at even position -> Rearrange the characters so that all consonants appear before the vowels and their order should not change ...
aaec74ede47b4187d17b155fb899130b5e38a001
Arjun-Pinpoint/InfyTQ
/Programming Fundamentals using Python/Day 7/Assignment 46.py
518
3.859375
4
''' Write a python function, nearest_palindrome() which accepts a number and returns the nearest palindrome greater than the given number. Also write the pytest test cases to test the program. Sample Input Expected Output 12300 12321 12331 12421 ''' #PF-Assgn-46 def nearest_palindrome(number): flag=0 temp='' ...
911e960efcae5fb88e90ce9e8a49487a6edd3a81
Arjun-Pinpoint/InfyTQ
/Programming Fundamentals using Python/Day 1/Assignment 12.py
542
3.71875
4
''' Write a program to create the following pattern: ''' import turtle # allows us to use the turtles library wn = turtle.Screen() # creates a graphics window wn.setup(540,508) # set window dimension alex = turtle.Turtle() # create a turtle named alex alex.shape("turtle") # a...
ed1cc3f8c39044e423818d828027614dc46984bb
rohitkriitkgp/LearningPython
/Sorting/InsertionSort.py
332
4.09375
4
n = int(input('Enter the number of elements: ')) arr = [] for i in xrange(1,n+1): arr.append(int(input('Enter the value: '))) def InsertionSort(data): for j in range(1,n): key = data[j] i = j - 1 while data[i] > key and i >= 0: data[i+1] = data[i] i = i-1 data[i+1] = key return data print(Inserti...
9c65e8a0c034c454145578a71c5ebe7a364f7599
PerScholasNYC/PythonPS
/HW4practice.py
96
3.71875
4
string = "Good Morning" print (string.upper()) string2 = "Hello World" print (string2.lower())
32f5af793a5de02a243eebebbb423088dbaad40f
PerScholasNYC/PythonPS
/HW6.py
998
4
4
class shapes: def _init_(self, s): self.sides = s def area(self): if self.sides == triangle: print(self.sides, "1/2 * b * h") elif self.sides == square: print(self.sides, "a ^ 2") elif self.sides == rectangle: print(self.sides, "w * l") ...
81de100ccc922b6b88afa61b9be255ba9b163d0a
DebarunMitra/PlayWithPython
/Problems/Q3.py
273
3.859375
4
##List of words from sentence sentence=input() words = sentence.split() counts = {} new_list=[] for word in words: if word not in counts: counts[word] = 0 counts[word] += 1 if counts[word] < 2: new_list.append(word) print (new_list)
1aaa235006a575add43e4a05f373323af2e4ec12
yjench/python-challenges
/guess-and-check/sqrt_babylon.py
811
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Use Babylonian/Heron's method to estimate square root of a non-negative # interger # # Problem source: MITx 6.00.1x # # Created on Wed Jun 24 10:38:47 2020 by Yi-Jen Chen import random def sqrt_babylon(x, epsilon=0.01, max_iters=100): random.seed(0) g = rando...
b4abfef08f9aa0c7a0dbf6df39e7cf8f6f85a81d
gaopinghuang0/useful_scripts
/compiler/lisp_compiler.py
5,880
3.765625
4
# this is for Leetcode 736. Parse Lisp Expression # https://leetcode.com/problems/parse-lisp-expression/ class Parser(object): def __init__(self, expr): self.expr = expr self.idx = 0 self.N = len(expr) def peek(self, exp): return self.expr[self.idx: self.idx+len(exp)] == exp ...
2dc3dcc245d14964ead1fb75d33fb3c63a4fb8d4
rahdirs11/Pirple-pythonIsEasy
/Classes/main.py
2,145
3.96875
4
class Vehicle: def __init__(self, make="", model="", year="", weight=0): self.make = make self.model = model self.year = year self.weight = weight self.needsMaintenance = False self.tripsSinceMaintenance = 0 def setMake(self, make): self.mak...
5f1a461091f13af162ad7fb7d3dec666444d6185
rahdirs11/Pirple-pythonIsEasy
/DictionariesAndSets/main.py
925
3.921875
4
humble = { 'album': 'DAMN.', 'artist': 'Kendrick Lamar', 'releasedYear': 2017, 'releasedMonth': 12, 'releasedDay': 8, 'numberOfAwards': 13, 'genre': 'West Coast Hip-Hop, Hip-Hop/Rap', 'totalSongsInAlbum': 14, 'availableOn': ['Spotify', 'YouTube Music', 'Gaana', 'JioSaavn', '...
c78e65a4b606ee3bd677c51b29798d1339ff8c1c
camillepzardo/Python
/tiposvariaveis8.py
1,166
3.921875
4
#x = int(input('De qual numero você quer saber a tabuada?')) #b = (x*1) #c = (x*2) #d = (x*3) #e = (x*4) #f = (x*5) #g = (x*6) #h = (x*7) #i = (x*8) #j = (x*9) #k = (x*10) #print('{}x1={}'.format(x,b)) #print('{}x2={}'.format(x,c)) #print('{}x3={}'.format(x,d)) #print('{}x4={}'.format(x,e)) #print('{}x5=...
122e7346c4afb3006a49c1ee8f0a18a83d81ddf7
dougtc1/algorithms2
/old/ordenamiento.py
3,964
4.25
4
# Descripción: Módulo con la implementación de algoritmos de ordenamientos # que son aplicados sobre listas de elementos que son comparables # entre sí. Al aplicar algún algoritmo de ordenamiento, la lista a ordenar # es copiada y se retorna una nueva lista con los elementos orden...
f8989ba4056ee3008baa156a1538be3f230f7224
piaoyidage/LeetCode
/python/2/source.py
1,549
3.734375
4
#!/usr/bin/env python #-*- coding: utf-8 -*- ''' Created on 2015-1-7 @author: Ben ''' import math # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @return a ListNode def addTwoNumbers(self, l1, l2): # 传入的是两个...
8853b70819c16150e377d6c4a3654c1f36810c61
Jit26k/HacktoberFestContribute
/Algorithms/Array/ReverseArray.py
464
4.28125
4
import Arrays def reversingAnArray(start, end, myArray): while(start < end): myArray[start], myArray[end - 1] = myArray[end - 1], myArray[start] start += 1 end -= 1 if __name__ == '__main__': myArray = Arrays.Array(10) myArray.insert(2, 2) myArray.insert(1, 3) myArray.inse...
4499dd1b261fcb668595f7a0a0e3937a04bfe911
msappington11/R6-Stats
/basicFunctions.py
1,557
3.84375
4
'''Returns the array of white pixels as a string''' def toString(chart): chartToString = '' for i in range(len(chart)): chartToString += '\n' for a in range(len(chart[i])): chartToString += chart[i][a] return chartToString '''Returns the string of white pixels as an ar...
cf4f48ffd73c3ad9f1e45c842d82a8a02e85d4af
Franciszer/PythonBootcam-42ai
/day02/ex00/ft_map.py
290
3.609375
4
def ft_map(func, *args): shortest_len = 0 for arg in args: shortest_len = len(arg) if shortest_len == 0 or len(arg) < shortest_len else shortest_len output = [] for i in range(0, shortest_len): func_args = [arg[i] for arg in args] output.append(func(*func_args)) return (output)
40157c3d4eece2e2fc254c63b0593dd0a2548068
jonieson/pythonDemo
/BaseLogic/judge.py
158
3.96875
4
name = 'jonieson' if name == 'hello': print('this name is not hello') elif name== 'world': print ('this name is not world') else: print ('judge')
92f91f8292a0b48d2cb75c94955a0187327cb563
jandirafviana/python-exercises
/my-python-files/aula06_desafio004.py
2,986
4.1875
4
n1 = int(input ('Digite um número: ')) n2 = int(input('Digite outro número: ')) s = n1 + n2 print('A soma entre {} e {} é {}'.format(n1, n2, s)) a = input('Digite algo: ') print('O tipo primitivo desse valor é ', type(a)) n = input('Digite algo: ') # Esse 'n' que estamos analisando é um objeto. Em n.isnumeric por exe...
aa73a558295d6214d6ba2d6364df1fe0e4b60c63
jandirafviana/python-exercises
/my-python-files/aula07_desafio013.py
457
4
4
print('=== DESAFIO 013 ===') print('Faça um algoritmo que leia o salário de um funcionário e mostre seu novo salário, com 15% de aumento:') salário = float(input('Digite seu salário atual: R$ ')) novo = float(salário + (salário * 15/100)) print(f'O seu novo salário com 15% de aumento é R$ {novo:.2f}') print() salário ...
e4d361c009cd1a4cd312d9ebd6cf5cdd5019c954
JRobinson28/CS50-PSets
/pset7/houses/import.py
933
4.125
4
from cs50 import SQL from sys import argv, exit from csv import reader, DictReader db = SQL("sqlite:///students.db") def main(): # Check command line args if len(argv) != 2: print("Exactly one commmand line argument must be entered") exit(1) # Open CSV file given by command line arg ...
36a45ba23a2da3c3b400cb51011367eb5c7b7011
razakadam74/Interview-Preparation
/node.py
440
3.796875
4
class Node(Object): __init__(self, data): self.data = data self.left = None self.right = None class Tree(Object): __init__(self, root_data): self.root = Node(root_data) addLeft(node, data): if not node.left: node.left = Node(data) re...
f7cfcca9d3b20dab378c374aeac1c30d27746d79
razakadam74/Interview-Preparation
/19th/3sum.py
579
3.65625
4
def threeSum(arr): l = [] for idx,val in enumerate(arr): for i in range(idx + 1, len(arr)): for r in range(i + 1, len(arr)): if val + arr[i] + arr[r] == 0: l_new =[] l_new.append(val) l_new.append(arr[i]) ...
a6b1dcbb3a9208404240bb20b515c236b84456d7
razakadam74/Interview-Preparation
/14th/LinkedList.py
2,043
4.09375
4
class Node(object): data = None next = None def __init__(self, data): self.data = data self.next = None def addNext(self, data): self.next = Node(data) class LinkedList(object): head = None def __init__(self, data): self.head = Node(data) def addNode...
28ba8cb8d16878c4c76dfe5d9de650c4a52cd3c3
oscar-cen/python_basics
/dic.py
1,509
3.6875
4
a1={"color":"red", 'age':18, 'shape':'circle'} print(a1) print(a1["age"]) print("He's "+str(a1['age'])+" years old!") a1['xpos']=25 # add jianzhidui freely like LIST a1['ypos']=10 print(a1) a2={} # create an empty dictionary a2['color']="blue" a2['xpos']=25 a2['ypos']=10 print(a2)...
51f86374d18124783820e4e7740dd33cf01fb6d0
Trooper2123/logica_com_python
/python/lista1/quadrado.py
86
3.5625
4
lado = float(input("Insira o valor do lado:")) print(f"Área do quadrado: {lado**2}")
d5fbe411b72cd0e85f92d2e47f0901fc25f03bc3
Trooper2123/logica_com_python
/python/tp3/voto.py
724
3.84375
4
#Desenvolva uma função que recebe a idade de uma pessoa e informe se essa pessoa é: #Eleitor obrigatório (18 anos completos e menos de 70 anos de idade) #Eleitor facultativo (16 anos completos e menos de 18 anos ou 70 anos de idade ou mais). #Não tem direito a voto (menor de 16 anos). #Fluxo de exceção: #O programa dev...
f5537ae9d2f3f7c79f00afa45c232f703a53c363
bsamimi1/Database_Project1
/get_process_sale.py
898
3.53125
4
def get_sale_info(): vin = get_vin() old_fname = get_old_fname() old_lname = get_old_lname() new_fname = get_new_fname() new_lname = get_new_lname() new_plate = get_new_plate() return vin, old_fname, old_lname, new_fname, new_lname, new_plate def get_vin(): vin = input("En...
297417c03aa9302a6d2b4a209951811f33c9d4e8
bsamimi1/Database_Project1
/get_ticket_payment_info.py
592
3.578125
4
import datetime def get_ticket_payment_info(): tno = get_tno() pdate = get_pdate().strftime("%Y-%m-%d") amount = get_amount() return tno, pdate, amount def get_tno(): tno = input("Enter the ticket number: ") return tno def get_pdate(): pdate = datetime.date.today() ...
2c4e03ba1ccca39eb1ce3bf50cfe01056ca65a9a
harbenml/advent-of-code-2020
/puzzles/puzzle11.py
3,974
3.734375
4
from typing import Tuple from typing import Callable def check_single_seat(value: "str") -> int: if value == "L": return 0 if value == "#": return 1 return 0 def check_adjacent_seats(X: list, row: int, col: int) -> int: nrows, ncols = len(X), len(X[0]) if X[row][col] == ".": ...
2579259859f95fdbf3cee519c69dd3c25508db96
harbenml/advent-of-code-2020
/puzzles/puzzle06.py
947
3.5625
4
from typing import List, Tuple def load_data(filename: str) -> Tuple[List, List]: with open(filename) as f: X = f.read().split("\n\n") no_people = [el.count("\n") + 1 for el in X] X = [el.replace("\n", "") for el in X] X_unique = ["".join(set(el)) for el in X] return X, X_unique, no_people...
3e384188183e8b6d84ee509b13dd2f03766bae73
harbenml/advent-of-code-2020
/puzzles/puzzle25.py
586
3.65625
4
def loop(val: int, subject_num: int = 7) -> int: val *= subject_num return val % 20201227 def get_encryption_key(PUBLIC_KEY_CARD: int, PUBLIC_KEY_DOOR: int) -> int: val = loop_size = 1 while True: val = loop(val) if val == PUBLIC_KEY_CARD: break loop_size += 1 ...
971e8da0cb88bb66211e73f49ada8039e3a46a08
vighnesh153/Notes
/Python/Python3.8-Features/power_modulo.py
384
3.953125
4
pow(x, y) # x ** y # For x, y, z belong to integers, pow supports power_modulo a = pow(x, y, z) # if y >= 0: # a = (x ** y) % z # else (cool feature) # a = ((modular inverse of x, modulo z ) times |y|) modulo z # in simple words, if y == -1, then a = modular inverse of x, modulo z # and if |y| > 1, then let b = modu...
cd0513bcaab5adf1185c407f5cea345cb9e7e28a
vighnesh153/Notes
/Interesting-Problems/Recursion-Backtracking/sudoku/9-by-9_sudoku_solver.py
3,596
4.28125
4
# An efficient way to solve a 9 x 9 sudoku puzzle. # In the 3-by-3 version, I substitute all numbers from 1 to 9 in the empty cell and # check if the board is solvable for each value from 1 to 9 in that cell by recursively # calling the board. But the time complexity of that approach is very high. It can't # be used t...
aaef447a30d8430cf78bdbff4a3ed8bc7a0fda22
jonasbuckner/MarloweEngine
/src/marlowe-unittests-Room.py
4,109
3.65625
4
import unittest import Room import Item from direction import north, south, west, east, up, down class TestRoom(unittest.TestCase): """Unit tests for the Room class""" def setUp(self): """Reusable constants""" self.generic_room_title = "A Generic Room" self.generic_room_desc = "Wow. Y...
cb0047307c54653b76b80abd1d8af216b121c857
dhaneshpawar/python_practicals
/ass1.py
31,889
3.953125
4
""" python demo program for class and object """" import msvcrt import re class Student(object): static_total_students = 0 static_department = "Information Technology" static_college = "MITAOE" @staticmethod def s_t_s(): print "Total students are = ",Student.static_total_students," " ...
ac45bf931da60f3ffa79780019860007e836eefd
timatim/Blackjack
/cards.py
4,967
3.890625
4
from enum import Enum import numpy as np class Suit(Enum): SPADE = 1 HEART = 2 DIAMOND = 3 CLOVER = 4 FACES = {1 : 'A', 2 : '2', 3 : '3', 4 : '4', 5 : '5', 6 : '6', 7 : '7', 8 : '8', 9 : '9', 10: '10', 11: 'J',...
dea74d62f7f6a0161f17cf523083e007358bf397
zaptekofficial/Csharp-Compiler-With-Python
/lexicalAnalyzer.py
2,886
3.796875
4
def dict(userInput): builtin_func = [ "Console.WriteLine", "Console.Write", "Console.Read", "Console.ReadLine" ] symbols = { ";": "term", "{": "cbr-op", "}": "cbr-cl", "(": "rbr-op", ")": "rbr-cl" } keywords = { "while":...
6bf64b2f931e38afdc8436a27e234bad5b74e63b
sandeepkv93/sudoku-solver-comparitive-analysis
/sudokuValidator.py
8,741
3.703125
4
import numpy as np BOARDER = '-------------------------\n' # This class contains all the details needed for validating a Sudoku class SudokuValidator(object): def __init__(self, line=None, grid=[]): self.line = line self.grid = grid def generateBoard(self): grid = [] for c i...
994a98474d5c671f3699545c1d21910becdabeee
OrthantBing/Pythonlearnings
/anagram.py
497
3.640625
4
string1 = raw_input().strip() string2 = raw_input().strip() def isAnagram(string1, string2): c1 = [0] * 26 c2 = [0] * 26 for i in xrange(len(string1)): index = ord(string1[i]) - ord('a') c1[index] += 1 for i in xrange(len(string2)): index = ord(string2[i]) - ord('a') c...
076cd71983b8726b0c54a871ef498fe346a94bb0
OrthantBing/Pythonlearnings
/scratchpad/secondlargest.py
485
3.859375
4
if __name__ == '__main__': n = int(raw_input()) arr = map(int, raw_input().split()) def second_largest(arr): count = 0 m1 = m2 = float('-inf') for i in arr: if i == m1 or i == m2: continue count += 1 if i > m1: if i ...
8ac31d2668c7f1f27df61dc7d5996dec879fe59d
OrthantBing/Pythonlearnings
/test.py
425
3.828125
4
from linkedlist import Node, LinkedList test = LinkedList() test.add("Anton") test.add("Winston") test.add("Christy") test.add("Thomson") print test print "Count: %s" % (test.count) print len(test) print test.search("Christy") test.remove("Thomso") print test test.remove("Thomson") print test test.remove("Anton...
bbe3393beee4d401ffdec13060af560036f03683
OrthantBing/Pythonlearnings
/trie/mastermind.py
3,322
3.53125
4
#https://www.hackerearth.com/practice/data-structures/advanced-data-structures/trie-keyword-tree/practice-problems/algorithm/ma5termind-and-xor-minimization/ import math import sys MAX_LEN_INT = len(bin(sys.maxint)[2:]) def NumStringToBinString(string): num = int(string) return bin(num)[2:].zfill(MAX_LEN_INT) ...
644384d040a63c64ebad854e1923856549a5b760
OrthantBing/Pythonlearnings
/hackerearth/number/gcd.py
318
3.59375
4
def gcd(a, b): if b == 0: return a else: return gcd(b, a%b) def extendedgcd(a, b): if b == 0: return (a, 1, 0) else: g, x, y = extendedgcd(b, a%b) return (g, y, x-(a//b)*y) if __name__ == '__main__': print gcd(81, 18) print extendedgcd(16, 10)
3031b007c39ac147a753365b435df13bfbdaaa1e
OrthantBing/Pythonlearnings
/linkedlist.py
1,919
3.859375
4
class Node: def __init__(self, value): self.value = value self.next = None def getData(self): return self.value def getNext(self): return self.next def setData(self, value): self.data = value def setNext(self, nextNode): self.next = nextNode class...
1b69dab5c2037d1086fcc16b91622af948d84ae8
OrthantBing/Pythonlearnings
/timeinwords.py
2,099
3.609375
4
import re def intlen(n): if n == 0: return 1 count = 0 while n > 0: n = n // 10 count += 1 return count def numinwords(time): words = { 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', ...
0e878733e01919f2f14828ee4e3ffe678e0d0f5f
OrthantBing/Pythonlearnings
/hackerearth/number/fastfactorization.py
295
3.84375
4
def factorize(v): returnlist = list() i = 2 while i * i <= v: while v % i == 0: returnlist.append(i) v = v // i i += 1 if (v != 1): returnlist.append(v) return returnlist if __name__ == '__main__': print factorize(50)
19b4986e16686dae103bac6f6b330aab5426b2ac
OrthantBing/Pythonlearnings
/lynk/arrayreverse.py
803
3.84375
4
def spiralMatrix(array): n = len(array) m = len(array[0]) k = 0 l = 0 print (n, m) while (k < m or l < n): for i in range(k, m, 1): print(array[l][i], end=" ") l += 1 for i in range(l, n, 1): print(array[i][m-1], end=" ") m -= 1 ...
3254337533f549addafb3de206e3866786627bf7
OrthantBing/Pythonlearnings
/hackerearth/binarysearch/monkpolynomial.py
1,017
3.84375
4
# https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/monks-encounter-with-polynomial/ import math def binarysearchpolinomial(a, b, c, k): # x should be between 1 and sqrt(k) if (c >= k): return 0 right = int(math.sqrt(k)) + 1 left = 0 mid = ...
d125094b14771a82b9fe04cd000caea1ff3ae3e5
OrthantBing/Pythonlearnings
/hackerearth/strings/quicksort.py
983
3.890625
4
def partition(array, startindex, endindex): pivot = array[endindex] partitionindex = startindex for i in xrange(startindex, endindex): if ord(array[i]) >= ord(pivot): array[i], array[partitionindex] = array[partitionindex], array[i] partitionindex += 1 array[partitio...
be6e4d2c2dc648f502acdab879b94331bf6f6d5d
OrthantBing/Pythonlearnings
/list/linkedlist.py
2,583
3.8125
4
# https://www.hackerearth.com/practice/data-structures/linked-list/singly-linked-list/practice-problems/algorithm/remove-friends-5/ class LinkedList(object): class Node: __slots__ = '_element', '_prev', '_next' def __init__(self, element, prev, next): self._element = element ...
fba09db92011da7401162e66fdedfad4b41914b0
novidadespikachu/pyObfuscator
/rectangle.py
412
3.796875
4
class Rectangle: '''my class of rectangles''' def __init__(self, a, b): self.width = max(a, b) self.heigh = min(a, b) def get_square(self): return self.width * self.heigh def get_perimetr(self): # count perimetr return 2 * (self.width + self.heigh) if __name__ == '__main__': print(locals()) p...
f25ec583b82367fecb22d14b92764fcbc5ec6a91
msinnema33/Sprint-Challenge--Data-Structures-Python
/names/names.py
3,399
3.671875
4
import time from binary_search_tree import BinarySearchTree start_time = time.time() f = open('names_1.txt', 'r') names_1 = f.read().split("\n") # List containing 10000 names f.close() f = open('names_2.txt', 'r') names_2 = f.read().split("\n") # List containing 10000 names f.close() duplicates = [] # Return th...
94f5f1a23926c581a757ba1c8e73952224de90a8
hellojaney/FIT3077-Assignment-2
/webclientmelb.py
962
3.5
4
from webclient import WebClient from suds.client import Client """ WebClientMelb creates an instance of the Web Client """ class WebClientMelb(WebClient): def __init__(self): WebClient.__init__(self) self.client = Client('http://viper.infotech.monash.edu.au:8180/axis2/services/MelbourneWeather2?wsd...
b529e4c88c9b7067ad669262b515104112862e1f
hellojaney/FIT3077-Assignment-2
/gui.py
1,319
3.71875
4
import Tkinter as tk """ Code derived from: http://stackoverflow.com/questions/3085696/adding-a-scrollbar-to-a-group-of-widgets-in-tkinter/3092341#3092341 Creates a custom Tkinter GUI that allows scrolling of information added to it. """ class GUI: def __init__(self, title): # Configure Frame self...
79fd71a56b681f27c3da6d76a7bce000ca376e22
lawson84/our-toolkit
/ourtoolkit/time.py
524
3.578125
4
import time def measure_time(function, verbose=True, *args, **kwargs): start = time.perf_counter_ns() duration = (time.perf_counter_ns() - start)/10**6 if verbose: print(f"The function {function.__name__} took {duration:.3f} miliseconds to run!") return duration if __name__ == "__main...
aa9384caf498fe38d5c75e2c7ec4aefd6c97c2d2
jesssecat/python-stu
/OOP/7-demo-duojicheng.py
263
3.671875
4
class A: def func(self): print('A') class B: def func(self): print('B') class C: def func(self): print('C') class D(A,B,C): #def func(self): print('D') pass d = D() d.func() #一般情况下 #d = D() #会首先调取d的值,d没有找a,b,c依次查找
a92efbf49b42bed151c53b272a8d905872c58c50
jesssecat/python-stu
/zhuangshi/demo-1.py
1,476
3.640625
4
#打印出函数的地址 #def home(): # print('hello,word') #print(home) #<function home at 0x7fcb27c97e18>输出函数地址 #我们可以看到这段代码的点睛之笔就在这句:“home = wrapper(home)”,我们将home函数的地址当做参数传给了wrapper方法,在wrapper方法中进行验证,验证通过之后再将home方法的地址返回,这个之后再调用home,我们就在没有修改home方法的情况下,调用了home,是不是方便了很多?这就是装饰器的概念! #def login(usr): # if usr == 'Eva_J': # r...
35b5a76d04c7b1373dc29d5063f634d8d8dd8070
swathy21/swathyy
/jdj.py
75
3.703125
4
a1=int(input()) if(a1>1 and a1<10): print("yes") else: print("no")
96bdf80153bcc2d7cf07c128dd0e70b3513da14c
SauravMukherjeeParabole/parabole-recruitment-test-py3
/driver.py
1,389
3.5
4
import logging import os # Reads and returns the list of files from a directory def read_directory(mypath): current_list_of_files = [] while True: for (_, _, filenames) in os.walk(mypath): current_list_of_files = filenames logging.info("Reading the directory for the list of file n...
859c13e0f4a0020510639ae84c145b6e6ef95749
KitGardner/Violet
/entries.py
1,243
3.734375
4
from datetime import datetime from datetime import date class Entry(object): """Individual entries meant to be stored in an agenda. Contains entry information such as entry date, points of discussion, and notes""" def GenerateFileName(self): return str(self.Date) + "_" + self.Title.strip() + "_" + self.Autho...
893117511460ec2e357e3f4f8316a04acb29cad6
femy16/boggle
/study.py
542
3.515625
4
# def get_stems(word): # # print(word[:1]) # # print(word[:2]) # # print(word[:3]) # # print(word[:4]) # # print(word[:5]) # output=[] # i=1 # while i<=len(word): # output.append(word[:i]) # i+=1 # print(output) # get_stems("hello") def get_stems(word): ...
c554137cdd47552035b81ddafb20069c3b05f936
Klukinil/Django_ReqHandling
/PycharmProjects/Homework_Class/Homework_Class.py
3,057
3.890625
4
class Animal(): def __init__(self, name, weight, animal_type, sound): self.animal_type = animal_type self.name = name self.weight = weight self.sound = sound def sounds(self): return f'{self.animal_type} говорит {self.sound}' def eating(self, meal, portion): ...
5884e034aeb5f835d6ac13e2e37eac26afb90818
rutsky/python-course-2014
/04_practice/pygame03_move_keyboard.py
4,447
3.546875
4
# -*- encoding: utf-8 -*- # # Обработка клавиатуры # # Основано на примерах Simpson College Computer Science <http://cs.simpson.edu> import pygame # Определим константы для цветов (модель RGB) black = (0, 0, 0) white = (255, 255, 255) green = (0, 255, 0) red = (255, 0, 0) blue = (0, 0, 255) dkgreen = (0...
aa748bea7bc66b2787ec99aae590351b5f7b0875
pihu456/pooja
/list operation.py
1,064
3.890625
4
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> fruits=['orange','apple','banana','dates','mango'] >>> fruits.count('orange') 1 >>> fruits.index('dates') 3 >>> fruits.reverse() >>> fruits ['mango', 'dates', 'b...