blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
90ca7d5a1a03458f38dddba6346bd98671ccefd5
NineSH/leecode
/Two Sum1.py
1,503
3.796875
4
# Given an array of integers, return indices of the two numbers such that they add up to a specific target. # 给定一个整数数组,从数组中找两个数值使其相加等于目标数字,并返回其在数组的位置 主要每个target只有一个解决办法 # You may assume that each input would have exactly one solution, and you may not use the same element twice. # eg.nums=nums = [2,7,11,15],target = ...
d7929e87bcc9d1fe3764845d6102dd06d8551a12
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/mhdllo001/question1.py
2,013
3.609375
4
print("Welcome to UCT BBS") print("MENU") print("(E)nter a message") print("(V)iew message") print("(L)ist files") print("(D)isplay file") print("e(X)it") x=input("Enter your selection:\n") s="no message yet" E="" file1="42.txt" file2="1015.txt" content1="The meaning of life is blah blah blah ..." content2...
fdd88e8eb3decf5160be15d1a9d3a6fa6c9ad75c
Fame1772-cmis/fame1772-cmis-cs2
/ourwakeup.py
1,384
4.40625
4
def main (): print (""" This program will ask you for 5 integer or float values. It will calculate the average of all values from 0 inclusive to 10 exclusive. It will print out whether the resulting average is even or odd.""") N0 = float(raw_input("n0: ")) if N0 < int(0) or N0 >= int(10): print str(N0) + " is ...
ece964c1ee6ab70ef3aa0e0fb57fc07f9219c98a
Ianh4526/Code
/Data Science and Machine Learning with Python - Hands On!/Covariance and Correlation/covariance.py
768
3.703125
4
#covariance measures how to variables vary in tandem from their means #how much atribiutes depends on each others import matplotlib.pyplot as plt import numpy as np def de_mean(x): xmean = np.mean(x) return [xi - xmean for xi in x] def covariance(x,y): n = len(x) return np.dot(de_mean(x), de_mean(y))...
e69cf49ac08ab254b7bd58dee778594c9721f9a7
BrandonBaLu/poo--1719110177
/semana-4/banco.py
1,338
3.625
4
class banco: "atríbutos" cajeros= 5 personal= 30 sillas= 15 pantallas_llama_turnos= 4 ventanillas= 12 #métodos def retirar(self): print("retirar") def depositar(self): print("depositar") def __init__(self): pass class azteca(banco): #atríbutos abierto_ta...
cf7afe795c7c6af50edcf5d7a62a0c4b008dc60f
thiagofb84jp/python-exercises
/pythonBook/chapter08/exercise8-28.py
347
3.828125
4
# Valida a entrada de uma função def validaEntrada(mensagem, opcoesValidas): opcoes = opcoesValidas.lower() while True: escolha = input(mensagem) if escolha.lower() in opcoes: break print("Erro: opção inválida. Redigite.\n") return escolha validaEntrada("Escolha uma...
48786c567cdaad2f58e58eea707015214bb018fc
devGB/Zombula
/gui_temp.py
671
3.859375
4
import easygui easygui.msgbox("This program converts Fahrenheit to Celsies ") #print("This program converts Fahrenheit to Celsies") fahrenheit = easygui.integerbox("Type in a temperature in Fahrenheit: ", lowerbound = -9999999, upperbound = 999999999) #print("Type in a temperature in Fahrenheit: ",end="")...
5d600dd6a45f4e7fda210a11c19c5c18c57d3f52
aleksiheikkila/HackerRank_Python_Problems
/Time_Conversion.py
693
4
4
''' HackerRank problem Domain : Python Author : Aleksi Heikkilä Created : Aug 2019 Problem : https://www.hackerrank.com/challenges/time-conversion/problem ''' #!/bin/python3 import os import sys # # Complete the timeConversion function below. # def timeConversion(s): # # Write your code here. #...
4f5352f9c13813e2d4934e95efbdc05c6a51a229
Recoan0/KohonenNetwork
/kohonen.py
5,108
3.5
4
import numpy as np import matplotlib.pyplot as plt import time # 100x100 for 1000 iterations takes 149.263 seconds # 100x100 for 2000 iterations takes 182.651 seconds np.random.seed(4) # Set seed of random generator to get same outcome each time class Node: def __init__(self, weight_vector_size, x, y): ...
fef1c72ebcaefe549870713c2b808d781089c45e
anubhavmarasini/CIS223-Algorithms-
/asignment1.py
4,597
4.53125
5
print("\n Problem 1 -> \n") ###Problem 1:> Print a list of your favorite foods by using a for loop. ##Creating a list of favourite foods My_Food_list = ["\n" "\t" "\t" "\t" "\t" "MOMO", "\n" "\t" "\t" "\t" "\t" "CHOWMEIN", "\n" "\t" "\t" "\t" "\t" "CHATPATE", "\n" "...
8656f016892560049b3c129eb86cf7405ceac6a3
etoitau/CS50-Projects
/Week 6/bleep/bleep.py
1,475
3.875
4
# CS50 Problem Set 6 # bleep # user gives text file with banned words in it # all lowercase, one word per line # # by: Kyle Chatman # on: 190308 # # Spec: # don't ban big words that just contain a banned word (e.g. darn is banned but darnit is not) # can assume user will not input punctuation, just word...
dd97ff380be1a570b140883989bd28caf2670820
gzliang2010/Turtle-module
/Sierpinski_Triangle.py
1,474
4.125
4
import turtle from random import randint from math import sqrt #color = ["red", "blue", "yellow", "brown", "black", "green", "violet"] def drawTriangle(point1, point2, point3, t): t.up() t.goto(point1[0], point1[1]) t.down() t.goto(point2[0], point2[1]) t.goto(point3[0], point3[1]) t.goto(point1[0],...
4422be5ff2ea3d7d8ed7fa76740e01de2eb9c7b5
BettyAtt/myWork
/week03/Labs/lab3.3.3normalise.py
729
4.59375
5
# This program reads in a string and strips # any leading or trailing spaces. # It also coverts all the letters to lower case # and outputs the length of the original string # and the normalised one. # Author: Betty Attwood # .strip() removes white space before and after string # .lower() changes all characters to lo...
1e40501755aeae65ed1187156f903661ec6d042d
gineer01/programming-challenges
/python/UVA/10038_jolly_jumpers.py
405
3.5625
4
import fileinput f = fileinput.input() def check_jolly(n, a): expected = set(range(1, n)) actual = {abs(a[i] - a[i - 1]) for i in range(1, n)} # print(expected, actual) return actual == expected def process_line(l): a = list(map(int, l.strip().split())) if check_jolly(a[0], a[1:]): p...
d828865efbaf5bf51931a7c02c6abc81775aa5de
FillipdotS/hashcode-real-2021
/main.py
5,299
3.578125
4
from datetime import datetime from operator import itemgetter class Street: def __init__(self, origin, destination, name, duration): self.origin = origin self.destination = destination self.name = name self.duration = duration self.activity = 0 self.prior...
65e77a79c718cf49cb24f3dd42e27302688b9d37
lixiang2017/leetcode
/problems/1185.0_Day_of_the_Week.py
1,589
3.859375
4
''' Success Details Runtime: 16 ms, faster than 70.13% of Python online submissions for Day of the Week. Memory Usage: 13.3 MB, less than 13.64% of Python online submissions for Day of the Week. ''' class Solution(object): def dayOfTheWeek(self, day, month, year): """ :type day: int :type m...
216dcefd4c2eb85d6eec367497eb8f8f217e6169
zhenyulin/mlcoursework
/ex2/gradientFunction.py
971
4.09375
4
from sigmoid import sigmoid import numpy as np def gradientFunction(theta, X, y): """ Compute cost and gradient for logistic regression with regularization computes the cost of using theta as the parameter for regularized logistic regression and the gradient of the cost w.r.t. to the parameters. ...
c02bd02b78237b989e1a62b96d5617d973e31f10
leanndropx/px-python-logica-de-programacao
/76 - Dicionarios - Aprova ou reprova aluno.py
724
4.03125
4
# - DESCREVENDO O DESAFIO print('76 - Faça um programa que leia nome e média de um aluno ',end='') print('guardando também a situação em um dicionario') print('No final, mostre o conteúdo da estrutura na tela') print() #INICIALIZANDO O PROGRAMA # IMPORTA BIBLIOTECAS # 1 - RECEBE DA...
57f9f67715e10e5c0103ea6007fd0d7b53ef56be
sgrade/pytest
/leetcode/pascals_triangle.py
1,248
4.09375
4
# https://leetcode.com/problems/pascals-triangle/description/ """ Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] """ class Solution: def generate(self, numRows): """ :type numR...
fc2aa8ac43ea85bf95f3418fbea47e539c5de566
uoumol/python
/ex33_sample.py
221
3.9375
4
def loop(i,n,a): e=[] while i<n: print("the top number is %d" %i) e.append(i) i+=a print("the bottom number is %d" %i) print(e) def fr(n,a): E=[] for i<n: print("the number is %d " %i ) E+=[i] i+=a
e411c374831d796a6d7881e286a923398e25ed5a
CaptCorpMURICA/TrainingClasses
/Udemy/TimBuchalka/CompletePythonMasterclass/DictionariesAndSets/fruit.py
1,356
3.84375
4
""" Author: CaptCorpMURICA File: fruit.py Creation Date: 1/8/2018, 12:31 PM Description: More methods using dictionaries """ fruit = {"orange": "a sweet, orange, citrus fruit", "apple": "good for making cider", "lemon": "a sour, yellow citrus fruit", ...
72858e75ff7be01d8300ae5be286e22209c599e0
kentasato718/LeetCode
/univalued-binary-tree.py
711
4.1875
4
# https://leetcode.com/problems/univalued-binary-tree/ # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def isUnivalTree(self, root): """ :type root: TreeNode ...
8cd20133881a99fe105d1506115faa58f70cc2ea
Scott-S-Lin/Python_ittraining
/0409上午/p_fun.py
152
3.53125
4
def f1(n,m): print('f1() n*m =',n*m) def f2(n,m): n-=1 return n n = int(input()) m = int(input()) f1(n,m) print(f2(n,m))
71d138762db4bfcb5ff656754658397db5f50a59
misterecco/deep_learning
/lab_08/mnist_rnn.py
2,284
3.828125
4
import tensorflow as tf import numpy as np from tensorflow.examples.tutorials.mnist import input_data import os '''' Task 1. Write simple RNN to recognize MNIST digits. The image is 28x28. Flatten it to a 784 vector. Pick some divisior d of 784, e.g. d = 28. At each timestep the input will be d bits of the image. Th...
c63a172ed8b5204f1843492502af1e7e81a2d6a9
FarrelNA/python-test
/Tugas 1.1.py
431
3.765625
4
#Definisi fungsi def penjumlahan(*vartuple): print("Jumlahnya adalah:") jumlah=0 for var in vartuple: jumlah=jumlah + var print(jumlah) def rata(*vartuple): print("Rata-ratanya adalah:") rerata=0 tot=0 for var in vartuple: tot=tot+var rerata=tot/len(var...
1de7e02ee1404a797e31aba59e7966a5032025b7
noozip2241993/learning-python
/csulb-is-640/deitel-text/exercises/ch04/ex409.py
649
4.53125
5
'''(Temperature Conversion) Implement a fahrenheit function that returns the Fahrenheit equivalent of a Celsius temperature. Use the following formula: F = (9 / 5) * C + 32 Use this function to print a chart showing the Fahrenheit equivalents of all Celsius temperatures in the range 0–100 degrees. Use one digit of ...
de3f68048af5cd79e779397bfe3c34775061b3b9
prd-dahal/Data-Strucutre-Python
/binary_tree.py
1,400
4.0625
4
class Node: def __init__(self, data=None): self.data = data self.right = None self.left = None class BinaryTree: def __init__(self,initialNode = None): self.initialNode = initialNode def insert(self,item): temp = self.initialNode while(True): if(...
cd66757767e3fba5ff3caade8ba136a0055ad769
alexandraback/datacollection
/solutions_5688567749672960_0/Python/mrussell/main.py
1,237
3.5
4
import fileinput from math import log, floor, ceil input = fileinput.input() def flip(x): return int(str(x)[::-1]) def num_digits(x): if x == 0: return 0 else: return 1 + num_digits(x // 10) def largest_digit(x): n = num_digits(x) for i in range(n-1): x = x // 10 return x def small...
c87a9b071aeed64fcebe5915bc4c2b7eb316bbec
sooyeon9/python
/프로그래밍기초/복습.py
3,395
3.875
4
def test1(xs) : #대입리스트는 바뀌지않음 xs = xs + [6] return xs def test2(xs) : #대입리스트 바뀜 -> 대입리스트를 훼손시킴 xs.append(6) return xs def test2_2(xs) : #test2를 보완시킴 (대입리스트를 복사) xs = xs[:]#복사!!!! xs.append(6) return xs def test3(xs) : #대입리스트도 바뀜 xs += [6] return xs xs1 = [1,2,3,4] xs2 = [1,2,3,4]...
94647b4025edb683c416224d568ae946b7f620cb
5footerica/pyClass
/ants2.py
852
3.71875
4
""" ants2.py Classic counting song use parameters and return statements 09/20/2017 """ def chorus(): output = """ ...and they all go marching down- to the ground- to get out- of the rain. Boom boom boom boom boom boom """ return output def versus(verseNum): if verseNum == 1: ...
ad0195bd7106d5aa6a44398e2fb4f840f9b48fd5
EladAssia/InterviewBit
/Binary Search/Rotated_Sorted_Array_Search.py
1,569
3.796875
4
# Suppose a sorted array is rotated at some pivot unknown to you beforehand. # (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2 ). # You are given a target value to search. If found in the array, return its index, otherwise return -1. # You may assume no duplicate exists in the array. # Input : [4 5 6 7 0 1 2] and ...
52a6575cad39307b541213adc7db30f69d5a83e0
moontasirabtahee/Problem-Solving
/helpers/linked_list.py
349
3.53125
4
class Node: def __init__(self, x, parent=None): self.val = x self.next = None if parent: parent.next = self def __str__(self): head = self values = [] while head: values.append(head.val) head = head.next return ', '.jo...
e96b4af896a0a4834ec3ab7d834f01263461a9db
vinayakushakola/Python-Basic-Programs
/reverse_string.py
185
3.96875
4
def reverse(name): r = "" length = len(name) - 1 while length >= 0: r = r + name[length] length -= 1 return r output = reverse("Vinayak Ushakola") print(output)
1f1ded31dc5be62f0130bcd763c4beef6a2f99e9
VaggelisSpi/Hate-Speech-Detection-Using-Neural-Networks
/src/my_models.py
2,425
3.625
4
from keras.models import Sequential, load_model from keras.layers import Dense, GaussianNoise, Activation, Embedding, Dropout, TimeDistributed, LSTM, Flatten, \ GlobalAveragePooling1D, Masking def make_model(vec_size=200, batch_size=2000, go_backwards=True, return_sequences=True, layers=2, dropout=0.2, ...
d36d998a482c89981baf6259ed1d6a9039784c69
prabhupant/python-ds
/data_structures/stack/largest_rectangle_area_in_histogram.py
1,048
4.09375
4
''' Largest rectangle area in a histogram:: Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars have same width and the width is 1 unit. ''' def max_area_histogram(histogram): stack = list()...
25b3cc0ed5661878482b4a7f1e6e165ecea8842d
kociumbas/ReturnMaxFromThree
/ReturnMaxFromThree.py
845
4.3125
4
#Define a function max_of_three() that takes three numbers as arguments and returns the largest of them. #zdefiniuj funkcję max_of_three(), która bierze trzy liczby jako argumenty i zwraca największą z nich def maxOfThree (numberA, numberB, numberC): if numberA>=numberB: if numberA>=numberC: r...
ab1ef361b59c10a0135bd358082be0053f24936a
Admin9705/console-menu
/consolemenu/multiselect_menu.py
2,929
3.75
4
import itertools from consolemenu import ConsoleMenu from consolemenu.items import SubmenuItem class MultiSelectMenu(ConsoleMenu): """ Console menu that allows the selection of multiple menu items at a single prompt. """ def __init__(self, title=None, subtitle=None, show_exit_option=True, formatter=...
f92403b35da92e364bd07d7c4dd55801d2ff519c
ankit1222000/Python_Example
/Python_Example/module (2)/pass_validationa.py
106
3.6875
4
password=input("Enter the Password: ") if(password=='prospero'): print("Valid") else: print("Invalid")
b284ed657a0b1c83fddb7377697d2b60be39fa39
denis-soshenkov/Coursera_Python
/week2/z38.py
187
3.5
4
N = int(input()) k = N i = 0 while N != 0: N = int(input()) if i == 0 and N < k: i = N elif N == k: i = N elif N > k: i = k k = N print(i)
c58fd9fb1796d339187710403d34280fb9b4b91f
SrikarValluri/computer-networks
/lab0/part2.py
1,659
3.578125
4
# Used this resource to help: https://zetcode.com/python/socket/#:~:text=The%20recv()%20method%20receives,returns%20an%20empty%20byte%20string """ Bodnar, Jan. “Python Socket Tutorial.” Python Socket Tutorial - Python Network Programming with Sockets, zetcode.com/python/socket/#:~:text=The%20recv()%20method%20receives,...
2ff0eac0bb08cd7d1dd3878e8d83178e258056bc
src053/PythonComputerScience
/chap7/examScores.py
478
4.0625
4
#Program to determine exam scores using if def main(): #input scores score = eval(input("Please provid the exam score (0 thru 5): ")) if score == 5: print("Congradulations you studied hard and got a A!") elif score == 4: print("Congradulations you studied hard and got a B!") elif score == 3: print("Not b...
112589c6f3ee495fe4a1146bc9a1569792e33680
DimitrisKostorrizos/UndergraduateCeidProjects
/Project Θεωρία Αποφάσεων/SVMMain.py
3,387
3.546875
4
import SVMHelperMethods import pandas import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.svm import SVC # Import the wine quality train sample from the excel file trainingSample = pandas.DataFrame(pandas.read_excel("Wine_Training.xlsx", header = 0)) # Import the wine qu...
37adefa9ab509c75a1645e75c9303449a19f1a67
rachelcynthia/Machine-Learning-Projects
/2-Simple-Linear-Regression/Example1/LinearRegression1.py
826
3.921875
4
import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression dataset = pd.read_csv('mydata.csv') x=dataset.iloc[:,:-1] y=dataset.iloc[:,-1] x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=0) re...
a3ad6fb4d4e9c674e1f4fe09382fb16a1569d4f3
isk02206/python
/informatics/previous/ex_python_by.JunKim/Seungjun_PY/series_06/Baggage_carousel.py
2,926
3.6875
4
''' Created on 2015. 11. 20. @Group_number: 14 @author: Seungjun Kim @student_number: 01503749 ''' def carousel(blank, bag): # set blank list, 'carousel' where the components of bag will be added. carousel = [] # construct a carousel which is filled with None as the number of blank. for i in r...
bb95d4dab6c7d25630ebc53a49d55f7f7e6a8357
gabrielvtan/ByteAcademy-FullStack
/Phase1/Week1/Python/1.2-ControlFlow/5-currency/currency.py
1,458
3.875
4
#!/usr/bin/env python3 def currency_converter(amount): penny = 0.01 nickel = 0.05 dime = 0.10 quarter = 0.25 oneDollar = 1.00 fiveDollar = 5.00 tenDollar = 10.00 twentyDollar = 20.00 fiftyDollar = 50.00 hundredDollar = 100.00 hundred_need = float(amount//100) fifty_need...
60ef7f08f442d66f65f576955eaf5bcbb4bd34e1
jmsbrcwll/Project-Euler
/src/problem35.py
793
3.75
4
CACHED_PRIMES = set() EVEN_DIGITS = {'2', '4', '6', '8'} def run(): #eligable numbers cannot contain any even digits eligable_primes = [i for i in range(2, 1000000) if contains_no_even_digits(i) ] primes = [i for i in eligable_primes if is_circular(i)] print len(primes) def contains_no_even_digits(n): digits ...
ed453d175cd1587da6014657edd8ec87ab4b056f
Joua6/Final-Project
/finalTwoPseudocode.py
478
4.0625
4
''' Created on Mar 7, 2020 @author: ITAUser ''' #PSEUDOCODE: #import turtle #create function # set width and height #set speed #Set look # create variable x and c with zero value # write color for color control. #By writing it in a string the colors changes # multiplying it by a number tells...
01dd4b6570fe4fb41e35c1507070f18fb866d8fe
tanuja6/Project1
/main.py
337
3.859375
4
#!/bin/python3 import random chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*' length=int(input('Enter password length?')) num_pass=int(input('Enter numbers of passwords to be generated:')) for p in range(num_pass): password='' for t in range(length): password+=random.choice(chars) ...
4b9288f7f381468113271ee8ff4bda81345ea8f8
sahilkhose/sem5
/AP/lab1/2.py
114
3.8125
4
num = 1 for i in range(5): for j in range(i+1): print(num, end=" ") num+=1 print()
e556d0cc430f0c0c8997bd129f72704633750ba5
ieesejin/algorithm_study
/programmers/타겟넘버.py
1,089
3.625
4
# https://programmers.co.kr/learn/courses/30/lessons/43165 def solution(numbers, target): # BFS results = [0] for number in numbers: temp = [] for result in results: temp.append(result + number) temp.append(result - number) results = temp # Initialize the list b...
fa7e78f0050f55fcf99ef3d1b7e7f7c2972b7f6c
eazapata/python
/Ejercicios python/PE6/PE6E14(for).py
827
4.09375
4
#Desarrolla un programa junto con tu compañero, apoyándote en la #“metodología pair programming” que tenga las siguientes características: #Piensa en un problema que requiera para su resolución el uso de sentencias repetitivas. #Dicho problema resuélvelo con bucles for y while. #Justifica en el propio programa porque ...
1a06149d16641ac32bdc00ca425c1f7921d7d2fc
ifpb-cz-ads/pw1-2020-2-ac04-wanielton
/questao_01.py
173
3.78125
4
# Questao 01 (A): x = 1 while x <= 100: print(x) x = x + 1 print('------------------------') # Questao 01 (B): x = 50 while x <= 100: print(x) x = x + 1
cbed60a65f569aed0c5da7fe0fad3a99273e5024
harshonyou/SOFT1
/week7/week7_practical6a_2.py
864
4.59375
5
''' Exercise 2: Another very useful method to write is __str__. This will enable us to print the content of the instance using the print function. For the purpose of this exercise we have decided to represent the vector [ 𝑎 𝑏 𝑐 ] with the string '<a, b, c>' to differentiate it from a list. Implement __str__. def __...
d2948ca716c0b1180da167a47ee5620f6380882c
khoaphamj1505/CS112.L21.KHCL-1
/Project_Unit_Test/Add_test.py
1,273
3.5
4
#Importing library and Add function import unittest import random from Add import Add #Creating class unittest class TestAdd(unittest.TestCase): def test_1_manual(self): with open("Add1.in", 'w+') as f_in: # Creating new file input with open("Add1.out", 'w+') as f_out: # Creating ne...
f6bb335e7a922c253844a2d21b8a6413edc9be29
NamrathaNShetty/Basic-Python-Programs
/Data Structures/Dictionary/SortByValue.py
754
4.09375
4
''' * @Author: Namratha N Shetty * @Date: 2021-09-18 12:28 * @Last Modified by: Namratha N Shetty * @Last Modified time: 2021-09-18 12:52 * @Title: To sort (ascending and descending) a dictionary by value ''' from Loggers import logger def sort_by_value(): ''' Description: This function used to sort...
b3af89467f0f032060b9617ddb5466502bc642d7
robertopedroso/euler
/python/problem21.py
529
3.875
4
def sumdivisors(n): """Returns the sum of the proper divisors of n""" return sum([x for x in xrange(1, n) if n % x == 0]) if __name__ == "__main__": amicablenums = set() for n in xrange(1, 10000): if n in amicablenums: continue # no repeats x = sumdivisors(n) # we have to check ...
4147b199ccef512dfe9c7752b3b90d73b3e8ba0c
WGC575/python_learning
/tutorial/05_string.py
1,148
4.25
4
#single quatation is the same as double quatation x = 'Word ' y = "word" print(x) print(y) #str[a] #get specific character in the string with position print(x[1]) #'o' #str[a:b] #get substring with position (left included, right excluded) print(x[0:2]) #str.strip() #remove the spaces in the beginni...
0d004f7facb13c65d34ed5a3e52d83476c4c5b96
sandy1618/LiveCodeRelive
/Python_Coding_Practice/CodingInterviews/HackerRank/Warmup/plusMinus.py
1,064
3.734375
4
#! usr/bin/env python __author__ = 'Sandeep Kumar Nayak' __status__ = 'development' # def plusMinus(arr): # postive_count = 0 # negative_count = 0 # zero_count = 0 # for item in arr: # if item > 0: # postive_count+=1 # elif item < 0: # negative_count+=1 # ...
6c221541ac4acc7f133e6576ee0796b941874751
shinsung3/ASY
/Python/hw_test/hw_210524.py
1,850
3.515625
4
# 518 # a,b,c = input().split() # a = int(a) # b = int(b) # c = int(c) # sum = (a+b+c) # avg = (a+b+c)/3 # print("sum : %d" %(sum)) # print("avg : %d" %(avg)) # 525 # a,b,c = input().split() # answer = "" # if a>b and a>c: # answer += "1" # else : # answer += "0" # answer += " " # if a==b and b==c: # answ...
fb0aa3519d2c8f796321317cb9aa27853f822e26
Eric01752/CSCI308
/Classwork/chap6Problem1.py
147
3.65625
4
#Opens file and prints all lines open_Numbers = open("numbers.txt", "r") for line in open_Numbers: number = int(line) print(number)
b287debd6e5a32dbdc6987a28f93229ff98f285c
sureshyhap/Python-Crash-Course
/Chapter 8/3/t-shirt.py
141
3.703125
4
def make_shirt(size, text): print("This shirt is a size " + str(size) + ". It says, \"" + text + "\"") make_shirt(9, "I like Pokemon!")
1ab0644c48091c91a35bcf7e81534292cc8b26a7
RuidongZ/LeetCode
/code/38.py
1,174
4.03125
4
# -*- Encoding:UTF-8 -*- # 38. Count and Say # The count-and-say sequence is the sequence of integers with the first five terms as following: # # 1. 1 # 2. 11 # 3. 21 # 4. 1211 # 5. 111221 # 1 is read off as "one 1" or 11. # 11 is read off as "two 1s" or 21. # 21 is read off as "one 2, then one 1"...
e1bd322fd378d84a72de2199197dd17a30345345
devedzic/lennon
/music/band.py
12,078
3.90625
4
"""The class representing the concept of a music group/band. It includes a list of Musician objects (band members) and the date when the band started performing together. """ from datetime import date, datetime, time import json from music.musician import Musician, musician_json_to_py, musician_py_to_json from settin...
7194a4ed71b3f032ebebe9d4c2a8fee93b604062
Brandon300055/CS-2420
/11-13.py
1,041
3.65625
4
def delete(self, item): if not self.exists(item): return False self.DeleteR(item, self.mroot) return True def delete(self, item): if item < current.mItem: self.DeleteR(iTem,current.l) elif item > current.mItem: self.deleteR(iTem, current.r) else: #delete item in current ...
a3f0083de5087c3ee7a4b2193af43af0e790c29c
gabriellaec/desoft-analise-exercicios
/backup/user_119/ch25_2019_03_14_19_04_44_541692.py
100
3.8125
4
km=int(input("Quantos km? ") if km<=200: return km*0.5 else: return 100+(km-200)*0.45
a55903f87cac22a06fb6b0ddd8cfe0f8f4a69df4
mikemadden42/pyutils
/read_csv.py
824
3.671875
4
#!/usr/bin/env python3 import csv from rich import print def read_csv(filename): MIN_LENGTH = 12 with open(filename, mode="r") as csv_file: csv_reader = csv.DictReader(csv_file) line_count = 0 for row in csv_reader: if line_count == 0: print(f'Column names...
25e883effe3ba3a5d09dd5582bb5ae96896564da
uppaltushar/basicpython
/basic python/concatnate.py
88
3.984375
4
str=input("enter") if 'yes' in str: print(str+"no") else: print(str+"yes")
10eade7d1a6a4efa0c2c1f5bc943a96873589088
zdyLaNz/Actividaddemetodos
/SerieTaylor.py
612
4.125
4
'''Importamos libreria math''' import math a = float(input("\n\tIngrese el dato que desea resolver en grados: ")) '''Metodo para transformar el dato ingresado en grados a radianes''' b = math.radians(a) print("") n= int(input("\tDato con el que truncara a la serie: ")) senx= 0.0 print("{:^2} {:^10}{:^16}".format("...
b0c211b5ac07e2720f9623c4a024fc07de46cb38
jdasinger/real_python
/factors.py
234
4.125
4
number = input("Enter a positive integer: ") def factors(number): number = int(number) for i in range(1,number+1): if number % i == 0: print("{0} is a divisor of {1}".format(i, number)) factors(number)
ab6615c054dcc3539ad6cf87f11ec770196f1d51
ellldar/python_course
/lessons/lesson6_lists.py
4,000
3.90625
4
# arr = list(range(0, 10)) # res = [num * 2 for num in arr if num <= 5] # arr2 = list(range(15, 20)) # res.extend(arr2) # print(arr) # print(res) # if any(num > 15 for num in res): # print("Success!") # # if all(num >= 0 for num in res): # print("All is true!") # Task 1 # friends = ['Данчик', 'Макс', 'Чина', ...
ca704cb8363ebe1b3163ac2c3ce6923922f83076
Rajadip/Converter
/timeConversion.py
299
3.78125
4
def toSec(hours): hours = hours.split(':') if len(hours) == 3: return (float(hours[0]) * 60 * 60) + (float(hours[1]) * 60) + float(hours[2]) elif len(hours) == 2: return (float(hours[0]) * 60) + (float(hours[1])) elif len(hours) == 1: return float(hours[0])
6d1381fc21ad9a619b510077250235eeb289fb99
jlw123199/PythonHub
/PythonRD/reqhtml_app.py
832
3.5625
4
# -*- coding: utf-8 -*- # This module demonstrate how to use requests_html import requests import re from requests_html import HTMLSession from bs4 import BeautifulSoup session = HTMLSession() def getHTML(url): try: spliterLine = "--" * 30 response = session.get(url) soup = BeautifulSo...
fb093a066db505d7e838c9ed87401804c3df2905
kalvii/basic
/basic.py
40
3.546875
4
num=5 num2=7 sum=num+num2 print(sum)
c033f1dd7cfba075a20c9d78e991e3a7fdc0c6c7
februaryfebryan/tolinh1-fundamental-c4e25
/session 3/while intro.py
290
3.953125
4
#loop co 2 kieu: for va while #for cho dong lap co dinh, while la cho khong co dinh #while co the thay the cho for, nhung k dc nguoc lai loop_count = 0 loop = True while loop_count < 3: print("Hi") loop_count += 1 print(loop_count) if loop_count >= 3: loop = False0
6323f8bc912acdc8ad77864090a08e3eee66e481
jeffdeng1314/New-Relic-Assignment
/solution.py
3,290
4.28125
4
# 100 most common three-word sequences import os import sys import string import re # referrence https://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string REGEX = re.compile('[%s]' % re.escape(string.punctuation)) # accept input as files or line-by-line from pipe def main(): # proc...
4fd8792e1fbebf7a3a2e1ab2dfcd858a4f3d549c
lidongdongbuaa/leetcode2.0
/堆/378. Kth Smallest Element in a Sorted Matrix.py
2,360
3.953125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/4/25 9:25 # @Author : LI Dongdong # @FileName: 378. Kth Smallest Element in a Sorted Matrix.py '''''' ''' 题目概述:求一个已行排序矩阵中的第k小的数 题目考点:max heap 解决方案: 方法及方法分析: time complexity order: O(n^2 * log(k)) space complexity order: O(k) 如何考 ''' ''' input: matrix, size r...
6eb8c7be77e84e85e9f8036e16dc8db2e7ff3e4c
Divya192/divyathoughts
/write file.py
188
3.65625
4
with open('geek','r') as reader: content=reader.readline() reversed(content) with open('geek','w') as writer: for line in reversed(content): writer.write(line)
269885f083551e7a8ad78e8fbf2912ffa96cc19c
DMCFA/Snake-Game
/snake.py
1,371
3.75
4
from turtle import Turtle STARTING_POSITION = [(0, 0), (-20, 0), (-40, 0)] MOVE = 20 UP = 90 DOWN = 270 RIGHT = 0 LEFT = 180 class Snake: def __init__(self): self.segments = [] self.create_snake() self.head = self.segments[0] def create_snake(self): for pos...
e071c63a90c68d53eeb8d28f7ac79e09edfb9864
hwan1753/Samsung-SW
/D3/Odd or Even.py
184
3.65625
4
T = int(input()) for test_case in range(1,1+T): N = int(input()) if N % 2 == 1: print("#{} Odd".format(test_case)) else: print("#{} Even".format(test_case))
92b0a09c0adc528b1502a4a9fbce5a029641efb4
PasinduUkwatta/Python-Dash
/pandas_practise.py
473
3.9375
4
import pandas as pd df = pd.read_csv('salaries.csv') print(df) #when we get more than one column we need to define them in list , separatly print(df[['Name','Salary']]) print(df['Salary'].min()) print(df['Salary'].mean()) age_critira =df['Age']>30 print(age_critira) #this will produce the results...
e0ae0555bb0596a54e64163181c8534a17300f28
santiago-m/IA2019
/libs/problems.py
7,316
3.515625
4
import sys import os import subprocess sys.path.append('../aima-python') from search import * from arithmetic import * import math ''' NQueens Problem ''' class NQueens(Problem): """The problem of placing N queens on an NxN board with none attacking each other. A state is represented as an N-element array, whe...
972b6b194f4cb59c251bd3ec33744430d5489190
saraducks/Python_interview_prep
/Leetcode/Dynamic_programming/FInd_nth_prime.py
963
4.28125
4
# Ugly numbers are numbers whose only prime factors are 2, 3 or 5. # The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, # shows the first 11 ugly numbers. By convention, 1 is included def find_nth_prime(input_number): result_array = [1] num = 2 # check for the 2, 3, 5 recurrsively, if the result is 1 then i...
67724cdc3d44a882f2433b894cd8bb2d52a5b808
taylor-jones/Cracking-The-Coding-Interview
/1_arrays_and_strings/src/urlify/urlify.py
409
4.25
4
""" Question: 1.3 Name: URLify Description: Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end of the string to hold the additional characters, and that you are given the 'true' length of the string. """ def urlify(s): return s.replace...
f51b1362ed0783050ede8602cd21232c7417b632
Tella-Ramya-Shree/PythonAssignment4
/321810304048:Prime number or not.py
186
4.1875
4
#Prime number or not num = int(input("enter a number: ")) for i in range(2, num): if (num % i == 0): print(num," is a not prime number") break else: print(num,"is a prime number")
314ce9cda8fac61db13cce716dd257c93e4e6b99
Brunochavesg/Guanabara
/ex004.py
355
3.84375
4
a = input("Digita algo! ") print("O tipo primitido desse valor é", type(a)) print("Só tem espaços?", a.isspace()) print(" è um numero?", a.isnumeric()) print("É alfabetico?", a.isalpha()) print("É Alpa numerico", a.isalnum()) print("Esta em Maiuscila?", a.isupper()) print('Esta em minuscula?', a.islower()) print('Esta ...
5cc0e1975276e3a33281ec8817b9c5f8719bea0a
Indra2007/Codehub
/com/module/basics/Program21Assignement5_bad.py
1,097
4.125
4
#Creating empty list numList = [] #Creating variable that will control number of countries we can enter count = 0 biggest_num, smallest_num = 0,0 #Creating the while loop while count < 5: next = int(input("Please enter a number you've been to > " )) if next > 0 or next <= 0: #next = int(inp) ...
87fe98ca90fbce0b74b3da0b6b0d036ad2aea0db
venki-s/python
/Functions/practice4.py
459
3.890625
4
# OLD MACDONALD: Write a function that capitalizes the first and fourth letters of a name def old_mcdonald(str): if len(str) > 3: return str[0].upper() + str[1:3] + str[3].upper() + str[4:] elif len(str)>0 and len(str)< 4: return str[0].upper() + str[1:] else: return str prin...
b62f0175916e125646d41934b718e34b905fe4d7
djxf/TensorFlowLearn
/dimchange.py
1,168
4.15625
4
###维度变换 import tensorflow as tf print("Hello tensorflow") #View:视图的概念 #[b, 28, 28] #[b, 28*28] #----> [b, 2, 14*28] #----> [b, 28, 28, 1] ### tf.random.normal()函数 ### ###Args: # shape: A 1-D integer Tensor or Python array. The shape of the output tensor. # mean: A Tensor or Python value of type `dtype`, bro...
b6dfcc69233a1b697621ac55af5cf2db2a5a7577
Voljega/BestArcade
/logger.py
814
3.5625
4
import queue class Logger: ERROR = 'ERROR' WARNING = 'WARNING' INFO = 'INFO' SUCCESS = 'SUCCESS' UNKNOWN = 'UNKNOWN' def __init__(self): self.log_queue = queue.Queue() # Print dictionary to logger def printDict(self, dictList, level=INFO): for key in dictList: ...
d69c6b3f1495ad658febaa020c6d2ca4ea1087c0
JaishaAsad/spyderpractice
/Q4.py
697
4.25
4
print (" DAYS BETWEEN TWO DAYS ") a1 = int (input("PLEASE PROVIDE THE SMALLEST YEAR:/n ")) b1 = int (input ("PLEASE PROVIDE THE SMALLEST MONTH:/n ")) c1 = int (input ("PLEASE PROVIDE THE SMALLEST DAY:/n ")) date1 = (a1,b1,c1) a2 = int (input ("PLEASE PROVIDE THE LARGEST YEAR:/n ")) b2 = int (input ("PLEASE ...
9b752a278bd4b77598e6d7fb0d853e554d4fad41
RguezElias/curso_python
/tipos_datos.py
263
3.5
4
# string nombre = 'Juan' # int edad = 29 # float altura = 1.70 # list hobbies = ['comer','dormir'] #boolean frio = False # diccionario punto = {'a':'b','hobbies':hobbies,'peso':20} print type(punto) print type(frio) print type(hobbies)
33f0ddd0b0de1d01c7db6198adb356a97a1d996b
meera21-meet/meet2019y1lab4
/funturtle.py
987
3.796875
4
import turtle '''turtle.shape('square') finn=turtle.clone() finn.shape('square') finn.forward (100) finn.right(90) finn.forward(100) finn.right(90) finn.forward(100) finn.right(90) finn.forward(100) sam.shape('triangle') sam.left(45) sam.stamp() sam.forward(100) sam.stamp() sam.clearstamps() sam.right(130) sam.forward...
8f2e25778acbb826cb2297113c6c0b8925c309ff
abhishek2507/100daysofcode
/Day2/3.count_total_subset_equal_to_given_sum.py
1,223
3.859375
4
'''' Count total number of Subset equal to a given sum Problem (Dynamic Programming solution) This was just a handson practice for vraitaion in 0-1 Knapsack Given array nums[] =[2,3,5,6,8,10] and sum = 10 Output => 3 Explaination: [2,3,5],[2,8] and [10] are the 3 subset ''' class Solution: def countSubsetEqual(sel...
994df4ccd70d4197e99db1e11b5e26cb71156e68
CrashNosok/flask
/6_db2/csv_functions.py
2,184
3.53125
4
import csv ''' # открытие - закрытие файла f = open('filename.txt', 'r') m = f.read() f.close() # менеджер контекста with with open('filename.txt', 'r') as f: m = f.read() ''' def write_rows_to_csv(file, rows): # запись в csv файл with open(file, 'w', encoding='utf-8', newline='') as f: writer = ...
49f06492f28f6fd4fd8b9454ae2e6e7a3a4a1d7b
Aayush-Ankit/puma-simulator
/src/data_convert.py
4,334
3.703125
4
# APIs to convert data from: # 1. float to fixed point binary (2s complement) [float to bit-string] # 2. fixed point binary (2s complement) to float [bit-string to float] # 3. integer to binary (2s complement) [int to bit-string] # 4. binary (2s complement) to inetger [bit-string to int] import numpy as np def bin2int...
e335a77a7676148ad68c0e8dc20fe7f776cb933e
ManasHarbola/EPI_solutions
/Chapter8/8-2.py
481
3.75
4
def evaluate(expression): stack = [] result = 0 operations = {'+' : lambda a, b: b + a, '-' : lambda a, b: b - a, '*' : lambda a, b: b * a, '/' : lambda a, b: int(b / a)} delimiter = ',' for token in expression.split(delimiter): if token ...
59af1bc669457b0af99f30766c2644de1a69aead
raumild-ept/python_exercise_2
/program 13.py
30,140
4.125
4
from datetime import date class product: # product class:- contains product_info, product_creation methods. def __init__(self): self.product_dict = {'PRD1': {'product_name': 'pen', 'unit_price': '100', 'cost_price': '2', 'stock_type': 'Stockable', 'stock_amount': '1000'}, 'PRD2': {'product_name': 'book', '...
4bde1d307f0e2c00f6cc87b6c464a3b84edf604f
codejay411/python_practical
/python jhansi2.7/p18.py
144
4.125
4
print "reverse order of string line by line" name=raw_input("enter the string:") line=len(name) for i in range(-1,-line-1,-1): print name[i],
f2cd9527c7aa7e89907e5d29efbb624bc045c4cd
sudo-apt-install/hello-world
/coffee.py
2,921
3.875
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, ...
cf537f448e497025d676fa2c22e6274b3069bce2
Reactionz/calculator-project
/calc/calculator-python/calc.py
8,379
3.984375
4
import tkinter from math import * ## first thing that should always be done when working with Tkinter root = tkinter.Tk() root.title("Calculator") #global variable setup fNum = None math = None e = tkinter.Entry(root, width=40, borderwidth=6) e.grid(row=0, column=0, columnspan=6, padx = 25, pady = 15) ...