blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3c901acff3910976604d2f1f1de853274080ad8a
Huh-jae-won/Study
/PythonAI/Source/W1D3/src/EX_URL/ex_str_byte.py
721
3.53125
4
# str과 byte --------------------------------- msg='hello' # 일반 문자열 bmsg=b'hello' # b'문자열' => 문자 해당 ASCII code 변환한 값 즉 바이트 형식 # 각 데이터 요소 출력 print('\n===== 데이터 요소 출력 =====') for i in msg: print(i, end='\t') print('\n') for i in bmsg: print(i, end='\t') for i in bmsg: print('0x%x'%i, end='\t') print('\n...
a4b27e4dfbb6e41dd966a902a1ba2be08253bd78
lucasdiogomartins/curso-em-video
/python/ex022_string_meths.py
397
4.15625
4
nome = input('Digite seu nome: ').strip() print('\n Nome em maiúsculas:', nome.upper()) print(' Nome em minúsculas:', nome.lower()) print(' Quantidade de letras:', len(nome.replace(' ', ''))) print(' Quantidade de letras:', len(nome)-nome.count(' ')) # 2° opção print(' Q. de letras primeiro nome:', len(nome.split()[0]...
77990194f1b61aeaba91b98c8988865e69b762ea
mohamedhmda/Algorithms
/Easy/bubble_sort/bubble_sort.py
282
4.125
4
def bubble_sort(array): l = len(array) sorted = False while not sorted: sorted = True for i in range(l-1): if array[i] > array[i+1]: array[i], array[i+1] = array[i+1], array[i] sorted = False return array
b92caa9a4cc870552d6fe944e768dc8bca374ac1
hmutschler15/rpi_git
/cs/300/lab3/switch_blink.py
692
3.75
4
# Name: Hamilton Mutschler # For: Lab 3 in CS 300 at Calvin University # Date: February 21, 2020 import RPi.GPIO as GPIO # set up GPIO pins to BCM GPIO.setmode(GPIO.BCM) # set BCM pin 12 to an input GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) # set BCM pin 16 to an output GPIO.setup(16, GPIO.OUT) # initialize L...
0997cb31c2f610e64955b6b92144f5e61bf1fbf1
yinxingyi/Python100day_Learning
/Day6.py
479
3.984375
4
from random import randint def roll_dice(n = 2): # n=2 is default number, if there is no inputs when you call this function, the n use default number 2 total = 0 # roll the dice, and return total number, duce number origanlly is 2 for _ in range(n): total += randint(1,6) return to...
d1f95632fa1db78ee1667a579e08ee718047299e
AdamZhouSE/pythonHomework
/Code/CodeRecords/2064/60634/269458.py
602
3.609375
4
def tranBit(c): if c == 'I': return 1 elif c == 'V': return 5 elif c == 'X': return 10 elif c == 'L': return 50 elif c == 'C': return 100 elif c == 'D': return 500 elif c == 'M': return 1000 def tran(num): result = 0 i = 0 ...
3438b4eb1b69fe6674b952a95fa9c2e181acd8f8
renancoelhodev/jogo_nim
/jogadas.py
1,174
4.125
4
from time import sleep def computador_escolhe_jogada(n, m): if n > 0: if n <= m: # retira o maior número de peças possíveis se o número de peças no tabuleiro for menor print() # que o número de peças que podem ser retiradas em uma jogada sleep(2) print("O computador ...
e5e45ec12b92c4e4979f63a2d6a8ce84d5028d5d
cielo33456/practice
/main.py
329
3.609375
4
from sort import bubble list_a = [233,1,453,35,87,400,46,77,35,700] print(list_a) bubble(list_a) #length = len(list_a) #for times in range(1, length): # for flag in range(1, length-times+1): # if list_a[flag-1] > list_a[flag]: # list_a[flag-1], list_a[flag] = list_a[flag], list_a[flag-1] print...
1f1ca9e1869593a302abd770f991400b67a1e1a4
thanhmaikmt/pjl
/PythonPodSim/src/devel/podworld/atttic/podParamEvolver_orig.py
14,192
3.625
4
# demonstration of Evolving pods using a randomish search. # # uses the idea of a population selection and mutatation (does not try crossover) # # Each pod is controlled with a neural brain. # Pods have a finite life. # Pods die when they reach the age limit or crash into a wall # The fitness of a pod is measure...
6de80be36186ff661cbfb55b2d8451e429c6a991
qzson/Study
/hamsu/h1_split.py
767
3.765625
4
import numpy as np # test0602_samsung_review에서 사용 def split_x(seq, size): aaa = [] for i in range(len(seq) - size + 1): subset = seq[i:(i+size)] aaa.append([j for j in subset]) # print(type(aaa)) return np.array(aaa) size = 6 # 6일치씩 자르겠다? # test0602_exam에서 사용 def split_xy3...
19ea97b11d097b0f661960b53abbbf34b32e5033
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4351/codes/1649_1054.py
185
3.90625
4
x=float(input("valor de x")) y=float(input("valor de y")) reta= (2*x)+y if (reta == 3): menssagem="ponto pertence a reta" else: menssagem="ponto nao pertence a reta" print(menssagem)
8625f2d1d1a04a1b86fc2a28dc2c207b207fefa7
teberger/cs554-project2
/ll1_tools.py
10,129
3.625
4
from cfg import Grammar, EOF, EPSILON def nullable(grammar): ''' Returns a list of the all non-terminals that are nullable in the given grammar. A nullable non-terminal is calculated as a closure using the following rules: nullable(A -> Epsilon) -> True nullable(A -> a) -> False ...
f1d86d652d01d6dddfb4d7c88707ef9b434027d2
kristenlega/python-challenge
/PyPoll/main.py
2,434
3.765625
4
import os import csv electiondata_csv = os.path.join("..","PyPoll", "Resources", "election_data.csv") # Open the CSV file with open(electiondata_csv,'r') as csvfile: csvreader = csv.reader(csvfile, delimiter=",") # Skip the header row next(csvreader, None) # Set the initial summing variables to 0 ...
439853f2a919e95e1ff4d52ddd9b0fc63eb56578
dantsub/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/6-print_comb3.py
316
3.96875
4
#!/usr/bin/python3 for first in range(0, 10): second = first + 1 for second in range(0, 10, 1): if (first != 8 or second != 9): if (first != 8 and second > first): print('{}{}'.format(first, second), end=', ') else: print('{}{}'.format(first, second))
44067d74ac7aea3cc15b343433fa8c9d5147d2be
mindovermiles262/codecademy-python
/11 Introduction to Classes/18_inheritance.py
1,072
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jan 8 09:59:18 2017 @author: mindovermiles262 Codecademy Python Create a class named Equilateral that inherits from Triangle. Inside Equilateral, create a member variable named angle and set it equal to 60. Create an __init__() function with only the...
a3f24ce27ad6d4d961704e1fb82768be2b64ed3a
chereddybhargav/disc-opt
/knapsack/solver_dp_time_opt.py
3,215
3.5
4
#!/usr/bin/python # -*- coding: utf-8 -*- import sys from collections import namedtuple sys.setrecursionlimit(10001) Item = namedtuple("Item", ['index', 'value', 'weight']) def solve_it(input_data): # Modify this code to run your optimization algorithm # parse the input lines = input_data.split('\n') ...
2f7b72e44d7712613602eae2d920260508efeba7
EvanJamesMG/Leetcode
/python/Dynamic Programming/264.Ugly Number II.py
1,977
4.3125
4
''' Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number. Hint: The naive approach is to call isUgly for e...
31d2a8ee14e7510d8892b2f5ae5a2d5f653742da
DCWhiteSnake/Data-Structures-and-Algo-Practice
/Chapter 2/Projects/P-2.33.py
2,926
4.21875
4
def differentiate(expression): """ Function that finds the first differential of a polynomial expression expression the polynomial expression if expression is a constant, the function returns 1. if expression is a number, the function returns 0. if the expressionis...
0768a2ae7c269c71ed59d3ec406db82d3a18b8ab
HeyVoyager/Portfolio-Projects
/ud_graph.py
14,532
3.875
4
# Course: CS261 - Data Structures # Author: Michael Hilmes # Assignment: 6 # Description: Undirected Graph Implementation from collections import deque class UndirectedGraph: """ Class to implement undirected graph - duplicate edges not allowed - loops not allowed - no edge weights - vertex na...
cfd1fa7811f434c2f9293d8526e06122575c100b
dankeder/xbtarbiter
/xbtarbiter/forex.py
675
3.640625
4
import requests from decimal import Decimal def get_eurusd(): """ Return the current EUR/USD exchange rate from Yahho Finance API. :return: Current EUR/USD exchange rate """ # See: # http://code.google.com/p/yahoo-finance-managed/wiki/csvQuotesDownload # http://code.google.com/p/yahoo-...
aae8909ba175d168a6d2915e6ff312fca93eeb34
Ecoste/MouseFlask
/db_manager.py
2,743
3.578125
4
__author__ = 'A pen is a pen' import sqlite3 from contextlib import closing import sys class Point: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): if isinstance(other, self.__class__): return Point(self.x + other.x, self.y + other.y) else...
60e6e9b4d07b2072462161428e6721f8e22fc076
2dam-spopov/di
/P12_Sergey.py
717
3.796875
4
def copia(fichero): """ Se pasa por parámetro el nombre del fichero. Crea dos ficheros, uno con nombre del fichero y otro con extensión bak. Copia del archivo creado el contenido al archivo bak. """ fichero1 = open(str(fichero), "w+") fichero2 = open(str(fichero) + "bak.txt", "w+") respuesta = "" while(respu...
44e79a7adca8d55172f4e94c3644cc507c7dcffc
shivanshsen7/goeduhub
/assignment-1/assignment-1-q14.py
626
4.03125
4
""" Write a Python program to get next day of a given date. Expected Output: Input a year: 2016 Input a month [1-12]: 08 Input a day [1-31]: 23 The next date i...
95808b861c32248f3557a3957e39cbe06211f87b
Yifei-Deng/myPython-foundational-level-practice-code
/Woniu ATM version3.0.py
3,691
3.5625
4
''' WoniuATM a. 在前面项目的基础上进一步改进,要求使用一个二位列表来保存用户名和密码 b. 添加如下操作主菜单,用户选择对应的菜单选项进行操作,每次操作完成后继续进入主菜单,用户输入3之后可以结束并退出应用 *****************Welcome to Woniu ATM***************** ******Please Choose One of The Following Options****** **************1.Sign Up 2.Log In 3.Exit*************** ''' users = [ ['Rey','5P1...
6b722c5fedcd4aa172eb7b85c4470f344d596bcd
YossiBenZaken/Python-Scripts
/1.py
372
3.515625
4
''' Yossi Ben Zaken ID:315368134 ''' #-------Targil 1---- H=int(input("Enter hours of start:")) M=int(input("Enter minutes of start:")) S=int(input("Enter seconds of start:")) FL=int(input("Enter seconds of flight time:")) time=FL+S+M*60+H*3600 D=time//86400 H=time%86400//3600 M=time%3600//60 S=time%3600%60 print('Days...
ee76a5f4ac36d3eb1de623cfeb5e4ff5c7b58799
HMurkute/PythonNumpy
/LearnNumpy3.py
1,187
4.65625
5
import numpy as np # To perform linespacing we use '.linspace' function. Linespacing means printing # values between two points divided equally. a = np.linspace(1, 10, 5) # The syntax is like this '(start,stop,no. of values)'. print(a) # For finding the min, max, sum we use functions like below # Let's defi...
6db8f79a1209cd06ab9c1ba797b22f1c125d3cd8
Dexton/advent2020
/d6/d6-p2.py
682
3.546875
4
input = open("input", "r") groups = [] group = set() first_in_group = True for line in input: person = set() if line == '\n': groups.append(group) group = {} first_in_group = True continue for char in line.strip(): person.add(char) if first_in_group: gr...
49661d5de0169b0c0f3d798f022a4d6c7b3aff87
pswilson/WordSolver
/python/Dictionary.py
2,227
3.8125
4
# Basic Word Dictionary # to support a Word Solver and Boggle Solver DEFAULT_DICTIONARY_FILE = 'twl06.txt' # Private class to keep track of whether a node is a prefix and/or a word class _DictionaryNode: is_prefix = False is_word = False # The Dictionary class itself class Dictionary: def __init__(se...
0e271b9c239a95d7a589e3d3aedf22f8e60c53bd
sakurasakura1996/Leetcode
/二叉树/problem563_二叉树的坡度.py
1,312
4.09375
4
""" 563. 二叉树的坡度 给定一个二叉树,计算整个树的坡度。 一个树的节点的坡度定义即为,该节点左子树的结点之和和右子树结点之和的差的绝对值。空结点的的坡度是0。 整个树的坡度就是其所有节点的坡度之和。 示例: 输入: 1 / \ 2 3 输出:1 解释: 结点 2 的坡度: 0 结点 3 的坡度: 0 结点 1 的坡度: |2-3| = 1 树的坡度 : 0 + 0 + 1 = 1 提示: 任何子树的结点的和不会超过 32 位整数的范围。 坡度的值不会超过 32 位整数的范围。 """ class TreeNode: def __init__(self, x):...
abf8f381154347bc738a45bd00438e18dddaac03
GourabRoy551/Python_Codes_2
/Matplotlib/BarChart.py
603
3.78125
4
import matplotlib.pyplot as plt x = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++'] popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7] x_pos = [i for i, _ in enumerate(x)] plt.bar(x_pos, popularity, color='blue') plt.xlabel("Languages") plt.ylabel("Popularity") plt.title("Popularity of Programming Language\n" + "Worl...
a130af5c3ec8cd82ba7b0999c3e2deecb26e2cb6
LucMc/backup-of-old-projects
/go.py
3,835
3.5
4
import pygame import numpy as np pygame.init() display_width = 600 display_height = 600 gameDisplay = pygame.display.set_mode((display_width, display_height)) pygame.display.set_caption('GO') clock = pygame.time.Clock() black = (0,0,0) white = (255,255,255) grey = (200,140,70) points = [] board_size = 9 board = np.zer...
b06d55c44206ca9329252496cac69efa6f4a474b
luid95/Python-Django
/python/POO2.py
828
3.90625
4
#INHERITANCE class Animal(): def __init__(self): print("Animal created") def WhoAmI(self): print("Animal") def eat(self): print("Eating") class Dog(Animal): def __init__(self): print("Dog created") def bark(self): print("Woof") myd = Dog() myd.WhoAmI() m...
f60f18fd350cb56f2abf2d670109a397658b5e88
ComteAgustin/learning-py
/tuples.py
236
3.890625
4
# Tuples can't be modified and are more secure than lists tuple = (1, 2, 3) x = tuple((1, 2, 3)) # > (1, 2, 3) singleTuple = (1) print(singleTuple) # > class 'int'> # del, delete all the tuple del tuple # > error, tuple doesn't exist
bfb9b7939d291f9baa3ace1188fa53b3501e362a
WeiS49/Python-Crash-Course
/python_work/ch9/practice/9-5 sign_in_count.py
1,574
4
4
class User: """ simulate person. """ def __init__(self, first_name, last_name): """ Initialize property first_name and last_name. """ self.first_name = first_name self.last_name = last_name self.login_attempts = 0 # 声明的变量不用self的, 只能作用于这个函数 # full_name = self.fir...
488355f5922b03b19f82365a0a6462ae0c3cb011
reddyachyuth/python_devops
/InterPython/1.py
99
3.859375
4
sum = 0 a = input("enter a number for range:") for i in range(a): sum = sum +i print sum
7ae31c4b365c7073ed23e6ebaf90d491f082b8a9
uludag-udl/Python_Beginner
/8_Fonskiyonlar/Rg_first.py
602
3.96875
4
firstNumber=int(input("Bir Sayı Giriniz: ")) secondNumber=int(input("Bir Daha Sayi Giriniz: ")) print("\nfirstNumber : {}\nsecondNumber : {}\n".format(firstNumber,secondNumber)) def calculator(firstNumber,secondNumber,default): if default=="add": return firstNumber+secondNumber if default=="sub": ...
0ef4199cdaf6ca9dadb3f3651aa1db34683b2b68
saurav188/python_practice_projects
/largest_no.py
853
3.71875
4
def fact(n): temp=1 for i in range(1,n+1): temp*=i return temp def get_num(nums,indexes): temp='' for index in indexes: temp+=str(nums[index]) return int(temp) def largestNum(nums): largest=0 indexes=[i for i in range(len(nums))] for each in range(fact(len(nums))): ...
4680c89c982aa13768fe37f39e121241a308771a
Vijay1126/Interview-Prep
/Amazon/flatten.py
1,003
3.765625
4
""" # Definition for a Node. class Node: def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child """ class Solution: def (self, head: 'Node') -> 'Node': if not head: return head start = head ...
f2559b676347ccef18c87896ad64bfdd57e368bb
IrynaKucherenko/hw_repository
/hw2/leap_year.py
395
4.125
4
""" Вводится год. Программа выводит количество дней в году, учитывая високосный год. * високосный год кратный 4, но не кратный 100 или кратный 400 """ a = int(input("year: ")) if a % 4 != 0 or a % 100 == 0 and a % 400 != 0: print("365 days") else: print("366 days")
a6753878ec2386822da3e6e61370f6fcc103e9d3
Estefa29/Ejercicios_con_Python
/Examen1NT/marceliano.py
1,498
4.0625
4
# La escuela marceliano desea obtener el promedio de notas de un grupo de 25 estudiantes, # y los 25 se les solicita 5 notas por cada una de las materias (matemática y lenguaje). # Se debe imprimir el promedio de notas por cada materia, se debe imprimir el promedio de # notas de las dos asignaturas por estudiante ...
a44b2b5427baebd95b4607f14573a61fdf1db487
mustafabinothman/cs50
/6__Python__/pset6/dna/dna.py
664
3.640625
4
import sys import csv if len(sys.argv) != 3: sys.exit("Usage: python dna.py database.csv sequence.txt") database = sys.argv[1] with open(database) as file: db_data = [row for row in csv.DictReader(file)] sequence = sys.argv[2] with open(sequence) as file: seq_data = file.read() counts = {} for key in db...
3e9596e0d0f6f692d66665f847af83020f83577c
JapoDeveloper/think-python
/exercises/chapter9/words.py
358
4.25
4
""" Helper functions that will be used in several exercises into the chapter """ def list_words(): """return a list of words""" fin = open('words.txt') words = [] for line in fin: words.append(line.strip()) fin.close() return words def is_palindrome(s): """check if a string is a ...
c9cb5b875a347bf40584759abaf6f97fdf4bcdc5
Remyaaadwik171017/mypythonprograms
/collections/dictionary/advanced python/oops/inheritance/hiarchy.py
682
3.984375
4
#multilevel inheritance/hiarchial inheritance class Parent: parentname="Ajith" def m1(self,age): self.age=age print("I am father of adwik.my name is ",Parent.parentname) class Mom(Parent): def m2(self,name): self.name=name print("I am",self.name,"mother of Aadwik") p...
e7eeb5e3a2f2f82af679a486348df72c89775ac4
zhiymatt/Leetcode
/Python/30.substring-with-concatenation-of-all-words.131470044.ac.py
1,698
3.8125
4
# # [30] Substring with Concatenation of All Words # # https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/ # # algorithms # Hard (22.26%) # Total Accepted: 95.9K # Total Submissions: 430.9K # Testcase Example: '"barfoothefoobarman"\n["foo","bar"]' # # # You are given a string, s, a...
e7817ae275899c458e618af2d22c865bc11cc39b
Neha-kumari200/python-Project2
/wordsgreterthank.py
290
4.375
4
#Find words which are greater than given length k def stringLength(k, str): string = [] text = str.split(" ") for x in text: if len(x) > k: string.append(x) res = ' '.join(string) return res k = 3 str = "Neha is Nehas" print(stringLength(k, str))
8353db478540285ef3e745d7ed465299faed716d
Daniyal963/Programming-LAB-04
/Question no.5.py
363
3.96875
4
print("Daniyal Ali - 18b-096-CS(A)") print("Lab-4 - 09/Nov/2018") print("Question no.5") #Code initial_value = eval(input("Enter the initial value for the range :")) final_value = eval(input("Enter the final value for the range :")) numbers = range(initial_value,final_value) sum = 0 for value in numbers: s...
256539a03c1dec74130e0c616f4da6951aa9d7c8
Jinny-s/ddit_python_backUp
/HELLOPYTHON/day02/exer02.py
316
3.796875
4
#Exer 02 #첫 숫자를 입력하시오 : 1 #끝 숫자를 입력하시오 : 3 #모든 수의 합은 '6'입니다 (1~3 덧셈) a = int(input("첫 숫자를 입력하시오")) b = int(input("끝 숫자를 입력하시오")) c = 0 for i in range(a, b+1): c += i print("모든 수의 합은 {}입니다".format(c))
a3bcf6842e7cf5082adde20e5745197925eaabd9
japarker02446/BUProjects
/CS521 Data Structures with Python/Homework2/japarker_hw_2_3.py
526
4.0625
4
# -*- coding: utf-8 -*- """ japarker_hw_2_3.py Jefferson Parker Class: CS 521 - Spring 1 Date: January 27, 2022 Prompt the user for a number. Calculate the cube of that number divided by the number. Print the formula and result using the entered value, limited to two decimal places. # REFERENCE: https:/...
60f2a7146b46cc8275f1a5672199d0ec9cf994fd
Robinthatdoesnotsuck/Python-misc
/cola.py
100
3.65625
4
print("micola") print("a iram le huele la cola") for i in range(10): print("contar " + str(i))
57796a4dcc6064f082813d53cdb19321ebddd62e
svicaria/svicaria.github.io
/Curso_basico_python/conversor_a_cop.py
181
3.578125
4
USD = input('¿Ingrese los USD que desea convertir? ') USD = float(USD) TRM = 3768 COP = USD*TRM COP = round(COP, 1) COP = str(COP) print('Tendrías $ '+ COP + ' Pesos colombianos')
423612f123db3b6593b131b5a8929bc4d38bd1ee
ykurylyak87/udemy
/methods/methodsdemo1_2.py
354
4.03125
4
def sum_nums(a, b): """ Get sum of two numbers :param a: :param b: :return: """ return a + b c = sum_nums(5, 5) print(c) def is_metro(city): l = ['sfo', 'nyc', 'la'] if city in l: return True else: return False x = is_metro('sfo') print(x) y = is_metro(input...
e16d3e6c8040204e8ca4e90f34379923d633d6cf
JhordanRojas/test
/perro/boleta restaurante.py
1,521
3.984375
4
#input nombre_cliente=input("inserte el nombre del cliente:") nombre_mesero=input("ingrese el nombre del mesero:") cant_arroz_pato=int(input("ingrese la cantidad de arroz con pato:")) precio_arroz=int(input("ingrese el precio unitario del arroz con pato:")) cant_chica=int(input("ingres la cantidad de jarras de chicha:...
fd3760b1c30d5896f18f955ff10ee71a831aa25e
gschen/sctu-ds-2020
/1906101063-何章逸/day0229/test06.py
414
3.5
4
#6. (使用def函数完成)编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n def he(n): sum=0 if n % 2==0: for i in range(2,n+2,2): k=1/i sum+=k return sum else: for i in range(1,n+1,2): k=1/i sum+=k return sum n=int(input())...
9ab57c5cc1b542d38737f5c3ca118f0383c80e27
nvenegas-oliva/training
/hacker-rank/algorithms/grading_students.py
611
3.5625
4
import sys def next_mult(num, mult): num = num + 1 while num % mult != 0: num = num + 1 return num def solve(grades): result = [] for g in grades: if g >= 38 and next_mult(g, 5) - g < 3: result.append(next_mult(g, 5)) else: result.append(g) retur...
1efb7cd8d66c9a4e3e8d4023c410cb395eacd57e
AGrigaluns/Algorithm-A1
/exercise/ex1Operators.py
398
4.28125
4
# Task # The provided code stub reads two integers from STDIN, and # . Add code to print three lines where: # The first line contains the sum of the two numbers. # The second line contains the difference of the two numbers (first - second). # The third line contains the product of the two numbers. a = int(input())...
379529efd31b20db8b304795a440818faa800b79
Charlzzz/mainhub
/Pystudy/lesson1step14.py
425
3.75
4
x = str(input()) if x == ("прямоугольник"): a = int(input()) b = int(input()) s = (a * b) print(s); if x == ("круг"): a = int(input()) pi = float(3.14) s = float(pi * a ** 2) print(s); if x == ("треугольник"): a = int(input()) b = int(input()) c = int(input()) p = (a + b ...
c0f59471bed7cab235d17c27b0d27c0f78990d94
fpgmaas/project-euler
/euler549.py
2,668
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 21 11:17:36 2017 @author: florian """ import math from sympy import sieve from collections import Counter def primefacs(n): primfac = [] d = 2 while d*d <= n: while (n % d) == 0: primfac.append(d) # supposing you ...
82c6e2e4d2284eed5bf1625b40ab570dabfda5ba
broadlxx/171-172-271python-
/dayi/tutorial 10/Problem 5.py
380
3.734375
4
def getdetails(): if a=="quit": print(items) return None else: dictionary={} dictionary['title']=input("What the title is:") dictionary['cost']=input("What the title is:") items.append(dictionary) items=[] while True: a=input("answer") if a=="quit": ...
2e38845a8b0cf24d145ecc040faa521f1c9c6f42
feecoding/Python
/Loops/Program 21.py
102
3.609375
4
##created by feecoding n=int(input("Type a number :")) d=0 for i in range(1,n+1): d=d+i print(d)
e15ce01fd4d4eab58458e8c49c9c251dc5b62cb2
rjmarshall17/trees
/leet_code_lowest_common_ancestor.py
3,803
3.8125
4
#!/usr/bin/env python3 from typing import List class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def __str__(self): ret = str(self.val) ret += " left: %s" % ("None" if self.left is None else str(self.left.val)) ret += " rig...
31416de1fd472c7690369195693b3129c59451ae
XinyuYun/cs1026-labs
/lesson5/task2/task.py
249
4.21875
4
# Replace the placeholders and complete the Python program. def factorial(n): result = n for Complete the for loop statement: Compute a new result value return result print(factorial(5)) print(factorial(7)) print(factorial(9))
b7b974522f7cdc7cdd593538c082dd59f1ebd151
adibsxion19/CS1114
/HW/hw1_q2.py
592
3.609375
4
# Author: Aadiba Haque # Assignment / Part: HW1 - Q2 # Date due: 2020-02-14 # I pledge that I have completed this assignment without # collaborating with anyone else, in conformance with the # NYU School of Engineering Policies and Procedures on # Academic Misconduct. current_pop = 330109174 year = int(inp...
ce34c71895130071c839d22e7870142f86581f9b
amoor22/patterns
/Bday cake pattern.py
444
3.78125
4
num = int(input("How big do you want the cake? ")) num2 = 2 for x in range(num): for y in range(2): for i in range(num * 2 - 2): print(' ', end='') for a in range(num2): print('*',end='') if y == 0: print() num2 += 4 num -= 1 print() # input: ...
d94e939cd9ba086bd9f6be15c9ede7b08b7a5435
ddeepak2k14/python-practice
/com/deepak/python/practice/sipmlePython.py
634
3.609375
4
__author__ = 'deepak.k' def triangle(base,height): area=1.0/2*base*height return area print(triangle(3,4)) def hangeTocelcius(faren): celcius=(5.0/9)*(faren-32) return celcius print(hangeTocelcius(30)) a=1 b=1 print(bool(a and b)) c="hello"=="hell" print(c) def greet(friend,money): if frien...
d8c5443040e9816466f47dbbb267ca582b19e4b2
cydu/datasci_course_materials
/assignment3/asymmetric_friendships.py
1,044
3.75
4
import MapReduce import sys """ The relationship "friend" is often symmetric, meaning that if I am your friend, you are my friend. Implement a MapReduce algorithm to check whether this property holds. Generate a list of all non-symmetric friend relationships. """ mr = MapReduce.MapReduce() # ========================...
3d29e425361ab009504e60ab9858c856992a14f5
KevinSarav/Python-Projects
/identityMatrix.py
458
3.9375
4
def generate_identity_matrix(n): identityMatrix = [] for emptyLists in range(0, n): identityMatrix.append([]) for column in range(0, n): for row in range(0, n): if column == row: identityMatrix[column].append(1) else: identityM...
8990c6297bbe769fb9bc33230bb57968a55e551b
SpookyJelly/Python_Practice
/leetcode/49_GroupAnagrams.py
1,618
3.84375
4
#49. Group Anagrams """ Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Constraints: 1 <= strs.length <= 104 0 <...
1b26a57161ceabd5958bd08a1e936ce79876fd97
akashvshroff/Puzzles_Challenges
/quick_sort.py
902
4.21875
4
def quick_sort(arr): """ A less memory efficient technique of comparison based sorting where a random pivot is chosen and the rest of elements are partitioned into 2 groups that are less than or equal to the pivot and greater than the pivot. At each partition, the pivot is placed in its final positi...
30415ea4c160a9fb1814380a6be11743c79b3842
Sarahjdes/ninjeanne
/portal_validation/draft_validation.py
2,467
3.515625
4
print "CSV validation" import csv # import csv module # file1 ele | fName | lName # file2 prof | fName | lName # file3 prog | title | group # file4 ele | group ## Unregristered students ## f = open('1.csv') csv_1 = csv.reader(f) ele_1 = [] for row in csv_1: ele_1....
7a9e78e6b93e0680774b4624d14bdd1a8ec0be7c
sungminoh/algorithms
/leetcode/solved/85_Maximal_Rectangle/solution.py
3,108
3.671875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2020 sungminoh <smoh2044@gmail.com> # # Distributed under terms of the MIT license. """ Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matr...
765ae4f49073c45d0f14d4b271ca1371f7594e39
fionaEyoung/Interdisciplinary-Research-Skills
/book/_build/jupyter_execute/4_simulation/simulation.py
9,984
4.28125
4
#!/usr/bin/env python # coding: utf-8 # # Workshop 4: Modelling and Simulation # # ## Introduction # # A [scientific model ](https://www.britannica.com/science/scientific-modeling) is a mathematical or conceptual representation of a real-world process or phenomenon. # # In the previous workshop, we simulated the m...
e55a31880ef831787b218d00dc8fa14d04adaecc
Okreicberga/programming
/labs/Topic09-errors/myFunctions.py
1,507
4.375
4
# Function Fibonacci that makes a numbers and returns a list containing a Fibonacci sequence of that many numbers. # Author: Olga Kreicberga import logging #logging.basicConfig(level=logging.DEBUG) def fibonacci (number): if number < 0: raise ValueError('number must be > 0') if number == 0: ...
eb8e63167b79515053341b36725226c037378c52
CiraciNicolo/AdvancedPython
/labs/es5-1.py
499
3.546875
4
import unittest import string def anagram(s): s = s.translate(None, string.punctuation).lower().replace(' ', '') return s==s[::-1] class FunctionsTests(unittest.TestCase): def test_anagram(self): self.assertEqual(False, anagram("Test")) self.assertEqual(True, anagram("I topi non avevano ni...
9a267fc6c8be6b751d2334c2f8e8fa6113d5ad7a
patricktuite/Learn-Python-The-Hard-Way-
/ex3.py
999
4.53125
5
# displays text about counting the chickens print "I will now count my chickens:" # displays the result of 25 plus 30 divided by 6 print "Hens", float(25 + 30 / 6) # displays the result of 100 minus the remainder of (25 times 3) divided by 4 print "Roosters", float(100.00 - float(25.00 * 3.00 % 4.00)) # displays tex...
4f70b06a2ebf6b73d90adadad70892936a37476c
bittubaiju/ccna-devnet
/sorting_list.py
557
3.921875
4
x=[] n = int(input('total num of elements: ')) for i in range(n): x.append(int(input('enter the element: '))) print('list is: ',x) already_sorted = True for i in range(n-1): #beacuse range starts from 0 for j in range(n-1-i): #so that j won't go upto last element as it is already sorted if x[j]>x[j+1]: ...
866d5d3e1bb5521fd39a515a6912736d5a7244ba
ericjsolis/danapeerlab
/scf/src/parameterchanger.py
10,163
3.5
4
#!/usr/bin/env python import string import re import logging from collections import namedtuple """Keys are function names which will be annonated. If you call ParameterChangerManager.get_current_changer from any of these function you will get a ParameterChanger that can change the parameters of the function in the...
3cbc08ba78894ba53982e15ff56c1dead819f76e
melission/Timus.ru
/1100_memory_limit.py
1,037
3.640625
4
# https://acm.timus.ru/problem.aspx?space=1&num=1100 # ru: https://habr.com/ru/post/455722/ # eng: https://habr.com/ru/post/458518/ import sys itemcount = int(input().strip()) toSortList = [] for i in range(itemcount): str_lst = input().strip().split() # print(len(str_lst)) str_lst[1] = int(str_lst[1]) ...
f9933925e47f793321777a0109bf652b55f0bebb
stnorling/Rice-Programming
/iipp/Week 8/quiz_ex_list_func.py
488
3.609375
4
class Point2D: def __init__(self, x=0, y=0): self.x = x self.y = y def translate(self, deltax=0, deltay=0): """Translate the point in the x direction by deltas and in the y direction by deltay.""" self.x += deltax self.y += deltay def __str__(self): ...
0ce0f9ba60d23daec2ebe98d7198dfa95b70bf58
henrikemx/PycharmProjects
/exercicios-cursoemvideo-python3-mundo3/Aula16/exerc077a.py
224
3.890625
4
# Dica do desafio 25 da Aula 09 do Mundo 1 nome = ('Adalberto Silva') print('Seu nome tem Silva ? Resp.: {}'.format('Silva' in nome)) print('-'*30) print(f'Seu nome tem Silva ? Resp.: {"Silva" in nome}') print('-'*30) print(f'A ')
c7d223c13698117491a160c40d8c37f6b189df79
Grande-zhu/CSCI1100
/LEC/lec20/lec20_ex_start.py
690
4
4
''' Template program for Lecture 20 exercises. ''' def linear_search( x, L ): pass # replace with your code if __name__ == "__main__": # Get the name of the file containing data fname = input('Enter the name of the data file => ') print(fname) # Open and read the data values in_file = op...
ff5cffd30b319c54ede5d80dd2a826fac02eae53
bluehat7737/pythonTuts
/56_classMethods.py
382
3.75
4
class Emp: no_of_leaves = 8 def __init__(self, name, lname): self.name = name self.lname = lname @classmethod def changeLeaves(cls, newLeaves): cls.no_of_leaves = newLeaves anshul = Emp("Anshul", "Choursiya") print(anshul.no_of_leaves) print(Emp.no_of_leaves) anshul.changeL...
40635d64b0648ebbb5954ab225083ce5cb8e8d85
mateenjameel/Python-Course-Mathematics-Department
/Object Oriented Programming/class_9.py
730
3.6875
4
class Employee: no_of_emps= 0 raise_amt = 1.04 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last +'@1992.com' Employee.no_of_emps += 1 def fullname(self): retu...
648aa0559e756d9e75bc0cb4d7c37f5a8f47d8af
GiovanaPalhares/python-introduction
/MaiorPrimo.py
383
3.53125
4
def primo(x): num = 2 while x % num != 0 and num <= x / num: num = num + 1 if x % num == 0: return False else: return True def maior_primo(x): if primo(x): return(x) else: while x > 2: i = 1 if primo(x-i): return ...
0d439847ff347aa32e5a4062dd9db1be2e0edf83
karthi007/dev
/BST.py
804
3.703125
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def sortedArrayToBST(self, nums): start = 0 end = len(nums)-1 return self.BST(start,end,nums) def BST(self,start,end,nums): if st...
1d5524a8559ec80286dbbbb87082300502fad988
momentum-team-4/examples
/py--objects-basics/simple_examples.py
405
3.765625
4
from typing import Generator def generatelines(fname: str) -> Generator: """ Safe iterator over the lines of a file. """ with open(fname) as genfile: for line in genfile: yield line.strip() if __name__ == "__main__": assert list(generatelines("students-names.txt")) == ['Clint'...
e1e797b0cc9828d3c238fa6ef01e23e1932a26c7
Jdicks4137/function
/decisions.py
1,516
4.34375
4
# Josh Dickey 10/5/16 # this program generates a random math problem in either addition, subtraction, or multiplication import random def maximum_value(): """this allows the user to insert the maximum value""" maximum = float(input("what is the maximum value?")) return maximum def correct_answer(problem...
8570c178224165e87e9f676a6c026692b990e816
sreyansb/Codeforces
/codeforces4Awatermelon.py
147
3.5
4
n=int(input()) flag=0 for i in range(2,n,2): if (n-i)%2==0: print("YES") flag=1 break if flag==0: print("NO")
907aa828b7acd78e06697c519b1f8919f0f89613
1325052669/leetcode
/src/data_structure/search/traversal_with_state.py
3,491
3.578125
4
from collections import defaultdict from typing import List # https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/ class Solution1466: def minReorder_bfs(self, n: int, connections: List[List[int]]) -> int: road = defaultdict(set) for src, dest in connections: ...
bec930c4510526ab6697e1e7ecc789cf25c0f02c
evertondutra/udemy
/Seçao04/exe03.py
133
4.15625
4
soma = 0 for c in range(3): n = int(input(f'Digite o {c+1}º número: ')) soma += n print(f'A soma dos números é {soma}.')
5bb1f54e7fb93d82dc8178f7515d93b99944db23
YashAgarwalDev/Learn-Python
/if condition3.py
118
3.84375
4
a = 10 b = 20 c = 30 if a < b or a < c or a == 10: print('a is either 10 or a is greather than b @nd c')
bde73b5aa05d62f5b530b7670aa1edac41ef4c72
borislavstoychev/exam_preparation
/exams_advanced/Python Advanced Retake Exam - 16 Dec 2020/problem_1.py
1,090
3.515625
4
from collections import deque def div_25(m_or_f): new_m_f = deque() while m_or_f: num = m_or_f.pop() if num % 25 ==0: try: m_or_f.pop() except IndexError: break continue new_m_f.append(num) return new_m_f def pri...
9023a90e3a5707ea7630fa7fc47f503f02fd7384
cukejianya/leetcode
/trees_and_graphs/matrix_01.py
1,402
3.5
4
class Solution: def updateMatrix(self, matrix): queue = [] self.row_len = len(matrix) self.col_len = len(matrix[0]) for x in range(self.row_len): for y in range(self.col_len): if matrix[x][y] == 0: queue.append((x, y)) e...
812ca27ac312b7cd9422a0a82662580d24511b2b
mohammaddanish85/Python-Coding
/Range Data type.py
512
4.375
4
# Program for Range Data type. # Range data type represents sequence of numbers. Numbers in range cannot be modified. r= range(10) # Create range number for i in r: print(i) # Print values from 0 to 9 (Total 10 numbers) r= range(2, 22 , 2) # Here range i...
efc60f37c7e2f8c598e4e6c292166c1193bc2aeb
Masheenist/Python
/lesson_code/ex27_Memorizing_Logic/ex27.py
1,978
4.59375
5
# Memorizing Truth Tables # ============================== # Write out the Truth Terms: # => and # => or # => not # => != (not equal) Write this with an exclamation point followed my an equals sign. # => == (equal) # => >= (greater-than-equal) # => <= (less-than-equal) # => True # => False print("The 'NOT' operator...
08472f23c61998aef40d7d69289c7e2a11601c52
PandaCoding2020/pythonProject
/Python_Basic/10 公共的方法/7 range()方法.py
143
3.890625
4
# 1-9 # for i in range(1,10,1): # print(i) # 1-10的奇数 # for i in range(1,10,2): # print(i) # 0-9 for i in range(10): print(i)
39ee454befe98c4d0e9b4936c27a23430f280d33
hcourt/practice
/fibo.py
733
3.546875
4
def nacci(a, b, n): if n == 0: return [] c = a + b return [c] + nacci(b, c, n - 1) def fibonacci_sequence(seed1, seed2, n): if n > 1: return [seed1, seed2] + nacci(seed1, seed2, n - 2) elif n == 1: return [seed1] else: return [] def fibonacci_number(seed1, seed2, n): return...
360b0832224f6f4be7a6fb797d9860ee17ae67fa
dbenny42/streaker
/streaker/task.py
739
3.59375
4
import datetime class Task: def __init__(self): self.taskid = "" # string uniquely identifying self.userid = "" # string uniquely identifying self.description = "" self.start = None # date when first completed self.end = None # date when last completed def get_streak(se...
dd3e80f399c54a0daaa082f4779bc790bbdbfb5f
bschatzj/Algorithms
/recipe_batches/recipe_batches.py
787
4.03125
4
import math def recipe_batches(recipe, ingredients): batches={} max_batches = 10000 for i in recipe: try: #floor devision!!!! WOW THIS TOOK ME WAY TOO LONG TO FIND!!! batches[i] = ingredients[i] // recipe[i] except: max_batches = 0 for i in batches.values(): if i < max_...
92b07c4090892bbbe601378cdcc4a0c8e6203afd
waynewu6250/LeetCode-Solutions
/257.binary-tree-paths.py
786
3.6875
4
# # @lc app=leetcode id=257 lang=python3 # # [257] Binary Tree Paths # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def binaryTreePaths(self, root: TreeNode) -> Lis...
688bd6b6b5b7a45de7213e056d7d06edea3ccf4c
Andoree/Python-Study
/20181112requests/task0.py
658
3.578125
4
import requests # download file # https://wikipedia.org/wiki/London def download_file_by_url(url): filename = url.split('/')[-1] print(filename) r = requests.get(url) # r.text f = open(filename, 'wb') f.write(r.content) # print(r.headers.get('content-type')) # менеджер контекста. При...