blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4db4dcb2c3d659d0727a2e8265572277235f732f
luispaiva40200280/ALG.E.Dados
/ex04tent.py
1,296
4.09375
4
# ocupação de um pequeno parque de estacionamento def estacinamento(lin,col): lista=[] for i in range(lin): lista.append([]) for j in range(col): lista[i].append("livre") for linha in lista: print(linha) valor = False while not valor: tr...
3d85738207feeb0f8d1b942cbb26d766a4a55898
JoaoScheleder/Exercicios-de-python-resolvidos-CEV
/Exercicios/exercicio59.py
894
3.90625
4
x = 0 mn = 0 n1 = int(input('Digite um valor')) n2 = int(input('Digite outro')) while x != 5: if n1 > n2: mn = n1 else: mn = n2 print('''[1]SOMA\n[2]MULTIPLICAÇAO\n[3]MAIOR\n[4]NOVOS NUMEROS\n[5]SAIR DO PROGRAMA''') x = int(input('sua opcão é ?')) print ('-='*10) if x == 1: ...
ec721642b74c5def5a26af8091a72fa1524c6138
daniel-reich/turbo-robot
/v2k5hKnb4d5srYFvE_1.py
912
4.15625
4
""" The function is given a string containing digits from `2` to `9`. Return a set of all possible letter combinations that could represent the digit-string. ### Digits to Letters Mapping d = { "2": "abc", "3": "def", "4": "ghi", "5": "jkl", "6": "mno", "7": "pqrs", "8": "tuv", "9": "wxyz" } ### Examples ...
729c4a907146c2d4211b4748b223cf18a835cce4
pqnguyen/CompetitiveProgramming
/platforms/interviewbit/Anagrams.py
494
3.578125
4
from collections import defaultdict class Solution: # @param A : tuple of strings # @return a list of list of integers def anagrams(self, A): tb = defaultdict(list) words = A.split(" ") for i, word in enumerate(words): key = "".join(sorted(word)) tb[key].app...
7e4ad55764670cb91749a5e713b713df14ade9c2
gautam4941/Machine_Learning_Codes
/Pre Processing/Topic 1 - Numpy/Class 3 - SlicinginNumpyarray.py
1,526
3.671875
4
import numpy as np print( f"list( range(5, 10) ) = { list( range(5, 10) ) }" ) print( f"list( range(15, 20) ) = { list( range(15, 20) ) }" ) print( f"list( range(0, 5) ) = { list( range(0, 5) ) }" ) print( f"list( range(20, 25) ) = { list( range(20, 25) ) }" ) l = [ list( range(5, 10) ) , list( range(15, ...
cf6057fb4ffef71a9a3aa9e8e01069e41ac24d87
luancahus/Exercicios-logica-programacao-Python
/Quarantine days.py
733
3.703125
4
'''Programa para contar os dias que se passaram durante a quarentena !!''' from tkinter import * from datetime import date, datetime Início = datetime.strptime('18/03/2020', '%d/%m/%Y').date() hoje = date.today() dias = (hoje - Início).days window = Tk() window.title('DIAS DA MALDITA QUARENTENA') wind...
d7ae3ad9b778f5bc5cb368ce53b98661508281de
KasjanRadoslaw/Bootcamp
/zähler.py
172
3.703125
4
import random number = random.randint(1, 6) counter = 0 print(f"Anzahl des Counters: {counter}") print(number) counter += 1 print(f"Anzahl des Counters: {counter}")
e0d2d05452ce6c5e57b28c063a02a394fe717d93
SirAeroWN/ComputerScience
/101/December/PowerBall.py
1,358
3.671875
4
import random from tkinter import messagebox def prompt(upper, message): entry = eval(input(message)) gotit = False while gotit == False: if entry > upper or entry < 1: retry = "Your number was not in the allowable range, 1-" + str(upper) + ", please try again: " entry = eval(input(retry)) else:...
26adaa9edbf859da0f28f13694a1bee544bceb30
gabreuvcr/curso-em-video
/mundo2/ex052.py
346
3.9375
4
## EX052 ## num = int(input('Digite um numero para saber se ele é primo: ')) count = 0 divisores = [] for i in range(1, num+1): if (num % i) == 0: count = count + 1 divisores.append(i) print('Os divisores são: {}'.format(divisores)) if count == 2: print('O numero é primo.') else: print('O n...
aceb41aa6a9ae02fb14c896e6d7167079f6b9608
Herebert1706/Practicas-de-Estructura-de-Datos
/ColaPeekYMenu.py
4,583
3.796875
4
#Creo mi variable valor y mi indice llamado k valor=0 k=0 #Defino una funcion llamada cola en la cual dentro de ella hago una lista con un indice de 5 en la cual caben 6 valores def newCola(): Cola = [0,0,0,0,0,0] k=5 return Cola, k #Regreso el valor de mi cola y de mi indice #Defino mi funcion encolat en l...
77a673297e8dbbe74731284c7af8fa367f44bf77
Peter262/self-replicating-program
/self_replicate.py
4,773
3.6875
4
### START OF VIRUS ### import sys import glob ''' Getting the code of current file in a list ''' code = [] ''' Open the current file. We don't wanna pass a static file name because, we're not going to use this file only. This code we are writing right now is going to be injected in every other python script as well....
c592ead319c0bb590007c7dce1c6307566c928b0
kennlebu/OfficeSpaceAllocation
/app/fellow.py
549
3.75
4
from .person import Person class Fellow(Person): """Fellow inherits person. A Fellow is allocated office space and can opt for living space too. """ def __init__(self, person_name, wants_accommodation='N', allocated_office=None, allocated_livingspace=None): super().__init__(person_na...
d46622edb2b0c90eaa9364c3082bfbe2742c4f3c
ZdenekPazdersky/python-academy
/Lesson7/7.43_generate_data.py
2,552
3.796875
4
# ####2DO # Create a function that will be able to generate a table that should have the following headers: 'Name','Item','Amount','Unit_Price', 'Total_Price' # # The function should take only one input - number of rows, the generated table should have. The data should be generated from the following variables: # # val...
4d8c7c9899a5d7e63b2ff11d8c247f81ef604267
nahymeee/comp110-21f-workspace
/exercises/ex03/find_duplicates.py
373
3.796875
4
"""Finding duplicate letters in a word.""" __author__ = "730330561" i: int = 0 word: str = str(input("Enter a word: ")) result: bool = False while i < len(word): j: int = i + 1 while j < len(word): character: str = word[i] if word[j] == character: result = True j = j + 1 ...
3a7e3ca94e4c7848893eb101ae84e69a736a061f
ShaikhShakeebAhmed/DataStructures
/E_SpaceComplexity.py
239
3.71875
4
#5 Space complexity O(1) def boooo(n): for i in n : print('booooo'); #6 Space complexity O(n) def arrayOfHiNTimes(n): hiArray = []; for i in range(n): hiArray.append('hi'); return hiArray; arrayOfHiNTimes(6)
e00da1631d3d94ac1816ccf274475111b0626751
hlfshell/Robot-Framework-RBE3002
/Final_Lab_Python/frontalradar.py
2,123
3.515625
4
#! /usr/bin/env python ''' frontalradar.py Author: Keith Chester Using pygame, create a robot object and begin pan-scanning in front of the robot in order to draw a frontal radar mapping of objects in front of it. ''' import pygame, sys, math from RobotClass import * #Create the robot johnny5 = Robot('/dev/ttyUSB...
286b1bafd1e1692ae616e40a3e230ed5562915bc
SaiPamidi/CSC-projects
/Huffman-encoding-date 2018:05/huffman.py
7,204
3.984375
4
from operator import * class HuffmanNode: def __init__(self, char, freq): self.char = char # stored as an integer - the ASCII character code value self.freq = freq # the freqency associated with the node self.left = None # Huffman tree (node) to the left self.right = None # ...
8d1b77597bc1a7d52aba939e8894b89d0784dbca
farhanjaved47/python
/Basics/WebScraping.py
3,603
3.84375
4
""" Farhan Javed - 11-20-2019 Basic Web scraping tutorial with example for working with JSON. Also includes examples for working with HTML and XML files. """ import urllib.request as request import json from html.parser import HTMLParser import xml.dom.minidom # Python JSON class : https://docs.python.org/3/library/...
0176f040a2b87cb6fbf54403afffd028d6103731
dhzhd1/LeetCode
/Sum_of_Two_Integers.py
213
3.640625
4
def getSum(a, b): """ :type a: int :type b: int :rtype: int """ return a if b == 0 else getSum((a ^ b), (a & b) << 1) if __name__ == "__main__": a = 1 b = 2 print(getSum(a, b))
6dfbe432661c12e33460eabc993a3ef8ea3cd4a2
PantsWizard/CompCamps2018
/python/main.py
7,114
3.765625
4
import random import sys import time import player import location import item import enemy from datetime import datetime print ("What game do you want to play?") time.sleep(1) print("do you want to play wildernessexplorer or dungeoncrawler?") #print("wildernessexplorer/dungeoncrawler>").lower() == "wildernessexplorer"...
610006f53ec9abcb536eb1a28a1ee62a34ebf71d
TheerthaChammancheri/Python-Automation
/Excercise 2.py
258
3.78125
4
babyname=('d','a','c','d','w','x','g','z','i') b=sorted(babyname) print(b) countries=['africa','singapore','india','china','japan','pakistan','dubai','bangladesh','srilanka','afganisthan'] countries.sort() print countries print(b[0:5]+countries[0:5])
2267ed956e57a69a2b780aea6b67014193118ef9
yoda-yoda/my-project-euler-solutions
/solutions/9.py
796
3.8125
4
#!/usr/bin/python """ Author: Denis Karanja, Institution: The University of Nairobi, Kenya, Department: School of Computing and Informatics, Chiromo campus Email: dee.caranja@gmail.com, Task: 9(Pythagorean triplet such that a^2 + b^2 = c^2 and a < b < c and a + b + c = 1000) License type: MIT :) Status: COMPLETED... ""...
273bf11a343dbb8379543733402273401a59c059
AbaiIliiazov/PythonVol.9Evening
/SolutionsFunctions.py
4,461
4.03125
4
# Solutions: # Task1: # a = int(input("Enter a number: ")) # def function(a): # return a%10 # print(function(a)) # Task2: # a = int(input("Enter a number: ")) # def function(a): # return f'this is an even number' if a%2 == 0 else 'this is an odd number' # print(function(a)) # Task3: # n = int(input("...
d52dc993632c8ce6d272cc09a9e78656029cd444
DarisaSupriya/python-assignment-13
/colon.py
212
3.859375
4
#program to create the colon of a tuple from copy import deepcopy tupley=("higuy" , 5 , [] , True) print(tupley) tupley_colon=deepcopy(tupley) tupley_colon[2].append(50) print(tupley_colon) print(tupley)
685ede6fb745cb3a370e1f92d756e609f865d487
mfguerreiro/Python
/lista3/ex1.py
123
3.75
4
n = int(input("Digite o valor de n: ")) i = n - 1 if n == 0: n = 1 while(i > 0): n = n * i i-=1 print(n)
3897e9175ff40d3708a06b1968f8a871a42359b4
SamarQuadri/Game
/code.py
1,115
3.765625
4
import random while True: user_inp = int(input("Give a input. Press '1' for stone, '2' for paper and '3' for scissor.\n")) comp_inp = random.randrange(1, 4) if user_inp == 1: if comp_inp == 1: print(f"You: Stone\nComputer: Stone.\nIts a draw") elif comp_inp == 2: prin...
e138add7d34a2c34074d4cdcc6ea8b62a1114b6d
erelsgl/abcvoting
/abcvoting/output.py
2,355
3.90625
4
""" Print messages to terminal depending on a given verbosity level similar to the Python logging module. Also meant to be used as Singleton. """ import logging # should match the values defined in the logging module! CRITICAL = 50 ERROR = 40 WARNING = 30 INFO = 20 DETAILS = 15 DEBUG = 10 DEBUG2 = 5 VERBOSITY_TO_NAM...
b03a38e0f02fd22b032112b5990a4878895c7f15
kevink97/Teaching-Materials
/tutor_hs/les4/weather.py
960
3.5625
4
import requests # gets the weather data on the zip code specified and returns it in json format def get_data(zipcode): payload = {'zip': zipcode, 'units': 'imperial', 'appid': 'b73db8c0f065450acf87c6598cbfd37c', 'cnt': '16'} r = requests.get('http://api.openweathermap.org/data/2.5/forecast/daily', params=paylo...
6130b568029a77ac3ac93ccbe954f70a2c508d3f
wesenu/mitx-python-course-work
/WK1_bob_counter.py
547
4
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 30 22:30:31 2017 @author: g Week 1 Problem set 1 Problem 2 Bob Counter Given a lowercase string input, it will count the number of 'bob's in the input and print the result. Not a particularly clever solution. """ numBobs = 0 s = input("Enter any lowerca...
37b48c9fcd10126bfd9b2da5c72e63a018995e98
nera3328/Multi_Campus_2019
/Class_Season_2/2.자연어(부교재)/2-8.StopWord.py
512
3.703125
4
# 불용어 : Stop Words import nltk from nltk.corpus import stopwords # 영어의 Stop words를 확인한다. stopWords = stopwords.words('english') print(stopWords[:20]) # 영어 소설에서 Stop word를 제거한다. text = nltk.corpus.gutenberg.words('austen-sense.txt') removedStopWord = [w for w in text if w.lower() not in stopWords] print(rem...
fea0dab49dee63b32a0147acf66fa8025d3f605d
singo112ok/algorithm
/programmers/level2/trans_parentheses.py
1,480
3.796875
4
# https://programmers.co.kr/learn/courses/30/lessons/60058 # 괄호 변환 # level2 # 2020 KAKAO BLIND RECRUITMENT # 문제가 복잡해서 그대로 읽으며 구현해봄 # ide사용해서 디버깅했기에 금방풀었던 문제 def swap(p): resultStr = "" for i in range(0, len(p)): if p[i] == '(': resultStr += ')' else: resultStr += '('...
fdce529a626ebb5590dc5bff1c80a121fafc7020
vladn90/Algorithms
/Arrays/third_max_number.py
2,200
3.921875
4
""" Problem description can be found here: https://leetcode.com/problems/third-maximum-number/description/ """ class Solution: def thirdMax_1(self, nums): """ Returns 3rd maximum unique number in array nums. If there's no such, returns 1st / 2nd max unique number. Simple algorithm. Algorit...
da537f0db1bf66cd6a204761836c7c7045240c08
nagyrobert1990/python-practice
/first_python_game/lootbox.py
1,218
3.78125
4
def loot_system(): common_loot_list = ['cat','puppy','slime','shovel','ladder','mushroom','clover','soup square','tram ticket'] epic_loot_list = ['horn','minigun','lucky charm','natural beard','flame thrower','codecool brooch','tank','battleship','irish dwarf','gold'] legendary_loot_list = ['dragon','ifini...
d2023b93f6addb6acc7ca558c38791b8b0b7fff9
arvindkarir/python-pandas-code
/Py exercises/NewtonRaphsonANDBisectionMethodCompared.py
1,261
3.890625
4
epsilon = 0.001 k = 100000 compare_two = 0.00001 #an epsilon for comparing the two methods, NR method is better for 0.00001 and higher precision # Newton Raphson for square root # Find x such that x**-sth is within epsilon compare_two count = 0 guess = k/2.0 #starting point while abs(guess*guess - k) >= epsilo...
5d28db8de9e6073667681e9f8d4afb2d43ae04f3
VicDCruz/minimax-game-implementation
/Gameboard.py
2,538
4.03125
4
class Gameboard: """ Simulación de un tablero de juegos """ def __init__(self, width, height, player, opponent): """ Constructor de la clase Gameboard """ self.height = height self.width = width self.board = [] for x in range(height)...
8ccfd7b9c3ea238f9bfb2698a0ba8e357ba8ab60
siminio/CheckIo
/Home/SunAngle.py
659
4.1875
4
def sun_angle(time): """ Gives the angle between the sun and the surface of the land in function of the time of the day. """ hours, minutes = [int(elem) for elem in time.split(":")] result = -90 + hours * 15 + minutes * 0.25 return round(result, 2) if 0 <= result <= 180 else "I don't...
74fe5db27a50c965d9aa01c97889b28d7952a7c2
dougBelcher/Python
/Pay.py
211
3.59375
4
from computepay import computepay try: Hours = input('Enter Hours: ') Rate = input('Enter Rate: ') Pay = computepay(Hours, Rate) print Pay except: print 'Please enter numbers for Hours and Rate'
e47058f9b66c11519785d1aaa6b928fe3539db5d
dam90/tpoint
/utility/sphere.py
2,061
3.734375
4
#! python import numpy as np def regular_points(d): ''' Create a regular distribution of points on a sphere, where the average area per point is d^2 (radians^2). Input: d: half-dimension of unit area, required Ouput: V: is the polar angle (degrees) Phi: is the azimuth angle (degrees) ''' V ...
621e662abf4a0fab518ff63d727290b4489a9194
penalbie/al-test
/stack2.py
753
4.09375
4
import math # Python program to # demonstrate stack implementation # using list from graphics.py import * stack = [] # append() function to push # element in the stack def Stack(s): stack.append(s) #stack.append('a') #stack.append('b') #stack.append('c') # pop() fucntion to pop # elem...
305c9023386d87596529eda3edfde5dd36b74215
caionms/python
/Lista_1/l1q9.py
269
3.796875
4
print('Iremos calcular o preço total do aluguel de um carro!') dia = int(input('Digite o quantidade de dias de aluguel: ')) km = int(input('Digite o quantidade de km rodados: ')) preço = (60*dia) + (0.15*km) print(f'O preço total do aluguel foi de {preço} reais!')
6b469df5b818fe75f2891a974cc7fd7c570b6573
bhavanakurra29/Assignment-2
/Assignment 2.py
673
3.921875
4
#!/usr/bin/env python # coding: utf-8 # # Question 1 # In[1]: # Write a python program to remove empty list from a list # In[5]: lst=[1,2,[],3,[],4,5,6] res=list(filter(None, lst)) print("the list after removal of empty list is",res) # # Question 2 # In[6]: # Write a python program to remove all duplicates...
f9bf6accd717ba42840951d9724333ea7acd5b13
pskliff/21-weeks-of-algos
/mmnosovskiy/week-7/task-6/main.py
720
3.578125
4
def is_bipartite(graph): part = [-1] * n ok = True q = [0] * n for st in range(n): if part[st] == -1: h, t = 0, 0 q[t] = st t += 1 part[st] = 0 while h < t: v = q[h] h += 1 for to in graph...
06d3efe6995eb0088a53971155cf7c1835a03e91
dan19-meet/meet2017y1mini-proj
/brainGame.py
1,184
4.09375
4
import turtle speed = 2.5 UP = 0 LEFT = 1 DOWN = 3 RIGHT = 4 direction = UP turtle.pensize(10) turtle.left(90) turtle.shape("square") turtle.penup() UP_ARROW = "Up" LEFT_ARROW = "Left" DOWN_ARROW = "Down" RIGHT_ARROW = "Right" SPACEBAR = "space" def up(): direction = UP print(direction) oldPos = t...
eb6ab1ff6d81966f316adaf3d2d56541a06960b9
sarari0318/leetcode
/Backtracking/subset_52.py
691
3.703125
4
class Solution: def subsets(self, nums): ''' Parameters ---------- nums: List[int] Returns ------- res: List[List[int]] ⇨ return all possible subsets (the power set). ''' res = [] self.backtracking(res, [], nums,...
4b2016219ecffd5d5a088ec2323ab460296367c4
side-projects-42/DS-Bash-Examples-Deploy
/CONTENT/DS-n-Algos/ALGO/__PYTHON/kth_largest.py
157
3.640625
4
def kth_array(arr,n): arr.sort(reverse=True) for i in range(n): print(arr[i]) arr=[1, 23, 12, 9, 30, 2, 50] kth_array(arr,3)
bd5ebe37c24ec58d0fe9163af9cda50574be8269
AmyKenn/NCEA-level-3-internal-2016
/Travel Expo - achieved standard.py
17,179
3.546875
4
#Amy Kennard #AS91637 from tkinter import * #Suporting class to keep track of traveller's details class TravelInfo: def __init__(self, name, age, number, trips, local): self.name = name self.age = age self.number = number self.trips = trips self.local = local ...
2436758e1d7cd6c8508d475b0114e0408942b14d
Unclechamps/UnitTesting
/groceries.py
1,572
3.9375
4
#Groceries List class ShoppingList(): def __init__(self): self.grocery_stores = [] def addStore(self,store): found = False for the_store in self.grocery_stores: if the_store.store_name == store.store_name: print ("This store is already on the list.") ...
9c4053eedbf440cd5604fa851d78766f38e58b79
rafa-santana/Curso-Python
/Aula 10/ex30.py
145
4.03125
4
n = int(input('Digite um número inteiro: ')) if n%2==0: print('O número digitado é par') else: print ('O número digitado é ímpar')
16d42a62c8df555b47469345998339e32578eaae
Atsalibram/passwords
/run.py
5,627
3.828125
4
#!/usr/bin/env python3.8 import os from credential import Credential from user import User import random # def create_credentials(first_name, last_name, user_email): # ''' # A function that creates a new users credentials # ''' # new_user_credential = Credential(first_name, last_name, user_email,) # ...
627aba78f159b11a21b5fc822c6afac653c5aa0a
bapi24/py4e
/data_structures/lists/sum.py
797
3.96875
4
w''' write a program to sum all the numbers that are given as input ''' ''' sum = 0 length = 0 while True: choice = input("Enter number or press q to quit: ") if choice is 'q': break try: int_choice = int(choice) sum = sum + int_choice length = length + 1 except: print("...
61d8cb65ed02a9dbd905897290709080c49ba886
benjiaming/leetcode
/validate_binary_search_tree.py
1,596
4.15625
4
""" Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and righ...
0d749fd69e04170b675cf54986cecbb0a6115776
DizzyYunxuan/Leetcode_answers
/108.convert-sorted-array-to-binary-search-tree.py
754
3.671875
4
# # @lc app=leetcode id=108 lang=python3 # # [108] Convert Sorted Array to Binary Search Tree # # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def sortedArrayToBST(self, nums: List[int...
a61b83c0b1b3cb59bbc38c5e7371967827646c42
zcFun/python
/lesson1/indext.py
940
4.25
4
# python 数据类型:数字 ,字符串,列表,元组,字典 # 输出 print('我是曾晨,来自大数据1610\n '+ 'he\'s a handsome man \n '+ '\"青出于蓝而\",出自荀子《劝学》 \n') # 输入 x = float(input("请输入第一个数:")) y =float(input("请输入第二个数:")) z = float(input("请输入第三个数:")) sum = x+ y+ z ave = sum/3 print("三个数的和是:%f \n" %sum) # 多行注释 """ # %.2f指定保留小数点后两位小数 print("三个数的平均数是:%.2f" ...
e784c868c72da98300816e3e9cedfd8903e68d2c
jj1993/introduction-cls
/bloodflow.py
1,161
3.59375
4
# ==================================== # # BLOOD FLOW # Introduction computational science # # By # Jonathan Jeroen Beekman - 10345019 # Krishnakanth Sasi - ********* # # ==================================== import math DP = 80 # diastolic pressure, in (mm HG) SP = 120 # systolic pressure, in (mm HG) SV = .075 #...
57d361d365c7915de24fd2ab67e71e7be1bcb032
HarshilModi10/MCP_Competition
/easy/question100.py
1,493
3.96875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSameTree(self, p, q): """ :type p: TreeNode :type q: TreeNode :rtype: b...
adc99d5f29c90431ee58606411902dc578137998
raj13aug/python-refresher-nataraj
/destructring_values.py
652
4.4375
4
#destructring values t = 5, 11 x,y = t print(x,y) people = [("Bob", 42, "Mechanic"), ("James", 24, "Artist"), ("harry", 32, "Lecturer")] for name, age, profession in people: print(f{"Name": {name}, Age:{age}, profession: {profession}}) #underscore on its own is so bad a variable name, that nobody would wanna use i...
a234883e9349b90a917b20d7a0c10edbb6c092f3
priyaananthasankar/python-ctci
/chapter1/1.1.py
470
4.3125
4
# Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? # parse each character from string and put it new array. Check if the character is present in the new array already. If so, exit. my_string = raw_input("Enter the string: ") char_arr = list(m...
d35fe7b9d0e6c864ce4e4ba8a5b0f57852692f4c
317295869/THC
/OK/OK-Python/Laberinto/Lab01.py
353
3.5
4
#!/usr/bin/python3.7 # # Valencia Dorantes Eduardo Alexis # Python 3.6.8 # # # def cargarlaberinto(laberinto): archivo=open("LEduardo.txt","r") l1=" " l=[] while l1: l1=archivo.readline() if l1: l1=l1.rstrip() l1=[int(x) for x in list(l1)] l.append(l1...
68f2cb654209433cc81c8975d7345174e57035fa
DiogoM14/Python-Exercicios
/Curso/ex016.py
176
3.703125
4
from math import trunc msg = float(input('Escreva um número para saber a sua porção inteira: ')) n = trunc(msg) print('A parte inteira do número {} é {}'.format(msg, n))
558dc0d293be05f66aa03537f7fa3b28c720ad13
hosam1696/python_intro
/standard/files.cvs.py
266
3.796875
4
# dealing with comma separated values (CSV) import csv csv_file = open('one.csv', 'r') c1 = csv.reader(csv_file) print(csv_file.readlines(), list(c1)) for line in list(c1): for col in line: print(col.ljust(12)) # write a csv file csv.writer(csv_file)
311b5ecf48ebeb081005b3b3b729c787e3644637
Rodrigodp/leetPy
/1342. Number of Steps to Reduce a Number to Zero.py
551
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 4 22:43:16 2020 @author: Rodrigo """ import unittest class Solution: def numberOfSteps (self, num: int) -> int: i = 0 while num > 0: if num % 2 != 0: num = num - 1 i = i + 1 else: ...
4c19687dfe5f96d172b0dfadde701061a826de4a
DerevenetsArtyom/pure-python
/iterators/simple_infinite.py
609
4.125
4
class InfiniteIterator: def __init__(self): self.__number = 0 def __iter__(self): return self def __next__(self): self.__number += 1 return self.__number # Just plain usage of InfiniteIterator doubler = InfiniteIterator() counter = 0 for number in doubler: # print(num...
2233054303743e452ace9f67f255e308314c46f2
ramesharun/code-snippets
/Python3-functions/split_list_into_nSize_lists.py
781
4.375
4
''' this function split given list by using N value into small list in size of N. if the last group is not big enough, the last list will be in the size that was left. for example let's say you have the next list: [1,2,3,4,5,6,7,8,9,10] when you will send this list to the function with N=4 the resu...
e00ad9900334703dfb33b70a583085e9169e494b
Mivao/hons-pub
/code/three_var_hom.py
4,233
4.34375
4
import itertools import math import matplotlib.pyplot as plt import time import copy degree_string = input("What degree: ") #graph_string = input("Do you want to see the graphs? Answer 'y' or 'n': ") graph_string = 'n' #Sets up our list of homogeneous 3 tuples degree = int(degree_string) range_list = list(range(degr...
e5c7605952f1deb51c4126a4949506690a06df71
emguffy/ProjectEuler
/044_pentagonNumbers.py
1,372
4.03125
4
# Pentegon NUmbers def is_pentagon(number): isPentagon = False for n in range( int(2*(number**.5)/3) , int(number**.5)+1): if number == n*(3*n - 1)/2: print n isPentagon = True break return isPentagon print int(2167*(3*2167 - 1)/2) print is_pentagon(7042750) print is_pentagon(1560090) print is_pentagon(...
ecfaebff26e917e2c71e16107bf6d704a217aa16
mattgoff/My100Days
/Day_16/for_vs_gen.py
482
3.765625
4
import calendar import timeit #list def leap_years_list(n=1000000): leap_years = [] for year in range(1, n+1): if calendar.isleap(year): leap_years.append(year) return leap_years #generator def leap_years_gen(n=10000): for year in range(1, n+1): if calendar.isleap(year)...
5e80d6fc667b5f2c2a7a980fc6c9563fe70cefce
rupeshk1997/PROJECTS
/python/morse_code.py
1,844
3.90625
4
# Python program to implement Morse Code encoder. # Morse code values represented in form of dictionary Morse_Code_values = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-',...
2362db4e48e32be46814e252949e80fe9f152b35
cuimin07/cm_offer
/10-1.斐波那契数列.py
750
3.84375
4
''' 写一个函数,输入 n ,求斐波那契(Fibonacci)数列的第 n 项。斐波那契数列的定义如下: F(0) = 0,   F(1) = 1 F(N) = F(N - 1) + F(N - 2), 其中 N > 1. 斐波那契数列由 0 和 1 开始,之后的斐波那契数就是由之前的两数相加而得出。 答案需要取模 1e9+7(1000000007),如计算初始结果为:1000000008,请返回 1。 示例 1: 输入:n = 2 输出:1 示例 2: 输入:n = 5 输出:5 提示: 0 <= n <= 100 ''' #答: class Solution: def fib(self, n: int) -> ...
24dfa6ab6bc60569f065caf79d76fe7165d9b167
enomarozi/Crypto_Classic-Py
/Bruteforce_Subtitution.py
680
3.578125
4
import string from random import randint letter = string.ascii_lowercase def encrypt(): text = "vydnjvndineznuuffyfukngenvhngvysjbfydxyejgnr".replace(" ","").lower() letter_key = "" for i in range(200): add = string.ascii_lowercase[randint(0,25)] if add not in letter_key: ...
b78d3c0b8c7bb88f5e32e88e325b9b2d6068619a
sakamot/nlp100
/chapter1/03.py
186
3.5
4
str = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." list = [] for s in str.split(' '): list.append(len(s.strip(',.'))) print(list)
58e97fcd6ac3fc75298e67ff4a261c98a1e739e1
iningwei/Python-DDU
/Day1-15/Code/Day4/Prime.py
344
3.65625
4
""" 判断一个数是否是素数 只能被1和自身整除的大于1的整数是素数 """ num = int(input("输入一个数:")) flag = True if num > 1: for x in range(2, int(num**0.5)+1): if num % x == 0: flag = False break if flag: print("%d是素数" % num) else: print("%d不是素数" % num)
2cc6f8b2e368141d0f858387226d9b091ffb23b6
cryptozealot/projecteuler
/010.py
377
3.765625
4
#Find the sum of all the primes below two million. result = 0 for possiblePrime in range(2, 2000001): # Assume number is prime until shown it is not. isPrime = True for num in range(2, int(possiblePrime ** 0.5) + 1): if possiblePrime % num == 0: isPrime = False break i...
375246d4c544a7ead76c2cd6de9f7f36714ab1c2
ania4data/DSND1
/OOP_Udacity/fractal_triangle.py
1,666
3.9375
4
# import turtle # def draw_triangle(): # window=turtle.Screen() # window.bgcolor("orange") # araz=turtle.Turtle() # araz.shape("turtle") # araz.speed("fastest") # araz.setpos(0,0) # for i in range(2): # araz.color("black","blue") # araz.begin_fill() # araz.forward(50) # araz.left(...
534cdb0282dff479fa625508d1bfdc762a0c4ee0
bokdoll/Algorithm
/Algorithm-Programmers/level-1/secretMap.py
999
3.5
4
# 2020/08/10 (월) def solution(n, arr1, arr2): bin_arr1 = binarize(arr1, n) bin_arr2 = binarize(arr2, n) arr = [] for i in range(n): # 2. arr1 + arr2 0이 아니면 다 1 merged_array = list(map(lambda x, y: '0' if int(x) + int(y) == 0 else '1', bin_arr1[i], bin_arr2[i])) str_num = ''.join...
de7c2b4ece6286fa332abf429d1b1192fbc8221c
jsumedh10/Data-Structures
/Sorting/SelectionSort.py
435
3.703125
4
# author: Sumedh Junghare A = [5,4,3,2,1] #A=[3,2,1,4] #select minimum number #put it at the start #when the first minimum number reaches 0th place, #all other minimum numbers follow that number def selectionSort(A): for i in range(len(A)): indexOfMin = i for j in range(i+1,len(A)): if A[i]>A[j]: indexO...
7ac9be870cb4886f8b3862c62490780d0243e891
wicaksa/average_height
/average_height.py
843
4.25
4
# Ask user to input intergers into a list separated by a space student_heights = input("Input a list of student heights ").split() # Print the current list. for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) # Input: List of intgers that represents heights. # Output: Integer whic...
b3fd3f5c13e8863233fe0f56dae9b1aa201858f0
AnjaliCAbraham/S1-A-Anjali-C-Abraham
/programing lab/27-01-2021/14.py
75
3.984375
4
a = int(input("Enter an integer : ")) n1=a n2=a*a n3=a*a*a print (n1+n2+n3)
8bf46785ddda8c3a85a3558c3e14c20c46692a08
husbycodereis/CS50
/pset6/readability.py
1,102
3.6875
4
from cs50 import get_string import re # main function def main(): getText = get_string("Text: ") totalLetters = letterCount(getText) totalWords = wordCount(getText) totalSentences = sentenceCount(getText) L = (totalLetters * 100) / totalWords S = (totalSentences * 100) / totalWords ...
05ca32737f7eb63d5ee5729c2199a835724dd3c4
MitenTallewar/Design-Pattern
/singleton1.py
2,047
3.90625
4
# class SingletonGovt: # __instance__ = None # def __init__(self): # """ Constructor. # """ # if SingletonGovt.__instance__ is None: # SingletonGovt.__instance__ = self # else: # # SingletonGovt.__instance__ = SingletonGovt.__instance__ # raise Excepti...
14acc148e535a9af1c0addcb6966ff3c37d44edd
KADEEJASAFEER/pythonnew
/functional_programming/employee_prgm.py
1,543
4.03125
4
#QUESTION #convert employee name to upper case #print emplyee salary greater than 15000 #provide increment of 5000 for all employee who mhave experience greater than or equal to 2 #list all employees designation=developer class Employee: def __init__(self,eid,name,desig,sal,exp): self.eid=eid self....
2b4c932e41e1d3e3062ac594c984ac729d7d9d12
Dorpon23/Python-Programming
/problemstatement.py
263
3.734375
4
def sentence_maker(pharase): cap = pharase.capitalize() introgativer = ("how","what","why") if pharase.startswith(introgativer): return "{}?".format(cap) else: return "{}".format(cap) print(sentence_maker("what are you doing"))
57d6ca62bde91bdb1bfb160c8d7bea59fc722e54
superpenshine/ImageNet-TF-Classifier
/utils/preprocess.py
1,444
4.15625
4
import numpy as np def normalize(data, data_mean=None, data_range=None): """Normalizes input data. Notice that we have two optional input arguments to this function. When dealing with validation/test data, we expect these to be given, since we should not learn or change *anything* of the trained mode...
88498a857945e03e558c873bb02bb175b54ccbf5
desmondmcconnell/DnD_Skill_Tracker
/player.py
4,106
3.515625
4
""" Player class for Dungeons and Dragons """ from skill import Skill from attribute import Attribute from item import Item class Player: def __init__(self, name=""): self.name = name self.skills = [] self.attributes = [] self.previous_attributes = [] self.items = [] ...
a17a4bef9c8e3baf6da23831a251b7d09ab3d483
harrylee0810/TIL
/bj/bj8393.py
323
3.53125
4
# n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오. # 첫째 줄에 n (1 ≤ n ≤ 10,000)이 주어진다. # 1부터 n까지 합을 출력한다. # 예제 입력: 3 # 예제 출력: 6 init_num = int(input()) result = 0 for i in range(1, init_num+1): result += i print(result)
0a4580caff6a390a14c05421e7de81b1683c8e17
Audarya07/Core2Web
/Python/20QueAssign/Codes/prog4.py
111
3.71875
4
def sumTuple(x): return sum(x) tup = tuple([int(x) for x in input().split()]) print("Sum:",sumTuple(tup))
870d862d6e0e7fd0cc3c2915b0071a335e804473
Aasthaengg/IBMdataset
/Python_codes/p03479/s946912549.py
459
3.671875
4
#!/usr/bin/env python3 import sys DEBUG = False def read(t): return t(sys.stdin.readline().rstrip()) def read_list(t, sep = " "): return [t(s) for s in sys.stdin.readline().rstrip().split(sep)] def dprint(*args, **kwargs): if DEBUG: print(*args, **kwargs) return def main(): x, y = r...
14a0349747fde505d04ec7dfba4be6db8af80f33
frclasso/CodeGurus_Python_mod2_turma1
/Marcelo/list_comprehension/13. script.py
249
4.0625
4
list_of_list = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] listaUnica = [y for x in list_of_list for y in x] print(listaUnica) print() listaUnica2 = [] for x in list_of_list: for y in x: listaUnica2.append(y) print(listaUnica2)
7dbf7da2dd8cb203e289521d048176712759232e
alcrishub/learning_materials
/reverse.py
94
3.671875
4
x = ["Alice", "Cindy", "Bobby", "Jan", "Peter"] reversed_word = x[::-1] print(reversed_word)
38aea1dd6a991739e1f8aa0959dd7c46247b54bb
milley/ARTS
/week56/algo/lc414/Solution.py
1,290
3.890625
4
from typing import List from sortedcontainers import SortedList class Solution: def thirdMax(self, nums: List[int]) -> int: nums = list(set(nums)) nums.sort(reverse = True) #print(nums) return nums[2] if len(nums) > 2 else nums[0] def thirdMax1(self, nums: List[int]) -> int...
fe0f0aad06ba06f35050b5429b827ee2a22ac4f5
ybakkali/INFO-F404-Project-1
/Partitioner.py
4,707
3.765625
4
from Core import * class Partitioner: def __init__(self, tasks, heuristic, sort, limit, cores_number): """ A partitioner class whose purpose is to partition the task set between the different cores according to a combination of sorting order and heuristic :param tasks: the list of...
264ca4740eaf3262241340e235234db45ce0cc0f
arghya013/Vehicle-Detection-using-UAV
/OpenCV and Python with already trained xml file/VehicleDetection.py
1,137
3.5625
4
import cv2 #our video video = cv2.VideoCapture('Video File Name.mp4') #Our Pre-defined car classifier classifier_file = 'car_detector.xml' #create car classifier car_tracker = cv2.CascadeClassifier(classifier_file) while True: #read the current frame (read_successful, frame) = video.read() ...
00fa32748344545fdf7b858bc5d5bdedd30d7594
samirelanduk/omnicanvas
/omnicanvas/color.py
2,764
3.5625
4
"""This module contains various functions usued internally to process colours, mainly for validation pruposes currently.""" import colorsys def process_color(color): """Raises exceptions if a colour does not meet requirements. :param str color: The colour to check. :raises TypeError: if the colour is not...
bdc57e6ca060ac57d5e5cf9f395b09fc9786dd2a
gerdm/machine_learning
/implementations/softmax/softmax_mnist.py
1,541
3.5625
4
# Test of the SoftmaxRegression class # to learn the separations between flowers # inside the iris dataset from softmax import SoftmaxRegression from sklearn.model_selection import train_test_split from sklearn.metrics import confusion_matrix import matplotlib.pyplot as plt import seaborn as sns from sklearn.datasets...
49680e62482a3f96d5c3c225d40e98c37408c2aa
debankit/p342assignements
/assg1q3.py
147
3.84375
4
# Sum over 1+ 1/2 + 1/3 + ..... till 1/1000 num = 1 sum = 0.0 while(num < 1000): sum += (1.0/num) num += 1 print("The sum is", sum)
68d31ddc62b904bd1204c545a169052b1407975d
sylviocesart/Curso_em_Video
/PythonExercicios/ex002.py
322
4.125
4
""" Entre com um nome e mostre uma mensagem de boas vindas """ nome = input('Digite seu nome: ') print('É um prazer te conhecer,', nome,'!') # Outra forma de imprimir o resultado print('É um prazer te conhecer, %s!' %(nome)) # Mais uma forma de imprimir o resultado print('É um prazer te conhecer, {}!'.format(nome))
3ca6a6d6941954e435b0c5e2f14c5f8967d66afa
hemanthsoma/BigData
/Assignment02/printFibonacciSeries.py
203
4.03125
4
first,second=0,1 number=int(input('Enter number of terms')) print(first,second,end=' ') while(number-2): total=first+second first,second=second,total print(total,end=' ') number-=1
14c9a672a0f281421088fafdb10647918c19e2c5
vatsalsavani/old_project_archive
/aToDoList/todoListApp.pyw
5,894
3.578125
4
#Import Modules import tkinter import _tkinter import random import tkinter.messagebox import sys from tkinter import * w = 20 fontC = "white" bgC = "black" border = 1 hT = 0 bW = 0 tasks = [] doneTasks=[] #from todolist import * def updateList(): clearList() for index in...
dc8b81823b641c54c6637782702ae9f99e1b73de
MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video
/Ex054-ContadorIdade.py
311
3.96875
4
from datetime import date menores = 0 maiores = 0 for i in range(1,8): ano = int(input('Em que ano a pessoa nasceu? ')) idade = date.today().year - ano if idade < 21: menores += 1 else: maiores += 1 print('{} ainda são MENORES\nE {} já são MAIORES'.format(menores, maiores))
ca22d24611d2897342d6554f4af6dba223e4510d
kunal27071999/KunalAgrawal_week_1
/Week_1_datastructure_part1_Q40.py
344
3.734375
4
"""40. WAP find a pair with a given sum in the array.""" def getPair(a,sum): pair = [] for i in range(0,len(a)): for j in range(i+1,len(a)): if a[i] + a[j] == sum: pair.append(a[i]) pair.append(a[j]) return pair arr = [ 1,2,3,4,5,6,7,8,9] sum = 10 prin...
1e64d718957f6cb3583349945f478b0997e7509d
MaleCore/work
/07day/身价.py
366
3.953125
4
money = int(input("请输入身价")) face = int(input("请输入颜值")) height = float(input("请输入身高")) if (height >= 180 and money >= 100000000 and face >= 90): print("高富帅") elif (height >= 170 and money >= 1000000 and face >= 80): print("帅") elif (height <= 170 and money <= 1000000 and face <= 60): print("小康") else : print("乞丐")