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
d2d7443216488c3ef68a9f548867149f58da6b9c
Zippycz3ch/Python
/mileage.py
123
3.9375
4
print("How many kms?") kms = input() miles = float(kms)/1.60934 miles = round(miles, 2) print(f"Ok you said {miles} miles")
ec33fb5d8ababf0c7fce472b7981f59ab92be799
ShreeyaVenneti/TileDuo
/TileDuo.py
45,886
3.59375
4
#Importing tkinter under an alias (a much shorter name) called tk import tkinter as tk from tkinter import font as tkfont import random from tkinter import messagebox, PhotoImage,Menu,ttk import time import pygame class InitializeGame(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk...
7f4466ac9611b2f74825b3f71a8912d0bb3f9629
Gunasekaran-Annamalai/number-series-problem-python
/first-series.py
118
3.84375
4
user_input = int(input("Enter the limit: ")) for i in range(1, user_input+1): print("{} {}".format(i, i), end=' ')
a46fda6d8fed1cfebedb60788226c1ab95b076d5
AswinP2711/Python_Programs
/CO1/20.py
287
4
4
limit=int(input("Enter the limit : ")) list1=[] list2=[] for x in range(0,limit): item=int(input("Enter the integer : ")) list1.append(item) for i in list1: if i%2!=0: list2.append(i) print("The complete list is :",list1) print("The list after removing even number is :",list2)
21a996276aa81fef359e4bfaac514452344b27da
AswinP2711/Python_Programs
/CO1/6.py
133
3.5
4
nameList = ["aswin", "dilshad", "vyshak", "midhun","a"] count=0 for ele in nameList: if ele == "a": count=count+1 print(count)
7804532b391fe43fc82acd7a3ec0e8164b758671
AswinP2711/Python_Programs
/CO1/4.py
194
3.875
4
s = str(input("Enter a line of text : ")) counts = dict() words = s.split() for word in words: if word in counts: counts[word] += 1 else: counts[word] = 1 print(counts)
7973db13efeed966c8f504881bf2ae13581cf664
AswinP2711/Python_Programs
/CO1/7.py
1,112
3.828125
4
limit1 = int(input("Enter the limit for list 1 : ")) limit2 = int(input("Enter the limit for list 2 : ")) list1 = [] list2 = [] sum1 = 0 sum2 = 0 result = 0 for x in range(0, limit1): item1 = int(input("Enter the item for list 1 : ")) list1.append(item1) for y in range(0, limit2): item2 = int(input("Enter...
bde97dc1a8252c188d7af57e916e794b2f5ec661
Hyjj92/final_exam
/day04_re.py
2,018
3.640625
4
import re """ re.compile 用于编译正则表达式,生成一个正则表达式( Pattern )对象, re_basics(): re_function() re_split() re_ chinese() """ def re_basics(): one = "masdfghn12345n" #贪婪模式 默认 #. 任意 * 任意次 pattern = re.compile('m(.*)n') result = pattern.findall(one) print(result) pattern = re.com...
a30bd99e44e61f3223dfa2ba64adb89dc19ad0b2
Debu381/Conditional-Statement-Python-Program
/Conditional Statement Python Program/Guss.py
213
4.125
4
#write a python program to guess a number between 1 to 9 import random target_num, guess_num=random.randint(1,10), 0 while target_num !=guess_num: guess_num=int(input('Guess a number')) print('Well guessed')
42c7615eccd735b48b865ab84585b4cb4ca19a61
weed478/kolosy
/20 21 pt 1/zad1.py
779
3.640625
4
# Jakub Karbowski """ Probujemy wszystkie podciagi dlugosci 1 do len / 2 + 1. Przechodzimy przez reszte napisu sprawdzajac cyklicznosc znakow Szukamy najdluzszego """ def multi(T): max_len = 0 for text in T: for i in range(1, len(text) // 2 + 1): if len(text) % i != 0: # w...
3b3e5550904678240c31eb7b99282f4bf9c203f5
BurningBagel/TCCSimulator
/supFunc.py
238
3.5625
4
from statistics import stdev def avg(lst): return sum(lst)/len(lst) def normalize(lst): average = avg(lst) result = [] dev = stdev(lst) for item in lst: result.append((item-average)/dev) return result
6962a8e1456c1bf2ac90cf0a38d5c37149e02c48
kvolanski/provaPython
/venv/calculadora.py
1,060
3.890625
4
def soma(x,y): soma = x + y texto = "Você somou " + str(x) + " + " + str(y) + " e deu " + str(soma) print(texto) validaPar(soma,texto) def subtracao(x,y): subtracao = x - y texto = "Você subtraiu " + str(x) + " - " + str(y) + " e deu " + str(subtracao) print(texto) validaPar(subtracao,t...
e4167679420c18bb515caa60c0d3470ddd1a8923
KelvinUbaechu/PokerProject
/PokerConcepts/cards.py
1,988
3.609375
4
from enum import Enum class Face(Enum): TWO = 2 THREE = 3 FOUR = 4 FIVE = 5 SIX = 6 SEVEN = 7 EIGHT = 8 NINE = 9 TEN = 10 JACK = 11 QUEEN = 12 KING = 13 ACE = 14 class Suit(Enum): SPADES = 0 HEARTS = 1 CLOVERS = 2 DIAMONDS = 3 MIN_VALUE = min(face.value for face in Face) MAX_VALUE = max(face.value f...
b6ace974b9b55f653fe3c45d35a1c76fd3322f7e
lucasloo/leetcodepy
/solutions/36ValidSudoku.py
1,530
4.1875
4
# Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. # The Sudoku board could be partially filled, where empty cells are filled with the character '.'. # A partially filled sudoku which is valid. # Note: # A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled ce...
a0ceff07ec709c9c52bea130d2f7777421d78e42
lucasloo/leetcodepy
/solutions/137SingleNumberII.py
641
3.59375
4
# Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. class Solution: def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ a = set() b = set() for i in nums: ...
f00a5031cf1842e56761cbf3dde15b600a66bef1
lucasloo/leetcodepy
/solutions/120Triangle.py
1,436
3.84375
4
# Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. # For example, given the following triangle # [ # [2], # [3,4], # [6,5,7], # [4,1,8,3] # ] # The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). # Note: ...
bc227f4ff6fcca78d4d89b3367093167248c3bec
lucasloo/leetcodepy
/solutions/2AddTwoNumber.py
1,865
3.828125
4
# You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. # You may assume the two numbers do not contain any leading zero, except the number 0 itself. # ...
69458fb5c3d47fde737571bb97b463053d665c75
lucasloo/leetcodepy
/solutions/16ThreeSumClosest.py
1,385
3.71875
4
# Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. # For example, given array S = {-1 2 1 -4}, and target = 1. # The sum that is closest to the ...
d64b86bb12266e2471a290fe1f59677fd7badaea
lucasloo/leetcodepy
/solutions/25ReverseNodesInKGroup.py
2,834
4.03125
4
# Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. # k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. # You may not alter the values...
cac0eae2f7a55bdad2cb15cd4004f68d2a24ec2f
lucasloo/leetcodepy
/solutions/53MaximumSubarray.py
1,260
3.8125
4
# Find the contiguous subarray within an array (containing at least one number) which has the largest sum. # For example, given the array [-2,1,-3,4,-1,2,1,-5,4], # the contiguous subarray [4,-1,2,1] has the largest sum = 6. class Solution: def maxSubArray(self, nums): """ :type nums: List[int] ...
32d426156be840656a73e4bb40f85c0d6472ffc6
lucasloo/leetcodepy
/solutions/50PowXN.py
1,281
3.921875
4
# Implement pow(x, n). # Example 1: # Input: 2.00000, 10 # Output: 1024.00000 # Example 2: # Input: 2.10000, 3 # Output: 9.26100 class Solution: def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ return x ** n # after reading the discuss pa...
98c092348ce916622847924b48967ef75ce99d9e
SaralKumarKaviti/Problem-Solving-in-Python
/Day-3/unit_convert.py
1,738
4.25
4
print("Select your respective units...") print("1.centimetre") print("2.metre") print("3.millimetre") print("4.kilometre") choice= input("Enter choice(1/2/3/4)" unit1=input("Enter units from converting:") unit2=input("Enter units to coverting:") number=float(input("Enter value:")) if choice == '1': if unit1 == 'c...
e5988c8143563ae719d65dd3664093000db62776
hereTJZ/PythonProject
/weiboSpider/threadTest.py
1,674
3.921875
4
import threading import time # 继承父类threading.Thread,定义带返回值的线程类 class MyThread(threading.Thread): # Python的’构造函数‘,自由添加需要的参数 def __init__(self, threadID, name, delay): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.delay = delay # 把要执行的代码写到run...
e53487e70d54fe79499a9afba5cbc82a520bd2b3
ClaudiaSianga/Python-para-Zumbis
/Lista1/exercicio1_guilhermelouro_10.py
581
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Escreva um programa para calcular a redução do tempo de vida de um fumante. Pergunte a quantidade de cigarros fumados por dia e quantos anos ele já fumou. Considere que um fumante perde 10 minutos de vida a cada cigarro, calcule quantos dias de vida um fumante perderá...
e49dd0973443fb86684f5ef112091382d7afa607
ClaudiaSianga/Python-para-Zumbis
/Lista3/exercicio03_guilhermelouro_01.py
404
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Faça um programa que peça uma nota, entre zero e dez. Mostre uma mensagem caso o valor seja inválido e continue pedindo até que o usuário informe um valor válido. """ nota = "" while nota < 0 or nota > 10: nota = float(input("Digite uma nota de 0 a 10: ")) print "...
220cb72b0958c8ec75d43fce60110d783953643e
ClaudiaSianga/Python-para-Zumbis
/Lista4/exercicio04_guilhermelouro_02.py
495
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Sorteie 20 inteiros entre 1 e 100 numa lista. Armazene os números pares na lista PAR e os números ímpares na lista IMPAR. Imprima as três listas. """ import random lista = [] par = [] impar = [] for i in range(20): n = random.randint(1,100) lista.append(n) if ...
325f58b0fba930f472cd2445d775886daa8d7ad8
vidyavathibm/Python_solutions
/day01/pr02.py
1,225
3.796875
4
# a=int(input("Enter")); # b=input(); #print(a+b); # # print(int(a)+int(b)) # a=input("Enter"); # print(a); #print(int(input())+int(input())) # # a=1; # b=2; # print(a+b); # a=2 # b=12 # print(a+b) # # # a=[1,2,3] # b=[3,4,6] # a.append(b) # print(a) # print(a.pop()) # print(a.pop()) # print(a.extend(b)) # list2=[] str...
264d7e6f6eedc457439689e4e196758591eadc47
Endjy/word_test
/word_test.py
1,459
3.703125
4
import random import copy def read_file(file): with open(file,'r') as fp: line = fp.readline() count=1 while line: try: word,meaning=line.split(' ') meaning,less=meaning.split('\n') word_dict.append((...
1f31f6d85d4bd2e9b1f849d303961ba36353b0e9
suma619/mywork
/work/gui.py
2,075
3.53125
4
from tkinter import * import random import string import ctypes def run_on_click(): user_input = var1.get() #print(user_input) #var.set("") #label = Label(root, text=user_input,bg="red",width="100").grid(row=4) if user_input==rand: import os root.destroy() & os.system('python hel.pyw') ...
2d082dda2f464f6da9d9a043a90ca7599a4b92bd
anikanastarin/Learning-python
/Homework session 4.py
1,516
4.375
4
'''#1. Write a function to print out numbers in a range.Input = my_range(2, 6)Output = 2, 3, 4, 5, 6 def my_range(a,b): for c in range(a,b+1): print (c) my_range(2,6) #2. Now make a default parameter for “difference” in the previous function and set it to 1. When the difference value is passed, the d...
6ae607ac50b7fe370e6257fd083fc369a5ac7a14
Dcnqukin/A_Byte_of_Python
/while.py
383
4.15625
4
number=23 running=True while running: guess=int(input("Enter an integer:")) if guess==number: print("Congratulation, you guessd it.") running=False #this causes the while loop to stop elif guess<number: print("No, it is a little higher") else: print("No, it is a little l...
aa0a8a1051ca82ce705b489b41091b5c17653de9
judelhaye/pygano
/pygano
2,407
3.859375
4
#!/usr/bin/env python3 # coding: utf-8 import sys import argparse from PIL import Image def encode_image(file, text): """ Use the red value to store a text into the image. Limited to 255 caracter as it stores an index in the first pixel. """ if len(text) > 255 : print("Cannot accept a te...
a8c88870cde72c157873383e5a85229568907ac1
voidStuffedPotato/MIREA-crypt
/src/lib/common.py
1,956
3.96875
4
"""Содержит общие функции для криптографических алгоритмов""" import random class CryptError(Exception): """Базовое исключение модуля""" def is_prime(n: int) -> bool: """Проверяет n на простоту. Аргументы: n: проверяемое число. Возвращает: True, если число простое, иначе False. ...
1a67c9f2d197aefaf4f69122c44d64e6a8e99ef9
pyunixdevops/scripts
/Python/Python_Class/example1.py
161
3.671875
4
def add_diff(n1, n2): #print("addition of two nums", n1 + n2) #print("difference of two nums", n1 - n2) return (n1+n2, n1-n2) print(add_diff(10,5))
74371499ba40af14e6c6f679ea7020c824b601f8
pyunixdevops/scripts
/Python/reduced_string.py
415
3.875
4
#!/usr/bin/python3 import sys import re def super_reduced_string(s): # Complete this function regex=re.compile(r'(\w)(\1)') reg=regex.search(s) while reg: s=s.replace(reg.group(), '') reg=regex.search(s) #print(s if s else 'Empty String') return s if s else 'Empty String' prin...
ab155f14cdadd65b9d65e101ae98270d36f83688
nisha2488/DataScience-Projects
/Natural Language Processor/pos_solver.py
32,859
3.5
4
################################### # CS B551 Fall 2016, Assignment #3 # # Your names and user ids: # # (Based on skeleton code by D. Crandall) # # #### ''' 1. Abstraction: For this problem, we have taken - (i) Words (W) in the sentence as observed states (ii) Corresponding part of speech (S) as the hidden states For e...
60572eb06d25e226914087a975b24f23566db347
ztong001/TwitterFYP
/importjson.py
1,074
3.578125
4
"""Miscellanous scripts for data migrations across formats""" import sqlite3 import os import csv import json import setup def import_file_to_db(input_file): """Json/CSV/Txt files to DB""" ext = os.path.splitext(input_file)[-1].lower() with open(input_file, 'r', newline='\r\n', encoding='utf8') as content...
acf1dd2338c64a1118e7efadae4041668cb7bf7c
Aman-B/k-means
/kmeans.py
4,670
3.765625
4
from __future__ import division #import sys for exceptions import sys import math #class for initializing values provided by user input: class Create_list: def __init__(self,x,y): self.x=x self.y=y def get_coord(self): return self.x,self.y def set_x(self,x): self.x=x def set_y(self,y): self.y=y ...
b140dcdb3e5296c8534ddc95170112bd7e2e2296
wudanny/BoggleSolver
/python/trie.py
1,528
3.984375
4
class TrieNode: #Trie node data structure def __init__(self): self.prefix=0 self.word=0 self.paths={} class Trie: #Trie Tree def __init__(self): self.head=TrieNode() def add(self, word): #add a word to the Trie word=word.lower() self.addToTrie(word, self.head) def addToTrie(self, word, no...
bb0d629d392d9c5762bd8a90d91cd4b3cbf81988
MUKESHkUMAR2617/speechRecoginition
/sub.py
90
3.6875
4
a=int(input("enter the no")) b=int(input("enter the second no")) sub=a-b print("sub:",sub)
b5cf0e1ec9d8ad7f5f60e89891ee08ef6e3bc6f9
marieramsay/IT-1113
/Miles_To_Kilometers_Converter.py
2,618
4.5625
5
# Marie Ramsay # Prompts the user to select whether they want to convert Miles-to-Kilometers or Kilometers-to-Miles, then asks the user # to enter the distance they wish to convert. Program converts value to the desired unit. # Program will loop 15x. import sys # converts input from miles to kilometers def...
edd084878e233c3f0f0604aaf19dd128a902fb30
EvanRussellTheCoder/BadBunnies
/main.py
15,551
3.734375
4
import random import math import pygame pygame.init() winW = 400 winH = 400 window = pygame.display.set_mode((winW, winH)) pygame.display.set_caption("Bad Bunny") currentScene = 0 # randomizes bunny spawn after clicked rNum = round(random.randint(0, 3)) stillPlaying = False # keeps track of level/di...
e07ac75e79a257241d4a467320e113247db4df8b
calebwest/OpticsPrograms
/Computer_Problem_2.py
2,211
4.40625
4
# AUTHOR: Caleb Hoffman # CLASS: Optics and Photonics # ASSIGNMENT: Computer Problem 2 # REMARKS: Enter a value for the incident angle on a thin lens of 2.0cm, and # the focal length. A plot will open in a seperate window, which will display # light striking a thin lens, and the resulting output rays. This program use...
3f7bc2ec8a70238209084fbb0d79b37700c5e776
KSB2003/Summer
/SUMMER2021 - TUTION/datastructuresandalgorithms/sorting/MergeSort.py
1,712
3.546875
4
""" Merge sort: Divide and conquer type algo. [9, 1, 3, 6, 5, 0, 8] [9, 1, 3, 6, 5, 0, 8] - list divided into sublists: [9, 1, 3] and [6, 5, 0, 8] [2, 4, 12] and [1, 8, 9, 11] [[3], [2], [5], [4]] [[2, 3], [2], [4, 5], [4]] [ """ def minlist(x): min = (2**31)-1 for i in range(0, len(x)): if x...
18e6b7de5e4fec281a76e64069f760c55a6be2fd
KSB2003/Summer
/SUMMER2021 - TUTION/datastructuresandalgorithms/RecursiveAlgorithms/BooleanRecursion.py
652
3.96875
4
""" - take in a list of booleans - return true if all of the elements are true - else return false HW: - given a list of integers such that all numbers except for a particular number occur in pair, write a recursive function to return the number that occurs only once. hint: XOR gate - associative prope...
54a9ba49ab6d55cb8fbc0986f591ca430dc4fa7b
KSB2003/Summer
/SUMMER2021 - TUTION/Practice questions/non-divisible subset.py
964
3.53125
4
""" create the largest subset such that all paired sum of numbers is not divisible by k """ def factorial(n): product = 1 for i in range(1, n+1): product*=i return product def combination(n, r): answer = factorial(n)/(factorial(n-r)*factorial(r)) return int(answer) def finalfunction(...
9141377d706e71446f9c59592e3f48a3e5248f9c
Hayfever3041/tic-tac-toe
/tic-tac-toe.py
6,563
4
4
# tic-tac-toe.py def start(): print(''' Welcome to tic-tac-toe. You will be playing against a human opponent. The coordinate should be entered as letter and then number: Ex. a1, b3, c2 Good luck. ''') def player_input_func(cb): while True: player_input = input('Where would you like to go?: ') ...
b9743571fc8bb451c552bf93a8dfcc615c21dd74
invokerkael918/DFS
/Permutations II.py
863
3.640625
4
class Solution: """ @param: : A list of integers @return: A list of unique permutations """ def permuteUnique(self, nums): # write your code here if len(nums) == 0: return [[]] nums.sort() result = [] visit = [False] * len(nums) self.dfs(...
74caf241f79e757f7ea385d55da2c37bc0a46460
invokerkael918/DFS
/Binary Tree Path Sum.py
643
3.78125
4
class Solution: """ @param: root: the root of binary tree @param: target: An integer @return: all valid paths """ def binaryTreePathSum(self, root, target): result = [] path = [] self.dfs(root,target,result,path) return result def dfs(self,node,target,result,...
29582255ca2613027082996c5c4fb2eacfff5293
rocallaghan/2018_SOFT8033_SDH4_A01_RichardOCallaghan
/Hint 1/my_mapper.py
3,832
4.09375
4
#!/usr/bin/python # -------------------------------------------------------- # PYTHON PROGRAM # Here is where we are going to define our set of... # - Imports # - Global Variables # - Functions # ...to achieve the functionality required. # When executing > python 'this_file'.py in a terminal, # the Python in...
f2efa33150f6836c415dce747aebc0640b053dfe
matdomis/OBI
/2016/pokemon.py
380
3.84375
4
doces = int(input()) pok1 = int(input()) pok2 = int(input()) pok3 = int(input()) if pok1 + pok2 + pok3 <= doces: print("3") elif pok1 + pok2 <= doces: print("2") elif pok1 + pok3 <= doces: print("2") elif pok2 + pok3 <= doces: print("2") elif pok1 <= doces: print("1") elif pok2 <= doces: print("1")...
2a2c379b0b39a94f285a14fdd3ea4c3c26b73779
rahulmahajann/leetcode
/interview-bit/large_factorial.py
152
3.609375
4
def fact(A): ans=1 if(A==0): return 1 else: for _ in range(1,A+1): ans=ans*_ return ans print(fact(6))
820a96956c234eef09925bb18b1f80e0fb7c8ae9
rahulmahajann/leetcode
/interview-bit/trailing_zeroes_bi.py
267
3.53125
4
A=8 ans=[] def DecimalToBinary(num): if num >= 1: DecimalToBinary(num // 2) ans.append(str(num%2)) return ans a=DecimalToBinary(A) # print(a) a.reverse() count=0 for _ in a: if(_=='1'): break else: count+=1 print(count)
2bc749af2d1292c011628e9bfdbe7f84bfc3a03d
rahulmahajann/leetcode
/interview-bit/distribute_in_circle.py
128
3.65625
4
A=8 B=5 C=2 if(A<=B-C+1): print(A+C-1) else: A=A-(B-C+1) if(A%B)==0: print(B) else: print(A%B)
b0fb71c5bc8a77630bfe2dabaef356bf53217993
psteinhoff/postptv
/flowtracks/graphics.py
4,514
3.921875
4
# -*- coding: utf-8 -*- """ Various specialized graphing routines collected from scripts that do the same thing for different data. Created on Sun Sep 22 16:11:34 2013 @author: yosef """ import numpy as np, matplotlib.pyplot as pl def pdf_bins(data, num_bins, log_bins=False): """ Generate a PDF of the give...
7288ee4ee751868310c34c41a419ddfde0cff2f2
MrLayr/Project_of_Euler
/Multiples of 3_5.py
253
3.71875
4
numbers = [i for i in range(1001)] # Все числа до 1000 кратные 3 или 5 right_numbers = [] for j in numbers: if j != 0 and (j % 3 == 0 or j % 5 == 0): right_numbers.append(j) print(right_numbers) print(len(right_numbers))
756a096e6c156f1f5be7347067903a3135008535
22fansje/python
/modb_challenge.py
1,034
4.21875
4
def main(): #Get's info on the user's name than greets them first_name = input("What is your first name?: ") last_name = input("What is your last name?: ") print("Hello, %s %s!"%(first_name,last_name)) print() #Lists the foods avaliable food = ['Cookie', 'Steak', 'Ice cream', 'Apples'] ...
f3978516cdb133936e3aebd5c989f2fdd0269bac
yemo06/HackerRankSoultions
/CodeSignal Solutions/countSubstring.py
203
3.78125
4
def count_substring(string, sub_string): counter = 0 for i, letters in enumerate(string): if sub_string in string [i: i + len(sub_string)]: counter +=1 return counter
2e60a127700fe29ea3a7404450399c698c4a9e23
yemo06/HackerRankSoultions
/CodeSignal Solutions/firstDuplicate.py
1,096
3.921875
4
#Given an array a that contains only numbers in the range from 1 to a.length, # find the first duplicate number for which the second occurrence has the minimal index. # In other words, if there are more than 1 duplicated numbers, # return the number for which the second occurrence has a smaller index than the sec...
8cebc60a7b450e773f6e4b1cea615534e0f69c22
Albert-Hu/leetcode
/solutions/1-50/1/generate_test.py
1,407
3.65625
4
from __future__ import print_function import random ''' The inputs are repeating by: 1. Target 2. Numbers 3. Answer ''' def dump_test(test): print(str(test[0])) print(' '.join([str(n) for n in test[1]])) print('{} {}'.format(test[2][0], test[2][1])) def generate_test(start=-1e9, end=1e9, amount=100): array ...
7f6071b0aa4ea291a567a7f766ffaef00349e373
geronimo0630/2021
/clases/operaciones.py
683
4.15625
4
# se utilizan dos int y se les da un valor designado numeroA = 87 numeroB = 83 #se suman los int sumar = numeroA + numeroB #pone en pantalla el resultado print ("el resultado es", sumar) #se restan los int restar = numeroA - numeroB #pone en pantalla el resultado print ("el resultado es ",restar) #se multiplican lo...
7ca74d663b669275afcd601c49ea434b9e893f1a
geronimo0630/2021
/talleres/tallerclaseobjetos.py
1,821
3.65625
4
#punto 1 class Torta (): def _init_(self,saborentrada,fromaentrada,alturaentrada): self.sabor = saborentrada self.forma = fromaentrada self.altura = alturaentrada def atributos (self): print(f'hola.mi sabor es {self.sabor} y mi forma es {self.forma} y pot ultimo tngo una altura...
7a3e9fcd876c6642099f2a9465698f0b2f786637
geronimo0630/2021
/Parciales/final2021.py
529
3.640625
4
#punto 1 import matplotlib.pyplot as plt listaalimentosfav = [] listaprecios = [] for i in range (8): elemento = input('ingrese 8 alimentos favoritos: ') listaalimentosfav.append(elemento) for i in range (8): elemento = float (input('ingrese los precios de cada comida puesta: ')) listaprecios.append(el...
0b403aaa024cd51246c2c897e308e78a6620e450
geronimo0630/2021
/clases/edad.py
468
3.703125
4
#---- entradas ----# MENSAJE_BIENVENIDA = "AVERIGUAREMOS SI ERES MAYOR DE EDAD" MENSAJE_MAYYOR_EDAD = "eres mayor de edad" MENSAJE_MENOR_DE_EDAD = "eres menor de edad no puedes seguir " PREGUNTA_EDAD = "cuantos años tienes " #----entrada al codigo----# print (MENSAJE_BIENVENIDA) edad = int (input (PREGUNTA_EDAD)) isma...
496866c28b68c379dffea41e50a2f50c0bb356c7
Dcbaas/neon-souls-game
/neon-souls/actors/animation.py
3,517
3.71875
4
import pygame """ Holds a collection of sprite managing classes that allow for an actor to have dynamic sprites based on thier situation Author: David Baas Date: 2/22/2020 """ class AnimatedSpriteBase: """ Base class of all animated sprites. Holds a single sprite for a static actor """ def __init__...
244b1261371b22b2bd6ea56289da0ac9c9e20922
Hernandezjose2000/PRIMER_PARCIAL
/107411 - Hernandez, Jose - E3.py
6,140
3.875
4
def menu() ->int: opciones = ["Nueva carga de disciplina", "Armar medallero olimpico", "Pais con mas records mundiales", "Top 5 paises que mas veces subieron al podio", "Distribucion de medallas por pais"] for opcion in range(len(opciones)): print(f"{opcion+1}){opciones[opcion]}")...
49a171f91070d47439089abdcc9b3fa2f7a0de95
RunnerMom/oop_lesson
/game.py
10,912
3.75
4
# Bessie, Gowri & Julie #For Tomorrow: #Look at the engine file and make the screen bigger # done. Modified screen size at the top of engine.py #Message if you get to the door without key or power # done # show a bunch of hearts (non-solid) if you kiss the boy # added one heart # make a new room if you ope...
2ef3bd06a76b4b37a77aa9380124c27e53a106fa
ukachyuthan/RL-Course_Projects
/Blackjack_ CliffWalking/BlackJack/mc.py
6,661
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as np import random from collections import defaultdict #------------------------------------------------------------------------- ''' Monte-Carlo In this problem, you will implememnt an AI player for Blackjack. The main goal of this problem is to ...
8af779d96ca48e773b45ad883834f927348ae7f1
TeaaPartyy/basicProjectsAndGuides
/SudokuGame-master/simple_board.py
4,360
4.5
4
#Created by Hamza Slaoui Habib #Program that simulates the sudoku game and finds a solution for it #objectives: Learn and apply Backtracking Algorithm, as well as pygame #Algorithm to solve sudoku # 1 - Find empty spot(in this case a 0) # 2- Fill it with a nummber (1-9) # 3- Check if the number is valid in th...
6fd29cfa6d3667c2316c0322e35451ee9bfeefc2
dwlovelife/Python-Note
/code/basic/day05/test02.py
249
4.1875
4
def factorial(num): """ 求阶乘 """ result = 1 for x in range(1, num + 1): result *= x return result m = int(input("请输入m:")) n = int(input("请输入n:")) print(factorial(m)//factorial(n)//(factorial(m - n)))
e4d5f4f8a308eafeb60d6694b18b582d7c108c2e
dwlovelife/Python-Note
/code/basic/day07/test01.py
405
3.9375
4
""" 使用字符串或者常用数据结构 """ def main(): str = " hello world " #通过len计算字符串的长度 print(len(str)) #去除字符串两边的空格 print(str.strip()) str2 = "abc1234" print(str2[2]) print(str2[::-1]) print(str2[:3:-1]) #检查字符串是否由数字构成 print(str2.isdigit()) if __name__ == '__main__': main()
acf5f7ff2b563f54375c5dbfeb24294d6673f2f8
dwlovelife/Python-Note
/code/basic/day07/test04.py
262
4.15625
4
""" 集合切片 """ def main(): list = [1, 2, 3, 4] list.append(5) for x in list: print(x, end = " ") print() list2 = list[2:4] print(list2) list3 = list[::-1] print(list3) if __name__ == "__main__": main()
7beab14147e052c87b7069a3481272884408d549
Eduildo/Base-python
/gestion_etudiant/Modules/models.py
695
3.625
4
""" Python et la POO """ from enum import Enum from abc import ABC, abstractmethod class TypeEvaluation(Enum): CONTROLE = 1 EXAMEN = 2 class Module: """ Permet de mémoriser les informations sur un module """ def __init__(self, id=None, nom_module=None, volume_horaire=None, coefficient=None): ...
68ce2be1b50ea8bae525cbcfc24880497f37a4f4
ungerer-ricardo/py_challenge
/5.py
165
3.515625
4
import pickle file_obj = open( "5.obj", "r") obj = pickle.load(file_obj) for line in obj: for chars in line: print chars[0]*(chars[1]-1), print;
3772507c6b75d992c820233d608ea121dc818464
YUKalabin/NetPython
/Lesson2.py
177
4.03125
4
name = input('Input name: ') if name.startswith('Y'): print('startswith Y') elif name.endswith("a"): print('endswith a') else: print('Better input "Yura", ' + name)
c4844af63ffc307baa604a7a165bbebede30d876
cfeenstra67/chess.python
/chess.py
1,487
3.578125
4
from collections import namedtuple def conflicting(pos1,pos2): x1,y1,x2,y2=(*pos1,*pos2) dx,dy=(abs(x1-x2),abs(y1-y2)) if (dx==0 or dy==0 or dx==dy): return True return False side_length=8 start_position=(0,0) def next_pos(pos,dim): x,y=pos if (x+1)>=dim: x,y=0,y+1 else: x+=1 if y>=di...
fddb89f075281eb83b19654335e906dd91bdc367
BudacaB/CS50x
/Lecture7/houses/import.py
944
3.734375
4
import csv from sys import argv import cs50 def main(): if len(argv) != 2: print("Usage: python import.py data.csv") exit(1) # open db db = cs50.SQL("sqlite:///students.db") # open and read file with open(argv[1], "r") as csvfile: reader = csv.DictReader(csvfile, delimiter...
707576b3b26a5c59535d617667ccf26917f55023
duartejr/python_engenharia_unilab
/aula02_01.py
1,698
3.640625
4
#-*- coding: utf-8 -*- from sympy import Symbol x = Symbol('x') y = Symbol('y') print 2 * x - x print x + y + x + 10 * y print (x + y)**2 import sympy x,y,z = sympy.symbols('x,y,z') print x + 2*y + 3*z - x from sympy import symbols x, y = symbols('x,y') print x + 2*y print (x + 2*y).subs(x, 2) print (x + ...
67dd885f1bd610fbe70c939233c6c0eef69eee07
gibeiro/data-mining
/homework1/problem1.py
1,930
3.640625
4
import random import sys class Card: def __init__(self, suit, symbol): self.suit = suit self.symbol = symbol suits = ['C','D','H','S'] symbols = ['A','K','Q','J','T','9','8','7','6','5','4','3','2'] deck = [] for suit in suits: for symbol in symbols: card = Card(suit, symbol) deck.append(card...
b67d4b7af92fce096ebe191f27d3f3558f6dd33d
RaghavRaichur/oop-python
/Refactoring/refactoring_4_encapsulation.py
1,427
4.09375
4
""" Simulate a simple board game. There are 2 players. Each player takes turn rolling a die and moving that number of spaces. The first person to space 100 wins. Object-oriented with a Player and Game objects """ import random class Player(object): _target_score = 100 # hidden and "private" def __init__(se...
9bffdcebc2bf3360efb6b40f4f753ac784785a6f
sreekaransrinath/exercism-solutions
/allergies.py
398
3.96875
4
sc = int(input("Enter your allergy score ")) adict = {1 : 'Eggs', 2 : 'Peanuts', 4 : 'Shellfish', 8 : 'Strawberries', 16 : 'Tomatoes', 32 : 'Chocolate', 64 : 'Pollen', 128 : 'Cats'} while sc > 255: sc -= 256 print(sc) print("Your essential allergy score is", sc) for x in range (7, -1, -1): if sc >= 2...
7d8d653cf312b91cb995e7934687162e65eafe91
smigaja-ta/Election_Analysis2
/Python_practice.py
87
3.796875
4
arr = ["A","B"] if "E" and "A" in arr: print("confused") else: print("ay?")
0875bb780d2c5aa07b63f02de7fd28a0ffa8d96b
farmxbill/PIXL485
/Scripts/hex_converter/packSN.py
1,224
3.546875
4
#!/usr/bin/env python import sys def twoDigitHex (number): return '%02x' % number if ((len(sys.argv) != 2) or (len(sys.argv[1]) != 10)): if (len(sys.argv) != 2): print "Invalid number of command line arguments. Should be:" print "python packSN.py <serial number string>" else: ...
575399a3d11572433846f1f50e4f82e2b8cc7e23
andrejvanov42/LacitPractick
/game_visel.py
1,760
3.734375
4
import random def Hangman(): print ('Игра "Виселица"') wordlist =['привет', 'дело', 'калашников', 'автомат', 'сыр'] secret = random.choice(wordlist) guesses = 'еиваро' turns = 10 while turns > 0: missed = 0 for letter in secret: if letter in guesses: ...
87af374768ea45afc14edef4f90f56f5ee17b192
vikaslakshya/Basics-of-Python
/vikas_if_else.py
920
3.796875
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 21 17:58:18 2020 @author: vikas """ name = input("Please enter your name : ") age = int(input("What is your age, {0}? ".format(name))) print(age) if age >=18: print("You can give vote!!!") else: print("You can give vote after {0} year.".for...
ac07e8e0929e54cb95fb91570e60f347be8e198c
harry990/coding-exercises
/arrays/find-range-of-duplicates-in-array.py
771
4.0625
4
__author__ = 'dsbatista' """ - Given a sorted array with duplicates and a number, find the range in the form of (startIndex, endIndex) of that number. For example: find_range({0 2 3 3 3 10 10}, 3) should return (2,4). find_range({0 2 3 3 3 10 10}, 6) should return (-1,-1). The array and the number of duplicates can...
8f2c8d9926ae2220fead8725ecef655829d46a3a
harry990/coding-exercises
/design-patterns/factory_method.py
341
3.625
4
class Cup(object): color = '' @staticmethod def get_cup(color): if color == 'red': return RedCup() elif color == 'green': return GreenCup() class RedCup(Cup): def __init__(self): self.color = "red" class GreenCup(Cup): def __init__(self): ...
88222260f53d9cf84b52f5c4c74cf85ebafb8b82
harry990/coding-exercises
/strings/generate-all-permutations-of-a-string.py
534
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "David S. Batista" __email__ = "dsbatista@inesc-id.pt" """ - Generate a list of all permutation of a string """ def permute(s): res = [] if len(s) == 1: res = [s] else: for i, c in enumerate(s): for perm in permute(s[...
19eb4be275bd3a0477a42ec205be2596a5c459db
harry990/coding-exercises
/trees/tree-string-expression-balanced-parenthesis.py
1,107
4.15625
4
from collections import defaultdict """ Given a tree string expression in balanced parenthesis format: (A(B(C)(D))(E)(F)) A / | \ B E F / \ C D The function is to return the root of the tree you build, and if you can please print the tree with indent...
6cda652b71ca73f8fa4335eaf5d0e514297861f3
pushkash/python_exercises
/magic_method_exercise.py
1,340
3.625
4
import os import tempfile class File: def __init__(self, filepath): self.filepath = filepath def __str__(self): return self.filepath def __add__(self, second_file): first_content = self.__getContent(self.filepath) second_content = self.__getContent(second_file.filepath) ...
08b644159f7d30960b32efe84c3dbfc3e8f6929e
pedroth/python_experiments
/Test/RandomNumberGuessExp.py
2,244
3.515625
4
import random import math import matplotlib.pyplot as plt def randomSearch1(x, xmin, xmax): guess = xmin while guess != x: guess += 1 return guess def randomSearch2(x, xmin, xmax): ite = 0 guess = (xmin + xmax) / 2 while guess != x: if guess < x: ite += 1 ...
5959dc09e591aac5eb2b96090fc5344c3210e866
btrif/Python_dev_repo
/Courses, Trainings, Books & Exams/PYTHON 3 - Scientific Training/5-2 Functions, arguments, scope-01 - nested for loops.py
273
3.984375
4
# Multiplication Table print(" ", end="") for i in range(16): print("%4d|" % i, end="") print() print('------' * 14) for i in range(16): print ("%4d|" % i, end="") for j in range(16): print("%4d|" % (i * j), end="") print()
0a3cb446df251eac3d3a0999aed173aff58ba86f
btrif/Python_dev_repo
/BASE SCRIPTS/for_loop_examples.py
3,495
4.59375
5
print('-------- Generate primes with a double for nested loop, Only as an example ---------------------') for n in range(2, 16): for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n // x) break else: print(n, 'is a prime number') import os ...
1c90e6c43a74e92dc37477692317ae008d9ec415
btrif/Python_dev_repo
/Courses, Trainings, Books & Exams/Lynda - Python 3 Essential Training/11 Functions/generator_01_sequence_tuple_with_yield.py
1,411
4.59375
5
#!/usr/bin/python3 # A generator function is function that return an iterator object. # So this is how you create functionality that can be used in a for loop or any # place an iterator is allowable in Python def main(): print("This is the functions.py file.") for i in inclusive_range(2, 125, 4): ...
fced8ddd72254306593c220b661d09d5778447b2
btrif/Python_dev_repo
/Courses, Trainings, Books & Exams/EDX - MIT - Introduction to Comp Science I/final EXAM - nested functions.py
1,099
3.59375
4
# Problem 7 # Made by Bogdan Trif @ 2016-10-30, 12:00 ''' Problem 7 - 20/20 points (graded) Write a function called general_poly, that meets the specifications below. For example, general_poly([1, 2, 3, 4])(10) should evaluate to 1234 because 1∗10^3 + 2∗10^2 + 3∗10^1 + 4∗10^0 So in the example t...
8ed18dc6b4a824f9c01959ac1b3df827346fe994
btrif/Python_dev_repo
/turtles/complex 2d.py
556
3.640625
4
import turtle import random wn = turtle.Screen() seren = turtle.Turtle() wn.bgcolor ("grey") colors = ["cyan", "purple", "blue"] seren.penup() seren.forward(90) seren.left(45) seren.pendown() def branch() : for i in range(3): for i in range(3): seren.forward(30) seren.backward(30) ...
8ebd1cb716cbba86488ab87f6b64bea82d4a251f
btrif/Python_dev_repo
/Courses, Trainings, Books & Exams/EDX - MIT - Introduction to Comp Science I/mid_term_EXAM - closest_power.py
2,191
4.03125
4
''' base: base of the exponential, integer > 1 num: number you want to be closest to, integer > 0 Find the integer exponent such that base**exponent is closest to num. Note that the base**exponent may be either greater or smaller than num. In case of a tie, return the smaller value. Returns the exponent. ''' ''' base:...
2fe56474d4dfa1672180cc776e05e8d3dd46f90e
btrif/Python_dev_repo
/Algorithms/Recursion/N Queens Problem.py
9,898
3.5625
4
# Created by Bogdan Trif on 10-09-2017 , 6:57 PM. ''' Given nxn board place n queen on this board so that they dont attack each other. One solution is to find * any placement of queens which do not attack each other. Other solution is to find all placements of queen * on the board. Given an integer n, return all di...
89c5785788e5171d33ef0e2cc34622b8781004af
btrif/Python_dev_repo
/BASE SCRIPTS/Logic/basic_primes_generator.py
980
4.125
4
#!/usr/bin/python3 # comments.py by Bill Weinman [http://bw.org/] # This is an exercise file from Python 3 Essential Training on lynda.com # Copyright 2010 The BearHeart Group, LLC def main(): for n in primes(): #generate a list of prime numbers if n > 100: break print(n, end=' ') def isprime...
6c9a13d67dea2ce2672fc0dad170207bdfce715f
btrif/Python_dev_repo
/BASE SCRIPTS/module bisect pickle.py
2,002
4.46875
4
import bisect, pickle print(dir(bisect)) ######################## # The bisect() function can be useful for numeric table lookups. # This example uses bisect() to look up a letter grade for an exam score (say) # based on a set of ordered numeric breakpoints: 90 and up is an ‘A’, 80 to 89 is a ‘B’, and so on: def gr...