blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
e2f9867fa525b01ffadecbe5b5185228cbe17464 | tupakulasuresh/practice | /py/remove_linked_list_ele.py | 3,335 | 4.15625 | 4 | import unittest
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
def __str__(self):
return '{}(val={})'.format(self.__class__.__name__, self.val)
def __repr__(self):
return self.__str__()
def remove_elemen... |
7f3d555b76e0dfb93f83212b0c4d0211d0c9824c | guilherme-witkosky/MI66-T5 | /Lista 2/L2E04.py | 270 | 4.0625 | 4 | #Exercício 4
letra = input("Informe uma letra :")
if letra.upper() == "A" or letra.upper() == "E" or letra.upper() == "I" == letra.upper() == "O" or letra.upper() == "U":
print("O letra informado é vogal")
else:
print("O letra informado é consoante") |
a86c6112acbf26ef2d81ab7cc45c0f10725e34e9 | AlessioVallero/algorithms-coursera | /part1/week2/intersection-of-two-sets/intersections_of_two_sets.py | 1,381 | 3.6875 | 4 | from functools import cmp_to_key
class TwoSets:
"""
Given two arrays a[] and b[], each containing n distinct 2D points in the plane
we count the number of points that are contained both in array a[] and array b[]
"""
@staticmethod
def compare(first, second):
if first[0] < second[0] or... |
7e841ae4292af9f9b67ae2ca4d721e599b4e1b21 | turdasanbogdan/PythonExs | /PythonWork/while_loop.py | 725 | 4.0625 | 4 | sandwich_orders=['pui','vita', 'pastrami','paine', 'pastrami', 'pastrami']
finished_sandwiches=[]
print("We ran out of pastrami")
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
while sandwich_orders :
finished = sandwich_orders.pop()
finished_sandwiches.append(finished)
print(finished_sandw... |
15883e8c6caad904459a635e13ea7e9a7861b971 | mish-511/cse-470-final | /view.py | 276 | 3.515625 | 4 | class Choose:
def choices():
n = """
====== Bakery =======
1. Number of available cakes
2. Vanilla cake $5
3. Chocolate cake $10
4. Strawberry cake $12
5. Total bill
6. Exit
"""
print(n)
|
5bc11fb46e6a48766b8d5a2e1dfbaee38949d4b7 | rishi772001/Competetive-programming | /DataStructures/BST/sum of tree.py | 553 | 3.703125 | 4 | '''
@Author: rishi
https://binarysearch.com/problems/Tree-Sum
'''
class Tree:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
sum = 0
def find(self, root):
if root is None:
return
Solu... |
a91d74e5f2f5c17e76152bd4a615da62dc8c7c47 | Suraksha-sachan/tathastu_week_of_code | /day5/program1.py | 594 | 3.84375 | 4 | def replace0with5(number):
number += suraksha(number)
return number
def suraksha(number):
result = 0
a = 1
if (number == 0):
result += (5 * a)
while (number > 0):
... |
9327d7e6f0f5036352db40e28100dafe0a5b2ed8 | Tylerssmith/pythonista-scripts | /TimeClock.py | 4,767 | 3.8125 | 4 | # coding: utf-8
'''
#---Filename: TimeClock.py
#---Author: coomlata1
#---Created: 02-17-2018
#---Last Updated: 02-18-2018
#---Description: Calculates the time elapsed in hours
& minutes between two user selected times. Ideal for
calculating hours in shift work. Code includes time
deductions for lunches if applicable.
... |
f8b36e5839d467d7743339e53ad3a516c45f74ae | mcaptain79/common-data-structures-implementation-in-python | /singlyLinkedList.py | 2,232 | 3.96875 | 4 | class X:
def __init__(self,key):
self.key = key
self.nexty = None
class LinkedList:
def __init__(self):
self.head = None
def List_Insert(self,key):
x = X(key)
x.nexty = self.head
self.head = x
def List_Delete(self,key):
isFound = False
... |
5b7b3d6c97b6c2b5db1f1d71e21ab69d9c9170f0 | annisa-nur/wintersnowhite | /processingnumeric.py | 2,031 | 4.28125 | 4 | # Program ini meminta pengguna memasukkan tiga buah angka float
# dan menuliskan keduanya, masing-masing dalam satu baris,
# ke file angka.txt
def main():
# [1] Minta pengguna memasukkan tiga buah angka desimal
# Gunakan prompt "Masukkan sebuah angka desimal: " untuk angka pertama
# dan prompt ... |
752b6ddfe6acc5ce0b1f50a654e1d51836329be4 | NenadPantelic/GeeksforGeeks-Must-Do-Interview-preparation | /String/Anagram.py | 468 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 3 20:13:57 2020
@author: nenad
"""
def anagram(str1, str2):
return "YES" if sorted(str1) == sorted(str2) else "NO"
# Test 1
str1, str2 = "geeksforgeeks forgeeksgeeks".split()
print(anagram(str1,str2))
# Test 2
str1, str2 = "allergy allergi... |
5704e97650acf987e7fb88e707eb0ada2f96fd74 | AndProg/lesson1 | /numbers.py | 190 | 3.734375 | 4 | v = int(input('введите число от 1 до 10: '))
print('введенное значение:' + ' ' + str(v))
print('введенное значение +10:' + ' ' + str(v+10))
|
3fee6fe64615eefc561f1cfdb45b434c69a1f0ab | lhayhurst/exercism | /python/isogram/isogram.py | 285 | 3.609375 | 4 | def is_isogram(string):
if string is None or len(string) == 0:
return True
string = string.lower()
letters = set(string)
for l in letters:
if not l.isalnum():
continue
if string.count(l) > 1:
return False
return True
|
23b3c46f1a00862fd00f31749827e38c915ccd26 | rafaelperazzo/programacao-web | /moodledata/vpl_data/83/usersdata/195/42385/submittedfiles/dec2bin.py | 137 | 3.65625 | 4 | # -*- coding: utf-8 -*-
from __future__ import division
n=int(input('digite n:'))
resto=n%2
i=0
soma=0
while n>0:
s=s+resto*10**i
n=n//2
|
2eb3fbd4ae7a9e2fe4118f7c1186ed85f2f4274c | Fightingkeyboard/CompSci | /03/PigLatin.py | 168 | 3.890625 | 4 | def PigLatin(str):
vowels = 'aeiouAEIOU'
if str[0] not in vowels:
str = str[1:] + str[0] + 'ay'
return (str)
else:
return str + 'ay' |
a35291a4a267d8f1a704959b9d30af99a985e178 | Neetika23/Machine-Learning | /Preprocessing/Standardization/without_normalizing.py | 268 | 3.515625 | 4 | # Split the dataset and labels into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y)
# Fit the k-nearest neighbors model to the training data
knn.fit(X_train,y_train)
# Score the model on the test data
print(knn.score(X_test,y_test))
|
99e7ce60cd9061a3d0125226d9ff9609b2dea775 | surajdakua/Exploratory-Data-Analysis | /HabermanEDA.py | 5,540 | 3.625 | 4 | '''
@author Suraj Dakua
Haberman Dataset/Kaggel to perform Exploratory Data Analysis(EDA).
EDA is for seeing what the data can tell us beyond the formal modelling and also summarize the data characteristics often with visual methods.
EDA can be also used for better understanding of data and main features of data.
Mac... |
76ae4d67a8f9709403c6ab3844834e6638c4c095 | rodmur/hackerrank | /algorithms/implementation/utopiantree_recur.py | 245 | 3.828125 | 4 | #!/usr/bin/python3
import sys
def grow(n):
growth = 0
if n == 0:
return 1
elif n & 1:
growth = 2*(grow(n-1))
else:
growth = grow(n-1) + 1
return growth
n = int(sys.argv[1])
h = grow(n)
print(h)
|
a7a9f37fa98cf6fc72cebe85d9f187e802ebe8c9 | GuilhermeAntony14/Estudando-Python | /ex040.py | 317 | 3.84375 | 4 | print('vamos descobrir a sua nota!')
n = float(input('Digite sua primeira nota: '))
n1 = float(input('Digite o segundo valor: '))
n2 = float((n+n1)/2)
print(f'A media e {n2}!')
if n2 <= 4:
print('Reprovado!')
elif n2 >= 5 and n2 < 7:
print('Recuperação!')
elif n2 >= 7:
print('\033[32mAprovado!\033[m')
|
11ff8c482b2c7813ea0766be7f3186a3cc33776a | calabaza91/python | /CoxCaleb_Lab10_EmployeeClass.py | 1,265 | 4.25 | 4 | #This program creates a list of three employees using a class
import Cox_employee
def main():
#Get list of Employees
employees = make_list()
#Display data in list
print('Here is the list of employees:')
display_list(employees)
def make_list():
#Make empty list
emp_list = []
#Get S... |
4bc86e76eb75ea25f5d12df13ecb70df9f65ee13 | CodecoolBP20172/pbwp-3rd-si-game-statistics-DeboraCsomos | /part2/export.py | 1,083 | 3.703125 | 4 | #!/usr/bin/env python
# Export functions
from reports import *
def exporting_results_to_file(export_file="reports.txt"):
data_file = input("Give name of data file (e.g. game_stat.txt): \n")
title = input("Enter title for question 5 (e.g. Diablo II): \n")
with open(export_file, "w") as file:
file.w... |
6229e051c318e2f0a31404b7447cc5b3f49c40cb | Srinivas-Rao-au27/Accomplish_classes- | /Extra-Things/Extra_Files/27may.py | 583 | 4.0625 | 4 | # data = [
# [1, 2, 3],
# [5, 6, 7],
# [7, 8, 9]
# ]
# # for i in range(0, len(data)):
# # for j in range(0, len(data)):
# # print(data[i][j])
# for i in range(0, len(data)):
# print(data[0][i])
Raw = int(input("Enter the number of rows:"))
Clm = int(input("Enter the number of columns:"))... |
fb8ae919bf14fee6f8058458fa3355d8569e15bc | datAnir/GeekForGeeks-Problems | /Dynamic Programming/equal_sum_partition_subsets.py | 2,098 | 3.828125 | 4 | '''
https://practice.geeksforgeeks.org/problems/subset-sum-problem/0
Given a set of numbers, check whether it can be partitioned into two subsets such that the sum of elements in both subsets is same or not.
Input:
2
4
1 5 11 5
3
1 3 5
Output:
YES
NO
Explanation:
Testcase 1: There exists two subsets such that {1, 5,... |
295e356fb69874b5b84c1199c814e3db25bb4c62 | LucijaJ/Python_projekti | /FizzBuzz/fizzBuzz.py | 344 | 3.734375 | 4 | # -*- coding: utf-8 -*-
print "To je FizzBuzz igrica"
stevilka = raw_input(u"Izberi številko med 1 in 100: ")
stevilka = int(stevilka)
for num in range(1, stevilka+1):
if num % 3 == 0 and num % 5 == 0:
print "fizzbuzz"
elif num % 3 == 0:
print "fizz"
elif num % 5 == 0:
print "bu... |
67f528fb6fe2120269547a66de4a37fe6b6f8d5a | nathanin/histo-seg | /pca/clean_all_folders.py | 698 | 3.5625 | 4 | #!/usr/bin/python
###
# Clean up all folders #
###
import os
import shutil
def lstdirs(lookin='.'):
dlist = os.listdir(lookin)
return [d for d in os.listdir(lookin) if os.path.isdir(d)]
def purge(dlist):
for d in dlist:
print 'Removing {}'.format(d)
shutil.rmtree(d)
if __name__ == '_... |
be7a72158d2e8e879d5262f3dd5f351e49f38d1c | caleb-train/Competetive-programming | /Data Structures/Hashtable/Linear probing.py | 1,708 | 3.671875 | 4 | '''
@Author: rishi
'''
# Implement Hashmap with collision using Linear probing
class Hashmap:
def __init__(self):
self.MAXSIZE = 5
self.arr = [None for i in range(self.MAXSIZE)]
def find_hash(self, key):
if type(key) == int:
return (2*key+1)%self.MAXSIZE
... |
cc80e14b499d6737e02c24533b161b87b87f2a2b | TheAragont97/Python | /Actividades/Relacion 1/Relacion de ejercicios - Tipos de Datos Simples/ejercicio3/ejercicio3.py | 75 | 3.59375 | 4 | nombre=input("Ingresa el nombre del usuario: ")
print("¡Hola",nombre,"!")
|
c73a659321099aa3d0bee06b0f0562211a8f5a67 | kumaranika/MyCaptain | /fibonacci.py | 282 | 4.21875 | 4 | n=int(input("How many terms? "))
a=0
b=1
c=0
if n<=0:
print("Please enter a positive integer")
elif n==1:
print("Fibonacci sequence upto",n,":")
print(a)
else:
print("Fibonacci sequence:")
while c<n:
print(a)
fib=a+b
a=b
b=fib
c+=1
|
82301f6c6b1b14b6be893176944a4ae4ea3199c1 | jbischof/algo_practice | /udacity/sort.py | 1,801 | 4.1875 | 4 | # Sorting algorithms
def bubblesort(array):
l = len(array)
# Number of swaps in last pass
swaps = 1
while swaps > 0:
# Set swap counter back to zero
swaps = 0
for i in range(l - 1):
if array[i + 1] < array[i]:
array[i], array[i + 1] = array[i + 1], array[i]
swaps += 1
def mergearr(arr1, arr2):
""... |
23fd40e9efe313ef4072e7caed9bd2e5276699d1 | alch/python-bitcoin | /bc/field_element.py | 2,591 | 3.5625 | 4 | from __future__ import annotations
class FieldElement:
def __init__(self, num: int, prime: int):
if num >= prime or num < 0:
error = "Num {} not in field range 0 to {}".format(num, prime - 1)
raise ValueError(error)
self.num = num
self.prime = prime
def __repr_... |
d412984c907a53b8ebac38145f85cf9af18a270f | dishantpatel27/CS61A-UoC-berkeley- | /lab3/Q5.py | 1,200 | 4.1875 | 4 | def cycle(f1, f2, f3):
""" Returns a function that is itself a higher order function
>>> add1 = lambda x: x+1
>>> times2 = lambda x: 2*x
>>> add3 = lambda x: x+3
>>> my_cycle = cycle(add1, times2, add3)
>>> identity = my_cycle(0)
>>> identity(5)
5
>>> add_one_then_double = my_cyc... |
bffb90a90232c4bf9af3e48c9e5d556bbb2ec631 | judigunkel/Exercicios-Python | /Mundo 2/ex058.py | 834 | 4.1875 | 4 | """
Melhore o jogo 028 onde o computador vai 'pensar' em um número de 0 a 10. Só
que agora o jogador vai tentar adivinhar até acertar, mostrando no final
quantos palpites foram necessários para vencer.
"""
from random import randint
print('Sou seu computador...\n'
'Acabei de pesar em um número entre 0 e 10.\n'
... |
116d92cce52314e9335d01cc8344daeee2dca681 | Elliotcomputerguy/LearningPython | /LogicalOperators.py | 6,363 | 4 | 4 | #!/usr/bin/env python
# and, or, not are logical operators that are used to combine Boolean expressions.
# When combined with simple conditions such as a Boolean comparators they become compound conditions.
# ===============================================================
# ===
# and
# ===
# =======================... |
8da3f91803bc311f46fbfb0a7734d4dc9e1f6462 | henryxian/leetcode | /remove_element.py | 1,071 | 3.84375 | 4 | # Remove Element
class Solution(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
length = len(nums)
index = 0
index_not_val = 0
count = 0
while(index < length):
if (nums[inde... |
ee3e7faf30d82af54060c755e6fee732d36a786f | avasich/a3200-2015-algs | /lab8/Vasich/queue.py | 2,072 | 3.8125 | 4 | from sys import stdin, stdout
class Queue:
def pop(self):
pass
def push(self, n):
pass
def size(self):
pass
# implement Queue
class StacksQueue(Queue):
def __init__(self):
self._seq = []
def push(self, a):
self._seq.append(a)
def pop(self):
... |
60cc3f1ac13d96d3a3297c0ed687afb4667ff063 | Glimtoko/pyramid | /pyramid.py | 650 | 3.828125 | 4 | class Pyramid():
def __init__(self, initial):
self.data = [[initial]]
def __repr__(self):
result = ""
for entry in reversed(self.data):
result += str(entry) + "\n"
result += "\n"
return result
def add(self, value):
# First, add value to bottom le... |
0cc53c3071eadfe43c602dbd1eac67470f63ea4b | rishabhgupta03/Hacker-Rank-python | /Set .union(), .intersection() Operation.py | 254 | 3.546875 | 4 | n = int(input())
english = set(map(int, input().split()))
b = int(input())
french = set(map(int, input().split()))
set_union = english.union(french)
set_intersection = english.intersection(french)
print(len(set_union))
print(len(set_intersection)) |
ae0df91871f9e5d24ad1effffd3eac0b107929a8 | dhruv3/IntroToPython | /Unit 3/palinTools.py | 140 | 3.625 | 4 | #
#
#
def isPalindrome(a):
if a == a[::-1]:
return True
else:
return False
#a = isPalindrome("rwadar")
#print(a)
|
596f4a08e06c6ec4dcf7afbce01ae81bc60c483b | lingxiaomeng/CS305 | /lab2/prime.py | 383 | 3.9375 | 4 | def find_prime(start: int, end: int):
prime_list = []
for num in range(start, end + 1):
if is_prime(num):
prime_list.append(num)
return prime_list
def is_prime(num: int):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
return False
... |
f600b3f6eebf05c40bd05e6b85c556d3fbd0aa4a | advaittrivedi1122/Contact-Book-in-Python | /Contact_Book.py | 5,092 | 3.921875 | 4 | import sys
import sqlite3
from prettytable import from_db_cursor
# Connecting database
db = sqlite3.connect('contacts.db')
cursor = db.cursor()
# Declaring SQL database statements
def create():
create = '''
CREATE TABLE IF NOT EXISTS
CONTACTS(Name TEXT, Number TEXT);
'''
cursor.execute(create)
... |
ce4daf5269a408f6676b51c506b8f3e1acb75e16 | giladse19-meet/y2s18-python_review | /exercises/superheros.py | 584 | 3.6875 | 4 | # Write your solutions for 1.5 here!
class Superheros:
def __init__(self, name, superpower, strengh):
self.name = name
self.superpower = superpower
self.strengh = strengh
def hero(self):
print(self.name)
print(self.strengh)
def save_civilian(self, work):
if ... |
ea98690ae25b74ebfb2137d1ba4d000965931ea2 | danbev/learning-python | /src/get_item.py | 326 | 3.5625 | 4 | class Results(object):
def __init__(self, contenders):
self._places = [None]*contenders
def __setitem__(self, place, data):
self._places[place] = data
def __getitem__(self, place):
return self._places[place]
r = Results(3)
r[0] = 'Gold'
r[1] = 'Silver'
r[2] = 'Bronce'
print(... |
809d1f255dc8609194442651bf4fcdd14ef78bbb | chxj1992/leetcode-exercise | /152_maximum_product_subarray/_1.py | 687 | 3.84375 | 4 | import unittest
from typing import List
class Solution:
def maxProduct(self, nums: List[int]) -> int:
max_product, max_here, min_here = nums[0], nums[0], nums[0]
for x in nums[1:]:
if x < 0:
max_here, min_here = min_here, max_here
max_here = max(max_here * x... |
626d28f084048953122b1ffe24dc215ab1890288 | sresis/practice-problems | /weighted-path/weighted_path.py | 1,387 | 3.765625 | 4 | def Helper(start, end, connections, routes, curr, weight): """Get possible routes and add to routes dict."""
# if start and end are the same, add to routes
if start == end:
routes[curr+start] = weight
# otherwise, iterate through possible connections
else:
for connection in connections:
if start ... |
2797c075a11ae211a79c6087209a64636ce835d5 | VsPun/learning | /sample/chapt02/chapt02-13.py | 107 | 3.875 | 4 | a = 10
while a < 10:
a = a + 1
print( a )
else:
print( 'no loop' ) # 「no loop」と表示される
|
35379aea4ec7a62f63a1cbb743803e4ea8fdf374 | Clay190/Unit-2 | /adventure.py | 386 | 3.6875 | 4 | #Clay Kynor
#9/18/17
#adventure.py - Create an adventure
answer = input("You are strolling along a field and see a wild Claire sitting on her most prized possesion, her bench. Do you approach her, yes or no?")
if "yes" in answer:
answer2 = input("You approach her and she leaps from the bench, eyes bulging, trying ... |
3343294eb8fa8377e5c40f0b6b2f86d09854f8db | eric-olson/AutoGrader | /flowers_old/problems/carrotboxes/convert.py | 273 | 3.71875 | 4 | #!/usr/bin/python3
import re
expr = r"\[(.*)\],\s+([0-9]+)\s+([0-9]+)"
input = open("input")
for line in input:
result = re.search(expr, line)
if result:
print("\t{{{" + result.group(1) + "},", result.group(2)+"},", result.group(3)+"},")
input.close()
|
b1f400e0dcf56e30d0c93f3483505907dd4941b9 | mxh970120/leetcode_python | /medium/49. group-anagrams.py | 699 | 3.78125 | 4 | '''
Author: mxh970120
Date: 2020.12.14
'''
class Solution:
def groupAnagrams(self, strs):
res = {}
for item in strs:
k = ''.join(sorted(item)) # 字符串排序,Python join() 方法用于将序列中的元素以指定的字符连接生成一个新的字符串。
print(k)
if k not in res: # 判断是否存在
res[k] = []
... |
7a9dd98eea7432cf54e7afed56be6feae54a94f6 | ver007/pythonjumpstart | /.history/day3/oops/employee.py | 666 | 3.71875 | 4 | #!/usr/bin/env python
from person import Person
class Employee(Person):
def __init__(self, eid, firstName, lastName, age, gender,\
designation, department):
self.eid = eid
super(Employee, self).__init__(firstName, lastName, \
age, gender) #calling the base class constructor
self.designation = design... |
c60d6f43a03f1604de7be6d7d9ad57c97c723559 | Smithry9/InClassActivity4 | /test_wordCount.py | 707 | 3.84375 | 4 | #test_palindrome
import unittest
import wordCount
class testCaseAdd(unittest.TestCase):
#1 word
def test_wordCount1(self):
self.assertEqual(wordCount.numWords("Hi"), 1)
#2 words
def test_wordCount2(self):
self.assertEqual(wordCount.numWords("Hello World!"), 2)
#empty string
def ... |
50b1be7a68dcce6b3c193a3390df2ff5931608c2 | MahoHarasawa/Maho | /uranai02.py | 5,773 | 4 | 4 | '''ソウルナンバー占い
合計が1桁になるまで足し、最終的に出た数がソウルナンバー
ぞろ目はそのまま'''
#8桁の生年月日を入力 1998/04/11生まれ⇒1,9,9,8,0,4,1,1
num1=int(input("1桁目⇒"))
while num1>=10 or num1<0:
print("0または1桁の正の数で入力してください")
print()
num1=int(input("1桁目⇒"))
num2=int(input("2桁目⇒"))
while num2>=10 or num2<0:
print("0または1桁の正の数で入力してください")
... |
b9dd5b022c76da7295c1eaa48e64ff7344f802d6 | deepakpesumalnai/Project | /Sample Programs/Function/Function_withLopp.py | 264 | 3.953125 | 4 | def Check_even(number_list):
for num in number_list:
if num % 2 == 0:
print(f'number {num} is even')
else:
print(f'number {num} is odd')
if __name__ == '__main__':
numberlist = [2,3,4,5,6]
Checkeven(numberlist) |
0c6b61f149e86237efc55ece80ad9350fdfb7fd5 | Manoj-t/PythonExamples | /String/findOperator.py | 420 | 4.21875 | 4 | #There are total 4 functions in Python String to find substrings
#1. find() method - which returns the index of first occurence of the given substring. If substring not present, it returns -1
s = input("Enter a string: ")
substr = input("Enter substring: ")
print(s.find(substr))
#we can specify our own boundaries fo... |
bdb55e038623ae35fdadaf0a02fcd8de58b3abb4 | AustinTSchaffer/DailyProgrammer | /Cracking the Coding Interview/Python/ctci/chapter01/_q08.py | 652 | 4.0625 | 4 | from typing import List
def zero_matrix(matrix: List[List[int]]) -> List[List[int]]:
"""
Sets entire rows and columns of the input matrix to 0 if any
of the values in the row or column are 0.
Modifies and returns the input matrix.
"""
cols_to_0 = set()
rows_to_0 = set()
for i, row in... |
c4e72ffc3199c03902b759c77bc0fdc035b25d35 | ikenticus/blogcode | /python/tasks/10-days-stats/00-weighted-mean.py | 395 | 3.71875 | 4 | # Easy
# https://www.hackerrank.com/challenges/s10-weighted-mean/problem
# Enter your code here. Read input from STDIN. Print output to STDOUT
N = int(raw_input())
X = [ float(i) for i in raw_input().rstrip().split(' ') ]
W = [ int(i) for i in raw_input().rstrip().split(' ') ]
num = []
for i in range(len(X)):
num... |
95936a709fe9f146cfd8af938268071f000ca0ea | shsh9888/leet | /min_chairs_required/sol.py | 1,500 | 3.875 | 4 |
def min_chairs(S, E):
if len(S) is 0 or len(E) is 0:
return 0
##the maximum timestamp where a person leaves
max_time = max(E)
arrives = {}
##stores how many chairs neeeded at each timestamp. index is the timestamp here
time_array = [0]*(max_time+1)
##Filling the leave time stamp... |
9bc4980ea0fbceaf90b33ace879138ec71a37099 | Danilo-Araujo-Silva/A-Python-Neural-Network | /neuralNetwork.py | 10,224 | 3.671875 | 4 | #!/usr/bin/env python
"""Erik Hope --- CSC 578 --- Neural Network Midterm Project"""
from optparse import OptionParser
import random
import math
import sys
THRESHOLD_VALUE = -1.0
def set_threshold_value(value):
"""A function which sets the value
of the threshold nodes in the neural network"""
global THRESH... |
c3fb59e7baa777d61e0f3f4153da529bb570ff8f | jaliagag/21_python | /UCEMA/06.py | 793 | 4.25 | 4 | """print("Multiplicación")
print(5 * 4)
print("División")
print(5 / 4)
print("Potencia")
print(5 ** 4)
print("Módulo")
print(5 % 4)
print("Parte entera")
print(5 // 4)
1. Declarar las variables "numero1" y "numero2" y pedirle al usuario que ingrese estas con la linea "Ingrese un número entero: "
2. Imprimir solam... |
9902e7c9640fa47c8290756ba7117d9f40a2310f | jngirakwizera/python-class | /JeanNgirakwizeraLab7 2/Hangman_delete.py | 1,076 | 4.125 | 4 | import sqlite3
import Hangman_readone
#The delete functino deletes an item
def delete():
hiddenword = ""
level = ""
hint = ""
hiddenword, level, hint = Hangman_readone.getWord()
if hiddenword == "-1":
print("Word not found")
else:
sure = input('Are you sure you want to delete th... |
0c090d3272d3874d7577eccfd1686d2934ac8015 | parkus/ffd | /utils.py | 2,166 | 3.5625 | 4 | from __future__ import division, print_function, absolute_import
import numpy as _np
class OutOfRange(Exception):
pass
def error_bars(x, x_best=None, interval=0.683):
"""
Get the error bars from an MCMC chain of values, x.
Parameters
----------
x : array-like
The randomly sampled da... |
912f4dbafbc27bd55cd3bd76058eadf3741afc95 | LangchunSi/0-1-Knapsack-problem | /dKnapsack.py | 3,375 | 3.796875 | 4 | # Dynamic programming method
'''
# mainRun(weight,value,capacity,type)
n: number of items
value: value of each item
weight: weight of each item
capacity: capacity of bag
m: memery matrix
type: 'right2left' or 'left2right'
'''
# right to left
def Knapsack(value,w... |
83bbc292acc57c352d83d1e19c5cc9ca1a2e68bb | pinal-012/MY-PROJECTS | /Pizza_store_management.py | 6,311 | 3.96875 | 4 | #write a python program that handles pizzeria customers and at the end of day show the
# full day report(like total earning of day,pizza earning, pasta earning etc..)
import os
os.system('cls')
from decimal import Decimal
from datetime import datetime
class Pizzeria:
shift=0
def __init__(self):
print... |
a93ca3594739e64904970c9ff2cc18ff33bb360c | Dhrumilcse/Project-Euler | /Problem2.py | 460 | 3.703125 | 4 | #Sum of Even Fibonacci Numbers (Unitil the number Exceeds 4 million)
#Recursive function to find Fibonacci of the number
def fib(n):
if (n == 0 or n == 1):
return(1)
else:
return(fib(n-1) + fib(n-2))
#Printing out Sum of even Fibonacci numbers
def testFib(n):
sum = 0
for i in range(1,n... |
c6aba5e8d7822343ca2a22dd3fd4ea6cfd22cb8c | LewisT543/Notes | /Learning_Tkinter/23Labs-tic-tak-toe.py | 4,104 | 3.75 | 4 | #### TRAFFIC LIGHTS MODEL ####
# Tik tak toe... again. This time with more gui.
# use grid() geometry manager
# define and use callbacks
# identifying and servicing GUI events
# pc plays x's, who are always red
# player plays O's, who are always green
# 9 tiles (buttons)
# firs... |
1b32e1fec25f16ee7e7a73b1a3ff0330677c6117 | mdfarazzakir/Pes_Python_Assignment-3 | /Program60/stringPackage/string6.py | 2,089 | 4.40625 | 4 | """
Strings:
Write a program to check how many ovals present in the given string. That is, count the number of " a e i o u" in the given string and
print the numbers against each oval. Example:- "This is Python" Number of total ovals = 3, i = 2, o =1
"""
"""Function to calculate vowels in a string"""
def vowels(strg):... |
9c3497b7b440a40556e690e70c771e221f119a3e | SpencerBeloin/Python-files | /maxnumber.py | 310 | 4.09375 | 4 | #maxnumber.py
x1,x2,x3= eval(input("Please eneter three values : "))
if x1 >= x2 and x1 >= x3:
max = x1
print( x1, " x1 is the biggest" )
elif x2 >=x1 and x2 >= x3:
max = x2
print( x2, " x2 is the biggest" )
else:
max = x3
print( x3, " x3 is the biggest" )
|
64b36f1560095ef719a0ee3c1bc85ab516addcf6 | Nehanavgurukul/function_ques | /harshad_number.py | 212 | 3.859375 | 4 | num=int(input("enter the number"))
c=num
sum=0
modulus=0
while(c!=0):
modulus=c%10
sum=sum+modulus
c=c//10
if(num%sum==0):
print("it is harshad number")
else:
print("it is not harshad number") |
84bcd25ce6ff77615db54a08f7b15ace7578cebb | simgek/simge3-2 | /3.2for4.py | 276 | 3.640625 | 4 | # 10 ile 20 arasındaki asal sayıları gösterin
for num in range(10,21):
for i in range(2,num):
if num % i == 0:
j = num/i
print("{} eşittir{}*{}".format(num,i,int(j)))
break
else:
print(num, "asal sayıdır")
|
bfa5b5035647d16639732d4af0a045994813738e | Jamesburgess44/Marketing-Sweepstakes | /contestant.py | 1,059 | 3.875 | 4 | from userinterface import UserInterface
class Contestant:
""", I want to create a Contestant class that has a first name, last name, email address, and registration number."""
def __init__(self):
self.first_name = UserInterface.get_user_input_string("Enter first name")
self.last_name = UserInt... |
3d49c005dca3f40a21e6464783b7f70dc95cce31 | PropeReferio/practice-exercises | /random_exercises/factorial.py | 204 | 4.15625 | 4 | def factorial(number):
x = 1
while number > 0:
x *= number
number = number - 1
return x
n = int(input("Give me a number, and I'll compute the factorial!"))
print(factorial(n))
|
2a5cb04a9194f75ae0cbd9872d750476db81ccb7 | Sunilbhat717/python_programs | /Input_output.py | 352 | 3.9375 | 4 | #!/usr/bin/env python
print("Please enter the following details")
name = input("Enter your name\n")
age = int(input("Enter your age\n"))
while age > 100 or age < 0:
print("Invalid input..please re-enter the age")
age = int(input("Enter your age\n"))
ans = 100 - age
print("Hey %s, Good day. You will turn 100 ... |
eff583ca91cc155142b566064789cbc3b951a5fa | Mehvix/competitive-programming | /Codeforces/Individual Problems/P_4A.py | 166 | 3.78125 | 4 | user_input = int(input().strip())
if (user_input % 2 == 0) and (user_input > 0) and (user_input != 2) and (user_input <= 100):
print("YES")
else:
print("NO") |
8f85abd2fc2dd8cbd26c41d5dc5fc49d11d237b3 | aliakseik1993/skillbox_python_basic | /module1_13/module7_hw/task_7.py | 943 | 4.125 | 4 | print('Задача 7. Отрезок')
# Напишите программу,
# которая считывает с клавиатуры два числа a и b,
# считает и выводит на консоль
#среднее арифметическое всех чисел из отрезка [a; b], которые кратны числу 3.
number_begin = int(input("Введите начальное число: "))
number_end = int(input("Введите конечное число: "))
div... |
60c2fe22aff00c820f40a0d65e65d689e70fd620 | rafa3lmonteiro/python | /python3-course/aula17/aula17-parte2-b.py | 1,420 | 4.25 | 4 | #Curso Python #17 - Listas (Parte 2)
#continuacão
teste = list()
teste.append('Gustavo')
teste.append('40')
galera = list()
galera.append(teste) #Nesta forma de append eu faco uma ligacão, e tudo que acontecer nesta lista flete nos futuros appends
teste[0] = 'Maria'
teste[1] = 22
galera.append(teste)
print(galera)
#-... |
eaac1f951ce6638228a58b4f5b9ee9dca7f6a3fe | arjunsawhney1/graph-algorithms | /number_of_shortest_paths.py | 1,252 | 3.8125 | 4 | import graph
from collections import deque
def number_of_shortest_paths(graph, source):
status = {node: 'undiscovered' for node in graph.nodes}
distance = {node: float('inf') for node in graph.nodes}
paths = {node: 0 for node in graph.nodes}
status[source] = 'pending'
pending = deque([... |
2274acc0bd401e910a669a259fd72a9ca075ac80 | vvspearlvvs/CodingTest | /1.알고리즘정리/DFS와BFS/bfs.py | 676 | 3.703125 | 4 | #BFS -큐(deque)이용
import collections import deque
#각 노드가 연결된 정보 표현
graph=[
[],
[2,3,8],
[1,7],
[1,4,5],
[3,5],
[3,4],
[7],
[2,6,8],
[1,7]
]
visited=[False]*9
def bfs(graph,start,visited):
#현재노드 방문처리
queue=deque([start])
visited[start]=True
while queue:
#큐에서 하... |
af642079a5ec8dfa332a5e37ce9433587857321e | daniel-reich/ubiquitous-fiesta | /gnaxzuGNPnxKkJo39_0.py | 363 | 3.75 | 4 |
def easter_date(y):
# I have no idea what I'm doing
g = y%19 +1
s = (y -1600)//100 -(y -1600)//400
l = (((y -1400)//100)*8)//25
p = (3 +s -l -11*g)%30
p -= 1 if p == 29 or (p == 28 and g > 11) else 0
d = (y +(y//4) -(y//100) +(y//400))%7
e = p +1 +(4 -d -p)%7
return 'March ' + str(e... |
953d8f795de9c6693bd04aa68d5fd402c65cfd24 | Fahad-Hassan/itp-test | /test.py | 2,716 | 3.6875 | 4 |
class Contact(object):
def __init__(self, name, email,phone):
self.name = name
self.email = email
self.phone = phone
def __str__(self):
return f"{self.name} <{self.email}> {self.phone}"
class Leads(object):
def __init__(self, name, email,phone):
self.name = nam... |
e7fef429f1fb85396de9763916b65ff409aa6efa | YoonhoRayLee/BOJ_Solution | /Math/1475.py | 453 | 3.546875 | 4 | #Dongguk University Computer Science Engineering
#Yoonho Ray Lee
#BOJ Solution for Problem.1475
import math
N = list(input())
list1 = []
list2 = []
count = 0
for i in N:
if i == '6':
count += 1
continue
if i == '9':
count += 1
continue
if N.count(i) != 1:
list1.app... |
cea60137e987a2a6b008dd75acdb17fcea23a36f | Charlymaitre/30exo_python | /25.py | 534 | 4.03125 | 4 | # Faire un programme python qui demande à un utilisateur d’entrer un entier positif. Le programme indique ensuite si l’entier positif est pair ou impair ? Le programme vérifie et redemande l’entier si ce n’est pas un entier positif.
valeurInitiale = int(input("Choississez un nombre "))
while valeurInitiale < 0:
... |
33cbc7d3d2cefac3b4a3f6afde5509621d9f3512 | algo2020-lesnaya-skazka/python1_tasks | /python_book_page_128_ex_1.py | 86 | 3.875 | 4 | names = ['Simon' , 'Kate' , 'Vanya']
for item in names :
print('Hello' , item)
|
ef18474fe312b0d17f3342b7417b740f2a1390dd | daniel-reich/ubiquitous-fiesta | /gdzS7pXsPexY8j4A3_9.py | 378 | 3.90625 | 4 |
def count_digits(lst, t):
result = []
total = 0
digits = [list(str(n)) for n in lst]
for number in digits:
for digit in number:
if t == "even" and int(digit) % 2 == 0:
total += 1
elif t == "odd" and int(digit) % 2 != 0:
total += 1
... |
838bcc64ee4c849ab9139dbd4ac51e6b9a1d0e10 | james-cape/exercisms | /python/twelve-days/twelve_days.py | 1,260 | 3.65625 | 4 | def recite(start_verse, end_verse):
last_line = "a Partridge in a Pear Tree."
if end_verse > 1:
last_line = "and " + last_line
numbers = {
1: "first",
2: "second",
3: "third",
4: "fourth",
5: "fifth",
6: "sixth",
7: "seventh",
8: "eigh... |
505109e91722fa1f0cc3c22a61ca1a6e0e64d909 | hanameee/Algorithm | /Leetcode/파이썬 알고리즘 인터뷰/12_그래프/src/dfs_bfs.py | 1,048 | 3.765625 | 4 | from collections import deque
graph = {
1: [2, 3, 4],
2: [5],
3: [5],
4: [],
5: [6, 7],
6: [],
7: [3]
}
def recursive_dfs(v, visited=[]):
visited.append(v)
for w in graph[v]:
if not w in visited:
visited = recursive_dfs(w, visited)
return visited
def iter... |
e2f4b1ce77039cf4c73b04062c690f6160ecc8e8 | veenakruthi-1694/TestGithub | /stopwords .py | 484 | 3.875 | 4 | def remove_stopwords(text, is_lower_case=False):
tokens = tokenizer.tokenize(text)
tokens = [token.strip() for token in tokens]
if is_lower_case:
filtered_tokens = [token for token in tokens if token not in stopword_list]
else:
filtered_tokens = [token for token in tokens if token.lower(... |
def8754f3b81042ce38bcba35a2df0a6201b3f7b | AricA05/Python_OOP | /init_method.py | 965 | 4.5625 | 5 | #object orientated programming in Python
#objects will have attributes and behaviours
#class = the design/blueprint to create the object
#object = what the class produces
#define class:
class Computer:
#initialize objects (constructor), in this case we are passing three arguments/paramters
def __init__(self,cpu,r... |
3094c30520205c981881338ce5baf31b72977d7f | felixvor/flipfacts | /flask-backend/flipfacts/api/validate.py | 824 | 3.609375 | 4 | import string
def username(username):
if not (len(username) >= 3 and len(username) < 35):
return False
whitelist_chars = [".","-","_"]
blacklist_chars = string.punctuation+" " #whitespace not included
for c in blacklist_chars:
if c in whitelist_chars:
continue
if c ... |
a5a75ed14c1ffebaa43a707f5c059e1df960f208 | ZakawarMaw/python-learning | /input.py | 176 | 4.09375 | 4 | # print("Hello World");
# name=input(' Name :');
# print('Hello ' +name);
# Calculate Area ( Formula Pi r**2)
PI=3.142;
r=int(input('radius : '));
area=PI*r**2;
print(area); |
ff5d1907589f5647fcdea36cfd59acbb1e408952 | gschen/where2go-python-test | /1906101009肖文星/ago/练习4.py | 292 | 3.78125 | 4 | '''斐波那契数列。(斐波那契数列(Fibonacci sequence),又称黄金分割数列,指的是这样一个数列:0、1、1、2、3、5、8、13、21、34、……。前两项相加等于第三项)求前101项'''
a=0
b=1
for i in range(99):
c=a+b
a,b=b,c
print(c) |
a0caa3a78c80c98b101056b02df97dc525df9eb5 | shivamar/geeks | /src/mthSequence.py | 808 | 3.703125 | 4 | ## Generate mth permutation sequence lexicographically
## 0,1,2 : 5th sequence is 201
def fact(n):
if(n==1): return 1
if(n < 1): return 0
return n * fact(n-1)
def combination(N, M):
num_list = [0,1,2,3,4,5,6,7,8,9]
num_list = num_list[0:N]
ans=''
i=1
fac = fact(N-i)
rem = M
... |
b2037c4bf2463315f7868277a4f1e4edf3451800 | Ilya225/codingChallenges | /python/leet_code/jump_game_II.py | 668 | 3.5625 | 4 | from typing import List
class Solution:
def jump(self, nums: List[int]) -> int:
i = 0
jumps = 0
while i < len(nums)-1:
max_index = 0
for j in range(1, nums[i]+1):
if i + j < len(nums):
if max_index == 0:
m... |
6112c410016c172d5338bb78508e49dbf91f7e01 | 14021612946/python_all-hedengyong | /pythonProject2day11.0/day11.3.py | 1,688 | 3.640625 | 4 | class student:
__username=None
__age=None
__deskmatename=None
__daskmateage=None
def setUsername(self,username):
self.__username=username
def getUsername(self):
return self.__username
def setAge(self,age):
self.__age=age
def getAge(self):
retur... |
f81676fdd4ce88191ad55d9fa83ca4954d77b66c | nookalaramu/python | /list.py | 750 | 4.25 | 4 | # Take 5 different names from user which should have first name middle name and last name ,
# and should be stored in List called as "nameList" Example:
# 1) suresh kumar angadi
# 2) basappa chennappa gadad
# 3) rakesh kumar miskin
# 4) rithwik ullagaddi mathad
# 5) shankar gowda kumar
# 1)Suresh K.A
# 2)Basa... |
e223d8261e5b5253f6cd5d4b3a0ded2c78a39d7c | matt-a-a-achooo/DukeTip | /rocket.py | 697 | 3.875 | 4 | import array as np
import matplotlib.pyplot as plt
x = [-40, -20, 0, 20, 40, 60, 80] # angle measurements
y = [61, 177.33, 296.33, 680.33, 651, 534.67, 24.67] # average
result = np.polyfit(x, y, 2)
print(result)
eq = np.poly1d(result)
print(eq)
print(eq(2))
x2 = np.arange(-40, 90) # gives a range for the angles
... |
694ccf14ab1fd174eafdfbc3d5c25ff5b5461644 | veratsurkis/enjoy_sleeping | /ex10_1.py | 201 | 3.765625 | 4 | import turtle as tr
tr.shape('turtle')
tr.speed(0)
def circle(n):
turn = 360/n
for i in range(n):
tr.forward(1)
tr.right(turn)
p=400
for i in range(6):
circle(p)
tr.right(60)
|
4d3ce1f21ea9ad03a801886e9cd673a67aa393de | jhsmaciel/PythonZombie | /Python/List 3/Exer2.py | 351 | 4.1875 | 4 | nome = input("Digite o nome de usuário: ")
senha = input("Digite a sua senha: ")
x = -1
while x != 0:
if nome == senha:
print("Usuário e senha não podem ser iguais!")
nome = input("Digite o nome de usuário: ")
senha = input("Digite a sua senha: ")
else:
x = 0
print("Usuário e sen... |
23d8c168396cf84a41ff5ec802f9a6e47ad04427 | spike688023/Python-for-Algorithms--Data-Structures | /Graphs/Graph Interview Questions/BFS.py | 1,881 | 4.09375 | 4 | # -*- coding: utf-8 -*-
graph = {'A': set(['B', 'C']),
'B': set(['A', 'D', 'E']),
'C': set(['A', 'F']),
'D': set(['B']),
'E': set(['B', 'F']),
'F': set(['C', 'E'])}
print graph
"""
實作DFS, BFS:
最大的差別在, 使用的儲存結構,
BFS因為要從相鄰的往外延申, 所以要用queue,
DFS則是用stack,
喔, 它媽的想到了,
DFS,... |
9de37e1a00bdb0c05f1d5ded8a72145b0ba3c333 | Dawsen64/hello-world | /LeetCode-python/T844.py | 796 | 3.609375 | 4 | class Solution:
def backspaceCompare(self, s: str, t: str) -> bool:
left, right = 0, 0
S = list(s)
while right < len(S):
if S[right] != "#":
S[left] = S[right]
left += 1
else:
left -= 1
if left < 0:
... |
e55fb660b2899364e553868ac8be14f6c8d0dfee | vmathurdev/Customer-Analytics-for-banking-services | /NN_Keras.py | 5,781 | 4.5625 | 5 | #Presenting an Artificial Neural Network implementation to find out reasons as to why and which customers are leaving the bank and their dependencies on one another.
#This is a classification problem 0-1 classification(1 if Leaves 0 if customer stays)
#We make use of Keras which enables us writing powerful Neural Netw... |
c5a67c631481ff858ec374c26c10b4446bab7bdc | MihaiCatescu/python_exercises | /exercise10.py | 1,016 | 4.25 | 4 | # This exercise is for checking whether a number given by the user is prime or not.
# Solution 1 - Using functions
number = int(input("Give me a number: "))
numbers = list(range(1, number + 1))
divisors = []
def get_divisors(number):
for i in numbers:
if number % i == 0:
divisors.a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.