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
3c3fd0683a8185ece305f3a49db98b229bf00ea2
SP18-Introduction-Computer-Science/hello-world-python-BrandonConrad
/Question7.py
143
3.65625
4
a = [ 2, 4, 6, 8, 10, 12 ] def altElement(a): b = [] for i in a: b.append(a) print b def altElement(a): return a[::2]
1690d3b401b79511a733b43c5dbfe814ffd26e9b
igormartins1/Python-Projetos
/Exercicios Python/Python-Antigos/fatorial.py
115
3.90625
4
fatorial=1 n=int(input('Digite um valor de n:')) while(n>0): fatorial=fatorial*n n-=1 print(fatorial)
a2318f87b16e2a7ddbb2a2a14fea964e69923972
MichalKotecki/DataCiphering
/ModularInverse/ModularInverse.py
1,517
4.1875
4
# Title: Modular Inverse in Python # Author: Michał Kotecki # Date: 5/09/2020 # Description: # This algorithm is used to find S in (a * S) mod b = 1, given that a and b are known. # This kind of problem is called 'Prime Factorization'. class TableRow: def __init__(self, q, r, s): self.q = q self.r ...
0d20dfb61332e71ad8220acf89da824a5b1721f8
pauladaly/pands-problem-set
/solution-8.py
243
3.875
4
# Paula Daly Solution to Problem 8 March 2019 # Datetime import datetime as dt # Setting the display of todays date in the fomat Day, Month, Date, Year, time today = dt.datetime.strftime(dt.datetime.now(),"%A, %B %dth, %G at %I:%M%p") print(today)
68198758a77cce4ea9cceae3d0e51069aa0a76a1
kirklaursen/PythonSamples
/Decorators.py
802
3.65625
4
# # Basic example of a decorator function # You can also use decorator classes # See https://www.youtube.com/watch?v=FsAPt_9Bf3U def decorator_function(original_function): def wrapper_function(): print('wrapper executed here.') return original_function() return wrapper_function # def display...
35601e6231ec63c080fb814d705b2545a5fa51fe
lewiuberg/visual-automata
/visual_automata/colors.py
1,873
3.703125
4
from colormath.color_conversions import convert_color from colormath.color_objects import sRGBColor from typing import Generator import numpy as np def create_palette( start_rgb: sRGBColor, end_rgb: sRGBColor, n: int, colorspace: sRGBColor ) -> list: """ Generates color palette based on start and end colo...
c37a1aef6c44f1ee72f8b818f894ae73b99416dd
cody-brock/toy-problems
/valid_pandrome_2.py
2,126
3.671875
4
# Runtime: 92 ms, faster than 81.22% of Python online submissions for Valid Palindrome II. # Memory Usage: 14.4 MB, less than 33.69% of Python online submissions for Valid Palindrome II. class Solution(object): def validPalindrome_improved(self, s): """ :type s: str :rtype: bool """ ...
bc80369fe4b1eb8d89e81060a2f87416a9977217
cyphar/ncss
/2012/w4/q6.py
245
3.609375
4
#!/usr/bin/env python2 words = [k.strip() for k in open('dictionary.txt', 'rU')] d = {} for x in words: a,b = x.split(",") d[a] = b for inp in iter(lambda:raw_input("English: "), ""): abo = [d[s] for s in inp.split()] print " ".join(abo)
87367cbc3a813ea24619049462be747da899182f
cyphar/ncss
/2014/w4/q4.py
3,276
3.828125
4
#!/usr/bin/env python3 # Enter your code for "Falling Balls" here. class Point(object): def __init__(self, x, y): self.x = x self.y = y def __str__(self): return "(%r, %r)" % (self.x, self.y) def __repr__(self): return self.__str__() class Line(object): def __init__(self, p1, p2): # Only deal with on...
c1649abbfeea25a8b318f96a8dfe086a1d8a1a40
cyphar/ncss
/2014/w2/q4complex.py
1,806
4.1875
4
#!/usr/bin/env python3 # Enter your code for "Mysterious Dates" here. # THIS WAS MY INITAL SOLUTION. # IT DOES NOT PASS THE TEST CASES. # However, the reason I added this is because this code will take any date # format (not just the given ones) and brute-force the first non-ambiguous # representation. It is (in my op...
0665338a2114e143bd9285ce959a189cc7cee720
cyphar/ncss
/2013/w1/q4.py
348
3.75
4
#!/usr/bin python3 # Enter your code for "Autobiographical Numbers" here. inp = input("Number: ") def is_auto(num): if len(num) > 10: return False for x in range(0, len(num) - 1): if int(num[x]) != num.count(str(x)): return False return True print("%s is %s" % (inp, "autobiographical" if is_auto(inp) el...
ab91ea3813f0366a38ee1b622c90512e1801e42a
cyphar/ncss
/2012/w3/q2.py
174
3.890625
4
#!/usr/bin/env python2 msg = str(raw_input("Message: ")).lower().split() w = set(msg) for word in w: if word in msg: msg.remove(word) if len(msg): print " ".join(msg)
975d2fda89c20ef9eb905931ed1c09ac40a83b5c
cyphar/ncss
/2013/w4/q1.py
624
3.578125
4
#!/usr/bin/env python3 # Enter your code for "Carry On" here. def carries(a, b): biglen = max([len(str(a)), len(str(b))]) + 1 x,y = str(a).zfill(biglen),str(b).zfill(biglen) new = [] carries = 0 for digit in zip(x, y): new += [[digit[0], digit[1], 0]] for pos in range(biglen - 1, -1, -1): place = new[pos] ...
0b97acfebbe22ff11bd4c3397aaf1fb953e20a24
cyphar/ncss
/2014/w1/q6.py
318
3.59375
4
#!/usr/bin/env python3 # Enter your code for "1800-BUY-NOW" here. def count_collisions(text, keypad): occur = {} for word in text.split(): keys = tuple(keypad[letter] for letter in word.lower()) if keys not in occur: occur[keys] = 0 occur[keys] += 1 return sum(val for val in occur.values() if val > 1)
f6d1e8e2cb91da9ffd94101d502740d83d85677a
kadu-ymd/ep2
/jogo.py
2,692
3.671875
4
from funcs import * from colorama import Fore, Style print(print_jogo()) quer_jogar = True baralho = [] # COMEÇO DO JOGO while quer_jogar: cartas = rand_lista(cria_baralho()) for carta in cartas: baralho.append(carta) while possui_movimentos_possiveis(baralho) == True: posicao_ = True ...
c90679780cb9c7c20b6c19486dd816a428da65b4
prodkuredo/school
/ege 23.py
172
3.75
4
def f(a,b): if a > b or a == 11 or a == 18: return 0 if a == b: return 1 else: return f(a+1,b)+f(a+2,b)+f(a*3,b) print(f(4,8)*f(8,23))
84413399fa5ed98f3f665ff5c3089f8b5765e873
yadamit/Machine-Learning
/digit_classifier/digit_beginner.py
2,635
3.59375
4
# https://www.kaggle.com/c/digit-recognizer/data #MNIST beginner #python3 import numpy as np import tensorflow as tf from math import ceil train_data = np.genfromtxt('train.csv', delimiter=',' , skip_header=1); test_data = np.genfromtxt('test.csv', delimiter=',' , skip_header=1); train_X = train_data[:,1:] train_y = t...
a36764a526518e013610fbec80772891d9b9410e
eduardo-a-silva/Python-project
/REO_1/function_4.py
607
3.84375
4
print("") print("----------------------------------------------------------------------------------------------------") print("Função para o exercício 4") def media(vetor): somador = 0 for num in vetor: somador += num # somador = somador + num media = somador / len(vetor) return medi...
61b036fa9fb5e7d9f6332d5e51a6a4ca9f09ab91
eccrawford/Advent-of-Code-2019
/day03.py
1,761
3.8125
4
#Advent of Code 2019 - Day 3 #Part One f = open('day03input.txt') center = (0,0) wiresPath = [] wire1coords = [] wire2coords = [] for line in f: wire = line.split(",") wiresPath.append(wire) def listCoords(directions, coordList): xcounter = 0 ycounter = 0 for direction in directions: di...
d6160bce762f9b8b9977844d3129018321ebb702
Daniex/OJcode
/leetcode/algorithms/2.AddTwoNumbers/Solution.py
2,200
3.890625
4
# You are given two linked lists representing two non-negative numbers. # 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. # # Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) # Output: 7 -> 0 -> 8 # Definition for singly-linked list. cla...
03c4303626c1585e5ab2b04eb4c9f247cf85d5a7
dgberg89/dsp
/python/q7_lists.py
4,096
3.96875
4
# Based on materials copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 #def match_ends(words): """ Given a list of strings, return the count of the number of strings where the string length is 2 or more and the first and last chars of the string are the same. >>> match_e...
2310ccd8502d78146011624b78fcb892ece122c2
dennis-sell/Euler
/python/Euler1.py
155
3.578125
4
def euler1(): l = range(1000) return sum(set(l[::3] + l[::5])) def euler1a(): return sum(x for x in range(1000) if x % 3 == 0 or x % 5 == 0)
1166a432d872fa09433ddcb117716165aab302b4
Honestpuck/xworld2017
/animals/animal.py
2,346
3.9375
4
#!/usr/bin/python ''' Port of BASIC game to Python. Attempts to guess the animal you are thinking of. ''' import sys import io Q_POS = 0 Y_POS = 1 N_POS = 2 last_answer = '' # Was the last answer Y or N last_question = '' # index of the last question asked next_index = 1 # 1 + number of entries in our array anoth...
495426b15ad4ebc28ee76d58bd3c27799af3c050
NithinKumaraNT/DNN_Quantizer
/quantization.py
13,935
3.640625
4
import tensorflow as tf import math as mathlib #-----------------------------some important methods for quantization------------------------------ def clip_max(x, c, alpha): """ The clipping function in the maximum saturation region Args: c: tf.tensor in R, the range to clip to a...
c2433daa1e9deb0ef529eca516bd62cb42f13f0b
Clement-Roque/swapi-tornado
/project/models/people.py
2,844
3.515625
4
import dictionary class People: def __init__(self, people): self.id = people[dictionary.people_id] self.name = people[dictionary.name] self.birth_year = people[dictionary.birth_year] self.eye_color = people[dictionary.eye_color] self.gender = people[dictionary.gender] ...
ba4603bd6884ba7b213b1069263ec7fc2f697d0a
LucWendel/Python-Basic
/5-eindopdracht/eindopdracht.py
686
3.890625
4
import time #Zodat hij de secondes kan wachten seconds = input("Sec: ") s = int(seconds) minute = input("Min: ") m = int(minute) hour = input("Hour: ") h = int(hour) #Input voor de gewenste tijd while (s < 60): #inplaats van een for gebruik ik while zodat hij stopt met tellen bij de 60 seconden marking prin...
9506387889d6c1afd636e22e575ab2934f7d913e
kani67/More-Python-Programming
/chap05/1TestClock.py
4,609
3.8125
4
import sys, random, math, pygame from pygame.locals import * from datetime import datetime, date, time from tkinter import * tk = Tk() class Clock(): def __init__(self): self.pos_x = 300 self.pos_y = 250 self.radius = 250 self.middle_radius = 25 self.x0 = 0 self...
d93d3bf5fac9212f005a047b735808b7636a76c6
yiyuxiniao/MLPythonTutorial
/OOP/Inheritence.py
1,005
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """继承 """ __author__ = 'mlyixi' class RoundFloat(float): def __new__(cls, val): # 实例构造器, 一般只有对不可变的标准类型使用 return super(RoundFloat, cls).__new__(cls,round(val,2)) class SortedKeyDict(dict): # 对于可变对象的继承, 一般只要覆盖特定方法就行了 def keys(self): return sorted(s...
95e13c96a3e78f8ae9554137b787ff97e0e7077e
jonathanwd/python-forensics
/jpg_extractor.py
1,135
3.703125
4
""" This script scans files for hidden jpg files. If a file contains a jpg file, it will be extracted using the jpg file's header and trailer file signatures. """ import argparse import binascii def parse_args(): parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('-i', ...
aed5baa1e6b4d2c858be6157400fddd13b193e8a
Aonu78/Project-management-system
/Background.py
294
3.671875
4
from tkinter import * import GUI1 import GUI2 # the first gui owns the root window root = Tk() gui1 = GUI1.GUI(root) gui1.pack(fill="both", expand=True) # the second GUI is in a Toplevel win2 = Toplevel(root) gui2 = GUI2.GUI(win2) gui2.pack(fill="both", expand=True) mainloop()
94465b8bc666c3e20ceab8d4f28797d3a18868d1
Aonu78/Project-management-system
/Program_function.py
676
3.609375
4
from tkinter import * import random import setup from PIL import Image,ImageTk screen = Tk() lpc = globals()[setup.ima] result = Label(screen,text='cksdckjs') result.grid(row=0,column=0) def generate(): random_number = random.randint(1, 1000) result['text'] = "Number: " + str(random_number) ...
35e78a6bfae40316a673c56539a393b94c4c4428
Aonu78/Project-management-system
/create data base.py
6,427
3.828125
4
import sqlite3 from tkinter import * from tkcalendar import DateEntry, Calendar import time import random root = Tk() conn = sqlite3.connect('Whole_Database.db') cmd = conn.cursor() def test(Campus_entry): print("Enter in test mode") conn = sqlite3.connect('Whole_Database.db') cmd = conn.curs...
f0327878a8e625b480636220e4cd01fb4f8ad9c8
rephus/tweeting-plants
/db/sensor.py
936
3.65625
4
from sqlite import Sqlite import time class Sensor(Sqlite): table = "sensors" def __init__(self): Sqlite.__init__(self) #This table must be included in the default schema (see evolutions) def save(self,temperature, humidity, light): c = self._conn.cursor() now = int(time.time()) dat...
3aefb3b1737d670d2361d707ef2881e4d3f87f2f
pangbochen/leetjob
/code/1-100/4_median_of_two_sorted_arrays.py
2,124
3.953125
4
''' 4. Median of Two Sorted Arrays Hard 4068 547 Favorite Share There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: nums1 = [1, ...
351c9a477b75b37695abd583b2f8edb2d5ce04b9
niteshagrahari/pythoncodecamp
/pascalstriangle.py
135
3.640625
4
def pascal(y,x): print(y,x) if x==1: return 1 if y==x: return 1 return pascal(y-1,x) +pascal(y-1,x-1)
64c4ba30d4bd24b00656119b133cf4319e19e96c
niteshagrahari/pythoncodecamp
/interview/propercase.py
253
4.0625
4
name = "sachin RAmesh tenDulKar" print(name) propername = "" parts=name.split(" ") for part in parts: part = part.lower() letter1 = part[0].upper() otherletters = part[1:] newpart = letter1 + otherletters propername += newpart + " " print(propername)
9c51a95a4e57edf2d5dbce1f0addfee004a41f15
niteshagrahari/pythoncodecamp
/simpleio.py
83
3.78125
4
a=input("Enter a\n") b=input("Enter b\n") a=int(a) b=int(b) print(a+b) print(a-b)
ac46a3d6e285422cc1a35a3bb2d092107e284492
niteshagrahari/pythoncodecamp
/Interview Questions/arrays/readlist.py
120
3.71875
4
l = [] n = int(input("Enter length\n")) for i in range(n): x = int(input("Enter value\n")) l = l + [x] print(l)
dd1b80abb2cbb86ecb4f354cf120542a92eb4acc
niteshagrahari/pythoncodecamp
/niteshcsv.py
323
3.84375
4
import csv # csv fileused id Geeks.csv filename = "Geeks.csv" # opening the file using "with" # statement with open(filename, 'r') as data: for line in csv.reader(data): print(line) # then data is read line by line # using csv.reader the printed # result will be in a list format # which is easy to interp...
94228f4aad6aff073104fb7ade0f6e6ddf69389d
daaniel3232/curso_intensivo_de_python
/cap_04/4.11 – Minhas pizzas, suas pizzas.py
332
4.0625
4
pizzas = ['queijo', 'portuguesa', 'mista', '4 queijos', 'frango'] friend_pizzas = pizzas[:] pizzas.append('calabresa') friend_pizzas.append('banana') for minha in pizzas: print("Minhas pizzas favoritas são: "+minha.title()) for friends in friend_pizzas: print("As pizzas favoritas dos meus amigos são: "+friend...
563806710fedfbaa76595b8a33cae43dee4b8767
cedric448/pysyl
/week1/calculator-new.py
1,350
3.5625
4
#!/usr/bin/env python3 import sys def cal_tax(income): tax = 0 earn = 0 insurance = income * 16.5 / 100 b = income - insurance -3500 if b <= 0: tax = 0 elif b <= 1500: tax = b * 0.03 elif b > 1500 and b <= 4500: tax = b * 0.10 - 105 elif b > 4500 and b <= 9000: ...
286c5cfa9a21bb9f30ef4381f3cc48ae7abb42cc
rppgithub/CarND-Advanced-Lane_Finding
/Advanced_Lane_Finding.py
23,039
3.53125
4
import numpy as np import cv2 import glob import matplotlib.pyplot as plt import matplotlib.image as mpimg # ## Advanced Lane Finding Project # # The goals / steps of this project are the following: # # * Compute the camera calibration matrix and distortion coefficients given a set of chessboard images. # * Apply a...
6b5688ee4c4cd94739bea1e50193904653ff4fc7
vincedinh/salesproject
/scraping_scripts/nordstrom.py
548
3.6875
4
import requests from bs4 import BeautifulSoup # Using the requests module, we use the "get" function # provided to access the webpage provided as an # argument to this function: result = requests.get("https://www.nordstrom.com/") # Check for 200 OK response print(result.status_code) print(result.headers) src = resul...
bf48560a8e6796bd8729740f5bdae07573324b3d
darjeeling4g/web_scrapper
/challenge/day2.py
740
3.96875
4
""" As you can see, the code is broken. Create the missing functions, use default arguments. Sometimes you have to use 'return' and sometimes you dont. Start by creating the functions """ def is_on_list(days, day): return day in days def get_x(days, num): return days[num] def add_x(days, day): return day...
dae087736ea32a4218fd96670bbc1011d3faf429
gaziozgen/practices
/Reverse String.py
241
3.6875
4
# https://leetcode.com/problems/reverse-string/ # 22.10.2020 class Solution: def reverseString(self, s: List[str]) -> None: for i in range(int(len(s)/2)): a = s[i] s[i] = s[-i-1] s[-i-1]= a
954ecbf16326abddafe9b391a88fabe0393cc50e
dhwani910/w18c-fizzbuzz
/app.py
409
4.125
4
numbers = [10, 22, 27, 30, 29, 18, 21, 1, 28, 20, 18, 5, 19, 9, 11, 22, 15, 20, 0, 6, 12, 7, 17] def fizzbuzz(number): if(number % 3 == 0 and number % 5 == 0): print("fizzbuzz") elif(number % 3 ==0): print("fizz") elif(number % 5 == 0): print("buzz") else: print...
d5a9b370c4d610329ea0e3a0913f58fd0750c243
Mohit030802/GeekWeek-Local
/Mohit030802/DAY-2-PROBLEM-3.py
547
3.53125
4
#You are given a string S. Your task is to determine if the given string S contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). Print "YES" or "NO". #include <string.h> #include <stdio.h> #include <iostream> using namespace std; void twoSubstrings(char *s) { char *p; ...
c684944ef69f75a3ef0ca7f51366b6c281efe980
DyllanSowersTR/CIS224
/Dyllan_Ethan_Project1.py
3,294
3.96875
4
# Dyllan Sowers and Ethan Curley # CIS 224 Project 1 import math import struct def convert_to_decimal(n): while n > 1: n = n/10 return n # Converts a floating point number to binary def convert_float_binary(n): # Left and right of decimal point left, right = str(n).split(".") left = int(l...
dd6ae39fef3b4f4b5de133c1e1dc4df42cde1c3d
yuqinq/hackerrank_problems
/Day3_IntroToConditionalStatements.py
230
3.828125
4
import sys N = int(input().strip()) if N%2 == 1: print ("Weird") elif N%2 == 0 and N<=5 and N >=2: print ('Not Weird') elif N%2 == 0 and N<=20 and N >=6: print ('Weird') elif N%2 == 0 and N>=20: print ('Not Weird')
a63cc098e7cd096d2a91675486635c69c2d42207
reard96/data-structures-and-algorithms
/algorithmic-toolbox/week_3/3_car_fueling.py
706
3.828125
4
# python3 import sys def compute_min_refills(distance, tank, stops): # number of gas stations n = len(stops) # add start and end points stops.insert(0, 0) stops.append(distance) numRefills = 0 currentRefill = 0 while currentRefill <= n: lastRefill = currentRefill whi...
c1e1f6f4e260d11c98559788dfd17a9bb79823af
reard96/data-structures-and-algorithms
/algorithmic-toolbox/week_2/5_fibonacci_huge.py
588
3.609375
4
# Uses python3 import sys def get_fibonacci_huge(n, m): if n <= 1: return n cache = [0, 1] previousMod = 0 currentMod = 1 for i in range(n - 1): tempMod = previousMod previousMod = currentMod % m currentMod = (tempMod + currentMod) % m cache.append(currentM...
5371e2fd9ae36d2da346c44ff4416db76031f789
VolkovDV/Python_lessons_basic
/lesson05/home_work/hw05_easy.py
1,406
3.765625
4
# Задача-1: # Напишите скрипт, создающий директории dir_1 - dir_9 в папке, # из которой запущен данный скрипт. # И второй скрипт, удаляющий эти папки. import os import sys from shutil import copyfile print(sys.path) sys.path.append(r'C:\Users\Dmitrii\PycharmProjects\Python_lessons_basic') def makedir(name): dir_pa...
a821362c5af3561b34d54c12ddf19d72266ba5f4
VolkovDV/Python_lessons_basic
/lesson02/home_work/hw02_hard.py
5,044
3.75
4
# Задание-1: уравнение прямой вида y = kx + b задано в виде строки. # Определить координату y точки с заданной координатой x. equation = 'y = -12x + 11111140.2121' x = 2.5 # вычислите и выведите y eq= equation.index('=') equation = equation[eq+1:].lstrip(' ') x_pos = equation.index('x') k = float(equation[:x_pos]) equ...
84814003da3ec8a7659390929b92bbb8fe085626
lucassimon/exercicios-em-python
/lista_de_exercicios/estrutura_sequencial/exercicio03.py
344
4
4
# -*- coding: utf-8 -*- __author__ = 'lucas' # Faça um Programa que peça dois números e imprima a soma. numero_um = input('Informe o primeiro numero:\n> ') numero_dois = input('Informe o segundo numero:\n> ') print 'A soma do primeiro numero(%d) + o segundo numero(%d) e = %d' % (numero_um, numero_dois, num...
0aea41b84aad8a3f54017d0ef48c00ca326eca32
lucassimon/exercicios-em-python
/python-para-zumbis/comecando_com_basico/exercicio01_lucassimon_01.py
571
3.75
4
# -*- coding: utf-8 -*- __author__ = u'lucas simon' u""" lista de exercicios 01 Url: https://pingmind-private.s3.amazonaws.com/exercises/attachments/Lista_de_Exerc%C3%ADcios_I_Python_para_Zumbis.pdf?Signature=m20t0GoOXGi3SuVG8WujkY6YJUA%3D&Expires=1380467241&AWSAccessKeyId=AKIAIEIV5JA2YZL4TUJA Enunciado: Faça um pro...
e197e3f73c4d8a6b44dcc0d0ab921f067f903b8e
lucassimon/exercicios-em-python
/python-para-zumbis/comecando_com_basico/exercicio01_lucassimon_06.py
2,532
3.703125
4
# -*- coding: utf-8 -*- __author__ = u'lucas simon' u""" lista de exercicios 01 Url: https://pingmind-private.s3.amazonaws.com/exercises/attachments/Lista_de_Exerc%C3%ADcios_I_Python_para_Zumbis.pdf?Signature=m20t0GoOXGi3SuVG8WujkY6YJUA%3D&Expires=1380467241&AWSAccessKeyId=AKIAIEIV5JA2YZL4TUJA Enunciado: Calcule o t...
a1ff68ab2c51dd5a859cfe919875cefa97cc5008
YIREN1/speechossitant
/main.py
2,861
3.53125
4
import speech_recognition as sr import playsound # to play an audio file from gtts import gTTS # google text to speech import random from time import ctime # get time details import webbrowser # open browser # import yfinance as yf # to fetch financial data import ssl import certifi import time import os # to remo...
d028421be1e8717323a97aa80d7c0b51f24d3193
simonhwp/Python
/list-str-tuple.py
3,358
3.84375
4
# 输入一串数字,并从大到小排序 num = input('Enter New num:') new_num = list(map(int, num.strip().split())) print(new_num) # new_num.sorted(reverse=False) print(sorted(new_num, reverse=True)) print(new_num.sort(reverse=True)) # 测试得分放到一个列表中,并求出平均值 num = input('Enter New num:') new_num = list(map(int, num.strip().split())) total = 0 ...
76c2a205292169daea9e1c5c085dea4525992e94
javedbaloch4/python-programs
/01-Basics/015-print-formatting.py
490
4.125
4
#!C:/python/python print("Content-type: text/html\n\n") s = "string" x = 123 # print ("Place my variable here: %s" %s) # Prints the string and also convert this into string # print("Floating point number: %0.3f" %1335) # Prints the following floating number .3 is decimal point # print("Convert into string %r" %x) # ...
107e593411b9178b8ad8f3da7351efcaf4e3e981
javedbaloch4/python-programs
/01-Basics/002-adding_two_numbers.py
122
4.03125
4
num1 = 1.5 num2 = 2.5 total = float(num1) + float(num2) print("The sum of {0} and {1} is {2}".format(num1, num2, total))
9eed800cfa8d20d3f6e040d8b4d7d6d9a51a3a20
javedbaloch4/python-programs
/01-Basics/020-sets.py
207
4.03125
4
x = set() # Create set x.add(1) # Adding Elements to set x.add(2) x.add(1) l = [1,1,1,2,2,3,3,4,4,5,5,6,6] # Creating list list_set = set(l) # Set will print only unique elements in list print(list_set)
117c7923ff3ef46cf50b065fa5cd69fa01d968f1
sr-utkarsh/python-TWoC-TwoWaits
/day_3/second.py
181
4.15625
4
from itertools import permutations str1=input("Enter the string ") permutation = [''.join(p) for p in permutations(str1)] print("list of permutations are ", str(permutation))
1c2417215f0a9a2df21be9e60e83c9e23ed1024f
sr-utkarsh/python-TWoC-TwoWaits
/day_6/3rd.py
218
3.703125
4
n=int(input("Enter the size of list: ")) lst=[] print("Enter the elements: ") for i in range (n): el=int(input()) lst.append(el) lst.sort() i=0 while(i==lst[i]): i+=1 if(i==n): break print(i)
34b03e9a81d807fee6872d12477648ef0d83f335
sr-utkarsh/python-TWoC-TwoWaits
/day_6/10th.py
495
4.09375
4
def reemovNestings(List): for i in List: if type(i) == list: reemovNestings(i) else: output.append(i) size = int(input("Enter the number of sorted lists you want to merge: ")) List= [] for i in range(size): List.append(list(map(int,input("Enter the elements seprate...
54a10d41ef8a3bc55c624d1115bff0d731dff64f
androidSec/SecurityInterviews
/docs/custom_linked_list.py
837
4.15625
4
''' Create a linked list that supported add and remove. Numbers are added in ascending order, so if the list was 1,3,5 and 4 was added it would look like 1,3,4,5. ''' class custom_linked_list: def __init__(self): self.custom_list = [] def add(self, number): if len(self.custom_list) == 0: self.custom_list.app...
1afb8d706f65e9f76609f1d4950db9a0ccd2dea0
AleLombardi/projectPy
/send-mail-py/ttk1.py
3,093
3.546875
4
#Python 3.7 from tkinter import * from tkinter.ttk import * import tkinter from tkinter import messagebox from PIL import ImageTk, Image import smtplib def new(): messagebox.showinfo("info","Il programma funziona inserendo\n" "le proprie credenziali di accesso Gmail\n" ...
565d9cb2d310947f597b73f63fa3a0f402b6cd14
LiHengofChina/_python
/002.Artificial_Intelligence/worspace/month04/day01/02_attr.py
497
3.53125
4
''' ndarray 的基本属性 查看数组维度,修改数组维度 ''' import numpy as np ary = np.arange(1, 9) print(ary) #查看数组的维度 print("==" * 20) print(ary.shape) # (8,),查看它是几维数组 # 修改数组的维度 print("==" * 20) ary.shape = (4, 2) print(ary) print("==" * 20) ary.shape = (2, 2, 2) print(ary) print("==" * 20) ary.shape = (1, 1, 1, 1, 1, 1, 1, 8)...
ec3ec5a996c1eca97555be97ff9dacea762f90ee
kirypto/Challenges
/AdventOfCode/2018/Day2/part1.py
1,545
3.625
4
import sys from itertools import groupby from typing import List, Tuple def calc_checksum(box_ids: List[str]) -> Tuple[int, int, int]: double_count = 0 triple_count = 0 for box_id in box_ids: occurrence_counts = dict((char, len(list(group))) for char, group in groupby(sorted(box_id))) if 2...
3ff474fbcb9dcb7274b09aab42e5b1483ffbd821
Melonsv/CS435Project1
/project1.py
21,151
3.921875
4
# Vladislav Saburov # Project 1 435 import random class Node: def __init__(self, value): self.value = value self.left_child = None self.right_child = None self.value = value # Added for AVL Tree self.parent = None self.height = 1 self.b...
852ce7279572d60bf327fa05d1def67aba27bc36
ReeseZavala/python_summer2020
/HW/Homework5_RZ.py
4,717
4.28125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 15 09:56:47 2020 @author: rzava """ # Create Class Node: class Node(): def __init__(self, value = None, child = None): self.value = value self.child = child def __str__(self): return str(self.value) #Create LinkedList Class class Linke...
b0450b18d60f7c0d86c719a7e4a8e2a8b8b50822
Vipul-Kumar/dialogflow2chatterbot
/testSlice.py
1,412
3.828125
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 29 11:22:51 2018 @author: vipkumar """ import itertools def find_substring(substring, string): """ Returns list of indices where substring begins in string >>> find_substring('me', "The cat says meow, meow") [13, 19] """ indices = [] index = ...
9adfd163625823046ae1f9fb96a877c8f6db50e7
ghormadesoham/AIForRobotics
/Search/Search/Search/compute_value.py
5,149
4.0625
4
# Dynamic Programming Lesson 4 # ---------- # User Instructions: # # Create a function compute_value which returns # a grid of values. The value of a cell is the minimum # number of moves required to get from the cell to the goal. # # If a cell is a wall or it is impossible to reach the goal from a cell, # assign tha...
51fce45bb405ab2fc62e3f0cdfd92759b9e4f515
vijayb5hyd/class_notes
/turtle_race.py
2,138
4.28125
4
import turtle # Import every object(*) from module 'turtle' from turtle import * speed(100) penup() # The following code is for writing 0 to 13 numbers on the sheet # By default, the turtle arrow starts at the middle of the page. goto(x,y) will take it to (x,y). goto(-120,120) for step in range...
fe307a0827ce3b30d50b83195a869cb8da10eeb8
Julien00859/mazesolver
/mazesolver/solvers.py
4,645
3.84375
4
#!/usr/bin/env python3 """ Maze solvers, multiple solutions are proposed, depth-first, breadth-first and iterative-deepening. Breadth-first finds the shortest path, depth-first and breadth-first are memory efficient but find a very long solution. """ import itertools import sys import fileinput import time WIDTH = ...
6685de3ed10300c3d27844558d305b9f0cedbbef
rpaech/udacity-aipnd-project
/train.py
10,514
3.703125
4
#!/usr/bin/env python3 """Trains a new neural network to identify different flower categories. This script accepts a set of images of different flowers, which are used to train a neural network to identify different flower categories. The script uses transfer learning to speed the training process and reduce the amo...
178020d5040cf315f7daf1f4d44d30e148c24e64
mushahid6666/Data_Science_Movie_Matching
/Rotten_Tomato_crawler/test.py
729
3.765625
4
def findslashes(str): fslash = '/' bslash = "\\" result = str.find(fslash) if (result == -1): result = str.find(bslash) if (result == -1): return str else: bslashindex = str.index(bslash) str = str[0:bsla...
c4a20ecbaf58b683098f1a7cbca21c3ebab79f59
ramchinthamsetty/learning
/Projects/Relayr/findstring/finder.py
1,579
3.8125
4
class Finder: def __init__(self, strings_in): self.string_patterns = strings_in def find_match(self, match_string): """ match_string - Input value to match strings in the list @return - List if there are match of strings irrespective of order of characters in matc...
240c3858d106e84608f7bcd6fa8190c8517adb40
ramchinthamsetty/learning
/Python3/OOPS/AbstractNode.py
785
4.09375
4
from abc import ABC, abstractmethod class AbstractNode(ABC): """ - Just declaring the Abstract methods. Pass ABC to class, so that it is not instantiated. """ @abstractmethod def get_data(self): pass @abstractmethod def get_links(self): pass class AbstractInterfac...
fdc37d4b6119ef863393cc36eec3fe8cbeafa09f
ramchinthamsetty/learning
/Python3/Advanced/decorators2.py
2,605
4.65625
5
""" 1. Demystifying Decorators for Simple Use. 2. Helps in Building Libraries and Frameworks. 3. Encapuslating details and providing simple interface. """ def simple_func1(x): ''' @return - Square of given values ''' return x*x # Passing the reference to a varibaale # dec_func is stored ...
2e942374022e730b5b2970ef3b92050ebd904c1e
tokenblakk/python
/Modules/moviepy/audio/io/AudioFileClip.py
4,808
3.71875
4
import wave import numpy as np from moviepy.Clip import Clip from moviepy.audio.AudioClip import AudioClip from moviepy.audio.io.readers import FFMPEG_AudioReader class AudioFileClip(AudioClip): """ An audio clip read from a sound file, or an array. The whole file is not loaded in memory. Instead, o...
cc9967f4aefd9a665551ef8e72dd6252ed72e51f
tokenblakk/python
/InterviewProblems/median.py
666
3.859375
4
__author__ = 'Tramel Jones' def median(a,b,c): if a>b: if c>a: return a elif b>c: #Assume that b > a return max(a,c) #Assume b > a and b > c, making b the max value. Median is second place else: return b def median2(a,b,c,min,max): return a^b^c^min^max #X-clusive Or...
9c2b49e93a466ce39efdc14f3e7e5395f2dd4fd2
AHA-HH/President-1
/Deck.py
1,025
3.796875
4
import random class Deck(object): def __init__(self): self.list_cards = self.generate_cards() def draw_card(self): return self.list_cards.pop() def size(self): return len(self.list_cards) def generate_cards(self): suits = ["Spades", "Clubs", "Diamonds", "Hearts"] names = [ ("Two", 15), ("Three", 3), (...
73bcb9343d8ed93663bfd8be05c4959b0d068720
nadeemcite/wall-e
/nearby.py
1,622
3.734375
4
import requests #now 2 tasks # 1 change the whole program to Object oriented style # e.g. a = GoogleMapPlaces("Chittorgarh", "1500", "Pizza", "") should create object # a.getNearByAddress() should give result # 2 Get your own API Key from google cloud console # open terminal arey baba yaha pr class GoogleMapPlaces:...
ba078389459af0a2eae798f82883efeea4136e07
williamsjr/Using_exceptions
/working_with_exceptions.py
293
3.796875
4
try: counter = 1 while (counter >= 1): number = 2.0 ** counter counter = counter + 0.001 except OverflowError: print(counter, "to big to be stored in memory") except KeyboardInterrupt: print("User stopped program when 'counter' was at", counter)
cbf6341ddef69ee4313605b8ab71414b48608344
justyna-eevee/python_rusz_glowa
/korzystanie_z_uporządkowanych_danych/eggs.py
409
3.578125
4
phrase = "Podaj jajko!" plist = list(phrase) print(phrase) print(plist) plist.remove("P") plist.remove("!") plist.remove("a") plist.remove("j") plist.remove("k") plist.pop(len(plist) - 1) new_phrase = ''.join(plist) print(plist) print(new_phrase) print() phrase = "Podaj jajko!" plist = list(phrase) print(phrase) prin...
0214ea5a8f5bb61651d72e88d96153a1cf098e75
Rishabh2134/Python-Basics
/Splitting.py
284
3.75
4
abc = ('My name is Rishabh') f = abc.split() print(f[0]) for w in f: print(w) a = ('I;am;an;Engineer') b = a.split() print(b) b = a.split(';') print(b) c = ('My Email id is rishabh19092001@gmail.com') d = c.split() print(c) e = d[4] print(e) f = e.split('@') print(f[1])
814e53074dd42579ba453d185386b48de33e7fcb
glqdlt/ex-python-automatic
/p_65.py
263
3.640625
4
if __name__ == '__main__': spam = 0 if spam < 5: print('value is spam < 5') while spam < 5: print('spam = ' + str(spam)) # spam = spam + 1 spam += 1 if spam == 3: print('break!') break
66511e71803dda972c9c701fe3608417aac4545c
glqdlt/ex-python-automatic
/p_74.py
328
3.875
4
if __name__ == '__main__': print('My name is') for i in range(5): print('i ==' + str(i)) # 시작값과 종료값 for i in range(12, 15): print('y ==' + str(i)) # 마지막 인자 값2는 2씩 증가하라는 매개변수다. for i in range(0, 10, 2): print('k == ' + str(i))
44fab754e8e03d765b6b21309bb4c3a4b2e6e76d
cintax/dap_2019
/sum_equation.py
303
3.71875
4
#!/usr/bin/env python3 def sum_equation(L): if len(L) == 0: return "0 = 0" add = sum(L) s = " + ".join(str(x) for x in L) s += " = " +str(add) return s def main(): print(sum_equation([1,5,7])) if __name__ == "__main__": main()
ade812c1726b72d8fa22be2aec1142e54eeea9b1
cintax/dap_2019
/matrix_power.py
515
3.578125
4
#!/usr/bin/env python3 import numpy as np from functools import reduce import math def matrix_power(a, n): if n == 0: return np.eye(a.shape[0], dtype=int) else: gen = (a for i in range(abs(n))) fun = lambda x,y : x@y mul = reduce(fun, gen) if n > 0: ...
bf5a57816608353f402c38cbb0f0294fbad96731
cintax/dap_2019
/areas_of_shapes.py
944
4.21875
4
#!/usr/bin/env python3 import math def circle(): radius = int(input("Give radius of the circle: ")) print(f"The area is {math.pi*(radius**2):6f}") def rectangle(): width = int(input("Give width of the rectangle: ")) height = int(input("Give height of the rectangle: ")) print(f"The area is {heigh...
667736735e937ad570aea1fec4d3c14a09dd238b
cintax/dap_2019
/interleave.py
293
4.0625
4
#!/usr/bin/env python3 def interleave(*lists): result = list(zip(*lists)) test = [] for i in range(len(result)): test.extend(result[i]) return test def main(): print(interleave([1, 2, 3], [20, 30, 40], ['a', 'b', 'c'])) if __name__ == "__main__": main()
217fe89c201f6eb0290f5aa8d669809490ab5f58
PredragMitic/Fractals_in_Python
/zvezda.py
761
3.859375
4
import turtle t = turtle.Turtle() t.color("white") t.pensize(2) t.shape('turtle') t.speed(0) t.goto(-300,200) def fraktalZvezda(i, k): if k == 0: t.forward(i) else: fraktalZvezda(i, k-1) t.left(60) fraktalZvezda(i, k-1) t.right(120) fraktalZvezd...
bb2c553ec8ca61dc69bde7338de7c7f2d238c05b
MrChrisFarrell/RPSLS
/spock.py
286
3.53125
4
from choice import Choice class Spock(Choice): def __init__(self): super().__init__("Spock") def compare(self, opp_choice): if opp_choice.name == "Scissors" or opp_choice.name == "Rock": self.win = True else: self.win = False
10e2ebedeb6fd073d057229267325f8d127be0d5
justworld/adbox
/design patterns/Behavioral Patterns/state.py
746
3.78125
4
""" 状态模式 """ class State(object): def show(self): print(self.name) class StateOne(State): def __init__(self, host): self.name = "One" class StateTwo(State): def __init__(self, host): self.name = "Two" class Host(object): def __init__(self): self.state_list = [Stat...
0a0afbd9fcc023ebb2d6dffd6b35a6418bc000e5
justworld/adbox
/design patterns/Creational Patterns/builder.py
776
4
4
""" 建造者模式 """ class Benz: def __init__(self): self._current = None @property def current(self): if self._current: return self._current return self._build() def _build(self): instance = Car() instance.color = 'black' instance.size = 'big' ...
16c433c861e8810bbc14075baf64d3dbf3ecac9e
justworld/adbox
/algorithms/questions/python/sselect_sort.py
689
3.765625
4
""" 直接选择排序 第一次从R[0]~R[n-1]中选取最小值,与R[0]交换, 第二次从R[1]~R[n-1]中选取最小值,与R[1]交换,...., 第i次从R[i-1]~R[n-1]中选取最小值,与R[i-1]交换,....., 第n-1次从R[n-2]~R[n-1]中选取最小值,与R[n-2]交换, 总共通过n-1次,得到一个按排序码从小到大排列的有序序列 不稳定、o(1)空间复杂度、o(n2)时间复杂度 """ def select_sort(l): if not l: return [] length = len(l) for i in range(length): ...
80904e1835eb87c13f389199c4c99862e4262bc6
MWELU-pr0g/sample
/exe15.py
228
3.671875
4
from sys import argv script,filename=argv text=open(filename) print("here's your file %r:")%(filename) print(text.read) print("the filename again:") file_again=input('>') text_again=open(file_again) print(text_again.read)
25bd19caff41286f6b423a49c0b86097b4421ffa
tmuzaffa/IBM-recommendation-engine-IBM-Watson
/Recommendations_with_IBM.py
43,427
3.546875
4
#!/usr/bin/env python # coding: utf-8 # # Recommendations with IBM # # In this notebook, you will be putting your recommendation skills to use on real data from the IBM Watson Studio platform. # # # You may either submit your notebook through the workspace here, or you may work from your local machine and submit t...
c1339fdc102fea24370fe4f96c0410989c503640
UtkarshSrivastava05/TSF_Internship_Tasks
/Task 3 - To Explore Unsupervised Machine Learning/model.py
2,127
3.75
4
# Task 3 - To Explore Unsupervised Machine Learning # Importing the libraries import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Download the iris dataset url = "https://drive.google.com/file/d/11Iq7YvbWZbt8VXjfm06brx66b10YiwK-/view?usp=sharing" path = 'https://...