blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
79ef16265273cc7eee8e81b88fb0cc118004e13c
chenthillrulz/fun_with_python
/group_anagrams.py
291
3.734375
4
#!/bin/python array = ["a", "abcd", "az", "bcd", "bcda"] a = dict() for w in array: key = ''.join(sorted(w)) print (key) if key in a: v = a[key] v.append(w) else: v = [] v.append(w) a[key] = v for k, v in a.items(): print (v)
0e169574c879e3d9db9df88fe55f74dcfa37051b
mcomatas/Rutgers-CS440
/project_1/priority_queue.py
5,201
4.0625
4
import copy class Priority_Queue(): def __init__(self): self.queue = [0] self.length = 0 self.small_g = False # set to True if we want small-g as tie breaker def get_length(self): return self.length def is_empty(self): if len(self.queue) ...
203661e711aeb97eacfcf926e662228e964b3245
An1dsq/hillel_python
/Tests/Test_11.py
589
4
4
def exotic_sorter(lst): mix_lst = list(map(list, zip(*lst))) for i in range(len(lst)): for j in range(len(lst[i])): if i % 2 == 0: mix_lst[i].sort(reverse=True) else: mix_lst[i].sort() result = list(map(list, zip(*mix_lst))) return result ...
887176bbe3fa603a6e81f3121fa1c77e75b36a44
An1dsq/hillel_python
/home_work/home_work_25.py
308
3.6875
4
import random def shuffle_list(lst): # no return (shuffles list in place) for i in range(len(lst) - 1): j = random.randint(0, len(lst) - 1) lst[i], lst[j] = lst[j], lst[i] list1 = list(range(1, 101, 2)) print(id(list1)) print(list1) shuffle_list(list1) print(list1) print(id(list1))
7eca8c21617c085ddb27c407e88ec4d650b3516b
itonorimitsu/kyopuro
/Disco_ディスカバリ/b.py
126
3.6875
4
N = int(input()) if(N % 2 ==1): num = (N - 2)** 2//2+1 print(num) else: num = (N ** 2 - 2 * N) // 2 print(num)
66a5d533a37ba0df7d85bba6df765a903e5679d3
KakE-TURTL3/PythonPractice
/Login System/loginSystem.py
1,509
4.15625
4
import time #Introduces user to program they are using print("Welcome to *insert name here*") #Asks the user to either register or log in opt = int(input ("To continue you must login or register. Please pick an option.\n1)Log In\n2)Register\n")) #Defines login function def login(): accountName = input(...
704eeb3197f4bfd65121dcb7bed54dc5113014b5
simrit1/scrabble-word-score-calculator
/scrabble_word_score.py
1,837
4.25
4
''' Habitica Challenge October 2019 Challenge Description In the game Scrabble each letter has a value. One completed word gives you a score. Write a program that takes a word as an imput and outputs the calculated scrabble score. Values and Letters: 1 - A, E, I, O, U, L, N, R, S, T 2 - D, G 3 - B, C, M, ...
86e70d6449635a0cf5928a56319a164eef662731
Fadlian17/Week_2
/h2/namefile6.py
142
3.75
4
# range first = int(input("Input pertama : ")) second = int(input("Input kedua : ")) for output in range(first, second+1): print(output)
8d6a0509c2961dfd1db418b46d25a6bd31d1462e
naliniganesan/priya1
/90.py
89
3.53125
4
e1=input() e2=[] for i in e1: if i.isnumeric(): e2.append(i) print("".join(e2))
a40c2ce1a60b42aff04cf319daf3bb85be50f101
naliniganesan/priya1
/80.py
86
3.625
4
p1=input() p1=list(p1) for i in p1: i=int(i) if(i%2!=0): print(i,end=" ")
cde224ed5f8691edbe141794b4535e0cad211d09
Annarien/Exam-Practise
/Lecture4/NumpyComplex.py
363
3.640625
4
import numpy def exp_prod(m,n,N): #defining an imaginary unit J=numpy.complex(0,1) #rest of code is real numbers x=numpy.arange(0,0,N)*2*J*numpy.pi/N return numpy.sum (numpy.exp(-1*x*m)*numpy.exp(x*n)) if __name__=='__main__': print (exp_prod(0,0,8)) print (exp_prod(2,4,8)) print (exp_...
458199f43fa6e68bf5fb244f67e7ca1ab54e0e51
Annarien/Exam-Practise
/Lecture3/Lists.py
235
3.765625
4
mylist=['a','b',4.0,5,['d',99]] print (mylist) print (mylist[0]) print (mylist[1]) print (mylist[2]) print (mylist[3]) print (mylist[4]) print (mylist[-1]) print (mylist[-2]) print (mylist[-3]) print (mylist[-4]) print (mylist[-5])
f1bee033404e488367764c89353caa5798015b37
PaulCardoos/pythonBasics
/ListComprehensions/Examples/concatLists.py
214
4.21875
4
#concatenting lists in python is like combing them x = [1, 2, 3] y = [4, 5] z = x + y print(z) #z = [1, 2, 3, 4, 5] #if you multiple 3 * x it is similar to x + x + x print(3 * x) #[1, 2, 3, 1, 2, 3, 1, 2, 3]
08f9a8c7e174acc88b18811e4b2b6ee2b6bc0c4f
Liquid-sun/MIT-6.00.1x
/week-4/fruits.py
1,665
4.21875
4
""" Code Grader: Python Loves Fruits (10 points possible) Python is an MIT student who loves fruits. He carries different types of fruits (represented by capital letters) daily from his house to the MIT campus to eat on the way. But the way he eats fruits is unique. After each fruit he eats (except the last one wh...
d43a9d3ba885470d292cb3d377913f7257862571
Liquid-sun/MIT-6.00.1x
/week-1-2/payments3.py
731
4.125
4
#!/usr/bin/env python balance = 320000 annualInterestRate = 0.2 monthlyInterestRate = annualInterestRate / 12.0 min_pay = balance / 12 max_pay = (balance * (1 + monthlyInterestRate)**12) / 12.0 ans = (min_pay + max_pay) / 2 while(balance <= 0): print('pay: ', ans) for month in range(1, 13): balance -= a...
2dfc365283d74732559002389ca6b526ec4d0891
Liquid-sun/MIT-6.00.1x
/quiz/flatten.py
616
4.46875
4
#!/usr/bin/env python """ Problem 6 (15 points possible) Write a function to flatten a list. The list contains other lists, strings, or ints. For example, [[1,'a',['cat'],2],[[[3]],'dog'],4,5] is flattened into [1,'a','cat',2,3,'dog',4,5] """ def flatten(aList): ''' aList: a list Returns a copy of a...
e9500725b35803b18f3e091ff62d447dc3a7d788
Liquid-sun/MIT-6.00.1x
/quiz/satisfies.py
2,105
4.09375
4
#!/usr/bin/env python """ Problem 8 (20/20 points) Write a Python function called satisfiesF that has the specification below. Then make the function call run_satisfiesF(L, satisfiesF). Your code should look like: def satisfiesF(L): """ Assumes L is a list of strings Assume function f is already defined...
96f5e490d0d0e216bc13b8ac4b6fced2a3888e86
Liquid-sun/MIT-6.00.1x
/week-6/queue.py
1,694
4.46875
4
#!/usr/bin/env python """ For this exercise, you will be coding your very first class, a Queue class. Queues are a fundamental computer science data structure. A queue is basically like a line at Disneyland - you can add elements to a queue, and they maintain a specific order. When you want to get something off the en...
8a5ed2be6290e9b24d9f875b6911b37a35288eac
ZippoCode/Patter-Recognition-Machine-Learning
/naive_bayes/naive_bayes.py
5,041
3.625
4
''' Class that models a Naive Bayes Classifier ''' import numpy as np class NaiveBayesClassifier: ''' ''' def __init__(self): ''' Class constructor ''' self._classes = None self._num_classes = 0 self._eps = np.finfo(np.float32).eps # Array of c...
d34b5d4f791efb03822cd6841ba5f7636cf635f1
prajaktasangore/coding-challenge-2015
/PythogorousTriplets.py
787
4.3125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Prajakta Sangore # Date: 30th September 2015 # Problem: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet for which a + b...
7665b12a27dd3b3b3f7965c212241398e06310f6
Ruknin/Day-08
/Day 08 List2/Lesson8a.py
313
3.953125
4
Friends = ('Sovon','pritom','rohit','Zobayer') for x in Friends: print(x,end='\t') '''print("\nTotal number of Friends:", end="") print(len(Friends))''' print("Total number of Friends {0}".format(len(Friends))) digits=(1,2,3,4,5,6,7,8,9) print(min(digits)) print(max(digits)) print(sum(digits))
1dc3300bbf8789467745aea30b6909efe169b9ed
billangli/LeetCode
/medium/binary_tree_zigzag_level_order_traversal.py
992
3.765625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def zigzagLevelOrder(self, root: TreeNode) -> List[List[int]]: result = [] level = 0 ...
974b853bacdb5056821f21eaf4d535d8c0c5a482
billangli/LeetCode
/medium/path_sum_iii.py
817
3.671875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def pathSum(self, root: TreeNode, sum: int) -> int: if not root: return 0 ...
cf8f0e06d50bb9d9ca97a77613ccd166e113fc04
billangli/LeetCode
/medium/vertical_order_traversal_of_a_binary_tree.py
1,017
3.890625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def verticalTraversal(self, root: TreeNode) -> List[List[int]]: grid = defaultdict(lambda: defaultdi...
95ea28b0f562647a6338872d776e9cc990ee458a
billangli/LeetCode
/easy/design_hashset.py
2,100
3.796875
4
class Node: def __init__(self, item: int): self.item = item self.next = None def append(self, item: int): curr = self while curr.next is not None: if curr.item == item: return curr = curr.next if curr.item != item: ...
89734c08028c83853a01707c8b32f5fffe788965
billangli/LeetCode
/easy/add_binary.py
1,029
3.5625
4
class Solution: def addBinary(self, a: str, b: str) -> str: carry = "0" result = "" if len(a) > len(b): b = "0" * (len(a) - len(b)) + b elif len(a) < len(b): a = "0" * (len(b) - len(a)) + a for i in range(len(a) - 1, -1, -1): i...
394e985951a996af13d2bd683a60a0586ab711e5
billangli/LeetCode
/medium/4sum.py
2,848
3.5625
4
from typing import List import unittest import collections class Solution: def fourSum(self, nums: List[int], target: int) -> List[List[int]]: """ The idea is to find all sums of pairs and then pair the sums to quads freqs: dictionary of frequencies of numbers in nums freqs_keys: ...
c8a6d7caef5c558d448908ba2f764f4adbfab1d8
chunkify/Course_Materials
/CMPT 830_Bioinformatics_and_Computational_Biology/Assignment_1/Solution/Exercise 2.py
2,098
4.21875
4
#!/usr/bin/env python3 # This script will open the file "Glycoprotein.fasta" and read each line of the # file within a for-loop. That means that each iteration through the for-loop # will be performed with a new (the next) line of the input file. The # number of characters in each line is printed. # Open the file #f...
6e04c6bbfb0e8952c51144cb4f935c9ac8582899
apatel16/cs50
/pset6/credit/credit.py
1,063
3.78125
4
import cs50 while True: print("Enter credit card number: ") cc_number = cs50.get_float() if not cc_number: continue else: break temp = cc_number i = 0 sum1 = 0 sum2 = 0 while (temp != 0): digit = int(temp % 10) temp = int(temp / 10) if (i % 2 == 0): sum2 = sum2 ...
0033aff6797f87d4797b1ab5f6bde307c3417912
ashrafuzzaman1973/python-basic
/operator_overloading.py
251
3.859375
4
class Student: def __init__(self,m1,m2): self.m1 = m1 self.m2 = m2 def __add__(self,other): m1 = self.m1+other.m1 m2 = self.m2+other.m2 s3 = Student(m1,m2) return s3 s1= Student(34,38) s2= Student(43,40) s3 =s1+s2 print(s3.m2)
12e2cafcb8e530cbcb59b383ea204533b73de94e
ashrafuzzaman1973/python-basic
/for_loop.py
163
3.765625
4
num = [10,20,22,12,30] print(num) """ index = 0 n = len(num) while index < n: print(num[index]) index= index+1 """ sum = 0 for x in num: sum = sum+x print(sum)
b87ab17b096cb7c1eed8dd619788156da0ce6047
ashrafuzzaman1973/python-basic
/logical.py
424
4.1875
4
''' num1 = 30 num2 = 50 num3 = 40 if num1 > num2 and num1 > num3 : print(num1) elif num2 > num1 and num2 > num3 : print(num2) else: print(num3) ''' #vowel - a,e,i,o,u ''' ch = 'b' if ch == 'a' or ch == 'e' or ch == 'i' and ch == 'o' or ch == 'u' : print("Vowel") else: print("Consonant") ''' marks...
1d879c225bd027149809a48f3cb3e513098a1153
littlebee/shelly-bot
/src/common/fps_stats.py
1,221
3.6875
4
""" FpsStats - A class to track overall and floating frames per seconds """ import time # last n seconds to use for fps calc FPS_WINDOW = 60 class FpsStats(object): def __init__(self): self.start() # can call start after init, or pause and start for more accuracy def start(self): self.s...
4f4365a61e5059cd84ce6bdbdeaca7539983fcae
andrewbub/Projects
/MD5/test.py
232
4
4
#!/usr/bin/env python2.7 import string import itertools ALPHABET = string.ascii_lowercase + string.digits length = 2 def permutation(length, ALPHABET): for word in itertools.permutations(ALPHABET, length): yield ''.join(word)
b9500def99f7ad4b7c0f8d3f9212f448b14ec32d
andrewbub/Projects
/CollegeSearch/WS/_college_database.py
5,853
3.53125
4
# Andrew Bub, Harry Gebremedhim, & Molly Pierce # CSE30332 - Final Project: OO API # November 27, 2017 import csv class _college_database: def __init__(self): self.college = {} # dictionary with name as key and all other info self.state= {} # dictionary with state and then list of colleges self.city = {} #...
2e7ff854254b84bd18dd07b4066bbc57a3a1ec33
srikant-ai/Data_Structure_-_Algo_in_Python
/merge_sort.py
900
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 25 01:32:25 2021 @author: Srikanth Sahoo """ def merge_sort(arr): if len(arr) <= 1: return arr mid = len(arr)//2 left = arr[:mid] right = arr[mid:] merge_sort(left) merge_sort(right) merge_sorted_arrays(left, r...
866d870339f6ec9f71517bf4e9059ca6db055ea9
jrbella/python_open_work
/pandas/csv/working_with_pandas.py
126
3.828125
4
import pandas df1=pandas.DataFrame([[2,4,6],[10,20,30]],columns=["Price","Age","Value"],index=["First","Second"]) print(df1)
083f063bcb96b2af4e43b4e3c88c3e6abaf355ca
jrbella/python_open_work
/more_functions.py
1,168
3.625
4
#imports #basic function for area def area(a, b): return a * b print(area(4,5)) #explicit function argument def area_2(a,b): try: if(isinstance(a, (int, float)) and isinstance(b, (int, float))): return a * b else: return (float(a) * float(b)) except ValueError: ...
20059d8247158bdcfd22233553aca472d36dc312
bsimps01/Tweet-Gen
/rearrange.py
250
3.609375
4
import random words = ["how", "now", "brown", "cow"] def random_cow(): for rand_index in words: rand_index = random.randint(0, len(words) - 1) print(words[rand_index]) return True if __name__ == '__main__': random_cow()
626006913e5a6c30165a0d26e4ad18a31a6017a7
adamr14/consumer-classifier
/custom_kmeans.py
4,036
3.53125
4
# ========================================================= # HW 4: Unsupervised Learning, K-Means Clustering # CS 4824 / ECE 4484, Spring '21 # Written by Matt Harrington, Haider Ali # ========================================================= """ Adam Rankin adamr14 """ # Standard imports import random import...
885b249d7459d23db7f518cdab6944f8c531b60b
cha63506/W4112_Project2
/Benchmark/Results/compile.py
3,945
3.71875
4
#! /usr/bin/python __author__ = 'Jervis Muindi' import argparse from result import Result def read_file_to_string(file_path): f = open(file_path) line = f.readline() result = line while line: line = f.readline() result += line f.close() return result def parse_record(record): """ Parses ...
d3db0e57da66e3105e022c17ee7567a2358b9541
chriscross00/cci
/data_structures/linked_lists.py
2,176
4.15625
4
# https://www.codefellows.org/blog/implementing-a-singly-linked-list-in-python/ # READ THIS https://www.greenteapress.com/thinkpython/thinkCSpy/html/chap17 # .html # creating the class Node class Node: def __init__(self, data, next=None): self.data = data self.next = next def get_data(self)...
d33091ab6c9d672c34b450f3791845df1e53cfea
chriscross00/cci
/key_problems/new.py
772
3.890625
4
# given a string, check if brackets are balanced # Stack: LIFO # 1. initialize stack # 2. iterate through string # 3. if char in open_bracket dict, push to stack # 4. if char is in closed_bracket dict, pop from stack # 5. compare to def solution(string): stack = [] open_bracket = ['[', '{', '('] closed_bracket = ...
4d3d84949839d146f0c91caa337bc4912b5cd7a0
chriscross00/cci
/algorithms/bfs.py
1,323
4
4
# https://stackoverflow.com/questions/46383493/python-implement-breadth-first-search graph= {} graph[0] = [1,5] graph[1] = [2] graph[2] = [3] graph[3] = [4,5] graph[4] = [0] graph[5] = [2,4] # This is a modified bfs that is written much more like the dfs. Use this instead. def bfs(dict, start): queue, path = [st...
4c296c5109ecb02edae771aacaf925c98b646144
chriscross00/cci
/ch2/ch2.3.py
1,013
4.0625
4
# Delete a node from the middle of a singly linked list, given only access # to that node. # # # Similar to the remove method: # # Give a current, create a next node # Set current == next # set next == next.get_next() # Return True # Time: O(1) class Node: def __init__(self, data, next= None) -> object: ...
05d5866701a186bb0989940214a5022432e3c4ab
chriscross00/cci
/ch1/ch1.7.py
189
3.640625
4
# Rotate Matrix: """ Approach: 1) For loop -Iterate over matrix -For i in range(col): >for j in range(row): -If [i][j] == 0 - """
2223c68bac439630074699e93ae573c221042bc9
gefranco/holbertonschool-interview
/0x22-primegame/0-prime_game.py
1,570
3.78125
4
#!/usr/bin/python3 """ ... """ def isWinner(x, nums): """ ... """ if x <= 0 or nums is None or len(nums) < x: return None index = 0 maria_points = 0 ben_points = 0 while index < x: array_primes = [] array_nums = [] maria_turn = True get_array_num...
d7e23b71528a13ef47220ff5a64bdc68fecfabcb
shruti735/Machine-Learning
/Learning11.py
1,079
3.71875
4
import numpy as np import matplotlib.pyplot as plt def estimate_coef(x,y): print(x) print(y) n = np.size(x) print("Size - ",n) m_x, m_y = np.mean(x), np.mean(y) print("Mean x- ",m_x,"Mean y - ",m_y) SS_xx = np.sum(y * x - n * m_y *m_x) SS_xy = np.sum(x * x - n * m_x * m_x) print(SS_x...
7c7f15ee756005af05d6da52e712f9c9f1e2189f
LauraReynosa/Reto-18
/test_gun.py
1,498
3.703125
4
from unittest import TestCase from main import Gun import sys sys.tracebacklimit = 0 class TestGun(TestCase): def setUp(self): print(self._testMethodDoc) self.gun = Gun(5) def test_lock(self): """-- Test Gun Lock""" msg = "The gun is not lock" self.gun.lock() se...
639ec7d665f8f7e83aea8c2fe54ba84a0b242955
bhawnagurjar27/Programming-Practice
/Codechef/LongChallenge/VACCINE2/codeA.py
565
3.546875
4
num_test_cases = int(input()) while num_test_cases > 0: N =int(input()) red = input() red_count = 0 blue_count = 0 red = list(map(int,red)) blue = input() blue = list(map(int,blue)) for i in range(N): if red[i] > blue[i]: red_count = red_count + 1 elif red[i]...
a1ac7c7dafa2aea2d432aeb83938cd058ae0fdd1
bhawnagurjar27/Programming-Practice
/Coding Problems/Minimum and maximum of array/min_and_max_of_array.py
448
3.59375
4
number_of_testcases = int(input()) for _ in range(number_of_testcases): N = int(input()) array = list(map(int, input().split())) max_element = array[0] min_element = array[0] for i in range(len(array)): if array[i] < min_element: min_element = array[i] if a...
6ff41863eeb9bdc2f87346566b7b82f5464a02ee
bhawnagurjar27/Programming-Practice
/Codechef/Beginner's Level/ATM2/ATM2.py
685
3.6875
4
number_of_test_cases = int(input()) for _ in range(number_of_test_cases): number_of_people, total_money_available = map(int, input().split()) people_wants_to_withdraw_money = list(map(int, input().split())) answer = '' # Here answer variable is used as string to determine whether they will get th...
75bb3b2633210eb160034a0cb515e1d61db76d4c
KertisJones/05-checkers
/05-checkers.py
15,468
3.5
4
#!/Library/Frameworks/Python.framework/Versions/3.6/bin import sys, pygame, time, random from Board import Board, Piece, Square assert sys.version_info >= (3,4), 'This script requires at least Python 3.4' pygame.init() font = pygame.font.SysFont("arial",30) #easy to divide by sixteen size = (width,height) = (800,800)...
a1d614c6aad6241be42659673d077eba7c4418de
Katayounb/class-work
/testinng2.py
359
3.75
4
mylist = [1,2,3,4,5,6,7,8,9] newlist = mylist[4:8] print(newlist) for n in newlist: n *= 2 print(n) myevenlist = [] myoddlist = [] list1=mylist[0:5] print(list1) list2=mylist[5:9] print(list2) print(list1, '',list2) for n in mylist: if n % 2 == 0: myevenlist.append(n) else: myoddlist.a...
a1dbffc25c40c672891996c435654cdac3998a79
jay-master/LeetCode
/Easy/[14]Longest_Common_Prefix.py
2,549
4
4
""" 14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","racecar","car"] Output: "" Explanation: There is no common ...
d3f718a4536d64ee41368f2b01956d463794874c
Divadsjo/Skola
/Färdigt/Dice_game.py
323
3.546875
4
p1 = str(input()) p2 = str(input()) p1 = p1.split(" ") p2 = p2.split(" ") print(p1) print(p2) p1dice = (int(p1[0])+int(p1[1]))/2 + (int(p1[2])+int(p1[3]))/2 p2dice = (int(p2[0])+int(p2[1]))/2 + (int(p2[2])+int(p2[3]))/2 if p1dice == p2dice: print("Tie") elif p1dice > p2dice: print("Gunnar") else: print("Emm...
146d6dee2cf6477f9ae5342f0274173d964c0599
AnanthKumarD/CodePractice
/leetCode/JuneChallenge_2020/P9.py
462
3.90625
4
# link:- https://leetcode.com/explore/featured/card/june-leetcoding-challenge/540/week-2-june-8th-june-14th/3356/ def searchInsert(nums, target): for i in range(len(nums)): #print(i,'.....',len(nums)) if nums[i] >= target: return i; if i == len(nums)-1: return i+1; ...
2b3fc899579eb01c57bdee84bba47918656be5e8
AnanthKumarD/CodePractice
/leetCode/palindromeNumber.py
438
3.703125
4
def isPalindrome(x): d = str(x); i = 0; j = len(d)-1; while( i <= (len(d)-1) and j >= 0): flag = 1; #print(i ,'>' ,(len(d)-1) ,',and', j ,'<', 0) if(d[i] != d[j]): flag = 0; break; i = i+1; j = j-1; if(flag == 0): return Fa...
4f4b1f8d07e12ede2fc210ab563bd6ece33feeab
BlackTimber-Labs/DemoPullRequest
/Python/ashi77.py
1,785
4.28125
4
from random import randint EASY_LEVEL_TURNS = 10 HARD_LEVEL_TURNS = 5 #Function to check user's guess against actual answer. def check_answer(guess, answer, turns): """checks answer against guess. Returns the number of turns remaining.""" if guess > answer: print("Too high.") return turns - 1 elif guess...
13300283d829e0a97591566f852896cbf30e2a00
BlackTimber-Labs/DemoPullRequest
/Python/tripur1.py
303
4.15625
4
# to find sum # of elements in given array def _sum(arr): sum=0 for i in arr: sum = sum + i return(sum) # driver function arr=[] # input values to list arr = [12, 3, 4, 15] # calculating length of array n = len(arr) ans = _sum(arr) # display sum print ('Sum of the array is ', ans)
2045422cd54dd0b667bc2f0332b4b98f01dcbff1
BlackTimber-Labs/DemoPullRequest
/Python/pranavagrawal321_countdowntimer
279
3.65625
4
import os import time b = int(input("Enter the time in seconds: ")) a = b while a > 0: os.system("cls") print(f"Timer for {b} seconds") print('You have \033[1m' + str(a) + "\033[0m", 'seconds left') a -= 1 time.sleep(1) os.system("cls") print("Time Up")
30bac6e5adb1d8700dd26e51ab90101b6e1bbf56
cqvu/Web-Scraping-Projects
/topMovies.py
848
3.84375
4
""" Scrape IMBD website for most popular movies of a certain year and display the titles of the movies. IMBD website: https://www.imdb.com/search/title?release_date=2018 Sources of help: https://medium.com/@nishantsahoo/which-movie-should-i-watch-5c83a3c0f5b1 """ import requests from bs4 import BeautifulSo...
c282aa91b1e480b906321470d318c8a5cdb419d4
dearhannah/xrdfit
/xrd2021/element_data.py
1,568
3.515625
4
""" This module is a database for element information. """ def crystal(ele): """ Tell me the name of element. I will tell you its crystal structure and recorded lattice parameter. """ if ele in ('Cu', 'cu'): lat_a = 3.597 # unit is A lat_b = lat_a lat_c = lat_a crys...
2683ac7db3ac824ac5b58f05a14e10ceaa80de8d
Lunaniri/Homework
/menu.py
489
3.859375
4
print "Welcome to the menu programme!" menu={} while True: dish=raw_input("Please enter the name of the dish") price=raw_input("Please enter the price of the '%s': " % dish) menu[dish]=price new=raw_input("Would you like to add another dish? (yes/no) ") if new.lower==no: break print "Men...
ae33b423103085042b0b0084035f20108689778e
fizzahwaseem/Assignments
/31_gcd.py
394
4.21875
4
#Python program to compute the greatest common divisor (GCD) of two positive integers. print('To find GCD enter ') num1 = int(input('number 1 : ')) num2 = int(input('number 2 : ')) if num1 > num2: greater = num1 else: greater = num2 for i in range(1, greater+1): if((num1 % i == 0) and (num2 % i == 0...
17d4b295a194fe2736a0b3970fcb1724e0ff3424
fizzahwaseem/Assignments
/04_n+nn+nnn.py
176
4.25
4
# Python program that accepts an integer (n) and computes the value of (n + nn + nnn) n = float(input("Enter a number: ")) print(n, "+", n**2, "+", n**3, "=", n + n**2 + n**3)
bf7277d5525a73caaa50fa00b3189114a636ac34
fizzahwaseem/Assignments
/38_fibnocci.py
153
3.875
4
#Python program to get the Fibonacci series between 0 to 50 a = 0 b = 1 while b <= 50: c = a + b a = b b = c if b <= 50: print(b)
37bd3a47aacd1402a5e1a2dd9bc3d828b0222027
fizzahwaseem/Assignments
/26_digit_to_etc.py
257
4.53125
5
#Python program to convert an integer to Binary, Octal and Hexadecimal numbers decimal = int(input("Enter an integer: ")) print(decimal, "to binary: ", bin(decimal)) print(decimal, "to octal: ", oct(decimal)) print(decimal, "to hexadecimal: ", hex(decimal))
9757061960d039b4d2a4d1ba4ebde2786b1ccdfa
fizzahwaseem/Assignments
/25_sum_of_digits.py
194
4.375
4
#Python program to calculate the sum of the digits in an integer n = input("Enter a number: ") sum_of_digits = 0 for i in n: sum_of_digits += int(i) print("sum of digits is ", sum_of_digits)
bd671af590ae1ec9251afc96487aa2e1f95db6cb
fizzahwaseem/Assignments
/20_time_to_seconds.py
224
4.28125
4
#Python program to convert all units of time into seconds. hour = int(input("Enter time in hours: ")) minute = int(input("Enter time in minutes: ")) t = (hour * 60 * 60) + (minute * 60) print("Total time in seconds is: ", t)
26a3b257f2a1797e32773e653195450f68e83729
AnneOkk/Alien_Game
/bullet.py
1,561
4.125
4
import pygame from pygame.sprite import Sprite class Bullet(Sprite): """A class to manage bullets fired from the ship""" def __init__(self, ai_game): """Create a bullet object at the ship's current position.""" super().__init__() self.screen = ai_game.screen self.settings = ai_...
1ac916c01bc05e16134e53bf9567116e58d079d9
NguyenHungThuong/Deeplearning.AI
/C2-Improve Deep Learning/Gradient_Checking.py
22,603
4.15625
4
#!/usr/bin/env python # coding: utf-8 # # Gradient Checking # # Welcome to the final assignment for this week! In this assignment you'll be implementing gradient checking. # # By the end of this notebook, you'll be able to: # # Implement gradient checking to verify the accuracy of your backprop implementation # ##...
3fc9eefccf111f2c954cddef74e6e8b966ae4aa9
stag152766/gb_ik_python
/Lesson2/les_2_task_6.py
837
4.09375
4
""" 6. Написать программу, где генерируется случайное целое число от 0 до 100. Пользователь должен его отгадать максимум за 10 попыток. После каждой неудачи должно сообщаться, больше или меньше загаданного то число, что ввел пользователь. Если за 10 попыток число не отгадано – вывести его. """ import random r = rando...
5f905e4ef25a8d4900dccfad05e7c70c89c77ae0
stag152766/gb_ik_python
/Lesson3/task3.py
237
3.53125
4
import random a = [random.randint(-100,100) for _ in range(100)] print(a) arr_below = [] arr_large = [] for i in a: if i < 0: arr_below.append(i) else: arr_large.append(i) print(arr_below) print(arr_large)
5c794b4c2ac27e1f76878562810f778850615ebe
stag152766/gb_ik_python
/Lesson2/les_2_task_2.py
549
3.875
4
""" 2. Посчитать четные и нечетные цифры введенного натурального числа. Например, если введено число 34560, то у него 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5). """ o = [] e = [] num = int(input('Введите натуральное число: ')) while num != 0: r = num % 10 % 2 num = num // 10 if r == 0: e.appen...
6a4e9d1b7145dab2c6768fbb247f5d15f11c96cd
stag152766/gb_ik_python
/Lesson2/les_2_task_7.py
594
3.875
4
""" 7. Написать программу, доказывающую или проверяющую, что для множества натуральных чисел выполняется равенство: 1 + 2 + … + n = n × (n + 1) / 2, где n – любое натуральное число. """ n = int(input("Введите натуральное число: ")) sum1 = 0 for i in range(1,n+1): sum1 += i sum2 = int(n * (n + 1) / 2) if sum1 ==...
c062d9667d8725fd95d4faec3a6db0e4b20264d9
stag152766/gb_ik_python
/Lesson5/les_5_task_1.py
1,550
3.921875
4
# 1. Пользователь вводит данные о количестве предприятий, # их наименования и прибыль за четыре квартала для каждого предприятия. # Программа должна определить среднюю прибыль (за год для всех предприятий) # и отдельно вывести наименования предприятий, чья прибыль выше среднего и ниже среднего. from collections import ...
6c2b9739df7609016584fdf818ee4fcb50f399db
stag152766/gb_ik_python
/Lesson3/les_3_task_3.py
624
3.640625
4
# 3. В массиве случайных целых чисел поменять местами минимальный и максимальный элементы. import random a = [random.randint(-100, 100) for _ in range(10)] print(a) mn = 0 mx = 0 for i in range(len(a)): if a[i] < a[mn]: mn = i elif a[i] > a[mx]: mx = i # spam = a[mn] # a[mn] = a[mx] # a[mx] ...
a0ee9885fe2a9a129441f34fc0ffe43418e99326
Daniel-Messias-Bueno/jogos-python
/questoes1e2.py
1,724
3.578125
4
class Tank(object): def __init__(self, name): self.name = name self.alive=True self.ammo=5 self.armor=60 def __str__(self): if self.alive: return "%s (%i armor, %i shells)" % (self.name, self.armor, self.ammo) else: return "%s (DEADE)" % s...
2fd352ac15c327b7269739e1fb3b018f6fb74672
bramlenting12345/multiplier-x.py
/tafelx .py
814
3.6875
4
# Het programma begint met de vraag: “Van welk getal wilt u de tafel zien?” # Het antwoord van de vraag wordt als argument aan een function mee gegeven die 1 parameter heeft dat een int moet zijn. # De function laat door middel van een loop de tafel (1 t/m 10) van het gekozen getal op het scherm zien. def tafel(a,...
0e7bb4dbdc0e6e7d58fe98e439ee4854ac932b82
JohnReddyZhang/week9
/send_weather.py
1,681
3.796875
4
# Prompts for a zip code # and displays the current temperature # and also sends it as a text message to your phone. # Python 3.x import keys from sys import exit from urllib.request import urlopen from twilio.rest import Client import json zip = input("What's your zip code? ") if len(zip) != 5: print("That's no...
51a3a43955c93cfadfd3ae3cc7205fa7be48f68e
Christian-Lin/RPS
/RPS.py
6,201
4.03125
4
"""This program plays a game of Rock, Paper, Scissors between two Players, and reports both Player's scores each round.""" import random import os os.system("") moves = ['rock', 'paper', 'scissors', 'spock', 'lizard'] playersText = """ Rock, Paper, Scissors, Spock, Lizard! Rules of the game: - ...
60d7f5c3bba2feeb5ea546c523952aebc14c5654
ilinxiao/syncitems
/tests/test_dynamic_attribute.py
409
3.515625
4
from types import DynamicClassAttribute class BaseClass: name = "linxiao" if __name__ == "__main__": base = BaseClass() base.name = "linxiao-new" base.age = 30 BaseClass.age = 30 for c in BaseClass.mro(): print(c) for k, v in c.__dict__.items(): if isinstance(v, ...
bbf8b3e5f29aeb6e5a400d993c9284e187e26f3e
JohntyR/Day23_TurtleCapstone
/scoreboard.py
769
3.734375
4
from turtle import Turtle ALIGNMENT = "center" FONT = "Tahoma" FONT_SIZE = 16 FONT_WEIGHT = "normal" FONT_COLOUR = "black" X_POS = -250 Y_POS = 270 class Scoreboard(Turtle): def __init__(self): super().__init__() self.level = 0 self.color(FONT_COLOUR) self.penup() self.got...
0a3f9de483ec4b29664078ed081f3df310c5a98c
nguyendodangquang/FreeCodeCamp_Data_Analysis_Projects
/Sea_Level_Predictor/sea_level_predictor.py
1,160
3.546875
4
import pandas as pd import matplotlib.pyplot as plt from scipy.stats import linregress def draw_plot(): # Read data from file df = pd.read_csv('epa-sea-level.csv') # Create scatter plot fig, ax = plt.subplots(figsize=(10,7)) ax.scatter(x=df['Year'], y=df['CSIRO Adjusted Sea Level']) # Create ...
49adfdb297cf6ede2916536ee65c1acd1fec9bc1
saurav2525/python-
/Ass-8.py
2,572
3.890625
4
#Qusetion 1 class circle: def __init__(self,r): self.radius=r def getArea(self): return 3.14 * self.radius * self.radius def getCircumference(self): return 2 * 3.14 * self.radius t1 = circle(6) print("area of circle is ", t1.getArea()) print('circumference of circle is ...
7e2b137f023a898f481116c4c45c642f1bdaeb4a
saurav2525/python-
/assignment 9.py
771
3.921875
4
#Question1 a=3 if(a<=4): try: a=a/(a-3) except ZeroDivisionError: print("It is a zero division error") #Question2 l=[1,2,3] try: print(l[3]) except IndexError: print("It is an index error") #Question3 #try: # raise NameError("Hi there") #except NameError: # print("An exception") ...
f510f7e05f53e0ba9f4b56401cf96787021f4b5a
k64pony/Module5_python
/Module5.py
574
3.9375
4
#Assignment 1 runstring = """ def math(a, b): sum = float(a) + float(b); sub = float(a) - float(b); mul = float(a) * float(b); div = float(a) / float(b); print('{0} plus {1} is {2}'.format(a, b, sum)) print('{0} minus {1} is {2}'.format(a, b, sub)) print('{0} times {1} is {2}'.format(a, b, mul)) print('{0} d...
6d253bef44cc013a3e86882ebd0c20da81633e19
mustapha1964/My-First-Repository
/passcode.py
945
3.65625
4
# # This little program provides all possible 4 digits pascodes # from string import digits # from itertools import product # for passcode in product(digits, repeat=4): # print("".join(passcode)) # # This little program provides all possible 4 (digits & letters) passcode # from string import ascii_l...
394a336b6ef3927def396c04a6f8365f89c23929
yusukenishimori/my-Python-Study
/ex24.py
1,196
3.984375
4
print("すべてのことを'練習'しよう。") print('そのためには、\\を使った\'エスケープ\'を理解する必要がある。') print('\nは改行で\tはタブだ') poem=""" \tThe lovely world with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an explanation \n\t\twhere there is none. """ print("-----------") print(poem) prin...
c3d33098170996546565972f615b7634ddb5a81e
1337yolodosr/Math-programs
/SolveQuadratics.py
1,924
3.703125
4
import math #math.sqrt import sys #sys.exit import time #time.sleep def Simultaneous_Equation_Solver(): print('''In development redirecting you to the quadratic solver and thanks for trying Sho's solver system...''') time.sleep(3) Quadratic_Equation_Solver() def Quadratic_Equati...
70a0a83fd53d49a1e962a7c2c769565c84be3f9a
timofeyr/k
/hangamn/hangman.py
3,294
3.953125
4
import sys import sqlite3 con = sqlite3.connect('players.db') c = con.cursor() def add_user(): username = str(input("Type in username: ")) c.execute("INSERT INTO players VALUES (?, ?)", (username, 0)) con.commit() def add_score(user): score = c.execute("SELECT score FROM players WHERE username = ?"...
c6aa3e3cd4d127781449ebfb8e20d6de297c5a68
Sachingupta30/Code_For_Beginner
/Code_For_Beginners/armstrong.py
643
3.96875
4
# Armstrong Numbers.. # number of n digit which are equal to sum of nth power of its digit. # examples : 5--> # (a) find no of digit(n) : n = 1 # (b) 5**1 = 5==5(original num) so it is armstrong number. # examples : 153--> # (a) n = 3 # (b) 1**3 + 5**3 + 3**3 == 1+125+27 == 153 == 153 (original num) # so it is armsstr...
227814427772fb91d8abc57aa6ddafda5afa291c
Legionof7/CISPython
/JustinZhengLab4.py
614
3.921875
4
########################## # CIS 117 Python Programming: Lab #4 # # Objects and Classes # ########################## class Message: def __init__(self, sender, recipient): self.sender = sender self.recipient = recipient self.body = "" def append(self, line): self.body += line +...
fff26cc770a61d90768741116806ccb61172c048
EkaterinaAnufrieva/Repo1
/3 урок 1 задание.py
406
3.890625
4
delimoe = float(input("Введите делимое ")) delitel = float(input("Введите делитель ")) while delitel == 0: print("Деление на 0 запрещено. Введите число отличное от 0 ") delitel = float(input("Введите делитель ")) def chastnoe(a, b): return a / b print(round((chastnoe(delimoe, delitel)), 2))...
343cd7567341f94b32b70ac9b1089734aa79aaaf
trev3rd/gogo
/guess1.py
1,622
4.46875
4
import random guessesTaken = 0 #this represents how many times the user has tried guessing the right number starting from zero number = random.randint(1, 10) print(number) #this shows the random number the computer picked good for seeing if code works properly print(' I am thinking of a number between 1 and 10.') ...
a4509e8ea0ec20c45b4dc716fb8612de3b432228
hysz/leetcode
/kth_permutation.py
807
3.546875
4
from typing import List class Solution: def permute(current: List[int], entries: List[int], k: List[int]) -> List[int]: if not entries: k[0] -= 1 if (k[0] == 0): return current else: return None for i,entry in enum...
d866de7ed2a0c4d6de67d2e5c66a64d544fc9ab0
hysz/leetcode
/remove_nth_node_from_linked_list.py
1,215
3.984375
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def __repr__(self): return "%s -> %s"%(self.val, self.next) class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: # base case...
392c2fecab145784ebc6a186ada2acc42895d285
dineshneela/class-100
/main.py
482
3.546875
4
class Car(object): def __init__(self,model,color,company,speed_limit): self.color=color self.company=company self.speed_limit=speed_limit self.model=model def start(self): print("started") def stop(self): print("stop") def accelerate(self): ...
0a1a426a901d5f9bf54bd5852baeb6ca4e89a908
C-SON-TC1028-001-2113/listas---quiz-5-AllanBa17
/assignments/16DiagonalPrincipal/tests/input_data.py
510
3.75
4
# List of tuples # Each tuple contains a test: # - the first element are the inputs, # - the second are the output, # - and the third is the message in case of an error # To test another case, add another tuple input_values = [ # Test case 1 ( ["3","4"], ["","","La matriz no es cuadrada"], ...