blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
85801d1e9640a10bc5c42e2644eac37ae3b9160d
osamaamin402/Python-programs
/add30.py
78
3.75
4
a=10 b=10 c=int(input("enter value ")) if (a+b+c)>30: print(a+b+c)
7f66cefd56983aab265183651e42231beca016cd
1cloud11/LearnPython
/lesson2/py_if_else/slide1.py
568
3.921875
4
user_age = int(input('Пожалуйста, укаэите свой возраст: ')) def employement(age): if age <= 6: return 'Человек в детском саду' elif 6 < age <= 17: return 'Человек учится в школе' elif 17 < age <= 24: return 'Человек учится в ВУЗе' elif 24 < age <= 60: return 'Человек раб...
0c522cc232b970d2a51d4477355144a7fabdbd02
RainingEveryday/cpy5python
/practical02/q02_triangle.py
686
4.5
4
#2 Validating triangles and computing perimeter: side1 = float(input("Please input the length of the first side of the shape you wish to ascertain as a triangle(units): ")) side2 = float(input("Please input the length of the second side of the shape you wish to ascertain as a triangle(units): ")) side3 = float(input("...
b525f78c6904c71d70a6357e78dae6722aa02670
Wuzhibin05/python-course
/Course/Section-1/day2/code/practice.py
1,757
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author:Bruce wu # Date: 2019/1/29 # 1、判断下列逻辑语句的True,False. print(1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F # 2、求出下列逻辑语句的值。 print(8 or 3 and 4 or 2 and 0 or 9 and 7) # 8 print(0 or 2 an...
c16b4eac75a83019f0d6f4bf2005f81c6a69a69c
akimi-yano/algorithm-practice
/lc/review_473.MatchsticksToSquare.py
1,827
3.6875
4
# 473. Matchsticks to Square # Medium # 1942 # 155 # Add to List # Share # You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any stick, but you can link them up, and each matchstick must b...
6e976dadaf60734135e1fcb72b71803aa51992c8
tsukasan3/Impractical_Python_Projects
/Chapter4/key_permutations.py
508
3.890625
4
"""暗号の列数を整数で受け取って、ありうる鍵の組み合わせをタプルとして返す。""" from itertools import permutations # 列数 COLS = 4 possible_keys = [n for n in range(-(COLS),COLS+1) if n != 0] keys = [] print(possible_keys) for key in permutations(possible_keys, 4): abs_key = set() for n in key: abs_key.add(abs(n)) if len(abs_key) == ...
e1c95dc00e61b0406c6011450e6345afcfa40c11
DeepBlueCUG/Leetcode-Practise
/078.py
1,076
3.859375
4
#尝试使用回溯法解决 class Solution: def subsets(self, nums: list) -> list: if len(nums) == 0: return [] else: temp = [] result = [] current_index = 0 self.__recall(nums, current_index, temp, result) return result # 开头单下划线约定该函数为内部使用 ...
c6e920e9cec0a5880944c8a081917c45b11670eb
rrodrigu3z/ai_search_examples
/priority_queue.py
651
3.78125
4
import heapq class PriorityQueue: def __init__(self, f=lambda x: x): self.f = f self.queue = [] def insert(self, item): weight = self.f(item) heapq.heappush(self.queue, (weight, item)) def items(self): return [item[1] for item in self.queue] def has_items(self): return len(self.queue...
b76c289eab9b9052233524c4123d2362aa2a7493
ksigWyatt/Fun_With_Python
/Random/Creating & Writing/CreateMP3Zip.py
1,749
3.59375
4
from pydub import AudioSegment import zipfile import os, glob #convert to mp3 #assuming the directory path is absolute - this will work # change this to fit your project directory = 'C:/Users/wyatt/Desktop/Wyatt/Python_Code/Git/Fun_With_Python/Audio' # Create an empty array of files in the zip filesInZi...
3a141e524e8b78b9478fd014a1808bdbd65a2316
mradu97/python-programmes
/enumerate_thread.py
499
3.515625
4
from threading import* import time def display(): print(current_thread().getName(),"started\n") time.sleep(3) print(current_thread().getName(),"ended\n") print("active threads\n",active_count()) t1=Thread(target=display,name="child thread\n") t2=Thread(target=display,name="chil2\n") t3=Thread(target=display...
f13952a18028991bb9418c684ce132424a5bbef4
Jess-Ferguson/httpscanner
/prepare-list.py
892
3.578125
4
#!/usr/bin/python3 # Script to take a hosts file and convert it to a format that the scanner script can use import sys import os def main(): if len(sys.argv) <= 1: print("Usage: %s [input file(s)]" % (sys.argv[0])) else: files = [file for file in sys.argv if file != sys.argv[0]] for filename in files: if ...
8fd8c4f41d0c23413da4fc088a84b814fff3908b
komtaki/atCoder
/contest_abc/141/b.py
251
3.6875
4
S = input() def solve(S): index = 1 for word in S: if index % 2 != 0 and word == 'L': return 'No' elif index % 2 == 0 and word == 'R': return 'No' index += 1 return 'Yes' print(solve())
a363a8a3b42d021b9ddb3efa1d07c70bef4b4eec
marwaw/intern_tasks
/task2.py
1,092
3.84375
4
def damage(spell): """ Function calculating damage :param str spell: string with spell :rtype: int :return: points of damage """ spells_list = [('dai', 5), ('aine', 4), ('ain', 3), ('jee', 3), ('je', 2), ('ne', 2), ('ai', 2), ('fe', 1)] damage = 0 if (is_correct(spell)): s...
59521044e08fb03273df5cded965ae43f735552b
zahedul/python-practice
/practice/find_angle_mbc.py
129
3.5625
4
import math ab = int(input()) bc = int(input()) res = math.atan2(ab,bc) print(int(round(math.degrees(res))), chr(176), sep='')
4805c90e46f803e2072763de52d30819ee606954
lycheng/leetcode
/dp/coin_change.py
1,396
3.578125
4
# -*- coding: utf-8 -*- class Solution(object): ''' https://leetcode.com/problems/coin-change/ ''' def coinChange(self, coins, amount): """ :type coins: List[int] :type amount: int :rtype: int """ count = [0] + [-1] * amount for x in range(amount): ...
96dc24cc8e85920ef8646d4f7a6fdb5573787858
snehilk1312/Python-Progress
/frozenset.py
150
3.53125
4
# frozensets are immutable form of normal sets frozens = frozenset([1,2,3,4,5]) print(frozens) for i in frozens: print(i) print(type(frozens))
8d45e213d3d5479276c36ca25e8a9367a91c9ab5
iqbalamo93/Python
/Class_OOP/PropertyDecorator.py
1,162
3.921875
4
''''Getters, Setters, and Deleters''' class Emp: number_of_employee = 0 #Example of class Variable raise_amount = 1.04 #Another class Variable def __init__(self,first,last,pay): #Special Init Method self.first_name = first self.last_name = last self.pay = pay ...
6b526329a1d29cffb53c92c765a56be1e4e8568f
Kitee666/UMK
/Python/Zadania/pileczka.py
337
3.578125
4
import math h = input("Podaj wysokosc do uderzenia(m): ") a = 9.8 l = input("Podaj odleglosc do upadku(m): ") tx = math.sqrt(2*l/a) vz = math.sqrt(l*a/2) if vz**2 - 2*a*h < 0 : print "Wprowadzono bledne dane!" else : vo = math.sqrt(vz**2 - 2*a*h); print "Predkosc poczatkowa:",\ vo,\ ...
b9dd24ebbfd10d18deb233e1aefe48912ceab93b
Redwanuzzaman/Python-Practicing
/Zip.py
891
4.03125
4
ZIP: Men = ['Romeo','Forhad','Majnu','Shajahan'] Women = ['Juliet','Siri','Laily','Momtaj'] for couple in zip(Men,Women): print(couple) # Output ('Romeo', 'Juliet') ('Forhad', 'Siri') ('Majnu', 'Laily') ('Shajahan', 'Momtaj') ----------------------------------------------- names = ('Richard','Danesh','Gylfoyl',...
4cea4116c5377115784fc9277ac5a812fe6a59a9
OneHandedTester/Drugie
/pal.py
216
3.75
4
slowo = input("Wprowadź swoje słowo aby sprawdzić czy jest palidromem: ") odwrocone = slowo [::-1] if slowo==odwrocone: print("Podane słowo to palindrom.") else: print("Podane słowo to nie palindrom.")
136e4e849891502f10da84ce39e3f7ed61911a6a
bernardoadca18/Curso-IGTI-ProgramadorDeSoftwareIniciante
/4 - Python/Aula09_OperaçõesComOsTipos.py
798
4.09375
4
# Boolean # print(5 == 5); # print(4 == 4); # print(5 == 4); # print(15 > 10); # print(3 > 15); # print("Python" == "Java"); # print("Python" > "Java"); # print("Python" == "Python\n"); # Convertendo tipos de dados num_end = 500; num_end_2 = "200"; str_end = "String Qualuer"; num_end_x = str(num_end); ...
917fe2bfb64476a0abb8fb6ca2a381c798449c4e
thecodearrow/LeetCode-Python-Solutions
/30 Days of Leet Code (COVID-19)/Valid Paranthesis String.py
1,005
3.78125
4
#https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/530/week-3/3301/ class Solution: def checkValidString(self, s: str) -> bool: n=len(s) if(n==0): return True stack=[] stars=[] valid=True for i in range(n): c=s[i] ...
bde3f4e2d2fad91fd976cde6c0360027844662a9
CarMoreno/PyBegins
/Modulos/Humano.py
1,118
3.625
4
# import nombreModulo # obj = nombreModulo.nombreClase() #obj2 = nombreModulo.nombreOtraClase() # otra forma puede ser: # from nombreModulo import nombreClase # obj = nombreClase() class Humano(object): def __init__(self, nombre, apellido, edad, comida): #Atributos self.nombre = nombre self.apellido = apellid...
f2e5f570778cc8ffb7a7d213e4263174f03ad755
zhanxiongjun/Python
/twelfth.py
192
3.84375
4
def front3(str): if(len(str) < 3): return str * 3 return str[:3] * 3 print(front3("zh")) #这个做的是比答案要好的,答案有点复杂,而且也没有运用乘法
061f242a8efa974b589bccb8b7abe18c7d1490a8
CDog5/AutoUpdate
/Fizzbuzz.py
655
3.78125
4
def fizzbuzz_v1(start,stop): for i in range(start,stop+1): output="" if i % 3 == 0: output += "Fizz" if i % 5 == 0: output += "Buzz" if output == "": output = i print(output) mlts={3:"Fizz",5:"Buzz"} # far superior method, using...
267d3701fb294829bce9e79e7c7c409d1da78355
sganzulya/ops435_a2p
/a2_class.py
4,960
4.46875
4
#!/usr/bin/env python3 class Date: def __init__(self, year, month, day): '''Testing to see if entered date is correct in the correct format & not above/below maximum number of days in a month ''' mon_max = self.days_in_mon(year) if (month > 12 or month < 1) : print("E...
61d30968c7dcb60916343050664655ae04b19bf6
HarshalTalreja/DjangoProject
/Python/Part10_Simple_Game.py
1,978
4.3125
4
########################### ## PART 10: Simple Game ### ### --- CODEBREAKER --- ### ## --Nope--Close--Match-- ## ########################### # It's time to actually make a simple command line game so put together everything # you've learned so far about Python. The game goes like this: # 1. The computer will think o...
2e856e742dd4d94cd0a554fa56d592bc3eba153e
mikaelbeat/Python_Programming_Masterclass
/Python_Programming_Masterclass/Modules_and_functions/Dates_and_times/Datetime.py
228
3.640625
4
import datetime today = datetime.datetime.today() now = datetime.datetime.now() utc = datetime.datetime.utcnow() print(f"\nDatetime today -> {today}") print(f"\nDatetime now -> {now}") print(f"\nDatetime UTC -> {utc}")
87da21784df4726e1f289307e3c29dc725dc9d4e
HotView/PycharmProjects
/Exercise_for_Job/3-寻路问题/Dijkstra优先队列.py
1,385
3.8125
4
## 需要一个优先队列,需要一个距离字典,需要一个状态集合,父节点的列表。 import heapq import math from collections import defaultdict graph = defaultdict(dict) graph = { "A":{"B":5,"C":1}, "B":{"A":5,"C":2,"D":1}, "C":{"A":1,"B":2,"D":4,"E":8}, "D":{"B":1,"C":4,"E":3,"F":6}, "E":{"C":8,"D":3}, "F":{"D":6} } def init_distance(grap...
7d31d0f7b80829be333e850ff43b53cf7802375a
OluwaseunA/PYTHONFILES
/listRangesTuples.py
4,410
4.09375
4
import csv flightsFile = open("flights.csv") reader = csv.reader(flightsFile) for item in reader: origin, destination, duration = item print(f"Origin: {origin}, destination: {destination}, duration: {duration}") #list is defined as a homogenous group of items although #in practice homogenity is not actually e...
2457a03e8be2d2ed175fd3cb5ff9a597261a7e2f
harsh95/codeforces_python
/Translation.py
107
3.9375
4
str1, str2 = str(input()), str(input()) str1 = str1[::-1] if str1 == str2: print("YES") else: print("NO")
88b199ce55b99ad0ff642e3ab7afb9345f5a85d6
Awingo/Taxes
/taxes2.py
2,513
4.0625
4
""" Anthony Wingo CS Introduction into Computation Laboratory 5""" import random products = input("What is items do you have? ") product_list = products.split(", ") location = input("What is your location? ") # Setting the second input def output(location, product_list): print("SALES TAX CALCULATION PROG...
eb9345c01a9fb9513f1a8ece5ce45324646f277d
sumkincpp/CodeTest
/comptetive-programming/adventofcode2020/02-12-valid-passwords.py
3,095
3.71875
4
#!/usr/bin/env python import sys import pytest from collections import namedtuple def is_pass_valid(line): start, word = line.strip().split(": ") rules = {} Rule = namedtuple('Rule', ['min', 'max']) for rule in start.split(","): rule = rule.strip() letter = rule[-...
6d3c7ad363d1265eca61d71585fe7ccd0a8dd59f
MarcusStuhr/Advent-Of-Code-2016
/Day22/Day22.py
5,151
3.515625
4
import re import heapq from itertools import combinations """ This makes several assumptions (due to how the AoC data was constructed): -There exists exactly one node with 0T Used, the initial "empty node." -There may exist "unviable" nodes with very large Size and Used attributes that aren't able to transfer data o...
3f0953b980b0b8d51ceba33af845dc2c50319fd5
hachira/lecture
/2020/datascience/6-2.py
178
3.5
4
''' 배열의 누적합과 누적곱 표현 ''' import numpy as np x = np.arange(1, 11) print("x = %s"%x) y = np.cumsum(x) print("y = %s"%y) z = np.cumprod(x) print("z = %s"%z)
82485aede0648f8b914a6c1436adfed189f242af
Naykayvd/Lotto-task
/converter.py
1,430
3.546875
4
import tkinter as tk from tkinter import * import requests window = tk.Tk() window.geometry("400x550") window.title("Lotto currency converter") value = IntVar() information = requests.get('https://v6.exchangerate-api.com/v6/89dcd9e8cc7777ded2575ce1/latest/ZAR') information_json = information.json() conversion_rate ...
73a2105f7a8799ad36a28410016ae8117c66eda6
Fabbinante7305/ShiftCipher_BruteForce
/crack.py
1,336
3.984375
4
#This will take Ciphertext and brute force every combination to get a sensical Plaintext value cipherText = input("Enter CIPHERTEXT value:\t") letterList = {'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y'...
be2ed19cacea25af1224669a65df2b15748530c3
MarinaGoto/python-basic
/Simple programs/Number_Days_in_Month.py
649
4.09375
4
#Develop a program that promps the user for a given month (and year for February), #and display how many days are in the month. month = input('Enter month: ') if month in ('January' ,'March' ,'May' ,'July' ,'August' ,'October' ,'December'): print('31 days') elif month in ('April', 'June' ,'September' ,'Nove...
2af41bad7586a650e37ded88c8dd9923536862c0
yenhungyu/109021009-20210507-CK
/numpy-CK-6.py
484
3.609375
4
#課堂練習 #加密 import sys import random import numpy data = list("This is book") if __name__ == "__main__": if len(sys.argv) >2: seedValu = int(sys.argv[1]) data = list(sys.argv[2]) random.seed(seedValu) random.shuffle(data) print("".join(data)) #解密 seedValu = int(sys.argv[1]...
b8776ad5c9eac770dc3a3032c71a2134c3a7cbb3
eddiewu6/LeetCode
/605. Can Place Flowers.py
687
3.984375
4
#Use a mask of 3 element to check the flowerbed #O(n) in time, O(1) in space #AC in 115ms class Solution(object): def canPlaceFlowers(self, flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ countFlower = 0 flowerbed.append(0) ...
c222ebefa2b13b52af09b5411ad1b76ad405e90d
iniyan-kannappan/python
/Programs/set5/Name_Relation_Address_StCity.py
785
3.84375
4
def details(): print('What is your name?') name=input() print('Who is your relation?') relation=input() print('What is your address?') address=input() print('What is your St City?') Stcity=input() print('What is ...
2019642344e6bb2ea09116e4d8be30cb96b4466d
ozdemiryucel/Artificial-Intelligence
/DepthFirst BreadthFirst UniformCostSearch AStarSearch/MazeAI.py
22,382
3.65625
4
# Yucel Ozdemir # 220201009 # This AI adds nodes to frontiers with the following line: Up, Down, Left, Right for all algorithms import sys from collections import deque from enum import Enum import functools import copy from typing import List import random # it is for printing side by side printf = functo...
dcc71f330e7de9f09db71c8ad3d4e0a8ccf162d7
JnLuck/ExamenJNQV
/5.potencia_r.py
199
4
4
def potencia_recursivo(num, pot): val = num*(num**(pot - 1)) return val numero = int(input("Numero: ")) potencia = int(input("Elevar a la potencia: ")) print(potencia_recursivo(numero, potencia))
7ba0409000bc527e58e9412de42c50a0088a1bc1
brianchiang-tw/leetcode
/No_1431_Kids With the Greatest Number of Candies/by_iteration.py
3,052
4.09375
4
''' Description: Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has. For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple ki...
cbd7520430f6a24d9032a5259847c2f016d27975
magnusoy/Python-Grunnleggende
/Kapittel-03/hjelpemidler.py
908
3.703125
4
# Variabler a = 2 b = 5 d = "Hei alle sammen" # Addisjon c = a + b # Subtrasksjon c = a - b # Multiplikasjon c = a * b # Float Divisjon c = a / b # Int Divisjon c = a // b # Modulus c = a % b # Eksonensjonell c = a ** b # Serie av operasjoner c = a // b * b - 3 # Serie av operasjoner c = a // (b * b - 3) # La...
942d5b5ea73260aff52e1bafc5b26df4c7e87206
jngcii/python-algorithm
/advanced/top.py
206
3.578125
4
def solution(heights): answer = [0 for i in heights] for i in range(1, len(heights)): for j in range(i-1, -1, -1): if i < j: answer[i] = j return answer
62a8e30d49e31a5d2be35d3d80d28b4440c6197f
xcodeburpx/PYTHON_WORKSHOPS
/Workshop_2/Chapter1_1/compozition.py
943
3.90625
4
""" Kompozycja Tworzenie obiektu z wielu obiektów. Obiekt posiada wiele składowych a te składowe są budowane w oparciu o inne obiekty """ from inherit import PizzaRobot, Server class Customer: def __init__(self,name): self.name = name def order(self, server): print(self.name, "za...
13e93712ad7b0667fbd6fe78d0f0e955387be621
ZohanKPI/Lab1
/third_task.py
901
3.8125
4
def EBNF_SyntaxChecker(string): if not string: return False, None elif string.isdigit(): return True, int(string) flag = True subtract = False operationResult = 0 for i in range(0, len(string), 2): if not string[i].isdigit(): flag = False break ...
f8d5d9667b71de8510eaf3ea4e6d844d77cddf46
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/sxxbar001/question2.py
344
4.3125
4
#Assignment 3 #Question 2 #25 March 2014 #Program to create an isosceles triangle height=eval(input("Enter the height of the triangle: \n")) def tri(height): gap=height-1 star=1 for i in range(height): print(" "*gap,end="") print('*'*star) gap=gap-1 star=star+...
a359982a1beaa8239f3b8d64f8120f81a5fbe156
svv232/Hack-Night
/z3-presentation/examples/coefficients.py
465
3.78125
4
#!/usr/bin/env python from z3 import * """ produces solutions for equations in the form ax^2 + bx + c to go through some set of points """ def coefficients(points): #Works on 2 dimensions s = Solver() a,b,c = map(Int, ("a","b","c")) for x,y in points: s.add(a*(x**2) + b*x + c == y) s.check() ...
d2b1f18770c29d5e50f691117aff6f8be1417dcf
nabiedma/python_crash_course
/unit_5/hello_admin.py
311
3.9375
4
users = ['admin', 'robert', 'nabiedma', 'benny', 'yepu'] if users: for user in users: if user == 'admin': print("Hello Admin. Would you like to see a report?") else: print(f"Hello there {user}. Welcome back.") else: print("There are still no users registered!")
0c3e6f9a97a360a0802c3c4f19950e09139c1f74
NiushanDong/data_processing
/image/contsign_rename_img.py
1,645
3.578125
4
# -*- coding: utf-8 -*- # Author: Yejinyu (yejinyu@9fbank.com.cn) # This is a class to rename the picture by hash from PIL import Image import imagehash import os import argparse def run(filePara): file_extension = ['.jpg', '.png'] if isinstance(filePara, str) and os.path.exists(filePara): for file in...
b49a290ca5b03c4e13e7cde473110adc8a6f214b
RakeshRameshDS/Programming-Interview-Preparation
/Dynamic Programming/04. Longest Increasing Subsequence.py
568
4.125
4
""" Find the longest increasing subsequence of a given array of numbers using dynamic programming. """ arr = [2, 7, 3, 4, 9, 8, 12] def longest_increasing_subsequence(arr): dp = [1 for i in range(len(arr))] res_link = [-1 for i in range(len(arr))] for i in range(len(arr)): for j in range(0, i): ...
8d49cd009be8e64a98fbed4135df8e00756a542a
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/space-age/b60b746f542940bdbb2bc187fd506244.py
741
3.65625
4
EARTH_YEAR_SECONDS = 31557600 ORBITS = { 'mercury': 000.2408467, 'venus': 000.61519726, 'mars': 001.8808158, 'jupiter': 011.862615, 'saturn': 029.447498, 'uranus': 084.016846, 'neptune': 164.79132, } class SpaceAge(object): def __init__(self, seconds): self.seco...
fc171070726bf18277cd39d52084693f0897fd1f
qizongjun/Algorithms-1
/Leetcode/Sort/#280-Wiggle Sort/main.py
1,182
3.8125
4
# coding=utf-8 ''' Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4]. ''' ''' 每个奇数位将相邻的三个元素最大的放在这里,每个偶数位将相邻的三个元素最小的放在这里 Beat 82.60% 公司:Google ''' class Solution(object): ...
6fcf16f0a8b920421228694ac3fe96d983c7eb0a
jdsoteldo/100days
/day8-ceasar.py
861
4.4375
4
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n") text = input("Type your message:\n").lower() shift = int(input("Type the shift number:\n")) #-1: Crea...
aa9498a25f2cf7c0c5632151cd54df6813f911e6
iFun/Project-G
/solutions/0040-combination-sum-ii/combination-sum-ii.py
2,671
3.796875
4
# Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. # # Each number in candidates may only be used once in the combination. # # Note: # # # All numbers (including target) will be positive integers...
c0d519caa25d9041025d4f28ad4ecad10fbf90cb
horselurrver/practice-code
/ex9.py
696
3.90625
4
import random def game(num): user = '' print("The number is {}".format(num)) while not user.isdigit() or int(user) < 0 or int(user) > 100: user = raw_input("Please enter an integer between 0 and 100 inclusive (or exit to exist): ") if user == 'exit': print("Thanks for playing!")...
89a8c56b2a31efb3cdb34fca9168e6d8c7131f45
eduardosm7/python-piano
/piano.py
2,165
3.671875
4
""" Piano class """ from tone import Tone from note import Note from pynput.keyboard import Key, Listener class Piano: # keyboard_key: piano_note __key_mapping = { "a": "c", "w": "c#", "s": "d", "e": "d#", "d": "e", "f": "f", "t": "f#", "g": "g"...
ebb080cf16a313c485db753888d32144e73c85db
JBM291/PythonDemo
/dbquery.py
264
3.71875
4
import sqlite3 as db conn = db.connect('test.db') conn.row_factory = db.Row cursor = conn.cursor() cursor.execute("select * from films") rows = cursor.fetchall() conn.close() for row in rows: print("%s %s %s" % (row["title"], row["year"], row["director"]))
94eeea968d3f91eb9f12597652c024b8eb8a08cf
vii6029/Matrizortogonal
/pertence a matriz.py
669
3.703125
4
def estanamatriz(x): cont=0 for i in range(linhas): for j in range(colunas): if(x==matriz[i][j]): cont+=1 if(cont==0): pertence=False else: pertence=True return pertence x=int(input()) matriz=[] linhas=2 colunas...
7274bcff7784083a3570127629621ff1cc7ec0fd
rgrishigajra/Competitive-Problems
/Coding interview course/Sliding Window/Longest Substring with Same Letters after Replacement (hard).py
1,020
4.09375
4
# Given a string with lowercase letters only, if you are allowed to replace no more than ‘k’ letters with any letter, find the length of the longest substring having the same letters after replacement. def length_of_longest_substring(str, k): characters={} window_start,max_length,max_length,curr_length,max_char_fre...
b36ccf21af067de49e421628ea1e5c3ed79a26db
rohitamrutkar1204/dsc-hacktoberfest-2021
/Submissions/Validate_IP_Address/Vedant_Gokhale.py
1,328
3.875
4
# Validate an IP Address # Vedant Gokhale (gokhalevedant06) # Explanation # 1) Split the string using split method # 2) Check if length = 4 else return False (Invalid IP) # 3) Append all possible integers(0-255) in a list # 4) Initialize a temp string and a counter # 5) Find for '.' in the original string using for...
ef28b9e9c0d2d7763e26e14030232fadfceab1b0
GhostDovahkiin/Introducao-a-Programacao
/Monitoria/Lista-Strings/1.py
433
3.90625
4
print("Compara duas strings") str1 = input("Frase 1: ") str2 = input("Frase 2: ") print("Comprimento String 1: {}" .format(len(str1))) print("Comprimento String 2: {}" .format(len(str2))) if len(str1) == len(str2): print("As duas strings são iguais") else: print("As duas strings são diferentes") if str1 == str2: pri...
6120ef02ac6ab125e2fbb2c672fda06256b7b5b8
PayelSelfStudy/Python-C104
/mean.py
2,035
4.1875
4
# Python program to print # mean of elements # list of elements to calculate mean import csv from collections import Counter with open('height-weight.csv', newline='') as f: reader = csv.reader(f) file_data = list(reader) file_data.pop(0) # print(file_data) # sorting data to get the height of peo...
a6492d8d9e242237351a1426e2f5c6947a3974ec
DanielHry/Python
/11 - Unit Convert/main_class/classPressure.py
3,456
3.90625
4
# -*- coding: utf-8 -*- def choice(): while True: try: c = int(input('>>> ')) if 1 <= c <= 5: break else: print('Your choice must be between 1 and 5') except: print('Your choice must be between 1 and 5') return c class Pressure(): ...
531031b3f5a8230cf4bed75bb4aee6d9bf878338
miyamotok0105/python_sample
/python_sample/sort.py
552
3.5625
4
data = [ ('betty', 1), ('bought', 1), ('a', 1), ('bit', 1), ('of', 1), ('butter', 2), ('but', 1), ('the', 1), ('was', 1), ('bitter', 1)] print(data) print(sorted(data, key=lambda tup:(-tup[1], tup[0]))) # data = [[1,2,3], [4,5,6], [7,8,9]] data = [(1,3,6), (2,2,3), (3,1,9)] print("tup[0]:",sorted(data, key=lambda tu...
d66b024e87278fd25f3f97fcec9606f8d0bb6964
KennyRich/Algorithm-Solutions
/Plus Minus.py
365
3.640625
4
def plusMinus(arr): zero = 0 positive = 0 negative = 0 for i in range(len(arr)): if arr[i] > 0: positive += 1 elif arr[i] == 0: zero += 1 elif arr[i] < 0: negative += 1 p = positive / len(arr) n = negative / len(arr) z = zero / len...
4cb4b077f06bc4e25b52a29514f9db97fd5dd958
jfulghum/practice_thy_algos
/matrices/flip_matrix.py
1,149
4.1875
4
# Given a two dimensional array of integers, fold this array over a vertical axis, adding the numbers that meet. This means that in each row, the first and last numbers are added to become the first element in the output, and the second and second to last become the second element, etc. For example: matrix = [[1,2,3, ...
ceab5f27a7f4bc8120f9c44f627770e197a47eff
Mrgove10/PythonInitiation
/Exos/Exo7.py
229
3.734375
4
# -*- coding: utf-8 -*- for i in range(2000, 4001): if i % 7 == 0: if i % 5 != 0: print(str(i) + " => Oui (divisible par 7 et pas par 5)") else: print(str(i) + " => Non (pas divisible par 7)")
bac06cabc1afa5357b903aadcc321b30e8ef81e0
mkaul14/Project
/Autoccorect_Project.py
3,112
4.28125
4
#Meghna Kaul #This program uses two functions to determine which word in the dictionary is closest to the user word. The first function, the #distance function, uses the Levenshtein distance too see how far apart the two words are. This is a better and more accurate #system than the hamming distance because hamming di...
3dc3a623f6ae47d3188ad5b2b4e2914108002999
alexfreed23/OleksiiHorbachevskyi-PythonCore
/Python/PythonCore/HomeWork/HomeWork_10_20200714/Task4.py
965
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jul 19 20:57:35 2020 @author: oleksii """ import random elementsCount = random.randint(3,10) print("Genertated list which consist of",elementsCount, "elements") firstList = [] for i in range(elementsCount): addElement = random.randint(0,10) fi...
2e4d8ae9464e133ba85b22d32b5fbbe7cb66c56f
nixbpe/legacy
/fibo.py
171
3.640625
4
import sys def fibo(n): if n <= 2 : return 1 p1 = 1 p2 = 1 for i in range (2,n): fibo = p1 + p2 p2 = p1 p1 = fibo return fibo print fibo(int(sys.argv[1]))
181629b268481b7229acc6c8beff1f3a4e0f5a57
Uche-Clare/python-challenge-solutions
/Darlington/phase1/python Basic 1/day 15 solution/qtn1.py
209
3.859375
4
#program to split a variable length string into variables. var_list = ['a', 'b', 'c'] x, y, z = (var_list + [None] * 3)[:3] print(x, y, z) var_list = [100, 20.25] x, y = (var_list + [None] * 2)[:2] print(x, y)
138b5175032362cd124b4088b6bb7f59b4b9090f
Raakeshtrip/test_Repo
/quickcheckup.py
274
4.15625
4
print("Hello User") name = input("what is user name: ") print ("Hello" + name) age = int(input("What is your age: ")) if age < 6: print("Awww..you're just a baby") if age > 31: print("Ah... A travelled soul are ye") else: print("You are the any other guy")
0968affcd28bedc69d4cd34500f2c52558998fba
nathansmerrill/rsa
/rsa.py
6,741
3.65625
4
import sys, math, random sys.setrecursionlimit(5000) """ Usage: Generate keys - python rsa.py -g <bits> Encrypt text - python rsa.py -e <text to encrypt> <encryption key> <n> Decrypt text - python rsa.py -d <text to decrypt> <decryption key> <n> """ def gcd(a, b): while b != 0:...
51e746db9541956385ee64cbd54df1bfe50ae2f0
HenryHdez/ASIGNATURAS
/Diseño_Digital_Avanzado/Python_proyectos/Python_Unicamente/Interfaz-Grafica/Reloj.py
582
3.546875
4
#Asignar una función a los botones import sys from Tkinter import* import time def Tick(): Salida_Label=time.strftime("%H:%M:%S") etiqueta.config(text=Salida_Label) #Tiempo de Actualizacion en Milisegundos Tiempo_Actualizacion=1000 app.after(Tiempo_Actualizacion,Tick) #Crear Interfaz ap...
b4638ad0827b936fbf791b324211ce7e24f99742
mpatel3196/Aero-CFD
/NACA_4digit_Airfoil.py
3,641
3.765625
4
import numpy as np import matplotlib.pyplot as plt def main(): NACA4digit("2412") def NACA4digit(airfoil_number, points=1000, closed_trailing_edge=True, save_to_file=False): """Compute and plot coordinates of a NACA 4-digit airfoil. Arguments: number: Name of the requested 4-digt NACA airfoi...
c706e585d28caf914c007aaba41424adc2d0f219
Zhontar/proyectos
/string_rep.py
353
3.734375
4
#Crea un programa que cuente el número de veces que aparece una palabra en una string frase_user = input("Introduce una frase: ") base_palabras = dict() frase_lista = frase_user.split() for palabra in frase_lista: if palabra in base_palabras : base_palabras[palabra] += 1 else: base_palabras[pa...
53024acada9ec1ac42b97237472740a8597f3782
ZacharyRanes/30-Days-Of-Python
/day_22/day22_web_scraping.py
887
3.671875
4
import requests from bs4 import BeautifulSoup url = 'http://mlr.cs.umass.edu/ml/datasets.html' response = requests.get(url) content = response.content # we get all the content from the website # beautiful soup will give a chance to parse soup = BeautifulSoup(content, 'html.parser') print(soup.title) # <title>UCI Mac...
314f60d29903fbee48719ee018c0d202fa67407f
theSaintBelial/PythonJedi
/oop/simple_examples/first_class.py
158
3.609375
4
class Person: def __init__(self, name): self.name = name def say_hi(self): print("Hi, {}!".format(self.name)) example = Person('Kek') example.say_hi()
f1273adbdb69a457af56bceb2112d6da21555603
kelvinng213/PythonDailyChallenge
/Day06Challenge.py
464
4.34375
4
# Create a function that given a string, it returns the middle character of # the string. If the length of the string is even, return the two middle # characters of the string. def middle(string): if len(string) % 2 == 0: middle_string = (string[(int(len(string)/2)-1):(int(len(string)/2)+1)]) ...
c150b9537f0a86d2a2afb34354e9ae4e24378d99
Gao-Xixi/cs61a
/projects/hog/my_test.py
3,005
3.5625
4
from hog import * from dice import make_test_dice # free_bacon(0) # free_bacon(1) # free_bacon(2) # free_bacon(80) #Test of problem3 # print(take_turn(2, 0, make_test_dice(4, 5, 1))) # print(take_turn(3, 0, make_test_dice(4, 6, 1))) # print(take_turn(0, 2)) # print(take_turn(0, 0)) # print(swine_align(2, 4)) # print...
d2d34dbbe781852ce97bf6d90c3505c4c42687e5
austinlewis/leet-code-local
/python/arrays/p_217.py
1,198
3.515625
4
#!/usr/bin/env from typing import List class Solution: def containsDuplicate(self, nums: List[int]) -> bool: ''' Submission_1: https://leetcode.com/submissions/detail/550779729/ ''' if(len(set(nums)) != len(nums)): return True else: ...
25b1e8000442ad2d42d37a59cb8d70ffe7f8dde2
shaikhanas1993/learningPython
/ex3.py
471
3.703125
4
class MyError(Exception): def __init__(self,value): self.value = value def __str__(self): return repr(self.value) raise MyError('oops!') # class MyError(Exception): # def __init__(self,value): # #print dir(self) # # print self # self.value = value # ...
a4514282b4e2da09b03b899584e4a10046e491d2
JorSanders/Python-MOOC
/fundamentals/module2.py
1,028
4.3125
4
animals = ['cat', 'goat', 'cat'] def list_o_matic(targetString, list): if targetString == '': return '1 instance of ' + list.pop() + ' removed from list' counter = 0 for item in list: if (item == targetString): return '1 instance of ' + list.pop(counter) + ' removed from list' ...
35a130451562cfc118d29d5901bc0c581207c5c8
OhOverLord/loft-Python
/Алгоритмы_ теория и практика. Структуры данных/(2.3.2)Parallel_processing.py
797
3.640625
4
""" Параллельная обработка Sample Input: 2 5 1 2 3 4 5 Sample Output: 0 0 1 0 0 1 1 2 0 4 """ from heapq import heapreplace # Функция которая удаляет и возвращает самый маленький элемент из кучи, а также # добавляет новый элемент def main(): """ Функция реализующая параллельную обработку """ n, m = ...
2074ec87741f6b970d0c6c7615c10fd4368a7a83
Aceinna/gnss-ins-sim
/gnss_ins_sim/sim/ins_algo.py
2,364
3.625
4
# -*- coding: utf-8 -*- # Filename: ins_algo.py """ A base algorithm class. Created on 2018-04-28 @author: dongxiaoguang """ class InsAlgo(object): ''' A base algorithm class. User defined algorithms should be a subclass of this. An algorithm should at least contain three variables to describe its input, ...
64a80aee0ea279666ccd2d6bd1c01166adf6457d
HeroIsUseless/c
/IntToHash.py
223
3.578125
4
class HashMap: list = [] def insert(self, a): pass def getPos(self, key): pass n, p = map(int, input().split()) l = list(map(int, input().split())) hm = HashMap() for i in l: hm.insert(i)
0a97d3072dedbf6aed9766978cecd2f6eb0f2ff4
Xiaoxiong-Liu/leetcode-easy
/string/firstUniqChar.py
946
4.09375
4
""" 字符串中的第一个唯一字符 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 案例: s = "leetcode" 返回 0. s = "loveleetcode", 返回 2. 注意事项:您可以假定该字符串只包含小写字母。 https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/5/strings/34/ """ class Solution: def firstUniqChar(self, s): """ :type s: str ...
e1e226207818662f871ffb98a7a5e92be313404b
lawtonsclass/f20-code-from-class
/csci41/lec31/mandelbrot.py
1,226
3.953125
4
import turtle # the fractal is recursive, but this program is not! turtle.shape('turtle') turtle.speed('fastest') turtle.tracer(5000) # make the turtle really really fast turtle.color('blue') turtle.up() # scale:1 zoom level scale = 200 def isPointInTheMandelbrotSet(x, y): # turn (x, y) into x + iy ...
e189f7eafce61c8b4c9e1163c8c203394dac8b18
Mitesh2499/AI-algorithms
/tower-of-hanoi.py
332
3.921875
4
def toh(size,start,aux,des): if size ==1: print("move disk {} from {} to {} ".format(size,start,des)) return toh(size-1,start,des,aux) print("move disk {} from {} to {} ".format(size,start,des)) toh(size-1,aux,start,des) size=int(input("Enter Number of Disk :- ")) toh(size,'A...
0a10952b205a58fd550b623ff6933f8a96df48a4
Zepur/Kattis
/mixedfractions.py
252
3.65625
4
while True: a, b = [int(i) for i in input().split()] if a == b == 0: break else: if a < b: print('0 ' + str(a) + ' / ' + str(b)) else: print(str(int(a/b)) + ' ' + str(a % b) + ' / ' + str(b))
0228471e0e499badc2bfaa362e5e74ef6329c67c
gabriellaec/desoft-analise-exercicios
/backup/user_250/ch151_2020_06_21_21_18_02_568028.py
430
3.53125
4
def calssifica_lista(lista): crescente = True decrescente = True for i in range(0,len(lista)-1): if lista[i] > lista[i+1]: crescente = False if lista[i] < lista[i+1]: decrescente = False if crescente == True and decrescente == False: return 'crescente' ...
e9562a5c6842ce347d67fe60d5c78c798406c7e9
riven569/python-windows
/Q30.py
211
3.765625
4
#-*-coding:utf-8-*- x=int(input('input a number (5):')) a =x//10000 b =x%10000//1000 c =x%1000//100 d =x%100//10 e =x%10 if a==e and b==d: print ('it is a 回文数') else: print("it is false")
fd4e64dd282cd603e38de959949fed4bb34eb7e3
gasobral/python_codes
/Data Structure/Chapter 2/R_2_12.py
2,247
4.28125
4
#! /usr/bin/env python3 # # -*- coding: utf-8 -*- # ## Implementação de Classes - - - - - - - - - - - - - - - - - - - - - # class Vector: """Represent a vector in a multidimensional space.""" def __init__(self, d): self._coords = [0] * d def __len__(self): return len(self._coords) d...
15648c8a3c622f9dd621227e5ee1a293785df9ba
ymwondimu/PracticeAlgos
/find_substring.py
368
3.890625
4
def find_substring(s, substr): n = len(substr) start = 0 end = start + n while (end <= len(s)): proposed_substring = s[start:end] if proposed_substring == substr: return True start += 1 end += 1 return False def main(): print (find_substring("hello"...
71679d467887c08c82d718b04a27e4c63ae3fe6b
sanket-qp/IK
/2-Linked Lists, Stacks, Queues/zip_linked_list.py
1,821
4.0625
4
""" Given an integer singly linked list L of size n, zip it from its two ends. What does zipping mean? Given a singly linked list L: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> NULL 1 -> 6 -> 2 -> 5 -> 3 -> 4 -> NULL You have to do it in-place i.e. in the same linked list given in input, using only cons...
7cd151836ab3a2187e24cb9c3364aeb39cf7d72d
Yuvv/LeetCode
/1001-1100/1089-duplicate-zeros.py
939
3.75
4
from typing import List class Solution: """ https://leetcode.com/problems/duplicate-zeros/ 把数组里面的 0 重复一遍,数组后面的数往后退 """ def duplicateZeros(self, arr: List[int]) -> None: """ Do not return anything, modify arr in-place instead. """ arr_len = len(arr) i = 0 ...
4eb9681477f4c6004457f13c4ff7b280e9cfc4aa
DataRedKite/datagalaxy
/client/utils.py
2,940
3.734375
4
# Import import pandas as pd import numpy as np def split_path_subpath(path): """ function used to split a path into its sub-paths Parameters __________ path : str Path which needs to be split Returns ________ List(String) List of strings containing all the sub-paths ...