blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e57b2a7e370f849ba15f0bd16c27639cdf209b04
nzsnapshot/MyTimeLine
/1-2 Months/tutorial/Files/remember_me2.py
455
4.09375
4
import json # Load username, if it has been stored previously, # Otherwise, prompt for the username and store it. filename = 'username2.txt' try: with open(filename) as f: username = json.load(f) except FileNotFoundError: username = input('What is your name? ') with open(filename,'w') as f: ...
853ae8c416ba63740724685e4af6f0c47af21ea9
nzsnapshot/MyTimeLine
/1-2 Months/tutorial/Files/Favourite_number.py
739
3.640625
4
import json def check_fornumb(): """File name""" filename = 'fav_number.json' try: with open(filename) as f: number = json.load(f) except FileNotFoundError: return None else: return number def fav_numb(): filename = 'fav_number.json' try: number =...
5ef341feb669c0cb2b2e0581de7bef9b2a6cdb7f
a44fdd/Begginer-_projects
/my_matplotlib.py
4,017
3.734375
4
import matplotlib.pyplot as plt '''Temperature graphics''' # nyc_temp_2000 = [31.3, 37.3, 47.2, 51.0, 63.5, 71.3, 72.3, 72.7, 66.0, 57.0, 45.3, 31.1] # nyc_temp_2006 = [40.9, 35.7, 43.1, 55.7, 63.1, 71.0, 77.9, 75.8, 66.6, 56.2, 51.9, 43.6] # nyc_temp_2012 = [37.3, 40.9, 50.9, 54.8, 65.1, 71.0, 78.8, 76.7, 68.8, ...
6bcde8d63e43875011070ad27b19fd3f90bbec08
anna2506/nn-limbo
/Task3/anna2506/model.py
4,262
3.640625
4
import numpy as np from layers import ( FullyConnectedLayer, ReLULayer, ConvolutionalLayer, MaxPoolingLayer, Flattener, softmax_with_cross_entropy, l2_regularization ) class ConvNet: """ Implements a very simple conv net Input -> Conv[3x3] -> Relu -> Maxpool[4x4] -> Conv[3x3] -> Relu...
20f0b3f6a835c4038b9accf1be833849ccb76019
anna2506/nn-limbo
/Task3/SkymeFactor/model.py
3,990
3.609375
4
import numpy as np from layers import ( FullyConnectedLayer, ReLULayer, ConvolutionalLayer, MaxPoolingLayer, Flattener, softmax_with_cross_entropy, l2_regularization ) class ConvNet: """ Implements a very simple conv net Input -> Conv[3x3] -> Relu -> Maxpool[4x4] -> Conv[3x3] -> Relu...
1ab6d1a35e9e898431e2a6bd1563579a4c8df14f
sundaygeek/book-python-data-minning
/code/4/4-3.py
823
3.578125
4
# -*- coding:utf-8 -*- # 自定义类2 class Charmander: def __init__(self,name,gender,level): self.type = ('fire',None) self.gender = gender self.name = name self.level = level self.status = [10+2*level,5+1*level,5+1*level,5+1*level,5+1*level,5+1*level] # 最大HP,攻击,防御,特攻,特防,速...
1c2b046b5f4cab19886ac32c85eced74b54bbdf7
sundaygeek/book-python-data-minning
/code/4/4-5.py
2,106
3.921875
4
# -*- coding:utf-8 -*- print('''自定义类5''') class pokemon: def __init__(self,name,gender,level,type,status): self.__type = type self.__gender = gender self.__name = name self.__level = level self.__status = status self.__info = [self.__name,self.__type,self.__gender,se...
7da73a6879390b306e1040bcbb5b1c2d5a8dd1ba
sundaygeek/book-python-data-minning
/code/2/2-4-5.py
180
3.671875
4
# -*- coding:utf-8 -*- print('''创建集合''') set1 = {1,2,3} # 直接创建集合 set2 = set([2,3,4]) # set()创建 print(set1,set2) # result: set([1, 2, 3]) set([2, 3, 4])
77ab370c4da7b6f592355efbd2c7f4b0f058fd40
anisssoudki/intro-to-python
/tip-calculator.py
405
4.09375
4
print('welcome to the tip calculator') totalBill = input('what was the total bill? $') numOfPeople = input('how many people to split the bill?') tipPercentage = input('what percentage tip would you like to give? 10, 12 or 15?') result = (float(totalBill) / float(numOfPeople))+ float(totalBill)/float(numOfPeople)*(f...
cd0d6e283e5344733864d6eb79113d6552e02d5f
AlpacaMoon/python_practices
/Check_if_Sudoku_is_valid_1.0.py
1,323
3.921875
4
sudoku = ['', '', '', '', '', '', '', '', ''] for i in range(len(sudoku)): sudoku[i] = input("Enter row " + str(i + 1) + ':') def validSudoku(sudoku): #Check for rows for row in sudoku: if ''.join(sorted(row)) != '123456789': print('a') return False #Check for colu...
05ff1135c9e3ce6ac64f4d8fbf1abf7dad730253
NatalijaGucevska/DataVisualization
/Project_k/server/flask/helper/timer.py
336
3.59375
4
import threading def set_interval(func, sec): """Automatic function caller. Keyword arguments: func -- the function to call repeatedly sec -- time interval to call func """ def func_wrapper(): set_interval(func, sec) func() t = threading.Timer(sec, func_wrapper) t.start...
227bfbed621544f32bbddd18299c8fd0ea29fe0a
daisy-carolin/pyquiz
/python_test.py
989
4.125
4
x = [100,110,120,130,140,150] multiplied_list=[element*5 for element in x] print(multiplied_list) def divisible_by_three(): x=range(10,100) for y in x: if y%3==0: print(y) x = [[1,2],[3,4],[5,6]], flat_list = [] for sublist in x: for num in sublist: flat_list.append(num) ...
439358dd20567d8743de84ec3935031ac4e76d3c
surya810/Numerical-method-notes
/Numerical method_practical_problems/Taylor.py
716
3.890625
4
#Taylor Series (Upto 3rd Order Derivative) #Name: Rejoy Chakraborty #Sem: V Subject: Computer Science #Subject: Numerical Methods (DSE-I) #Roll No: 717 import math as m def func_d1(x,y): return x+y+(x*y) def func_d2(x,y): return ((1+x)*func_d1(x,y)) + y + 1 def func_d3(x,y): return ((x+1)*fu...
941420c2b36b1491d5e8671ddf462160f80b6841
dbuscaglia/leetcode_practice
/reverse_integer.py
686
3.828125
4
""" 7. Reverse Integer Easy 2476 3842 Favorite Share Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 """ class Solution(object): def reverse(self, x): """ :type x: int ...
8e72d35419e25bfe11fd1d554927346ccf405a7c
tlholo34/Projects-
/task_manager.py
12,846
4.15625
4
import datetime from datetime import date #we open our users.txt file1 = open('user.txt','r') users = {} #for all the lines in users.txt for lines in file1: #we strip the new line lines = lines.strip('\n') #make a list of all the items in the file userls = lines.split(', ') #add items into the di...
996da01a75f050ffcdb755c5c5f2b16fb1ec8f1c
Shmuco/PY4E
/PY4E/ex_05_02/ex_05_02.py
839
4.15625
4
##### 5.2 Write a program that repeatedly prompts a user for integer numbers until #the user enters 'done'. Once 'done' is entered, print out the largest and #smallest of the numbers. If the user enters anything other than a valid number #catch it with a try/except and put out an appropriate message and ignore the #num...
d5e151283d98121eeeadb57157acab2355ad3afa
bmbueno/pesquisa
/tratamento dados.py
4,104
3.90625
4
import csv import sqlite3 with open('Pesquisa500.csv') as file: fileReader = csv.reader(file, delimiter=',') dbConec = sqlite3.connect("pesquisa500.db") db = dbConec.cursor() # db.execute('CREATE TABLE perfilSocioEconomico( id INTEGER PRIMARY KEY AUTOINCREMENT, resposta VARCHAR(100) NOT NULL);')...
48f85e68fcdd06ca468437c536ac7e27fd20ef77
endreujhelyi/zerda-exam-python
/first.py
431
4.28125
4
# Create a function that takes a list as a parameter, # and returns a new list with every second element from the original list. # It should raise an error if the parameter is not a list. # Example: with the input [1, 2, 3, 4, 5] it should return [2, 4]. def even_elements(input_list): if type(input_list) == list: ...
d23251d361e76538cdac028a51835bf691414163
mallegrini/katas
/tests/test_fizzbuzz.py
717
3.640625
4
import unittest from src.fizzbuzz import FizzBuzzer, Checker class FizzBuzzerTest(unittest.TestCase): def setUp(self): self.m = FizzBuzzer((Checker(3, 'Fizz'), Checker(5, 'Buzz'), Checker(7, 'Bang'))) def test_one_two(self): assert self.m.say(1) == "1" assert self.m.say(2) == "2" def test_fizz(self): ass...
fed2d8b58677306755301073a22e88088f9ce6de
Matthew-Inman/calculator-pygame
/dist/pygame_calculator.app/Contents/Resources/Screen.py
3,707
3.515625
4
import pygame import math from Calculator import Calculator from globals import * class Screen: init_text = '0' error = False def __init__(self): self.text = '0' self.x = 100 self.y = 80 self.width = 390 self.height = 80 self.calc = Calculator() def dra...
6caa36efec61cd233576a4dcb9b3e925ab259fae
briangfang/COGS-18
/functions.py
9,522
3.8125
4
"""Collection of functions used in my project""" from datetime import date import pandas as pd def create_food(food, quant, exp, categ): """Creates dictionary of preset keys paired with input parameters as corresponding values. Parameters ---------- food : string String of food name....
c6745d3dde458a86ed000e6877f1291bafe1c489
alapa/Training
/phonebook.py
3,321
3.65625
4
import pickle import sys class PhoneBookError(Exception): pass class Contact(): def __init__(self, name, number): self.name = name self.number = number def __eq__(self, other): return self.name == other.name def __hash__(self): return hash(self.name) "...
8fe7e9ee5da57e056d279168bc8c34789779109a
cainiaosun/study
/测试/UI自动化/测试工具__Selenium/selenium/Phy/class.py
1,134
4.3125
4
class Person: '''Represents a person.''' population = 0 def __init__(self,name,age): '''Initializes the person's data.''' self.name = name self.age = age print '(Initializing %s)' % self.name # When this person is created, he/she # adds to the population ...
8d5f5d635bcba612042b6e94c12292f92ecf6630
Ankita-2331/PythonTurtlePrograms
/Design2.py
241
3.71875
4
import turtle colors=['red','yellow','blue','green','orange','pink'] screen=turtle.Screen() t=turtle.Turtle() t.speed(0) screen.bgcolor('black') for x in range(300): t.pencolor(colors[x%6]) t.width(3) t.forward(x) t.left(20)
1eaa0f74dbf499832727a4ed3c642cdc20cce795
DoranLyong/CSE-python-tutorial
/Coding-Test/CodeUp/Python/055_Logical.py
304
3.8125
4
""" [ref] https://codeup.kr/problem.php?id=1055 Question: 1. take two true(1) or false(0) 2. print true when any of them is True at least """ import sys x, y = map(int, sys.stdin.readline().rstrip().split()) x, y = map(bool, [x, y]) OrGate = lambda x, y: x or y print(int(OrGate(x, y)))
3bf12dd6c33cc03a1d21b50ac6758b69a8785db2
DoranLyong/CSE-python-tutorial
/Coding-Test/CodeUp/Python/029_InputOutput.py
203
3.5
4
""" [ref] https://codeup.kr/problem.php?id=1029 Question: 1. get one real number in range 0 ~ 4,294,967,295 2. print it up to 11 decimal places """ data = float(input()) print("%.11f" %data)
40eb347ec2a99811529a9af3aa536a16618d0ad3
DoranLyong/CSE-python-tutorial
/Coding-Test/CodeUp/Python/036_number.py
345
4.375
4
""" [ref] https://codeup.kr/problem.php?id=1036 Question: 1. take one English letter 2. print it out as the decimal value of the ASCII code table. """ letter = input() print(ord(letter)) """ Program to find the ASCII value of a character: https://beginnersbook.com/2019/03/python-program-to-find-ascii-...
b1e4dbd8b361e4a4b91d4f5b1e021e225c5f4cf2
DoranLyong/CSE-python-tutorial
/Coding-Test/CodeUp/Python/069_if_statement.py
490
3.90625
4
# coding=<utf-8> """ [ref] https://codeup.kr/problem.php?id=1069 Question: 1. receive evaluation as letters (A, B, C, D ...) 2. print it as comment 평가 내용 평가 : 내용 A : best!!! B : good!! C : run! D : slowly~ others : what? """ eval = input() commen...
cfbda90651469ee446bbb28c69b0d33bedfb980b
DoranLyong/CSE-python-tutorial
/Coding-Test/CodeUp/Python/026_InputOutput.py
177
3.5625
4
""" [ref] https://codeup.kr/problem.php?id=1026 Question: 1. get hour:minute:second 2. print only 'minute' part """ h, m, s = input().split(":") print("%d" %(int(m)))
be18912e38faf01a46bc0c740a5044d71bbc615d
DoranLyong/CSE-python-tutorial
/Coding-Test/CodeUp/Python/013_InputOutput.py
179
3.65625
4
""" [ref] https://codeup.kr/problem.php?id=1013 Question: 1. get two integers 2. print them """ import sys a, b = map(int, sys.stdin.readline().split()) print(a, b)
58dce475f4c94e14c6d58a4ee3c1836e34c82f21
DoranLyong/CSE-python-tutorial
/Coding-Test/CodeUp/Python/037_number.py
319
4.125
4
""" [ref] https://codeup.kr/problem.php?id=1037 Question: 1. take one decimal ineger 2. print it out in ASCII characters """ num = int(input()) print(chr(num)) """ Program to find the ASCII value of a character: https://beginnersbook.com/2019/03/python-program-to-find-ascii-value-of-a-character/ """
173631da2b89f158a22cde74defe44465acce1b6
wuhuabushijie/sample
/chapter04/4_1.py
488
4.125
4
'''鸭子类型,多态''' class Cat: def say(self): print("I am a cat") class Dog: def say(self): print("I am a dog") def __getitem__(self): return "bob8" class Duck: def say(self): print("I am a duck") animal_list = [Cat,Dog,Duck] for animal in animal_list: animal().say() ...
fd7e0913e3563e7df5bbb860e23d2bc91046a501
wuhuabushijie/sample
/chapter08/metaclass_test.py
700
3.71875
4
from collections.abc import * from _collections_abc import __all__ class Base: def answer(self): print("This is base class") def say(self): print("hello " + self.name) class MetaClass(type): def __new__(cls, *args, **kwargs): print("This is MetaClass") return super().__new__(cls,...
3c442143a21e9a16b2d595ab0e867791effa2f13
wuhuabushijie/sample
/chapter07/ags_fault.py
762
3.984375
4
class Company: def __init__(self, name, staffs=[]): self.name=name self.staffs=staffs def add(self,staff): self.staffs.append(staff) com1 = Company("com1") com2 = Company("com2") com1.add("bob1") com2.add("bob2") print(com1.staffs) print(com2.staffs) print(com1.staffs is com2.staffs...
0c5c047faa0c42dc7471edc4e627718f0e6a444b
pri-nitta/firstProject
/CAP4/funcao.py
506
3.96875
4
def somar(): a = float(input("Digite o primeiro número: ")) b = float(input("Digite o segundo número: ")) print(a + b) somar() #Usando parâmetros def somar2(c, d): total = c + d print(total) v1 = float(input("Digite o 1º num: ")) v2 = float(input("Digite o 2º num: ")) somar2(v1, v2) #passando di...
2d77ec4e8a640d28a657fd2dd581c3fe013e7703
pri-nitta/firstProject
/CAP2/bonus.py
656
3.8125
4
var = input("Qual o tipo da sua assinatura? ") assinatura = var.upper() faturamento = float(input("Quanto foi seu faturamento anual? ")) if assinatura == "BASIC": bonus = faturamento * 0.3 print(f"O valor que deverá ser pago é de R${bonus}") elif assinatura == "SILVER": bonus = faturamento * 0.2 print...
4fcabbe7be3110a9ee278b5321eaa30319c9d7a7
pri-nitta/firstProject
/CAP3/calorias.py
1,093
4.21875
4
#1 – O projeto HealthTrack está tomando forma e podemos pensar em algoritmos que possam ser reaproveitados # quando estivermos implementando o front e o back do nosso sistema. # Uma das funções mais procuradas por usuários de aplicativos de saúde é o de controle de calorias ingeridas em um dia. # Por essa razão, você d...
c5bb97e87faa1dc65fff8faf36b50e4a66f2cc3f
luigirivera/PE4-Sentiment-Classification
/sentiment_classification.py
9,094
3.5625
4
import nltk import os import csv import pandas as pd nltk.download('punkt') dataset = pd.read_csv('dataset/Virgin America and US Airways Tweets.csv', sep='\t') import numpy as np dataset = np.array(dataset) sentiments = dataset.T[0] airline = dataset.T[1] text = dataset.T[2] print(sentiments[:5]) #Y in example p...
ae78936d1135929125080769c5fc815465e57728
ALcot/-Python_6.26
/script.py
351
4.1875
4
fruits = ['apple', 'banana', 'orange'] # リストの末尾に文字列「 grape 」を追加 fruits.append('grape') # 変数 fruits に代入したリストを出力 print(fruits) # インデックス番号が 0 の要素を文字列「 cherry 」に更新 fruits[0] = 'cherry' # インデックス番号が 0 の要素を出力 print(fruits[0])
696a3bda867bf9bec089767c961f9f41c6d463bc
stemaan/isapyweb
/Day01/source code/osoba.py
875
3.828125
4
class Osoba(object): '''Osoba''' def __init__(self, imie, nazwisko, pesel): '''Tworzy instancję klasy Osoba''' self.imie = imie self.nazwisko = nazwisko self.pesel = pesel self.wiek = None def __str__(self): '''Wlasna reprezentacja obiektu przy print() ''' ...
62fd79a0a86093b3014dec48a61b9ebb7b405b11
dalanmendonca/Coding-Practice
/happy_numbers.py
417
3.5625
4
SQUARE = dict([(c, int(c)**2) for c in "0123456789"]) def is_happy(n): s = set() while (n > 1) and (n not in s): s.add(n) n = sum(SQUARE[d] for d in str(n)) return n == 1 print "1", is_happy(1) print "7", is_happy(7) print "9", is_happy(9) print "32", is_happy(32) print "56", is_happy(56) print "921", is_happy(...
916ff25f6d15f94f3ed4d81d31250c14c1f9d220
bitforbyte/Scripts
/sleepTime.py
1,497
3.9375
4
#!/usr/bin/python3 import argparse import sys import re def calcSleepTime(argc, argv): match = re.match(r'(\d+):(\d\d)', argv) if match is None: match = re.match(r'(\d*)', argv) hour = int(match.group(1)) # Make sure input is greater than 12 if (hour > 12): print("Must be between...
75dcd1daebf33f1d58bc9a1b313223288bddecc5
Pallavidighe2/python_201901
/class_02.py
1,686
3.96875
4
"""" this is class 02 file 1 Varibale 2 Data type: integer, string,boolean,none 3 Data structure : We can store multiple data type and their relationship in string """ integer_variable =3 print(integer_variable,id(integer_variable),) # string string_variable ="This is my sinle line string" string_variable_2= "This...
03bd4e50ba2c18977599d5b012c04547ef2d2eb1
Pallavidighe2/python_201901
/Income_Tax_Calculator.py
4,055
4.0625
4
def income_tax_calculaor(): global Total_Income Total_Income = input("Enter your Total Annual income : ") Total_Income = int(Total_Income) investment() def investment(): investment = input("user have investment then 'S' or 'N': ") if investment == "N": tax_calculate_without_deductio...
0c90ee44f054f4c81f0d4afb9773c387328dafe6
FIH-Engineering/FLIR-Lepton
/button/button.py
621
3.6875
4
import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP) # ISR: if our button is pressed, we will have a falling edge on pin 31 # this will trigger this interrupt: def Int_shutdown(channel): # shutdown...
a416493250bfa568f349a4e4278d8cc293fcc7de
xaadu/uri-solves
/Python/1002.py
55
3.578125
4
a = float(input()) print("A=%.4f" % ((a**2)*3.14159))
8464f1fa7547f86074e796a694ed4d87822e2983
itothep/Project_Euler
/Q2.py
230
3.75
4
def Fibonacci(n): if(n==2): return 2; elif(n==1): return 1; return Fibonacci(n-1)+Fibonacci(n-2) def Find(): i=1; sum=0; while(Fibonacci(i)<=4000000): if(Fibonacci(i)%2==0): sum+=Fibonacci(i) i+=1 print(sum)
b5d7ea09ea024245a2a2221a5c1b314fb47f19a1
dukexl/code
/python/day210901/python3_3.py
1,562
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sun Aug 25 19:51:00 2019 @author: Administrator """ from pandas import Series; #定义,可以混合定义 x = Series(['a', True, 1], index=['first', 'second', 'third']) x = Series(['a', True, 1]); #访问 print(x[1]); #根据index访问 #x['first'] ???? #不能越界访问 x[2] """ #不能追加单个元素 x.append('2') #追加一个序列...
0653a961dfdf6df6d69b35ae469934e0f274cfd0
ters81/Texas-Hold-em-Poker
/tests/validators/test_flush_validator.py
1,522
3.65625
4
import unittest from poker.card import Card from poker.validators import FlushValidator class FlushValidatorTest(unittest.TestCase): def setUp(self): self.two_of_diamonds = Card(rank='2', suit='Diamonds') self.three_of_diamonds = Card(rank='3', suit='Diamonds') self.five_of_diam...
0c2e3e32a1f985c543ec4330f5e2a06eb7e1bdb7
johnsonge/eulerSolutions
/sol06.py
494
3.65625
4
#Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. tempSquares = [] tempSum = [] n = 100 for i in range(1,n+1): tempSum.append(i) i = i ** 2 tempSquares.append(i) squareOfSums = sum(tempSum) ** 2 sumOfSquares = sum(tempSquares) print ("Sum of sq...
73f9180b49009c4a52be068f633f177124ec4c97
parthu12/DataScience
/daily practise/try.py
206
3.890625
4
a=int(input('enter a num')) try: if a>4: print('>4') else: print('<4') except valueerror: print('value in digit') finally: print('success')
69a6dafd185ec6aa955a7bc1e99fada17c9f1341
parthu12/DataScience
/daily practise/simple intrest.py
367
3.578125
4
p=float(input("input princple")) t=float(input("time")) r=float(input("rate of intresst")) def simpleIntrest(p,t,r): si=0 si=p*t*r/100 print("simple intrest is"+str(si)) simpleIntrest(p,t,r) def compoundIntrest(p,t,r): amount=0 amount=p*((1+(r/100))**t) ci=amount-p print("compo...
6ab7d0c612cb6e62aae83d747b9b1c450185f28b
doshik101/Laby
/Laba2/10.6.py
236
3.890625
4
sum=0 while a!='стоп' or a!='Стоп': a=input('Введите число; Чтобы остановить работу программы введите слово Стоп ') if a.isdigit(): sum=sum+int(a) print(c)
40a44fdb0b2e70f0c8e182a5f8611daf261e1861
doshik101/Laby
/clc/calc.py
2,520
3.890625
4
import tkinter from tkinter import * window=tkinter.Tk() window.title('Calculator') window.geometry('200x190+300+200') ch=StringVar() pole = Entry(window, width = 35, font = 'Arial 8', textvariable=ch) pole.grid(column = 0) pole.place(x=0, y=1) pole.pack() def enter(c): return ch.set(ch.get() + c) def result(c):...
3f3e22f6e0c3211ba64c0b0fe58c37f22ec556c1
doshik101/Laby
/Laba2/7.py
1,280
3.625
4
import math import random n=int(input('Введите номер задачи: ')) if n == 7.1: a,b,c=map(int,input('Введите a,b,c').split()) p=(a+b+c)/2 s=math.sqrt(p*(p-a)*(p-b)*(p-c)) print(s) elif n == 7.2: print(round (math.pi,2)) elif n == 7.3: x=int(input('Введите x')) print(math.sqrt(1-(pow(math.sin(...
0c2e80554a16683a033dcfbfb4744840bbb81066
prasankarthik/Numpy_package
/Main.py
1,938
4.09375
4
# coding: utf-8 # In[1]: #Advantages of usning numpy's universal function import numpy as np # In[26]: #Without using numpy the speed of the loop is 90microsec list1 = list(range(1000)) get_ipython().magic('timeit newlist = [i + 2 for i in list1]') # In[27]: #Now converting the list into numpy #The same loo...
cf34d21380953104cca0b9aa4444dded3c763e63
MohdTabish008/PYTHON
/Guess_the_Code.py
1,061
4.0625
4
#!/usr/bin/env python import random def get_guess(): return list(input('Enter 3 Digit Code')) #Generate Random Code def code_generator(): digits = [str(num) for num in range(10)] #shuffling the digits random.shuffle(digits) #grab first three digits return digits[:3] #Generate The Cl...
a6a8f31e4b96a57b49e7123769768049717fc115
evbeda/games3
/uno/const.py
756
3.84375
4
from .card import NumberCard RED = 'red' GREEN = 'green' BLUE = 'blue' YELLOW = 'yellow' DRAW_CARD_INPUT = '' EXIT = 'exit' ASK_FOR_INPUT = \ "Please select index of card to play! \n" + \ "Or just press enter to draw a card \n" + \ "(Type exit to quit) \n" UNO_FINAL_LAST_PLAYED_CARD = NumberCard('red', 7) U...
3442780fcf656417aa119190f13137e61db8d005
jamessandy/Pycon-Ng-Refactoring-
/refcator.py
527
4.21875
4
#Example 1 num1 = 4 num2 = 4 result = num1 + num2 print(result) #Example 2 num1 = int(input('enter the firExamst number:')) num2 = int(input('enter the second number:')) result = num1 + num2 print('your answer is:', result) #Example 3 num1 = int(input('Enter number 1:')) num2 = int(input('Enter number 2:')) result =...
b9859dfaf7618cd28253a941374f1cbfcaa560c4
nicolas43000/MHWorldData
/mhdata/util/orderedset.py
631
3.828125
4
import collections.abc class OrderedSet(collections.abc.MutableSet): "A set that maintains insertion order" def __init__(self): # use a dict to hold data. # In python 2.6 and up, dicts maintain insertion order self._data = {} def add(self, item): if item not in self: ...
4d9729e57e5e19855bd13b71df3b21ed4d00d98b
Tuhgtuhgtuhg/PythonLabs
/lab01/Task_1.py
651
4.21875
4
from math import sqrt while True: m = input("Введіть число \"m\" для обчислення формули z=sqrt((m+3)/(m-3)): ") if ( m.isdigit()): m = float(m) if (m<=-3 or m > 3): break else: print("""Нажаль число "m" повинно лежати у такому проміжку: m ∈ (-∞;-3]U(3;∞) !!! Сп...
ab57db61ddf1747446f7a8d568222ab23f7584ac
Tuhgtuhgtuhg/PythonLabs
/lab05/lab5_6.py
2,614
3.84375
4
class Transport: def __init__(self): self.value = 0 self.speed = 0 self.year = 0 self.coord = "" def setVal(self, input): self.value = input def setSpeed(self, input): self.speed = input def setYear(self, input): self.year = input ...
e130159211e4dc6092a9943fa6a1c9422d058f68
mclark116/techdegree-project
/guessing_game2.py
2,321
4.125
4
import random history = [] def welcome(): print( """ ____________________________________ Welcome to the Number Guessing Game! ____________________________________ """) def start_game(): another = "y" solution = random.randint(1,10) value = "Oh no! That's not a valid value. Pl...
ff6b31dbab81384f18190e0129bcf48ef88b7eda
kuarchi-programming-2018/181025assignment-a0176177
/recursion-practice/rose.py
946
3.609375
4
# -*- coding: utf-8 -*- from turtle import * def rectangle(points): [[x0,y0],[x1,y1],[x2,y2],[x3,y3]] = points up() setpos(x0,y0) down() setpos(x1,y1) setpos(x2,y2) setpos(x3,y3) setpos(x0,y0) def deviding_point(p0,p1,ratio): [x0,y0] = p0 [x1,y1] = p1 xr = devidi...
31af3d59a193c172200018bff9f02fdd888e98ba
GaryDoooo/Khan_A_JS
/Libby workspace root/Libby1.py
326
4.03125
4
print ("Libby's Calculator!") a=input("Please input A:") b=input("Please input B:") a=int(a) b=int(b) print("A+B=",a+b) print("A*B=",a*b) print("A/B=",a/b) print("A-B=",a-b) print("A**B=",a**b) if a>b: print("A is larger than B.") if a<b: print("A is smaller t```han B.") if a==b: print("A is equal to B.")...
b2cf77213839d3fc4ddc8ece7d5c44636e5d201b
PhillyVanilly9119/LearnPythonFromScratch
/Python_Practice_Code_1_random.py
4,748
4.125
4
# The following functions were coded from the "practice!"- exercise on Codeacademy(c) # Note that some (the majority) are the solutions from Codeacademy(c) def is_even(x): # This function return whether or not a number a even if x % 2 == 0: return True else: return False # print ...
0457106e33cc1878c120bf7712cac80bb8aff331
mhaco/tkinter
/tkinter_01.py
456
3.5625
4
from tkinter import * root = Tk() topFrame = Frame(root) topFrame.pack() bottomFrame = Frame(root) bottomFrame.pack(side=BOTTOM) button1 = Button(topFrame, text="Button 1", fg="red", command="hello") button2 = Button(topFrame, text="Button 2", fg="blue") button3 = Button(topFrame, text="Button 3", fg="green") but...
1271c6b2b6d3c37badf55124c38c37b331415365
ayushmittal02/Python-Basics
/Intro_to_Matplotlib.ipynb
2,029
3.796875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: import matplotlib.pyplot as plt import numpy as np get_ipython().run_line_magic('matplotlib', 'inline') # # Basic function plot # In[ ]: x=np.linspace(0,2*np.pi,360) #Creating functions to be plotted y1=np.sin(x) y2=np.sin(x**2) # In[ ]: plt.plot(x,y1,label='si...
ff21a6db36168a88f168290b880917c9633f8c65
rohinro/Basic_Shopping
/Appending_Values.py
1,001
3.9375
4
class Compute: def __init__(self): self.l = [] def add(self,a=0): if a == 0: a = self.get_val() self.l.append(a) print('List : ',self.l) def remove(self,a=0): print('List : ',self.l) if a == 0: a = self.get_val() sel...
d4a5c92bad4b857244fe1ed1e9fdbabc44ccacdf
bibhore/CodingProblems
/Code/Problem7.py
407
3.5
4
import random import time class Problem7: def printrandom(self): for i in range(10): print(random.randint(1,100)) time.sleep(random.randint(0,1)) def problem7(self): starttime = time.time() self.printrandom() endtime = time.time() print('Total elaps...
b9f4cc226b76a68867de37727920a989c2b35280
kars96/code
/py/pconcat.py
1,412
4.09375
4
from math import sqrt,floor def SieveOfEratosthenes(prime,n): # Create a boolean array "prime[0..n]" and initialize # all entries it as true. A value in prime[i] will # finally be false if i is Not a prime, else true. p=2 x=[] while(p * p <= n): # If prime[p] is not chan...
53d8311ea0ed3e07ae18a4ed192a473f0ff24dbb
kars96/code
/py/nlp/stop_words.py
273
3.5
4
from nltk import word_tokenize from nltk.corpus import stopwords import string s = [] while True: sent = input() if sent is None: break stop = stopwords.words('english') + list(string.punctuation) s+=[i for i in word_tokenize(sent.lower()) if i not in stop] print(s)
cf7554340e039e9c317243a1aae5e5f9e52810f9
IraPara08/raspberrypi
/meghapalindrom.py
412
4.3125
4
#Ask user for word wordinput = input("Please Type In A Word: ") #Define reverse palindrome reverseword = '' #For loop for x in range(len(wordinput)-1, -1, -1): reverseword = reverseword + wordinput[x] #Print reverse word print(reverseword) #Compare if wordinput == reverseword: print("This is a palindrome!")...
c2b1be4c40a53648e5c2fe1f79b614b63b2287d0
IraPara08/raspberrypi
/printfunction.py
165
3.578125
4
if __name__ == '__main__': n = int(input()) outputstring = '' for x in range(1, n + 1): outputstring = outputstring + str(x) print(outputstring)
951ce38c0f118938df7368aa1332a21bafc719f7
pinkyba/NLP_Lab
/eng-upper-fsm/word.py
120
3.53125
4
string = "abcdefghijklmnopqrstuvwxyz" print("-"+"\t"+"0") for i in range(len(string)): print(string[i]+"\t"+str(i+1))
c38bd5408534cfc084fbb40f956fca146f6834b5
pinkyba/NLP_Lab
/word-segment-checker/word-seg-check1.py
2,253
3.921875
4
# How to run: python word-seg-check1.py ./test-data-for-word-segment-checker.txt > out import sys fileName = sys.argv[1] f = open(fileName, "r") fline = f.readlines() for i in range(len(fline)): # split words with space for first line line1 = fline[i].split(" ") # go to next line loop that is checked with line b...
4d78460a2561b60c3dd5261b52a30876fd0bac6e
ruchibaheti86/NumPy
/Filter NumPy.py
500
3.796875
4
import numpy as np #Filter the array arr = np.array([2,4,2,9,2]) print("Array: ",arr) x = [False, False, True, False, True] newarr = arr[x] print("Filtered new array : ",newarr) #Filteration of array in for and if command as well. arr = np.array([100, 110, 120, 150, 180]) filterarr = [] for e in arr: i...
aa588a7dc6e82568306a9bb683ed685458c3c445
stephengushue/Resplendent_Tiger
/guessanumber.py
235
4.09375
4
x = int(input('Pick a number between 2 and 10')) if x == 1 or x > 10: print('That is not what I asked.') else: print('Please hold while I calculate...') while x < 10: x += 1 print (str(x) + ' ...')
0db9f3ca1c2093216f167bb5aad6c57f57f09ae2
PhysCdr/MobileRobotics2019
/Solutions/HW1/solution/p1d.py
347
3.5625
4
import numpy as np def ortho(m): identity_m = np.identity(m.shape[0]) return np.allclose(np.matmul(m, m.T).flatten(), identity_m.flatten()) def main(): d = np.array([[2, 2, -1], [2, -1, 2], [-1, 2, 2]])/3 if ortho(d): print('matrix', d, 'is orthogonal') else: print('matrix', d, 'is not orthogonal') if __na...
fa3fe1fcf7983483d2d0258097c0c8ef5716c0ef
domlockett/pythoncourse2018
/homeworks/hw3/HW3_DL.py
2,787
3.625
4
## pick a search criteria for groups, such as a zip code or a search term, like in class. Then answer the following with the returned results: ## 1. Which group is the most popular (i.e., has the most members)? ## 2. For this group, which member is the most active (i.e., belongs to the most groups)? ## ...
fed78ccbb8a565e936cacbac817485c26ab84383
domlockett/pythoncourse2018
/day03/exercise03_dl.py
458
4.28125
4
## Write a function that counts how many vowels are in a word ## Raise a TypeError with an informative message if 'word' is passed as an integer ## When done, run the test file in the terminal and see your results. def count_vowels(word): vowels=('a','e','i','o','u') count= 0 for i in word: if type(...
ec8a300f12f6fa3d081ec9b3831dcee4e23cf426
rwbogl/n-queens
/queens.py
5,184
4.09375
4
import itertools def n_queens(n): """Return a solution to the n-queens problem for an nxn board. This uses E. Pauls' explicit solution, which solves n > 3. A solution is possible for all n > 3 and n = 1. Pauls' solution gives back 1-based indices, and we want 0-based, so all points have an extra -...
b885e635046f49474bedc697135121f2e315e65c
cbppg/ML-NeuralNetwork
/main.py
2,406
3.921875
4
# -*- coding: utf-8 -*- """ Qiu Zihao's homework of ML Student ID: 141130077 Neural Network """ import numpy as np # input layer -- 400 (d in book) input_num = 400 # hidden layer -- 100 (q in book) hidden_num = 100 # output layer -- 10 (l in book) output_num = 10 # connection weights from input layer to hidden lay...
9d49f2cc8e67a064ee7bc802a619794a7164a922
hsj00/Python
/python 200/075.py
1,662
3.609375
4
# 075 char extract from specific position in string # 076 string extract from specific range in string # 077 oddth char extract from string # 078 string reversing # 079 string sum # 080 string repeating txt1 = 'A tale that was not right' txt2 = '이것 또한 지나가리라' # 075 print(txt1[5]) # 4번째 문자, 5 미만에서의 위치 prin...
5d1269355b68717992f38971bedb74877ab668ee
scientific-coder/josephus
/element-recursion/josephus.py
728
3.578125
4
from collections import deque def find(chainlength = 40, kill = 3): return findlast(deque(range(1,chainlength+1)),3,1) def findlast(chain,nth,counter) : if len(chain) == 1 : return chain[0] elif counter == 1 : #print chain.popleft(), " dies" chain.popleft() return findlast...
ddbffa79e219713e4054839a07392898edf94e7a
Emiya2098212383/csy_try
/main.py
938
3.53125
4
# -*- coding: UTF-8 -*- # Filename : 01-string.py # author by : Emiya import csv import os # Global: Define file name & path filename = 'test_write.csv' csv_path = os.getcwd() + '\\csv_files\\' + filename # Practice 1 - write # write a row once header_data = ["1行号", "2列名1", "3列名2"] row_data = [1, '第1列数据', '第2列数据...
85196830fe29ba9aabcfcd1712bbde6d3dd822e4
ChingLingYeung/honoursProject
/test2.py
1,912
3.796875
4
# taken from https://codereview.stackexchange.com/questions/203319/greedy-graph-coloring-in-python def color_nodes(graph): # Order nodes in descending degree nodes = sorted(list(graph.keys()), key=lambda x: len(graph[x]), reverse=True) color_map = {} for node in nodes: available_colors = [True] * len(node...
a295f7530513cc1fe389cb0026afac25c30e38c0
ruvvet/texas-hold-em-python
/src/utils.py
714
3.875
4
INPUT_ERROR_INT = 'Must be an integer. Try again.' INPUT_ERROR_STR = 'Must be either K, C, R, F. Try again.' # Input validation def input_num(message): while True: try: user_input = int(input(message)) except ValueError: print(INPUT_ERROR_INT) continue e...
2074006981e41d2e7f0db760986ea31f6173d181
ladas74/pyneng-ver2
/exercises/06_control_structures/task_6_2a.py
1,282
4.40625
4
# -*- coding: utf-8 -*- """ Task 6.2a Make a copy of the code from the task 6.2. Add verification of the entered IP address. An IP address is considered correct if it: - consists of 4 numbers (not letters or other symbols) - numbers are separated by a dot - every number in the range from 0 to 255 If the ...
27cc3bbaffff82dfb22f83be1bcbd163ff4c77f1
ladas74/pyneng-ver2
/exercises/05_basic_scripts/task_5_1.py
1,340
4.3125
4
# -*- coding: utf-8 -*- """ Task 5.1 The task contains a dictionary with information about different devices. In the task you need: ask the user to enter the device name (r1, r2 or sw1). Print information about the corresponding device to standard output (information will be in the form of a dictionary). An example ...
b25fd7a616e2d5e6aa54f228f327f6f885af7b17
dkushche/Crypto
/crypto_tools/math_tools.py
1,292
3.671875
4
""" Math Tools Some general math tools that can help with numbers) """ import math import random def EGCD(a, b): """ Extended Euclidean algorithm computes common divisor of integers a and b. a * x + b * y = gcd(a, b) returns gcd, x, y or gcd, y, x. Sorry, I can't remembe...
9fdb382bce23404a286b430d5c77edf4453af378
Andreasdahlberg/advent-of-code-2018
/day 9/marble.py
1,290
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -* import re from blist import blist def get_answer(number_of_players, number_of_marbles): scores = [0 for i in range(number_of_players)] circle = blist([0]) current_marble_index = 0 marble_value = 1 while marble_value < number_of_marbles + 1: i...
53975d40690fcd19925011d4b527465a55d37806
mendelson/neoway-challenge
/customLib/DataImputer.py
6,961
3.578125
4
import pandas as pd import math import numpy as np from tqdm import tqdm from sklearn.impute import KNNImputer # DataImputer: performs Nearest Neighbor Imputation on # the input_df variable. class DataImputer(): def __init__(self, input_df): """ This constructor initializes the internal ...
82c2f3952589113e474b80916a2d5e1175da0403
Bunnycakes62/Machine-Learning
/PopArt/PopArt.py
2,321
3.734375
4
# Task 1 (Creating a popart and compressible version of a colour image): # Using either imageio or pillow to upload an image. read a colour image of your choosing or this default image (Links to an external site.). # Please submit the image that you chose if not the default. Code could be: # from imageio import imre...
ba34b9016a7fd98af0ac47527e73fd4d3671ae0f
eileen-b/example-code-2e
/10-dp-1class-func/strategy.py
2,825
3.5625
4
# strategy.py # Strategy pattern -- function-based implementation """ # tag::STRATEGY_TESTS[] >>> joe = Customer('John Doe', 0) # <1> >>> ann = Customer('Ann Smith', 1100) >>> cart = [LineItem('banana', 4, .5), ... LineItem('apple', 10, 1.5), ... LineItem('watermelon', 5, 5.0)] ...
d899082e889a05cfc8d4ed698086eb857e949162
supriyaprasanth/test
/strings and lists/word_sorting.py
122
3.890625
4
str = raw_input("Enter some words seperated using , : ") words = str.split(",") words.sort() for i in words: print(i)
518b6613fdaf2b43de899242f803a3340d86afd5
supriyaprasanth/test
/Exam/binary_search.py
788
4.0625
4
# to do binary search n=input("enter the number of elements : ") # to get the number of elements item = [] for i in range(0,n): #to accept the elements of the list a = input("enter the items : ") item.append(a) print item ele = input("Enter the element to be searched :") # to accept the element to be sea...
44f9711729238bc3fc3e59cd7b85f09705ab3b18
supriyaprasanth/test
/9_july/test1.py
1,142
4.0625
4
from Exam import random words = ['kerala','karnataka','pune','delhi','punjab',] word = random.choice(words) leng = len(word) count =0 chances = 9 l_guessed = [] x = "" y= True def word_update(x,word, l_guessed): for letter in word: if letter in l_guessed: x += letter else: x += " _ " ...
09db1390181a162563845f139d31f47127355021
wuhuliang/leecode
/car.py
213
3.546875
4
class User(object): def __init__(self,first_name,last_name): self.FN = first_name self.LN= last_name def describe(self): print ('The username is: ' + str(self.FN) + str(self.LN))
d17eb4bc9a1bb627e47b6025378ec33869652d55
dorismoisuc/Programming-Fundamentals
/Assignment3-4/ui.py
7,884
3.734375
4
from model import * from copy import * from undo import * #reads the real part and the imaginary part of the complex number def readComplex(): realPart = int(input(" ⁂ real part:")) complexPart = int(input(" ⁂ complex part:")) return createComplex(realPart,complexPart) #creates the list of ...