blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
ecdf1624163912b3901c912e17528ebed0301a8b
lanhybrid/Python_Basics
/CursoEmVideo/064_sumStop.py
507
4.03125
4
num = 0 sum = 0 cont = 0 flag = 'S' maior = 0 menor = 0 while flag in 'Ss': num = int(input('Digite um número para somar: ')) if cont == 0: maior = num menor = num elif num > maior: maior = num elif num < menor: menor = num sum += num cont += 1 flag = input('...
e5c0f355f6a14af884363c0d2b057a87b3a21183
andywu1998/A-Byte-of-Python
/str_format.py
614
4.21875
4
#print("hello world")#注意到print是一个函数 age=20 name='Swaroop' country='America' print('{0} was {1} years old when he wrote this book in {2}'.format(name,age,country)) print('why is {0} playing with that python?'.format(name)) #对于浮点数'0.333'保留小数点(.)后三位 print('{0:.3f}'.format(1.0/3)) #使用下标填充文本,并保持文字处于中间位置 #使用(^)定义'__hello_...
4a14ce8576ec62731716d6251d06bb32d8b59d02
lareniar/Curso2018-2019DAW
/1er Trimestre/Ejercicios/estrellasNumeros.py
161
4.09375
4
x = int(input("Inserta un número")) while 0 < x: cont = x while 0 < cont: print("x", end="") cont = cont - 1 x = x - 1 print("")
e350b244a3f299380dbd774866bd3540e2ae05b1
wardmike/Rapid-Problem-Solving
/Codeforces/602B/codeforces602b.py
1,714
4
4
number = int(raw_input()) line = map(int, raw_input().split()) def find_largest_range(size, numbers): longestRange = 0 #longest range so far beginRange1 = 0 #begin of current number - 1 beginRange2 = 0 #begin of current number - 2 for x in range(1, size): if numbers[x] > numbers[x - 1]...
55fdf04aafbbd871f1afecf1f4dd55931faa66a0
bkmgit/megamol
/plugins/pbs/utils/knapsack.py
2,478
3.8125
4
# SOURCES: # https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize # https://codereview.stackexchange.com/questions/20569/dynamic-programming-solution-to-knapsack-problem import collections import functools class memoized(object): '''Decorator. Caches a function's return value each time it is called....
991292bceb0efe007dfea8eda48afa8a9e7edbf4
shiran1992s/HW2_AI
/intro_to_AI_hw2_2020-provided-code/SearchAlgos.py
6,233
3.515625
4
""" Search Algos: MiniMax, AlphaBeta """ from utils import ALPHA_VALUE_INIT, BETA_VALUE_INIT # TODO: you can import more modules, if needed import numpy as np import copy from players import MinimaxPlayer from players import AlphabetaPlayer class SearchAlgos: def __init__(self, utility, succ, perform_move, goal):...
075531c2c448b0af31ef066ad1146266be850bc1
Portia-Lin/caesar-code
/RSA/rsa_decrypt.py
909
3.71875
4
import binascii def modinv(a, m): for x in range(1, m): if (a * x) % m == 1: return x return None def decrypt_block(c): m = modinv(c**d, n) if m == None: print("Немає оберненого за модулем числа для: " + str(c) + ".") return m def decrypt_string(s): return ''.join([chr(dec...
55b77471f4e65d2baef128f5d4041c079ebaff0b
BashvitzBen/Final-Project-Ben-Bashvitz
/class_model.py
6,423
4.09375
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 16 10:13:33 2021 @author: bashv """ from tensorflow.keras.models import Sequential, load_model from tensorflow.keras.layers import Dense, Conv2D, Activation, Flatten, MaxPooling2D class model(): #this class handles all functions that relate to creating,...
4b0f80d03f934d585dcd64923371744211730874
iakonk/MyHomeRepos
/python/examples/leetcode/easy/reverse-words-in-a-string-iii.py
785
3.734375
4
# Runtime: 48 ms, faster than 31.54% of Python online submissions for Reverse Words in a String III. # Memory Usage: 13.9 MB, less than 9.09% of Python online submissions for Reverse Words in a String III. class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str ...
3dd355d63fed3cb8e5fec5de075958e299d17947
kanoaellis/Kattis
/jackpot.py
714
3.546875
4
def GCD(g, s): if (s == 0): return g return GCD(s, g % s) def LCM(x, y): return (x * y) // GCD(x, y) i = 0 a = int(input()) while(i < a): b = int(input()) z = [int(w) for w in input().split()] if(b == 1): t = z[0] elif(b == 2): t = LCM(z[0], z[1]) elif(b == 3): ...
04b6e4ec53dee91ba5ccf370fffbd8fe03f1bd0b
harut0111/ACA
/Homework/homework_03/task2.py
283
3.515625
4
def get_frequency(li): l = len(li) res = [] for x in list(set(li)): k = 0 for y in li: if x == y: k += 1 res.append({x: k/l}) return res print(get_frequency([1,1,2,2,3])) print(get_frequency([4,4])) print(get_frequency([1,2,3]))
2b992ca8bbd413bb71769515caa5f8de7cbc0ffe
snowcloak/PYTHON
/shortestDistance.py
790
3.859375
4
data = [(1, 1), (-1, -1), (3, 4), (6, 1), (-1, -6), (-4, -3)] #simple distance formula def euclideanDistance(point1, point2): return ((point1[0]-point2[0])**2 + (point1[1]-point2[1])**2) ** 0.5 #shortest distance algorithm #double loops, use range with len #conditional check for minDistance #update the new minDis...
6cacc94b4629a8168a251016a2a7eefb269c7304
hedgehoCrow/Python_study
/language_processing/00/09.py
694
3.765625
4
#!/usr/bin/env python3 # coding: UTF-8 import random def typoglycmia(target): result = [] shuffle_list = target[1:-1] random.shuffle(shuffle_list) result.append(target[0]) result.extend(shuffle_list) result.append(target[-1]) return result def main(): sentence = "I couldn't belie...
bfc3d14edfa7cf18aeb6e704d0a51f6c7f2fcca7
mymindhungry/python_works
/intro.py
7,328
4.3125
4
# # # print('Hello Python') # # # # x = 10 # # print('the number',format(x)) # # # ---------------------------------------- # # name = 'admin' # # age = 20 # # # # # print ('your name is : ' + (name)) # # print('your age is', format(age)) # # # # print(type(age)) # # print(type(name)) # # # ----------------------------...
ea84c2259c54caa7b67fb8eb1824141497c04b3f
Opsy1169/locationbot
/prime.py
351
3.65625
4
import math import random def inventing(comp): comp = int(comp) que = random.randint(3, 10 ** (comp + 1)) if (que % 2 == 0): que += 1; return que def isprime(que): limit = int(math.sqrt((que))) i = 3 while (i <= limit): if (que % i == 0): return 'False' ...
a293d6cc7ba26430676024acdc6794e82ce3463b
MichaelArslangul/python_Sandbox
/DP/CuttingRods.py
1,316
3.75
4
class CuttingRods: """ Given a rod of length N and prices p[0], ..., p[N], where p[i] is the price of a length i of the rod. Find the max revenue we can get from the rod by cutting and selling it """ def highest_revenue_recursive(self, rod_length, prices): _max_revenue = float("-inf") ...
e7ceaf1411b28676e55afc5acfb4b4312f405ead
santosclaudinei/Entra21_Claudinei
/exercicioa05e06.py
311
4.09375
4
# Exercicio 6 # Escreva um programa que peça 2 números e mostre eles em ordem crescente num1 = int(input('Digite um numero: ')) num2 = int(input('Digite outro numero: ')) if num1 > num2: menor = num2 if num2 > num1: menor = num1 print('O menor numero entre {} e {} é {}' .format(num1, num2, menor))
acef33b2785335b4ba52169cc0b4fd0767bbf0b4
mantues/Medical-temp-check-sheet
/temp-check-sheet-en.py
3,485
4.125
4
# web ↓ # https://office54.net/python/tkinter/textbox-get-insert import tkinter as tk from tkinter import * import csv import os # Processing when a button is pressed. def memo_temp(): #Read IDs from taion.csv index=int(textID.get())#ID value judgment if(index<1 or 1001<index): s="Make sure ID is ...
9770ae221755016022ae8888406f6604ca6f13b2
CurryMentos/algorithm
/exercise/数学题/2.1.py
537
3.53125
4
# !/usr/bin/env python # -*-coding:utf-8 -*- """ # File : 2.1.py # Time :2021/7/16 10:22 # Author :zyz # version :python 3.7 """ """ 如果一个 3 位数等于其各位数字的立方和,则称这个数为水仙花数。 例如:153 = 1^3 + 5^3 + 3^3,因此 153 就是一个水仙花数 那么问题来了,求1000以内的水仙花数(3位数) """ for i in range(100, 1000): a = i % 10 b = int(i / 100) ...
72a78852a61f104f2d112cc620f29ad252073103
git-mih/Learning
/python/01_functional/06modules_packages_namespaces/01modules/exemple1/module1.py
2,039
3.796875
4
print(f'--------------- Running: {__name__} ---------------') def func(file_name, namespace): print(f'\n\t---------- {file_name} ----------') for k, v in namespace.items(): print(f'{k}: {v}') print(f'\t-------------------------------------\n') func('module1 namespace', globals()) print(f'--------...
fa2c80eba7483d452261d1864a936f13c9c39c7e
stOracle/Migrate
/Programming/CS313E/Turtle/Train.py
2,004
3.75
4
# File: Train.py # Description: A turtle graphics attempt of drawing a choo-choo train # Student Name: Stephen Rauner # Student UT EID: STR428 # Course Name: CS 313E # Unique Number: 50945 # Date Created: 2/28/16 # Date Last Modified: 2/29/16 import turtle import math def drawLine (ttl, x1, y1, x2, y2...
8c8cd78dcc454d5d08fc7b3abb0863987b4f56fd
Jackthebighead/recruiment-2022
/algo_probs/jzoffer/jz32_3.py
1,555
3.90625
4
# 题意:从上到下打印二叉树3: 奇数层从左到右,偶数层从右到左 # 题解1: 辅助双端队列 # 题解2: 对奇偶不同处理,若该层的res_temp的len为奇数则正序加入res,若为偶数则倒序加入res。 # 题解3: 对单数双数层不同处理,这个最笨。if 即可。 # res.append(tmp[::-1] if len(res) % 2 else tmp) # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # ...
f1c915e9774887422bb2c7405d0e99e8320c5d85
uzusun/tf
/python/set_op.py
260
3.921875
4
data1 = set(["cola","water","sprite"]) data2 = set(["coffee","milk"]) print(data1 & data2) print(data1.intersection(data2)) print(data1 | data2) print(data1.union(data2)) print(data1 - data2) print(data1.difference(data2)) """ print(data1) print(data2) """
cdd90bd93b18c55d46cd974c31eb9a1a56862b5e
AmbientOne/FlaskBarCodeScanner
/BarcodeScanner/digitGenerator.py
261
3.8125
4
import random def randomDigitGenerator(name, price): barcode = name[0:2].upper() for i in range(15): barcode += str(random.randrange(1, 10)) return barcode print(randomDigitGenerator(input("Enter a name: "), input("Enter a price: ")))
a6deb79c757e25b3f43adc6ec30323286ec33fee
omitogunjesufemi/gits
/PythonBootcamp/day2/Assignment Two/Question1.py
201
4.25
4
# Coverting Celsius to Fahrenheit celsius = int(input("Enter the temperature degree in celsius: ")) fahrenheit = (9/5) * celsius + 32 print(str(celsius), "Celsius is " +str(fahrenheit), "Fahrenheit" )
b8575f4f45140cac291a60f7b82f0f2168330361
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/134_7.py
2,835
4.375
4
Python | Type conversion of dictionary items The interconversion of data types is quite common, and we may have this problem while working with dictionaries as well. We might have a key and corresponding list with numeric alphabets, and we with to transform the whole dictionary to integers rather than string ...
9d334671995beeb247af5ff2b5c3c983413d9e9d
wfeng1991/learnpy
/py/leetcode/114.py
1,541
3.921875
4
# 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 flatten1(self, root): """ :type root: TreeNode :rtype: void Do not return anything, modify root in-plac...
2e98629efd3cc149d75f23b02cc6af8b4b0954e1
abs-tudelft/vhsnunzip
/tests/emu/utils.py
2,924
3.9375
4
def safe_chr(data, oneline=False): """Returns a byte or iterable of bytes as ASCII, using ANSI color codes to represent non-printables. If oneline is set, \n is treated as a special character, otherwise it is passed through unchanged. The following color codes are used: - green 'n': newline ...
8e37b06a20173b889da316e61ecf3990bc220877
prachijain07/Prachi-programs
/src/Exercise_32.py
661
3.5
4
#PF-Exer-32 def human_pyramid(no_of_people): if(no_of_people==1): return 1*(50) else: return no_of_people*(50)+human_pyramid(no_of_people-2) def find_maximum_people(max_weight): no_of_people=0 m=max_weight//50 sum1=0 for i in range(1,m+1,2): s...
94a41636496c8e16d5b401aa41d229e3aba1190f
dipikakhullar/Data-Structures-Algorithms
/trie.py
4,725
4.03125
4
from collections import deque class TrieNode: def __init__(self, v): self.val = v self.children = {} self.is_end = False class Trie: """ 1. insert 2. contains word 3. return all words with prefix 4. num entries with that prefix? 5. delete word 6. return all words in trie """ def __init__(self): se...
9d7696b6673420e9c88e271593f0cc41a8e7935f
rraj29/Sequences
/spliting_things.py
920
3.9375
4
panagram = "The quick brown fox jumps over the lazy dog" words = panagram.split() print(words) numbers = "4,566,4523,8895,445,5656,55,4226,45" print(numbers.split(",")) # **JOIN will create a STRING from a list. SPLIT will create a LIST from a string. #values = "".join(char if char not in separators else " " for ...
894ac296306c253b9c32ac11d49fbde2d97d1ae8
Rishiraj122/Python_programs
/ForLoop.py
179
4.15625
4
fruits=["Apple","Pineapple","Mango","Grapes","Oranges"] for x in fruits: print(x); if x=="Apple": print("Well, there's Apple, so there must be Applepie :) ");
28e3113c08178de77a32b8427346880f8479536e
huginngri/TitleTraveler
/V2.py
1,563
3.921875
4
def possiblem(x , y): attir = "(S)outh (N)orth (W)est (E)ast" s, n, w, e = attir.split() if y == 1: return n + "." elif x == 1: if y == 2: return n + " or " + e + " or " + s + "." if y == 3: return e + " or " + s + "." elif x == 2: if y == 2: ...
6c655044a49f27e0d4d8766df68cd6bf2da18cf6
Tri-x/exercise
/5/chars_count.py
620
3.578125
4
from string import *#引入字符模块 from random import * #统计字符数 str_dict={} strings='' for x in range(randint(0,200)):#随机字符随机长度 strings+=printable[randint(0,len(printable)-6)] #string.printable='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' print(strings) for ...
08744af1aae261def618dd478a0fdd54224fe32a
JeferyLee/smpAlgorithms
/K_calibre.py
510
3.5
4
""" -*- coding:utf-8 -*- @author : jerry @time : 2019/10/28 9:24 """ import pandas as pd import numpy as np data=pd.read_excel("c:/users/dell/desktop/test.xlsx") print(data) # data=pd.DataFrame(data=ws2,index=[[1,2],[1,2,3,4]],columns=[[1,2],[1,2,3,4]]) # data=pd.DataFrame(data=ws2,index=['2','3',...
0b455d583dbfd9a3935dd860d8bce940105bb562
SteveImmanuel/multimedia-stegano
/crypto/engine/key.py
435
3.546875
4
from enum import Enum from typing import List, Union class KeyType(Enum): NUMBER = 'number' STRING = 'string' class Key: def __init__(self, key_type: KeyType, data: List[Union[str, int]]): self.key_type = key_type if key_type == KeyType.NUMBER: self.data = list(map(int, data...
b2cf3d07c9a77b8a5b25fe2673ca30c0c49ff291
atkins126/sample_nullpobug
/python/csv1/reader.py
382
3.65625
4
# coding: utf-8 import csv def main(): with open('data.csv') as csvfile: reader = csv.reader(csvfile) # readerのシーケンスはリストを返す for row in reader: for idx, value in enumerate(row): print u"{}: {}".format(idx + 1, value.decode('cp932')) print "-" * 10 if...
375a0f3634cc9b9bcea50ce0c5dc05cfbd088770
JerryTom121/COREL
/code/Models/pi_pj_model_with_no_th_cat.py
1,670
3.6875
4
import csv import sys from itertools import product import operator from sets import Set readfile=csv.reader(open('./../dataset/preprocess_data_new.csv','rt')) true_count=0 #no of time successfuly predicted total_count=0 #total number of prediction made n=int(input("Enter N: ")) def frequency(products,item): #this wi...
1ad2a2beb0d679cc6963254194e98737c7097cb5
samuVG/Tarea1_Samuel_Vasco_Gonz-lez
/Tarea1.py
975
4.0625
4
#!/usr/bin/env python # coding: utf-8 # In[3]: import funciones #se invocan las funciones creadas en el módulo funciones #Ejercicio 4: se lanza una moneda n veces # a). la probabilidad de que si se hace este experimento 100 veces, el resultado sean 10 veces cara. def Probabilidad(n,k): #funcion que calcula la pro...
9dfea52358d6c3d7511f9d05b6afccd2d2d906f3
Rproc/sim_agent
/monteCarlo.py
1,380
4.3125
4
import numpy as np import math import random e = math.e pi = math.pi def get_rand_number(min_value, max_value): """ This functions gets a random number from a uniform distribution between the two input values [min_value, max_value] inclusively Args: - min_value (float) - max_value (float) Re...
dd17d8251a661225c4ab68ac6c61b3eb3a818be4
vapawar/vpz_pycodes
/vpz/vpz_linklist.py
1,020
3.890625
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def add(self, data): temp = Node(data) temp.next = self.head self.head = temp def remove(self, key): temp = self.head ...
9c59ff7d03ba56c52523a22530c4559e0aa6a53c
Tahmid79/ud120-projects
/outliers/outlier_cleaner.py
885
3.796875
4
#!/usr/bin/python import math def outlierCleaner(predictions, ages, net_worths): """ Clean away the 10% of points that have the largest residual errors (difference between the prediction and the actual net worth). Return a list of tuples named cleaned_data where each tuple...
4107bd220d010a882f92807299c1b07e529c358d
Flibielt/mlbasics-ex6
/ex6/src/ex6_spam.py
5,776
3.515625
4
from scipy.io import loadmat import numpy as np import os from .utils import process_email, email_features, svm_train, linear_kernel, svm_predict, get_vocab_list def ex6_spam(): """ Exercise 6 | Spam Classification with SVMs Instructions ------------ This file contains code that helps you get s...
5236f90479fe988fda5f8692db1b01c77f17aa51
4597veronica/Projectos_python
/calculadora/Ejercicio_17-3/menu_calc_if.py
405
3.984375
4
#coding:utf-8 # Haremos un menu de una calculadora print "¿Que desea hacer amo?" print "S.-salir" print "1.-Sumar" print "2.-Restar" print "3.-Multiplicar" print "4.-Dividir" obcion=raw_input ("Introduce una obcion: ") #if not obcion>=1 and obcion<=4: if obcion == "s" : print "Introduce una S mayusc...
437b1f52ee4f0293f9d03aab34330b80b619b7c4
orloffanya/python
/advanced_loops_80.py
1,066
4.375
4
# The prime factorization of an integer, n, can be determined using the following steps: # Initialize factor to 2 # While factor is less than or equal to n do # If n is evenly divisible by factor then # Conclude that factor is a factor of n # Divide n by factor using floor division # Else # Increase factor by 1 # Write...
a164fc90702c0192a9aa71cad6e65b0a8e198de2
CrookedY/AirPollutionBot
/buildreplytweet.py
350
3.625
4
from replybot import listofstationsdata if pollutant == 'NOX': #if function on data to sort which high or low function append high of low to list for pollutionlevel function to sort though Then add the pollutant name and a space to a string. Start of string should be 'The pollution level in (location) is high or l...
a331a6b6820a72375f6d8b355c1a4344b1d761a1
Ohforcute/learn-arcade-work
/Lab 12 - Final Lab/part_12.py
61,898
3.75
4
import arcade import os SPRITE_SCALING = 0.1 SPRITE_NATIVE_SIZE = 128 SPRITE_SIZE = int(SPRITE_NATIVE_SIZE * SPRITE_SCALING) SCREEN_WIDTH = 600 SCREEN_HEIGHT = 400 SCREEN_TITLE = "Atari Adventure Knockoff Edition" MOVEMENT_SPEED = 5 class Room: """ This class holds all the information about the differe...
caa4abed4158bc9c4ed4289e1564db76a676dfd7
Jimboni-tech/python-exercise
/first_python/first.py
508
4.15625
4
def main(): while True: try: num = input('what is your favorite number? ') square = int(num)**2 print('The square of', num, 'is', square) break except: print('Please enter a valid number') if __name__ == "__main__": main() ''' I learned how to use a while True loo...
246d8c45ead653cd3df51643eadedee7b2fd9f2f
sydul-fahim-pantha/python-practice
/tutorials-point/list.py
1,522
4.46875
4
#!/usr/bin/python3 num_list = list(range(5)) str_list = ["a", "b", "c"] print() print("str_list: ", str_list ) hetero_list = ["a", 10, list(range(5))] print() print("hetero_list: ", hetero_list ) print() print("num_list: ", num_list ) print("accessing value") print("list[2]: ", num_list[2]) print("delete item 3...
cc8c22f3b950db022a53d844f185381978fe2eab
ahephner/pythonUdemy
/Python basics/list_methods.py
946
4.21875
4
#list methods add #append #cant add more than 1 item scores = [3,4,12,4] scores.append(3) scores.append('string') #extend can pass in a list that adds to the end of that list #if you did .append([]) you would nest a list in a list scores.extend([2, 3]) print(scores) #insert #first pass where you want the item pla...
7a2726d05fe906643f70842453af94bdfa01f77c
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/blmjac004/question1.py
956
3.8125
4
message="no message yet" while True: print("Welcome to UCT BBS\nMENU") print("(E)nter a message\n(V)iew message\n(L)ist files\n(D)isplay file\ne(X)it") selection=input("Enter your selection:\n") if selection== "E" or selection=="e": message=input("Enter the message:\n") elif se...
92749a358c54765e38e8f841fb67be6b7425ee78
yz9527-1/1YZ
/pycharm/Practice/python 3自学/9-函数.py
582
3.75
4
""" def maxTwo(a, b): if a > b: print(a) else: print(b) def maxThree(x, y, z): if x > y: maxTwo(x, z) else: maxTwo(y, z) maxThree(12, 8, 45) import random def custom_str(length, type): if type == 'number': s = '1234567890' elif type == 'letter': ...
03cf84510129ef9ecc2a33ecf9ea1d7022d7a345
gabriellaec/desoft-analise-exercicios
/backup/user_112/ch16_2020_05_04_19_58_13_049880.py
100
3.59375
4
x = input('valor da conta do restaurante') n = x * 1.01 print("Valor da conta com 10%: R$%2f" % n)
6f6c149d54c7dd0fef7ec9dd0defa5b24f6e9b48
KylanThomson/Polynomial-Regression-Neuron
/main.py
1,106
3.78125
4
# John Bachman Kelley, 10/19/2020, Artificial Intelligence # The purpose of this code is to predict energy consumption using three different architectures of linear regression # neurons. We have been given 3 days of data, from 8:00 to 5:00 pm with 1-hour intervals. import pandas as pd import numpy as np import matp...
276c0719a609ba213d60d3c4b75c110a8c34409a
Archenemy-666/Edureka-Python-Training-for-Data-Science
/assignments/case_study/siddharth.c_casestudy1.py
1,543
4.25
4
#Write a program which will find factors of given number and find whether the factor is even or odd. def fatorization_of(x): print("list : ") for i in range(1, x+1): if x % i == 0: print(i," : is a factor") else: print(i," : is not the factor\n\n") num = 10 fatorization...
1c1cd18465c3a0232cf863fc8f9a21e6f4a7130b
ektorasgr/ABS
/tablePrinter.py
1,157
4.25
4
''' this function takes a list of lists of strings and displays it in a well-organized table with each column right-justified ABS Ch. 6 Practice Project ''' tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose...
ac2504902390a810ed29cb659fe722d2d97d88b8
NikolaosPanagiotopoulos/PythonLab
/labs/source/lab_02/lab_02_exercise_1.py
964
3.640625
4
# Ζητάμε από το φοιτητή να δώσει το όνομα του onoma = input("Δώσε όνομα φοιτητή: ") # Ζητάμε από το φοιτητ΄τη να δώσει το βαθμό προόδου proodos = input("Δώσε βαθμό προόδου: ") # Ζητάμε από το φοιτητ΄τη να δώσει το βαθμό γραπτού grapto = input("Δώσε βαθμό γραπτού: ") # Μετρατρέπουμε την πρόοδο από αλφαριθμητική τιμή σε...
5e7bc2b2ea7e1eb2faf45710cad46bc82b2703a8
colinpannikkat/pythonexercises
/exercise6.py
344
3.84375
4
string = input("Input String:\n") string = string.replace(" ", "") list = list(string) a = int(len(list)) x = a-1 c = [] while x > -1: b = string[x] c.append(b) x = x-1 b = int(len(c)) z = list[0:a] y = c[0:b] print (z,y) if z == y: print("The string is a palendrome!\n") else: print("The string i...
d12108b43170575efc1fc8647998be68db478eb4
tuanphandeveloper/practicepython.org
/cowsAndBulls.py
1,524
4.125
4
# Create a program that will play the “cows and bulls” game with the user. The game works like this: # Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit that the # user guessed correctly in the correct place, they have a “cow”. For every digit the user guessed correctly # i...
c88cf2191baf0f40f37b54f70fd57093e6da4c8d
SuzanneRioue/programmering1python
/Arbetsbok/kap 16/övn 16.1, sid. 40 - register.py
2,074
3.53125
4
#!/usr/local/bin/python3.9 # Filnamn: övn 16.1, sid. 40 - register.py # Mer om listor samt dictionarier # Programmeringsövningar till kapitel 16 # Programmet låter användaren mata in uppgifer till register över e-postadresser, vilka lagras i et dictionary. # Nycklarna ska vara namn och e-postadresserna värden. Vi l...
0b7ced82cb26c14214facfb3a1ee5c53d6e593a0
jeffreyalvr/python-sistema-mercado-simples
/main.py
1,329
3.59375
4
import math import sys # variável para determinar em qual menu o usuário estará comando = 0 # mensagem inicial de boas vindas print('Bem-vindo ao Sistema de Mercadinho!\n') # função para exibir o menu inicial def mostrar_menu(): print('1. Inciar uma nova compra') print('2. Adicionar produto ao catálogo') ...
22c29914fc208fbbee7042e3cbb2e3c3ffec255e
milohiggo/PythonSQL
/database3.py
602
3.875
4
# -*- coding: utf-8 -*- """ Video https://www.youtube.com/watch?v=byHcYRpMgI4 Created on Sat May 29 20:17:56 2021 @author: ssaghi """ import sqlite3 # conn = sqlite3.connect(':memory:') conn = sqlite3.connect('customer.db') #Create cursor curs = conn.cursor() #Insert many records many_customers = [('M1', 'Brown','M1...
56073b87d9972d41eb7823b4befa31b7df1f899e
Fahofah/Python-Week1
/Phyton Exs.py
2,619
3.890625
4
#Task1 print('#Task1') print('Hello World!') #Task2 print('#Task2') hi='Hello World' print(hi) #Task3 print('#Task3') def printThis(text): print(text) printThis('Hello Mama') #Task4 print('#Task4') def add(x,y): print(x+y) add(4,5) #Task5 print('#Task5') def sumORmult(x,y,sumIt): if (sumIt): result=...
e870a8e0ff6adaa32e2722aa4e9622839bd0e07d
rafaelblira/python-progressivo
/exibir_laber_vertical.py
841
4
4
import tkinter class MinhaGUI: def __init__(self): # Criando a janela principal self.main_window = tkinter.Tk() # Criando a label Ceará e exibindo self.label = tkinter.Label(self.main_window, text="Ceará", bg="black", fg="white") self.label.pack(fill = tkinter.Y, side='...
7a881b449e348d21f5174a30384f6f5cac16b2b4
arnoldtaveras/ICC_102
/dividendos.py
343
4.03125
4
dividendo = -1 divisor = -1 while (dividendo <= 0 or divisor <= 0): dividendo = int(input("Digite el dividendo: ")) divisor = int(input("Digite el divisor: ")) if (dividendo <= 0 or divisor <= 0): print ("Error. solo numeros positivos") while(dividendo >= divisor): dividendo = dividendo - div...
458b1e6f951f4f53aaa625b3d8c09e7a69703257
aechen10/redtrackedit
/Test/Pandas+NumPy/pandasTest.py
2,017
3.546875
4
import numpy import pandas import random #Creating series (similar to arrays?) s = pandas.Series([1, 3, 5, numpy.nan, 6, 8]) print(s) #Creating Date Range dates = pandas.date_range('20190602', '20190604',3) print(dates) numpyData = numpy.random.randn(3, 4) for i in range(0, len(numpyData)): for j in range(0, len(num...
3a8f91d5e43af07ad555619162a25a3c548a7c1b
nuraanNinah/ANIMALS-PART-1.-OOP-BASICS
/Animal.py
326
3.796875
4
class Animal: def __init__ (self, name, sounds): self.name= name self.sounds =sounds def food(self): print("{0} eats".format (self.name)) def sound(self): print("{0} barks".format(self.sounds)) dog = Animal("Rex", "Dog") cat = Animal("Stormy", "Cat") dog.food() dog.so...
7ded493fa87d022fe474133db99a6ba62b241292
ShimnaA/Turtle
/Hexagon.py
119
3.78125
4
# Draw a Hexagon using turtle import turtle t = turtle.Turtle() for i in range(6): t.forward(50) t.right(60)
5c31af2cf537031b0d22d7d1471a64e6774dff58
PedroDNBR/ossu-pyton-for-everybody
/6. Loops and Iterations/worked-exercise-5.1.py
582
4.03125
4
numberQtd = 0 total = 0 #loop that users insert the numbers, if write done, the loop stops while True numberInput = input("Insira um numero:") if numberInput == "done" : break try: numberFloat = float(numberInput) except: print("Valor invalido") continue #calculate ...
23ba4a0f80643f85ca5b64af6aca504034249d52
ZoranPandovski/al-go-rithms
/data_structures/b_tree/Python/sum_root_leaf.py
1,270
4.125
4
""" To find whether a tree has a sum of tree from root to leaf is equal to the given number. If true, return the path which produces the sum. Else, return False """ from __future__ import print_function import binary_search_tree class SumRootLeaf(): def root_leaf(self,root, given_sum, val, path_list): ...
d55a2966408ec30b2ee98097bf520cb399c1c43f
favour-22/holbertonschool-higher_level_programming
/0x03-python-data_structures/2-main.py
803
3.953125
4
#!/usr/bin/python3 replace_in_list = __import__('2-replace_in_list').replace_in_list my_list = [1, 2, 3, 4, 5] idx = 3 new_element = 9 new_list = replace_in_list(my_list, idx, new_element) print("Valid index") print(new_list) print(my_list) idx = -1 new_element = 19 new_list = replace_in_list(my_list, idx, new_eleme...
ce55d1121ac3ea0d4ec4c4dc722f24ab7fe0b3e0
dhanashreesshetty/Project-Euler
/Problem 19 Counting Sundays/pyprog.py
161
3.84375
4
from datetime import date count=0 for year in range(1901,2001): for month in range(1,13): if date(year,month,1).weekday()==6: count+=1 print(count)
6f07c8fa8f7bf8f0a945613e48c5a76aadc028b3
nodicora/planarity
/planarity/planarity_functions.py
780
3.671875
4
"""Functional interface to planarity.""" import planarity __all__ = ['is_planar', 'kuratowski_edges', 'ascii', 'write', 'mapping'] def is_planar(graph): """Test planarity of graph.""" return planarity.PGraph(graph).is_planar() def kuratowski_edges(graph): """Return edges of forbidden subgraph of non-plan...
6a9882c304ac032524e615e45c9e80c2301ea69a
pnugues/ilppp
/programs/ch05/python/count_bigrams.py
737
3.875
4
""" Bigram counting Usage: python count_bigrams.py < corpus.txt """ __author__ = "Pierre Nugues" import sys import regex def tokenize(text): words = regex.findall(r'\p{L}+', text) return words def count_bigrams(words): bigrams = [tuple(words[idx:idx + 2]) for idx in range(len(words) - 1...
d2e3b144af63fee8009b8dacd4e83b35503d46f7
ashud06/algorithms_dataStructures
/Code_development/Recursion_Backtracking/Hackerank_Problems/problem1/problem1.py
2,785
3.5625
4
#!/bin/python3 import math import os import random import re import sys ''' def check(X,val): global combos if val == X: print('success') combos+=1 return 1 else: return 0 def getCombos(X, N,prev_total=0,start_index=0): print('previous total: {}'.format(prev_total)) ...
2a02f0ef86a56792fa2bbb15778d45325e6071d1
EunhyeKIMM/python
/ch09/ex13.py
262
3.546875
4
import time def gettime(): now = time.localtime() return now.tm_hour, now.tm_min result = gettime() print("지금은 %d시 %d분 입니다. " %(result[0], result[1])) hour, minute = gettime() print("지금은 %d시 %d분 입니다. " %(hour, minute))
7242e88b50610a0481937714bf2dc40dfb69f138
sknielsen/shopping_list
/shopping_list_program.py
1,823
4.3125
4
shopping_list = { "Target": ["socks" , "soap", "detergent", "sponges"], "Bi-Rite" : [ "butter", "cake", "cookies", "bread"] } #Function to display main Menu def show_main_menu(): return """ 0 - Main Menu 1 - Show all lists. 2 - Show a specific list. 3 - Add a new shopping list. 4 - Add an item to a shopping list....
e27ce8911a2851969ed189bc7d326d9f3a6307f3
Infinity7878/SimpleLogin
/main.py
937
3.671875
4
import tkinter as tk from tkinter import messagebox app = tk.Tk() app.geometry("300x50") box1 = tk.Entry(app) box1.grid(row=1, column=1) box2 = tk.Entry(app) box2.grid(row=2, column=1) def signup(): user = box1.get() passw = box2.get() file1 = open("users.txt", "a") info = user + passw...
353843608bede50f52ff8bf3662c3bb1ca048bf8
sharondsza26/python-Technology
/objectOriented/PiggyBank/objectOrientation.py
2,111
3.921875
4
# Stage 1 class PiggyBank: pass print("Hello") pg1 = PiggyBank() print(pg1) print(id(pg1)) print(hex(id(pg1))) print(type(pg1)) print(pg1.__class__) # Stage 2 -Extensible class PiggyBank: pass pg1 = PiggyBank() print(pg1) print(id(pg1)) print(pg1.__class__) pg1.balance = 10 # It creates a variable ba...
45aa0f6b6b032f5f31a392efb73131de994fa4ce
Edvinauskas/Project-Euler
/nr_014_python.py
1,178
3.875
4
######################################### # Problem Nr. 14 # The following iterative sequence is defined # for the set of positive integers: # # n n/2 (n is even) # n 3n + 1 (n is odd) # # Using the rule above and starting with 13, we # generate the following sequence: # # 13 40 20 10 5 16 8 4 2 1 # It can b...
d11b87211b857167e090cd315ac093554403ba66
MakeSchool-17/twitter-bot-python-samlee405
/5. HerokuServer/sample.py
1,287
3.890625
4
import wordFrequency import sys import random # Get a random word from a file def sample(): textFile = sys.argv[1] histogram = wordFrequency.histogramFile(textFile) # print(histogram) # Get total count of words wordCount = 0 for item in histogram: wordCount += item[1] # Generate a...
576585854e1f93c004ffa0da9549d387a515b8e2
sreesindhusruthiyadavalli/MLsnippets
/numpybasics.py
1,031
4
4
import numpy as np #1d array a = np.array([0,1, 2, 3,4,5]) print a print a.ndim #dimension is 1 print a.shape #(6,) is 6 rows print a.dtype #type of the array #For 2d array b = a.reshape((3,2)) # 3 rows and 2 columns print b print b.ndim #2 dimensional print b.shape #Shape of the array #Here b and a refers same...
f114dbea25ff21bc529989c4fee1a19cac287f87
frankolson/PythonProjectEuler
/problem8.py
611
3.8125
4
### Project Euler Problem 8 ### Will Olson ### 01 July 2013 ### Python 2.7.5 def iterate_through_file( file_name ): fout = open(file_name, 'r') file_line = fout.readline() file_list = list(file_line) count = 0 highest = 0 while count < len(file_list)-5: product = int(file_list[count])*...
b4be1ec472c62ad0c15b1028527729248c6671ea
costadazur/g_code_sample_python
/src/video_playlist.py
1,124
3.78125
4
"""A video playlist class.""" from .video_library import VideoLibrary from .video import Video class Playlist: """A class used to represent a Playlist.""" def __init__(self): self._video_library = VideoLibrary() self._videos = [] self._current_video = Video("","","") def add_video_...
0b3f5a7174a434763041c921188ee74e1023551e
guveni/RandomExerciseQuestions
/distance.py
978
4
4
# !/usr/bin/env python # -*- coding: utf-8 -*- """ """ __author__ = 'guven' def get_min_of_three(o1,o2,o3): first = o1 if o1 < o2 else o2 result = first if first < o3 else o3 return result def calculate_dist(str1, str2): if not str1 or not str2: return -1 len1 = len(str1)+1 len2 = l...
56df065da26975a245a8bdd365ca7b46afadc281
MichaelYoungGo/Practice
/输入限制I的双向队列.py
1,714
3.96875
4
# -*- coding: utf-8 -*- # @Time : 2018/11/1 0001 下午 1:23 # @Author : 杨宏兵 # @File : 输入限制I的双向队列.py # @Software: PyCharm class Node: def __init__(self): self.data = 0 self.next = None front = Node() rear = Node() front = None rear = None def enquenue(value): global front global rear...
a0cd4e87f470509d4b764b4b379575fb843ec153
Glitch-is/CP
/cp.py
2,414
4.15625
4
""" Competitive Programming Library for Python Functions: #Primes: isPrime(n) sieve(n) #Fibonacci: fib(n) Authors: Glitch https://github.com/RuNnNy/CP """ import math """Primality check that iterates through all integers below the square root of the number being checked and makes sur...
fdfc923ad3020be38d6dbbc059bfd944877ff7af
ppinko/python_exercises
/algorithms/hard_algoritm_sorting_time.py
570
3.703125
4
""" https://edabit.com/challenge/kjJWvK9XtdbEJ2EKe """ def sort_array(L: list) -> list: for i in range(len(L)): for j in range(len(L) - 1): if L[j+1] < L[j]: temp = L[j+1] L[j+1] = L[j] L[j] = temp return L assert sort_array([2, -5, 1, 4, 7...
08f4b21b8da0de351ac2b69bf1926dfa9cafbf1d
GlennRC/Algorithms
/Labs/Lab13/Horspools.py
2,103
3.53125
4
import string import random import time ''' This lab was worked on by Glenn Contreras, Neha Tammana, and Ben Liu ''' def shiftTable(pattern, isBit): if isBit: var = ['0', '1'] else: var = string.ascii_lowercase + ' ' table = {} for i in range(len(var)): table.update({var[i]: l...
38b5aa1557881fb22c3722c5bea8cf42a9befffb
Inosonnia/ImgAna
/recog_label2txt.py
1,854
3.71875
4
#coding:utf-8 #将一种字符集产生的Text文件,转换为Label import codecs import argparse import os import sys def read_tag_file(tag_file): file_io = codecs.open(tag_file,'r','utf-8') lines = file_io.readlines() file_io.close() tag_map = {} for line in lines: line = line.strip() label,text = line.sp...
39b2342dd306d706f8ba9cbcf383f08a55385b6a
BoZhaoUT/Teaching
/Winter_2016_CSCA48_Intro_to_Computer_Science_II/Week_2_ADTs_and_Number_Conversion/my_queues.py
5,266
4
4
class QueueA: '''A first-in , first-out (FIFO) queue of items''' def __init__(self): '''(Queue) -> NoneType Create a new, empty queue. ''' self._contents = [] def push(self, new_obj): '''(Queue, obj) -> NoneType Place new_obj at the end of this queue. ''' self._con...
91fa41e6c33e3082ccc1358bf2864596c9a296dc
Bavithakv/PythonLab
/CO1/colour_13.py
167
3.84375
4
color=input("Enter the list of color names seperated by commas:") print("First color entered :",color.split(",")[0]) print("Last color entered :",color.split(",")[-1])
20d0c5bb921f5ed261bb7c4e3caf918bbf772a11
michaelWGR/projectmc
/testpy/prime_test.py
1,137
4.03125
4
# -*- coding:utf-8 -*- import math import time def isPrimeNumber(num): if (num == 2): return True if (num < 2 or num % 2 == 0): return False i = 3 while i <=math.sqrt(num): if (num % i == 0): return False i +=2 return True def get_prime_list(number): ...
7897da4b3ccfadefd2f0142107d610fe1507325b
AzeezBello/_python
/univelcity/vowels.py
136
4
4
vowels = ['a', 'e', 'i','o','u'] name = input("Enter the your name") if a in name: print('yes', name, "contains" vowels) elif
d341c23a99d935c26557b0e66b6c162c2bd300b3
ludvikpet/denGodeGamleStatistics
/init_denGodeGamle.py
5,941
3.765625
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 1 13:21:31 2020 @author: ludvi """ import sys import random # *** INIT - METHODS *** # #Method, that generates data: def generateData(outcomeList, k, throws): #List of results: results = [] #Switch, to indicate, whether a switch has been made: ...
63c2bc0c5ab1c1c042c73d9df1cc5f29e877735c
Rilst/Programming
/Practice/13/Python/Project.py
403
3.921875
4
a = int(input('Введите целое число больше 1: ')) if a == 1 or a == 0: print("Неверно введенно число") elif a == 2: print("Простое") else: i = 2 c = 0 while i < a: if (a % i == 0): c = 1 i = a i += 1; if c == 1: print("Составное") else: ...
e1958efdb19f204fa9b3e465280a9acd7bf15ad5
Nilcelso/exercicios-python
/ex018.py
773
4.15625
4
'''import math ang = float(input('Digite um angulo: ')) seno = math.sin(math.radians(ang)) cosseno = math.cos(math.radians(ang)) tangente = math.tan(math.radians(ang)) print('O angulo de {} tem seno de {:.2f}'.format(ang, seno)) print('O angulo de {} tem cosseno de {:.2f}'.format(ang, cosseno)) print('O angulo de {} te...
d048167e8dac22669a8b7f757b7d9cb196f2e7c8
Bulgakoff/files_utf8_04
/lesson03/write_bytes.py
659
3.59375
4
# открываем файл для записи бфйтов with open('bytes.txt', 'wb') as f: # пишем сроку байт f.write(b'Hello bytes') # читаем как текст with open('bytes.txt', 'r', encoding='ascii') as f: # печатаем сроку байт врежиме чтения print(f.read()) # тепрь запишем(write()) и выведем на печать то что чит...
50bf93c73e3178db4611ccfa65841c0a5ac302f0
rjrishav5/Codes
/Sorting Algorithms/bogo_sort.py
388
3.890625
4
import random import sys def is_sorted(values): for index in range(len(values)-1): if values[index] > values[index+1]: return False return True def bogo_sort(values): count=0 while not is_sorted: print(count) random.shuffle(values) count+=1 ret...
5a84e39022b52955f7e52d926d1f25ada26ebde7
Ivanm21/hackerrank
/Happy_Ladybugs.py
1,465
4.125
4
'''#Happy Ladybugs is a board game having the following properties: The board is represented by a string, , of length . The character of the string, , denotes the cell of the board. If is an underscore (i.e., _), it means the cell of the board is empty. If is an uppercase English alphabetic letter (i.e., A throug...