blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
490f026d78bc88cfbc4de0960edbd5333628288b
GeorgiaHCA/Fizzbuzz
/start.py
1,130
4.21875
4
def fizz_buzzer(number): if number%5==0 and number%3==0: return "fizzbuzz" elif number%5==0: return "buzz" elif number%3==0: return "fizz" else: return number def negfizz_buzzer(number): #created neg_fizzbuzz loop for negative numbers if number%5==0 and number%3==0:...
eded708ffb884438d337ce5e9a87f57dc76ed408
CharleneC/ECE143_F18
/SupportCode/Plots/Station_percent_trend.py
1,943
3.59375
4
#@author: Arun Joseph def plot_station_percent_share(df,*,size='large'): ''' This function plots the variation of percentage share over years for 4 large or small stations Args: df (dataFrame) : data, should be a valid pandas dataframe Kwargs: size (str) : valid options large or small...
8b6209956b35c63b52fa8e9d5e0dcd94ba03a4d5
melbinmathew425/Core_Python
/advpython/oop/inheritance/demo1.py
419
4.03125
4
#single inheritance class parent:#parentclass base class superclass parent_name="arun" def m1(self,age): self.age=age print("my name is ",parent.parent_name) print(self.age) class child(parent):#derived class def m2(self,cage): self.cage=cage print("parentn name is "...
d069229844ac5fe94b627998708c52b4920ce0c6
pappukr4444/DataCamp
/Data Scientist With Python/01-Introduction-to-Python/01-Python-Basics/13-Can-Python-handle-everything.py
716
3.84375
4
''' Can Python handle everything? - 50 XP ============================================================== Now that you know something more about combining different sources of information, have a look at the four Python expressions below. Which one of these will throw an error? You can always copy and paste this code i...
08328167d6d53e86585f15552614da85251218af
ausaki/data_structures_and_algorithms
/leetcode/minesweeper/287092257.py
1,204
3.53125
4
# title: minesweeper # detail: https://leetcode.com/submissions/detail/287092257/ # datetime: Thu Dec 19 18:24:16 2019 # runtime: 204 ms # memory: 15.3 MB class Solution: def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]: def update(i, j): if board[i][j] == 'M':...
3ef3bb3d8c7ecda94be6a5753ee212cf8ca0e9fa
irynalu/HackathonMS
/runner/calendar.py
1,169
3.5
4
import datetime begin_of_day = datetime.timedelta(hours=9, minutes=30) end_of_day = datetime.timedelta(hours=6, minutes=30) next_day = datetime.timedelta(hours=8) one_day = datetime.timedelta(days=1) weekend = datetime.timedelta(days=2) class Calendar: class __Calendar: def __init__(self): s...
7eae206910c6da0f573c1cb3592e79c5787d8231
JhonveraDev/python_test
/pruebas_estudio/tupla.py
254
4.09375
4
tupla=("Hola",1,2,3,"Bye","Hola") nombre,a,b,c,d,e=tupla print(nombre) print(a) print(b) print(c) print(d) print(e) print(tupla[0]) print("Hola" in tupla) print(tupla.count("Hola")) print(len(tupla)) # Saber cuantos elementos hay dentro de la tupla
f64da48efe4afc27ed6edf6ca89ec956dae77af3
AlbyAa03/Compiti_Vacanze
/sistemi/pythagoreanTriplet.py
399
3.71875
4
import math def trovaTerna(num): c = 0 risultati = [] for a in range(num-2) : for b in range(1,a): c = math.sqrt((float)(a**2 + b**2)) if (c%1) == 0 and a+b+c==num: print(a,b,(int)(c)) risultati.append([a,b,(int)(c)]) ...
41439270330682fec90a1f0190f7ed1d4fd980c8
epicmonky/Project-Euler-Solutions
/problem015.py
408
3.546875
4
# Starting in the top left corner of a 2 x 2 grid, and only being able to move to the right and down, # there are exactly 6 routes to the bottom right corner. # How many such routes are there through a 20 x 20 grid? import math def num_routes(m, n): num = int(math.factorial(m + n) / (math.factorial(m) * math.f...
ed5bd7fa064cfa72c3ce1d1a24ebea04b4ed269f
rpalominosc/python
/Aprendizaje/graficas/practica_radio_buton.py
530
3.609375
4
from tkinter import * root=Tk() varOpcion=IntVar() def imprimir(): # print("El valor rescatado es ", varOpcion.get()) if varOpcion.get()==1: etiqueta.config(text="Has elegido Male") else: etiqueta.config(text="Has elegido Female") Label(root, text="Género:").pack() Radiobutton(root,text="...
f5cd80625538de6a03526ae14326d3c3675a969d
vivekchoudhary98/ds
/map_lambda
443
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 12 14:30:34 2019 @author: geass """ cube = lambda x: x**3 def fibonacci(n): # return a list of fibonacci numbers l=[] if(n==1): l=[0] if(n>=2): l=[0,1] for i in range(n-2): x=l[i]+l[i+1] ...
38fe8c97adddb8e550c82b2f3bfd8021976d9204
chaosWsF/Python-Practice
/leetcode/0504_base_7.py
615
4.0625
4
""" Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" Example 2: Input: -7 Output: "-10" Note: The input will be in range of [-1e7, 1e7]. """ class Solution: def convertToBase7(self, num): if num < 0: is_neg = True n...
dfb516f19838dabc19e8fe9bbe0186bcdb4a7198
Walt9019/Python_OneMonth
/math.py
300
4
4
#+ plus #- minus # / divide # * times #** exponentiation #< less than #> greater that #% modulo print("What is the awnser to life, the iniverse, and everythong?", (40 + 30 -7) * 2 / 3) print("Is it true 5 * 2 > 3 * 4") print(5 * 2> 3 * 4) print("what is 5 * 2?", 5*2) print("what is 3 * 4?", 3*4)
064984c156e63cd50c2512e8f23a2ef248667754
JugBones/ExerciseAP
/slopealine.py
238
4.03125
4
#formula x1 = float(input ("Enter your x1 : ")) y1 = float(input ("Enter your y1 : ")) x2 = float(input ("Enter your x2 : ")) y2 = float(input ("Enter your y2 : ")) f = (y2-y1)/(x2-x1) #result print("The slope is: {:.5f}.".format(f))
b4a7ec1658292f9a02bf612992d94072cd7aa77c
Tananan-Jee/exp_ict_12
/18B09784_01_12.py
1,475
3.78125
4
# -*- coding: utf-8 -*- #プログラミング言語:Python version 3.8.0 #コンパイル方法:python3 18B09784_01_12.py #実行方法:ターミナル上で python3 18B09784_01_12.py を実行 size=int(input("alphabet size> ")) list = [] for i in range(size): ele =[input("symbol_" + str(i+1) + "> "),input("codeword_" + str(i+1) + "> ")]#get symbol and codeword list....
7814d7290e209492155a14bbeecee5642bb883e6
Eric-Wonbin-Sang/CS110Manager
/2020F_hw6_submissions/kohlimeher/bmi hw 6.py
570
4.15625
4
#function to analyze BMI levels def main(): weight = float(input("Enter weight (in pounds): ")) height = float(input("Enter height (in inches): ")) BMI = weight * 720 / ((height) ** 2) if BMI < 19: print("You are below the healthy range and have a BMI of", BMI) elif BMI >= 19 and BMI <= 25:...
dc3e9647ef28b02949305cadc7bfe4075eb42f18
ikefx/eva.eichelbe02
/cs5320Project02_Eichelberger.py
3,506
3.625
4
""" CS5320 : PROJECT03 NEIL EICHELBERGER """ import math import itertools import random from statistics import * from functions import * from prettytable import PrettyTable def runSim01(numberOfItems:int, W:int, wMax:int, vMax:int): """ FIND THE BEST SEQUENCE OF RANDOM WEIGHT | VALUE """ v = list() w...
3be71a2d700c46b3ec7376399a32ee7507b5ec29
CatrielCaruso/frro-soporte-2019-13
/practico_01/ejercicio-07.py
439
4.03125
4
'''Definir una función es_palindromo() que reconoce palíndromos (es decir, palabras que tienen el mismo aspecto escritas invertidas), ejemplo: es_palindromo ("radar") tendría que devolver True.''' def es_polindromo(cad): reves = cad[::-1] if(cad==reves): return True else: return False pass cadena ...
92a6d4600c1133f1f3c2bd0ac49a9ef733bc41b4
YusiZhang/leetcode-python
/DFS_BackTrack/permutationSequence.py
1,005
3.734375
4
__author__ = 'yusizhang' """ The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123" "132" "213" "231" "312" "321" Given n and k, return the kth permutation sequence. Note: Given n will be between 1...
08422bba771c59e43842499bfdfa8f50c756aaef
kolyanovna/MyMinor2015
/DZ3/DZ3C.py
162
3.5
4
__author__ = 'NikolaiEgorov' def factor(x): if x == 0: return 1 else: return x * factor(x - 1) n = int(input()) print(str(factor(n)))
11419ffe4dfd3f2feb49bbe52fdd0261705be297
sendurr/spring-grading
/submission - Homework2/set2/RACHEL A SMOAK_7052_assignsubmission_file_Homework2/hw2/P3.py
327
3.890625
4
#Rachel Smoak #Homework 2 #14 February 2016 #Problem 3 h = 0.01 #Given value xlist = [] #Empty list to add values to for i in range(0,101): #Numbers 0 to 100 x = 1 + i*h #Generate the coordinates y = round(x,2) #Round to two decimals to get rid of the long trailing numbers xlist.append(y) #Add rounded number to lis...
bf0997cfc0bb991b4415d762f74839ec6d0d9885
Shadaez/euler
/euler10.py
413
3.75
4
"""The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million.""" import math def primeCheck(): p = 2 x = 0 n = 3 while n <= 2000000: x = int(math.ceil(n**.5)) for i in range(2, x + 1): if n%i == 0: break el...
3880a0d8833f2402ec627fa05d1f4c8aaff7d323
shisanjun/fortmachine
/DAY13-李祥-堡垒机/bin/fortmachine/src/fomatter.py
1,032
3.53125
4
# -*- coding:utf-8 -*- __author__ = 'shisanjun' import os,sys BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) #父级目录加入系统环境 sys.path.append(BASE_DIR) class Fomatter(object): def input_str_format(self,input_str): """ 格式化字符串输入 """ while True: format_str...
8763feacf645120ca2ca36450b3929c88bb185b9
taapasX28/RLexperiments
/mountaincar_tcoded_dynaq.py
6,051
3.640625
4
from typing import Sequence import gym import numpy as np from numpy.core.fromnumeric import shape env = gym.make("MountainCar-v0") import time import tiles3 as tc class MountainCarTileCoder: def __init__(self, iht_size=4096, num_tilings=8, num_tiles=8): """ Initializes the MountainCar Tile Coder ...
18bb95e8dc2b3645218b9a0c0b4657cfbde2afb6
yshaikhygali/intro-to-programming-nanodegree
/code_your_quiz/fill_in_the_blank/quiz.py
2,636
4.3125
4
easy_questions = """Classes and objects are the two main aspects of object oriented programming. A __1__ creates a new type where objects are instances of the class. Variables that belong to an object or class are referred to as __2__. Objects can also have functionality by using functions that belong to a class. ...
ef16366b738cf749d1cbe181b862692e6c1fe65c
8563a236e65cede7b14220e65c70ad5718144a3/introduction-python-programming-solutions
/Chapter06/0017_review_questions.py
5,121
4.3125
4
""" Review Questions 1) Lists avoid having a separate variable to store each item which is less efficient and more error prone when you have to perform some operations on these items. Lists are flexible because they can have values added, removed and changed Lists allow you to store heterogeneous ...
997f518d81a8a9820f3c9ea999c7c2a018ae8084
afxdance/fb_productivity
/aggregated.py
4,529
3.515625
4
from urllib.request import urlopen import json import datetime import csv import time import pandas as pd # input group name # input access_token # group_name is the name of the group as it appears in the url # access_token can be attained from Graph API Explorer def getGroupID(group_name, access_token): base =...
f14491e895402d1a0802438b6916b117b03759b8
JMBoter/Euler-Problems
/12_Highly_divisible_triangular_number.py
835
3.625
4
from math import sqrt from util import divisors from datetime import datetime def IsTriangular(n): a = 0.5*(sqrt(8*n+1)-1) remainder = a % int(a) return remainder == 0 def LastTerm(n): if IsTriangular(n) == True: a = 0.5*(sqrt(8*n+1)-1) return int(a) else: return None star...
4efcecd06ee102c2489481b985dbf70e5c6be1fd
jiejie168/array_leetCodes
/RemoveDuplicatSortedArray.py
438
3.5625
4
__author__ = 'Jie' """ """ class Solution: def removeDuplicates(self, nums) -> int: # two pointers count=0 n=len(nums) if n==0: return 0 for i in range(n): if nums[count]!=nums[i]: count+=1 nums[count]=nums[i] ...
0c0688c285a32e9f2d9f1a299a31e459f24f588d
andreskask/taller-recursividad
/10. bases.py
575
3.875
4
def inicio(): if int(input("conversion de bases:\n1: decimal a binario\n2: binario a decimal\n")) == 1: print decimalBinario(int(input("ingrese decimal: "))) else: print binarioDecimal(int(input("ingrese binario: "))) raw_input("enter para salir") def decimalBinario(numero): if numero == 0: ...
d374709d5f30c59b5474dfb8675d24fb7f8035e3
bbkbbbk/Data-Structure
/data_structures/graph/graph.py
3,008
3.546875
4
class UnweightedGraph: def __init__(self, g): self.graph = g def add_edge(self, vertex, neighbour): if vertex not in self.graph: self.graph[vertex] = [neighbour] else: self.graph[vertex].append(neighbour) def print(self): for vertex in self.graph: ...
321e137168121498bba52c96bf06e8bc2d6c2108
Mityun/Analitic_of_my_book
/task.py
298
3.921875
4
def check_wrong_word(key_word): with open('file', 'r') as file: text = file.readlines() for i in text: if key_word in i.lower(): print("Надо менять!!") print('Line:', text.index(i), '\n', i) check_wrong_word('ранг')
e1801b4acac59f957cc9eb21887b2e0eaa86b161
robertslabriab/Swap
/swappingWithKeys.py
603
3.515625
4
import swapInput,swapper,key def unswap(): keyList=swapInput.swapKey() tracker=0 while tracker<len(keyList): if tracker==0: swappedMessage=swapper.swapper(keyList[tracker],swapInput.swapMessage()) else: swappedMessage=swapper.swapper(keyList[tracker],swappedMessage) tracker+=1 return swappedMessage de...
cab30b958c86f0699846cad8c2100f5b35c56e98
AremanHashemi/Practice_Problems
/LeetCode/Python/MoveZeros.py
651
4.03125
4
# Given array of nums move all 0s to the end while mainting order of non zero element """ Algorithm Itterate through numbers If you find a zero increment zero count If you find a non-zero shift it to the left by zero count If index + zero count = end this is where we just put zeroes """ def moveZeroes(nums) -> ...
e93683e67b0e58965c6e03a553caa0e215757453
estebesov01/it_school_files
/Встроенные функции/Ошибки/n2.py
288
4
4
# Спросите у пользователя 5 чисел добавьте их в # SET и скажите какое самое маленькое число он ввел. q = set() for i in range(5): num = int(input("Введите число : ")) q.add(num) print(min(q))
47f343666ff20f8a446c8a1264358e998ce5576f
sunnygeorge1025/my-python-projects
/tictaktoe.py
2,851
4.15625
4
shutdef printbox(): for i in range(3): print("\t") for j in range(3): print(i + 1, j + 1, ':', number[i][j], '\t', end='\t') print() def staircase(n): k = 2 * n - 2 for i in range(0, n): for j in range(0, k): print(end=" ") k = k...
3109ebcff8f79a1c1e12dc02c5329ca8991eeb4c
nikeshD10/BlackJack-Card-Game
/Blackjack/BlackJackConfig.py
12,183
4.1875
4
#Import random for the suffle import random # Declare the Variables to store suits, ranks and values suits = ("Hearts", "Diamonds", "Spades", "Clubs") ranks = ("Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace") values = {"Two":2, "Three":3, "Four":4, "...
761da363f07860cc3973d0da05aa97488bfd4eea
ishamibrahim/BasicProgramming
/LeetCode/24_lc_543_diamter_of_binary_tree.py
1,898
4.15625
4
from typing import Optional from LeetCode.constants import TreeNode """ --easy-- https://leetcode.com/problems/diameter-of-binary-tree/ Given the root of a binary tree, return the length of the diameter of the tree. Solution - Runtime: 67% Memory: 80% """ class Solution: max_diameter = 0 def fi...
f67942b7fadd6c9fed290a868d5ec6cc42dbe330
willghostyou/Breast-cancer-
/dt and svm.py
6,976
3.515625
4
#!/usr/bin/env python # coding: utf-8 # # **A tumor is an abnormal lump or growth of cells. When the cells in the tumor are normal, it is benign. Something just went wrong, and they overgrew and produced a lump. When the cells are abnormal and can grow uncontrollably, they are cancerous cells, and the tumor is malign...
c241f30015785dbfe072be22515e0195e6f78cfa
XingyuHe/cracking-the-coding-interview
/Leetcode/217.ContainsDuplicate.py
411
3.671875
4
def containsDuplicate(nums): from collections import Counter fq = Counter(nums) return fq.most_common(1)[0][1] > 1 def faster(nums): return len(set(nums)) != len(nums) def evenFaster(nums): fq = set([]) for n in nums: if n in fq: return False fq.add(n) retu...
b218c95575378913cda634bec8148874b8a20de0
casol/MS-python-task
/date.py
1,852
3.5625
4
import datetime def earliest_possible(date): lst_date = [int(date_string) for date_string in date.split('/')] for year in lst_date: if len(str(year)) == 4: lst_date.remove(year) day, month = lst_date if month > 12: day, month = month, day ...
d7e2079045ae03fe369db4f0e5e7d815ae91e1cb
MaiconGavino/Uri_in_Golang
/Python/1043.py
487
3.53125
4
line = input().split(" ") ladoA, ladoB, ladoC = line ladoA = float(ladoA) ladoB = float(ladoB) ladoC = float(ladoC) if ladoB - ladoC < ladoA and ladoB + ladoC > ladoA: if ladoA - ladoC < ladoB and ladoA + ladoC > ladoB: if ladoA - ladoB < ladoC and ladoA + ladoB > ladoC: perimetro = ladoA + lado...
0496df19a1e9b694e31cd6aa22315784bae57192
sswaring/advent2015
/Day4/advent2015-4.py
977
3.625
4
# import md5 library import hashlib # variable to hold the input string some_string = "ckczppom" # variable to hold the integer counter some_number = 0 # variable to stick the string and number together puzzle_input = some_string + str(some_number) # loop until the md5 checksum has "00000" as the first 5 characters...
6d288c37aecb3f05e518d1520d60ea27de518cb5
sabrinachen321/LeetCode
/python/0130-solve.py
1,053
3.609375
4
from collections import deque class Solution(object): def solve(self, board): """ :type board: List[List[str]] :rtype: None Do not return anything, modify board in-place instead. """ if not board or not board[0]: return q = deque([]) for i in range(l...
6096eaf46a9aebbfdece1b4af5f7552521d0d8b3
paulmc95/proyecto_taller_sistemas
/model/persona.py
545
3.546875
4
class persona: def __init__(self,id_persona,id_usuario,nombre,apellido_paterno,apellido_materno,correo,celular,genero): self.id_persona=id_persona self.id_usuario=id_usuario self.nombre=nombre self.apellido_paterno=apellido_paterno self.apellido_materno=apellido_materno ...
4761fb7dc803adfed07ae34c5d4871cdf25fa077
Liav8/Games.cards2
/CardGame.py
2,752
3.578125
4
from Player import * from DeckOfCards import * # מחלקה המייצגת משחק קלפים class CardGame: def __init__(self, name1="Player", name2="Player", num=10): self.p1 = Player(name1, num) self.p2 = Player(name2, num) self.deck = DeckOfCards() def __repr__(self): return f"This game's pl...
8ccf8c2ac3a85937615564394956f2611d0391ac
ptavaresh/python_snippets
/regular_expression/regexp.py
411
3.953125
4
""" Regular expressions ^ Start $ Stop . Any character * Match one character 0+ times + Match one character 1+ times ? Non-greedy \s Whitespace \S Non-Whitespace [abc] Match one character in the specified set [^abc] Match one character not in the specified set """ import re myString = 'Send an email...
b3c933bdad7ccb724890880f1864458bb813652b
PostnicovaY/Postnikova_Yana_dz
/Task1.py
892
3.953125
4
class Date: date = '01-01-1970' def __init__(self, str): self.date = str self.day = str.split('-')[0] self.month = str.split('-')[1] self.year = str.split('-')[2] def __str__(self): return '{\n' + f'\tday: {self.day}\n\tmonth: {self.month}\n\tyear: {self.year}\n' + ...
2ce33b466bee7f9fcd019e8f097c1895e60bff4a
jmery24/python
/ippython/numero_primo_v7.py
558
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 28 09:49:39 2013 @author: daniel """ #programa:numero_primo_v8.py #obten los numeros primos en el intervalo (1, n) #data input limite = int(raw_input('Dame un numero: ')) primos = [] #proccesing and printout for num in range(2, limite+1): creo_es_primo = True ...
9c6546e60203b26df4b04c79dc48924440b25f15
yue-sk/Python_practice
/Chapter8/8-7.py
398
4.03125
4
#返回字典 def make_album(artist, title): musician = {"artist":artist,"title":title} return musician music=make_album("A","B") print(music) #可选形参 def make_album(artist, title, num=' '): musician = {"artist":artist,"title":title} if num: musician['num'] = num return musician music=make_album("B...
25dfdc696e89a6e7efb9629549e485aa2a0f5687
maiyeu97/nguyenduyhoang-fundermental-c4e14
/fundamental/session03/delete.py
336
3.65625
4
favs = ['xinh','cute',"vui tinh"] for i, fav in enumerate(favs): print(i + 1, fav, sep=". ") position = int(input("Nhap chi so can xoa:")) # TODO: input validation if position < 1 or position > len(favs): print("Our of range") else: favs.pop(position - 1) for i, fav in enumerate(favs): print(i + 1,...
5207a42931d1281b40706bfab838cf3e6756c73d
sananand007/LeetCodeProblems
/3SUM.py
983
3.71875
4
def three_sum(nums): nums.sort() res = [] n = len(nums) for i in range(n-2): if i==0 or nums[i]>nums[i-1]: sum_find = 0 - nums[i] low = i+1 high = n-1 while(low < high): if nums[low] + nums[high] == sum_find: r...
377c9148e42da82f96a63c2def0b565f96fbbc1a
NathanMuniz/Exercises-Python
/Desafio/ex50.py
228
3.703125
4
soma = 0 cont = 0 for c in range(1, 7): n1 = int(input('Digite Um Numero {}'.format(c))) if n1 % 2 == 0: soma = soma + n1 cont = cont + 1 print('A soma de os {} Numeros Pares são {}'.format(cont, soma))
034efb6fadfac5b2b2a445d08efb3b9f5770e1e1
aaronhodges1126/Python
/random_pass_gen.py
735
3.859375
4
from random import choice from string import ascii_letters, digits, punctuation def password_generator(length=16): chars = tuple(ascii_letters) + tuple(digits) + tuple(punctuation) return ''.join(choice(chars) for x in range(length)) def alternative_password_generator(ctbi, i): pass # Put your code ...
e7cc690edf3bd9fa3c84323587a7617f7493505b
snowcity1231/python_learning
/cycle/for_demo.py
676
3.921875
4
# -*- coding: UTF-8 -*- for letter in 'Python': print '当前字母:', letter print fruits = ['apple', 'banana', 'mango'] for fruit in fruits: print '当前水果:', fruit print # 通过序列迭代索引 for index in range(len(fruits)): # 内置函数len()返回列表长度,range()返回一个序列的数 print '当前水果:', fruits[index] print # for...else else会在循环正常执行完(...
f86b1d1f2c41784c2339e8915e445b27c4633c26
fhulu84/Python_Crs
/Exercises/S01/Set01/06.py
286
4.3125
4
# Given a list of numbers, Iterate it and print only those numbers which are divisible of 5 def print_div_by_5(li): for num in li: if num % 5 == 0: print(num) my_list = [1, 3, 5, 10, 37, 53, 30, 15, 8] print(my_list) print('Finding divisible of 5') print_div_by_5(my_list)
d136f79d21971d0f612d295c1123296dc171264d
Deepti3006/InterviewPractise
/vowelsConsonants.py
477
4.0625
4
def findVowelsConsonants(): string1 = input("Enter the String ") vowels =[] consonants =[] for char in string1: if ((char == 'a') or (char == 'e') or (char == 'i') or (char == 'o')): print("I am vowel") vowels.append(char) else: print("I am consonant"...
e386bce181e63b88dea122ef30953a863a7daa90
jericsinger/Euler
/03 Largest prime factor.py
637
3.984375
4
from sys import argv import math script, to_factor = argv to_factor = int(to_factor) def isPrime(q): # test if q is prime """Test if q is prime. Returns True/False""" prime = False for i in range(2, int(math.sqrt(q))): if q % i == 0: break else: prime = True return prime def isFactor(q, x): # test ...
6076d5e6b47a2c477991e588e897991407fcf0f3
jberkow713/cs-module-project-algorithms
/single_number/single_number.py
811
4
4
''' Input: a List of integers where every int except one shows up twice Returns: an integer ''' def single_number(arr): # Your code here # two nested loops # loop through every element # loop through every element again, compare if two elements match at different parts # of array # count times e...
8d7e0aa78f7df64410421df39f9d4b876cb821f8
cg-taylor/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
542
4.0625
4
#!/usr/bin/python3 """0-add_integer module""" def add_integer(a, b=98): """Add two integers Args: a: the first number b: the second number. Defaults to 98 Raises: TypeError: if a or b is not an integer """ if type(a) not in (float, int): raise TypeError('a must be...
fc3bf6c7262bddebe7e0a8901585d6f63fdb5f8e
danqueiroz/0204-lista-exemplos
/exemplo1.py
395
3.859375
4
def somar(valor1, valor2): resultado = valor1 + valor2 return resultado valor_1 = round(float(input("Digite o primeiro número: ")), 2) valor_2 = round(float(input("Digite o segundo número: ")), 2) resultado_soma = somar(valor1=valor_1, valor2=valor_2) if resultado_soma > 40: print("A soma dos valores é",...
1dd941159810481233454491fec0b4290b9de27f
dmytroreva/cursor
/PycharmProjects/pythonProject9/hw2/hw2.py
5,638
4.28125
4
from abc import abstractmethod, ABC class Animal: def __init__(self, name, age): self.name = name self.age = age """ Perent class, should have eat. sleep """ def eat(self): print(f"A(n) {self.__class__.__name__} called {self.name} is eating.") def sleep(self): ...
672fba09c16426ef11b670a8e30c9860423504ef
summer-vacation/AlgoExec
/jianzhioffer/minNumber.py
1,987
3.609375
4
# -*- coding: utf-8 -*- """ File Name: minNumber.py Author : jynnezhang Date: 2020/4/28 8:18 下午 Description: """ class Solution: def minNumber(self, nums) -> str: if nums is None or len(nums) == 0: return None res = [] cur = [] lens = len(nums) f...
a2481ffbfedbcd1226b29b16ab5374ad90442647
sophiahoffman/python-inheritance
/vehicle.py
1,430
4.15625
4
# Define 5 of your favorite vehicles # Move all common properties in your vehicles to a new Vehicle class. # Create an instance of each vehicle. # Define a different value for each vehicle's properties. # Create a drive() method in the Vehicle class. # Override the drive() method in all the other vehicle classes. Inclu...
cbb48a0da3046920255a146ab07644b4a5cd682b
TeaLeaves/cecs-174-classwork
/lab6.py
1,056
4.21875
4
#get a word def get_word(): word = input("Please enter a word: ").strip().lower() return word #initialize LETTER = 'a' #clarify if a letter in the word is a vowel or nah def is_vowel(LETTER): #return true when letter is vowel if LETTER == 'a' or LETTER == 'e' or LETTER == 'i' or LETTER == 'o' or LETTE...
fa25de15b0aabd1f012009a1f4770bb321ef31c4
jayjay1973/CIS115-Python-Labs
/williamPrudencio_lab6-8.py
1,295
4.1875
4
#Program, williamPrudencio_lab6-8.py, 02/23/19 ''' This program will read the numbers generated onto randomNumber.txt in the previous lab assignment lab6-7. It will display all the numbers that were read from the file and add them together to get a sum total. It will also keep and display a count of how many number ...
540683c9a875e358e279cfd972f26fd669e2a5ba
jose-dev/teaching_python
/src/main/game/hangman/hangman_utils.py
1,772
3.59375
4
import random from os import system, listdir from os.path import isfile, join def read_file_with_words(filename): filein = open(filename, 'r') words = [] for line in filein.readlines(): words.append(line.strip('\n').lower()) return words def collect_dictionaries_from_directory(pathin="resour...
b7e1452185cf7f534915fc91b3bef92be28f2e7d
NicholasDowell/PopulationRiddleTest
/PopGenerator.py
340
3.640625
4
import random boy_num = 0 girl_num = 0 got_girl = False for couple in range(100000000): got_girl = False while got_girl == False: if random.random() > .5: boy_num += 1 else: girl_num += 1 got_girl = True print("{0} : {1}".format(boy_num,girl_num)) print(...
599efa8c7a047c731a2ff7933af4f4981be79ee8
jaredparmer/ThinkPythonRepo
/word_freq.py
4,213
3.90625
4
""" this solves exercises 13.1 through 13.7 of Downey, _Think Python_ 2nd ed """ import string import random from bisect import bisect from dict_fns import load_words_dict as load_dict """ takes a given histogram dictionary and chooses n words from it with a prob- ability in proportion to that words's relative frequ...
2ad1161be6203b5a048bdb49a44d5bef9f2f0f5e
ASHIQKI/Think-Python
/chapter_7/7.3.py
419
3.859375
4
import math def sqrt(n): # print 'the estimate value:', b=0.75*float(n) eps=0.000001 # if n==0: # return 0 # if n==1: # return 1 while True: # print b x=(b+(n/b))/2 if abs(x-b)<eps: return b else: b=x for n in range(1,10): print ...
ebb664f783c1e4ae2c4e03e312a348728418a0db
Lohit9/python_algorithms
/legacy/oopBasic.py
1,566
3.5
4
class LRUCache(object): def __init__(self, capacity=0): """ :type capacity: int """ #lets use an hash map/dictionary self.capacity = capacity self.LRUDict = dict() def getKey(self): #{4a7:2} inputDict = self.LRUDict keys = inputDict.keys() ...
60dac49cc478fad1b4e74513fee9a6e5b6be18ae
ElizabethOkerio/BOOTCAMP-HOMEDAY3
/find_missing.py
154
3.8125
4
def find_missing(arr1, arr2): result=0 if len(arr1)==len(arr2): return result for num in arr1+arr2: result^=num return result
aaad8be201a678061e631ca051938321218a9d3f
StafDehat/badcode
/class04/sieve-faster.py
1,046
3.90625
4
#!/usr/bin/python import math # Re-write primesUnder(x) # Use the Sieve of Eratosthenes, instead of math, to determine # if a number is prime. # https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes def sieveOut(lst, x): if (x == 2): increment = x else: # x is odd. Skip the evens. increment = 2 * x ...
e6bfffcdd73f33c086e27131ab0ba5d03ffbb903
traciarms/team-treehouse-python-track
/percent_letter.py
1,236
4.34375
4
# testing for int and float and also using try and except user_string = input("what's your word? ") user_num = input("what's your number? ") try: # this tells python to try to convert the input into int using the int function our_num = int(user_num) except: #if anything goes wrong with that let's say the user ...
3fed8525137d955939e334ae4beb587e0dd9d8e9
FlyingUnicornSF/ud036_StarterCode
/media.py
398
3.625
4
class Movie(): """Creating Movie class. Take movie title, story line, and link to poster image and trailer youtube""" def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube): self.title = movie_title self.storyline = movie_storyline self.post...
9390ce964fc209587d90f134a5061c50b0ad83ac
brianpattie/concurrency
/dp/dp.py
1,567
3.671875
4
import threading import time class Philosopher(threading.Thread): running = True def __init__(self, name, leftFork, rightFork, lefty): threading.Thread.__init__(self) self.name = name self.leftFork = leftFork self.rightFork = rightFork self.lefty = lefty def run(...
af32410c48f63444fb2971470a60de2a0179c187
futureesch/ops401reading
/python/pingscanner.py
889
3.84375
4
#!/usr/bin/env python3 # Author: Tom Esch # Last Revised: April 6th, 2021 # Purpose: Ping Scanner # Evaluate the response as either success or failure. # Assign success or failure to a status variable. # For every ICMP transmission attempted, print the status variable along with a comprehensive timestamp a...
d189d901d2cbad9ad43c363f78b17058c779e246
MeParas324/Python-programs
/pythontuts/map filter.py
947
3.890625
4
# numbers=["3","4","56","45","9","90","34"] # print(map(int, numbers)) # numbers=list(map(int, numbers)) # for i in range(len(numbers)): # numbers[i]=int(numbers[i]) # numbers[2]=numbers[2]+1 # print(numbers[2]) # def sq(a): # return a*a # # num=[2,5,5,33,7,7,234] # square=list(map(sq,num)) # print(square) ...
c21a2a64e5bbe05baf724e3bc40ba5f1cae46741
jhonnjc15/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/6-print_sorted_dictionary.py
180
3.984375
4
#!/usr/bin/python3 def print_sorted_dictionary(a_dictionary): sorted_dic = sorted(a_dictionary) for i in sorted_dic: print("{:s}: {}".format(i, a_dictionary[i]))
77a060033f33b6b8a1d7337c337c5511dee0c35b
AbdulMoizChishti/python-practice
/Pfundamental Lab/Lab 6/Task 2.py
276
3.59375
4
a = 900 b = 1000 print("\tFollowing are the Prime numbers between", a, "and", b,"\n") for num in range(a, b + 1): if num > 1: for i in range(2, num): if (num % i) == 0: break else: print(num, end =" ")
a3fa7af14e1b5ed7f063dd24239746f7de3da902
ParkerAli/CS-1st-Year-Assignments
/Python/Recursion (Pattern match detection exercises)/src/advancedmatch.py
721
4
4
def match(pattern,word): find=pattern.find('*') if find==0: if pattern=='*': return True elif pattern[-1]==word[-1] or pattern[-1]=='?': return match(pattern[:-2],word[:-2]) else: return False elif find==(len(pattern)-1): if pattern[0]==wo...
7255a33fca2a09ec52f79642568f71c82f5f04e0
notalexg/Ch.04_Conditionals
/4.2_Grading_2.0.py
1,199
4.09375
4
''' GRADING 2.0 ------------------- Copy your Grading 1.0 program and modify it to also print out the letter grade depending on the numerical grade. If they fail, tell them to "Transfer to Johnston!" ''' print() print("So you want to know what your grade will be? \nBeen slacking and want to know what you need to get an...
92dfec763178e05b3091f91f64e41e3980916d86
debugyes/Python-Learning
/chapter4/making_numerical_lists/threes.py
81
3.6875
4
threes = [value * 3 for value in range(3, 31)] for value in threes: print(value)
46d567b6490c0da55ebd98224346b83a173ca405
qingfengxia/python-projecteuler
/projecteuler/projectEuler51.py
2,727
3.78125
4
# -*- coding: utf-8 -*- from __future__ import print_function, unicode_literals, absolute_import, division """ problem description: By replacing the 1st digit of *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime. By replacing the 3rd and 4th digits of 56**3 with ...
1639f6e22fd055b9159a2ba97a7dfe729c1ff2e2
HuangZengPei/LeetCode
/Easy/Que125回文字符串.py
755
3.671875
4
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ if not s:return True def check(c): if '0' <= c <= '9' or 'a' <= c <= 'z' or 'A' <= c <= 'Z': return True return False s = s.lower() ...
3805de33d85f1d01adb51c02a26cef0414b64cfb
Drmanzanas/Hackaton_Python
/Kata 1/main2.py
542
3.828125
4
''' Escribir un programa que almacene la cadena de caracteresa contraseña en una variable, pregunte al usuario por la contraseña e imprima por pantalla si la contraseña introducida por el usuario coincide con la guardada en la variable sin tener en cuenta mayusculas y minusculas ''' password = 'contraseña' password_d...
7bfb2ec5edf6f1380f6c7b518c2c8858e52d693b
702criticcal/1Day1Commit
/Baekjoon/11586.py
265
3.703125
4
n = int(input()) mirror = [input() for _ in range(n)] k = int(input()) if k == 1: for i in range(n): print(mirror[i]) elif k == 2: for i in range(n): print(mirror[i][::-1]) else: for i in range(n - 1, -1, -1): print(mirror[i])
768104fe52ead1a70251b4496b586d0778a1bb8b
Shisan-xd/testPy
/python_work/day9_04函数嵌套调用.py
660
4.09375
4
# 函数嵌套调用---多条横线 def print_line1(): print('-' * 40) # def print_lines(num): # i = 0 # while i < num: # print_line1() # i += 1 # print_lines(3) def print_lines1(bu): a = 0 while a < bu: print_line1() a += 1 print_lines1(5) # 嵌套调用之函数计算 # 函数求和计算 def sum_mua(a, b...
e4d4165b60c55630a672c9e4559ae5c5c13cf7ad
pymft/mft-04
/S06/decorators/the_basic_idea.py
512
3.59375
4
import time from math import sqrt def decorator(f): def decorated(*args, **kwargs): t1 = time.time() out = f(*args, **kwargs) t2 = time.time() print("elapsed time = ", t2-t1) return out return decorated @decorator def is_prime(n): limit = n for i in range(2, l...
0c3e0c77f2c9185255777068eb4ef207f5ff8908
JerryCheung1005/A_Bastards_Homework
/1/2.py
354
3.796875
4
'''list1 = [] while True: num = int(input("Enter a number: ")) list1.append(num) con = str(input("Continue or not: (Yes or No): ")) if not con.lower() in ("yes"): break print(sorted(list1, reverse=True))''' def fuckone(): print('fuck u mom') def fucktwo(): print("jb") def main(): ...
32e151cc8d0baf3d7f73f6830e88ecf933663ade
jkeane889/ThinkLikeACS
/GradingTool.py
529
3.84375
4
import math def gradeScale(): for i in [56, 84, 90, 45, 88, 79, 90, 95]: if i >= 90: print(i, "- You received an A - congratulations!") elif i >= 80 and i < 90: print(i, "- You received a B - congrats!") elif i >= 70 and i <80: print(i, "- You received a ...
99d6fe6c14c04c03e9d98e0d3a6285f563989e80
golmschenk/simplex
/simplex.py
6,658
3.703125
4
""" The class for solving simplex. Given a standard LPP, finds the optimal solution through simplex method. """ import numpy as np from variable import Variable class Simplex: """Class to preform simplex.""" def __init__(self, coefficients=np.array([[]], dtype='float'), const...
0186e33abffaa4a2ab6456c685d07f0920c7be65
nguyenhoangdung123/nguyenhoangdung
/session6/list.py
94
3.609375
4
items = ["com","bun","chao"] print(items) new_item = "pho" items.append(new_item) print(items)
8ee7c17a1538ccf8bc59b26667b41224121e6b3a
Baidaly/datacamp-samples
/14 - Data manipulation with Pandas/chapter 2 - Aggregating Data/10 - Pivoting on one variable.py
1,082
4.40625
4
''' Pivot tables are the standard way of aggregating data in spreadsheets. In pandas, pivot tables are essentially just another way of performing grouped calculations. That is, the .pivot_table() method is just an alternative to .groupby(). In this exercise, you'll perform calculations using .pivot_table() to replicat...
d0a4f9a3de03c1c07e050cb3906a31673a2b1f0d
ElijahYG/Leetcode_Python
/206-Reverse Linked List.py
1,849
3.625
4
''' Reverse a singly linked list. click to show more hints. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both? 反转单链表。 单击以显示更多提示。 暗示: 链接列表可以迭代地或递归地反转。 你能实现两者吗? ''' # ------------------------------------------------------------------------------------------------- ''' le...
15caacd4de2ab28e2bc67bba222d72234bb35a6c
ehjalmar/AoC2020
/day1.py
417
3.5625
4
import math file=open('day1input.txt', 'r') lines = file.readlines() for line in lines: i = 0 while i < len(lines): currentNumber = int(line) if (currentNumber + int(lines[i])) == 2020: print('Found the numbers!') print(str(currentNumber) + ' + ' + lines[i]) ...
dc95e7af304b23f0c9c67a4c482609ef5897d47d
KaranPupneja/typography-turtle
/NUM.py
4,064
3.53125
4
import turtle # all numbers will be digital font def draw_1(offset): # drawing number 1 on = turtle.Turtle() on.speed(4) on.color("white") on.up() on.forward(offset) on.down() on.up() on.left(90) on.forward(100) on.right(90) on.forward(10) on.right(90) on.down(...
0ed6e2f9043e0156fa1d8110838795ce29d42d73
ankitwayne/Python-Practice
/VowelRemover.py
327
3.859375
4
x = input("Enter any string: ") if x == 's': exit(); else: w = x; vow = ('a', 'e', 'i', 'o', 'u'); for s in x.lower(): if s in vow: print("Vowels removed are : ",s); w = w.replace(s,""); print("New string after successfully removed all the vowels:"); pr...
835298884f19dc41ff6c1bf2f1c0e4b13cee750a
williamguilhermeprochnow/TrabalhosPython
/Aula23.py/aula23.py
1,002
3.9375
4
total = 0,365 dias_de_cada_mes = { 1:31, 2:28, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31, } # qual_mes = int(input('Digite o número do mês:')) # print('O mês', qual_mes, 'tem', dias_de_cada_mes[qual_mes], 'dias') # print('Dias que faltam para acabar o...
e6024971fca1026f19a6e3507e9b98d7337699c9
figgybit/alogrithms
/quick_data_structure.py
1,042
3.609375
4
# data structure with fast insertion, removal, membership testing, and random import QuickSort import random class QuickData: def __init__(self): self.quick_list = [] self.quick_hash = {} def add(self, x): if x not in self.quick_hash: self.quick_list.append(x) self.quick_hash[x] = len(self....