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
61a81ff981fb238b5d229d8b745c1358b0c2a235
QinmengLUAN/Daily_Python_Coding
/wk4_countNegatives_v2.py
817
4.0625
4
""" Leetcode 1351. Count Negative Numbers in a Sorted Matrix Given a m * n matrix grid which is sorted in non-increasing order both row-wise and column-wise. Return the number of negative numbers in grid. Example 1: Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]] Output: 8 Explanation: There are 8 ...
a91a248809499f3999656f0950e072078578bdc6
QinmengLUAN/Daily_Python_Coding
/wk9_Queue_openLock.py
2,647
3.828125
4
""" 752. Open the Lock Medium: Stack, Breadth-first Search (BFS), Solution from web You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '0' to be '9'. E...
4cdf2630d9549af9d2f9d31d95e0177b60334800
QinmengLUAN/Daily_Python_Coding
/LC395_longestSubstring_String.py
1,138
3.9375
4
""" 395. Longest Substring with At Least K Repeating Characters Medium: String Recursion Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times. Example 1: Input: s = "aaabb", k = 3 Output: 3 The longest substrin...
7e4c89bc3812a0bf3707b3de2183ca661b693f3d
QinmengLUAN/Daily_Python_Coding
/LC207_canFinish_Graph.py
2,214
4.1875
4
""" 207. Course Schedule Medium: Graph There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prere...
ae97ae778a111e521e39a297fc5cf53ddfc2cc45
QinmengLUAN/Daily_Python_Coding
/LC328_oddEvenList_LinkedList.py
1,026
3.984375
4
""" 328. Odd Even Linked List Medium: Linked List Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it in place. The program should run in O(1) space complexity and O(nodes) ti...
38d5b19a55b149ea276c1409f6349728a3c1cbb0
QinmengLUAN/Daily_Python_Coding
/DailyProblem10_check_Array.py
1,744
3.828125
4
""" Hi, here's your problem today. This problem was recently asked by Microsoft: Leetcode 665 You are given an array of integers in an arbitrary order. Return whether or not it is possible to make the array non-decreasing by modifying at most 1 element to any value. We define an array is non-decreasing if array[i] <= ...
5a03c623822c3a5b80f2dfacea7823be91ba2a4a
QinmengLUAN/Daily_Python_Coding
/wk11_array_findUnsortedSubarray_LC581.py
1,908
3.9375
4
""" 581. Shortest Unsorted Continuous Subarray Easy: Array, time complexity O(n) Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. You need to find the shortest such subarray and output ...
f27497e9a8acc603807d738e36b3937ad47f1b77
NkStevo/daily-programmer
/challenge-003/intermediate/substitution_cipher.py
1,260
4.125
4
import json def main(): with open('ciphertext.json') as json_file: ciphertext = json.load(json_file) print("----Substitution Cipher Program----") choice = input("Input 1 to encode text and 2 to decode text:\n") if choice == '1': text = input("Input the text you would l...
ffb1b016686a29890ee7da1ca0fa420c3490de97
shane-thurston/Year11SDD
/cake_menu.py
808
4
4
from cake import Cake cakes = [] while True: print("Cake Menu") print("1: Add Cake") print("2: View Cake") print("3: Eat cake") cmd = int(input("> ")) if cmd == 1: cakeType = input("Cake type: ") cakeSlices = int(input("Cake slices: ")) cakes.append(Cake(cakeType, cakeSlices)) if cmd == 2: ...
45743ceb60a4febb60731fda3c5b769387d80374
olya-bo/A_level
/Lesson6/Classwork/student_group.py
1,370
3.921875
4
'''Vvod studentov''' # student_group = {} # for _ in range(int(input('how many students are there in the group? '))): # student = input('Put name student ') # course = input('what courses does the student go to? ').split() # student_group[student] = course student_group = {'Kolya':['Python'], ...
ae762e79d2e7da8c7d7299ee363c43fb076bf186
olya-bo/A_level
/Practice/file_test.py
427
3.578125
4
with open('test.txt', 'r') as text: for line in text: ans = line.rstrip().split(';') number_sum = [int(i) for i in ans[0].split()] whole_part, remainder_division = int(ans[1].split()[0]), int(ans[1].split()[1]) if sum(number_sum) // len(number_sum) == whole_part and sum(number_sum) %...
67214b9d612a60f1abb222b8b1ba203d941dc2fc
karisk/Text-Adventure
/adventure.py
5,617
4.09375
4
start = ''' You work at Trump Co. ''' print(start) print("Type 'Male' or 'Female'") user_input = input() if user_input == "Male": print("You're a new employee, and you just received a pay raise!") # finished the story by writing what happens print("Do you take your girlfriend out for din...
9b1e666e56cbff6be911328f9fbcf414e263068e
EpicSte/devopsEG
/temp.py
351
4
4
#####Nicolas###### #!/usr/bin/env python3 # programme temperature.py #super steven on est la !!!!ouioui try: temp=int(input("Quelle température fait-il ? ")) except ValueError: print("la valeur entrée n'est pas numerique") else: if int(temp)> 18 : print("Il fait beau !") else: print("I...
26a50414c49120cee423e5fd4721d137bbe2a107
mfatih000/GlobalAIHubPythonCourse
/Final Project/Final_Project.py
3,098
3.890625
4
#KnowLedge Competition questions={ "q1" : "Which is the most crowded country in the world?", "q2" : "What is the name of the first computer?", "q3" : "Who is the 2nd place in 2010 eurovision?", "q4" : "Who is the lead role of Downfall movie?", "q5" : "In which year did w...
f07d71052664fea719e65ceeaa1d39a12346cf03
guutama/DeepLearning-Class-2020
/exercise1/multiLayer.py
3,860
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 27 10:16:14 2020 @author: gutama """ #%% #used librariies and packages import numpy as np import matplotlib.pyplot as plt from activations import Activations from sklearn.datasets import make_moons #%% #%% #Global variables X,y = make_moon...
d4ddcc43d0be4f395d7c5e42aeddf953d526c919
mattlynley/Metarating
/pythonpractice/cowsandbulls.py
469
3.546875
4
import random def cowsandbulls(): num = str(random.randint(1,9999)) cows = 0 bulls = 0 while True: nums = raw_input("Enter a number: ") cows = 0 bulls = 0 j = 0 if nums == num: print("Right number") break for i in nums: print(i) if i in num: cows += 1 print(cows) if i == num[j...
7626d830bf28dddc0b21988f29c84e83451c54da
ksamokhin/python
/Lesson1/task2.py
347
3.9375
4
time = int(input('Введите время в секундах (не более 86400): ')) if time <= 86400: sec = time % 60 time = int(time / 60) min = time % 60 time = int(time / 60) print ('Получилось %.2d:%.2d:%.2d' % (time, min, sec)) else: print('Вы ввели слишком большое число')
2aa4e7dd1be96eb6c188dc0f837cc19f47ad7592
ksamokhin/python
/Lesson1/task6.py
355
3.578125
4
a = int(input('Сколько км пробежит спортсмен в первый день? ')) b = int(input('Сколько км должен пробегать спортсмен в день? ')) day = 1 while b > a: a = a * 1.1 day += 1 print('На %d-й день спортсмен пробежит не менее %d км.' % (day,b))
479ad0bb60c6a42b39da1c8934aa939d9f7d44f5
ksamokhin/python
/Lesson2/task3_dict.py
731
3.78125
4
i = 1 while i: mon = input('Введите месяц в виде целого числа от 1 до 12: ') if (mon.isdigit()): mon = int(mon) if (mon > 0 and mon < 13): i = 0 mon_dict = {1: ('январь', 'зима'), 2: ('февраль', 'зима'), 3: ('март', 'весна'), 4: ('апрель', 'весна'), 5: ('май', 'весна'), ...
f9d9bc2b24f2600e79157415f7d5a55cef3418e4
ksamokhin/python
/Lesson4/task6.py
621
3.640625
4
from itertools import count from itertools import cycle def iterator1(start): stop = 0 list = [] for el in count(start): list.append(el) stop += 1 if stop > 10: break return list def iterator2(str): stop = 0 list = [] for el in cycle(str): list...
256397f3e77cb2b23f30e98fbb8df11b89b755c1
gstrugala/hp-tests
/vaplac/_plot.py
6,823
4.0625
4
""" This module implements the plot function, to easily produce formatted subplots from Quantity objects. """ import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates import warnings def plot(*args, time='min', step=60, interval=slice(0, None), sharex='col', legend=True, lf=True,...
6d40ba8fc00665c2a167eb149a0220e86759d054
Lukasavicus/MachineLearning_Library
/UFSCar_ML_Class/Python/KNN/visualizarDados.py
1,612
3.671875
4
import matplotlib.pyplot as plt #function visualizarDados(X, Y) def visualizarDados(X, Y): """ VIZUALIZARDADOS Plota as amostras X de acordo com as classe em Y em uma nova figura VIZUALIZARDADOS(X,Y) plota os exemplos positivos como sinais '+' e os os exemplos negativos como sinais 'o'. Assume-se que X eh uma ma...
505816e71a2df217a36b6dc74ae814e40208b26d
zszinegh/PyConvert
/pyconvert/conversions.py
1,068
4.375
4
"""A module to do various unit conversions. This module's functions convert various units of measurement. All functions expect a 'float' as an argument and return a 'float'. 'validate_input()' can be used before running any function to convert the input to a 'float'. """ def validate_input(incoming): """Conve...
9417e58d7fd7321aec4373925588d5aab732da05
mattzegreat8/conditionals
/Problem2.py
351
4
4
a1= int(raw_input("Please give me a number" '>')) a2= int(raw_input("Please give me another number" '>')) a3= int(raw_input("Please give me one more number" '>')) if( a1< a2< a3): print("Up and Rising") if( a1> a2> a3): print("Falling Down") if( a1< a2 > a3): print("Over the Mountain") if( a1> a2 < a3): ...
4e05c575b41e8126f8dbf9999b4a6e9a48815eef
NourAlaaeldin/Python-projects
/2D Lists.py
489
4
4
number_grid = [ [1,2,3], [4,5,6], [7,8,9], [0] ] #accessing first element in first list print(number_grid[0][0]) #accessing first element in second list print(number_grid[1][0]) #accessing first element in third list print(number_grid[2][0]) #accessing first element in fourth list print(n...
511fa98995d7f8eea254224478abe2fb447687b1
albul-k/leetcode
/src/medium/longest_substring_without_repeating_characters.py
2,337
3.6875
4
""" Url: https://leetcode.com/problems/longest-substring-without-repeating-characters/ Author: Konstantin Albul Given a string s, find the length of the longest substring without repeating characters. Constraints: * 0 <= s.length <= 5 * 104 * s consists of English letters, digits, symbols and spaces. """ # pylint: ...
050ac83df1e5b57fa4b5a898a902f98aada7f2f1
albul-k/leetcode
/src/medium/perfect_squares.py
1,420
3.75
4
""" Url: https://leetcode.com/problems/perfect-squares/ Author: Konstantin Albul Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, an...
61c0658f4299a3175b50d3d2c680ad8ea52d2d4c
cadbane/python-dojo
/tricks/iterating.py
279
4.1875
4
# iterating over list index and value pairs a = ['Lorem', 'ipsum', 'dorem', 'kolorem'] for i, x in enumerate(a): print(f'{i}: {x}') # iterating over dictionary b = {'apple': 3, 'banana': 7, 'orange': 0} for f, q in b.items(): # iteritems() for python2 print(f'{f}: {q}')
a9165cb87c5c537d213f3c6853d2b47542bd8c9e
isaiah1782-cmis/isaiah1782-cmis-cs2
/happy.py
382
3.921875
4
print "Type 'Yes' for yes and 'No' for no" def clapYourHands(): print "Clap Clap" def stompYourFeet(): print "Stomp Stomp" def main(): youreHappy = raw_input("Are you happy?: ") == "Yes" youKnowIt = raw_input("Do you know that you are happy?: ") == "Yes" if youreHappy and youKnowIt: clapYou...
3b2da44de01385682a646ca0cc1208933a50771a
isaiah1782-cmis/isaiah1782-cmis-cs2
/test2.py
411
3.984375
4
a = int(raw_input("Starting number: ")) b = int(raw_input("Ending number: ")) def countdown(start, stop): if start == stop or start >= stop: print 'Blastoff!' else: print start countdown(start+1, stop) def countup(start, stop): if start == stop: print 'Blastoff!' else:...
82be926a6549078edf9b27ea2e56c0993d5e6b3a
isaiah1782-cmis/isaiah1782-cmis-cs2
/Assignment_Guessing_Game.py
950
4.25
4
import math import random Minimum_Number = int(raw_input("What is the minimum number? ")) Maximum_Number = int(raw_input("What is the maximum number? ")) print "I'm thinking of a number from " + str(Minimum_Number) + " to " + str(Maximum_Number) + "." Guess = str(raw_input("What do you think it is?: ")) def Correc...
33859baa7408e9b1cdf23b41d016d75258d64e7f
Enock8574/Calculador_IMC
/main.py
738
3.890625
4
print("----------#Enoc Carrera ©2021#---------") print("Este programa le ayudara a conocer su indice de masa corporal") #Variables para recoger los datos del usuario altura = float(input("Ingrese su estatura en metros. Ejemplo(1.78) \n")) peso = float(input("Ingrese su peso en kg(Kilogramos) \n")) #Variable que re...
27d4d41ca785afa105f59b8420637948d29ea9b0
kammariprasannalaxmi02/sdet
/python/Activity14.py
538
4.3125
4
#Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. fibo_num = input("Enter the number to get Fibonnaci numbers: ") def fibonnaci_Num(fib_num): n1 = 0 n2 = 1 i = 1 n = int(fib_num) - 2 fiba_list = [0,1] if(int(fib_num)==1): pri...
77069ee92fcb26ff76619058b379d05e8c177153
kammariprasannalaxmi02/sdet
/python/Activity12.py
264
4.21875
4
#Write a recursive function to calculate the sum of numbers from 0 to 10 def calculate(i): if i <= 1: return i else: return i + calculate(i-1) num = int(input("Enter a number: ")) print("The sum of numbers: ", calculate(num))
d6ab63644aa8875f4e893589cc0d9b05132d19fb
wolflop/leetcode
/三数之和等于0.py
797
3.5625
4
# -*- coding:utf-8 -*- class solution: def __init__(self, nums): self.nums = nums def threeSum(self): output=[] ''' 算法复杂度最高,益理解。 依次循环,从而选出不同的值,但是相加等于0的。 ''' for countA in range(len(self.nums)): # print(countA) for countB in range(c...
e3571cd55e08cf95b40970ad463d955602a8ed1f
dart-neitro/py_checkio_org
/islands/scientific_expedition/double_substring.py
2,220
3.984375
4
def search_double_string_using_brute_force(original_text): result = 0 original_text = original_text or '' if len(original_text) > 0: searching_substring = original_text[:1] text_for_searching = original_text[1:] while len(searching_substring) <= len(text_for_searching): ...
02ce14ff4b5d2cf8f77337a51703a83b3dafaece
raydive/sandbox
/fizzbuzz.py
388
3.828125
4
#!/usr/bin/env python # encoding: utf-8 import sys def FizzBuzz(number=100): for x, x3, x5 in ((i , i%3, i%5) for i in range(1, number)): if x3 == 0 and x5 == 0: print('FizzBuzz') elif x3 == 0: print('Fizz') elif x5 == 0: print('Buzz') else: print(x) if __name__ == '__main__': number = 100 if...
0c35a70e11f438aedbfd4dae543ca8dd52322ce6
brunocvs7/reputation_score
/src/data_acquisition.py
779
4.03125
4
# Libs import twint # Functions def get_tweets(query, since, until): """Function to get tweets using a query (string with terms) and two dates, specifying a range to search . Parameters: query (string): query with terms to be used in the search. since (string): string with the initial date. ...
539aef2fb175525375fc23f1e133c71076aa3a1c
neal-o-r/aoc2019
/day12.py
1,286
3.78125
4
from typing import List, Tuple from operator import add from collections import namedtuple import re class Point(namedtuple('Point', ['x', 'y', 'z', 'vx', 'vy', 'vz'])): pass Position = Tuple[int, int, int] Velocity = Tuple[int, int, int] Points = List[Point] def parse_input(txt: list) -> Points: parse_pos...
9d69a49343a7b08062f4aaeb099d8aacc7842a9f
dorukismen/Number-Theory-and-Cryptography
/Diophantine-Equations.py
283
3.546875
4
def diophantine(a, b, c): assert c % gcd(a, b) == 0 q, r = divmod(a,b) #divmod operation to compute the quotient and remainder at the same time if r == 0: return( [0,c/b] ) else: sol = diophantine( b, r, c ) u = sol[0] v = sol[1] return( [ v, u - q*v ] )
07005384913f346397cd627c77eb36db04ef1633
suren17/BootCamp-python-
/Exercises/week_1/Ex_1(SOL).py
524
4.09375
4
def multiply(num_1, num_2): return num_1 * num_2 def divide(num_1, num_2): return num_1 / num_2 def remainder(num_1, num_2): return num_1 % num_2 def power(num_1, num_2): return num_1 ** num_2 ######################### # Challenges # ######################### def divisible_by_two(num...
9e2df6f1f7e90bf65fef3e5af70dcda5767c07b3
mumbihere/general
/Info Viz'17/web_scrapper2.py
1,379
3.5625
4
import sys import urllib.request from bs4 import BeautifulSoup import re import csv #import wikipedia def preprocess_page(content): ''' Remove extra spaces between HTML tags. ''' content = ''.join([line.strip() for line in content.split('\n')]) return content def extract_content(url,file): print('....
26343c2e7d1a57463b71faee58c204afd426b5b8
noemiko/design_patterns
/factory/game_factory.py
2,774
4.75
5
# Abstract Factory # The Abstract Factory design pattern is a generalization of Factory Method. Basically, # an Abstract Factory is a (logical) group of Factory Methods, where each Factory # Method is responsible for generating a different kind of object # Frog game class Frog: def __init__(self, name): ...
96a7d9c4f9b0c4220ae241de57dc8110bd24ad78
miftaunnoor/Hangman
/Stage_6.py
1,054
3.78125
4
import random print("H A N G M A N") print() types= ['python', 'java', 'kotlin', 'javascript'] r= random.choice(types) guess = len(r)*["-"] lives= 8 correct_letters = [] while lives!=0: print("".join(guess)) letter= input("Input a letter: ") idx = 0 if (letter in correct_letters): if lives...
3323954020835d19b80de8d97e36b61301e88f7c
JavierAlbert/Reinforcement_Learning
/02_2Dmaze/maze_env.py
4,631
4.40625
4
""" This is a simple maze example for reinforcement learning There is an agent on a 2D maze that needs to get to the finish square Blue rectangle: agent Black rectangles: penalty states (reward = -1] Yellow rectangle: Finish [reward = 1] All other rectangles: nothing [reward = 0] """ import numpy as np impor...
7acaab3f75bf6cbc6dfa7c4343e4d7f96072d5f0
ASK1995/Leetcode-old
/984. String Without AAA or BBB.py
417
3.53125
4
class Solution: def strWithout3a3b(self, A: int, B: int) -> str: if(A == 0): return "b" * B elif(B == 0): return "a" * A elif(A == B): return "ab" + self.strWithout3a3b(A-1, B-1) elif(A > B): return "aab" + self.strWithout3a3b(A-2, B-1)...
66bc3bdcdafcadbea18b8f6a0ae1e2917b85117b
reddhu/beauty_more
/my_first_project/my_first_project/utils/StringGenerator.py
323
3.515625
4
import random import string def randomString(stringLength=4): letters = string.ascii_letters + string.digits return ''.join(random.choice(letters) for i in range(stringLength)) def randomNumber(stringLength=6): letters = string.digits return ''.join(random.choice(letters) for i in range(stringLength)...
f782955b09f76cfba68f689decdba1bc9cd6f149
devanrus/Python_Katas
/multiplicatio_tables.py
187
3.625
4
def multiplication_table(row,col): resl = [[] for i in range(row)] index = 0 for r in range(1,row+1): for c in range(1,col+1): resl[index].append(r*c) index+=1 return resl
a92ba4ac7248a4d44f9e871fec551700ef66f52c
ageldama/loan-mower-man
/misc/check-aggrs/csv-select-cols.py
732
3.71875
4
import sys import csv def sanitize_as_int(s): try: return int(s.replace(",", "")) except: return s def select_cols(filename, column_numbers): with open(filename, 'r') as f: reader = csv.reader(f) writer = csv.writer(sys.stdout) for row in reader: new_row...
e45bdd05387bba20fb1ae75e49aa5ead73923d07
ltimaginea/Python_org
/Turtle_Graphics/treeLearn.py
919
3.515625
4
from turtle import * from math import * from random import * def tree(n,l): pd() t=cos(radians(heading()+45))/8+0.25 pencolor(t,t,t) pensize(n/3) forward(l) if(n>0): b=random()*15+10 c=random()*15+10 d=l*(random()*0.25+0.7) right(b) tree(n-1,d) left(b+c) tree(n-1,d) right(c) else: right(90) n...
90d89e6c2d09a4eee77a922ded250b6df696fee8
darrylmendonez/python3-tutorial-by-thenetninja
/07-string-format.py
194
3.796875
4
num1 = 3.1425467389 num2 = 10.2903948 # FORMAT METHOD # print('num 1 is {0:.3f} and num 2 is {1:.3f}'.format(num1, num2)) # USING F-STRINGS print(f'num 1 is {num1:.3f} and num2 is {num2:.3f}')
a958812a96a07f6ab5b2ca55a05d681a205caba1
sophialuo/TypingTest
/typingtest.py
3,969
4.25
4
import time import random import math from difflib import SequenceMatcher class TypingTest(): def __init__(self): pass def format_file(self, filename, max_len, min_len): ''' Given a file of words separated by a line, return a list of all the words that ...
0f0052c16f4b3f27ea2c2de9146f940235a90236
NeonMiami271/Work_JINR
/Python/summa.py
190
3.84375
4
n=int(input("До какого числа ищем сумму? ")) k = 0 sum = 0 while k<=n: sum = sum + k k = k + 1 print('Сумма от 1 до '+str(n)+" равна "+str(sum))
74eaf70857725b5385572553acadacfa15dbab32
NeonMiami271/Work_JINR
/Python/treug.py
511
3.96875
4
# Треугольник тип import sys a = int(input("a = ")) b = int(input("b = ")) c = int(input("c = ")) if (a + b < c) or (a + c < b) or (c+ b < a): print("Такого треугольника не сущствует") sys.exit(0) if (a == b == c): print("Треугольник равносторонний") elif (a != b) and (a != c) and (c != b): print("Тр...
5f20f80abf87e9a9b32d0f5b32da197e75b18655
NeonMiami271/Work_JINR
/Python/Kvadrat_yravn.py
551
4.125
4
#Решение квадратного уравнения import math print("Решим квадратное уравнение") a = float(input("а = ")) b = float(input("b = ")) c = float(input("c = ")) D = b**2 - (4*a*c) if D < 0: print("Корней нет") elif D == 0: x = -b/(2*a) print("Корень равен:" + str(x)) elif D > 0: x1 = (-b - math.sqrt(D))...
801c1e9011890e439cbb00fefd5531de750038e2
Wayodeni/to_new_radix_from_any
/dicttest.py
389
3.640625
4
def get_val_key (dict, val): for k, v in dict.items(): if v == val: return k alphabet = { 10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F', 16: 'G', 17: 'H', 18: 'I', 19: 'J', 20: 'K', 21: 'L', 22: 'M', 23: 'N', 24: 'O', 25: 'P', 21: 'Q', 27: 'R', 28: 'S', 29: 'T', 30: 'U', 31: 'V', 32: ...
8e9e67c4d5e05a94ab30dd16039675614ff6feff
SabAlej/codigo-backend-pnp
/Semana2/08-ejercicios-con-funciones.py
1,064
3.734375
4
#Cree una función para que el usuario ingrese su nombre y edad, con esos datos me indique si tengo que votar obligatoriamente, si tengo mas de 65 que me indique que no tengo obligacion de votar, si es menor de 18, que me diga que no tengo que votar. # def puedoVotar(nombre, edad): # if(edad >= 65): # print(f"{n...
73f1cb427713b19e4a8f5498796f260ee30003ec
SabAlej/codigo-backend-pnp
/Semana2/15-encapsulamiento.py
1,161
3.6875
4
class Vehiculo: def __init__(self, largo, ancho, color, motor, enMarcha = False): self.largo = largo #publica self.ancho = ancho self.__motor = motor #privada, encapsulado self.color = color self.enMarcha = enMarcha def arrancar(self, arrancar): self.enMarcha = arrancar if(self.enMarcha...
38ee98be99dbb8580a37379e9fcad9cc2d79e84d
phpdavid/python-study
/home-study/study-code/python-code/four/three.py
295
3.703125
4
# a = 1 # b = 2 # c = 3 # a, b, c = 1, 2, 3 # 简洁的写法 # d = 1, 2, 3 # 元祖类型通 d = [1,2,3] # print(type(d)) # a, b, c = d # 序列解包,这里要注意元素的数量要相等 # print(a, b, c) def add_test(a, b): d = a + b return d e = add_test(b=4, a=6) print(e)
bd0da41748d0ea72414b52566e37ff4b2e053215
phpdavid/python-study
/home-study/study-code/python-code/three/loop.py
2,641
3.921875
4
""" 循环 """ counter = 0 # list 列表类型 condition_list = ['apple_list', 'banana_list', 'orange_list', 'grape_list'] # tuple 元祖类型 condition_tuple = ('apple_tuple', 'banana_tuple', 'orange_tuple', 'grape_tuple') # set 集合类型 condition_set = {'apple_set', 'apple_set', 'orange_set', 'grape_set'} # dict 字典类型 condition_dict = {'a'...
506f9d55e774a6adfa91f69d74fc114cf183a6dc
phpdavid/python-study
/home-study/study-code/python-code/ten/three.py
248
3.796875
4
# 查询出现频率最高的5个单词 from collections import Counter import re txt = open('test').read() # 读取文件 res = re.split('\W+', txt) # 正则分割 counter = Counter(res) # counter计数 print(counter.most_common(5)) # 排序
cc59404f7b10f79ddbf44dc265083c99c32ad4be
phpdavid/python-study
/home-study/study-code/python-code/ten/one.py
760
4.625
5
# 使用类枚举的方式(python中没有枚举类型)为元祖每个元素命名,提高程序可读性 # 在python中没有真正的枚举类型,我们可以定义一些常量代替 Student = ('david', 19, 'male') # # 通过下标读取值,可读性很差,时间久了,不知道是什么了 # # name # Student[0] # # age # Student[1] # # gender # Student[2] # # # 定义常量 # # NAME = 0 # # AGE = 1 # # GENDER = 2 # NAME, AGE, GENDER = range(3) # Student[NAME] # Student[AGE] ...
6233b788230e85b8290c522b3d9517a311dd107d
phpdavid/python-study
/home-study/study-code/python-code/three/t/firstf.py
271
3.53125
4
__all__ = ['a', 'c'] # 控制*号的变量范围 a = 1 b = 2 c = 3 # print("hello python") # 不强制使用;做结尾 # 不使用{},使用缩进 ''' 多行注释 ''' # moon = True # # if moon: # print('left') # else: # print('right') # print('out if print')
b9a918552be72e08a6ffb55acbc7aeb455004b37
SAGARDX7/python-dev
/python_ifelse_greaterof3.py
156
3.9375
4
a = 1 b = 2 c = 3 if a>b and a>c: print ("a is greater") if b>a and b>c: print ("b is greater") if c>a and c>b: print ("c is greater")
4be0e26da1dfe01c74db952bcd64b4debe850b06
IvannikovG/Python-cheatsheet
/adv_str_formatting_cheatcheet.py
1,976
3.84375
4
import datetime person = {'name': 'Lev', 'age': 234} sentence1 = 'Hi, my name is {1} and i am {0} years old'.format( person['name'], person['age']) sentence = 'Hi, my name is {} and i am {} years old'.format( person['name'], person['age']) # 0 and 1 are numbers of values that are passed into the format func. ...
f40bdb00a3d14d85c86ed8ded03f655a1895043e
IvannikovG/Python-cheatsheet
/Scrapes/scrape.py
705
3.8125
4
# We want to grab all the info from our webpage # This is web-scraping # Some libraries are gonna be used from bs4 import BeautifulSoup import requests with open('simple.html') as html_file: soup = BeautifulSoup(html_file, 'lxml') # use ___ as file -> do smth # make lxml type of file from the html_file, which is #...
2569bb9c506a8f61c5f722be1d82cac567c85d22
IvannikovG/Python-cheatsheet
/python/functions.py
895
3.90625
4
def hello_func1(): #pass is used to leave it for now pass def hello_func(greeting, name="You"): return f'{greeting} {name}' print(hello_func('hey')) courses = ['Math', 'Art'] info = {'name': 'Jonh', 'age': 22} #positional and keyweord args def student_info(*args, **kwargs): print(args) print(kwargs) #returns a t...
c17e2a261ed5184391f8872c3035bb58cae935ea
fdoperezi/Transformer-Time-Series-Forecasting
/Preprocessing.py
3,356
3.515625
4
import pandas as pd import time import numpy as np import datetime from icecream import ic # the original features of the input data """ 0 - sensor_id 1 - timestamp 2 - temperature 3 - humidity 4 - ohms 5 - moisture 6 - weather_humidity 7 - weather_pressure 8 - weather_temp_dew 9 - weather_temp_dry 10 - weather_wind_d...
95a9f4e25127241ba07696dacca17dfe3740c930
vladflore/py4e
/course3/week6/extract-data-json.py
1,396
4.40625
4
# In this assignment you will write a Python program somewhat similar to http://www.py4e.com/code3/json2.py. The # program will prompt for a URL, read the JSON data from that URL using urllib and then parse and extract the comment # counts from the JSON data, compute the sum of the numbers in the file and enter the sum...
111066b18fbe2331e873dd1fde941c1739107c0d
Alexvi011/CYPHugoPV
/libro/problemas_resueltos/capitulo1/problema1_3.py
325
3.578125
4
NOM=str(input("Ingresa el nombre del dinosaurio:")) PES=int(input("Ingresa el peso del dinosaurio:")) LON=int(input("Ingresa la longitud del dinosaurio:")) PESKIL= PES*1000 LONMET= LON*0.3047 print(f"El nombre del dinosaurio es: {NOM}, su peso en kilogramos es: {PESKIL}, su longitud en metros es: {LONMET...
b2a22322bb57d4d6ec260054458f465fd9787833
Alexvi011/CYPHugoPV
/Funciones.py
3,929
4.25
4
#Una funcion es una unidad de codigo reutilizable, ademas de ser un mecanismo de organizar codigo #Una funcion puede tomar de entrada cualquier cantidad de parametros(de cualquier tipo) de entrada y retorna un solo valor,de cualquier tipo de dato #Puedes hacer dos cosas con una funcion 1.-Definirla, 2.-Llamarla def su...
e4d6b9008014df5878a73cc64df6ec694b065ed4
Alexvi011/CYPHugoPV
/libro/ejemplos/capitulo3/ejemplo3_3.py
205
3.890625
4
CUECER=0 N=int(input("Ingresa un numero: ")) for I in range(0,N,1): NUM=int(input("Ingresa un numero entero:")) if NUM==0: CUECER+=1 print("El numero de ceros capturados fue:",CUECER)
3bbe38417d8e9910f3b9872aa743e716c92fb28f
Alexvi011/CYPHugoPV
/libro/problemas_resueltos/capitulo2/problema2_10.py
607
3.875
4
A= int(input("Introduce tu primer numero: ")) B= int(input("Introduce tu segundo numero:")) C= int(input("Introduce tu tercer numero: ")) if A>B: if A>C: print(f"A es el mayor ") elif A==C: pritn(f"A y C son los mayores") else: print(f"C es el mayor") elif A==B: if A>C: p...
cd66c4db1d5e4ba6bc5b41fc442a73f3812dbe55
Alexvi011/CYPHugoPV
/Funcion_print.py
818
4.09375
4
# print tiene 4 formas de uso """ 1.- Con comas 2.- Consigno '+' 3.- Con la funcion format() 4.- Es con una variante de format() """ # Con comas,concatenar agregando # Un espacio y haciendo casting de tipo edad = 10 nombre= "Alex" estatura = 1.60 print(edad , estatura , nombre) # con '+' hace lo mismo pero no # Realiza...
392d206f151bd2eca9267f35c9df734d9237e7c2
Alexvi011/CYPHugoPV
/libro/problemas_resueltos/capitulo2/problema2_5.py
200
4.03125
4
NUM=int(input("Ingresa un numero y te dire si es positivo, negativo o nulo: ")) if NUM>0: print("Positivo") elif NUM==0: print("Nulo") else: print("Negativo") print("Fin del programa")
1604cc1fd7149bea30ff44f5ec947a1aeac877a9
bokusunny/atcoder-archive
/atcoder.jp/abc106/abc106_c/Main.py
255
3.65625
4
S = input() K = int(input()) is_all_one = True for i, s in enumerate(S, 1): if s != '1': first_non_zero_index = i first_non_zero_str = s is_all_one = False break print(1 if is_all_one or K < first_non_zero_index else first_non_zero_str)
5ab1fcdc6fc799ab640a9e3fe55d260b123acac1
LanLi-PR/Thurs-C-A6
/all temps/chen_temp.py
8,177
3.59375
4
import networkx as nx class Navigation: def __init__(self): self.G = nx.DiGraph() def add_inter(self, intersection: list): """ :param intersection: street intersection :return: """ self.G.add_node(intersection) def add_building(self, building: str, street...
597416454b410742bc4ac70d165389cd73093c56
PKpacheco/exec_roman_numerals
/main.py
826
4.1875
4
from int_roman import * from roman_int import * def decision_method(number_choice): if (number_choice == 1): N = int(input("Input integer number (between 1 and 3000: ")) if (N == 0): print ("Please enter a number greater than 0") elif (N > 3000): print ("Please enter...
2bbea569ba2cc5cd34585826b5775688f42a8936
marcgpuig/py_ai_learn
/py_ai_learn/Game.py
3,393
3.90625
4
''' Main Game file ''' class Board(object): """docstring for Board""" def __init__(self): self.board = [] self.game_over = False self.clear_board() def __str__(self): rows = [' ----------- \n', '| {} | {} | {} |\n', '|---+---+---|\n'] order = [0, 1, 2, 1, 2, 1, 0]...
d4507e05cb5752f82475ec4dcc32e1f52b644dd8
Helper2020/Huffman-Coding
/problem_3.py
7,529
3.9375
4
import sys from collections import deque class Node(object): def __init__(self, element=None, freq_value=0): self.element = element self.freq_value = freq_value self.left = None self.right = None def set_element(self, element): self.element = element ...
cc9e2315662516211a2cb3d3f8aefea8f66d470d
ErikSchierboom/exercism
/python/matching-brackets/matching_brackets.py
352
4.09375
4
DELIMITERS = {']': '[', ')': '(', '}': '{'} def is_paired(input_string): unmatched = [] for letter in input_string: if letter in DELIMITERS and (not unmatched or unmatched.pop() != DELIMITERS[letter]): return False if letter in DELIMITERS.values(): unmatched.append(le...
8a7dc6486fb172ff1000b58dd290530983a8547e
ErikSchierboom/exercism
/python/all-your-base/all_your_base.py
1,015
3.890625
4
from itertools import dropwhile def rebase(input_base, digits, output_base): if input_base < 2: raise ValueError("input base must be >= 2") if output_base < 2: raise ValueError("output base must be >= 2") if any(digit for digit in digits if digit < 0 or digit >= input_base): raise ...
3ff1e9bd519ddef4bb262596647a55fe049e038b
MajorGrinch/we_chall_assist
/asc.py
94
4.09375
4
seq = input("input the ascii sequence:") str = "" for num in seq: str += chr(num) print(str)
c1a97464602f7a33ae0f0042dbeb092bb02e4e02
krishislegend/EASD
/comp1.py
1,958
3.5
4
import sys # Function to return max sum such that # no two elements are adjacent def find_max_sum(arr): incl = arr[0] excl = 0 max_ele = arr[0] excl_arr = [] incl_arr = [] if incl>=0: incl_arr.append(incl) for i in arr[1:]: if max_ele < i: ...
73d1665bd582f792ff6da408a87d0cc69b36dc9c
bigyihsuan/International-Phonetic-Esoteric-Language
/src/parser.py
3,695
3.890625
4
from util import Token as T import lexer import os """ This file defines the code for the parser. """ class Parser: def getNextToken(self, code): return lexer.getNextToken(code) def mapLabels(self, lex, lab): """ Maps labels, functions, and loops to their locations within the lexeme ...
b5cc2371d667434e849ccff47e05fb42f5242b70
lawrence-ms/codewars
/rainfall.py
669
3.515625
4
# https://www.codewars.com/kata/56a32dd6e4f4748cc3000006 def get_num_list(town, strng): new_list = [] for line in strng.split("\n"): if line.split(":")[0] == town: for chunk in line.split(":")[1].split(): new_list.append(chunk.split(",")[0]) return [float(num) fo...
9f05463ef2f0bb2b64f98beb7cb2ae298f7c9312
lawrence-ms/codewars
/string_incrementer.py
567
3.546875
4
# https://www.codewars.com/kata/54a91a4883a7de5d7800009c def increment_string(strng): char_str, num_str = "", "" for i in range(len(strng), 0, -1): if strng[i-1].isnumeric() and char_str == "": num_str = strng[i-1] + num_str else: char_str = strng[i-1] + char_str num...
2ae5996fb4902037fb6f8985226e33941c6588be
lawrence-ms/codewars
/tribonacci_sequence.py
216
3.640625
4
# https://www.codewars.com/kata/556deca17c58da83c00002db def tribonacci(signature, n): trib_list = signature[:n] for i in range(3, n): trib_list.append(sum(trib_list[i-3:i])) return trib_list
6599ec766082781fa7c971d12c752b9c11cd6988
alindsharmasimply/Python_Practice
/third.py
248
3.875
4
a, b, c, d = input("enter a "), input("enter b "), input("Enter c "), input("Enter d") print "the smallest number is ", min(a,b,c,d) print "the largest number is ", max(a,b,c,d) print "the middle value is ", ((a+b+c+d)- max(a,b,c,d) - min(a,b,c,d))
2b5d351d2df862399e32ce28691d88749187db49
alindsharmasimply/Python_Practice
/eighth.py
841
3.90625
4
plate = raw_input("Enter your license plate number ") f = 0 i = 0 g = 0 plate = plate.upper() if len(plate) == 6: while i<3: if plate[i] >= 'A' and plate[i] <= 'Z': f = 1 else: f = 0 break i += 1 while i>=3 and i<6: if int(plate[i]) >= 0 and int(plate[i]) <=9: g = 1 else: g = 0 break i ...
48c68b71b75bb59d7b8f556f034a675a1bd47375
alindsharmasimply/Python_Practice
/fiftyFive.py
264
3.984375
4
def anagram(s1, s2): l1 = len(s1) character = {} for i in s1: character[i] = True for j in s2: if j not in character: f = 0 print "Not an anagram" else: f = 1 if f == 1: print "Strings are anagram" def main(): anagram("live", "evil") main()
36bfa4cd73198831dbaefa722d80ad830da0db63
alindsharmasimply/Python_Practice
/sixtyNinth.py
601
3.5625
4
from collections import OrderedDict import string letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] myList = range(1, 21) print list(myList) # Imp 1 myList2 = range(10, 201, 10) print list(map(str, myList2)) # Imp 2 myList3 = [1, 3, 3, 4, 5, 6, 6] print list(OrderedDict.fromkeys(myList3)) # Imp 3 d = {"...
f7f87810b50c50b2828e2c404763cdb3f44b08a0
alindsharmasimply/Python_Practice
/seventySecond.py
307
4.21875
4
def sumsum(): sum1 = 0 while True: try: a = input("Enter a valid number to get the sum ") if a == ' ': break sum1 = sum1 + a print sum1, "\n" except Exception: print "Enter a valid number only " sumsum()
dfe2667f330b05945524986d51b4549270cb08c9
alindsharmasimply/Python_Practice
/twentyThird.py
254
4.0625
4
def isInteger(a): f = 0 a = a.strip() for i in range(len(a)): if a[0:].isdigit() == True: b = 0 else: f = 1 if f==1: print "The string is not an integer" else: print "The string is an integer" def main(): isInteger(' 5sdf ') main()
ea7b796a5b2ca86dde73a03762da17be00dd339b
alindsharmasimply/Python_Practice
/fortySeven.py
482
3.578125
4
from Tkinter import * class myButtons(object): """docstring for myButtons""" def __init__(self, root1): frame = Frame(root1) frame.pack() self.printButton = Button(frame, text = "Click Here to print", command = self.display) self.printButton.pack() self.quitButton = Button(frame, text = "Click Here to...
2ad14afc019f483c2762aaaa33e46d766030624b
alindsharmasimply/Python_Practice
/nintyFifth.py
534
3.546875
4
def encode(l): index = 1 if len(l) == 0: return [] while index < len(l) and l[index] == l[index - 1]: index += 1 current = [l[index - 1], index] return current + encode(l[index:]) def decode(l): index = 1 if len(l) == 0: return [] current = [] for i in rang...
bbf3c0ef6754fd6df2404ca63558a56583eb7221
gyuwseong/Algorithm
/algorithm/longest_common_prefix.py
253
3.65625
4
def longestCommonPrefix(strs): if len(strs) == 0: return "" shortest = min(strs, key=len) for i, j in enumerate(shortest): for word in strs: if word[i] != j: return shortest[:i] return shortest
0d2cfed2923d28d2e76a8c551e638329d7d6fdf1
srthurman/sparkchallenge
/test.py
949
3.765625
4
import unittest import calculator class TestCalculator(unittest.TestCase): def test_simple_addition(self): self.assertEqual(calculator.calc("5 + 5"), 10) def test_simple_subtraction(self): self.assertEqual(calculator.calc("10 - 5"), 5) def test_simple_multiplication(self): self.assertEqual(calculator.calc("...
fe467433ee6a2413073a66eb97575d3c2314647f
zfhrp6/competitive-programming
/atcoder/abc021_b.py
162
3.671875
4
input() s=input().split() input() s=s+input().split() # print(s) # print(list(set(s))) if len(s)==len(list(set(s))): print('YES') else: print('NO')
a0ee40437026fb8d69bbd842f8d2be852385c30c
zfhrp6/competitive-programming
/codefes2016_c/d.py
397
3.703125
4
H, W = list(map(int, input().split())) down_col = {} for c in range(W): down_col[c] = 0 objet = [] for row in range(H): objet.append(list(input())) def cost3(): c = [] for _c in range(W): tmp = 0 for _h in range(H): objet[_h] def main(): if W>3: print(-1) ...