blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
61c8dbe0e8db5410a28e8d39cfe1edbce10ac41a
Prithamprince/Python-programming
/string28.py
159
3.515625
4
f=input() f=list(f) c=0 g=0 for i in f: if(i=='('): c=c+1 elif(i==')'): g=g+1 if(c==g): print("yes") else: print("no")
6225fb6bd0a83c54bda65c67e8156bbd27fe0a5c
Prithamprince/Python-programming
/string7.py
189
3.53125
4
p=input() q=list(p) r=len(q) if(r%2!=0): s=r/2 t=round(s) q[t]='*' print(*q,sep="") else: s=r/2 t=round(s) q[t-1]='*' q[t]='*' print(*q,sep="")
a2e137c46ba889a751a018cab558e841fc104c53
Prithamprince/Python-programming
/leapyr.py
92
3.703125
4
p=int(input()) if(p%4==0 or p%100==0 or p%400==0): print("yes") else: print("no")
7acd7413f4462c585b7ad05795b114d4feb4e8cb
teddy-boy/python_crash_course_exercises
/basics/ch03-list/ex_3_8.py
752
3.90625
4
locations = ['Singapore', 'Da Nang', 'Hong Kong', 'Bangkok', 'Tokyo'] print('Original list:') print(locations) print('*' * 10) print('Sorted list:') print(sorted(locations)) print('*' * 10) print('Original list:') print(locations) print('*' * 10) print('List in reverse alphabetical order:') print(sorted(locations, r...
9e6c62f804f1787f53cf0636450e83cd3b8eff28
teddy-boy/python_crash_course_exercises
/basics/ch03-list/ex_3_4.py
246
3.65625
4
guest_list = ['Lan', 'Chuc', 'Minh'] print('Hi ' + guest_list[0] + ', please come to have dinner with me') print('Hi ' + guest_list[1] + ', please come to have dinner with me') print('Hi ' + guest_list[2] + ', please come to have dinner with me')
5da00887cec83cbea8053b5701265315c85dc1b7
teddy-boy/python_crash_course_exercises
/basics/ch09_classes/Restaurant.py
399
3.609375
4
class Restaurant: def __init__(self, restaurant_name, cuisine_type): self.name = restaurant_name self.cuisine = cuisine_type def describe_restaurant(self): print(f"The restaurant name is {self.name.title()}.") print(f"It serves {self.cuisine.title()}.") def open_restaurant...
0a75955b9901cdb8ee2f590204b2f048a8dd0391
teddy-boy/python_crash_course_exercises
/basics/ch07_user_input/test.py
109
3.53125
4
print("This is a test file") prompt = "Please enter your name: " name = input(prompt) print(f"Hello {name}")
969e3f482549fc966537d5912582d6f6e43e351a
teddy-boy/python_crash_course_exercises
/basics/ch09_classes/ex_9_4.py
1,289
4.34375
4
class Restaurant(): """Create an restaurant with minimal infos""" def __init__(self, restaurant_name, cuisine_type): self.name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): print(f"The restaurant name is {self.n...
7ce2541d30daeeacb02ed22fb7b0d094ea745bb0
teddy-boy/python_crash_course_exercises
/basics/ch07_user_input/ex_7_3.py
199
4.28125
4
# Multiples of Ten prompt = "Please enter a number: " number = int(input(prompt)) if number % 10 == 0: print("Your number is a multiple of 10") else: print("Your number is not a multiple of 10")
258931f88ab91fa9cb7ff91ea78a94b9e765f6d9
apiyron/MOOCs
/stepik/Программирование на Python/2_3_2_Arithmetic_mean.py
1,059
4.03125
4
''' Напишите программу, которая считывает с клавиатуры два числа a и b, считает и выводит на консоль среднее арифметическое всех чисел из отрезка [a;b],которые делятся на 3. В приведенном ниже примере среднее арифметическое считается для чисел на отрезке [−5;12]. Всего чисел, делящихся на 3, на этом отрезке 6: −3,0,3,6...
a02041259c8cc84e07a907767c779f1fb959eff0
apiyron/MOOCs
/stepik/Программирование на Python/2_5_3_List_repeats.py
1,076
3.765625
4
''' Напишите программу, которая принимает на вход список чисел в одной строке и выводит на экран в одну строку значения, которые повторяются в нём более одного раза. Для решения задачи может пригодиться метод sort списка. Порядок вывода повторяющихся элементов может быть произвольным. Sample Input 1: 4 8 0 3 4 2 0 3 Sa...
15e4f6314c9dfca8fce50294e8a80c6a6b534747
santidcmat96/sim_est_2017
/Ejemplo Generadores.py
410
3.828125
4
def cuadrados(numeros): resultado = [] for i in numeros: resultado.append(i*i) return resultado mis_num = cuadrados([1,2,3,4,5]) print mis_num print cuadrados def cuadrados_gen(numeros): for i in numeros: yield i*i mis_num = cuadrados_gen([1,2,3,4,5]) print mis_num print cuadrados_g...
2733f3fa24cc1c2ec68f9203229714841c9d64f9
cristian1barajas/Lista-de-Objetos-en-Python
/Clases_Python/figuras.py
1,369
3.796875
4
from numpy import hypot, sqrt class Figura(object): def __init__(self, dim1, dim2): self.dim1 = dim1 self.dim2 = dim2 class Rectangulo(Figura): def __init__(self, dim1, dim2): super(Rectangulo, self).__init__(dim1, dim2) def area(self): if self.dim1 != self.dim2: ...
e847246a9f516b8169ca5e5fcdd9b8fcdbb6c85e
abexultan/rl-courses
/SAC/cartpole_swingup.py
13,501
3.65625
4
""" Cart pole swing-up: modified version of: https://github.com/hardmaru/estool/blob/master/custom_envs/cartpole_swingup.py """ from dataclasses import dataclass, field from collections import namedtuple import numpy as np import gym from gym import spaces from gym.utils import seeding @dataclass(frozen=True) class ...
8253eda326761c13b9039624e46f3b28f7068e3f
kwoodson/euler
/python/euler15.py
1,992
3.609375
4
#!/usr/bin/env python ''' Starting in the top left corner of a 2x2 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 20x20 grid? ''' ''' Combination formula states: for a 4x3 rectangle possible solutions is C(n,r) = n! / (r! * (n-r)! 7 steps to find a sol...
d52bf721f757ae8eec9faaebe357168c5c7cd15c
kwoodson/euler
/python/euler52.py
1,538
3.8125
4
#!/usr/bin/env python ''' It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. ''' start = "1000" found = False while True: for i in range(in...
766d01fb7247402cb68325ee027e2f1607ed5564
kwoodson/euler
/python/euler24.py
1,512
3.8125
4
#!/usr/bin/env python import collections import math ''' A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0...
1dcdf45a800f8b9fcc5b584e2f1119cf7001cd4e
kwoodson/euler
/python/euler21.py
926
3.953125
4
#!/usr/bin/env python import collections import math ''' Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a != b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, the proper divisors o...
f45b21b3752bfc6b7ac817cb151925b68e3da7b4
ker2x/evoPysa
/dna/point.py
658
3.71875
4
"""DNA Point class""" from random import randint class Point: """A simple DNA point, only x and y""" id = 0 def __init__(self, x: int = 0, y: int = 0): self.x = x self.y = y self.id = Point.id Point.id += 1 def __str__(self): return f"Point(x={self.x!r}, y={se...
0ff1aad67bdc12846da03198f3b72c66938b0333
perihanmirkelam/CSE505_Algorithms
/HW3/181041025_HW3/code/Solution2.py
714
3.71875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: n = 19 #Number of chips m = 3 #Number of maximum taken chips isFirstPlayer = True def startGame(n, m, isFirstPlayer): print("n ", n, ", m", m) if isFirstPlayer : player = 'First' else: player = 'Second' if not n % (m+1) == 0: ...
54661d95fdfa6bac50e9bf7cafb04f8c75248206
haiLJY/store
/html练习.py
3,231
3.578125
4
#任务1:百度自由搜索 from selenium import webdriver import time # 创建谷歌浏览器对象 # chromeDriver = webdriver.Chrome() # # # 打开百度网址 # chromeDriver.get("http://www.baidu.com") # # # 窗口最大化 # chromeDriver.maximize_window() # # #寻找搜索输入框 # chromeDriver.find_element_by_id("kw").send_keys("java") # # # 点击百度一下按钮 # chromeDriver...
3783408175c90274447ea8e08968b9eae188a63c
PoornimaMV/Programs
/SortingAlgorithms/BubbleSort.py
537
4.21875
4
#BUBBLE SORT def bubbleSort(my_list): for k in range(len(my_list)-1): for i in range(len(my_list)-1): if my_list[i] > my_list[i+1]: my_list[i], my_list[i+1] = my_list[i+1], my_list[i] print("Swapped: {} with {}".format(my_list[i], my_list[i+1])) ...
cfdee0db76ef09f47c2fc67e31262c3805e9d832
mdchia/advent-of-code-2017
/day1_2.py3
703
3.953125
4
#!/usr/bin/env python import sys if sys.argv: try: raw = input('Puzzle input:') puzzle_input = int(raw) except ValueError: print("Puzzle input needs to be a number") exit() else: puzzle_input=sys.argv[1] def shift_string(s, n): new = s[-n:]+s[:-n] return new puzzl...
7b11a135c10b5b46e36a4f510654aedfc242c367
allyrob/bill_calculator
/python_homework/bill_calculator.py
2,044
4.125
4
# i work! add me to GitHub def calculate_tip(bill_amount, tip_percentage): return bill_amount * tip_percentage * .01 def calculate_total(tip, bill_amount): return tip + bill_amount def calculate_split(total, people): return total / people def main(): print "Please choose from the following:" pri...
3d4689ac090c545277e9741b9a71f27d982a5f69
troyamelotte/pythonsorting
/assignment-insertionsort.py
431
3.984375
4
#def insertionsort(arr): # for i in range(0, len(arr)): # count = 0 # for num in range(0, len(arr)): # if arr[i]> arr[num]: # count+=1 # arr.insert(count,arr[i]) # arr.pop(i) # print arr def insertionsort(arr): for index in range(0, len(arr)): sub = arr[index] while index-1 >=0 and sub<arr[index-1]: ...
3b3caeb40e049f514163dc2a2697cdef75c34d5a
kelly-gilbert/preppin-data-challenge
/2022/preppin-data-2022-41/preppin-data-2022-41.py
2,001
4.03125
4
# -*- coding: utf-8 -*- """ Preppin' Data 2022: Week 41 - Dynamic Times Tables https://preppindata.blogspot.com/2022/10/2022-week-41-dynamic-times-tables.html - Input data - Create a parameter that allows the user to set the multiplication grid they want - Output the data Author: Kelly Gilbert Created: 202...
9d2a37cf00988a7f172b6f1938be8c1acc22d5d6
kelly-gilbert/preppin-data-challenge
/2021/preppin-data-2021-35/preppin-data-2021-35.py
3,451
3.734375
4
# -*- coding: utf-8 -*- """ Preppin' Data 2021: Week 35 - Picture Perfect https://preppindata.blogspot.com/2021/09/2021-week-35-picture-perfect.html - Input the data - Split up the sizes of the pictures and the frames into lengths and widths Remember an inch is 2.54cm - Frames can always be rotated, so make sure you...
e61e79a33dd914e79edda743d2818d0a308d86af
alakaz4m/GitHubRepoAssignment
/DojoAssignments/Python/tuples.py
240
3.6875
4
my_dict = { "Speros": "(555) 555-5555", "Michael": "(999) 999-9999", "Jay": "(777) 777-7777" } my_list = [] def tup_out(my_dict): for index in my_dict.iteritems(): my_list.append(index) print my_list tup_out(my_dict)
dfc892704dc2d5bceac99c5397a5877455512c38
alakaz4m/GitHubRepoAssignment
/DojoAssignments/Python/compare_lists.py
154
3.90625
4
list_one = [1,2,5,6,2] list_two = [1,2,5,6,2,1337] if list_one == list_two: print "These lists are the same" else: print "These lists are not the same"
9cad6d1f029eb689bd68d392f42201d3d5da5401
alakaz4m/GitHubRepoAssignment
/DojoAssignments/Python/stars.py
312
3.609375
4
def draw_stars(x): for i in x: fancy = "" length = i boolean = True if type(i) != int: length = len(i) boolean = False for y in range(0,length): if boolean == False: fancy = [i][0][0] * length else: fancy = '*' * length print fancy x = [2,'chicken','taco',6,3,1] draw_stars(x)
1dff7e729e543135862f5afd65004476dbcbdc93
alakaz4m/GitHubRepoAssignment
/DojoAssignments/Python/strings_and_list.py
639
3.90625
4
print '################' print 'Find and Replace' words = "It's thanksgiving day. It's my birthday too!" print words.find('day') new_string = words.replace('day', 'month') print '################' print 'Min and Max' y = [] x = [2,54,True,'pizza',232,12] for i in x: if type(i) == int: y.append(i) print "The min is...
71fe41c0f7fed72041363ff81352fb0be8f0b0b8
alakaz4m/GitHubRepoAssignment
/DojoAssignments/Python/animal_obj.py
1,248
4.0625
4
class Animal(object): def __init__(self, name, health): self.name = name self.health = health def walk(self): print 'Action: Walking...' self.health -= 1 return self def run(self): print 'Action: Running...' self.health -= 5 return self def displayHealth(self): print self.health clas...
bae15b65e51ce3db1ede4fa0824f358dccb80daa
Andchenn/python
/com/file.py
262
3.765625
4
# 从键盘输入一些字符,逐个把它们写到磁盘文件上,直到输入一个#为止 filename = input('输入文件名:\n') fp = open(filename, "w+") ch = '' while '#' not in ch: fp.write(ch) ch = input('输入字符串:\n') fp.close()
0f0d442ff6ea1fcd679976c1293e78302e021534
Andchenn/python
/text/is_number.py
393
3.53125
4
def is_number(s): try: float(s) return True except ValueError: pass try: import unicodedata unicodedata.numeric(s) return True except(TypeError, ValueError): pass return False print(is_number('tun')) print(is_number('1.5')) print(is_number(...
1b4ee2039c31b2a091b55f959b154eed66ae928a
Andchenn/python
/com/generator.py
332
3.796875
4
def counter_generator(low, high): while low <= high: yield low low += 1 for i in counter_generator(1, 5): print(i, end=' ') def infinite_generator(start=0): while True: yield start start += 1 for num in infinite_generator(4): print(num, end=' ') if num > 20: ...
42cd720fca0cb8c2db43bfff6e4faf2ac7550bb7
Andchenn/python
/com/nixu.py
244
3.734375
4
# 将一个数逆序输出。 if __name__ == '__main__': a = [9, 6, 5, 4, 1] print('输出a列表的数:') for u in range(len(a)): print(a[u]) print('逆序得到的数:') for i in reversed(a): print(i)
8d908b31a78f36341835d6662e60a8f60915022b
dlalita/midtrans
/midtrans - problem 6.py
305
3.828125
4
#Problem 6 import random def string(a, b): minimal =min(len(a), len(b)) print('Output = ', minimal) if len(a) or len(b) > minimal: #input add1 = input('First string:...') type(add1) add2 = input('Second string:...') type(add2) check = string(add1, add2)
ee1b21ecf8d8fe810440450683513a6b4024cf4b
natasyaoktv/basic-python-b3
/loop.py
894
3.921875
4
angka_list = ["ini", "adalah", "angka", "10"] print("Example 1") for x in angka_list: print(x) print("Example 2") hasil = "" for x in range(0, len(angka_list)): hasil = hasil + angka_list[x] print(hasil) print("Example 3") for i in range(0,5): #harus menentukan range dari looping print("i ke: {}".for...
a2e3d15f26f3f19cce917f44b89965fef0ecdfc2
natasyaoktv/basic-python-b3
/while-loop.py
229
4.03125
4
# i = 1 # while i < 6: # print(i) # # i = i+1 # i+=1 # for i in range(6): # print(i) masukkan = input("Masukkan nama: ") while masukkan != "stop!": print(masukkan) masukkan = input("Masukkan nama: ")
680a40604efb0851ed1a2f408aa97e87e26d1d8c
natasyaoktv/basic-python-b3
/math.py
100
3.640625
4
#this is for math x = 10 y = 7 print(x+y) print(x-y) print(x*y) print(x/y) print(x%y) print(x**y)
919d34d7ba37773c9010445fea6e9d77d073c41f
Pau1Robinson/asteroids
/main.py
4,386
3.71875
4
#!/usr/bin/env python3 ''' ########################### # # # PyGame Asteroids # # # ########################### ''' import pygame import asteroids_var import asteroids_classes #### Set everything up #### # initialise pygame pygame.init() #Define...
b62b2d5a2d5d3e491e9776728f4c40d09f640cac
agave233/leetcode
/404-Sum-of-Left-Leaves/referrence.py
664
3.8125
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 sumOfLeftLeaves(self, root): """ :type root: TreeNode :rtype: int """ ...
d4564fdaccf3e3384713f7b550c8c34b1f177961
agave233/leetcode
/105-从前序与中序遍历序列构造二叉树/105.py
2,136
3.828125
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 buildTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: L...
576546c52976f294d4d2d6d14e24df2a50f65201
agave233/leetcode
/404-Sum-of-Left-Leaves/SumOfLeftLeaves.py
745
3.78125
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 sumOfLeftLeaves(self, root): """ :type root: TreeNode :rtype: int """ ...
b259802efeb0d8e7e4fded1854c1a3fa680b32df
agave233/leetcode
/637-Average-of-Levels-in-Binary-Tree/AverageOfLevelsInBinaryTree.py
822
3.71875
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 averageOfLevels(self, root): """ :type root: TreeNode :rtype: List[float] ...
bedbcae4310f088b1e1547030742e0ab4446e533
agave233/leetcode
/73-矩阵置零/73.py
2,997
3.859375
4
# 给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0。请使用原地算法。 # 示例 1: # 输入: # [ # [1,1,1], # [1,0,1], # [1,1,1] # ] # 输出: # [ # [1,0,1], # [0,0,0], # [1,0,1] # ] # 示例 2: # 输入: # [ # [0,1,2,0], # [3,4,5,2], # [1,3,1,5] # ] # 输出: # [ # [0,0,0,0], # [0,4,5,0], # [0,3,1,0...
3ace66f100ab4b59a3281fba6c2e7da26171b489
rinkichandrawal1086/RinkiProjects
/AllAboutString.py
940
4.375
4
#name=input("enter your name : ") #Input String #age=int(input("How old are you, {0}? : ".format(name))) #String replacement #address=input("enter your address please : ") #print("The age of {0} is {1} who lives in {2} " .format(name,age,address)...
c851b25c2dc2cc31d1e8ab144715fbf3096dcba9
konstantinosBlatsoukasRepo/leet-code-problems
/arrays/repeated_n_times.py
412
3.578125
4
""" array - hash map """ class Solution: def repeatedNTimes(self, A: List[int]) -> int: N = len(A) / 2 number_frequencies = {} for number in A: if number in number_frequencies: number_frequencies[number] += 1 else: number_frequencies...
99a60a7fdb1cfee95153b796d751fb0098117751
craig3050/MiscTools
/Countdown_Words/cdwords.py
597
3.84375
4
import os dictionary = open('Dict.txt', 'r') print ("Welcome to Craig's Countdown Words solving tool!!") cdwords = input("Enter all the letters as one big word") word_length = len(cdwords) + 1 word_list = {} for words in dictionary: if len(words) <= word_length: letter_count = 0 for letters...
35cc0ce2af684da4229c00ebffbcbad1158ab1fa
zachnicoll/python-event-planner
/whats_on.py
41,060
3.53125
4
from tkinter import * from tkinter import messagebox from re import findall, finditer, MULTILINE, DOTALL from sqlite3 import * # Downloader function for grabbing each webpage. def download(url = 'http://www.wikipedia.org/', target_filename = 'download', filename_extension = 'html'): # Im...
9f1daf50b7a819e57fea9babddce01abec84701b
kristalkung/melon-delivery-report
/produce_summary.py
836
4.15625
4
def melon_report(day, file): """Using the given day and file, prints the count of melon, the type of melon sold, and the amount made""" print(f"Day {day}") # print the day and day number the_file = open(file) # set the_file to open the the given parameter, file for line in the_file: l...
1569b00095526d8a95cf90e2881aa19e26e2c99f
JannesKlaas/Python_Data_Analytics_Tools
/class 4/mnist.py
3,517
3.84375
4
from sklearn.datasets import fetch_mldata import numpy as np import seaborn as sns #download mnist dataset mnist = fetch_mldata('MNIST original') #generate a smaller subset train_subset = mnist.data[5::100] #generate a smaller cross validation subset cval_subset = mnist.data[50::1000] #generate a subset of y valu...
c80be3999f967bf159c20686e9b6604a501b02cf
danishmansur/new-projects
/DIRECTING CUSTOMERS TO SUBSCRIPTION PRODUCTSTHROUGH APP BEHAVIOUR ANALYSIS.py
14,758
3.65625
4
#!/usr/bin/env python # coding: utf-8 # DIRECTING CUSTOMERS TO SUBSCRIPTION PRODUCTS THROUGH APP BEHAVIOUR ANALYSIS # # import pandas as pd # from pandas import Series,DataFrameMany companies have mobile presence. These companies like YouTube, Pandora etc give theor customers free services or products in an attempt t...
f2339af374448309177331ac03e801de7dc0d458
AdamBanham/Space-Apps-Surface-to-Air
/location.py
2,357
3.828125
4
from pyproj import Proj from math import radians, cos, sin, asin, sqrt, atan2 p = Proj(proj='utm',zone=10,ellps='WGS84', preserve_units=False) class Coordinate: def __init__(self): raise NotImplementedError("Coordinate is an abstract class") def as_tuple(self): raise NotImplementedError("metho...
e4b8cbfcc6b1974b94904e112e945af42d729bab
kynesim/rrw1000scripts
/mail/split_mail.py
1,716
3.6875
4
#! /usr/bin/env python # """ So, python's mailbox implementation tries to load the whole mailbox. This ends badly when your mailbox is very big and your mail server is very small. So, this is a program which tries to split big mailboxes into lots of small ones. Syntax: split_mail.py <infile> <approx#bytes> <outstem...
ae04400ece7b53b006333e776d51804788836efb
Nayan-Sinha/List-Programs-in-Python
/similar_char.py
435
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 9 22:20:33 2021 @author: Nayan """ #Write a python program to filter all the strings #which have a similar case , either upper or lower (Palindrome type) list1 = ["nayan", "DAD", "abcd", "Java", "mom"] print("Orginal list of strings:") print(list1) result ...
27d92474fff28625b0294f601747280aadc06a35
hamidaucc/calculator-application-in-python
/Switch.py
2,122
3.53125
4
#!/usr/bin/env python3 __module__ = 'Switch' class Switch: # @author Herakliusz Lipiec (ID 114345041) # @author Hamid Abdul (ID 114734769) # @author Stephen Hannon(ID 113425638) __FORMAL_REPRESENTATION = "<Switch statement>" # formal representation of switch statement __DEFAULT_PARAMETER_N...
24759a2c6aab7a010104386fc714e20b546af931
hamidaucc/calculator-application-in-python
/Mul.py
688
3.8125
4
#!/usr/bin/env python3 __module__="Mul" from basicOp import BasicOperation class Mul(BasicOperation): # @author Herakliusz Lipiec (ID 114345041) # @author Hamid Abdul (ID 114734769) # @author Stephen Hannon(ID 113425638) # takes in the first number and the second number as well as the base def...
88c8ac3db32f0a050d1d60cdc2055edd51d79556
mckraken/Python_III_class_labs
/lab12b.py
1,319
3.90625
4
#! /usr/bin/env python import json class BankAccount(object): # Top tier class (super class) in Python 2 or 3 # class BankAccount: works fine in Python 3. Parens not required def __init__(self, name): # This method runs during instantiation self.balance = 0 # instance variable self.acctnam...
941a6eb7dde2642f6e4c51f22836425d1def4bfe
khoiduong/HangMan_Python
/HangMan Game/hangManGame.py
3,924
3.8125
4
import random, re, sys # ASCII SPRITE FOR THE GAME HANGMAN_PICS = [ ''' +---+ | | | ===''', ''' +---+ O | | | ===''', ''' +---+ O | | | | ===''', ''' +-...
0597a3f604a3abea7dd0482f9b033580ad0e918d
pinnheads/100-Days-Of-Code
/Day_30/challenges.py
1,769
4.15625
4
# Challenge 1 # IndexError Handling # Issue # We've got some buggy code. Try running the code. The code will crash and give # you an IndexError. This is because we're looking through the list of fruits # for an index that is out of range. # Bad Output # https: // cdn.fs.teachablecdn.com/GNPYLwHXQFOUTylnvWvK # Instr...
174a8b4c3c12172f62c266185cdea3cc14f7ba05
pinnheads/100-Days-Of-Code
/Day_26/main.py
592
3.84375
4
# List Comprehensions numbers = [1, 2, 3] new_numbers = [n + 1 for n in numbers] # List Comprehension with conditional names = ["Alex", "Beth", "Caroline", "Dave", "Eleanor", "Freddie"] short_names = [name for name in names if len(name) < 5] long_names = [name.upper() for name in names if len(name) > 5] # Dictionar...
8d6f173ad5f6a9eb6b89055696cc5a2653dd7ba9
pinnheads/100-Days-Of-Code
/Day_1/main.py
484
4.375
4
# Print anything with print() print("Hello World") # This is the python 3 syntax # Print multiple lines with '\n' print("Hello World\nDay 1 of 100 days of code!") # Concat strings with + print("Hello" + " " + "Utsav") # Take inputs from the user with input() input("A Prompt for the user: ") # length of string can b...
335a4a1b3d5eec8f45d30c7396b1a6a5ddd6cc71
pinnheads/100-Days-Of-Code
/Day_5/main.py
471
4.0625
4
# For Loops fruits = ["Apple", "Peach", "Pear"] for fruit in fruits: print(fruit) # Range Function for number in range(1, 101): print(number) # Steps in range total = 0 for number in range(1, 101, 2): total += number print(total) # If - Else statements in For Loops for number in range(1, 101): if number...
575a83182e65dd7a7a68074b6ddbac0b66499ab6
pinnheads/100-Days-Of-Code
/Day_4/challenges.py
3,441
4.46875
4
# Challenge 1 # Heads or Tails # Instructions # You are going to write a virtual coin toss program. It will randomly tell the user "Heads" or "Tails". # Important, the first letter should be capitalised and spelt exactly like in the example e.g. Heads, not heads. # There are many ways of doing this. But to practice ...
6e0883712a6c480cf7ea8bc78f06d8fb9dd1f54b
pinnheads/100-Days-Of-Code
/Day_46/main.py
1,943
3.734375
4
import requests import spotipy from spotipy.oauth2 import SpotifyOAuth from bs4 import BeautifulSoup client_id = "Enter ID" client_secret = "Secret" # Ask user for a date user_input = input( "Which year do you want to travel to? Type the date in this format YYYY-MM-DD" ) # Build url based on user input base_url ...
128550e963cc3a7073e6c69d452e42bc5007a19e
JuHyeong-K/algorithm-practice
/solution.py
1,293
3.53125
4
def solution(n, words): answer = [] # [실행] 버튼을 누르면 출력 값을 볼 수 있습니다. word_chain = [] for word in words: word_chain.append(word) if len(word_chain) == 1: continue if word in word_chain[:-1]: if len(word_chain) % n == 0: answe...
555b4c015a997c4ec1ddb4abc6b319ce47f523bb
KillerCrocII/Ch.07_Graphics
/7.2_Picasso.py
1,871
4.375
4
''' PICASSO PROJECT --------------- Your job is to make a cool picture. You must use multiple colors. You must have a coherent picture. No abstract art with random shapes. You must use multiple types of graphic functions (e.g. circles, rectangles, lines, etc.) Somewhere you must include a WHILE or FOR loop to create a ...
ef2876e47fb04dbd4a7908d2d838e18590402f49
juanferfranco/IoT
/ZerinthProjects/Blink/main.py
1,459
3.828125
4
############################################################################### # Led Blink # # Created by Zerynth Team 2015 CC # Authors: G. Baldi, D. Mazzei ############################################################################### # D0 to D127 represent the names of digital pins # On most Arduino-like boards P...
417710f29e279c9a1e3d5801c92f22fab5aa19de
nguyenduc810/DSA_HUST_20202
/Stack_Queue/TheQueue.py
853
3.953125
4
import random as rd class Node: # to init a new Node with given value def __init__(self, value): self.data = value self.next = None # class Queue to represent the queue of customers waiting class Queue: def __init__(self): self.head = None self.tail = None self.si...
81d489f4cc51a1d57c62518a9b8f07703a6bac0d
tareksfouda/AI
/python/trials/abcd.py
572
3.515625
4
#!/usr/bin/python # # What's the minimum value for: # # ABC # ------- # A+B+C # # From http://www.umassd.edu/mathcontest/abc.cfm # from constraint import * def main(): problem = Problem() problem.addVariables("abc", range(1,10)) results = [] for solution in problem.getSolutions(): ...
b3bc48c65a245d5e6d852b5d3cd44ad62401200e
zero347347/random-pw-generator
/random_password_generator.py
774
4.125
4
# 1st to think, password should be a string value which include numbers and alphabets .etc # its a variable, length , lowercase, uppercase # random module must include this project # for loops since we will going to repeat from random import randint password = "" for i in range(10): i = chr(randint(65, 9...
2d5db1ab60d15df8ac9a9d50b07ccffe776b3a38
loyti/rPi
/pythonPlay/mathPlay/mathPlay.py
614
3.796875
4
class MathDojo(object): def __init__(self): self.result = 0 def add(self, *nums): for i in nums: if isinstance(i, list) or isinstance(i, tuple): for j in i: self.result += i else: self.result += i print "You've done addition... Your new total is {}".format(self.result) return self def sub...
3cbf7666bf8be260a900533e4bd165993751383b
phucodes/lc101-git
/caesar.py
375
3.921875
4
from helpers import alphabet_position, rotate_character def encrypt(text, rot): alphabet_position(text) encrypted_message = rotate_character(text, rot) return encrypted_message def main(): text = input("Enter your code here: ") rot = input("Enter the key here (Must be a number): ") print(enc...
2a891257ba294b5dd2291b084935ab8385242ae5
trushna04/CodingPractice
/Sorting/mergesort.py
455
3.984375
4
def merge(lef,righ): result = [] i,j = 0, 0 while i<len(lef) and j< len(righ): if lef[i] <= righ[j]: result.append(lef[i]) i+=1 else: result.append(righ[j]) j+=1 result += lef[i:] result += righ[j:] return result def mergesort(lst): if(len(lst) <= 1): return lst mid = int(len(lst)/2) left ...
0d6c197931583d26e73f4b44f8e1cb63ed1204e1
trushna04/CodingPractice
/String/lowerandupper.py
462
4.15625
4
def lowerupper(string): upper = 0 lower = 0 for i in range ( len ( string ) ): if (ord ( string[ i ] ) >= 97 and ord ( string[ i ] ) <= 122): lower += 1 elif (ord ( string[ i ] ) >= 65 and ord ( string[ i ] ) <= 90): upper += 1 print...
2f066b6a59d98319bd29b6f728b0ba6ff006c6c9
trushna04/CodingPractice
/String/maxaccuringchar.py
349
3.609375
4
ASCII_SIZE = 256 def getMaxOccuringChar(str): cou= [ 0 ] * ASCII_SIZE max = -1 c = '' for i in str: cou[ ord ( i ) ] += 1; for i in str: if max < cou[ ord ( i ) ]: max = cou[ ord ( i ) ] c = i return c str = "Apple" print ("Max occurring character is " ...
8b2af46d9fd0c0394a9cafad1f7b067849733ff0
rohitravishankar/TwitterTweetAnalysis
/ProcessTweets/tweetprocessor.py
1,847
3.546875
4
""" This handles the process to get data from the MongoDB database, process it and produce the cleaned tweets towards a topic in Kafka Author: Rohit Ravishankar Email: rr9105@rit.edu """ import logging import json from pymongo import MongoClient from kafka import KafkaProducer from tweetcleaner import TweetClean cla...
9e5c40790944e66ed669d3341b3e91ccf6726276
kmartinez33/MIStest
/session5.py/excercise3.2.py
736
3.96875
4
import turtle import math dragon = turtle.Turtle() print(dragon) def polygon(t, n, length): angle = 360 / n for i in range(n): t.fd(length) t.lt(angle) import math def circle(t,r): circumference = 2 * math.pi * r n=50 length = circumference / n polygon(t,n,length) circle(dra...
29fb55bffd3e1b2b3a1ecb1e5661666bc1ee02d4
kmartinez33/MIStest
/session10_11.py/Lists.py
1,434
3.953125
4
#[10, 20, 30, 40] #['New England Patriots', 'Buffalo Bills','Miami Dolphins','New York Jets'] ['spam', 2.0, 5, [10,20]] AFC_east = ['New England Patriots', 'Buffalo Bills','Miami Dolphins','New York Jets'] numbers = [42, 123] empty= [] print(AFC_east,numbers, empty) AFC_east[3] = 'New York Giants' #New england is at ...
f2011a974a6c003033e98137b3939f23d70d29d3
kmartinez33/MIStest
/session7.py/excercise3.py
135
3.875
4
from math import sqrt def test_square_root(): x=a/2 while True: y =(x+a/x)/2 if y==x: break x=y return x
92e8f4cc80fe8b56926cdd53918812e97038f6d1
Psykepro/Concurrency
/Comparing-CPU-Bound-Problems/finding-squares-in-range-and-returning-sum/multiprocessing-version.py
531
3.515625
4
'''Average runtime 4.62 seconds on my computer -> The fastest solution!''' from timeit import default_timer as timer import multiprocessing def sum_squares_in_range(number): return sum(i * i for i in range(number)) def find_sums(numbers): with multiprocessing.Pool() as pool: pool.map(sum_squares_in...
b65fea1df668730ba550c62445c1b9636fd0d2fe
merissab44/CS-Functions
/multiply.py
228
4.125
4
#function that takes two parameters num1 and num2 and multiplies them together def multiply(num1,num2): result = num1 * num2 return result result1 = multiply(5,8) print(result1) result2 = multiply(8,10) print(result2)
a0cf985917bfbe45ee62e28e34db6add315e8f96
SFKiller/LeetCode
/nim_game.py
504
3.65625
4
#!/usr/bin/python """ This is an ugly solution for "Nim Game" @author SFKiller """ import sys class Solution: def CanWinNim(self, n): """ :type n: int :rtype: bool """ if (0 == (n - 1) % 4) or (0 == (n - 2) % 4) or (0 == (n - 3) % 4): print("Win") ...
3f3985b953b63f54beb9d7c5d77f2828db8c321d
surendra1233/gamblers-problem
/gamblers.py
2,121
3.859375
4
''' Gambler's problem. The gambler has a stake s between 0 and 100. At each play he wagers an integer <= s. He wins that much with prob p, else he loses that much. If he builds his stake to 100 he wins (thus he never wagers more than (- 100 s)); if his stake falls to 0 he loses. ''' import numpy as np import mat...
54f06fa15387c79d1813e3791e183f05a08f8da1
FateXRebirth/CS50-HarvardX
/pset6/vigenere.py
1,343
3.96875
4
import cs50 import sys # select key from a string def selectK(k, index): if str.isupper(k[index]): return ord(k[index]) - 65 else: return ord(k[index]) - 97 def main(): # ensure proper usage if len(sys.argv) != 2: sys.exit("Usage: ./vigenere k") # ensure proper usage ke...
5887fd8dc32f3f07b7399c1d2d60976cf9cd0e0a
uditsingh07/Data-Structures-and-Algorithms-DSA
/Merge_Intervals.py
1,019
4.0625
4
"""Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. Example: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and...
d99078ef8b41e05b63215f4a2e2f466e91fb1feb
Han325/Hangman-Game
/HangmanV2GUI.py
13,180
3.828125
4
# Hangman GUI # Version 2.0 # Created by Han # Finished on 4/5/2020 # Note: Need comments and reorganising code before uploading to GitHub # Update: Reorganzing and notes completed on 30/9/2020 import random import tkinter as tk from tkinter import messagebox # generates words from sowpods.txt def word_ge...
112395662d031934b85de5a64881360a7cae58e0
Alexvizcainolabrador/Ofimatica
/practica9.py
1,201
3.59375
4
def calcula_precio_total(comida) : IVA = round((float(comida) * 0.1),2) Propina = round((float(comida) * 0.1),2) Precio_total = round((float(comida) + float(IVA) + float(Propina)),2) print("\nPrecio de la comida: " + str(float(comida))) print("IVA: " + str(float(IVA))) print("Propina: " + str(f...
17509089bfd749c84df55e1ac7a6563df1954f1a
C-CCM-TC1028-111-2113/homework-3-SofiaaMas
/assignments/08TarjeteriaEspanola/src/exercise.py
723
3.84375
4
def main(): #escribe tu código abajo de esta línea def tarjetas(pliegos,plumones): ## 1. ESTA FUNCION DEBERIA ESTAR AFUERA COMO UNA FUNCIÓN INDEPENDIENTE, NO DENTRO DE LA FUNCIÓN MAIJ() tarjetasPli=pliegos*12 tarjetasPlu=plumones*35 if tarjetasPli<= tarjetasPlu: return tarjetasPli elif...
66a49d5d6107cb2107da9fb8f36f1cbf8398cd6b
RajathRD/competitive-coding
/Puzzle/ChessBoard/solution.py
406
3.640625
4
print "Printing chess board with M x N squares of size P x Q (ROW x COLUMN)" m, n = [int(x) for x in raw_input("Enter M and N:").split()] p, q = [int(x) for x in raw_input("Enter P and Q:").split()] # m, n = 10, 10 # p, q = 10, 10 row_cells = p * m column_cells = q * n chars = ["X","-"] for i in xrange(row_cells): ...
ade5696d2f2fc71b01b871e8576483d5bf3c05fc
whysodunks/belajar_python
/type.py
518
3.546875
4
a = 20.5 #float b = ["apple", "banana", "cherry"] #list c = {"name" : "John", "age" : 36} #dict d = {"apple", "banana", "cherry"} #set e = True #bool f = 2j #complex g = b"Hello" #bytes #display the data type of x: print("Value", a, "ber-type = ", type(a)) print("Value", b, "ber-type = ", type(b)) print("Value", c, ...
beaf27bac61ea7a4208f8f3849025c83667c0c72
funtabred/games
/Number Guessing Game/Number Guessing Game/Number_Guessing_Game.py
1,141
4.1875
4
import random #Input the stop number in range top_of_range = input("Type a number: ") if top_of_range.isdigit(): top_of_range = int(top_of_range) if top_of_range <= 0: print("Please type a number larger than 0 next time.") ...
ca83c3f7aacb5761f48840cb855278b919834c43
TapasDash/Algorithms
/Sorting Algorithms/Bubble_Sort.py
316
3.859375
4
def BubbleSort(listt): for roundd in range(len(listt) - 1): for i in range(len(listt) - 1 - roundd): if listt[i] > listt[i+1]: ''' temp = listt[i] listt[i] = listt[i+1] listt[i+1] = temp ''' listt[i],listt[i+1] = listt[i+1],listt[i] listt = [34,19,5,17] BubbleSort(listt) print(listt)
9723350535cc1173ef4be1c80dd5b79f143af72e
feden2906/study--python
/lesson1.py
2,787
3.65625
4
# # Типи даних # i = 33333333333333333333333333333333333333333333333333333 # f = 1.3 # b = True # s = 'text' # n = None # a = c = 10 # print(a, c) # print(type(i)) # # math operation # a = 0 # a -= 1 # a += 1 # a /= 1 # print(5 + 2) # print(5 - 2) # print(5 * 2) # print(5 / 2) # завжди повернає float # print(5 // ...
380267a1656696902e4115362d259890abe4e737
deshpandegaurang/python
/singly/run.py
950
3.984375
4
from singly import Singly w_iterator = 7 terminator = False obj = Singly() while w_iterator > 6 and terminator == False : print "1 to add to the start " print "2 to add to the end " print "3 to remove from start" print "4 to remove from end" print "5 to print the list" print "6 to terminate" ...
fee7f98f26a9c860a5b0a3cab3afa662d9db7369
CoSeCant-csc/hunting-python-performance
/03.primes-v2.py
569
3.6875
4
import time def primes(n): if n==2: return [2] elif n<2: return [] s=range(3,n+1,2) mroot = n ** 0.5 half=(n+1)/2-1 i=0 m=3 while m <= mroot: if s[i]: j=(m*m-3)/2 s[j]=0 while j<half: s[j]=0 j+...
0b5db2d078c6505ed2bc0ed4327228c5407c1a4b
wware/codegrep
/suffixes.py
656
3.828125
4
#!/usr/bin/env python """ Example usage: find . -type f | head -3000 | ./suffixes.py Lists the file suffixes it finds, in order of decreasing frequency. """ import sys d = {} while True: L = sys.stdin.readline() if L.startswith("./"): L = L[2:] if not L: bre...
3c60021e9debbd968d40d4a26eb0b10495ec2b21
Naga-kalyan/Competitive_Programming
/CodeChef/Tanu and Head-bob/HEADBOB.py
209
3.890625
4
for i in range(int(input())): length=int(input()) String=input() if("I" in String): print("INDIAN") elif("Y" in String): print("NOT INDIAN") else: print("NOT SURE")
3e88ad96388d0e86aaaabd9707244acfd557832b
Naga-kalyan/Competitive_Programming
/HackerRank/BiggestOne_master/BiggestOne.py
103
3.609375
4
a=int(input()) l=[] for i in range(0,a): l.append(int(input())) l.sort(reverse = True) print(l[0])