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
584ee367a92dd95d7b8a47bd61948bbc4806dc55
Clickidyclank/Year_2
/collage/python project/DAVID HURLEY project/R00150758 project.py
5,091
3.890625
4
#Student number ;R00150748 #Name ; David Hurley #These are my global lists that i need to reference threwout the program global account_number account_number =[] global balance balance = [] global balance_2 balance_2 =[] global name name = [] #this function reads in from the file and converts to a list def reading()...
582a0356082ad1925de285a9d9b4637d4532fefa
boikomykola10/hillel_python
/lesson_6/task_17.py
248
3.6875
4
d = { 'apple': ['malum', 'pomum', 'popula'], 'fruit': ['baca', 'bacca', 'popum'], 'punishment': ['malum', 'multa'] } c = {} for key, value in d.items(): for i in value: c[i] = c.get(i, []) c[i].append(key) print(c)
d1f1152f7e6ea1caa9122fb72b4b3b56baad3a13
boikomykola10/hillel_python
/lesson_4/task_8.py
93
3.546875
4
string = input('Введите строку: ') spaces = string.count(' ') print(spaces + 1)
26dc6bbe8917df10b9845aa08d9abf8e6ec25abf
boikomykola10/hillel_python
/lesson_3/task_5.py
230
3.90625
4
N = int(input('Введите натуральное число: ')) k = 1 # минимальное значение 2 ** 0 = 1 c = 0 # минимальная степень while k * 2 <= N: k *= 2 c += 1 print(c, k)
59c4fc94bd55211586126f7359db6f7071280513
seahrh/cses-problem-set-python
/src/sortingandsearching/sliding_median.py
2,550
3.828125
4
""" You are given an array of n integers. Your task is to calculate the median of each window of k elements, from left to right. The median is the middle element when the elements are sorted. If the number of elements is even, there are two possible medians and we assume that the median is the smaller of them. Inp...
7880a106e74ee6da7e33f9c89dbd1d89d2fd903a
seahrh/cses-problem-set-python
/src/introductoryproblems/two_sets.py
1,666
3.875
4
""" Your task is to divide the numbers 1,2,…,n into two sets of equal sum. Input The only input line contains an integer n. Output Print "YES", if the division is possible, and "NO" otherwise. After this, if the division is possible, print an example of how to create the sets. First, print the number of elements...
1c5814278c2f7bd843c44da9fead4f5a60254421
seahrh/cses-problem-set-python
/src/dynamicprogramming/coin_combinations_2.py
1,849
3.65625
4
""" Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using the available coins. For example, if the coins are {2,3,5} and the desired sum is 9, there are 3 ways: 2+2+5 3+3+3 2+2+2+3 I...
eebc92a55331564185410a7ebb31dc55f4a52ba5
seahrh/cses-problem-set-python
/src/dynamicprogramming/array_description.py
1,942
3.890625
4
""" You know that an array has n integers between 1 and m, and the difference between two adjacent values is at most 1. Given a description of the array where some values may be unknown, your task is to count the number of arrays that match the description. Input The first input line has two integers n and m: the ...
f5c2661d23b54728ad8378b193b9dee85f947374
seahrh/cses-problem-set-python
/src/sortingandsearching/concert_tickets.py
2,070
3.78125
4
""" There are n concert tickets available, each with a certain price. Then, m customers arrive, **one after another**. Each customer announces the maximum price he or she is willing to pay for a ticket, and after this, they will get a ticket with the **nearest possible price** such that it does not exceed the maxi...
541740942855ce56a6302c99dc04f437bbd55ada
seahrh/cses-problem-set-python
/src/introductoryproblems/creating_strings_1.py
1,460
3.953125
4
""" Given a string, your task is to generate all different strings that can be created using its characters. Input The only input line has a string of length n. Each character is between a–z. Output First print an integer k: the number of strings. Then print k lines: the strings in alphabetical order. Constraints...
dc4e613d631604bdf81ba8c80051b4c3130818c8
jun-Ghoul-Freezer/Trade
/俺ら東京さ行ぐだv1.07.py
1,427
3.703125
4
#俺ら東京さ行ぐだ #作詞・作曲・歌手:吉幾三 #1984年(昭和59年)11月25日発表 #python3コーデ:グール #俺ら東京さ行ぐだv1.07.py #巡査のパトロールは3/日と仮定する #[課題]自動車の「それほど」の解がわからず今回は「無い」と仮定 import datetime def 俺ら東京さ行ぐだ歌詞(): テレビ = str() ラジオ = str() 自動車 = str() ピアノ = str() バー = str() _巡査 = "巡査" パトロール = 3 村 = [テレビ, ラジオ, 自動車, ピ...
48cb3e1424a1e33bb8b234509cfedc72c13bd428
sylvioneto/python_games
/hanging.py
1,546
3.9375
4
# author: sylvio.pedroza@gmail.com import random def play(): print("***************************") print("Welcome to the hanging game") print("***************************") # local variables is_hanged = False is_won = False max_tentatives = 10 errors = 0; words = [] with open(...
db1488232311b790722b2eff8cb1ed8d11cc3271
simonostensson2001/python
/LEK1.py
193
3.765625
4
print("hej på er i ee17") firstName = "Simon" lastName = "Östensson" dateOfBirth = 20010614 age = 18 teacher = False print(firstName, lastName + str(age) + str(teacher)) print(dateOfBirth)
e7600b413c2d0770158562337833238c672c75aa
kylebgorman/wikipron
/wikipron/extract/jpn.py
2,170
3.5625
4
"""Simplified word and pron extraction for Japanese This extraction function attempts to target Japanese orthographic entries that are composed solely of kana. As of March 2020, the kana variant of a headword containing kanji is generally found inside an <rt> element that is itself contained with the <strong> element ...
7026a980fadc3de8a3fac64774c9df1502286ce9
tdengg/pylastic
/pylastic/distort.py
31,454
3.5
4
""" Get DEFORMATION MATRIX for given spacegroup number and Lagranian strain. **Example:** .. code-block:: python import distort dist = distort.Distort() # generate instance of distortion object dist.sgn = sgn # set spacegroup number (int) dist.set_strainList...
91181c566306bb381bce387d52ced5e289021091
prograsshopper/five-questions-for-a-week
/term11th/week_1/set_matrix_zeroes.py
639
3.796875
4
class Solution: def setZeroes(self, matrix: List[List[int]]) -> None: """ Runtime: 128 ms, faster than 95.86% of Python3 online submissions for Set Matrix Zeroes. """ row = set() col = set() for i in range(0, len(matrix)): for j in range(0, len(ma...
4419dba24336ae819076600c1aeccd49dcdf38ce
JessicaKarinaLopezMarroquin/Python_Crash_Course
/JKarinaLopezM/1hello_world.py
141
3.59375
4
#create a variable to hold the text message = "Hello World" #print the text stored in the variable print(message) #keeps the window input()
53681580795d78934c30bc8c37914caaa986db01
charles-stan/learn_python_Stanier
/E1e_hello_world.py
782
3.65625
4
""" Hello World Python Script Learning Example for Dr. Stanier's classes File: E1e_hello_world.py Author: Charles Stanier, charles-stanier@uiowa.edu Date: August 9, 2019 Written/Tested In: Python 3.7.3 Program Objective: Same as example 1d, but calling my library of functions as a module and accessing the ...
a5025265cdba510e8d1b9ec834e993db64d17ad5
charles-stan/learn_python_Stanier
/E9_steam_simple.py
1,635
3.734375
4
# -*- coding: utf-8 -*- """ Showing Steam Table Lookup Using IAPWS Learning Example for Dr. Stanier's classes File: E9_steam_simple.py Author: Charles Stanier, charles-stanier@uiowa.edu Date: September 7, 2019 Written/Tested In: Python 3.7.3 Program Objective: Demonstrate the lookup of entropy of superheat...
4aa560f5e217c769180295bab04083f575973d54
JakeAttard/2810ICTAssignment
/word_ladder.py
7,276
3.53125
4
#word_ladder created by: #Jake Attard s5138647 #Steven Phan s5080436 # Importing Regular Expressions import re import unittest print("Welcome to the ladder-gram program!") # Same function # Original code from the word_ladder given just renamed variables from c and t to better naming conventions def same(item, target)...
bf44413ec101466043c14961e255cd0dc1ab5af7
dimitrisgiannak/Python-Private_School-Part_B
/files/PV_methods2.py
1,081
4.1875
4
from datetime import date ''' For details check README ''' error_message3 = 'You must input an integer' def getdate(datetime_ , statement , empty): while True: date1 = 0 try: print_message = f'Please write the {datetime_} of the {statement} ' date = input(print_message +...
fb45a002e3a51ee5d93227776e03147e3eed0b96
gingerose/db
/coursework/view.py
21,648
3.65625
4
from controller import Controller import hashlib from datetime import datetime from datetime import time controller = Controller() while True: print("Enter 1 if you want to work with films") print("Enter 2 if you want to work with users") print("Enter 3 if you want to work with halls") print("Enter 4 i...
0293128e80e59fc6fc07ffbc167664b2b34fcfe7
zalloy/tools
/scripts/programming/bitmask.py
1,249
3.65625
4
#!/usr/bin/python import sys,re def getValue(inString): if re.search(r'^0x',inString): # Hex value return int(inString,16) else: # Treat as base-10 return int(inString) def usage(): print "Usage: %s number [mask]" exit(1) power = 0 num = 0 value = getValue(sys.argv[...
974424948c00168d58c2e962dade7874630a62dc
IskanderMahambet/urok_files
/main.py
1,617
3.515625
4
fileWithPeople = open('people.csv','r',encoding = 'utf-8') countM=0 countF=0 #for line in fileWithPeople: #mas = line.split(',') #for i in range (1,len(mas)): # if i==1 or i==2 or i==3: # countM+=int(mas[i]) # else: # countF+= int(mas[i]) #if countM > countF: ...
17c1f540d404b365852e8519318609f0e9e8e533
kylemccreery/dicts
/escape_discord.py
762
3.78125
4
LONGEST_KEY = 3 START = "STRO*EBG" START_WITHOUT_OUTER = "STRO*EBGZ" ESCAPE = "SKAEP" STAR = "STAR" def lookup(key): if len(key) < 1: raise KeyError if key[0] not in (START, START_WITHOUT_OUTER): raise KeyError outer = "" if key[0] == START_WITHOUT_OUTER else "`" if ...
bfdc6ee0bf7200debb05e7380ebb3003f426c0a5
anthepro/Advent-of-Code-2018
/day2.py
567
3.703125
4
# Who needs more code from functools import reduce def part1(input): return reduce(lambda x, y: x * y, (sum(any(x.count(c) == y for c in x) for x in input) for y in (2, 3))) def part2(input): # sum(1 for ... if cond) rather than sum(cond for ...) because it's much faster in this case return next(''.join...
2afb6ec117f80976580c25c9d6e94fc2d13de78a
Dhruv-Pindawala/Cryptography
/cryptomath.py
295
3.53125
4
def gcd(a,b): while a!=0: a,b = b%a, a return b def modinv(a,b): if gcd(a,b)!=1: return None u1, u2, u3 = 1,0,a v1, v2, v3 = 0,1,b while v3 != 0: q = u3//v3 v1,v2,v3,u1,u2,u3 = (u1-q*v1),(u2-q*v2),(u3-q*v3),v1,v2,v3 return u1 % m
57fcbebd3c4a73d8de3e1de33f9227bda6df8210
vishal1602/daily_interview_pro
/LongestSubStringWithoutRepeat.py
473
3.78125
4
# Given a string, find the length of the longest substring without repeating characters. class Solution: def lengthOfLongestSubstring(self, s): sub_strs = [] temp_str = "" if not s: return 0 for char in s: if char in temp_str: sub_strs.append(temp_str) temp_str = "" else: temp_str += char...
42c2c83ee0bbf8970e8a410af5545e90963c8612
rickyzhangNYC/LeetCode_Top100
/MaxDepthOfBinaryTree.py
639
3.578125
4
counter = 0 def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ if root == None: return 0 if root.left == None and root.Right == None: return 1 return max(self.maxDepth(root.left),self.maxDepth(root.right))+1 # left_depth = 0 # right_dep...
63d4918264b5151a9f1baed29e2227070b8464e3
rickyzhangNYC/LeetCode_Top100
/FirstUniqueCharacterinString.py
769
3.90625
4
''' Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Note: You may assume the string contain only lowercase letters. ''' def firstUniqChar(s): queue = list() indexdict = dict() for i in range(len(s)): if s[i] not in indexdict: ...
fce43d0ca4ceae27eb5eb52074676f67f084b30b
chuanzaizai/python_self_study
/4-oop基础/01.py
4,418
4
4
# 例子1 ########多继承的例子 class Fish(): sex = '男' def __init__(self, name): self.name = name self.__age = 15 self._school = '四川大学' self.firendly = True def swim(self): print('我会游泳') class Bird(): def __init__(self, name): self.name = name self.time = '...
f0e3308a3aa885f0d79f6dc6207651de8bdbcce5
arifasalma/codekata
/alphabet1.py
111
3.890625
4
ef=raw_input() if((ef>='a' and ef<='z') or (ef>='A' and ef<='Z')): print("Alphabet") else: print("No")
b4b408b8b300ba961be0d557179b1391724a8432
LastCow9000/Algorithms
/Algorithm/Programmers/19 카카오 겨울 인턴십 - 크레인 인형뽑기 게임/solution.py
895
3.734375
4
# 2019 카카오 개발자 겨울 인턴십 - 크레인 인형뽑기 게임 lv1 # https://programmers.co.kr/learn/courses/30/lessons/64061 from collections import deque def solution(board, moves): cnt = 0 _stack = [] rotate = [deque(list(arr)) for arr in zip(*board)] for move in moves: dq = rotate[move - 1] if not dq: ...
53385166c350c9854b10517e1141a0ad102301b7
LastCow9000/Algorithms
/Algorithm/BOJ/2577_숫자의 개수_b2/2577.py
225
3.609375
4
# https://www.acmicpc.net/problem/2577 A = int(input()) B = int(input()) C = int(input()) product = str(A * B * C) arr = [0] * 10 for i in range(10): arr[i] = product.count(str(i)) for result in arr: print(result)
b522d2f1bff7daf84a39ec74e693951b71b11817
LastCow9000/Algorithms
/Algorithm/Programmers/20 카카오 블라인드 - 자물쇠와 열쇠/solution.py
1,392
3.59375
4
# Programmers 2020 KAKAO BLIND RECRUITMENT - 자물쇠와 열쇠 Lv3 # https://programmers.co.kr/learn/courses/30/lessons/60059 # 백트래킹 # lock을 가운데에 두고 key를 모두 넣어볼 수 있는 큰 판을 만들고 다 시도 def rotate(key): return list(zip(*key[::-1])) def check(lock, board): for i in range(len(lock)): for j in range(len(lock)): ...
4c65fd8671ed8d9bce95a41b351fcad35a369390
nerdySingh/scrabbler
/prefixes.py
2,262
3.765625
4
import time import re wordlist=[] mybool=[] def check(f,pref,pref_len): flag = True for i in range(len(f)): if f[i][0] == pref[0]: #checks only those words that match with the 1'st letter of the prefix string. word=f[i][:pref_len] #for every string thats is read we concatenate the string in...
3c0239e6a49594c70023f58ffdfe517eebf9df88
DhammaWays/DataAnalyst
/Programming/maxdiff.py
2,429
3.5625
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 19 21:40:01 2016 @author: lsharma """ def maxDiff_0(A): if( A[1] > A[0] ): cur_max, max_sofar = A[1], A[1] cur_min, min_sofar = A[0], A[0] else: cur_max, max_sofar, cur_min, min_sofar = A[1], A[1], A[1], A[1] negdiff = A[1] - ...
ae8818270ef0f26f914391eadc22311e3d15f6f8
DhammaWays/DataAnalyst
/Programming/qsort.py
1,422
3.703125
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 25 13:50:18 2016 @author: lsharma """ """Implement quick sort in Python. Input a list. Output a sorted list.""" def qsort(array, s, e): # helper function to allow in-place sort if( e <= s ): # just one element or empty, return as it is pass elif( e-s == ...
f2dc16e373f8c6e18f30bb0f7ffa3c0985b16355
modukurusrikanth/python-inventateq
/dictinory_ex1.py
286
4.3125
4
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 d = {'KA':'BLR','MH':'mum','AP':'AMR','noodles':['yippeee','maggi']} for k,v in d.items(): print(" the capital of {} is: {}".format(k,v)) for k in d.values(): print("All the values of dictionary is:{}".format(k))
b430c0d93306ec90c5265ecf56f214596df4921e
modukurusrikanth/python-inventateq
/sorting_a_list_with_out_sort_function.py
590
4.09375
4
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 list_1 = [9, 8, 1, 6, 3, 2, 10, 12, 11, 201, 209, 99, 203,4,-5,4] print("The list is:", list_1) req = raw_input("Enter 'a' for ascendin order and 'd' for descending order:") for i in xrange(len(list_1)): for j in xrange(i+1,len(list_1)): if r...
a5b2fdd0a9f78f160f40d7975cab2c57cea2590f
modukurusrikanth/python-inventateq
/biggest_and_smallest_number_from_list.py
405
4.15625
4
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 list_1 = [9, 8, 1, 6, 3, 2, 10, 12, 11, 201, 209, 99, 203,4,-5] max_num = list_1[0] min_num = list_1[0] print("The list is:", list_1) for i in xrange(len(list_1)): if list_1[i] > max_num: max_num = list_1[i] elif list_1[i] < min_num: ...
3c670ae64a69427a2e14c7645264ee21cf53523c
frg100/Sobreviure
/enemy_class.py
1,832
3.828125
4
class enemy: def __init__(self,name,level,health): self.name = name self.level = level self.health = health def attack(self): print "A %r appears! It wants to fight!" % (self.name) player.weapon = (raw_input("What do you attack with? >>").lower()) while (player.he...
bdda8a74472232f6fc82b55b611859c0c4cfcaf0
1809mayur/array-gfg
/first_three_largest.py
766
4.03125
4
# Here we will find the first three largest elements. # O(NlogN) AND O(1) space. def get_by_sorting(arr,n): arr.sort(reverse = True) count = 0 ans = [] for i in arr: if count < 3: ans.append(i) count += 1 return ans # It take O(n) complexity but space complexit...
3b35a9f07719d985455fa2bdcff1d421d0493ebc
1809mayur/array-gfg
/merge_two_array.py
871
4.03125
4
def merge(a1,a2,m,n): i,j = 0,0 a3 = [] # contains union of both array in sorted order. a4 = [] # contains intersection of both array. while (i+j) < (m+n)-1: if i >= m: a3 += a2[j:] break if j >= n: a3 += a1[i:] break if a1[i]...
d2f53b00cae8731e03e804a43fbe06db53f340c6
cidexpertsystem/python-snippets
/isLucky.py
1,161
4.1875
4
# Ticket numbers usually consist of an even number of digits. # A ticket number is considered lucky if the sum of the first half # of the digits is equal to the sum of the second half. # Given a ticket number n, determine if it's lucky or not. import math def isLucky(n): # if sum of first half of digits equals s...
cf537c87a6e55c5f50fe91a3f5d17d210669bf7c
cidexpertsystem/python-snippets
/sortByHeight.py
484
4.09375
4
# Some people are standing in a row in a park. There are trees between # them which cannot be moved. Your task is to rearrange the people by # their heights in a non-descending order without moving the trees. def sortByHeight(a): # rearrange elements other than -1 without moving the -1 positions x = sorted(a) ...
cb2cc81bfac5d0025f5d5ebaeab61bfaa3299472
noelz8/Intro-II-semestre
/area rect primera programa 9-8-19.py
285
3.84375
4
#Primera prgramacion intro II semestre #9/8/2019 #Funcion que calcula el area de un rectangulo #E(entrada): base,altura #S(salida): area del rectangulo #R(restrincciones): base,altura numeros y mayores que 0 def area_rect(base,altura): area==base*altura return area
08cb6e1fa37833fd0488d1342b9d09b1fcf2ac78
dhanvijay-nannaware/32-to-43
/Q36 sum.py
320
3.75
4
i=1 sum=0 while 1<=10: num=int(input("enter the number")) sum=sum+num i=i+1 print(sum) # a="12/" # b="5/" # c="2020" # print(a+b+c) # a="AASHA" # b="RAHUL" # c=("PAWAR") # print(a+b+c) # i=1 # while i<=5: # j=5 # while j>=i: # print(j,end=" ") # j-=1 # print() # i+=1
9aa5aed5762c46784e67fdd4b140df0ba43a2fe6
nickdurbin/intro-python-II
/src/adv.py
1,807
3.53125
4
from room import Room from items import Item # Declare all the rooms room = { 'outside': Room("Outside Cave Entrance", "\n\nNorth of you, the cave mount beckons", ["lantern"]), 'foyer': Room("Foyer", """Dim light filters in from the south. Dusty passages run north and east.""", ["basic sword"]), 'overlook': R...
388df98195a371e003cc64aa8b92cdfc79b66040
KorAleksi/University-projects
/Creative Computer Engineering and Design/final.py
10,412
3.625
4
""" Variables: 0-9 = rows (FIXED) 10 = current position (FIXED) 11 = next position 12 = bit_manipulation (decoding, used with AND) 13 = current_pos, number_of_moves 14 = current_stage (how far in tree) 15-17 = division_positions 18-22 = moves (18 also next move) 23-28 = local variables for functions """ def init_memo...
40399459d51dfe5d9c394ac385b57be6eaf34325
mctopherganesh/diabetes_data
/dis_helper.py
1,462
3.53125
4
import sqlite3 import datetime import pandas as pd def db_and_table_name_setter(name_of_db, name_of_table): return name_of_db, name_of_table def create_table_for_bs(name_of_db, name_of_table): # function for testing and creating bs data table conn = sqlite3.connect(name_of_db) # previously 'bs.db' c ...
f9bb1b03eaa2d55ed7a905225abf06ba4f22920f
F3sterski/TuringMachine
/turing.py
1,101
3.84375
4
__author__ = 'Adam Zielke' import xml.etree.ElementTree as ET tree = ET.parse('program.xml') root = tree.getroot() alphabet = root.find('alphabet').text.split(' ') word = raw_input("Please input word: ") word = list(word) print word[0] sum = 0 for i in range(len(alphabet)): sum += word.count(alphabet[i]) if sum i...
1856263def6d2dee52316831dd29e8a92b4408fa
brunoczim/op-desafios
/desafio-03/JonathanLopes403/python/main.py
1,281
4.25
4
""" Esse progama mostrar todos os números palindrômicos entre um número e outro """ import sys def num_palindromicos(inicio, fim): """ Essa função é responsavel por gerar os números palindrômicos """ #Conjunto dos números que são palindrômicos palindromicos = set() # Verifica se fim é menor que inicio ...
df54fd25505fcce767e3c7ff8b317a4d8978e2dd
Krava-K/Class-Work
/cw03/CW 3.4.py
518
3.890625
4
def countCurrency(amount): #определяем функцию её аргумент. money = [1000, 500, 200, 100, 50, 20, 10, 5, 3, 2, 1] print ("Количество банкнот и их номинал ->") for i in money: if amount >= i: j = amount // i amount = amount - j * i print (i, ":", j) amount ...
172a9d26d2265021d371f44db66870e601ea024a
farfromhome/learn
/python_recurrence.py
210
3.75
4
def factional(n): if n==1: return 1 else: return n*factional(n-1) number=int(input('please input a int number')) result=factional(number) print('%d 的阶乘是:%d' %(number,result))
bb73cc9aeea50e6687a711264361fd5c519050f9
tbc31cc/Python-scripts
/150520/sp_search.py
3,907
3.84375
4
# Search Spotify library and return the URI of the desired item # The URI can be entered as a location in foobar2000 # For removing items not available in chosen country, filters out actual items in list. # Previous method did not attempt to filter list and instead printed blank line when item was not available. # ...
f040bdf06c541f4d34143e7ac24bac14229450d5
DeepBlueCUG/Leetcode-Practise
/021.py
1,734
4
4
# Definition for singly-linked list. # 合并两个有序列表 class LinkNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Link: def creat_link(self, nums: list) -> LinkNode: root_node = LinkNode(None) current_node = root_node for element in nums: ...
1811759e340d506fa6574deb9ae9d4bb43912d10
theblacksigma/Py9ft
/5. Python progra to calculate Area of Right Angled Triangle.py
346
4.34375
4
#Python progra to calculate area of Right Angled Triangle b=int(input("Enter base of the right angled triangle:")) p=int(input("Enter perpendicular height of the right angled triangle:")) h=(b**2+p**2)**(1/2) x=b+p+h a=(1/2)*b*p print("Perimeter of Right Angled Triangle:",x,"units") print("Area of Right Angled ...
b25292cb37c2ffe679c58faa5f1053fa73fcf000
theblacksigma/Py9ft
/9. Python program to calculate Simple Interest.py
211
4
4
#Python program to calculate Simple Interest p=int(input("Enter Pricipal amount: Rs")) t=int(input("Enter time period(in years):")) r=int(input("Enter rate%:")) s=(p*t*r)/100 print("Simple Interest=Rs",s)
6d181c409df3761a18a5ca4e7c8394da27ea0ab6
theblacksigma/Py9ft
/4. Python program to Add Subtract Multiply Division two numbers.py
258
3.875
4
#Python program to perform Add / Subtract / Multiply / Division on two numbers a=int(input('Enter number 1:')) b=int(input('Enter number 2:')) add=a+b sub=a-b mul=a*b div=a/b print('Add=',add) print('Sub=',sub) print('Mul=',mul) print('Div=',div)
3c2d59a55315a6cdd21af9d4158c5fbe5156aad0
theblacksigma/Py9ft
/11. Python program to use IF Statement.py
135
4.25
4
#Python program to use IF statement a=int(input("Enter a number:")) if(a>5): print("Value entered '",a,"' is greater than 5.")
9cd7399dc9a6e6dc4d715a17a7e386485a29e04c
sumginazu/dormsaver
/ask_watson.py
825
3.59375
4
import httplib, urllib import json class Watson: WATSON_INTERFACE_URI = "localhost" WATSON_INTERFACE_PORT = 3000 watson_conn = httplib.HTTPConnection(WATSON_INTERFACE_URI, WATSON_INTERFACE_PORT) def ask(self, question): if question == '': question = 'Bad question' # TODO change thi...
d28c7acb1b6b176905b6d1f62b6b0e3a5fd55fd9
SharjeelBaig0508/PIAIC_Assignment_3
/Assignment 3/Text File Reader/File Reader.py
1,313
3.984375
4
# File Opening file_path = "sample_text_file.txt4" file = open(file_path, 'r') contents = file.read() # -----------------( Calculations )------------------- # Word Count words = contents.split() num_words = len(words) # Line Count lines = contents.split("\n") num_lines = len(lines) # Non-Space Characters, Spaces, T...
32eb0faa636d917ebc65fc1e7830b1ab3fcc285d
barrdav/AoC
/AoC2022/src/2022_2.py
1,703
3.59375
4
''' Created on Dec 1, 2021 @author: barrda A, Rock win Scissors B, Papper win rock C, Scissors win papper X loose Y draw Z win ''' DEBUG = 0 def convertDraw(adv, me): if ( me == 'X'): if (adv == 'A'): return 'C' elif (adv == 'B'): return 'A' else: ...
844029fdb3823d35a1b3a7c1661c52b6eafca4d6
matthewzar/CodeWarsKatas
/Python/Kyu7/CountDivisors.py
1,663
3.84375
4
''' https://www.codewars.com/kata/542c0f198e077084c0000c2e/train/python Counts the divisors of a positive number 'n' >divisors(1) 1 >divisors(5) 2 >divisors(4) 3 ''' # Time: 2126ms # Despite looking simplistic, this is a better version than all those shown below for 2 reasons: # - Almost half the run-time (NOT due...
645b76d43eb988a42ce1daf1d5832eeb65a651b7
matthewzar/CodeWarsKatas
/Python/Kyu8/PositiveNegativeCount/PositiveNegativeCount.py
923
4.21875
4
''' https://www.codewars.com/kata/count-of-positives-slash-sum-of-negatives/train/python Count positive numbers, and sum negatives. ''' def count_positives_sum_negatives(arr): if(arr == []): return [] return [sum([1 if x > 0 else 0 for x in arr]), sum([x if x < 0 else 0 for x in arr])] impo...
dd7a081d5b3b3abff555ace8661af3d4805c7285
jidegithub/zuri-python-lessons
/CLASSES and OBJECTS/task.py
1,493
3.765625
4
class Budget: def __init__(self, name): self.name = name self.balance = 0 def deposit(self, amount): self.balance += amount return f"your new balance is \u20A6{self.balance} in {self.name} budget" def withdraw(self, amount): if(self.balance < amount): return f"insufficient funds" ...
92012d2fd70fe90f5167eac95e83a94409eba839
mourice-oduor/Tkinter-GUI-login-SignUp-System
/login-v1/login_1.py
3,120
3.796875
4
from tkinter import * import sqlite3 window=Tk() window.title("Python: GUI Login Application") window.geometry("400x200") #window.configure(bg='#105e1a') def login(): def login_database(): conn=sqlite3.connect("login.db") cur=conn.cursor() cur.execute("SELECT * FROM test WHERE email=? AND password=?",(e1.get()...
3e2d5d9dd079e5e5cb62b474c1077ce05741914e
rejane-b/Py-Me-Up-Charlie
/PyBank/main.py
1,206
3.890625
4
import csv # Declaring variables list_month = [] list_amount = [] list_change = [] # Read and assign data with open('Resources/budget_data.csv', newline='') as file: reader = csv.reader(file) data = list(reader) data.pop(0) for item in data: list_amount.append(int(item[1])) ...
192eccf887cad1887c94db578a1d7d02904f3530
kinjal2110/PythonTutorial
/39_comprehension.py
1,254
4.21875
4
# ls = [] # for i in range(50): # if i%3==0: # ls.append(i) #i module 3 ==0 value print # above things we can also done by list comprehensions # -----------------------------------------------list comprehension----------------------------------- ls = [i for i in range(50) if i %3==0] #it i...
61ed971df85f240a7c33ea84425ada21cec640f2
kinjal2110/PythonTutorial
/38_generator.py
953
4.28125
4
''' Itersble- __iter__() or __getitem__ Iterator __next__() Iteration ''' def gen(n): for i in range(n): # return i yield i #it is return value g =gen(3) for i in g: print(i) for i in range(6): print(i) # using generator factorial print("Factorial is: ") def fact(n): sum = 1 ...
7458f71e057ac16bda775bbf4e3ddeaefd06159d
kinjal2110/PythonTutorial
/exercise_5.py
2,755
3.765625
4
# Health Management System # 3 clients we need to manage their diet- harry, rohan and hammad # total 6 files need to make # write a function that when executed takes as input client name # one more function to retrieve exercise or food for any client ''' first of all user to ask which you want to lock: 1 for harry, 2 f...
9fa5497b05d08b7ed3dfb2cbee1924d1e92f0928
kinjal2110/PythonTutorial
/40_for_else.py
154
3.984375
4
eat = ["pavbhaji", "dosa", "soda"] for item in eat: if item == "paratha": break # print(item) else: print("Your item was not found!")
bfd0b02f1fc11908d66698a7678d79ccd8274e2a
kinjal2110/PythonTutorial
/17.py
374
3.875
4
# F strngs me = "Kinjal" a = "this is %s"%me #string formating, here readability massup print(a) b = "ks" c = "hi" p = "%s %s"%(c, b) print(p) a1 = "hi.." a2 = "how are you?" a3 = "{1} {0}" #{} {} blank also allowed. b = a3.format(a1, a2) print(b) #concept of f string import math a2= "kinjal" a = f"this is...
fc8a0e66310d9b4b30dff5addcdf4f01e026b489
kinjal2110/PythonTutorial
/8.py
867
4.25
4
#Exercise:- Take user input, and we need to say user to those number or less then or greater then number # which already has an over program.(it likes binary search). # if n=18 # number of guesses is 9 # we need to print number of guesses left # number of guesses he took to finish. # if all guesses left the...
a2c659a7da8a56c8736393b2491899c47336b734
kinjal2110/PythonTutorial
/Exercise_6.py
3,094
4.21875
4
# Snack Water Gun ''' this game i explained in gujrati as i understand. koi pan ek manas snack, water , or gun bnavi ske. if ek e snack bnavyo and bija e water bnavyu so snack e water ne pi jy and water out./snack winner if ek e water bnavyu bija e gun bnavi so gun e water ma padi jse, gun out/water winner. if el e gun...
8c389531d3c6b6d9370c03007d81dd833f268a68
KiRusshA/Python_DS_Lemeshevsky
/Laba2/adaptive_integration/adaptive_integration.py
345
3.84375
4
# coding=utf-8 from integration_methods.trapezoidal import trapezoidal def adaptive_integration(f, a, b, eps, method='trapezoidal'): n = 1 while abs(trapezoidal(f, a, b, n) - trapezoidal(f, a, b, 2 * n)) >= eps: n *= 2 result = trapezoidal(f, a, b, 2 * n) print(abs(result - trapezoidal(f, a, b...
fc54bd5f3c1bac1a229cd1c05b1b8f57667876ef
KiRusshA/Python_DS_Lemeshevsky
/Laba2/run.py
414
3.859375
4
from double_integration import test # f = True # while f: # q = input("What would you like to compare: rectangular's method or trapezoidal's one? If rectangular's input '1', else input '0' \n") # if q == 1: # rectangular_test_func() # f = False # elif q == 0: # trapezoidal_test_func(...
7fa136dda8cf65e7401505f171f8512843ecf2fd
loganpettit-stack/Python-Projects
/DiagraphSimulation/DiagraphSimulation.py
14,740
3.859375
4
""" Author: Logan Pettit Date: September 2, 2019 Class: 4500 Introduction to the Software Profession Description: This program is a game that will create a Digraph based on the given input file provided, The first line of the file will describe the amount of nodes that will be in the game, the game will require between...
1a14e5a09d5c4922501454611b6114925ba15afa
telecoda/teletris
/models.py
10,099
3.6875
4
# block.py import random import pygame from constants import * class Block(object): def __init__(self, x, y, colour): self.x = x self.y = y self.colour = colour def __str__(self): return 'x: %d y: %d colour: %d' % (self.x, self.y, self.colour) class Board(object): def...
c090772ff9e56f60d5f60a374e0989185deef349
AnselmoPfeifer/learning-python
/List/lista.py
511
3.984375
4
nomes = ['Zero Nome', 'Primeiro Nome', 'Segundo Nome', 'Terceiro Nome', 'Quarto Nome'] print 'Todos os nomes' print nomes print '' print 'Somente um nome' print nomes[2] print '' print 'Alguns da lista' print nomes[0:3] print nomes[3] print '' print 'Adicionando um nome na lista' nomes.append('Quinto Nome') nomes.ap...
f559c403b9d4ae2d4b56c5ec71b3a62fa0555591
scott124/Python
/基本套件使用/try_except.py
500
3.5625
4
while True: s=input('輸入100的餘數:') try: i=100/float(s) print('100除',s,'=',i) break except ValueError as e: #捕捉職錯誤的例外,並將例外存到e print('發生 ValueError 例外:','e') except ZeroDivisionError: #捕捉除以0的例外,省略as print('發生ZeroDivisionError例外') ...
8205016b2a403b13f8ed71eea6c700dedf88df9b
s3w3nofficial/Koneko-Chan
/scripts/OS_PathManager.py
622
3.609375
4
import os class OS_PathManager(): def get_music_path(self): files = os.listdir("D:") #get all files from D: print len(files) i = len(files) - 1 #remove all files that dont contains mp3 using backward for cycle while i != -1: if "mp3" not in files[i]: ...
fe5fd63f85a8e60a83bfe82ed940d8bbdb5b8d59
Dheerajcsd/Python-For-Everybody
/ex_3_2.py
266
3.875
4
score = input("Enter Score: ") s = float(score) if s>=0&&s<=1: if s>=0.9: print('A') elif (s>=0.8&&s<0.9): print('B') elif (s>=0.7&&s<0.8): print('C') elif (s>=0.6&&s<0.7): print('D') elif (s<0.6): print('F') else: print('Error')
679c75fa47b4cdbf0398ac23351dbcabd8b5072b
kentover/gitest
/main.py
346
4.03125
4
import math #name = input("What is your name? ") #age = int (input("What is your age? ")) #age += 1 #print ("Your name is " + name.capitalize()) #print ("Your age will be " + str(age) + " after 1 year")' a = 2 b = 2 c = 3 #print(max(a,b,c)) #print(pow(b,c)) if a>b: print("it is more") elif a==b: print("equally"...
5500c20f18a7b70a2942a660e0060ec72843b08e
tarantot/homework-for-Feb-3
/homework-for-Feb-3-1.py
1,198
3.875
4
from random import randint import math a = int( input ("Введите нижнюю границу: ")) b = int( input ("Введите верхнюю границу: ")) c = int( input ("Сколько ты хочешь? ")) l = [] l2 = [] l_2 = [] l3 = [] l_3 = [] l_n = [] for i in range(c): l.append(randint(a, b)) for i in l: l2.append(i**2) for i i...
cca3c66bd95684817d2c73a08eddb0d6d652bb0c
bhumika0311/Bootcamp-1
/Week1Day6/Interweave.py
214
3.890625
4
def interweave(str1, str2): string1 = ''.join(x + y for x, y in zip(str1, str2)) string1 += (str1[len(str2):] if len(str1) > len(str2) else str2[len(str1):]) print(string1) interweave("Bhumika", "Vasusamarth")
0bc67135ace173b09d8b5fdaede65d68c002f950
moxlev/AtCoder
/abc/abc001B.py
265
3.5
4
m = int(input()) m /= 1000 if m < 0.1: print('{:02d}'.format(0)) elif 0.1 <= m and m <= 5: print('{:02d}'.format(int(10 * m))) elif 6 <= m and m <= 30: print(int(m + 50)) elif 35 <= m and m <= 70: print(int((m - 30) // 5 + 80)) else: print(89)
83c59298e2b2b632735b2ebabac5ad3df1564e4e
PeterTeng/learn-nlp
/text_and_words/search_text.py
578
3.53125
4
import nltk # Need to download books data with nltk.download() from nltk.book import * # # Search text # ------------------------------ # Concordance: search text with words around it print(text1.concordance("monstrous")) # Similar: search for all similar words print(text1.similar("monstrous")) # Common Contexts: se...
5920e665d2182d852a8eb581f053cb9845890207
Smarty18/Academy_Python
/Controllati_Lunedì22/PiuGrande.py
565
4.0625
4
#Funzione che restituisce il maggiore tra due numeri inseriti da tastiera def piuGrande (numero1,numero2): if numero1>numero2: print("Il maggiore è:",numero1) else : print("Il maggiore è:",numero2) a = input("Inserisci il primo valore: \n") b = input("inserisci il secondo valore: \n") piuGrand...
c5f9f6fc480612b98a16e68583cd34e69885623a
sushimustwrite/sushipaca
/lpthw36.py
3,046
3.890625
4
from sys import exit def start(): print """You face an aged wizard in front of a gate. What do you do?""" do = raw_input("> ") if "talk" in do or "speak" in do or "say" in do: password() elif "fight" in do or "duel" in do: fight() elif "flee" in do or "run" in do: dead...
a886863ce99fe0dea449da423e7bebab2fc5a5c2
alexandru-dinu/competitive-programming
/leetcode/reverse_vowels_of_a_string.py
528
3.65625
4
# https://leetcode.com/problems/reverse-vowels-of-a-string class Solution: def reverseVowels(self, s: str) -> str: def is_vowel(c): return c.lower() in {"a", "e", "i", "o", "u"} l = 0 r = len(s) - 1 s = list(s) while l < r: while l < r and not is_v...
46c9a2e05fb0341936560c3d566ba1fa1bb4427c
alexandru-dinu/competitive-programming
/leetcode/climbing_stairs.py
279
3.875
4
# https://leetcode.com/problems/climbing-stairs def fib(a, b): while True: yield a a, b = b, a + b class Solution: def climbStairs(self, n: int) -> int: from itertools import islice *_, rv = islice(fib(1, 1), n + 1) return rv
d32ee087bf3d78c6a64b676ba841df8023e4edde
alexandru-dinu/competitive-programming
/leetcode/implement_trie_prefix_tree.py
923
4.1875
4
# https://leetcode.com/problems/implement-trie-prefix-tree class Trie: def __init__(self): self.kids = {} # char -> Trie self.is_end = False def walk(self, word: str) -> Optional["Trie"]: t = self for c in word: if c not in t.kids: return None ...
b80d957086c307d017d19e164e46c2bff982977b
alexandru-dinu/competitive-programming
/leetcode/construct_the_rectangle.py
300
3.75
4
# https://leetcode.com/problems/construct-the-rectangle from math import sqrt class Solution: def constructRectangle(self, n: int) -> List[int]: d = int(sqrt(n)) while True: if n % d == 0: return [n // d, d] else: d -= 1
1a96bb6583e796020d702551486ead3819d2c062
clabene/functionAnalyzer
/function.py
5,903
3.640625
4
from abc import ABC, abstractmethod from math import log from utils import factorial class IFunction(ABC): def __eq__(self, other): return str(self) == str(other) @abstractmethod def optimize(self): pass @abstractmethod def derivative(self): pass @abstractmethod def getVariables(self): pa...
46a91ec9308962a564d5b7eb7dc5b91c557a97ce
anveerappam/FST-M1
/Python/Activities/Activity4.py
932
4.03125
4
user1 = input("Enter first username: ") user2 = input("Enter second username: ") i='yes' while(i=='yes'): user1input = input(user1+" choose rock/paper/scissors: ").lower() user2input = input(user2+" choose rock/paper/scissors: ").lower() if ((user1input not in {'rock','paper','scissors'}) or (user2input not...
a68f65d25f2f47244f1b058944ef8b9f536b1adc
anveerappam/FST-M1
/Python/Activities/Activity3.py
657
3.90625
4
user1 = input("Enter first username: ") user2 = input("Enter second username: ") user1input = input(user1+" choose rock/paper/scissors: ").lower() user2input = input(user2+" choose rock/paper/scissors: ").lower() if user1input==user2input: print("It's a tie!") elif user1input == 'rock': if user2input == 'paper'...
f82259830ce7100a872ef5c457dc75d9e6492b1c
chrisb87/advent_of_code_2016
/day3/day3.py
993
3.734375
4
import re import os p = re.compile("\s*(\d+)\s+(\d+)\s+(\d+)") def solve_part_1(): input_file = os.path.join(os.path.dirname(__file__), 'input.txt') valid = 0 for line in open(input_file): m = p.match(line) sides = sorted((int(m.group(1)), int(m.group(2)), int(m.group(3)))) if (sides[0] + sides[1]) > sides...
34ba89dd427c8a266ffbcdea36ed8d2ba1c23ce7
FraPar/OC-4-chest-tournament-app
/lib/models/models.py
1,693
3.71875
4
from datetime import datetime class Tournament: """Représente un tournoi commencé par l'utilisateur.""" def __init__(self, title, content=None, tournament=None, players=[]): self.updated_datetime = None self.title = title self.content = content self.created_datetime = datetime...