blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1e8ed83b4b42edfa6e8b3c2d813f38c156fe2db0
williamsj71169/03_Assesment
/05_rounding_v2.py
927
3.734375
4
import math def num_check(question, error, num_type): valid = False while not valid: try: response = num_type(input(question)) if response <= 0: print(error) else: return response except ValueError: print(error...
7df00c06e7c74c54831fc7d4c8cc654e5e86d119
yndajas/cs50_2020_pset6_Mario_more
/mario.py
350
4.09375
4
from cs50 import get_int height = 0 # get height until it's within range 1-8 while height not in range(1, 9): height = get_int("Height: ") # for loop starting at one and going until height for row in range(1, height + 1): # print left spaces + left hashes + gap + right hashes print(" " * (height - row) +...
518c0ecee09abbb620a3220a00f6302ba0d43928
ldavis0866/Graphs
/projects/graph/src/graph.py
3,819
3.6875
4
""" Simple graph implementation compatible with BokehGraph class. """ import random class Vertex: def __init__(self, vertex_id, value=None, x=None , y=None, color=None): self.id = int(vertex_id) self.value = value self.color = color self.x = x self.y = y self.edges =...
11548da6b1667c274acb79a13da96f89964c1654
kevinr1/python
/chapter1-4/collatz.py
603
4.28125
4
#Collatz chapter 3 exercise print ('Enter a number') try: enteredNumber = int(input()) def collatz(enteredNumber): while enteredNumber != 1: if enteredNumber % 2 == 0: enteredNumber = (enteredNumber // 2) print(int(enteredNumber)) ...
ccb5c382e4b3c1087d04a287cc19cc94caa2c996
vaishaliyosini/Python_Concepts
/7.loops_while_for.py
451
3.734375
4
# while loop c = 0 while (c < 10): print (c, end='') c += 1 print(end='\n') # prints 0123456789 # while loop c = 0 while (c <= 10): print (c, end=',') c += 1 # for loop numbers = [1, 2, 4] for x in numbers: print (x) # prints 1 # 2 # 4 x = 5 for c in ra...
7d78dcd122ca94bab26b6747a22e2ab4a40bd0cb
2001Sapsap28/Python-Crash-Course-Book-Tasks
/Do It Yourself section tasks/Chapter 5/5.7.py
923
4.46875
4
# 5-7. Favorite Fruit: Make a list of your favorite fruits, and then write a series of # independent if statements that check for certain fruits in your list. # • Make a list of your three favorite fruits and call it favorite_fruits. # • Write five if statements. Each should check whether a certain kind of fruit # is i...
e031fff67c212f81a871b33967cf3b9f6a071b42
become-hero/mypython
/2_9_3.py
159
3.796875
4
print("------start------") i = 1 while i <= 20: if i % 2 == 0: if i % 10 == 0: break print(i) i+=1 print("-----end------")
1d2be99fcd07dae77009013656f2ad930b4249bd
group8BSE1/BSE-2021
/src/chapter 6/exercise1.py
116
3.8125
4
index = 0 fruit = 'banana' while index < len(fruit): index = index -1 letter = fruit[index] print(letter)
289ace9c280e1323e6d5a120d92eb71b41d1acb7
dheena18/python
/day11ex2.py
151
3.515625
4
list_1=["RAJA", "BADHRI", "DHEENA", "ANWAR", "SIVA", "RAWNA", "DHANANJ","6GROUP"] range = list(range(1,8)) lst = list(zip(list_1, range)) print(lst)
76474292d33c2c84702f9ff17c08301d06f4209f
Olddays/myExercise
/Python/LeetCodeTest/lc065_ValidNumber.py
1,771
3.578125
4
class Solution: # 使用编译原理中的优先状态机(DFA)解决 https://leetcode-cn.com/problems/valid-number/solution/biao-qu-dong-fa-by-user8973/ def isNumber(self, s: str) -> bool: state = [{}, {'blank': 1, 'sign': 2, 'digit':3, '.':4}, {'digit':3, '.':4}, {'digit':3, '.':5, 'e':6, '...
e0b9e6dc42e77c5fc41fa3a6b54205004291ddbe
kanishkb1/Data_Structures_Algorithms_In_PYTHON
/Queue/queue_problem.py
1,029
4.4375
4
#The aim is to design a queue abstract data type with the help of stacks. class Queue: def __init__(self): #use one stack for enqueue operation self.enqueue_stack = [] #use another stack for dequeue operation self.dequeue_stack = [] #adding item to the queue def e...
0cf01f275ab3a773d6cd4b9def1975d4ab2745c2
Costadoat/Informatique
/Olds/TP_2020/TP04 Boucles et complexité/Documents/cadeau_tp_boucles.py
304
3.953125
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 20 11:52:38 2013 @author: stephane """ from math import sqrt def est_premier(n): if n <= 1: return False if n <= 3: return True for k in range(2,1+int(sqrt(n))): if n % k ==0 : return False return True
e4a60ba9475f7cd63d74972d28303afcbe4d8f2e
brass3a4/AsignacionCuadratica
/mimi.py
3,833
3.71875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- import random from libj import * def factorial(n): max=1 if(n>0): max=factorial(n-1) max=max*n else: max=1 return max #genera la poblacion con el numero de elementos que se solicitan #parametros: poblacion es la poblacion total, cantidad es el numero...
3f580e77c54db34b1021d2eecff1579d8461a20b
rjw57/plot85
/polygon.py
791
4.15625
4
from pi.graphics import * from pi.maths import * from math import * def draw_polygon(sides): w, h = screen_size() centre_x = w / 2 centre_y = h / 2 radius = min(w, h) * 0.4 angle_per_side = 360.0 / sides move(centre_x, centre_y + radius) for side in range(1, sides + 2): deg_angle = angle_per_side * side ...
709dd0d78603585ee910a1046b28acbabb818633
jchuynh/daily-coding-problem
/problem_144.py
784
4.28125
4
# asked by Google # given an array of numbers and an index i, return the index of the # nearest largest number of the number at the index i, where the distance is # measured in array indices. # if two distances to larger numbers are equak, the return ant one of them. If # the array at i doesn't have a nearest larger...
7578527e9e65c2b8046f348e0d97b5ac3b723bdb
sasazlat/UdacitySolution-ITSDC
/PprobabilityDistribution/discrete_probability_exercise.py
6,717
4.53125
5
# coding: utf-8 # # Discrete Probability Exercise # # You have two dice. These are fair, six-sided dice with the values one # through six. # # You take the dice, and you roll them. Then you take the sum of the two # numbers. For example, if you roll the dice and get 5 and 4, then the sum # would be 9. # # # ![alt ...
d56690a0587b171087eb74fc22f2bc494a045cc0
Dybov-Alexey/lesson3
/task123.py
3,259
4
4
#Определить, является ли введенное число простым def primenumder(n): if n % 2 == 0: print("Not prime",'\n') return k = 3 while k **2 <= n and n % k != 0: if n % k == 0: print("Not prime",'\n') return k+=2 print("Prime",'\n') #primenumder(int(...
a555cc3c24e165d365ca2582e528ef6d144de655
aturtur/python-scripts
/old-random/frames_to_seconds.py
1,240
3.703125
4
# Frame calculator ############################################################################# print ("Frames?") # Question frameRange = raw_input(">") # Frame range input print ("Frame rate?") #Question fps = float(raw_input(">")) # Frame rate input mode = frameRange.count("-") if m...
9d15399b16932e987eda2dbf8a78c6caf7f964e0
Nick-P-Orr/factCalc
/factorial.py
479
4.0625
4
import math try: y = input('input factorial: ') except SyntaxError: y = None z = 1 ''' #range 2 to fact number for i in range (1,y+1): z = z*i print (z) ''' ''' #without factorial function def factCalc(fact, sum): sum = sum*fact fact = fact-1 if (fact-1 != 0): factCalc(fact, sum) ...
38f18e9793b121cdc04c5341addfc7a4096872df
ellelater/Baruch-PreMFE-Python
/level5/5.1/5.1.2.py
428
3.765625
4
import datetime def main(): # a time = raw_input("Input time (in format %Y-%m-%d %H:%M:%S:%f):") # b t = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S:%f") # c print "Year:", t.year print "Month:", t.month print "Day:", t.day print "Hour:", t.hour print "Minute:", t.minut...
be1a04af65648b90755cdf1cffa8c2e27894e05f
arsamigullin/problem_solving_python
/leet/dp/DPonTrees/unique_binary_search_trees.py
1,815
3.875
4
# this problem # https://leetcode.com/problems/unique-binary-search-trees/ # dynamic programming # binary search trees class SolutionMy: ''' the idea is to pick the root (i) and multiply combinations on the left subtree and combinations on the right subtree NOTE: If count of nodes on the left and righ...
4ad5a799e6d38c38d4b7f506d049e97737ce26a2
DeshanHarshana/Python-Files
/pythonfile/New folder/pythonAssesment/Marks.py
1,138
4.125
4
def A(marks): grade="" if 75 <= marks <= 100 : grade = 'A+' elif 70 <= marks < 75 : grade = 'A' elif 60 <= marks < 70 : grade = 'B' elif 50 <= marks < 60 : grade = 'C' elif 40 <= marks < 50 : grade = 'D+' elif 35 <= marks < 40 : grade = ...
33b8b9dac3f9c7d2697a5ce1b299748ed638e9ec
Timelomo/leetcode
/784 Letter Case Permutation.py
554
3.953125
4
""" 我的想法 首先全部转换成 小写 然后遍历 处理 一次处理一个 很复杂 but 下面代码 niu X """ class Solution(object): def letterCasePermutation(self, S): """ :type S: str :rtype: List[str] """ res = [''] for c in S: res = [i + c for i in res] + [i + c.swapcase() for i in res if c.isalph...
0183eb2dadeebf4086dddb2a69feaef299f3a777
timjab92/projectdraft
/projectdraft/lib.py
254
3.53125
4
def try_me(): x = input("Do you have any doubts? Type y or n") if x == "y": return "No need to worry. You are amazing! Keep going!" elif x == "n": return "Thats exactly right" else: return "read the instructions."
95f6d0542d80a33c6a8e94d784fb006d46966b3c
nabroux/Codingbar-Math-Camp
/Day2/Challenge - 轉換溫度計.py
339
3.5
4
# 按鍵A攝氏,按鍵B華氏 from microbit import * display.scroll('Press A or B', loop=True, delay=100, wait=False) while True: c = temperature() f = c * 9/5 + 32 if button_a.was_pressed(): display.scroll(c, loop=True, wait=False) elif button_b.was_pressed(): display.scroll(f, loop=True, wait=False)...
f2209a125de52106ef5f9c99dcf388d20b5addcd
kineugene/lessons-algorithms
/lesson-2/task_1.py
895
3.953125
4
if __name__ == '__main__': while True: operations = {'*': lambda a, b: a * b, '-': lambda a, b: a - b, '/': lambda a, b: a / b, '+': lambda a, b: a + b} operation = input('Введите операцию (+, -, *, /) или 0 для завершения:\n') ...
4ba580b34d211ebe5cf5e409d715bd4af025c8a1
VicenteCV/MCOC-Intensivo-de-nivelacion
/22082019/000200.py
266
4.03125
4
#4ta Entrega #Ciclo For #Ejemplo 1 print 'Ejemplo 1' a=['Bananaaaa!!!','Bee do Bee do Bee do','Tu le bella comme le papaya'] for i in a: #Ciclo for que recorre lista print i #Al recorrer la lista elemento, por elemento, estos se imprimen durante cada ciclo.
519d139c778f762db2afc1f4c48316038a92b8ac
garza71/TC1028.python.e07.matrices
/assignments/13Determinante/tests/input_data.py
350
3.84375
4
# List of tuples # Each tuple contains a test: # - the first element are the inputs, # - the second are the output, # - and the third is the message in case of an error # To test another case, add another tuple input_values = [ # Test case 1 ( ["1 2","3 4"], ["","","-2"], "La matriz no ...
df58c71176d5591af8c8977d69dbdda27358afe0
udhayprakash/PythonMaterial
/python3/19_Concurrency_and_Parallel_Programming/01_MultiThreading/a_function_based/c2_with_multithreading.py
644
3.9375
4
# This multithreading program prints output # of square and cube of a series of numbers import threading import time def PrintSquare(numbers): print("Print squares") for n in numbers: time.sleep(0.2) print("Square", n * n) def PrintCube(numbers): print("Print cubes") for n in numbe...
71cab8db01e102fd0f4fab937b98782550186d87
mushtaqmahboob/CodingPractice
/LeetCode/Easy/MajorityElement.py
414
3.90625
4
def majority(array): result = (len(array)//2) if len(array) == 0: return 'Empty Array' counter = {} for ele in array: if ele in counter: counter[ele]+=1 elif ele not in counter: counter[ele] = 1 for k in counter: if counter[k] > result: ...
941151859cffad2db57cde0b1d16e8c92e62d763
BradK14/Space_Invaders
/venv/alien_laser.py
1,368
3.78125
4
import pygame, random from pygame.sprite import Sprite class Alien_Laser(Sprite): """A class to manage lasers shot from the aliens""" def __init__(self, ai_settings, screen, aliens): """Create a laser at a random aliens position""" super(Alien_Laser, self).__init__() self.screen = scree...
7d3608a760b039ab0f152200262dc7e1f7f385e4
ufukcbicici/phd_work
/initializers/xavier.py
2,427
3.875
4
import numpy as np class Xavier: """Returns an initializer performing "Xavier" initialization for weights. This initializer is designed to keep the scale of gradients roughly the same in all layers. By default, `rnd_type` is ``'uniform'`` and `factor_type` is ``'avg'``, the initializer fills the w...
54114d77e04e4a651e7ea273b1cef4c2c9b89eb9
christianfosli/Series
/series.py
1,064
4.03125
4
# Evaluate sum of a Series (Sn) and each of the terms (an) # until an appears to go to zero (which could be a sign of convergence) # or until n reaches the specified endpoint import math Sn = 0 epsilon = 0.0001 # How close to zero an needs to get zeroCounter = 0 # zeroCounter will +1 whenever abs(an) < epsilon zer...
50cad57f687c9f22e8877169fbb0e8058f70f648
kwhit2/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
344
4.1875
4
#!/usr/bin/python3 """ Function that reads a text file (UTF8) and prints it to stdout: """ def read_file(filename=""): """ read_file method: Args: filename = name of file(string) Returns: None """ with open(filename, encoding='utf-8') as f: for x in f: ...
ebc49d586f9a35262188f80c46919bfd31d75627
botaoap/DesenvolvimentoPython_Botao_2020
/Revisao/exemplo5.py
653
3.921875
4
# Com a seguinte lista de nome de gatos, # mostre o nome um em cada linha # lista_gato = ["Mr pop", "Amora", "Frida", "Boo Cristina", "Patinha de neves"] # for i in lista_gato: # print(i) # Com a seguinte lista de numeros, mostre eles multiplicados # pelo número 3 # lista_numeros = [1, 9, 5, 7, 8, 2, 4, 3, 6] ...
37749d806eec1538c603e5f54cdb24d303ed8ea3
sajjanparida/DS-Algorithms
/Sorting/kthelementsortedarray.py
576
3.5
4
def kthelement(arr1,arr2,n,m,k): kthelement=0 i=0 j=0 l=0 while l < k: if arr1[i]<arr2[j]: kthelement =arr1[i] i += 1 l += 1 else: kthelement = arr2[j] j+=1 l += 1 if i==n: while l<k: ...
43f48e34d7c60c89f34bd3f15120a8a6a7ea41dc
junior0428/Python_IntroSU
/funtion.py
295
3.71875
4
def resta(): print("Hola como estan esto es un ejemplo de funciones") resta() def numero(): nu1=40 nu2=50 print(nu1+nu2) numero() def numero1(a,b): print(a*b) numero1(40052245524524,50045244524452455) def sume(x,y): result=x+y return result print(sume(2,3))
6e9d650ea8eef90eeb28ba047e30787c9c167647
Jaehoon-Cha-Data/ML
/prediction/Linear_regression.py
1,820
3.84375
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 25 23:00:20 2019 @author: jaehooncha @email: chajaehoon79@gmail.com Linear regression """ import numpy as np import pandas as pd from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt from sklearn.preprocessing import scale ### data load ###...
46c6960f1324763f4a77a8d6ffb73698b688357b
leowvazd/Python-Language
/Ex2.py
651
3.96875
4
# Sabe-se que um quilowatt de energia custa 1/500 avos do salrio mnimo. Faa um algoritmo que receba o valor do salrio mnimo e quantidade de quilowatts consumida por uma residncia. # Calcule e mostre: # - O valor, em reais, de cada quilowatt; # - O valor, em reais, da conta ser paga por essa residncia; # - O valor...
1f601ce1ff9a77bfe211d3dc526ea14db38d14c1
cjredmond/blackjack
/blackjack_game.py
5,039
3.84375
4
import random import time class Card: def __init__(self, suit, value): self.suit = suit self.value = value def show(self): print(self.value, self.suit) class Deck: def __init__(self): suits = ["diamonds", "hearts","clubs", "spades"] values = ["A",2,3,4,5,6,7,8,9,1...
d017f0bafbcd715af4813a7d80939f55acabd6a1
x4nth055/pythoncode-tutorials
/machine-learning/face_detection/face_detection.py
720
3.6875
4
import cv2 # loading the test image image = cv2.imread("kids.jpg") # converting to grayscale image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # initialize the face recognizer (default face haar cascade) face_cascade = cv2.CascadeClassifier("cascades/haarcascade_fontalface_default.xml") # detect all the faces i...
bf5ea92e49f8abfd78ba95a4a5d52f0ca34c8601
aaryanredkar/prog4everybody
/06 Conditionals/conditionals.py
257
3.625
4
def main(): v= '1' if v=='1': print(' v is 1') elif v== '2': print('v is 2') elif v=='3': print('v is 3') else: print('v is some other thing') if __name__ == "__main__": main()
20dbab678f85b9aa3f905027784759e15a9e6f86
Riley-Browne/Math_Quiz
/01_start_GUI.py
3,458
3.796875
4
from tkinter import * from functools import partial # To prevent unwanted windows import random class Start: def __init__(self, parent): # GUI Frame self.start_frame = Frame(padx=10, pady=10) self.start_frame.grid() # Buttons go here... button_font = "Arial 12 bold" ...
12811293b92fd75a4e83802f088cb933c27853b9
BasovAnton/pythonProject
/7.2.py
259
3.59375
4
if __name__ == "__main__": N = 64 rabbit_paws = 4 goose_paws = 2 max_rabbit = N//rabbit_paws for i in (range(1, max_rabbit)): rabbit = i goose = int((N - i*rabbit_paws)/goose_paws) print(f'{rabbit:^2}, {goose:^2}')
dd9fb2a9175c62f2e83f6f6b530ce1f703bf3708
jibinsmannapuzha765/Myproject
/PHYTON FILES/flow controls/exam %.py
253
3.84375
4
class1=int(input("Total Class:")) class2=int(input("Total Classes Attented:")) avg=(class2/class1)*100 print("Total Average of Attentence:",avg,"%") if (avg>=75): print("Student Can Attent The Exam") else: print("St\udent Can't Attent The Exam")
c74a448b4aae5cefa40b137b6d837ee5ff4da4fb
sagynangare/Python-Programming
/Pandas/abstractClass.py
251
3.609375
4
from abc import ABCMeta,abstractmethod class BaseClass(object): __metaclass__=ABCMeta @abstractmethod def printHam(self): pass class InClass(BaseClass): def printHam(self): print("Ham") x= InClass()
cb067443933ab3599e3a8fd36f8ccfabca2c6c6f
rasooll/Python-Learning
/mian-term/barname1.py
371
3.890625
4
# Type your code here def find_integer_with_most_divisors(input_list): mylist = [] len_list = int(len(input_list)) for i in range (0,len_list+1): count = 0 y = input_list[i] for x in range(1,y): if (input_list[i]%x) == 0: count = count + 1 mylist.append (count) return count test = [8, 12, 1...
a4d61fd62ba2aad5516e582a51e16a8c56964d89
jiadaizhao/LeetCode
/1101-1200/1154-Day of the Year/1154-Day of the Year.py
215
3.5
4
import datetime class Solution: def dayOfYear(self, date: str) -> int: year, month, day = map(int, date.split('-')) return (datetime.date(year, month, day) - datetime.date(year, 1, 1)).days + 1
b52e970b4a288c8fd75e82f016f41fd9f766bb54
Draymonder/Practices-on-Pyhton
/Day_6/button.py
552
3.578125
4
# -*- coding:UTF-8 -*- import pygame class Button(): def __init__(self, screen): self.screen = screen self.screen_rect = screen.get_rect() self.image = pygame.image.load('images/play.png') self.rect = self.image.get_rect() self.rect.centerx = self.screen_rect.centerx ...
34fcaf5475a43ea5ef8cd9cddabfe8e21e5e33bc
ArshNoman/VECLIP
/main.py
11,573
4.03125
4
# Very Easy Calculator Library In Python (VECLIP) from statistics import mode as m import math # -- Variables -- pi = 3.14159265359 phi = 1.618033988749895 eulars_number = 2.71828 wallis_constant = 2.094551481542326 # -- Basic operations -- 4 def add(number1, number2): if isinstance(number1 or number2, str): ...
1dce5cf4602e76ed5d78850a8378d805ad18d75e
ZsnnsZ/LeetCode
/insert_sort.py
621
3.796875
4
def insert_sort1(l): for i in range(1, len(l)): tmp = l[i] j = i - 1 # while j >= 0: # if l[j] > tmp: # l[j+1] = l[j] # l[j] = tmp # else: # break # j -= 1 # print l while j >= 0 and l[j] > tmp: l[j+1] = l[j] j -= 1 l[j+1] = tmp print l # for j in range(i, -1, -1): # if ...
b4305b8fbe2702b2d1d36704e39b8127cd7a8532
guihehans/self_improvement
/code_pattern/two_pointers/triplet_sum_close_to_target.py
2,191
4.40625
4
#!/usr/bin/env python # encoding: utf-8 """ @author: guihehans @file: triplet_sum_close_to_target.py @time: 2020/8/3 15:10 @function: Given an array of unsorted numbers and a target number, find a triplet in the array whose sum is as close to the target number as possible, return the sum of the triplet. If there are mo...
567bcff26c1d58f89c176a86d4943cd3f9f20449
chapman-cpsc-230/hw3-NicolayLamei
/turtlepoly.py
472
4.1875
4
num_sides = int (input ("Enter Number of Sides:")) side_len = int (input ("Enter the Length of Each Side:")) import turtle t = turtle.Pen() def draw_reg_polygon (t,num_sides,side_len): for i in range (num_sides): t.forward(side_len) t.left(360/num_sides) bob = turtle.Pen() #side = 10 for j in r...
ac903aaf355a47923054e85efab675c5901f363c
netor27/codefights-solutions
/interviewPractice/python/06_backtracking/05_combinationSum.py
1,617
4.03125
4
'''' Given an array of integers a and an integer sum, find all of the unique combinations in a that add up to sum. The same number from a can be used an unlimited number of times in a combination. Elements in a combination (a1 a2 … ak) must be sorted in non-descending order, while the combinations themselves must be so...
bfa940883b55ccf0cf958f869a8d96b98e01d321
phittawatch/6230401945-oop-labs
/Phittawat_6230401945-lab3/python3_problem10.py
364
4.1875
4
sum = 0 round = 0 while True: number = int(input("Enter an integers:")) if number >= 0: round += 1 sum = sum + number elif number < 0: if round == 0: print("You haven't entered a positive number") break elif round > 0: print("Av...
e4a31bcda6e728a07712f30a2ae99bcaccea6d94
Peaches491/CodeChallenge
/flight_path/simple.py
897
3.609375
4
#!/usr/bin/env python3 import numpy as np points = np.array([[0, 0], [0, 1.1], [1, 0], [1, 1]]) from scipy.spatial import Delaunay tri = Delaunay(points) # We can plot it: import matplotlib.pyplot as plt plt.triplot(points[:, 0], points[:, 1], tri.simplices.copy()) plt.plot(points[:, 0], points[:, 1], 'o') # plt.sh...
587f107ea0e855ec670306b1bb5bdf27083f3755
sundarsritharan/learning
/Python/hf_python/vowels7.py
209
4.25
4
vowels = set('aeiou') word = input("Enter a word to find it's vowels: ") found = {} #check if there are vowels in the given word found = vowels.intersection(set(word)) for letter in found: print(letter)
2f28840fd5642c2ce966358ee4be7c5d82507a2b
TejashwiniV/Python_Programs
/3b_PasswordGenerator.py
731
3.890625
4
import string import random def func(words): upper_case = [random.choice(string.ascii_uppercase) for upper in range(words)] lower_case = [random.choice(string.ascii_lowercase) for lower in range(words)] digits = [random.choice(string.digits) for dig in range(words)] special_characters = [random.choice(...
e110ba09000e344e65f9452ed97a05f1ddaba470
MalikaSajjad/SP
/Lab6/q7.py
289
3.84375
4
string = raw_input("enter string ") l = 0 d = 0 count = 0 print string while(count < len(string)): if(string[count].isalpha()): l = l+1 count = count + 1 elif(string[count].isdigit()): d = d+1 count = count + 1 else: count = count + 1 print "Letters ", l , "| Digits " , d
0ab31b5530c3eef71720e3060f9021432788bf06
OlgaLitv/Algorithms
/lesson3/task9.py
1,251
3.90625
4
""" Найти максимальный элемент среди минимальных элементов столбцов матрицы. """ from random import randint MAX_NUMBER = 100 matrixx = [] result_lst = [] m_size = randint(1, 7)#всего строк в матрице k_size = randint(2, 5)#всего столбцов в матрице for i in range(m_size): lst = [] for j in range(k_size): ...
79a710e89307661f01f31dce8844c34daddcd179
akhuh213/hangman-challenge
/hangman.py
2,007
3.84375
4
import random words = ['banana', 'tree', 'plate', 'mirror', 'chair'] # def shuffle(ls): # random.shuffle(ls) # return display_word(random_word) # print(shuffle(word)) def wrong_answer(count): if count == 1: print( "|-\ \n| 0 \n| \n| \n try again!") elif count == 2: print( "|-...
02a6f5b877709113eca74422670da94e8a483ca5
jesslam/reskill_americans
/conditionals.py
621
4.21875
4
# Conditionals """ age = -1 height = 6 if(age >= 18 and height > 5): print("This person can be admitted.") elif(age > 0 and age < 18 and height > 5): print("Sorry dude, try again when you're old enough.") else: print("You are not alive.") """ number = 15 if number > 10: print("Yes number is greater th...
7361fb5cd4ac43b8b9eb95b26b8ba3f7d15f4a58
rookieygl/LeetCode
/leet_code/lt_tiku/1143.longestCommonSubsequence.py
1,158
3.5625
4
""" 1143. 最长公共子序列 给定两个字符串 text1 和 text2,返回这两个字符串的最长 公共子序列 的长度。如果不存在 公共子序列 ,返回 0 。 一个字符串的 子序列 是指这样一个新的字符串:它是由原字符串在不改变字符的相对顺序的情况下删除某些字符(也可以不删除任何字符)后组成的新字符串。 例如,"ace" 是 "abcde" 的子序列,但 "aec" 不是 "abcde" 的子序列。 两个字符串的 公共子序列 是这两个字符串所共同拥有的子序列。 """ class Solution(object): def longestCommonSubsequence(self, text1, text2):...
2ba1e8675b0eb25af06683bf1d83a89608e78d71
MercyTrabe/Bootcamp-7
/day-4/super_sum.py
336
4.1875
4
def super_sum(*args): ''' Return a sum of numbers. e.g super_sum([1,2,3])==> 6 super_sum([1,2,3])==> 6 super_sum([10] [10,20,30])==>6 ''' total = 0 if not args: return 0 else: for x in args: if type(x)==list: total+=sum(x) elif type(x)==str: return 0 else: total+=x return ...
0a53a017052473982c30812fafcd1aed4c1b3b83
Aiooon/MyLeetcode
/python/offer_22_getKthFromEnd.py
1,563
4.03125
4
""" 剑指 Offer 22. 链表中倒数第k个节点 输入一个链表,输出该链表中倒数第k个节点。 为了符合大多数人的习惯,本题从 1 开始计数,即链表的尾节点是倒数第 1 个节点。 例如,一个链表有 6 个节点,从头节点开始,它们的值依次是 1、2、3、4、5、6。 这个链表的倒数第 3 个节点是值为 4 的节点。 示例: 给定一个链表: 1->2->3->4->5, 和 k = 2. 返回链表 4->5. date : 12-22-2020 """ # Definition for singly-linked list. from typing import Optional class ListNode: ...
c584d949d24151ba2130fabbdc73ff211176a33c
way2arun/datastructures_algorithms
/src/trees/buildTree.py
2,912
3.9375
4
""" Construct Binary Tree from Inorder and Postorder Traversal https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/547/week-4-july-22nd-july-28th/3403/ Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For examp...
c52d8bb10f63c215c18afd905eb6a474169295a6
eguyd/PythonNetworkUtilities
/ICMP.py
1,075
3.65625
4
""" Author: Guy D. Last Modified: 31 JUL 19 Program: Scan an entire subnet with Python using ICMP ECHO request to view live hosts. This sample code is provided for the purpose of illustration "AS IS" WITHOUT WARRANTY OF ANY KIND. """ import os import platform from datetime import datetime net = input("EN...
87bdc7b86886fe26ed1c626908a8d7b2f9713404
MaiadeOlive/Curso-Python3
/desafios-2mundo-36-71/D0060 Fatorial.py
251
4.0625
4
n = int(input('Digite um número para verificar seu fatorial: ')) c = n f = 1 print(f'Calculando fatorial do número {n}!') while c > 0: print(f'{c}', end='') print(' x 'if c > 1 else ' = ', end='') f *= c c -= 1 print(f'{f}')
fc715ec653742fe12059f05d1955c695ad884321
Sotonoke/-algoritmy
/lesson_1/tusk_5.py
265
3.890625
4
# 5. Пользователь вводит номер буквы в алфавите. Определить, какая это буква. n = int(input('Введите номер буквы в алфавите: ')) n = ord('a') + n - 1 print('Буква: ', chr(n))
737f4ac034d94ded14d60b86343b830466d76879
JesusFernandez1986/Python_clase1
/generadorPares_con_generadores.py
176
3.53125
4
def generadorPares(limite): num = 1 while num<limite: yield num*2 num+=1 devuelvePares = generadorPares(10) for x in devuelvePares: print(x)
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' ...
46132bf6d589de565212b6e76394473b18f2a588
melodyfs/Core-Data-Structures
/call_routing_project/routing.py
2,186
3.640625
4
import time class Routing: def __init__(self, cost_file, number_file=None): self.pricing = self.read_cost_file(cost_file) self.phone_nums = {} if number_file is not None: self.phone_nums = self.read_number_file(number_file) def read_cost_file(self, file_name): open...
74472d5b745ef8fe252393496d8dfb583f56a7e7
MilesShipman/Webb
/preference/sysInfo.py
1,647
3.5625
4
__author__ = 'milesshipman' import sys import platform import os class Session(): def __init__(self): """ This function establish the terminal's Location and other self contained data. """ print("Setting up the terminal Info") self.whereAmI = "" self.establishDefau...
d2734bff56a4cea580c6949f10e65b15077b2ada
apotree/Python
/Basic2.py
691
3.890625
4
letter = input("입력 : ") encode = "" for ch in letter: num = ord(ch) encode = encode + chr(num + 1) print("원문 :", letter) print("암호 :", encode) encode2 = "" for ch in encode: num = ord(ch) encode2 = encode2 + chr(num - 1) print("원문 :", encode2) #################################### let1 = "A" res1 ...
dbbbe2210c41442b575f2e539140a838b8e4eb32
webdevdream/learn_Python
/ex15.py
621
4.0625
4
# Import argv module from sys. from sys import argv # Specify the argv unpack variables script, filename = argv # Assign txt variable to open the file that have been choosed. txt = open(filename) # Print the file name. print ("Here is your file %r:" % filename) # Print the contents of the file. print (txt.read...
49349adcf15f88a3321306a3f23e2e2263cef591
EderLukas/python_portfolio
/us_states_game/main.py
1,443
3.96875
4
import turtle import pandas FONT = ("Arial", 8, "normal") # setup screen screen = turtle.Screen() screen.title("U.S. States Game") image = "blank_states_img.gif" screen.addshape(image) turtle.shape(image) # global Variables right_guessed_states = 0 data = pandas.read_csv("50_states.csv") correct_guesses = [] # game...
c683d6a69386aa34fb28f7a177d56db857503037
rafaelperazzo/programacao-web
/moodledata/vpl_data/7/usersdata/80/4470/submittedfiles/esferas.py
274
3.75
4
# -*- coding: utf-8 -*- from __future__ import division A=input('digite o peso da esfera 1:') B=input('digite o peso da esfera 2:') C=input('digite o peso da esfera 3:') D=input('digite o peso da esfera 4:') if A=B+C+D and D=B+C and B=C: print S else: print N
705a01e4d0d2483737fefa6024fe6479f1a31f93
JorijnInEemland/MyPythonProjects
/section06/lecture041.py
1,115
4.21875
4
# Simple function definition def name_of_function(argument): '''docstring exlaining the function''' print(f'do something here, perhaps using the {argument}') return "something, or don't" # Use help() to get the docstring help(name_of_function) # Default value for argument, return something def say_hello(n...
295e1575ac7660d0885fe3f9610680c6be48a2d2
Xelzus/Pythonlabs
/Pythonlabs/egomezvasque2013_lab05.py
1,261
3.84375
4
# Course: COP 4930 - Python Programming # Term: Fall 2015 - Dr. Clovis Tondo # Author: Esteban Gomez (egomezvasque2013) # Assignment #5- "lab05.py" # Due: September 30th, 2015 myDict={"\\A": "author", "\\B": "book", "\\J": "journal", "\\R": "article", "\\P": "publisher", "\\Y": "year" } #hardcoded keys that we ne...
631a6e3af90f8eb5d80c61be7bfafca70cfb8f76
talhahome/codewars
/int32_to_IPv4.py
963
3.890625
4
# Take the following IPv4 address: 128.32.10.1 # # This address has 4 octets where each octet is a single byte (or 8 bits). # # 1st octet 128 has the binary representation: 10000000 # 2nd octet 32 has the binary representation: 00100000 # 3rd octet 10 has the binary representation: 00001010 # 4th octet 1 has the binary...
3be60f9411417965a350b61820467efd66f59dec
bldulam1/python-algo
/linked_list.py
874
3.546875
4
class LLNode: def __init__(self, value, child): self.value = value self.child = child class LinkedList: def __init__(self, list): self.head = None list_len = len(list) for ind in range(list_len): ind = list_len - ind - 1 value = list[ind] ...
7612175bbd1dfd15ce51278dd541b08f64e4637a
Monata/CTCI_Python3_Solutions
/CTCI_solutions/1.1_IsUnique.py
1,089
4.09375
4
# Is Unique: Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? def is_unique_no_memory(inp): # for each char check if that character exists in the rest of the string n^2 for i in range(len(inp)): for j in range(i + 1, len(inp)...
3aaf14c2b11e702b77666d6c318480af03c7e8ab
Marlon-Poddalgoda/ICS3U-Unit3-03-Python
/guessing_game.py
667
4.1875
4
#!/usr/bin/env python3 # Created by Marlon Poddalgoda # Created on November 2020 # This program is a guessing game import random def main(): # this function compares a user input to a random number print("Today we will play a guessing game.") # random number generation random_number = random.randi...
386f7f8d977749508a419ed72df73738e52cb839
TheTagMen/thetagmen-workspace
/python/basic/multiplications.py
454
4.21875
4
#!/usr/bin/python3.7 # -*-coding:Utf-8 -* #Program objective : find if a year input by a user is a leap year nb = input("Entrez un chiffre") print(" 1 *", nb, "=", 1 * nb) print(" 2 *", nb, "=", 2 * nb) print(" 3 *", nb, "=", 3 * nb) print(" 4 *", nb, "=", 4 * nb) print(" 5 *", nb, "=", 5 * nb) print(" 6 *", nb, "=",...
5893da9ff5cf85684eea8714d6460537544c613f
doubleZ0108/my-python-study
/100Days/Review/6_2.py
1,051
3.5
4
from multiprocessing import Process,Lock from time import time, sleep from os import getpid from random import randint from threading import Thread class Account(object): def __init__(self): self._balance = 0 self._lock = Lock() @property def balance(self): return self._balance ...
64c2a72a5ea4b5ce8856af290d2dbe93c560b981
icenamor/wekaDomains
/readFolder.py
1,662
3.953125
4
import os import filecmp def dir_list(dir_name, subdir, args): '''Return a list of file names in directory 'dir_name' If 'subdir' is True, recursively access subdirectories under 'dir_name'. Additional arguments, if any, are file extensions to add to the list. Example usage: fileList = dir_list(r'...
c07a4ace9e9ad340936a4527275ce1f0bc54427c
chnlmy/python
/Part Three/Exp4.py
111
3.515625
4
i = 1 N = eval(input()) while 2*i-1 <= N: str1 = '*' * (2*i-1) print(str1.center(N, ' ')) i = i + 1
226b6f4e74b8ba06f7f844a86bfedacabcc7e47f
elemoine/adventofcode
/2020/day22/part1.py
1,191
3.5625
4
import collections def parse_cards(inputfile): with open(inputfile) as f: data = f.read() player1, player2 = data.split("\n\n") player1_deck = collections.deque() for line in player1.splitlines(): try: v = int(line.strip()) except Exception: v = None ...
430068b4a294095a40a252e02ebf72cc44752a48
Nekmo/micropython
/all_colors.py
545
3.9375
4
"""Ejemplo que teóricamente usa todos los colores para iluminar un led multicolor, pero no da suficiente tiempo a apreciar la variación, por lo que es mejor usar rainbow.py """ import machine red = machine.PWM(machine.Pin(12)) green = machine.PWM(machine.Pin(14)) blue = machine.PWM(machine.Pin(4)) red.freq(1000) green...
2e13092d5386ff5eb5661901a24b8266bec62dbe
LingHsiLiu/Algorithm1
/1. Hack the Algorithm Interview/627. Longest Palindrome.py
939
4.09375
4
# Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. # This is case sensitive, for example "Aa" is not considered a palindrome here. # Example # Given s = "abccccdd" return 7 # One longest palindrome that can be ...
7ed672fabe9ada3dd8be3df5a9d263bbdfb5f06a
chaudhary19/SDE-Interview-Problems
/CY_ArrayToBST.py
699
3.765625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def solve(self, start, end, nums): if start > end: return ...
9c0954fd60ae8b9153260d2628173863a02b1f39
fdima/GB-algAndStructData
/HW1/task6.py
1,057
4.1875
4
# По длинам трех отрезков, введенных пользователем, определить возможность существования треугольника, # составленного из этих отрезков. Если такой треугольник существует, то определить, является ли он # разносторонним, равнобедренным или равносторонним. input_str = input('Введите 3 длины отрезка через пробел: ') num...
2700c866d6513825ddbe418bbd84a9b69db99c5e
HugoTLR/Fun
/Anagram/anagram.py
843
3.8125
4
import string import sympy def generate_primes(): prime_list = [] i = 1 while len(prime_list) < 26: prime_list.append(sympy.nextprime(i)) i = prime_list[-1] return prime_list def score(w): score = BIND[w[0]] for c in w[1:]: score *= BIND[c] return score def is_anagram(w1,w2): w1 = "".join...
7b2143d56cc48ad17f5ee46b993cbff91fb48f92
YiwanFeng5/PythonSenior
/cn/fywspring/pythonsenior/regexdemo.py
3,740
3.9375
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- ''' Created on 2017年11月10日 Python中正则的使用,re模块 @author: Yiwan ''' # re.match(pattern,string,flags=0) # 参数 描述 # pattern 匹配的正则表达式 # string 要匹配的字符串。 # flags 标志位,用于控制正则表达式的匹配方式,如:是否区分大小写,多行匹配等等。 # 匹配成功re.match方法返回一个匹配的对象,否则返回None。 # 我们可以使用group(num) 或 g...
ac666ca12571d5f8682d6a29d189c59cc68c0a2c
sharmasourab93/CodeDaily
/DataStructures/Search&Sort/Sorting/selection_sort.py
718
4.3125
4
""" Python : Selection Sort Worst-case performance: О(n^2) comparisons, О(n) swaps Best-case performance: О(n^2) comparisons, О(n) swaps Average performance: О(n^2) comparisons, О(n) swaps Worst-case space complexity: O(1) auxiliary """ def print_array(array): for i in array:...
5f0f4e954bdc91c1d0b302cdd2aebba4960b2e2a
madhavGSU/Data_Programming
/Assignment_1/chapter4_21.py
547
4
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 26 17:16:48 2020 @author: Administrator """ year=eval(input("Enter the year: ")); month=eval(input("Enter the month with values between 1 and 12: ")); day=eval(input("Day of the month: ")); if(month<=2): month+=12; year-=1; century=year//100; yearOfCentury=year%...
9396aeb1700776f9d38bb4bc5da87b3aff2ee847
kristinyu/kris-python
/kris_python/thread/Time.py
287
3.765625
4
import time print("current time",time.localtime(time.time())) print("current format time",time.asctime(time.localtime(time.time()))) print(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())) a = "Sat Mar 28 22:24:24 2016" # print(time.mktime(time.strftime(a,"%a %b %d %H:%M:%S %Y")))
f6f3b49bac0ded4c0b23fa940ac5341bb189575c
mounicat/Statistics
/Confidence interval/ci.py
1,333
4.03125
4
#calculating confidence interval when population standard deviation is known import scipy.stats as stats import numpy import matplotlib.pyplot as plt import random import math def confidence_interval(population,sample_size): std_dev_pop = round(numpy.std(population),2) #print numpy.mean(population) sampl...
b53ae38d12114a3339dabfcf28370dfa48043467
ravikishorethella/Algo_Practice
/Sliding Window/longest_substr_without_repeating_chars.py
447
3.796875
4
''' Given a string, find the longest substr without repeating characters ''' # time - O(n) - one pass # space - O(m) - m distinct chars def longest_substr_without_rep_chars(s): start = 0 end = 0 count = 0 store = {} while end < len(s): if s[end] in store and d[s[end]] >= start: ...
85fbd9d634798d7c63d22b6542701ad39a42f41b
rhflocef521/myproject
/practice/demo2.py
848
3.796875
4
if __name__ == '__main__': # 创建列表Klist klist = ["good ", "good ", "study", " good ", "good", "study ", "good ", " good", " study", " good ", "good", " study ", "good ", "good ", "study", " day ", "day", " up", " day ", "day", " up", ...