blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2b857718b9d29849604b97b6dbaaff6854dbf3c2
lucascalebe/cs50-psets
/PSET 6/dna.py/dna.py
2,044
4.0625
4
from sys import argv from csv import reader, DictReader #checking if the inputs are right,if the input is different of 3, something is wrong! if len(argv) < 3: print("Usage: python dna.py data.csv sequence.txt") exit() #read the dna sequence (txt) with open(argv[2]) as dnafile: dnareader = reader(dnafile)...
5593314d53f49c9ca0c0d11a7fbe57b88206f9a7
whosedaddy/Learn_python_the_hard_way
/learn_python/ex21.py
708
4.09375
4
def add(a,b): print "ADDING %d+%d"%(a,b) return a+b def subtract(a,b): print "SUBTREACTING %d-%d"%(a,b) return a-b def multiply(a,b): print "MULTIPLYING %d*%d"%(a,b) return a*b def divide(a,b): print "DIVIDING %d/%d"%(a,b) return a/b print "Let's do some math with just functions!" age=add(30,5) heigh...
67cf5239a0f9ec1aace460980ca29b529ff7654c
viralbaitule/DSA-Python
/Sorting/selection_sort.py
273
4.0625
4
def selection_sort(list1): for i in range(0,len(list1)): min_var=i for j in range(i+1,len(list1)): if (list1[j]<list1[min_var]): min_var=j list1[i],list1[min_var]=list1[min_var],list1[i] list1=[6,3,8,1,2,4] selection_sort(list1) for i in list1: print (i)
d832765e047cd58013f66f236f34187075265dff
Jethrodeen/SimpleCNN
/EAllibhai.py
1,367
3.640625
4
""" https://towardsdatascience.com/building-a-convolutional-neural-network-cnn-in-keras-329fbbadc5f5 """ import matplotlib.pyplot as plt # load the MNIST data set. Consists of 70k images for digits. from keras.datasets import mnist #split into training and testing (x_train, y_train), (x_test, y_test) = mnist.load...
12367810e21dad7768410752a82d7de84c65d178
jamiezeminzhang/Leetcode_Python
/ALL_SOLUTIONS/061_OO_Rotate_List.py
1,062
4.21875
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 26 03:21:23 2016 61. Rotate List Total Accepted: 71094 Total Submissions: 308478 Difficulty: Medium Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. @author: ...
edbcb2526bb246707fbed29fb0836cf774700d4c
PoonamPrusty/Python_tasks
/tuplesprogram.py
791
4.1875
4
import random Words = ("sword", "armor", "python", "cruel") word = random.choice(Words) # chooses one element from the tuple randomly correct = word jumble = "" while word: position = random.randrange(len(word)) #picks a random letter from the word jumble += word[position] #adds the letter in word[positi...
9bec2dda4fd405267bffbb854ae7ac98437a727d
Aasthaengg/IBMdataset
/Python_codes/p03037/s450644897.py
429
3.546875
4
# 先頭の最大と最後尾の最小を求める card_num, gate_num = map(int, input().split()) lmax, rmin = map(int, input().split()) # 最初の入力がlの最大とrの最小 for i in range(1, gate_num): l, r = map(int, input().split()) lmax = max(lmax, l) # lmaxにlmaxとlの大きい方 rmin = min(rmin, r) # rminにrminとrの小さい方 print(max(0, rmin-lmax+1)) # 0かrmin-lmax+1の大き...
2bb51137d21a74fe6cce177215bfde864d917636
lcantillo00/python-exercises
/6-Selection/ex5.py
179
3.90625
4
def is_even(n): # your code here if n%2==0: print(True) else: print(False) print(is_even(10)) print(is_even(5)) print(is_even(1)) print(is_even(2))
235f4d79ca1455ee16b9fefde94d52b15434cdd3
NovackM/pythonHelloWorld
/testing/external_depen_test.py
1,488
3.5
4
import unittest from unittest import mock # explained mocking well # https://medium.com/python-pandemonium/python-mocking-you-are-a-tricksy-beast-6c4a1f8d19b2 class ExternalServices(): def call_service(self, request_params): return "Called Service" class AppLogic(): ext_services = ExternalService...
7c36a11e306e54eaa4b92ef78ae2e9accbbbc345
Pavithralakshmi/corekata
/stringstrip.py
98
3.75
4
s=str(input("enter something")) r=str(input("enter remove string")) print(s) print((s.strip(r)))
04670845fd4b995401caf986e625cbb3fba889be
rishavh/UW_python_class_demo.code
/nested.py
761
4.25
4
""" print nested data structure with increasing indentation at each level [ 'I....', 'II...', [ 'A...', 'B...' ], 'III....' ] is printed I... II... A... B... III... """ outline = [ 'I....', 'II...', [ 'A...', [ 1, 2 ], 'B...' ], 'III....' ] def print_nested(spaces, data): """ print nested d...
520dc52e52ec0492f71891b9ef58ca488b775568
jhonatanx123/Python
/Python/Python Program 4-2.py
1,548
3.609375
4
Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> Jhonatan Roopnarine Enter a number:5 Given number: 5 Result: 5 >>> =============...
993c1e646163b4c8f366ba995b41f584519e44df
Joevaen/Scikit-image_On_CT
/Feature/match_template.py
721
3.5625
4
# 适用于2d和3d的模板匹配方法 # 输出是一个值在-1.0到1.0之间的数组。 给定位置的值对应于图像和模板之间的相关系数。 # 对于pad_input = True,匹配项对应于模板的中心,否则对应于模板的左上角。 为了找到最佳匹配,您必须在响应(输出)图像中搜索峰值。 import numpy as np from skimage.feature import match_template template = np.zeros((3, 3)) template[1, 1] = 1 print(template) image = np.zeros((6, 6)) image[1, 1] = 1 image[4, 4]...
ba8818c1889056004763b8f1cead83dca7fd5f82
Mguysin/PythonProjects
/Week 2/For loops and dictionaries/dictionaries.py
1,731
3.984375
4
crazy=['Snow', 'The north', 'Cerci', 'Kings Landig'] # Lists not efficient as data not connected #Would be useful tp provide aadditional information e.g. where lives/previous work experiece/previous education/previous test results #Saves time as don't have to spend time looping through information #Dictionaries # Dic...
6591606c4794fba0f9ca94dec3ac001178090a2f
Richie010/uplift-python-resources
/Student's-Program/Meenu_Calculator.py
1,072
4
4
# The definition of the Addtion function def add(num1, num2): return num1 + num2 # The definition of the Substraction function def substract(num1, num2): return num1 - num2 # The definition of the multiply function def multiply(num1, num2): return num1 * num2 # the definition of the...
8ac1c3d7e194fa544db85302b9c3056de51f4075
SKapal/codewars
/Python/SquareEveryDigit.py
348
3.765625
4
def square_digits(num): if num == 0: return 0 else: arr = list(str(num)) square = "" for i in arr: square += str(int(i)**2) return int(square) print(square_digits(9119)) # Shortened: def square_digits2(num): ret = "" for x in str(num): ret += str(in...
7d818935cdda82741987c826ae20183307a53bb9
BorthakurAyon/snnpytorch
/snnpytorch/neuron/spiking_neuron.py
4,729
3.703125
4
""" Spiking Neuron Model ================================================ """ import torch.nn as nn import torch class SpikingNeuronLayer(nn.Module): """ Class of a spiking neuron layer. The iterative model for a neuron is inspired from the following papers:\n 'Enabling Deep Spiking Neural Networks ...
047297e3db57a5c3840173f3675aac4d304e1330
databill86/scout_apm_python
/src/scout_apm/core/util.py
305
3.609375
4
# coding=utf-8 from __future__ import absolute_import, division, print_function, unicode_literals # Takes an integer or a string containing an integer and returns # the octal value. # Raises a ValueError if the value cannot be converted to octal. def octal(value): return int("{}".format(value), 8)
8a6270aace60c6e239dc342e8af8b81fc9d5fd22
GerardoSGG/Portfolio
/Practices/Python/Programa_9.py
3,731
3.671875
4
import os import re op = 0 datos = [] while(op!=5): op = int(input("""Menu de opciones 1- Insertar datos 2- Buscar dato 3- Modificar dato 4- Borrar dato 5- Salir Opcion a seleccionar : """)) if op == 1: agrega = [] agrega.append(input("Introduce tu nombre : ")) agrega.append(input("Introduce tu dom...
377e7dc1a1821e154b7f5eba494c8e81001d41ed
jensecj/code-challenges
/advent-of-code-2022/01/main.py
993
3.578125
4
# tags: adding numbers from compytetive.util import benchmark def read_input(filename): with open(filename, "r", encoding="utf-8") as f: data = f.read().strip() data = data.split("\n\n") data = [d.split("\n") for d in data] groups = [] for d in data: groups.app...
78665a94e9e8d6a935f47e8893f55c6d39e17194
chongkim/magic_methods
/problem.py
1,219
3.5625
4
#!/usr/bin/env python # encoding: utf-8 class Address(object): def __init__(self, city, state): self.city = city self.state = state def __repr__(self): return '(%s, %s)' % (self.city, self.state) class User(object): def __init__(self, name, *addresses): self.name = name ...
84900bf71063352183ef7b5012caf40bf949a518
Santiagonk/Aprende_con_alf
/Programacion_funcional/Ejercicio_9.py
219
3.59375
4
def norma(lista): suma = 0 for i in lista: suma += i**2 return suma**0.5 def main(): a = [3, 4] print(norma(a)) b = [1, 2, 3] print(norma(b)) if __name__ == "__main__": main()
11c38f4da429c424cacac0da5b836a4e520c14a9
GauthamAjayKannan/GUVI-1
/evenNoRange.py
134
3.671875
4
starts, ends = map(int, input().split(" ")) list1 = [] for i in range(starts+1 , ends): if i%2 == 0: list1.append(i) print(*list1)
8bc2a2680dd7ddc8120bcafe406a2bcb43602d12
N-A-D/PE_PySol
/solutions/functions.py
233
4.0625
4
# Computes the greatest common divisor between two numbers def gcd(x, y): while y != 0: x, y = y, x % y return x # Computes the lowest common multiple between two numbers def lcm(x, y): return x * y // gcd(x, y)
54721a478da1e133c94091236af6ec01b86787a3
geniousisme/CodingInterview
/Company Interview/SC/triangle.py
1,037
3.84375
4
from copy import deepcopy class Solution(object): def minimumTotal(self, triangle): """ :type triangle: List[List[int]] :rtype: int """ triangle_path = deepcopy(triangle) tmp_triangle = deepcopy(triangle) for i in xrange(len(triangle) - 2, -1, -1): ...
a49a934ea9adb31d0cd8f203c7faf9ca98a5eff9
michellexyeo/DailyProgrammer
/Combinatorial/powerset.py
838
3.90625
4
def powerset(n): # lists all subsets of n ints arr = [None]*(n+1) backtrack(arr,0,n) def isASolution(arr, k, n): # stop when k == n return k==n def constructCandidates(candidates): # only 2 possibilities at each stage: True or False # technically we can just initialise candidates as [True, False] but doing thi...
4c3587abf7c1288897ad60dfb43e36819a002eb0
Ayush-Malik/PracAlgos
/remove_duplicates_from_a_sorted_array.py
863
3.5625
4
# https://practice.geeksforgeeks.org/problems/remove-duplicate-elements-from-sorted-array/1/?category[]=Arrays&category[]=Arrays&company[]=Amazon&company[]=Microsoft&company[]=Adobe&company[]=Samsung&company[]=Accolite&company[]=Amazon&company[]=Microsoft&company[]=Adobe&company[]=Samsung&company[]=Accolite&problemStat...
2b901e3734be3f2eb3b2111dcaa7d051bbccc92d
claudiordgz/coding-challenges
/insertion_sort.py
418
3.65625
4
import fileinput data = [int(l) for line in fileinput.input() for l in line.split()] n = data[0] arr = data[1:] def print_array(arr): print(' '.join(map(str, arr))) def insertion_sort(l): for i in range(len(l))[1:]: k, j = l[i], i - 1 while j >= 0 and l[j] < k: ...
997c23afbe8e346a22a18551700d2df5c59f556b
Raragyay/Snake
/snake/map/snake.py
9,493
4.0625
4
# coding=utf-8 """Definition of class Snake. He will become the all-powerful.""" import random from collections import deque from snake.map.direction import Direc from snake.map.point import PointType from snake.map.pos import Pos class Snake: """ Definitions for snake object. This is the ancestor of all sna...
56fc559d1f23014adbe3aee2a6ff292185ce5228
IEP/submissions
/wiki-euler/9.py
345
3.8125
4
#!/usr/bin/env python3 import math def triplet(): for c in range(999,0,-1): for b in range(c-1,0,-1): a = math.floor(math.sqrt(c**2 - b**2)) if a + b + c == 1000 and \ int(a**2) + int(b**2) == int(c**2): print(a,b,c) return a, b, c a, b, c ...
59e93357bce0d781fa5ba6ce5d3948eb46c8e881
mriduldutt/tahthastu_week_of_code
/Day 5/Program 1.py
153
3.703125
4
n=int(input('Enter the number :-')) m=str(n) new__s='' for i in m: if i=='0': new__s+='5' else: new__s+=i print(int(new__s))
08cb930f1df8eae78cc91caf4fecc7bd0b8a1983
alexZeLoCO/EcuacionSegundoGrado
/main.py
816
4.0625
4
#A DIFERENCIA DE JAVA, EN PYTHON NO HAY UN MÉTODO PARA HACER UNA RAÍZ CUADRADA, #HAREMOS UNO NOSOTROS MISMOS. def sqrt (n): #CREA MÉTODO RAÍZ CUADRADA return n**(1/2) #RAÍZ DE N = N ELEVADO A 1/2 print ("La ecuación es del tipo: ax^2 + bx + c = 0") #GUÍA PARA USUARIO a = float (input ("Introduzca...
9fa805ed4cff507eacd3c4b00bf4253520685182
AnastasiiaSA/To_do
/to_do1.py
1,460
3.65625
4
class ToDoList(): tasks = [] def __init__(self): a=0 def runLoop(self,command): self.command = input("Enter command...") print ('command') if self.command == 'add': add_task if self.command == 'print': tasks(enumerate(1, 1)) ...
f1eff3d0dd4f746f882f1388104e906d849dee41
sakiii999/Python-and-Deep-Learning-Lab
/Python Lab Assignment 2/Source/LA2_1.py
642
4
4
books={"python":50,"web":30,"c":20,"java":40} finallist=[] #The starting and ending numbers for the range are taken from user input start=int(input("Please enter the start number: ")) end=int(input("Please enter the end number: ")) #To iterate inside the dictionary items for key,value in books.items(): #The loop is...
9b5eb5a2d1872c89cfb139efa05e36e8a3f96c72
agrodriguezs/python-curso-practicas
/manejo de funciones.py
1,004
4.1875
4
PI = 3.141516 #Area del cuadrado def acuadrado(): lado = int(input("Cual es el valor del lado?")) x = lado**2 print("\nEl area del cuadrado es ", x, "unidades cuadradas") def atriangulo(): base = int(input("Cual es el valor de la base? ")) altura = int(input("Cual es el valor de la altura?...
28831616996bede562d15ee00b66d87cdd66d96b
savandriy/baratto
/chexch.py
1,328
3.5
4
import requests from webmoney import convert_curr_to_webmoney def get_chexch_course(from_currency, to_currency): """ :param from_currency: string, should be one of 'USD', 'EUR', 'UAH', 'RUR' :param to_currency: string, should be one of 'USD', 'EUR', 'UAH', 'RUR' :return: tuple(result: float, website: ...
489678968572921103c5121c0623dc6fcac7de23
murliwatz/2021-emotion-detection-from-german-texts
/misc-scripts/list-capitalized-only.py
169
3.84375
4
import sys import re lines = open(sys.argv[1], encoding="utf8").read().splitlines() for line in lines: if len(line) > 0 and line[0].isupper(): print(line)
bc3a3abbdd38fb71f52e5894a57fc17c16a40a65
matiasimc/RedesNeuronales
/ejercicio2/learning_perceptron.py
624
3.75
4
import math class LearningPerceptron: def __init__(self, bias = 2, w1 = 2, w2 = 2, C = 0.01): self.bias = bias self.w1 = w1 self.w2 = w2 self.C = C def perceptron_output(self,x1,x2): return x1*self.w1+x2*self.w2 + self.bias >= 0 def sigmoid_output(self,x1,x2): ...
596d810d38cccff8fbeb92fefaf25a7e1c20e514
jiyoungkimcr/Python_Summer_2021_2
/HW1_Prime_Numbers.py
505
4.09375
4
''' Please write a program that print the first N prime numbers. N should be declared as a variable at the beginning of your code. Code Writer: Jiyoung Kim ''' N = int(input("Please enter the value for N:")) def Prime(n): for i in range(2,n): if (n % i == 0): return False return True i=2 ...
74578c7fd4f71113513a18f69c659fb1ed89a5fb
Kacyk27/python-unittest-learning
/Video course/09_parameterized/02_project/tests/test_calc_math.py
440
3.53125
4
import unittest from parameterized import parameterized from calculator.calc_math import SimpleMathCalculator class TestSimpleMathCalculator(unittest.TestCase): def setUp(self): self.calc = SimpleMathCalculator() @parameterized.expand([ ("negative",-3,-2,-5), ("mixed",-3,2,-1), ...
f0d62044b2ea89d82d8053eae46a821867f328cb
SPVJ/Lab8
/Question3/Hanoi.py
912
3.59375
4
from Disk import Disk from Pole import Pole class Hanoi(object): def __init__(self,n=3,start="A",workspace="B",destination="C"): self.startp = Pole(start,0,0) self.workspacep = Pole(workspace,150,0) self.destinationp = Pole(destination,300,0) self.startp.showpole() self.wor...
958053f97e14b6efbb54a05b486d16f2d3beaaf8
rishav0004/Student-Management-Table
/main.py
18,345
3.5
4
from tkinter import * import tkinter as tk from tkinter import messagebox from tkinter import ttk import cx_Oracle # window = tk.Tk() # g = tk.Label(text="Student Management Table",font = ("",40,"bold"),foreground = "orange",background = "black") # f = tk.Label(text="next label") # window.title('MAIN') # w...
cbe391b18ca26b793c10e66fea59162730cc9651
Carlos-DOliveira/cursoemvideo-python3
/pacote-download/aula13 - Estrutura de repetição for.py
871
4.0625
4
for c in range(0, 5): print('oi') # vai colocar do a até 4 não conta o último print('\nsegundo exemplo') for c in range(0, 5): print(c) # aqui vai do 0 até o 4 print('\nterceiro exp') for c in range(1, 5): print(c) # aqui vai do 1 até o 4 print('\nquarto exemplo') for c in range(6, 0, -1): ...
e197a44876d0340edcd08d26d16ac580efd9d2b0
LeonLi-LZJ/Movie_Sentiment_Analysis
/sentiment.py
6,210
3.90625
4
from typing import TextIO, List, Union, Dict, Tuple import doctest # PART I: File I/O, strings, lists def is_word(token: str) -> bool: '''Return True IFF token is an alphabetic word optionally containing forward slashes or dashes. >>> is_word('Amazing') True >>> is_word('writer/director') ...
5d9e639a2647e67a13a5eadf9770b3b4510c3f94
AnteaRokov/PAF-1
/Vjezbe_4/integrate.py
817
3.71875
4
import matplotlib.pyplot as plt import calculus as calc import numpy as np def f(x): return 2*x**2 + 3 analitical_integral = 11./3. num_dn, num_up = calc.integrate_up_dn(f,0,1,10) print("Donja međa: {0:} \n Gornja međa:{1:}".format(num_dn,num_up)) fig= plt.figure(figsize=(20,10)) # Plot numerical solutions dn ...
057bb58a89abf10a163d90f573d33e02d1c9a7e9
AntonioRdzNav/DL_trainingVisualization
/laplacian_util.py
11,051
3.71875
4
#=====================================================================[ legal ] """ # Copyright (c) 2016-12-09, Laurenz Wiskott, www.ini.rub.de/PEOPLE/wiskott/ # License: BSD 2-Clause, https://opensource.org/licenses/BSD-2-Clause, see the end """ #====================================================================[...
7436ba4ffc9b7885edb1f47b574fad92a87f0704
GeForce98/Python-Exercises
/Challenge 1.py
2,271
4.40625
4
#Quincy Asemota #Weekly Assignment 2 #Write a program that calculates a student's final grade in this course. #Tells user about the purpose of the program print("This program will calculate a students final grade in the course based on the percentage in the syllabus.") #Prompts user to enter student's grades fo...
3058d7f96951a6c860c5a9490fab8edd6f220e1c
tzechienchu/jameswcooper
/newsletter/RankedVoting/RankedVoteTk.py
7,331
3.609375
4
""" Ranked Voting demonstration using tkinter GUI display""" import random from dataclasses import dataclass import tkinter as tk from tkinter import * from tkinter.ttk import * # Command interface class Command(): def comd(self):pass #derived button class with an abstract comd method class DButton(Button, Comman...
027393bba3d3f6bf2df2984dfe364564c8fb1896
azeddinebouabdallah/dataVisualizationPython
/Introductiontosets.py
134
3.6875
4
def average(l): l = set(l) return sum(l) / len(l) n = int(input()) l = list(map(int, input().split())) res = average(l) print(res)
edcfc26d2f538f42b9ed93bb0585b6424bf0b06f
SubsonBigod/LeetCode
/t000.py
3,192
3.578125
4
# solution of leetcode.com or leetcode-cn.com # 单链表结点定义 class ListNode: def __init__(self, x): self.val = x self.next = None # 列表转单链表 def list_to_link(lists): link = tmp = ListNode(0) for l in lists: tmp.next = ListNode(l) tmp = tmp.next return link.next # 单链表转列表 de...
d09dea918c2eaf0e36f11950a3485a707234f258
sjhhh3/Leetcode
/Leecode/leetcode28.py
311
3.71875
4
a = 'I love u us' b = 'us' def strStr(haystack, needle): if haystack == needle or not needle: return 0 ans = haystack.find(needle) return ans print(strStr(a,b)) ''' for i in range(len(haystack) - len(needle)+1): if haystack[i:i+len(needle)] == needle: return i return -1 '''
f91a392cd8c35289b6e308e24206c84b01d56fbd
aatakansalar/bir_takim_python_projeleri
/game_of_life_v1/life.py
6,235
3.515625
4
import os import random import sys import time import numpy as np """ Use: >> python life.py "rand" 100 100 options: rand(regular), vnn, reprod(reproduction), immortal, load >> python life.py "vnn" 100 100 >> python life.py "reprod" 100 100 >> python life.py "immortal" 100 100 >> python life.py "load" ...
716840deaf0972e441875c2a27d98275407a0ad2
genie-o/Mydocument
/python/basic02/random/Random01.py
1,252
3.515625
4
''' *** Random 난수 *** *seed : 임의로 선택하는 것처럼 만들어주는 숫자 ''' import random num = random.randint(1,5) print(num) # 0~1 사이의 실수 형태인 난수 print(random.random()) # 리스트의 값들중 하나를 무작위로 추출 lst = [10,20,30,40,50] num2 = random.choice(lst) print(num2) # 원하는 만큼의 리스트 원소들을 무작위로 추출 num3 = random.sample(lst, 3) print(num3) # 리스트를 무작위로 섞어...
4b79d0492710fe4ba6ee134194e97a0a1b31d351
mindew/Bao_POE
/GUI_tutorial/GUI_tutorial.py
2,700
4.03125
4
from PIL import Image, ImageTk from tkinter import Tk, BOTH from tkinter .ttk import Frame, Button, Style, Label # Frame is a container for other widgets # tutorial is from: http://zetcode.com/gui/tkinter/introduction/ class Example(Frame): def __init__(self): super().__init__() # class inherits ...
f0dd4eef2492268f67b9c94b050a602e1727c7b5
benflores/crypto-pals
/crypto12.py
3,109
3.515625
4
# Solution to Matasano Crypto Challenge 2.12 http://cryptopals.com/sets/2/challenges/12/ # Byte-at-a-time ECB Decryption (Simple) # Appends plaintext to a known block of text (one byte shorter than full block), then # brute-force matches the last byte of the encrypted block to get a byte of the plaintext from crypto1 ...
ed4f5a5a1a5de615d399762ee70b773774707a02
Archaeologist03/python-cs-erceg
/midterm-labs/midterm-lab1.py
1,369
3.9375
4
# MIDTERM LAB 1 # ======================================== # # # Type your code here # print('Information Technology') # print('Talladega College') # print('Talladega, AL 35160') # ======================================== # # userNum = int(input('Enter integer:\n')) # # Type your code here # squaredNum = use...
e4eed9986d10a450e050211fbed8935417cead89
singhsaumy/python-tdd-classroom
/src/exercises.py
198
4.0625
4
def reverse_list(input_list): """ Reverses order of elements in list input_list. """ return None def count_digits(number): """ Return count of digits """ return None
d59f0084465b691486953760c281d30341619b91
sungsikyang92/pythonStudy
/CodeUp/1087_0084.py
111
3.5625
4
num = input() num = int(num) n = 0 for x in range(1, num+1): n += x if n >= num: break print(n)
2d67df31f089389d94a67beac99ea2daa9937d4d
Dainean/Cmb-practical
/op11question7.py
548
4
4
#!/usr/bin/env python #op11question7.py #Write an Ascii file with your text editor with 10 rows and two columns with arbitrary numbers. #data file is called onzindata.dat #Write a program that reads this data in two arrays 'x' and 'y'. Print for both arrays the minimum and #maximum value and the mean (use array methods...
4a59207e02ae952bb688f90f11486f54735c5c38
lianlinton/TimeSeriesElectricityUsagePredictions
/DailyDataSummarize.py
2,323
3.828125
4
#summarize data for a specific day together #import required libraries import pandas as pd import math # load the file electricityUsage = pd.read_csv('pge_2020_data1.csv', header=0, infer_datetime_format=True, parse_dates=['DATE'], index_col=['DATE']) #print(electricityUsage.head()) #create an empty dictionary sumDa...
801bdc58879cc7df7dc64990f9c9f16a77352063
sun9121/CodeUp
/Python_basic100/15.py
282
3.640625
4
# 공백을 두고 입력된정수(integer) 2개를 입력받아 줄을 바꿔 출력해보자. # 예시 # a, b = input().split() # print(a) # print(b) # 과 같은 방법으로 두 정수를 입력받아 출력할 수 있다. a, b = input().split( ) print(str(a) + "\n" + str(b))
b079f73fa38bd2e71e11e90e2ddc50a6174a7e56
ruhsane/CS-2-Tweet-Generator
/histograms/histogram_list_of_tuples.py
1,561
3.96875
4
def histogram(): histogram = [] words = [] with open("/Users/ruhsane/dev/courses/cs1.2/tweet-generator/histograms/source.txt") as f: for line in f: for word in line.split(): words.append(word) for word in words: #for each word in file word_found = False ...
fc378c88765cec8354fb13daf2ad0bfbe5f15d23
planitary/Ai_Demo
/Main/Cal.py
2,591
3.5
4
import math, logging from Error_info import * from Log import LogConfig class Cal(BuildError): @classmethod def __init__(self): logging.info("Start") # 正方形面积 def Square_Area(self, length): try: if length < 0: raise PositiveIntegerError ...
936c6d189f652b507998cc2191ebe3669d4e00bd
wjddn279/Algorithms
/Programmers/2020 카카오 공채/괄호 변환.py
843
3.609375
4
def solution(p): global answer answer = '' recursive(p) return answer def recursive(p): global answer if not p: return dic = {'(':')',')':'('} idx = isbalance(p) u,v = p[0:idx+1],p[idx+1:len(p)+1] if iscorrect(u): answer += u recursive(v) else: answer...
55a3e5e3236bd8d8cac7b81ee3b768879f0b767b
longxinzhang/Python_Learning
/LPTHW/if_adult_18.py
168
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print ("中文字能显示吗?") #int age = raw_input(); #if age >= 18: # print ('adult') #else: # print ('teenager')
bdb707bac4ed1e1abd535f4301985881aa9ffe2a
Teemitayoo/ML-Study-Group
/Assignment/Solutions Week1/Ganiu_Ibrahim_week1.py
3,167
4.03125
4
import math import random def mean(n): """ Computes the mean value of a list of parameter n """ total = 0 for i in n: total += i return total/len(n) def median(n): """ Computes the median value of a list of parameter n """ n.sort() length_of_n = len(n) if length_of_n%2==0: after = lengt...
e801bd65ede8fd4d9927eb298fe97ed2f09de84b
dnwigley/Python-Crash-Course
/user.py
972
3.953125
4
#user class User(): """User databse""" def __init__(self, first_name, last_name, password, age): """Initialise name and user attributes.""" self.first_name = first_name self.last_name = last_name self.password = password self.age = str(age) def describe_user(self): full_name = self.first_...
082c91495dd6b17d0a1e4214ad5713eceed242a5
Danilo282/python-port
/Leitores_for_while/notas.py
348
3.890625
4
n1 = float(input('Digite a primeira nota: ')) n2 = float(input('Digite a segunda nota: ')) me = (n1 + n2) / 2 if n1 < 0: print('Numero invalido.') elif n1 >= 10.1: print('Numero invalido.') elif n2 < 0: print('Numero invalido.') elif n2 >= 10.1: print('Numero invalido.') else: print('A Media das not...
7ec198ff98ff4eabaf5df57461b5d4bf1a7fc8b4
ganesh-112/gans
/gans/core/generator.py
7,899
4.21875
4
""" ## Generator The first step is to build the generator component. You will start by creating a function to make a single layer/block for the generator's neural network. Each block should include a [linear transformation](https://pytorch.org/docs/stable/generated/torch.nn.Linear.html) to map to another shape, a [b...
28d46de7bd082250b02d5cbc9f0cb80e1f60c99f
RaiManish3/AdventOfCode
/contest2016/day16.py
627
3.546875
4
import time start =time.time() initial = "10010000000110000" disk_length = 35651584 def check_sum(a): while 1: strx="" for i in xrange(0,len(a),2): if a[i]==a[i+1]: strx+='1' else : strx+='0' if len(strx)%2: break a=strx return strx def dragon_curve(a): global disk_length while 1: b="" ...
4bad80811188dd991e938a52bb8e8fde32228373
Naoya-abe/siliconvalley-python
/section5/lesson42.py
560
3.875
4
# for文とcontinue文とbreak文 some_list = [1, 2, 3, 4, 5] # リストの中身を1つずつ出力 # while文を使用した場合 i = 0 while i < len(some_list): print(some_list[i]) i += 1 # for文を使用した場合 for j in some_list: # some_listの値を順番に「j」に入れて実行する print(j) # 文字列でもできる for s in 'abcde': print(s) # break、continueも使える for word in ['My', 'nam...
50cab0a23d740d16f537efa68c0ee0effdd7fc4c
srikanthpragada/PYTHON_10_DEC_2018_LANGDEMO
/funs/complex.py
187
3.6875
4
def add(a, b): return a + b def add(a, b, c): return a + b + c def sub(a, b): return a - b def task(a, b, op): print(op(a, b)) task(10, 20, add) task(10, 20, sub)
7d626286b2f53d33ee34075d93f3ebd10b61ee38
shasank-shah/pycharmProjects
/pythonProjects/perlweeklychallenge-club/challenge-049/orestis-zekai/python/ch-1.py
186
3.53125
4
import re num = 23 factor = 2 onesZeros = re.compile(r'[2-9]+') while True: intermed = num*factor if onesZeros.search(str(intermed)) is None: print(intermed) break factor += 1
1d9b2c70d5d3a658383d76da43edb6a803c974f7
vreddy2018/problemset0
/ps0.py
2,807
4.3125
4
def odd_even(number): """This function determines if the argument is odd or even and returns true if even""" if number%2 == 0: #if there is no remainder when divided by 2 the number is even return True else: return False def digits(number): """This function returns the number of digits in the argument""" ...
11afcbe77fda894713f1bc53c7bbeec842c3a9fc
BoggarapuSusmita/Artificial-Intelligence
/TSP using Hill Climbing.py
1,224
3.875
4
import copy # graph = matrix('0 2 3 3 6; 2 0 4 5 3; 3 4 0 7 3; 3 5 7 0 3; 6 3 3 3 0') graph = [[0, 2, 3, 3, 6], [2, 0, 4, 5, 3], [3, 4, 0, 7, 3], [3, 5, 7, 0, 3], [6, 3, 3, 3, 0]] v = 5 def computeCost(path): cost = graph[path[0]][path[v - 1]] for i in range(v - 1): cost += graph[path[i]][path[i + 1]...
5c73be0a77209dcf89016ceefcf5dce3863ea601
bruno-zaccariello/usefull
/EulerProject/euler_27.py
419
3.5625
4
from my_generators.primes import is_prime def get_result(): biggest = 0 res = () for a in range(-1000,1000): for b in range(-1001,1001): n = 0 while True: if is_prime(n**2 + a*n + b): n += 1 else: break ...
1ed5f2caad6946bea24f56ac1422b92b0637a1cc
EstefaniaLaverde/Torres_de_Hanoi
/PROYECTO_LOGICA/Archivos de texto-reglas logica2/Código/Codificacion.py
8,589
4.0625
4
"""=====FUNCIONES PARA PASAR LAS REGLAS A ARBOLES=====""" #import collections """FUNCION QUE LA LISTA CON LAS LETRAS PROPOSICIONALES LARGAS""" def crear_lista_letras_largas(): #Las letras "largas" tienen la forma (PA,1,Arriba,1) Posiciones=["Arriba","Medio","Abajo"] Palos=["PA","PB","PC"] Fichas=["1","2"...
e07ee645c3cb83b14ce842d1363b050e985de40c
slaypax/exercism
/python/word-count/word_count.py
1,039
3.796875
4
# def count_words(sentence): # words = OrderedDict() # # [A-Z]{2,}(?![a-z]) matches caps # # [A-Z][a-z]+(?=[A-Z]) matches caps first. # # (?=[A-Z]) part looks ahead to stop match before next cap # # [\'\w\-]+ # split_sentence = re.findall(r'[A-Z]{2,}(?![a-z])|[A-Z][a-z]+(?=[A-Z])|[\'\w\-]+', se...
8e38304102d27e4a76caf432bef1e27320c8f108
tpt5cu/python-tutorial
/language/python_27/built_in_functions/map_.py
466
4.3125
4
''' - In Python 2, map() returns a list where every item had <function> applied to it - In Python 3, map() returns an iterator that WILL apply <function> to every item in <iterable>. THIS IS IMPORTANT FOR MATPLOTLIB. ''' def divide_list_elements(): my_list = [2, 4, 6, 8, 10, 12] divided = map(lambda x: x / 2,...
d1b22b69404e0c1602e90672f3a1aec0897a04b5
laura-barluzzi/Learn-Python-hard-way
/ex40.py
1,314
4.0625
4
class Song(object): def __init__(self, lyrics): # it create the empty object of self for creating variables and lyrics imported self.lyrics = lyrics # I create a variable (like always using self.) with the value of the lyrics imported def sing_me_a_song(self): # I create a fu...
36cc979ba88fc0738f9b315477ffc197023d42b1
inkpei/WORK
/lintcode/56.py
1,128
3.625
4
# # 56. 两数之和 # 给一个整数数组,找到两个数使得他们的和等于一个给定的数 target。 # # 你需要实现的函数twoSum需要返回这两个数的下标, 并且第一个下标小于第二个下标。注意这里下标的范围是 0 到 n-1。 # # 样例 # 给出 numbers = [2, 7, 11, 15], target = 9, 返回 [0, 1]. # # 挑战 # Either of the following solutions are acceptable: # # O(n) Space, O(nlogn) Time # O(n) Space, O(n) Time class Solution: """ ...
a3713f75c932e9a022008054702203506d98feef
kanuos/python-programs
/List Programs/SortFirstListWithSecondList.py
805
4.28125
4
# Python | Sort the values of first list using second list # get two lists # list1 = ["a", "b", "c", "d", "e", "f", "g", "h", "i"] # list2 = [0, 1, 1, 0, 1, 2, 2, 0, 1] list1 = ["g", "e", "e", "k", "s", "f", "o", "r", "g", "e", "e", "k", "s"] list2 = [ 0, 1, 1, 0, 1, 2, 2, 0, 1] if len(list1) < len...
765df8b3873570c187232b25a053b20011b4cbe6
eduardogomezvidela/Summer-Intro
/Post-summer Assessment/sudoku.py
9,357
3.8125
4
"""2) Sudoku""" game = [[None, None, 4, None, None, 8, 5, None, 1], [None, None, None, None, 9, 5, None, 3, None], [None, None, None, 3, None, 1, None, 6, None], [None, 7, None, None, 8, None, 1, 4, None], [1, 6, 9, None, 3, None, 8, 2, 7], ...
3d708e971741df454a67db7c4dfadef2bad15ff4
momchilantonov/SoftUni-Python-Advanced-January-2021
/Exam-Preparation/Resolving-Tasks/fashion_boutique.py
772
3.765625
4
from collections import deque def take_clothes_vol(): clothes_vol = [int(x) for x in input().split(" ")] return clothes_vol def has_space(rack_cap, cloth): return rack_cap >= cloth def store_clothes(clothes_vol, rack_cap): rack_count = 1 current_rack_cap = rack_cap while clothes_vol: ...
6ffe08a3fedc0eac62be5479bbcc0c1e5a3c054b
sophiallen/csc110-hw
/rockpaper.py
1,124
4.125
4
from random import randint def draw(): opts = {1:'rock', 2:'paper', 3:'scissors'} choice = randint(1,3) return opts[choice] def winner(hum, comp): if hum == comp: return (0,0) elif hum == "rock": if comp == "paper": return (-1, 3) else: return (3,...
fe8ca389b8e06a94ab6a9f5b1e171bf4b54dcf81
mryyomutga/TechnicalSeminar
/src/textbook/chapter6/chapter6-4/chapter6-4-2.py
527
4.125
4
# -*- coding: utf-8 -*- # 特殊メソッド2 class Pos: """座標クラス""" def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Pos(self.x + other.x, self.y + other.y) def __mul__(self, other): if isinstance(other, (int, float)): return Pos(self.x...
6a8ec63f25f1f135e7037acc2e3973cf39bd0ad0
DallasJM/Python
/python/fundamentals/loopBasic.py
1,050
4.125
4
# 1. Basic - Print all integers from 0 to 150. # for i in range(0, 151): # print(i) # 2. Multiples of Five - Print all the multiples of 5 from 5 to 1,000 # for i in range(0, 1000, 5): # print(i) # 3. Print integers 1 to 100. If divisible by 5, print "div by 5" instead. If divisible by 10, print "div by 10". # def...
354d4387e87d221b05393fece06427ce02c67a82
Andmontc/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_models/test_rectangle.py
7,786
3.578125
4
#!/usr/bin/python3 """Unit testing rectangle""" import unittest from unittest.mock import patch from io import StringIO from models.rectangle import Rectangle from models.base import Base import pep8 class TestRectangle(unittest.TestCase): """This class is for testing the Square class""" @classmethod de...
8df726b32c5963e2efb42d39ed2e51a58243ca0a
congyingTech/Basic-Algorithm
/getOffer/56.entrance-in-circle-linkedlist.py
1,916
3.921875
4
# encoding:utf-8 """ 问题描述: 一个链表里面存在环,如何找出环的入口结点? 解决方案: 可用双指针的思路,定义两个指针p1,p2,指向链表的头结点, 如果链表中的环有n个结点,那么p1先在链表上移动n步,然后两个结点以相同的速度向前移动。 当两个结点相遇时,就是环的入口。 那么,如何求链表在环内的长度呢? 设置快慢指针,快指针每次向前移动两个指针,慢指针每次移动1次,它们第一次相遇的时候一定是在环内, 然后从第一次相遇后开始计数,直到慢结点再次回到这个位置,那么就是环的长度 """ class LinkedNode(object): def __init__(self, val): s...
9e063f753db17a4bd85c27b98a32ae6fb809546b
edu-athensoft/stem1401python_student
/py200912f_python2m7/day06_201017/homework_2_issa.py
1,099
4.3125
4
""" [Homework] 2. There are 3 candidates in the election for President in ABC country. They got voted in every state/province in ABC country. You are asked to calculate who got the highest vote in the election. Name Voted in State1 Voted in State2 Voted in State3 Jason 300 360 270...
ff473ebae6cc16e49d8e8a78c14cd615054b9e13
herzenuni/sem5-firsttask-04092018-Trofimchikkk
/firsttask.py
1,781
3.5625
4
class RangeException(Exception): def __init__(self,text): RangeException.txt = text logger = [] try: number = int(input('Введите число от 0 до 9: ')) if ((number<0) | (number>9)): raise RangeException('Введенное число не входит в указанный интервал') except RangeException: print('Введенн...
a98cb0685a822c1336ebf8e815312a2ff1a37776
brunomdrrosa/100DaysOfPython
/Day4/mapaTesouro.py
564
4.1875
4
# 🚨 Don't change the code below. 👇 row1 = ["⬜️","⬜️","⬜️"] row2 = ["⬜️","⬜️","⬜️"] row3 = ["⬜️","⬜️","⬜️"] mapa = [row1, row2, row3] print(f"{row1}\n{row2}\n{row3}") posicao = input("Onde você quer colocar o tesouro? ") # 🚨 Don't change the code above 👆 #Write your code below this row 👇 horizontal = int(posicao[0...
25026a91b55680b3b19a0de6edbe7736ad078b6b
DDRMASTERM/Python
/projects/Week_5/input_nums.py
160
3.953125
4
try: num1 = int(input("First number: ")) num2 = int(input("Second number: ")) print(int(num1)+ int(num2)) except ValueError: print("Please use integers")
998c9e431faec029e381f07a353441dbf05ff73a
hajuu/lehathu-fundamentals-c4t
/Session04/exercise/1.4.py
405
3.6875
4
from turtle import * shape("turtle") speed(0) for i in range(4): forward(100) left(90) penup() backward(50) pendown() for i in range(3): backward(120) right(120) penup() right(90) forward(50) left(90) pendown() for i in range (360): forward(1) right(1) penup() forward(350) pendown() for i in ran...
bc75dd7243eb5215d30298bd40cb530ece91d11c
yamendrasinganjude/aws_cloud
/Add.py
248
4.15625
4
num1 = 12 num2 = 13 num = num1+num2 print(num1+num2) print(num) #print floating sum from input from user a = input("1st num : ") b = input("2nd num : ") sum = float(a)+float(b) #printing values print("sum of {0} and {1} is {2}".format(a,b,sum))
95248f869de716e30dcf17bece31f3b5a2ab0dcf
XiaosuTong/Documents
/Python/Chapter1/1.12.py
371
4.28125
4
#!/usr/bin/env python3 from collections import Counter words = ['look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes', 'the', 'eyes', 'the' ] word_counts = Counter(words) top_three = word_counts.most_common(3) print(top_three) morewords = [ 'why', 'are', 'you','not', 'looking', 'my', 'eyes' ] for word in mor...
1f2c3b03423137369a2c5c353e064b156054d99a
savithande/Python
/functions.py
567
4.375
4
# creations of functions in python :- functions is a name of the block of code # creation of function\ def add_two_numbers(num1,num2): # def(used to tell fun is defined) name_of_block(arguments): result = num1 + num2 # statements return result # return value # call the function with argum...
411a13535438132a70451521271a40822fb87c25
yujinee/scimat2
/science/Electricity/ohms-law/ohms-law.py
1,698
4.09375
4
import random # If a V V battery is connected across an unknown resistor, there is I mA in the circuit, find the value of resistance of the resistor? # If a V V battery is connected across a resistance of R ohm, then find the current in the circuit? # If a resistance of R ohm is connected across a battery of unknown v...
fcfc360444b19a6b34ea4cb2a10607b2508fa962
rjorth/Algorithms-and-Data-Structures
/MergeSortedArray.py
168
3.90625
4
def merge(nums1, m, nums2, n): for i in range(m): if nums1[i] == 0: if nums2[i] not in nums1: nums1[i] = nums2[i] print(merge([1,2,3,0,0,0], 6, [2,5,6],3))
fad0dca7036472ad0f493adebec7feee7a0e4686
BottleOMan/Ejercicios
/Moodle 6.py
260
3.703125
4
n = int(input("ingrese un numero:" )) p = 0 j = 0 for i in range(1,n + 1): w = i ** 2 j += w p += i s2 = p ** 2 x = s2 - j print("la suma de los cuadrados es: ",j) print("el cuadrado de las sumas es: ",s2) print("y su diferencia es: ",x)