blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
988cf9746585dc6e2954bf1b56334c8f7567b3e5
cs9902/RentCaculator
/carrent.py
225
3.578125
4
total = 327800 rate = 0.50757/100 count = 36 print('total:', total) print('rate:', rate) print('count:', count) money = total * rate * (1 + rate)**count / ((1 + rate)**count - 1) print money print money * count - total
2580ad9e803634e7a8fcf904af830cc1a9642801
dmoonfire/mfgames-media-python
/src/mfgames-mplayer-mythtv
7,563
3.53125
4
#!/usr/bin/python import Tkinter import datetime import dateutil.relativedelta import logging import mfgames_media.mplayer import os import sys import time class RenderState(object): """Encapsulates the functionality for rendering text to the display.""" def __init__(self): self.canvas_texts = [] ...
7e1c56ab3ce044a6ba50adafb44aeb97b1c493ae
mmweber2/adm
/hash/dic2.py
1,529
3.75
4
# Dictionary: set of n records, each with one or more key fields # Build and maintain a data structure to efficiently locate, insert, # and delete the record associated with any query key q. # We could make objects for this, but it is probably less memory to # just put the key/record pair in a list. If we weren't go...
cceb24d6002701d663aa3796b3081b146b8479cc
ketanpandey01/DS_Algo
/Graph/TopologicalSort.py
956
3.8125
4
from collections import defaultdict class Graph: def __init__(self, vertices): self.graph = defaultdict(list) self.V = vertices def addEdge(self, u, v): self.graph[u].append(v) def topologicalSort(self): isVisited = [False] * self.V tempStack = [] ...
7b1eefb1d4b7cf3ee01ad95d2a8850a540c6b85a
kylelee89/kyle_ycc
/hw_200824_3.py
706
3.875
4
# https://www.hackerrank.com/challenges/python-mod-divmod/problem, mod divmod # enter your code here. read input from stdin. print output to stdout a = int(input()) b = int(input()) print(a // b) print(a % b) print((a // b, a % b) # https://www.hackerrank.com/challenges/python-power-mod-power/problem # Enter your co...
12e3df06c83c9f36a30e66dc5f39d314db130f62
Napier-JP/AtCoder
/abc101_d.py
183
3.546875
4
K = int(input()) for i in range(1,K+1): #1からKまで ansStr = "" ansStr += "9"*(i//9) if i%9 == 0: print(ansStr) else: print(str(i%9)+ansStr)
ff7b0275a4cd0ba7ac968e574f8204a89ac957f7
GeeksIncorporated/playground
/wires_and_pins.py
609
3.53125
4
from collections import defaultdict LEFT = 0 RIGHT = 1 wires = { "A": ["B", "D"], "B": ["A", "C"], "C": ["B", "D"], "D": ["A", "C"] } pins = defaultdict(lambda: {"side": None}) pins_pool = wires.keys() def split_wires(): if len(pins_pool) == 0: print (pins) return pin = pi...
1b857dc2199ba3cce6c6bf97ff785124ef51a2a7
EashanKaushik/LeetCode
/30-Day-Challange/Day-17/next_pointer-2.1.py
1,088
3.828125
4
from collections import deque class TreeNode: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next class Solution: def connect(self, root: 'Node') -> 'Node': ...
3393805de6c614217ff8555c69d501ef0558d034
drknsblct/find_grade_py
/main.py
1,517
3.671875
4
from find_grade_functions import * from sql_functions import * while True: try: answer = int(input('\n' + '[1] Add Courses\t\t\t' + '[4] Find Student Grade\n' + '[2] View List (Databases)\t' + '[5] D...
da844a32a08ea3c384be3dcf02c772cafc298d5d
adi0229/Python-AI
/pythonbasic/week1.py
2,112
4.25
4
print('hello world') print('hello world 2') print('Hello world'+'Hello Hong Kong') print(1+1) print(3-1) print(3*4) print(12/4) # print('iphone'+4) # 字符串不可以直接加上数字 print(int('2')+3) # int 定义为整数型 print(int(1.9)) # 当 int 一个浮点型数时,int 会保留整数部分 print(float('1.2')+3) # float()是浮点型,可以把字符串转换成小数 # python 可以直接运算,也可以用 print() ...
5f338224720decf8d6c037e6b2c09067e1ebfbb0
daniel-reich/turbo-robot
/qTmbTWqHNTtDMKD4G_2.py
2,411
4.25
4
""" It's been a long day for Matt. After working on Edabit for quite a bit, he decided to go out and get a beer at the local bar a few miles down the road. However, what Matt didn't realise, was that with too much drinks you can't find the way home properly anymore. Your goal is to help Matt get back home by telling...
737c18eaebc27123d4ee0ee770ea4cf01902acd9
mohitsaroha03/The-Py-Algorithms
/src/3.9Stringalgorithms/WildcardMatch.py
2,147
4.375
4
# Link: # IsDone: 0 # Python program to implement wildcard # pattern matching algorithm # Function that matches input strr with # given wildcard pattern def strrmatch(strr, pattern, n, m): # empty pattern can only match with # empty strring if (m == 0): return (n == 0) # lookup table ...
15ae3b082c03b338927ad7c1cc06ed8a8bbf7ef3
nandadao/Python_note
/note/my_note/second_month/day04/struct.py
287
3.53125
4
""" struct模块打包数据 """ import struct # 生成格式对象  i->int f---> float s--> bytes st = struct.Struct("i4sif") # 数据打包 data = st.pack(1, b"Lily", 172, 8) # print(data) # 解析数据 print(st.unpack(data)) print(type(st.unpack(data)))
7384e0f03b7d7066d932b3dbe9ef6f0795789e19
indexcardpills/python-labs
/16_variable_arguments/16_01_args.py
194
3.734375
4
''' Write a script with a function that demonstrates the use of *args. ''' def tennis_score(*args): for x in args: print(x) tennis_score('love', 15, 30, 40, 'deuce', 'advantage')
287c408405e2e6971a9fe384f3a5982fd5d08fac
NiaWilliams/python
/practice2.py
261
3.859375
4
demond_salary = 525600 arelia_salary = 135820 def potato(salary): if demond_salary > arelia_salary: print('Demond\'s salary is greater than Arelia\'s salary.') # if True: # print(demond_salary + arelia_salary) potato(7531)
ef4f2abd65eb75775cf41e86cc86a5b6da6c98dd
fatima-naqvi/Python-Problems
/Fatima/random.py
190
4.0625
4
print("Enter your age : ") age: int = int(input()) if age > 12 : print("What did one wall say to the other wall? I’ll meet you at the corner!") elif age > 11 :
ba61f04914fd54610dd924b5d88cc0e584b25888
jeff-cangialosi/learn_python
/ex12.py
474
4
4
# Exercise 12 # I went a little ahead and changed up this exercise a little. biggest_city_wi = input("What is the biggest city in Wisconsin? ") biggest_city_il = input("What is the biggest city in Illinois? " ) biggest_city_mi = input("What is the biggest city in Michigan? ") print(f"""\nWhen we scope out cities arou...
84e36755891df8aeb20ca49d08e8d1571e9db4e7
SUTDNLP/ZPar
/scripts/var/cclassifier/posreader.py
191
3.53125
4
import sys def readpossent(path): file = open(path) for line in file: line = line[:-1] sent = line.split() yield [word.split('|') for word in sent] file.close()
2846a8f6563b129cd159ebd123f1157990cc5d92
Spursh/Edmodo
/unit_test.py
4,576
3.6875
4
import unittest from python_file_reader import is_not_valid_date, split_line, is_row_valid, insert_valid_rows, \ is_user_entry_valid class TestIsNotValidDate(unittest.TestCase): def test_not_valid_date1(self): self.assertTrue(is_not_valid_date(r"2016-06-100-17:53:22")) def test_not_valid_date2(s...
5417087ddd289111a3f5846729fd25e4e2ed433f
AmitLY21/image_convert_app
/ImageConverter/program.py
4,045
3.859375
4
import os from tkinter import filedialog from PIL import Image import tkinter as tk """ In this project Ive learned while coding the tkinter library and pillow library. Made an application that convert photos from png to jpg and jpg to png. Added file explorer option and saved the converted photos to a differe...
70d379ece0c0df877437b029e9c49aadb5c5da58
ankit-rane/Task-reminder
/Task reminder.py
699
3.65625
4
import time from plyer import notification # installed plyer by giving the command pip install plyer. if __name__=="__main__": # it helps in encapsulation while True: # running a loop to push notification after a given time. Reminder=input("Enter that task you want to get reminded of") ...
854f991a95353f1fe9d4425097da2859c9147976
sparklynjewel/PYTHON_TASK3
/Modified Number Guessing Game.py
3,039
4.0625
4
import random level = 0 print("Hello lets play a game") game = True while True: print("To begin please select a level of difficulty") level = int(input("input a level of difficulty 1 for easy, 2 for medium and 3 for hard!.\n")) if level == 1: print("This is the easy level") break if l...
26ce16b6c7c5cb73579dee69e17bc7adbe38f6f9
aearl16/Python
/src/Python 3/RaspberryPi/blink.py
1,095
3.90625
4
################################ # # # LED Blink # # # ################################ # # # @Author: Aaron Earl # # # # Tutorial from Freenove to # # make an LED blink on # # a Raspbery Pi Zero W # ################################ import RPi.GPIO as GPIO imp...
d39c171c6a84f0b787ab2dea1e7f99a121a92c5d
IvayloValkov/Python-the-beginning
/Exams/03_oscars_week_in_cinema.py
886
3.6875
4
movie = input() hall = input() tickets = int(input()) price = 0 if movie == 'A Star Is Born': if hall == 'normal': price = 7.50 elif hall == 'luxury': price = 10.50 elif hall == 'ultra luxury': price = 13.50 elif movie == 'Bohemian Rhapsody': if hall == 'normal': ...
f83a824f24b19fdbcae3afed9d28efaa8de46d0e
Qiutiancheng/Python
/hello.py
780
4
4
import math # define a function def something (arg1,arg2): return 'Something' # It's still work if you don't return def PrintSomething (c): fahremheit = str(c * 9/5 + 32) print(fahremheit + '℉') PrintSomething(17) # G to KG def toKilogram (v): kilogram = str(v/1000) return print(kilogram + 'K...
f17d4a07fcde5ced510c4a27e8a01b0723c9e7b1
rajatAS142/Takshashila-Python-SQL-Assignment
/Assignment Q4.py
1,667
3.5
4
#installing the libraries psycopg2, Workbook, pandas import psycopg2 from openpyxl.workbook import Workbook import pandas as pd class employee_info: def emp(self): try: # to connect to the PostgreSQL database server in the Python program using the psycopg database adapter. con = ps...
fdf73fad63d98de302cbd95d4bd515c66cab9c93
lemonad/advent-of-code
/2019-misc/december1.py
1,578
3.609375
4
""" December 1, Advent of Code 2019 (Jonas Nockert / @lemonad) """ import numpy as np import pandas as pd from common.puzzlesolver import PuzzleSolver class Solver(PuzzleSolver): def __init__(self, *args, **kwargs): super(Solver, self).__init__(*args, **kwargs) @staticmethod def add_fuel_column...
9df67cbc5b7b8a11f600233598b1c5a4e30ce2f6
369geofreeman/MITx_6.00.1x
/HackerRank/loops.py
157
3.828125
4
# Loops # The provided code stub reads and integer, n, from STDIN. For all non-negative integers i<n, print i². n = 10 for i in range(n): print(i*i)
b4158154c8b0ef3356a9323b22fc9397e94d83ab
neveSZ/fatecsp-ads
/IAL-002/Listas/2-Seleção/08.py
415
3.953125
4
''' Fornecidos os três segmentos de reta: a, b e c (a>0, b>0 e c>0), verificar se podem formar um triangulo. Exibir a mensagem ‘formam’ ou ‘não formam’, conforme o caso. ''' a = float(input('a: ')) b = float(input('b: ')) c = float(input('c: ')) if (a < b+c) and (b < a+c) and (c < a+b): if(c-b < a > b-c) and (c-a <...
d1759e52a738342069376c6b97504b310574d2af
shiveshsky/datastructures
/contest_IV/test.py
588
3.953125
4
def merge(common, row): i=0 j=0 merged = [] if len(common)==0: return row while i<len(common) and j<len(row): if common[i]==row[j]: merged.append(common[i]) i+=1 j+=1 elif common[i]<row[j]: i+=1 elif common[i]>row[j]: ...
661c6cb5b2eb5557461d98aa847dea82f0ff51ae
leforestier/naval
/naval/__init__.py
2,855
3.921875
4
""" --------------- Examples of use --------------- Simple validation ================= .. code:: python >>> from naval import * >>> address_schema = Schema( ['house number', Type(int), Range(1, 10000)], ['street', Type(str), Length(min=5, max=255)], ['zipcode', Type(str),...
c49303c4e1c367233c87d8208911ee793eb9f675
r2dme/COMP-5005_FOP
/FOP/FOP/PracTest3/testAccounts.py
887
3.59375
4
from accounts import BankAccount def balances(): print('\n#### Balances ####\n') total = 0 for i in range(len(my_accounts)): print("Name: ", my_accounts[i].name, "\tNumber: ", my_accounts[i].number, \ "\tBalance: ", my_accounts[i].balance) total = total + my_accounts[i].balanc...
8aaaf02ce647ff655fd97b32f75b00dd9a2392d0
thumphries/python
/tree.py
2,349
4.15625
4
#!/usr/bin/env python # tree.py # very basic tree with traversals import sys class Tree(object): def __init__(self): self.root = None def insert(self, value): node = Node(value) if (self.root == None): self.root = node else: self.root.insert(node) ...
1d8eb937bc70b795ec6cea11d21e746a046f49b1
iompku/adventcode2020
/8/8.py
2,284
3.5625
4
import string f = open("input.txt") valid = 0 code = [] i = 0 # parse input file, add line number, instruction, and number to a code list for line in f: list = [i] list2 = line.split(' ') list.append(list2[0]) list.append(int(list2[1].strip())) code.append(list) i += 1 ...
e0c0310711e9d0c012b6e37a389dd8f503a1299c
Raxephion/Python-Gravity-Acceleration-Calculator
/Python Gravity Calculator.py
718
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 23 16:48:26 2020 @author: Pierre-Henri Rossouw This script calculates the gravity acceleration at any point in the known universe up to 15 decimal places accuracy """ G = 6.673*10**-11 M_Input = input(" What is the mass of the planet/moon/star/asteroid/comet or other h...
9c1a8c50b355aca40d205d8ba6f3abca11585658
jinwoo0710/python
/0507/rectArea.py
458
3.625
4
def calcarea(r): area = 3.14159 * r * r return area r = int(input("원의 반지름 : ")) print("반지름이", r , "인 원의 면적은", area, "입니다.") def calcArea(b, h): area = b * h return area base = int(input("밑변의 길이 : ")) height = int(input("높이의 길이 : ")) recArea = calcArea(base, height) print("밑변과 높이가", ...
25ca6b41503b3c01b0ba71c5122fff0c471c89c5
jacobbathan/python-examples
/ex8.12.py
499
3.890625
4
# exercise 8.12 ROT13 encryption def rotate_word(string, rotations): lower_string = string.lower() num_string = [] new_string = '' for char in lower_string: num_char = ord(char) - 96 + rotations num_string.append(num_char) for num in num_string: new_char = chr(...
04151e7c95d448f0df7e8095d6e493a11aed80b9
jackspicer1229/CSCI4446
/logMap.py
889
3.578125
4
import matplotlib.pyplot as plt m = input('Enter a value for m: ') R = 3 x0 = 0.2 nArray = [] xNarray = [] xNPlusOneArray = [] for i in range (0,m): x_n1 = R*x0*(1-x0) xNarray.append(x0) xNPlusOneArray.append(x_n1) x0 = x_n1 nArray.append(i) xNPlusTwoArray = xNPlusOneArray[1:m] plt.figure(figsize=(12,4)) plt.s...
f3c747fc66dbaa4f8063afc769d1386eaaa605fb
Abhay123-art/python
/1_march.py
639
3.8125
4
#l1 = [1,2,3,"radi,cal"] #print(li) l1 = [2,6,7,[7,8,9]] print(l1[3][2]) l1 =[1,2,3,4,5,6,7,8,9] l2 =l1[3:7] #print(l2) #print(l1[-6:-2]) #both are same result is same first bnumber in slicing is called as inclusive and the last one is exclusive l1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] #l2 = l1[2:8:2] #print(l...
24e8c230d92c7b1d0838c353956d4245210ea567
josepotal/Udacity_programming_foundations
/lesson_6_advanced ideas/media.py
828
3.5
4
# file that defines the Class (keep it here) import webbrowser class Movie(): """ This class provides a way to store movie related information """ ## this is documentation creation we access to it "(media.Movie.__doc__)' VALID_RATINGS = ["G","PG","PG-13","R"] def __init__(self, movie_title, movie_st...
7170ad5bc198540b646528d8df4bda55833b4461
markbromley/ml-experiments
/simple-linear-regression.py
3,472
3.84375
4
import math import random import numpy import matplotlib.pyplot as plt class SimpleLinearRegression(object): ''' A basic implementation of simple linear regression. Calculates coefficients b0 and b1, such that f(x) = b1x + b0. Also provides estimate for coefficient of determination (e.g. r^2). ''' ...
f478907f18288773da4f4c1fc2ca293f299bc504
harish-515/Python-Projects
/ErrorDebugging/ExceptionHandling.py
226
3.546875
4
def divide(a,b): try: return a/b except ZeroDivisionError: return "Divison by zero in meaningless" except: return "Error while executing the divison" print(divide(1,0))
710c76963499abcdccab800eb0f586a3657430b3
BZukerman/StepikRepo
/Python_Programming/Basics and use/Occurrence_SSs.py
1,211
4.21875
4
# # Вашей программе на вход подаются две строки s и t, состоящие из строчных # латинских букв. # Выведите одно число – количество вхождений строки t в строку s. # s, t = (input() for i in range(2)) # Ввод исходных данных Len_s = len(s) # Длина исходной строки # print("Len_s:", Len_s) Len_t...
f5519db96cf8b5bb12ae814c7d1247015dfbbaad
rajatpanwar/python
/FUNCTION/Add.py
582
4.09375
4
in theses exapmle we ll discuss about function <------example1-------> n1=input("enter the first no") n2=input("enter the second no") ttal=n1+n2 print(ttal) //output is ---44 //bcoz of input function takke input from user as a string <------example2-----> n1=int(input("enter the first no")) n2=int(input("ente...
0466388b11f41ad9c59afb306db7b7a6b7f7a0da
Jfadelli/Intro-Python-II
/src/adv.py
3,207
3.75
4
from room import Room from player import Player from items import Item # Rooms outside = Room("Outside Cave Entrance", "North of you, the cabe mount beckons", [('shield')]) foyer = Room("Foyer", "Dim light filters in from the south. Dusty passages run north and east.",[('sword')]) overlook = Room("Grand Overlook", "A ...
eec22730259d4165b01fbf8707b5926b98b465a2
benoitrosa/VTK_Useful_things
/grabVideo.py
731
3.640625
4
import os from natsort import natsorted class grabVideo: """ grabVideo is a simple class that will list all jpg files in a folder, sort them by natural order (i.e. 1 2 3 4 .. 10, and not 1 10 2 3 4 ...) and store the result when getNextFile is queried, it will return the path to the next image file in the list. I...
e93d3094a36e01dba4266f745ae941b69f66f896
SIDORESMO/crAssphage
/bin/location_db.py
4,391
4.34375
4
""" Create a location database for our data. This is a SQLite3 database that has a single table with the following attributes: 0. latitude 1. longitude 2. locality: the name of the city, municipality, or province in utf-8 encoding 3. country: the name of the country in utf-8 encoding 4. ascii_loca...
06b0dda1f51ea8f8816452f927bc08d0c436f2f8
ztalarick/School
/eclipse-workspace/CS115A/hw6.py
3,615
3.6875
4
''' Created on 10/16/17 @author: Zachary Talarick Pledge: I pledge my honor that I have abided by the stevens honor system. ztalaric CS115 - Hw 6 ''' # Number of bits for data in the run-length encoding format. # The assignment refers to this as k. COMPRESSED_BLOCK_SIZE = 5 # Number of bits for data in the origi...
5cb988b9ba8bd176aa11f9437dce0d5ebec777f1
Nalinswarup123/python
/class 7/duplicate in list.py
235
3.875
4
#wap wich reads list of int and return a new list bt eliminating the duplicate #elements in the list a=[1,2,5,2,4,1,3,6,6,6] b=[] for i in a: for j in a: if(i!=j and i not in b): b.append(i) print(b)
67abd7f38078b2ab9013e13fa458eb165675bfe6
cavmp/200DaysofCode
/Day116-ColorGame.py
1,730
3.9375
4
import tkinter import random colours = ['Red', 'Blue', 'Green', 'Pink', 'Black', 'Yellow', 'Orange', 'White', 'Purple', 'Brown'] score = 0 timeleft = 30 def startGame(event): if timeleft == 30: countdown() nextColour() def nextColour(): global score global timeleft if timel...
1907fb9ce3f2d374767d12baf72a9be27bd5ca92
WooWooNursat/Python
/lab7/informatics/5/probB.py
138
3.953125
4
a = int(input()) b = int(input()) def power(a,b): n = a for i in range(1, b, 1): n = n * a return n print(power(a, b))
11db5ce04015059387ed347f3a88d92492aa7d1d
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/cshjam001/question2.py
165
3.90625
4
x = eval(input("Enter the height of the triangle:\n")) gap=(x-1) for i in range(0,x*2-1,2): print(' '*gap,end='') print('*'*(i+1)) gap=gap-1
57e7f970237cd02907c7575587060fca5cbd2938
mannhb/guessing-game
/guessing_game.py
1,934
4.3125
4
""" Python Web Development Techdegree Project 1 - Number Guessing Game -------------------------------- For this first project we will be using Workspaces. NOTE: If you strongly prefer to work locally on your own computer, you can totally do that by clicking: File -> Download Workspace in the file menu after you fork...
3d7bee213d74f57e3b7f3c47228afdc1e24e5f11
AtushiMaeda/python_study
/bs/bs-select.py
639
3.59375
4
from bs4 import BeautifulSoup # 対象となるHTML html = """ <html><body> <div id="maxim"> <h1>トルストイの名言</h1> <ul class="sentences"> <li>汝の心に教えよ、心に学ぶな</li> <li>謙虚な人はだれからも好かれる</li> <li>強い人々は、いつも気取らない</li> </ul> </div> </body></html> """ # HTMLを解析 soup = BeautifulSoup(html, 'html.parser') # タイトル部分を取得 h1 = sou...
ad8567b2bbd0002e706a3766c6ac9b4941f2d040
pradeepshetty1/python-Pandas-and-Numpy-
/Module2/7_example_sequence.py
641
3.640625
4
l1 = list(range(10)) l2 = list('Edureka') l3 = [1,2,3,4] print(l1) print(l2) print(l3) print(l1[3]) print(l2[3]) print(l3[3]) print "=========BREAK1=============" print (l2[-1]) print (l2[-2]) print(l2[2:4]) print(l2[1:-1]) print(l2[1:-1:2]) print "============BREAK2==========" #print(l2[10]) print(l2[::-1]) pr...
502438a513af97ee68441cc575a3af8a003c1d04
green-fox-academy/FKinga92
/week-03/day-04/08string2.py
293
4.03125
4
# Given a string, compute recursively a new string where all the 'x' chars have been removed. def x_remove(string1): if string1 == "": return string1 elif string1[0] == "x": return "" + x_remove(string1[1:]) else: return string1[0] + x_remove(string1[1:])
09e2980e78b9be4371783d44247230c09dc78e58
ghardoim/seguranca-informacao
/gerawordlist.py
147
3.96875
4
import itertools string = input("Digite: ") resultado = itertools.permutations(string, len(string)) for char in resultado: print("".join(char))
bc2620c39fc6077d302977dd2a68583717fd21ff
wszeborowskimateusz/cryptography-exam
/modulo.py
2,014
3.609375
4
import math from functools import reduce def count_divisors(a): result = 0 for b in range(1, a + 1): result += math.floor(a // b) - math.floor((a - 1) // b) return result def fast_pow(a, b): c = 1 while b > 0: if b % 2 != 0: c *= a a = a ** 2 b = b // 2...
292b7c6e3c2590565187245b0f661dd032b3713d
karthiklingasamy/Python_Sandbox
/B14_T2_DateTime_TimeDelta.py
388
3.953125
4
import datetime tday=datetime.date.today() # to get current date tdelta=datetime.timedelta(days=7) print(tday+tdelta) print(tday-tdelta) # date2 = date1 + timedelta # timedelta = date1+date2 print('--------------------') bday=datetime.date(1993,9,13) till_bday=bday-tday print(till_bday) print(till_bday...
40be82bd52f0346646545e6cba10e0421e8a3ebf
czs108/LeetCode-Solutions
/Medium/323. Number of Connected Components in an Undirected Graph/solution (2).py
1,026
3.75
4
# 323. Number of Connected Components in an Undirected Graph # Runtime: 316 ms, faster than 6.20% of Python3 online submissions for Number of Connected Components in an Undirected Graph. # Memory Usage: 15.4 MB, less than 90.86% of Python3 online submissions for Number of Connected Components in an Undirected Graph. ...
47441e3fc76e87ffa2be38a8a35d264ef26941cb
CallMeSnacktime/100DaysofCodeProjects
/Day 29: Password Manager/main.py
3,113
3.921875
4
# Import shuffle, choice and randint methods to use them directly from random import choice, randint, shuffle from tkinter import * from tkinter import messagebox # ---------------------------- PASSWORD GENERATOR ------------------------------- # #Password Generator Project def password(): letters = ['a', 'b', '...
38eea2ed68b89f09ce14a8e2f8595d46589af962
DanielMalheiros/geekuniversity_programacao_em_python_essencial
/Exercicios/secao06_estruturas_de_repeticao/exercicio13.py
389
3.96875
4
"""13- Faça um programa que leia um número inteiro positivo par N e imprima todos os números pares de 0 até N em ordem crescente.""" n = int(input("Digite um número inteiro e positivo: ")) if n > 0: if n % 2 == 0: for x in range(n+1): if x % 2 == 0: print(x) else: p...
6161942f00c7061bf014ebcbcd58f5c31aa5c3b9
brett-davi5/Python-Numbers-Guessing-Game
/NumbersGuessingGame.py
4,145
4
4
# coding: utf-8 # In[31]: import random def randomNumber(): number = random.randint(1, 100) return number # In[32]: def game(): greeting() global magicNumber magicNumber = randomNumber() global tries tries = 10 while tries > 0: userNumber = askForInput() if(userNumb...
82da9d7705286605cb63bae7a533d9fa8ade39ad
ufukcbicici/phd_work
/tf_experiments/math_experiments.py
168
3.546875
4
import numpy as np def a(n_, p_): return 1.0 / (n_ * (np.log(n_)**p_)) sequence = [] p = -3.0 for n in range(2, 1000): sequence.append(a(n, p)) print("X")
b9023852a13e64e8a593ad684682a160782502c3
cljacoby/leetcode
/src/majority-element/majority-element.py
775
3.71875
4
# https://leetcode.com/problems/majority-element from collections import defaultdict class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int """ counts = defaultdict(int) mx = (float('nan'), float('-inf')) for num in nu...
88ca3d7c6783ea7400c00e840f1a8be383f8d677
ky822/assignment10
/ssz225/project/functions.py
2,115
3.984375
4
import pandas as pd import matplotlib.pyplot as plt def test_grades(grade_list): """Assuming list of grades given already sorted by DESCENDING date order: Assign A, B, C, to 1, 0, -1 and compare the most recent grade to its past grade. If the most recent grade has a higher value, the function returns 1; ...
6a94a4a9548b2eacf8b1d534944e3aff89a9cb7a
rutujamalusare/py_vsc
/encode_decode.py
467
4.03125
4
a="h\te\tl\tl\to" print(a) print(a.expandtabs(1)) import base64 string= base64.b64encode(bytes("hello I am learning python",'utf-8')) print(string) string1= base64.b64decode(string) print(string1) string2= input("enter any string") string2=base64.b64encode(bytes(string2,'utf-8')) print(string2) string3= base6...
74eb5edfde30fc5a710bd602641299cbf002fe15
bonicim/technical_interviews_exposed
/src/algorithms/tree_questions/find_max_sum_binary_tree.py
842
4.125
4
""" Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root. """ def find_max_sum_binary_...
72012b9cd32a7353ca6c3b0a219f8611542938d2
jhuang292/leetcode-diary-August-23
/hamming distance.py
210
3.5
4
class Solution: def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ o = x ^ y return sum(1 for i in range(32) if o & 1<<i)
7b73a9dde0dccdaf19434419c4ce16387f099588
hyrdbyrd/ctf-route
/public/tasks-content/code.python.py
124
3.53125
4
def encrypt(text): key = len(text) res = [] for i in text: res.append(ord(i) + (ord(i) % key)) key += 1 return res
d2517e2f45ddb7c97aa69d794ea9df63bb4fbdd6
young31/Algorithm
/백준/10815.py
351
3.609375
4
from collections import defaultdict def false(): return False n = int(input()) arr = list(map(int, input().split())) has = defaultdict(false) for a in arr: has[a] = True m = int(input()) is_has = list(map(int, input().split())) res = [] for i in is_has: if has[i]: res.append(1) else: ...
877eec6fc9d15bc5f3243489ceb7a50872342dfc
VladSemiletov/python_algorithms
/Task_4/4_1.py
1,184
3.6875
4
from timeit import timeit def func_1(nums): # общая сложность - O(N) new_arr = [] # O(1) for i in range(len(nums)): # O(N) + O(1) if nums[i] % 2 == 0: # O(1) new_arr.append(i) # O(1) return new_arr # O(1) def func_2(nums): new_arr = [i for...
4a8300cf8992ec60296a10eb1d21d5179c7e2cc6
hutor04/UiO
/in4110/assignment4/instapy/python_color2sepia.py
666
3.515625
4
import numpy as np def python_color2sepia(img): """ Applies sepia filter. Args: img (numpy.ndarray): vectorized image. Returns: numpy.ndarray: vectorized sepia image. """ sepia_filter = [[0.393, 0.769, 0.189], [0.349, 0.686, 0.168], [0.272, 0.534, 0.131]] height, width, cha...
d66330c6f9bc5b6fb1f77aa71112777435e46b80
abhishekshetye/competitive
/python/max_network_rank.py
922
3.609375
4
''' https://leetcode.com/problems/maximal-network-rank/ Store graph in map of set to optimzie the finding. Iterate through vertices and get the maximum rank. ''' class Solution: def maximalNetworkRank(self, n: int, roads: List[List[int]]) -> int: if len(roads) == 0: return 0 ...
b896828b795f7e60af39e46d83f85b876747d7f4
BhumikaReddy/3GRM
/Programming/Python/string1.py
248
4
4
import string a="the quick brown fox jumps over the lazy dog" print(set(a)) b=list(string.ascii_lowercase) print(set(b)) x=set(b)-set(a) print(x) if not x: print("panagram") else: print("no") #program to check whether a string is panagram or no
93b1481ff9af3956d4c341b08630d363a02dc19a
broepke/GTx
/part_3/4.5.11_reader.py
2,580
4.21875
4
# Recall in coding problem 4.4.3 that you wrote a function # called "reader" that read a .cs1301 file and returned a # list of lists. # # Let's revise that problem. Instead of a list of lists, # that's return a dictionary of dictionaries. # # Write a function called "reader" that takes one parameter, # a filename as a ...
ddd1e4686f67c0d1f78c5fac5e80d6ef7ed48801
comojin1994/Algorithm_Study
/Uijeong/Python/Math2/1929.py
392
3.75
4
import sys import math input = sys.stdin.readline def isPrime(number): if number == 1: return False sqrtN = math.floor(math.sqrt(number)) for j in range(2, sqrtN + 1): if number % j == 0: return False return True if __name__ == "__main__": m, n = map(int, input().split()) ...
2fe40dc6ca95a8805721d971074896c7d1a71b9e
PanPapag/A-Complete-Python-Guide-For-Beginners
/Functions_Files_and_Dictionaries/Functions_and_Tuples/Local_and_Global_variables/func_mutability.py
266
3.6875
4
def double(y): y = 2 * y def changeit(lst): lst[0] = "New one" y = 5 print("Initial y: ",y) double(y) print("Doubled y: ",y) mylist = ["lets", "see", "what", "will", "change"] print("Initial list: ",mylist) changeit(mylist) print("Changed list: ",mylist)
c57d75dd1d8b6c81cbea303908b19efbbdb7c5a1
mattyoungberg/Notebook
/Notebook/note_utils.py
1,340
4.15625
4
import datetime class Note: """ Container class for the notes instantiated by the user. Attributes: identifier:int -- unique identifier of the note memo:string -- the actual content of the note tags:list<string> -- tags for easy searching creation_date:datetime.datetime --...
85ed0f8b501e9aa153b04b8287b3e4592e397fe5
AngelosGeorgiou/PythonProjects
/ValidParenteses.py
437
4.40625
4
#Write a function called that takes a string of parentheses, and determines if #the order of the parentheses is valid. The function should return true if the #string is valid, and false if it's invalid. def valid_parentheses(string): total = 0 for letter in string: if letter=='(': total+=1 ...
0911b1c6097e3d8c5ccf2519375fd31410d407fe
AdamZhouSE/pythonHomework
/Code/CodeRecords/2776/60594/289021.py
1,007
3.640625
4
def findAllConcatenatedWordsInADict(words): def check_word(word, pre_dict): if len(word) == 0: return True cur_dict = pre_dict for index, c in enumerate(word): cur_dict = cur_dict.get(c, None) if cur_dict is None: return False i...
6e5dbd8ed889fa7f46828de030133acc5342d286
danmohler/File-Sort
/FileSort.py
6,493
4.1875
4
# Author: Dan Mohler # FileSort.py A program to sort files using account numbers # Last modified 10/14/2021 # Python Version Python 3.7.4 # Application Notes # Parameters are specified in the following order: # fileDir, folderDir, optional parameters # fileDir is...
72ab58328290a15315fbae6db97d8a01b8ea9688
pengnam/DailyCodingProblemSolutions
/Problem24-BinaryTreeLocking.py
1,549
4.125
4
""" Implement locking in a binary tree. A binary tree node can be locked or unlocked only if all of its descendants or ancestors are not locked. Design a binary tree node class with the following methods: is_locked, which returns whether the node is locked lock, which attempts to lock the node. If it cannot be locked...
0317cf338c2e03c6061a1a08273742e8ff43d234
dahlan77/Pacman-Test-Dahlan
/pacman_test_dahlan.py
3,817
3.625
4
import csv import math import numpy as np from matplotlib import pyplot as plt import random import pandas as pd def loadcsvdataset(filename): with open(filename, 'r') as csvfile: lines = csv.reader(csvfile) dataset = list(lines) headers = dataset[0] dataset = dataset[1: len(dataset)...
d2997fd2c08bb747181e6f9eb6d9a7ddb5d7c7b3
rubinshteyn89/Class_Spring
/Python/Lab_6/question2.py
478
3.84375
4
__author__ = 'ilya_rubinshteyn' def question2(): n = 1 while n != 0: n = eval(input("What range of numbers would you like to add? ")) if n < 0 or type(n) == float: print("Invalid input") continue elif n > 0: sum_of_n = n*(n+1)/2 print("T...
55a869884376329277c0ba158040ebace7c5c0e8
deesaw/PythonD-005
/Revise/11.py
1,537
4.15625
4
#------------------------------------------------------------------------------- # Define a new function that simply print's out "Game Over!"... #------------------------------------------------------------------------------- def printIt(): print( "I am already good at Python!" ) # Now, lets call our new function...
54af2a9a31e390ed35f054e1c74f6b74e0839821
ParulProgrammingHub/assignment-1-AlfaizKhan
/python 1 (5).py
152
3.859375
4
days=int(input('enter no. of days')) year=days/360 a=days%360 b=a//30 c=a%30 print 'no. of year=',year print 'no. of months =',b print 'no. of days=',c
3ef6c462b7d0a74903a2b78e1fb1e568b0784d85
2XL/Python4Everyone
/orientacionaobjetos/herenciamultiple.py
434
3.609375
4
class Terrestre: def desplazar(self): print "El animal anda" class Acuatico: def desplazar(self): print "el animal nada" # HERENCIA MULTIPLE """ EN PYTHON A DIFERENCIA DE LOS OTROS LENGUAJES COMO JAVA O C... """ # de las uqe hereda separados por comas: class Cocodrilo(Terrestre, Acuatico): ...
60e2bd6949f95734302f3077df978b6cb662619f
userwithoutcode/HOMEWORKS
/hw2.1/homework_2.1.py
1,712
3.8125
4
def get_file(): with open('homework_2.1.txt') as f: cook_book = {} for line in f: dish_name = line.upper().strip() contains = [] for i in range(int(f.readline())): ingredient = f.readline().split("|") ing_list = list(map(str.strip, ingredient)) contains.append({'ingr...
aa01f663a9cb23c5e6a25eadfc5508cda20f116c
PrachiNayak89/Prachi-rampUp
/passwordGenerator.py
711
4.15625
4
#!/usr/bin/python import random import string #This program will generate the strong password def passwordGenerator(size): char=string.ascii_uppercase+string.ascii_lowercase+string.digits+string.punctuation generatedPw=(''.join((random.choice(char) for x in range(size)))) print 'Generated password :', gen...
7243fbe58f8c3ce007a1e547c284767fcfa69db8
evanwangxx/leetcode
/python/70_Climbing_Stairs.py
378
3.765625
4
# 70. Climbing Stairs def climbStairs(n): """ :type n: int :rtype: int """ if n == 1: return 1 elif n == 2: return 2 else: r = list(range(n)) r[0] = 1 r[1] = 2 for i in range(2, n): r[i] = r[i-2] + r[i-1] return r[n-1] ...
547b5245b031f74864ec8d8f93e26d88f73b8909
KellianT/Transport_TAM
/tam2.py
7,768
3.75
4
import sqlite3 import argparse import sys import urllib.request from time import * import logging logging.basicConfig( filename='tam.log', level=logging.INFO, format='%(asctime)s %(levelname)s - %(message)s', datefmt='%d/%m/%Y %H:%M:%S',) logging.info('Demarrage du programe') def clear_rows(cursor...
66439ad629700d7baf8482321abe6344d0102219
Sangita-Paul/substraction-using-2-s-compliment-python3-
/code1.py
2,380
3.578125
4
global jan def hii(): new=list(b) new[0]="1" ''.join(new) print('-a') print(new) indexes = [index for index in range(len(new)) if new[index] == '1'] #print(indexes) q=max(indexes) #print(q) i=1 for i in range(i,q): ...
45ef956f03a8f532582877af71ecfaf185d5d001
changjustin217/cmq
/Queue.py
1,241
3.71875
4
class Node(object): def __init__(self, name, andrewID): self.name = name self.andrewID = andrewID def __hash__(self): return hash(self.name) def __eq__(self, other): return isinstance(other, Node) and self.name == other.name def __repr__(self): return self.name class Queue(o...
323ae1f499dc0bbc7fbf4c00379151cf1da4ee88
Jacob-Eckroth-School/362-InClassGit
/divisor.py
436
4.03125
4
def divisors(num): divisorsList = [] for i in range(num,0,-1): if(num%i == 0): divisorsList.append(i) print(divisorsList) def getUserInput(): userInput = input("Please enter a positive integer:") while(not userInput.isdigit()): print("Incorrect input, please enter a int...
d8d3ade8bb8e90a44230e709f177a33328595192
JoseCaarlos/Python
/Seção 09 - Comprehensions/list_comprehension_pt1.py
1,393
4.5625
5
""" List Comprehension - Utilizando List Comprehension nos podemos gerar novas listas com dados processaos a partir de de outro iteravel # Sintaxe da List Comprehension [ dado for dado in iterável ] # Exemplos numeros = [1, 2, 3, 4, 5] resp = [numero * 10 for numero in numeros] print(resp) res = [numero / 2 for...
82f9f34c4eccafa9249c3a0e0d70fff7a0bab805
hkXCIX/Fire-Maze
/dfs.py
2,607
3.609375
4
from mazeGen import arrayToTree import numpy as np from collections import deque import copy def dfs(maze, start, goal, mlen): # keep a grid that marks where it was already explored visited = np.zeros((mlen, mlen)) # DFS uses stack stack = deque() # starts at (0,0) stack.append(start) ...
a8d6c60913ca016dc44c6fac9d1eb877ce7c2759
kyungtae92/Keras
/keras20_2_load.py
1,740
3.5
4
#1. 데이터 import numpy as np x = np.array(range(1, 101)) # 1~100 y = np.array(range(1, 101)) print(x) from sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=66, test_size=0.4, shuffle=False) # 6:4 / 섞기 싫으면 shuffle=False / default=True x_test,...
345d65578b93626830179f13c4f0c51fc800dab2
GlinkaG/pp1
/02-ControlStructures/Zad15.py
84
3.8125
4
x = int(input("Podaj x: ")) for i in range(1, 11): print(f"{x}x{i}={x*i}")
78a5feed364a9fe45b8bb171fced1b6594ee02fe
gkarwchan/algorithms
/standard-algorithms/single-linked-list/linkedlist.py
969
3.78125
4
from node import Node class LinkedList: def __init__(self): self.tail = None self.head = None self.size = 0 def append(self, data): if self.tail: self.tail.next = Node(data) self.tail = self.tail.next else: self.head = Node(data) ...