blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2709f78507de09c7bc7a812798ff1a3cfab829db
arabae/ALGORITHM
/SW Expert Academy/1948.py
543
3.53125
4
def kalender(first_month, first_day, second_month, second_day): days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] answer = 0 if first_month == second_month: answer = second_day-first_day + 1 else: answer += days[first_month-1] - first_day + 1 for j in days[first_month:secon...
a4851fc8ba496d155e85f2f106078e0a88cfb00e
StRobertCHSCS/fabroa-PHRZORO
/Working/PracticeQuestions/2_4_6_logical_operators.py
202
4.0625
4
number_1 = int(input("Enter the first number: ")) number_2 = int(input("Enter the second number: ")) if number_1 == number_2: print((number_1 + number_2) * 2) else: print(number_1 + number_2)
eb1946fc30366686020db1d74d881a6e7df6082a
JestemStefan/AdventOfCode2020
/10/10.py
1,477
3.609375
4
import cProfile def main(): processed_input = [] with open("10/Input.txt") as input_file: for line in input_file.readlines(): line = line.strip() processed_input.append(int(line)) processed_input.append(max(processed_input) + 3) processed_input ...
060029226c8cfa3018cbf785c73c57590052ec12
minseunghwang/algorithm
/programmers/2019 KAKAO BLIND RECRUITMENT 오픈채팅방.py
677
3.65625
4
def solution(record): answer = [] dict = {} for i in record: m = i.split() if m[0] == 'Change': dict[m[1]] = m[2] elif m[0] == 'Leave': answer.append([m[1],0]) elif m[0] == 'Enter': dict[m[1]] = m[2] answer.append([m[1],1]) ...
7a449cc09fe15f42e10ea92a5fe0c8bfbe24b386
shrikantpadhy18/interview-techdev-guide
/Algorithms/Searching & Sorting/Bubble Sort/bubble_sort.py
344
4.21875
4
def bubble_sort(arr): while True: swap_count = 0 for i in range(len(arr) - 1): if arr[i] > arr[i + 1]: arr[i], arr[i + 1] = arr[i + 1], arr[i] swap_count += 1 if swap_count == 0: break return arr if __name__ == "__main__": arr = [1, 6, 2, 8, 2, 3] print(f"sorted array ...
3732f70b9cc39e3b4734ff6f8804cb4552de3988
catalinc/advent-of-code-2017
/day_5.py
1,314
3.609375
4
# Solution to https://adventofcode.com/2017/day/5 import unittest import sys def count_jumps(program, max_offset=0): jumps, pc = 0, 0 while 0 <= pc < len(program): offset = program[pc] if not max_offset: program[pc] += 1 else: if abs(offset) >= max...
2b64e91b6f1d9749e81d6ee2b8c96ce2b29b9b7a
GeoregTraynro/Homeauto-stuff
/button.py
377
3.5
4
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BCM) GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)#button GPIO.setwarnings(False) if GPIO.input(20) == False: print('Button Pressed') time.sleep(0.2) GPIO.setup(16, GPIO.OUT) GPIO.output(16, GPIO.HIGH) sleep(30) # Waits for hal...
54fdc9658248db4e3b20de31283ae23f3030aaa6
kopok2/Algorithms
/DynamicProgramming/NonDecreasingNDigits.py
468
3.515625
4
# coding=utf-8 """Non decreasing n-digits dynamic programming solution Python implementation.""" def ndnd(n): dp = [[0] * 10 for x in range(n + 1)] for i in range(10): dp[1][i] = 1 for digit in range(10): for l in range(2, n + 1): for x in range(digit + 1): dp[l...
d489ee67d3e15943303e13359bfd8eef7159f38d
SupremeSadat/Scientific-Computing
/time calculator/time_calculator.py
1,148
3.5625
4
def add_time(start, duration,startDay=''): time, period = start.split() hour, minutes = map(int, time.split(":")) if period == 'PM': hour = hour + 12 daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] newDay = '' hourAdded, minutesAdded = map(int...
42878f16c964b8120d43b9021ed71275103b62c4
gabriellaec/desoft-analise-exercicios
/backup/user_301/ch20_2019_03_12_22_28_56_298536.py
118
3.671875
4
a=input("qual eh seu nome?) if a==Chris return "Todo mundo odeia o Chris" else return ("Olá,{0}".format(a))
bc687d1a0315519b6ea181da7e6954e24a24c2db
Deekshith76/Cpp-programs
/python/find_binary.py
234
3.859375
4
def findBinary(num, res=""): if num == 0: return res res = str(num%2) + res return findBinary(num//2, res) num1 = 233 num2 = 32 num3 = 156 print(findBinary(num1)) print(findBinary(num2)) print(findBinary(num3))
bd4065b6272210517c3ab53f5b8101d973f4f4a9
nik24g/Python
/time module.py
729
4.0625
4
import time # import datetime initial = time.time() # this function is used to get total ticks with the help of ticks we can calculate programme execution time print(initial) list1 = ["Nitin", "Shayna", "Nik", "Kimmi"] for a in list1: print(a) print(f"For loop ran in {time.time() - initial} seconds") print("\nw...
6b059fad2b6dda78c3766a8d20f6f23316fcfcd6
dani3l8200/100-days-of-python
/day5-loops/exercise5.4/main.py
274
3.59375
4
for fizz_buzz_game in range(0, 101): if fizz_buzz_game % 3 == 0 and fizz_buzz_game % 5 == 0: print('FizzBuzz') elif fizz_buzz_game % 3 == 0: print('Fizz') elif fizz_buzz_game % 5 == 0: print('Buzz') else: print(fizz_buzz_game)
d9fe554a95153c9928aa65a6ac0b154b18594cc0
mschober/algorithms
/LinkedList/python/singly_linked_list/remove_duplicates.py
1,753
3.609375
4
class LL: def __init__(self, data, next=None): self.data = data self.next = next def append(self, node): node.next = self #self.next = node return node def __repr__(self): #print 'before loop' curr = self rtr = str(curr.d...
929340da89139f302500938bbe6fdf38ef9b6a96
DenisYavetsky/PythonBasic
/lesson8/task7.py
1,178
3.921875
4
# 7. Реализовать проект «Операции с комплексными числами». Создайте класс «Комплексное число», реализуйте перегрузку # методов сложения и умножения комплексных чисел. Проверьте работу проекта, создав экземпляры класса (комплексные числа) # и выполнив сложение и умножение созданных экземпляров. Проверьте корректность по...
72d9d486034a6a03eb8c39e935791c5df90f6bbf
Mahesh552001/RSA-encryption-and-decryption
/RoughPy/4_rev_vowel.py
415
3.8125
4
#4-Reversing the Vowels def check_vowel(s): if (s=="a" or s=="e" or s=="i" or s=="o" or s=="u"): return True print("Enter the string:") string=str(input()) arr=[] vow_arr=[] for i in string: arr.append(i) for i in string: if check_vowel(i): vow_arr.append(i) for i in range(l...
2769731ff8b4ea9ddb88e7c29c95df4460f0c8d3
ksoltan/invent_with_python
/nameV2.py
743
4.125
4
# This gives you a new name import random import time def intro(myName): print('Hi, '+myName+'. Would you like a new name?') new=input() print('Hello, what is your name?')#This is where everything begins. myName=input() intro(myName) def newName(name): print('Well, '+myName+', your new name is '+name+'.'...
cfe654ca48b920038864bf8f881c6c522355c2af
lukadimnik/test-data-creator
/query_timer.py
676
3.5625
4
# script to test execution times of queries import sqlite3 import random import time # open database conn = sqlite3.connect('Movies.sqlite') cur = conn.cursor() count = 0 start_time = time.time() while count < 100: count = count + 1 random_year = random.randint(1900, 2000) # result = cur.execute( # ...
8cc7776e6788bad1fb5ce63630521a094c39ca82
CPE202-PAR/project-1-enzosison
/bears.py
756
3.59375
4
# int -> booelan # Given integer n, returns True or False based on reachabilty of goal def bears(n): by_2 = n % 2 by_3 = n % 3 by_4 = n % 4 by_5 = n % 5 if n < 42: return False elif n == 42: return True if by_2 == 0: test = bears(n - n/2) if test ...
e1ec43c6fdb2a3b47b31b64680d91cf3a9a5d4c0
LekhanaWhat/Launchpad-assignments
/program3.py
151
3.859375
4
a_list=[1,1,2,4,5,3,6,3] elem=3 b_list=[] for i in range(len(a_list)): if a_list[i]==elem: b_list.append(i) print(b_list)
2baf5b29ab47526061112932bbff36b751e4f086
dbswl4951/programmers
/programmers_level2/타겟 넘버_dfs.py
613
3.625
4
result=0 def dfs(idx,target,numbers,val,n): global result #target에 도달하면 방법의 수(result)+1하고 return if n==idx and target==val: result+=1 return #numbers의 모든 수를 사용했지만 target을 만들지 못했을 때 바로 return if n==idx: return #numbers의 모든 수를 아직 다 사용하지 않았다면 dfs(idx+1,target,numbers,val+numbers...
6dd32ff92423c42594a07cc8d23036abdd6d7419
devashish9599/PythonPractice
/s.py
397
3.609375
4
a=input("enter the string") l=input("enter the second string") z=len(l) b=input("enter the character to be searched in first string") count2=0 c=input("enter the character to be searched in second string") x=len(a) count=0 for i in range(0,x): if(a[i]==b): count=count+1 print count,"times is",b for j...
5df5e1d4984f428280d63318ee5c52d90c51a3c4
telnettech/Python
/ForLoops.py
1,942
4.34375
4
# Columns: Name, Day/Month, Celebrates, Age BIRTHDAYS = ( ("James", "9/8", True, 9), ("Shawna", "12/6", True, 22), ("Amaya", "28/2", False, 8), ("Kamal", "29/4", True, 19), ("Sam", "16/7", False, 22), ("Xan", "14/3", False, 34), ) # Problem 1: Celebrations # Loop through all of the people in B...
b1072da3306320b119b8ead8fe386b41eabf11e6
guhaigg/python
/month01/day07/homework/exercise04.py
1,274
3.921875
4
""" 彩票:双色球 红色:6个 1--33之间的整数 不能重复 蓝色:1个 1--16之间的整数 1) 随机产生一注彩票(列表(前六个是红色,最后一个蓝色)) 2) 在终端中录入一支彩票 要求:满足彩票的规则. """ import random # 1) 随机产生一注彩票(列表(前六个是红色,最后一个蓝色)) list_ticket = [] # 前六个红球 while len(list_ticket) < 6: number = random.randint(1, 33) if number not in list_ticket: list...
5a629500d2eb8815cc824f210a2a0d4f4c04bf27
nihathalici/Break-The-Ice-With-Python
/Python-Files/Day-2/Question-6-alternative-solution-5.py
953
3.84375
4
""" Question 6 Question: Write a program that calculates and prints the value according to the given formula: Q = Square root of [(2 _ C _ D)/H] Following are the fixed values of C and H: C is 50. H is 30. D is the variable whose values should be input to your program in a comma-separated sequence. For example Let ...
97ae49648ffdfb1a94fb7a9e92fa5a4b2975f622
jeff87b/Python-module-1
/Day 1-5/029.py
1,025
3.90625
4
import turtle myTurtle = turtle.Turtle() averageTemperatureList = [3, 4, 6, 9, 14, 17, 18, 17, 8, 2] numberOfRainyDays = [22, 19, 19, 18, 17] def drawRectangle(): for i in range(0, len(averageTemperatureList)): myTurtle.left(90) myTurtle.forward(20) myTurtle.left(90) myTurtle.forwa...
d89ce191766063948943bc7d369a42b417f69f45
emerisly/python_data_science
/list.py
889
4.0625
4
# lists are like array # is not sorted x = [3, 5, 4, 9, 7, 10] print(x) print(x[0]) print(x[3]) y = ['max', 1, 15.5, [3, 2]] print(y[3]) print(len(y)) y.insert(1, 'tom') print(y) y.remove('tom') print(y) del y[0] print(y) # pop removes the last index of a list print(y.pop()) print("pop", y) del y # e...
0c98b289ce2e931818603439e0a396ea917b857c
gauravkunwar/PyPractice
/PyExamples/dict.py
203
3.953125
4
dict={} dict[1]="This is one" dict[2]="This is two" tinydict= {"name": "Ram","value": 3 ,"address": "kathmandu"} print dict[1] print dict[2] print tinydict print tinydict.keys() print tinydict.values()
c32075aa79a491d657066446eb64392f048390d1
Anupmor1998/DSA-in-python
/Array/28.py
415
3.75
4
# Triplet Sum in Array def find3Numbers(A, n, X): A.sort() for i in range(n-2): low = i + 1 high = n - 1 while low < high: if A[i] + A[low] + A[high] == X: return "Yes" elif A[i] + A[low] + A[high] < X: low += 1 else...
1dccba708fe89f8852b19ed0a58b542952fdbe89
antran2123153/AssignmentPPL
/src/main/d95/utils/AST.py
6,769
3.703125
4
from abc import ABC def printlist(lst): return f"[{','.join([str(x) for x in lst])}]" def printIfThenStmt(stmt): return f"({str(stmt[0])},{printlist(stmt[1])})" class AST(ABC): pass class Program(AST): # const: List[ConstDecl] # nonconst: List[NonConstDecl] def __init__(self, const, nonc...
bdf97fa94f977e6adc8385a1b9ce2689f28a972f
letientai299/leetcode
/py/14.longest-common-prefix.py
1,776
3.65625
4
# # @lc app=leetcode id=14 lang=python3 # # [14] Longest Common Prefix # # https://leetcode.com/problems/longest-common-prefix/description/ # # algorithms # Easy (33.00%) # Total Accepted: 417.5K # Total Submissions: 1.3M # Testcase Example: '["flower","flow","flight"]' # # Write a function to find the longest comm...
bbe1e16a36825859cfac1277b9e831911e8b5f8e
wudongdong1000/Liaopractice
/practice_5.py
257
3.953125
4
#计算若干个数的积 def product(*numbers): if not numbers: return '请输入值' pro=1 for i in numbers: pro=pro*i return pro print(product(*map(int,input('请输入数值,用空格隔开:').split())))
fb569c14e3255a94a829677d3a81cb54cd2be96a
rfgrammer/NeighborPlus
/Day2.py
1,681
3.984375
4
# # IF statements # x = int(input("Please enter an integer:")) # if x < 0: # x = 0 # print('Negative changed to zero') # elif x == 0: # print('Zero') # elif x ==1: # print('Single') # else: # print('More') # # # FOR statements # words = ['cat', 'window', 'defenestrate'] # for w in words: # print...
c56c02ffaf39e82baa9afa7b3e4078e282b62405
mikkelmilo/kattis-problems
/lessThanTwoPoints/kemija.py
264
3.625
4
x = [x for x in input().split()] vowels = "aeiou" res = [] for word in x: i = 0 r = '' while i < len(word): r += word[i] if word[i] in vowels: i += 3 else: i += 1 res.append(r) print(' '.join(res))
2b084824c0bf534aa66377726aad7349ac7500e2
FinnG/pychess
/main.py
15,707
3.84375
4
#!/usr/bin/env python import operator import string class Direction(object): STRAIGHT = [[1, 0], [0, 1], [-1, 0], [0, -1]] DIAGONAL = [[1, 1], [1, -1], [-1, 1], [-1, -1]] KNIGHT = [[1, 2], [-1, 2], [1, -2], [-1, -2], [2, 1], [-2, 1], [2, -1], [-2, -1]] ALL = STRAIGHT + DIAGONAL class Col...
b905432dbcca308d3624de9cc0194222a2fbe72d
BramvdnHeuvel/Batteryboys
/classes/house.py
1,010
4.03125
4
class House: """ The house class represents a house in the smart grid. Each house has an id, an x and y coordinate which determine the location of the house in the grid, and an output. """ def __init__(self, id, x, y, output): self.id = id self.x = x self.y = y ...
21fc04958f040c9e4e8faaf606877f13a20ed4ae
satoshi-n/tls-warning-collector
/misc/progress_bar.py
1,563
3.53125
4
from misc.setup_logger import logger def set_progress_percentage(iteration, total): """ Counts the progress percentage. :param iteration: Order number of browser or version :param total: Total number of browsers or versions :return: Percentage number """ return float((iteration + 1) / tota...
d2af3f9c481bf5d868e446c186eb9c48efd75157
rdoherty2019/Computer_Programming
/forwards_backwards.py
1,024
4.1875
4
#setting accumulator num = 0 print("Using while loops") #Iterations while num <31: #If number is divisably by 4 and 3 if num % 4 == 0 and num % 3 == 0: #accumalte num += 3 #continue to next iterations continue #IF number is divisable by 3 print if num % 3 == 0 : ...
3c228c027a0f47c6a6d143caaa1dd359010de8b0
sumairhassan/Python-Basics
/lessons/03_loops.py
953
4
4
# For loops #ninjas = ['ryu', 'crystal', 'yashi', 'ken'] """for ninja in ninjas: print(ninja)""" #for ninja in ninjas[1:3]: # print(ninja) """for ninja in ninjas: if ninja == 'yashi': print(f'{ninja} -- black belt') else: print(ninja)""" """for ninja in ninjas: if ninja == 'yash...
e852721ae106749dffb22a2a86d1f38bdc69a238
ChihChaoChang/Leetcode
/035.py
1,328
4.1875
4
''' Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Here are few examples. [1,3,5,6], 5 → 2 [1,3,5,6], 2 → 1 [1,3,5,6], 7 → 4 [1,3,5,6], 0 → 0 ...
43d7cd8867e35b972ec49054e32fff4528878e80
ankitsingh03/code-python
/geeksforgeek/Basic Programs/compund_interest.py
181
3.65625
4
p = float(input("enter principle : ")) r = float(input("enter rate : ")) t = float(input("enter time :")) compound = p*(1+r/100)**t print(f"your compound interest is : {compound}")
a2b0a52ab313a68657bddeaf965b130b7beda59d
fazil91289/Udacity-Bikeshare-Project
/bikeshare.py
11,819
4.1875
4
import pandas as pd from datetime import datetime from datetime import timedelta import time import datetime city = '' while city.lower() not in ['chicago', 'new york', 'washington']: city = input('\nHello! Let\'s explore some US bikeshare data!\n' 'Would you like to see data for Chicago, New...
37b8bf20e294148cd754976af7f1ab884ce79d6f
fcu-d0449763/cryptography
/sha-1/base.py
2,308
3.671875
4
#!/usr/bin/env python #-*- coding:utf-8 -*- # convert a hex-string to it's bin code # return the bin code # retury type: str def hex_bin(hex_str): """convert hex-str to it's bin code """ hex_bin_map={ '0':'0000', '1':'0001', '2':'0010', '3':'0011', ...
4a33f2147a5eedbbff2fe23b962a1a8d7baede1d
nehabais31/LeetCode-Solutions
/sqrt_usng_binary_search.py
300
3.703125
4
# -*- coding: utf-8 -*- """ Finding the square root using Binary Search Time Complexity: O(log n) """ x = 4 low = 0 high = x + 1 while low < high: mid = low + (high - low) // 2 if mid * mid > x: high = mid else: low = mid + 1 print( low -1 )
86107d7f7576f016ec0a5ad2190ebda672beab8c
agforero/SI-PLANNING
/Plans/CSCI121S2AGF-3.5.py
2,530
4.375
4
''' While loops. Finally. 1. Write a function to print the square of all numbers from 0 to 10. 2. Write a function to print the sum of all EVEN numbers from 0 to 100. 3. Write a function to read in three numbers a, b and c, and check how many numbers between a and b are divisible by c. 4. Write a function that...
9e6a4d6fdbd369c43ce8fe6f1c32a1795e0d2441
ssw02238/algorithm-study
/programmers_단속카메라/answer.py
407
3.640625
4
def solution(routes): routes.sort(key=lambda x:x[0]) answer = 0 # [[-20, -15], [-18, -13], [-14, -5], [-5, -3]] while routes: tmp = routes.pop(0) while routes: if routes[0][0] <= tmp[1]: routes.pop(0) else: break answer += 1...
0c2c19ff5ca4af7f88b5eb6817adb64a457c0fa2
EwertonLuan/Curso_em_video
/45_jo_ken_po.py
1,499
3.515625
4
from random import choice from time import sleep print('\033[1;34m=+=\033[m' * 10 + '\n JO KEN PO\n' + '\033[1;34m=*=\033[m' * 10) print('''Sua opções [1] pedra [2] papel [3] tesoura''') esco = int(input(' Escolha a sua jogada: ')) lista = ['pedra', 'papel', 'tesoura'] computa = choice(lista) print('\033[1;36mJO KEN ...
570ee5200a2372314fc276654eee553b3eed3a1f
YanHengGo/python
/39_OOP/lesson.py
382
4.03125
4
#类的共有方法 #类的私有变量 class CC: def setXY(self,x,y): self.x=x self.y=y def printXY(self): print(self.x,self.y) dd=CC() print(dd.__dict__) print(CC.__dict__) print('----------') dd.setXY(4,5) print(dd.__dict__) print(CC.__dict__) print('删除CC后printXY方法同样被调用----------') del CC dd.printXY() pri...
0f44ecb5b55370f96239847af8af98447cc45d2e
EdytaBalcerzak/python-for-all
/04_chapter/cwiczenia_z_petla_for.py
134
3.6875
4
print("cwiczenia z petla for\n\n\n") for i in range (10): print("Kocham Cie, ") input("\n\n\nAby zakonczyc program , nacisnij Enter")
82bf0cf4a5d549eabe9ff8293d5aaea04d9e2723
jacindaz/bradfield_algos
/algos/duplicates.py
1,472
3.90625
4
from collections import Counter import random import time def have_duplicates_n_squared(array): for index, item in enumerate(array): for index2, item2 in enumerate(array[(index+1):]): if item == item2: return True return False def have_duplicates1(array): """ O(n) sol...
9e2575781320fc63e65f8ccb9adaa9b7022eae5b
leticiassenna/POO2_trab1
/capoeira/model/cgt/Turma.py
391
3.53125
4
__author__ = 'Leticia' class Turma: def __int__(self): self.nome = "" self.turno = "" self.horario = "" self.dia_semana = "" self.rg_aluno = [] self.rg_professor = "" self.cadastro_reserva = list() self.cadastro_reserva.append(self.rg_aluno[len(self.c...
9543019bfff4ce6c96c5ccf5ecbe5c49f3665b08
jmstudyacc/python_practice
/fail_cakes.py
585
3.984375
4
dollars_cupcakes = int(input()) cents_cupcakes = int(input()) num_cupcakes = int(input()) dollar_sumcakes = dollars_cupcakes * num_cupcakes cents_cupcakes = cents_cupcakes * num_cupcakes monetary_cents = cents_cupcakes / 100 cents_to_dollars = monetary_cents // 1 remaining_cents = cents_cupcakes % 100 total_dollars...
0ec182b0b1390ce40dddc935fb147b93ca5b1e66
khanprog/Python-Stuff
/char_count.py
551
4.09375
4
""" Code for counting number of characters in a sentence. """ sentence = input("Enter a sentence here : ") sentence = sentence.lower() words = list(sentence) count_words = {} listCount = sentence.split(" ") print() print("Total Words: " + str(len(listCount))) print() for word in words: characters = list(word) fo...
5967427b6cc91d4d4c09ae7d66b5bf5f08ef89e9
funnyuser97/HT_1
/task8.py
299
4.1875
4
# 8. Write a script to replace last value of tuples in a list. mylist=[(1,2,3),(3,4,5),(6,7,8)] number=int(input('Input value for change :')) print('Input : ',mylist) for i in range(len(mylist)): tmp_list=list(mylist[i]) tmp_list[-1]=number mylist[i]=tuple(tmp_list) print('Output : ',mylist)
c8193691212960d3ceaf598eaca43ad2808bc201
wesenu/mit_6.00.1x
/Practice/collatz.py
1,238
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 21 10:52:44 2019 @author: dileepn Playing with the Collatz conjecture. """ import matplotlib.pyplot as plt def collatz(n, tries): """ This function implements the collatz conjecture. Start with a number, n. - If n is even, halve it ...
37d51ccd6463150fd75376ea7be24e1be5eb0f10
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/hrnali002/question2.py
2,521
4.0625
4
#The 30 second food on floor program #Alison Hoernle #HRNALI002 #8 March 2014 print("Welcome to the 30 Second Rule Expert") print("------------------------------------") print("Answer the following questions by selecting from among the options.") see = input("Did anyone see you? (yes/no)\n") if (see == 'yes'): who...
c5d666108c8892968cd317c066294772c56abd33
amani021/python100d
/day_57.py
799
4.65625
5
#-------- DAY 57 "regular expressions (regEx)1" -------- import re #Built-in module for RegEx # You can by RegEx searching a specified pattern from a string & check if it exist or not print("Lesson 57: Regular Expressions (RegEx) 1") txt = "This lesson is so important to understand it" print(txt + "\n----------------...
ee9d46ed3be2c96249346e0413d2b2e6986d8746
Ahuang1158/TurtleArtDesign
/myShape.py
810
3.640625
4
def square( t, distance ): for times in range(4): t.forward(distance) t.left(90) def triangle( t, distance ): for times in range(3): t.forward(distance) t.left(120) def pentagon ( t, distance): angle=360/5 for times in range(5): t.forward(distance) ...
81df80f8a2c91279ad4c6d14069b07cf6246898f
mridulrb/Basic-Python-Examples-for-Beginners
/Programs/MyPythonXII/Unit2/PyChap02/empdisp.py
1,022
4.15625
4
# File name: ...\\MyPythonXII\Unit1\PyChap02\empdisp.py # Accessing employee information using class class Employee: # Class variables empcode = "" empname = "" empdesig = "" empbasic = 0 # Constructor called when creating an object of class type def __init__(self, ecode, ename, ede...
f86f63b127ed1f45defe3164b15512b560dadc11
jiajiabin/python_study
/day11-20/day17/06_协程.py
291
3.875
4
def function(n, s): for i in range(n): print(s) yield True yield False i1 = iter(function(5, "hello world!")) i2 = iter(function(6, "good morning!!")) ret1 = ret2 = True while ret1 or ret2: if ret1: ret1 = next(i1) if ret2: ret2 = next(i2)
dcc0c2437211e471c00fd73b2bb25ea3c5a25a32
evbeda/games2
/guess_number_game/test_guess_number_game.py
1,593
3.609375
4
import unittest from guess_number_game.guess_number_game import GuessNumberGame class TestGuessNumberGame(unittest.TestCase): def setUp(self): self.game = GuessNumberGame() self.game._guess_number = 50 def test_initial_status(self): self.assertTrue(self.game.is_playing) def test...
699593147f6382fa46ef364eaff01ad3a747ad41
LimaXII/CPD-Laboratorios
/Laboratório 1/lab1.py
8,240
3.515625
4
#Laboratorio 1 - CPD: #Nomes: Luccas da Silva Lima e Bruno Longo Farina #Turma: B #biblioteca necessaria para cronometrar o tempo. import time #vai criar uma lista onde vai ser posto o texto antes de ser escrito no arquivo textinho = [] #mesma ideia da outra variavel textinho2 = [] #funcao que define qu...
e2cb553c1d23f2f3da65a1052ee290237dd6c1ce
fern17/algorithms_python
/sorting/bubble_sort.py
171
3.859375
4
def bubble_sort(v): for i in range(0, len(v)): for j in range(i+1, len(v)): if v[i] > v[j]: v[i], v[j] = v[j], v[i] return v
8d2377b49c58c975761d0fe014d8224fdd5ee8ee
aniket134/myCoding
/python/class_constructor.py
181
3.828125
4
class My_class(): def __init__(self, name): self.name = name print('inside My_class: ' + self.name) I1 = My_class('sall') I2 = My_class('bill') print(I1.name) print(I2.name)
e52e2085cccb9ac162fa3b8a22c8f4a6f3ef5f40
Sandoval-Angel/Learning-to-Code-Py
/Udemy: 100 Days of Code Challenge/Day 4.py
2,228
4.0625
4
from random import randint from time import sleep rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ____...
b795a7eb1156a42996df907e8bf50f35ac504e07
nitishgupta/qdmr
/analysis/test_prog_lisp.py
5,795
3.515625
4
from typing import List from parse_dataset.parse import (qdmr_program_to_nested_expression, nested_expression_to_lisp, remove_args_from_nested_expression) def lisp_to_nested_expression(lisp_string: str) -> List: """ Takes a logical form as a lisp string and returns a nested ...
78516228051f3909522ff569d36a90ed05e837bb
lucy9215/leetcode-python
/88_mergeSortedArray.py
783
3.9375
4
class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ while m>0 and n>0: if nums1[m-1...
15352584fbdce193854661aacf3b73826e716db8
paweldunajski/python_basics
/12_If_Statements.py
462
4.25
4
is_male = True if is_male: print("You are a male") is_male = False is_tall = False if is_male or is_tall: print("You are male or tall or both") else: print("You are not a male nor tall ") if is_male and is_tall: print("You are male and tall") elif is_male and not is_tall: print("You are male bu...
2f473f094f575d4176b1beda3503b96214780e2d
guywine/Python_course
/Exercises/09_tests/test_intadd.py
1,566
3.53125
4
import pytest from intadd import intadd def intadd(num1: int, num2: int) -> int: """Adds two numbers, assuming they're both positive integers. Parameters ---------- num1, num2 : int Positive integers Returns ------- int Resulting positive integer Raises ------ ...
69e58218827f49d3ffdb68a7213b542eff5791c5
kotegit2020/Python-Practice
/strdict.py
156
3.765625
4
str1 = "koti" mydict = { } for x in str1: if x.lower() in mydict: mydict[x.lower()] += 1 else: mydict[x.lower()] = 1 print(mydict)
b2c0db85d44b8eab0c013975f22c4d6b34c98f5e
AlejoCasti/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
235
3.546875
4
#!/usr/bin/python3 """ Get number of lines """ def number_of_lines(filename=""): """ number of lines function """ with open(filename, 'r') as fil: idx = 0 for i in fil: idx += 1 return idx
7e8500189de257c5cc988d1b5cbcceed6a274582
pyskills/Python-Programming
/rock_paper_scissor/basic2.py
902
4.09375
4
import random prompt = 'Enter your choice:\nR or r for rock\nP or p for paper\nS or s for scissors\nQ or q to quit\n' out_template = 'you {} against the computer' while True: # infinite loop till break user = input(prompt).lower() # lower case users input if user == 'q': break result = 'lose' ...
abd002c718c2e42e2ede6668839d6db43f538f3d
linuxfranklin/benjamin
/Days_calculator.py
298
3.609375
4
days=365 weeks=52 months=12 life_span=65 age_now=int(input("Enter your age :")) left_years=life_span-age_now left_months=left_years*months left_weeks=left_months*weeks left_days=left_months*days print(f"months to live : {left_months}, weeks to live : {left_weeks}, days to live : {left_days}")
cf3f9026197fcb0abc7c8b0f8028671b3f7fa29f
ushodayak/ushodaya
/area of circle using math
106
4.125
4
import math r = float(input("Enter the radius of the circle: ")) area = math.pi* r * r print("%.2f" %area)
996d02a5c96343f9401e0fd88d00059bfa04e75f
aaronsellek/w3-pathfinder-aaronsellek
/w3-pathfinder-aaronsellek/pathfinder.py
2,969
3.875
4
from PIL import Image, ImageDraw class Map: #creating a class for the map itself def __init__(self, filename): self.elevations = [] #creating the empty list for elevations with open(filename) as file: for line in file: self.elevations.append([int(e) for e in lin...
73e88332d5ab130a10286bd1da8430e7dc50d04b
Ann050/create
/2020-05-28 定义一个求平方和的函数.py
480
3.875
4
#------------------------------------------------------------------------------- # Name: 定义一个求平方和的函数 # Purpose: # # Author: chenw_000 # # Created: 28/05/2020 # Copyright: (c) chenw_000 2020 # Licence: <your licence> #------------------------------------------------------------------------...
a3ec2b0a3bd6f1d9741dbe019eb7111d65838d30
Amissan/prepaConcours
/td1/expr/expr.py
1,007
3.9375
4
from fractions import Fraction def calcul(expr): pile=[] val1=0.0 val2=0.0 for e in expr: if e!="+" and e!="-" and e!="*" and e!="/": pile.append(Fraction(e)) else: try: val1=pile.pop() val2=pile.pop() except: ...
786038f6e5eb25f5597be10b814ebbfdb49718ab
FranckCHAMBON/ClasseVirtuelle
/Term_NSI/devoirs/4-dm2/Corrigé/S5/E9.py
1,514
3.609375
4
""" Prologin: Entraînement 2003 Exercice: 9 - Puzzle https://prologin.org/train/2003/semifinal/puzzle """ nb_lignes_pièce = nb_colonnes_pièce = 4 nb_lignes_puzzle = nb_colonnes_puzzle = 10 pièce = [] puzzle = [] for ligne in range(nb_lignes_pièce): entrée = list(map(int, list(input()))) pièce.app...
c7636372d827a7b3c98b181ca92dc2add492c5c0
queryharada/lesson
/p238-07.py
161
3.734375
4
N = 10 Sum = 0 K = 0 while (K < N): K = K + 1 Sum = Sum + K print('loop invariant:N({0}) < K({1}) = {2}'.format(K, N, K < N)) print('Sum = ', Sum)
b8bf41baa2f06240a50372ebd36717678605dafe
pvargos17/python_practice
/week_02/labs/03_variables_statements_expressions/Exercise_08.py
475
4.375
4
''' Celsius to Fahrenheit: Write the necessary code to read a degree in Celsius from the console then convert it to fahrenheit and print it to the console. F = C * 1.8 + 32 Output should read like - "27.4 degrees celsius = 81.32 degrees fahrenheit" NOTE: if you get an error, look up what input() returns! ''' ...
0f77f2f030c7e1e07ef38e2cb37e0fc211f19017
campbellmarianna/Tweet-Generator
/2ndOrderMarkovChain.py
1,944
3.53125
4
from dictogram import Dictogram # Inspired by Alexander Dejeu from pprint import pprint import random from sample import * text = "one fish two blue fish fish red fish blue red fish END" texts_list = text.split() def make_higher_order_markov_model(order, data): """Creates a histogram""" markov_model = dict() ...
e0c87b750ca3fe8871aa2512269da40bf2f6540c
Rnazx/Assignment-08
/Q1.py
3,956
3.796875
4
import library as rands import matplotlib.pyplot as plt import math figure, axes = plt.subplots(nrows=3, ncols=2)#define no. of rows and collumns RMS = [] Nroot = [] l = 100# no. of iterations N = 250# start from N=250 i=1 while (i<=5): print("**************************************************************...
a17d8f997943be292fab12a66b9a2994c997d000
ShruBal09/Python-Combat
/Extended_game.py
12,563
3.75
4
# coding: utf-8 # !/usr/bin/env python """ The Extended game program implements medics and expanded army, it generates a 2 Player/Commander game that allows the user to pick which player he wants to use first to build his army. An army can consist of a maximum of 10 units that can be purchased in the range ...
1484ac000332ca88c56a3c6775c846572a68ef1e
salonikalsekar/Python
/programs/compute.py
184
4.21875
4
# Problem Description # The program takes a number n and computes n+nn+nnn. # Problem Solution n = int(input("Enter the number: ")) print(n + n**2 + n**3) # time complexity -> O(1)
bc619189eb27000a6d84f9734b46947aa4a904db
arieldeveloper/Salary-Predictor
/salary_project.py
1,718
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Feb 25 10:46:15 2018 @author: arielchouminov """ # Data Preprocessing Template # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('/Users/arielchouminov/Deskt...
b112f6d620e7220e2ad38b90214f2d8fdfd81caa
roiei/algo
/leet_code/350. Intersection of Two Arrays II.py
1,359
3.5
4
import time from util.util_list import * from util.util_tree import * import copy import collections from typing import List class Solution: def intersect(self, nums1: [int], nums2: [int]) -> [int]: if len(nums1) > len(nums2): long = nums1 short = nums2 else: ...
1772822afb1897d64761a1ef1975bdb3269b7ec6
shouya/thinking-dumps
/discrete-optimization-2/week4-tsp/solver.py
1,515
3.6875
4
#!/usr/bin/python # -*- coding: utf-8 -*- import math from collections import namedtuple Point = namedtuple("Point", ['x', 'y']) def length(point1, point2): return math.sqrt((point1.x - point2.x)**2 + (point1.y - point2.y)**2) def solve_it(input_data): # Modify this code to run your optimization algorithm ...
6420dcdd387bae72fa29696f7949cc47c59c3468
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/ddnami001/question1.py
245
4.15625
4
#Amitha Doodnath #DDNAMI001 #24/03/2014 #Programme to print user defined rectangle height=eval(input("Enter the height of the rectangle:\n")) width=eval(input("Enter the width of the rectangle:\n")) for i in range(height): print("*"*width)
b8f704d33c73a16879e71f283fe019726bb6e5b0
fernandojsmelo/Python---Curso-Completo
/exercicio5_16.py
606
3.8125
4
valor = float(input("Digite o valor a pagar: ")) cedulas = 0 atual = 100 apagar = valor while True: if atual <= apagar: apagar -= atual cedulas += 1 else: print("%d cedula(s) de R$ %3.2f"%(cedulas,atual)) if apagar == 0: break if atual == 100: atual = 50 elif atual == 50: atual = 20 elif atual ...
0bb1300aee1927315f6f9f555624d1e80e661ed8
josivantarcio/Desafios-em-Python
/Desafios/desafio041.py
398
3.703125
4
from datetime import date ano = int(input('Digite o ano de nascimento: ')) anoCorrente = date.today().year idade = anoCorrente - ano if(idade <= 9): print('Atleta \033[1;34mMirim') elif(idade <= 14): print('Atleta \033[1;34mInfantil') elif(idade <= 19): print('Atleta \033[1;34mJunior') elif(idade <= 25): ...
05096f0731e487efe6c54a5a943a06048d0b4f90
lalitzz/DS
/Sequence4/Algorithm-toolbox/Week4/binarysearch-1.py
1,291
3.71875
4
# Uses python3 import sys from random import randint def binary_search(a, x): left, right = 0, len(a) # write your code here while left < right: mid = (right + left) // 2 if a[mid] == x: return mid elif a[mid] > mid: right = mid - 1 else: left = mid + 1 r...
2a1095dbc8bdeae8559675f6740025c65b0bddd4
zilunzhang/Machine-Learning-and-Data-Mining
/a2/q2_0.py
963
3.84375
4
''' Question 2.0 Skeleton Code Here you should load the data and plot the means for each of the digit classes. ''' import data import numpy as np # Import pyplot - plt.imshow is useful! import matplotlib.pyplot as plt def plot_means(train_data, train_labels): means = [] for i in range(0, 10): ...
e785c986a47fd71bafccc100aaf02555bb1ef1b1
RakeshRameshDS/Programming-Interview-Preparation
/Trees And Graph/02. List of Depths.py
1,178
3.765625
4
""" Given a binary tree, design an algorithm which creates linked list of all nodes at each depth """ class LLNode: def __init__(self, data): self.data = data self.link = None class TNode: def __init__(self, data): self.data = data self.left = None self.right = None r...
5ebdfbfc359e550d7a6c5425c836c077aadac7fd
ArseniyCool/Python-YandexLyceum2019-2021
/Основы программирования Python/8. Nested Loops/Таблица Улама.py
582
3.90625
4
# Ширина таблицы Улама n = int(input()) # Кол-во чисел,о которым строится таблица max_val = int(input()) counter = 1 while counter <= max_val: is_prime = True if 0 == counter % 2 and counter != 2: is_prime = False for y in range(3, int(counter / 2), 2): if 0 == counter % y or not i...
54679cad23b57c9ae35480c7ae2d409cc3b8f7e2
Kornflex28/iqfit-solver
/iqfit/board.py
2,277
3.609375
4
from itertools import product from .piece import Piece class Board: def __init__(self, width=10, height=5): self.width = width self.height = height self.shape = width, height self.current_board = {(x, y): None for x, y in product( range(self.width), range(self.height))}...
8c031b625e027f4ec7b2567861f994f038d34921
NuclearAck/pythonLearning
/struture/palindromic_num.py
161
3.78125
4
import re def find_num_palindromic(): s = "ab" p = ".*c" res = re.findall(p,s) return True if not res else False print(find_num_palindromic())
a046567e8eb772648ea27eee2ea64a46f313e1ca
danlucss/Cursoemvideo
/Mundo3/ex104.py
818
4.15625
4
"""Exercício Python 104: Crie um programa que tenha a função leiaInt(), que vai funcionar de forma semelhante ‘a função input() do Python, só que fazendo a validação para aceitar apenas um valor numérico. Ex: n = leiaInt(‘Digite um n: ‘)""" def leiaInt(msg): ''' Função para imprimir na tela um número inteir...
19b75a94f1a8c1717fbd7600d0504b5194420982
M45t3rJ4ck/Student
/Primes.py
1,036
4.59375
5
# Create a new Python file in this folder called “Optional_task.py” # Create a program to check if a number inputted by the user is prime. # A prime number is a positive integer greater than 1, whose only factors are 1 and the number itself. # Examples of prime numbers are: 2, 3, 5, 7, etc. # Ask the user to enter an i...
43cadbb9d4c4cdb3a317b275dff3db2da1164b86
jchunf/NLP_Model
/fastText/src/utils/huffman.py
6,383
4.09375
4
from queue import PriorityQueue from typing import Dict, List class _Node(object): """node of huffman tree """ def __init__(self, num: int, weight: int): self._num = num self._weight = weight self._left_child = None self._right_child = None def add_child(self, type: i...
871c62de1d66b8b10f477fa0dfd1ef15a174129a
Busiky/Tasks
/Triangle numbers and words/solution.py
476
3.828125
4
import string def triangle(item): abc = string.ascii_uppercase if item.isdigit(): number = int(item) else: number = sum([abc.index(letter) + 1 for letter in item.upper()]) count = 0 triangle_number = 0 while triangle_number < number: count += 1 triangle_number =...