blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
d4d04bbe83d6a734e086c30ec3f713ec934b1170 | ParvathyGS/My-learnings | /Python/find-sum.py | 962 | 4.09375 | 4 | # list1 = int(input("Enter the numbers seperated by space \n"))
# # creating sum_list function
# def sumOfList(list, size):
# if (size == 0):
# return 0
# else:
# return list[size - 1] + sumOfList(list, size - 1)
# # Driver code
# total = sumOfList(list1,len(list1))
# print("Sum of all elem... |
de3a0d193c07f77fcaf263d21a596e617b922cfc | alexryan/projectEuler | /multiplesOf3and5.py | 323 | 3.703125 | 4 |
multiplesOf3 = set();
multiplesOf5 = set();
#multiplesOf3 = {3,6};
#multiplesOf5 = {5,10};
all = {};
sum = 0;
for i in range(1000):
if (i % 3 == 0):
multiplesOf3.add(i)
if (i % 5 == 0):
multiplesOf5.add(i)
all = multiplesOf3.union(multiplesOf5);
for i in all:
sum = sum + i;
#print(i);
print(sum... |
1d90e0015ac878e62cfcf8541c474be04e73209e | totland/Python-Public | /Getting-Started-Class/Getting-Started-Mod2 - 2022-12-29T154730.679324Z.py | 4,568 | 3.875 | 4 | # Module 2: Types, Statements, and other goodies
# *********************************************************
# *********************************************************
# Integers and Floats
# *****************************************************
"""
Multi Line Comment
"""
answer = 42 # Int
pi = 3.141592653589793 ... |
0989afd781a62d3d11e4bada355b457c76caf9a9 | tbedford/MCDS | /webapp/test/test_bcrypt.py | 651 | 3.84375 | 4 | import bcrypt
# hashes a plaintext password using bcrypt with bcrypt the hash
# contains the salt, so no need to store separately.
def hash_password (password):
salt = bcrypt.gensalt()
hash = bcrypt.hashpw(password, salt)
return hash
def check_password (password, hash):
hashpw = bcrypt.hashpw(pass... |
b4c5dcb7316977abd57499a32c101af6614e66cb | lasernite/mitpythoniap | /nims.py | 1,063 | 3.828125 | 4 | # Name: Laser Nite
# Kerberos: nite
# nims.py
def play_nims(pile, max_stones):
'''
An interactive two-person game; also known as Stones.
@param pile: the number of stones in the pile to start
@param max_stones: the maximum number of stones you can take on one turn
'''
## Basic structure of pro... |
ce5d6f2bed63c001e651a3b43fc1e300a10db109 | azizzouaghi/holbertonschool-higher_level_programming | /0x02-python-import_modules/2-args.py | 465 | 3.6875 | 4 | #!/usr/bin/python3
import sys
if __name__ == "__main__":
argv_len = len(sys.argv)
if argv_len - 1 == 0:
print("{:d} arguments.".format(argv_len - 1))
if argv_len - 1 == 1:
print("{:d} argument:".format(argv_len - 1))
print("{:d}: {:s}".format(1, sys.argv[1]))
elif argv_len > 1:
... |
438adb533e5192dcce6070b12902f96676e852a4 | nopomi/hy-data-analysis-python-2019 | /hy-data-analysis-with-python-2020/part04-e09_snow_depth/src/snow_depth.py | 271 | 3.578125 | 4 | #!/usr/bin/env python3
import pandas as pd
def snow_depth():
wh = pd.read_csv("src/kumpula-weather-2017.csv")
max = wh["Snow depth (cm)"].max()
return max
def main():
print("Max snow depth: " + str(snow_depth()))
if __name__ == "__main__":
main()
|
cfd2fea6d22aab97ac0b9049a71b0820d73b5105 | shlomikaduri/ProjectGames | /GuessGame.py | 1,423 | 4.15625 | 4 | import random,Score
'''
The purpose of guess game is to start a new game, cast a random number between 1 to a
variable called difficulty.
'''
'''
get a number variable named difficulty
return a random number between 1 to difficulty.
'''
def generate_number(difficulty):
return(random.randint(1, int(difficulty)))
... |
b15ab26b135bc494b8b32e01ca7ba1b98f7edee9 | sidv/Assignments | /Thanushree/Assignment/Aug_17/calc_module/quiz.py | 69 | 3.8125 | 4 | i=0
while i<5:
print(i)
i+=1
if i == 3:
break
else:
print(0)
|
f06e67cc9853b5aa80d8039fd5c6437f72824f0b | githubjyotiranjan/pytraining | /data/all-pratic/VivekKumar_DCC/python_2/project1.py | 1,074 | 3.734375 | 4 | file = open("project.txt", "w")
file.write("India, also called the Republic of India, is a country in South Asia.\n It is the seventh-largest country by area, the second-most populous country, and the most populous democracy in the world.\n It is bounded by the Indian Ocean on the south, the Arabian Sea on the southwes... |
05895db4c92a5ec055d369f070ba500aa62b06b1 | saralkbhagat/leet | /Linkedlist/Reverse LL/206.reverse-linked-list.py | 1,248 | 4.0625 | 4 | #
# @lc app=leetcode id=206 lang=python3
#
# [206] Reverse Linked List
#
# https://leetcode.com/problems/reverse-linked-list/description/
#
# algorithms
# Easy (57.16%)
# Total Accepted: 699.7K
# Total Submissions: 1.2M
# Testcase Example: '[1,2,3,4,5]'
#
# Reverse a singly linked list.
#
# Example:
#
#
# Input:... |
ae47d12c13e3564dd16cd8f7021bb672fa32bde1 | ioanajoj/Artificial-Intelligence | /Subgraphs (EA)/Algorithm.py | 4,359 | 3.625 | 4 | import math
import matplotlib.pyplot as plt
from GraphProblem import GraphProblem
from Population import Population
class Algorithm:
def __init__(self, file_name, parameters_file_name):
"""
self.__problem: Problem
self.__population: Population
"""
self.__data_file_name = f... |
8ce879453683219ef3da099c62a2481f1ed0bc48 | linloone/code_examples | /padding-oracle/padding_oracle_server.py | 4,559 | 3.75 | 4 | # we'll be using the lovely pycryptodome library for our crypto functions
from Crypto.Cipher import AES
# for key/iv generation
import random
# since we're using AES for our example, this is 16 bytes
BLOCK_SIZE = 16
# let's set up the 'server-side' functions. our server is going to do the following:
# - generate a... |
85a7144ce8cf1eb1cbc05993489a872ef87f28bb | raririn/LeetCodePractice | /Solution/1071_Greatest_Common_Divisor_of_Strings.py | 652 | 3.546875 | 4 | class Solution:
def gcdOfStrings(self, str1: str, str2: str) -> str:
# The same as gcd algorithm for integers.
l1 = len(str1)
l2 = len(str2)
if l1 < l2:
str1, str2 = str2, str1
if str1[:l2] != str2:
return False
str1 = str1[l... |
0d61608c97e32364acf93be5ac28404649746a34 | psavery/POSCARModules | /readPOSCAR.py | 1,938 | 3.578125 | 4 | # Author -- Patrick S. Avery -- 2016
# This is so we can loop through the lower case alphabet...
from string import ascii_lowercase
import crystal
"""
Reads a POSCAR and returns a Crystal object
"""
def readPOSCAR(fileName = str):
with open(fileName, "r") as f:
lines = f.readlines()
title = lines[0]
sc... |
2e4b6204741846f2eff45d08bd7e526f5895ad17 | zackdallen/Learning | /classes.py | 1,366 | 4.21875 | 4 | # Classes and objects
class Person:
__name = ''
__email = ''
def __init__(self, name, email):
self.__name = name
self.__email = email
# 'self' in Python is the same as 'this' in ruby
def set_name(self, name):
self.__name = name
def get_name(self):
return self._... |
6e6b6c4c7fe01877bba06adc39d8619aa3e397fe | Miroscyer/PythonStudy | /python_work/Chart6_Dictionary/Test6.4_Dics2.py | 356 | 3.75 | 4 | words = {
'if': 'perhaps',
'or': 'other',
'print': '打印',
'str': 'string',
'len': 'length',
}
for key, val in words.items():
print(key + " = " + val)
words['&&']='and'
words['+']='plus'
words['-']='decrease'
words['*']='multiply'
words['/']='divide'
print('\n')
for key, val in words.items(... |
ba14f4076e2889860b68f9423424b9a988ba4426 | saadkang/PyCharmLearning | /basicsyntax/dictmethods.py | 1,764 | 4.59375 | 5 | """
Dictionary Methods
"""
car = {'Make' : 'Toyota', 'Model' : 'Camry', 'Year' : 2015}
cars = {'BMW': {'Model': '550i', 'Year': 2016}, 'Toyota': {'Model': 'Camry', 'Year': 2015}}
# key() is a built-in method that can help you get the key inside a dictionary
# values() is also a built-in method that can help you get th... |
af511f49144ffe066f001cdccfda98783419ee3c | yachialice/Leetcode | /15-3Sum.py | 1,212 | 3.625 | 4 | """
15. 3Sum
Sort the input array and use two pointers l and r to make the sum of three integers approximate 0.
Pay attention to avoid putting the same triplets in the output by skipping the same nums in iteration.
"""
class Solution(object):
def threeSum(self, nums):
"""
:type nums: List[int]
... |
ea65d6aaa9b85bfb1815bc590ee2a4d9b7243b64 | qizongjun/Algorithms-1 | /Leetcode/Divide and Conquer/#106-Construct Binary Tree from Inorder and Postorder Traversal/main.py | 2,124 | 3.953125 | 4 | # coding=utf-8
'''
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
'''
'''
标准的分治算法思维,可能有其他的方式解决,不过这里参照的是清华数据结构课介绍的思路
第一种思路,最为清晰易理解,但是因为递归调用过多额外内存导致内存超限
'''
# Definition for a binary tree node.
# class TreeNode(object):
# d... |
eb7076d9c7d75d4b0ce59b5a1f74c6cdfe311b7e | jessiecantdoanything/Week10-24 | /CodesAndStrings.py | 1,531 | 4.125 | 4 | # strings
# concatenation
firstName = "Jesus"
lastName = "Monte"
print(firstName + " " + lastName)
name = firstName + " " + lastName
lastFirst = lastName + ", " + firstName
print(lastFirst)
# repition
print("uh "*2 + "AAAAAAAAA")
def imTiredofSchool():
print("me, "*3 + "young Jessie,")
print("is extreme... |
9b2726378853130eb5f92064efe235f7c4f3e572 | Coder2Programmer/Leetcode-Solution | /twentySixthWeek/remove_sub_folders_from_the_filesystem.py | 984 | 3.734375 | 4 | class TrieNode:
def __init__(self):
self.children = dict()
self.value = False
class Trie:
def __init__(self):
self.root = TrieNode()
def insert(self, word):
node = self.root
for char in word:
if char not in node.chil... |
5135e847fe397123f43ed49445d619609f2b73b3 | amardipkumar91/PracticePython | /function_oriented_strategy.py | 2,698 | 3.9375 | 4 | from abc import ABC, abstractmethod
from collections import namedtuple
Customer = namedtuple('Customer', 'name fidelity')
class ListItem(object):
def __init__(self, product, quantity, price):
self.product = product
self.quantity = quantity
self.price = price
def total(self):
ret... |
df5fe54777a01e15ab699e6b1984d3a83679867f | userr2232/PC | /Codeforces/A/667.py | 258 | 3.515625 | 4 | import sys
import math
d, h, v, e = (map(float, input().strip().split()))
if not h:
print("YES\n0")
else:
drink_speed = v / (math.pi * d ** 2 / 4)
if drink_speed < e:
print("NO")
else:
print(f"YES\n{h / -(e - drink_speed)}") |
f77a9da0834313b21af2a16a3988a0b4ca3fc496 | aucan/ilkpython | /ilkpython/08recursion.py | 166 | 3.640625 | 4 | def faktoryel(sayi):
if sayi==0:
return 1
else:
return sayi*faktoryel(sayi-1)
girdi= int(input("bir sayi giriniz:"))
print(faktoryel(girdi)) |
75e7ce7b780e7c5b41f3390587c2c3a85741356d | Shantanu1395/Algorithms | /Trees/print_leftmost_rightmost.py | 1,583 | 4.03125 | 4 | class Node(object):
def __init__(self,data):
self.data=data
self.left=None
self.right=None
class Tree():
def __init__(self):
self.root=None
class Queue:
def __init__(self):
self.queue = list()
def enqueue(self,data):
self.queue.insert(0,data)
... |
16ea99409a47ab6242fed43f8bada3d95ba3d687 | lucasbflopes/codewars-solutions | /6-kyu/are-we-alternate?/python/solution.py | 187 | 3.828125 | 4 | def isAlt(s):
vowels = 'aeiou'
rule = lambda x,y : x in vowels and y not in vowels or x not in vowels and y in vowels
return all(rule(s[i], s[i+1]) for i in range(len(s) - 1)) |
11f68fe3ba8962efa382354d23caf645d0a46348 | frogonhills/OOP-.Practice | /oop5.py | 960 | 3.984375 | 4 | class Employee:
raise_amount = 1.04
num_of_employee = 0
def __init__(self , first , last , pay ):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + "@company.com"
Employee.num_of_employee += 1
def fullName(self):
ret... |
64c1a44e3a6ed34cbe66e092c2bb628b65e76cdf | jackie-kinsler/Labs | /dicts-word-count/wordcount.py | 898 | 3.921875 | 4 |
import sys
def make_word_counts():
wordcount_in_textfile = {}
#Write a table that takes ASCII values and translates them to other characters
#In this case, the other character is None
#Table handles: .(46) ,(44) !(33) ?(63) ;(59) :(58) _(95) "(34)
punctuation = { 44 : None, 46 : None, 33 : N... |
f1d886bbcf6ae7200ded8b0936ba48ce94d398cf | AsanalievBakyt/classwork | /functional_programming_2.py | 330 | 3.546875 | 4 |
def twoSum(nums, target):
for index in range(len(nums)):
current = nums[index]
next_list = nums[index + 1:]
for j in range(len(next_list)):
num = next_list[j]
if current + num == target:
return index, nums.index(num, index+1)
print(twoSum([2,7,11,... |
b8b6206a110dbd92e7fc31c7fac2d9a6d1ab4898 | Lucas-Guimaraes/Reddit-Daily-Programmer | /Easy Problems/131-140/136easy.py | 990 | 3.71875 | 4 | # https://www.reddit.com/r/dailyprogrammer/comments/1kphtf/081313_challenge_136_easy_student_management/
#Allows multiple lines to be read
import sys
#This program handles the initial function
#Stu = 'students'
def student_management(stu_input):
#This handles all of the new lines
space = stu_input.fi... |
763f8a75987f704b4f94188f5d0560ebb4721e2b | Airlis/LeetCode | /2.add-two-numbers.py | 872 | 3.6875 | 4 | #
# @lc app=leetcode id=2 lang=python3
#
# [2] Add Two Numbers
#
# @lc code=start
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
dummy = L... |
70a39b776e4839816ab51346083e43c80b9dd44b | Chloejay/patterns | /structAlgorithm/selectionsort.py | 396 | 3.890625 | 4 | #! /usr/bin/env python
def selectsort(lst):
n = len(lst)
for i in range(n):
smallest = i
for j in range(i+1, n):
if lst[j] < lst[smallest]:
#replace the smallest value to j
smallest = j
lst[smallest], lst[i]= lst[i], lst[smallest] #swap
... |
b6cd38c77fd2e1749c899645b90e7222b0b8c48c | SamNadjari/Algorithms | /max_flow.py | 1,619 | 3.578125 | 4 | #Resources: https://www.geeksforgeeks.org/ford-fulkerson-algorithm-for-maximum-flow-problem/
import networkx as nx
def max_flow(residual, s, t):
max_flow = 0
parent = {}
for node in residual:
parent[node] = "none"
while augmenting_path(residual, s, t, parent) == True:
... |
352684d4471e2387368f2d8c11e49bc96df77b3a | mayakhanna4/adventofcode | /day7.py | 1,191 | 3.59375 | 4 | total_count = set()
val_dict = {}
def find(line_list, to_look ):
print('TO LOOK: ' + to_look)
for i in line_list:
print(i[1])
if(i[1].find(to_look) != -1 ):
print('in here')
print(i[0].strip())
if(i[1].strip() not in total_count):
total_count.... |
26a94e93ffff957f7c6b187cbf85a72de9e1beef | ThiagoNFerreira/PythonFund | /exercicios/lojaRoupas/modules/produtos.py | 492 | 3.75 | 4 | produtos = []
def addProduto(nome, tamanho, preco):
produto = {
'nome': nome,
'tamanho': tamanho,
'preco': preco
}
produtos.append(produto)
def verProduto():
for p in produtos:
print('================')
print(f"Nome: {p['nome']}")
print(f"Tamanho: {... |
8b7a3409afe32eb96defc06cb3c81af1eb1a0932 | tawatchai-6898/tawatchai-6898 | /Lab03/Problem5.py | 386 | 4.125 | 4 | from functools import reduce
def compute_sum_positive_odd_numbers():
get_num = list(map(int, input("Enter number of elements:").split()))
less_than_zero = list(filter(lambda x: (x % 2 == 1 and x > 0), get_num))
product = reduce((lambda x, y: x + y), less_than_zero)
return print(product)
if... |
a7587bd466310d9453efea24fa0dc8528f2668da | cry999/AtCoder | /beginner/092/B.py | 639 | 3.578125 | 4 | def chocolate(N: int, D: int, X: int, A: list) -> int:
# i 人目の参加者が食べる個数を m とすると、m は
# (m-1)ai + 1 <= D
# を満たす最大の m である。したがって、これを変形して、
# m = 1 + (D-1)//ai
# となる。
# これを各 i について和をとって、残った X 個を足せば
# 初日に用意されていた個数が算出できる。
return X + sum(1 + (D-1)//a for a in A)
if __name__ == "__main__":
N... |
8e946987c9072069173e92d0746defeee815ccc8 | Jon-Rey/DodgeBallZ | /game/buttons.py | 1,751 | 3.890625 | 4 | # Button class to create our on-screen buttons
from globals import *
import pygame
class Button(pygame.sprite.Sprite):
"""Allows for the creation of buttons. Give the class its parameters and make a button
that is any color, size, font and position"""
def __init__(self, w, h, label="Button", color=RED):
... |
6399eecebfec8538b62e259851041d786d9be62b | HKuz/MOOCMITx600 | /6_00_1x/Midterm/midterm.py | 6,365 | 3.765625 | 4 | #!/usr/local/bin/python3
def main():
test_is_triangular = True
test_print_without_vowels = True
test_largest_odd_times = True
test_dict_invert = True
test_general_poly = True
test_is_list_permutation = True
if test_is_triangular:
nums = [-1, 0, 0.5, 1, 2, 3, 4, 6, 10, 12, 15]
... |
0bdbe712ce37645c2308541c49e475f1732c6060 | ekivoka/PythonExercises | /gen.py | 304 | 3.671875 | 4 | def primes():
n = 1
while True:
n +=1
d = 0
for k in range(n):
if n%(k+1) == 0:
d+=1
if d==2:
d = 0
yield n
d = 0
k = 0
for x in primes():
print(x)
k+= 1
if k > 10:
break
|
2e5e388438add44633428d1e02144df0c901b6d9 | igortereshchenko/amis_python | /km73/Samodryga_Oleg/3/task4.py | 313 | 3.59375 | 4 | n=int(input("Введіть кількість студентів "))
k=int(input("Введіть кількість яблук "))
stud=int(n/k)
bag=int(n%k)
print("Кількість яблук на студента", (str)(stud),"\nКількість яблук у кошику", (str)(bag))
input("")
|
a67bd5986d05e6ebbd9fa43e85248077a6f583d2 | CCG-Magno/Tutoriales_Python | /utils/easy_plot.py | 476 | 3.65625 | 4 | import matplotlib.pyplot as plt
def plot_fn(data=tuple(), labels=('X','Y'), scale="linear", title="Graph"):
'''Disclaimer: Streamlined plotting from matplotlib functions,
for ease of use not claiming ownership. '''
x, y = data
x_label, y_label = labels
plt.plot(x,y)
plt.xlabel(x... |
60424942859871b84af7c9b1197f194a0cb16eb0 | davidcoxch/PierianPython | /6_Methods_and_Functions/is_greater.py | 325 | 4.15625 | 4 | #create a function that returns True if first value is higher or equal
# and false if the second value is higher
def is_greater(c,d):
return c>=d
#When you run the statement above, you won't get any output
#for the return satement displayed
#So you have to wrap the function in a print statement
print(is_greater(... |
8031a19f009cc8bfe7092d321f56b400135430a8 | electriclo/quizgame | /quiz.py | 1,003 | 3.765625 | 4 | q1 = "what color is the sky? a.blue, b.red, c.green, d.yellow"
print (q1)
userchoice = input()
count = 0
q1answer = "a"
if userchoice == q1answer:
print ("correct")
count += 1
print (count)
else:
print ("incorrect")
q2 = "what is 1 + 1? a.1, b.5, c.2"
print (q2)
userchoice = input()
q2a... |
8010e58862aa0561436f162f659284022b31f4f1 | anotimpp90c2c7/zulip-gci-submissions | /interactive-bots/message_info/LarsZauberer/message_info.py | 824 | 3.609375 | 4 | # See readme.md for instructions on running this code.
from typing import Any
class MessageInfoHandler(object):
def usage(self) -> str:
return '''
This bot will allow users to analyze a message for word count. The gathered information will then be sent to a private conversation with the user. User... |
a888129e29c60ee7899e023b62061f184abfc52a | RaimundoJSoares/Programs-in-Python | /Separando_Numerais.py | 519 | 3.8125 | 4 | n = int(input('digite um numero'))
#m = str(n)
#print('analisando o numero{}'.format(n))
#print('Unidade : {}'.format(m[3]))
#print('Dezena: {}'.format(m[2]))
#print('Centena: {}'.format(m[1]))
#print(' Milhar: {} '.format(m[0])) ( Vamos tentar o metodo 2, pq esse não da pra digitar numeros abaixo de 1000 pois da erro... |
216131c0fb36ff2d5c864d419ede8895d948c3c7 | andriiglukhyi/codewars | /multi-tap-keypad/solution.py | 299 | 3.5625 | 4 | def presses(phrase):
print(phrase)
total = 0
char = ['1', 'abc2', 'def3', 'ghi4', 'jkl5', 'mno6','pqrs7', 'tuv8', 'wxyz9', ' 0', '#', '*']
for let in phrase.lower():
for but in char:
if let in but:
total+=but.index(let)+1
return total
|
b242242e6848f5c3c06d5635696f4135a8130dc1 | CoraJung/book-recommendation-system | /working_files/nmslib_recommend2.py | 2,499 | 3.53125 | 4 | def augment_inner_product_matrix(factors):
"""
This involves transforming each row by adding one extra dimension as suggested in the paper:
"Speeding Up the Xbox Recommender System Using a Euclidean Transformation for Inner-Product
Spaces" https://www.microsoft.com/en-us/research/wp-content/uploads/... |
b076717a05b1032acb6fd355316c11ab3c78987a | JeradXander/pythoMyCode | /loops/WorkingWith/csvChallenge.py | 1,948 | 4.03125 | 4 | #!/usr/bin/env python3
"""CSV Challenge reading and writing food data"""
# standard library import
import csv
#lists to add data too
boysList = []
girlsList = []
with open("babyName.csv","r") as names:
#variables
ind = 0
year = 2000
haveGirl = False
rowNumber = 0
#for loop to loop through... |
331fc8f0f0c0280da993772157a0585a38aad03c | joanne282/code-up | /zz/201023_1094.py | 183 | 3.796875 | 4 | def main():
n = int(input())
numbers = input().strip().split(' ')
for number in reversed(numbers):
print(number, end=' ')
if __name__ == '__main__':
main()
|
66c18ccffc4a1a2f0cdb62cc34c7664b8dc3b549 | aspidistras/grandpy-bot | /botapp/models/user.py | 1,525 | 3.75 | 4 | """defines User model and Login Form"""
from wtforms import form, fields, validators
from flask_sqlalchemy import SQLAlchemy
from flask_security import UserMixin
db = SQLAlchemy()
class User(db.Model, UserMixin):
"""initializes User object with its attributes to permit account creation and login"""
id = ... |
81fc4c546b2f906537134bb87b25a40107860d6b | KevenGe/LeetCode-Solutions | /problemset/1001. 网格照明/solution.py | 2,140 | 3.6875 | 4 | # 1001. 网格照明
# https://leetcode-cn.com/problems/grid-illumination/
from typing import List
class Solution:
def gridIllumination(self, n: int, lamps: List[List[int]], queries: List[List[int]]) -> List[int]:
row = {}
col = {}
dig = {}
anti_dig = {}
pos = {}
for x, y... |
c90e123c1362646ea62541f1d9538b84cc027477 | MrHamdulay/csc3-capstone | /examples/data/Assignment_7/mkxtat001/util.py | 1,771 | 3.9375 | 4 | #Tato Moaki MKXTAT001
#Module of functions to manipulate 2-D arrays of size 4 x 4
#Assignment7 question2
def create_grid(grid):
"""create a 4x4 grid"""
for i in range(4):
grid.append([0] * 4) #create a list of size 4 and append to grid to create a 2-D array
return(grid)
def print_gr... |
915114dcad82ccc9c0597c64e6966f07e30e5ddf | Myusuft/Alpro-part5 | /PRAUTS/max4ankga.py | 170 | 3.671875 | 4 |
def mulai(nilai):
for i in range (1,nilai+1,1):
print(i)
for i in range(nilai-1,0,-1):
print(i)
nilai = int(input())
print(mulai(nilai)) |
b9d6698a9768b274e72fc44d66e6fe482fa1b587 | winkitee/coding-interview-problems | /41-50/42_validate_binary_search_tree.py | 1,277 | 4.1875 | 4 | """
Hi, here's your problem today. This problem was recently asked by Facebook:
You are given the root of a binary search tree. Return true if it is a valid
binary search tree, and false otherwise. Recall that a binary search tree has
the property that all keys in the left subtree are less than or equal to the
root, a... |
3b35b7856a31eaf4c30425c94a2def2d5e269edb | NChesser/Challenge | /005/budgeter.py | 1,631 | 4.03125 | 4 | # budget program, where I can enter in my expenses and it will store results
# perhaps I can also incorperate some graphs or something
import sqlite3
import random
# might want to change the database name, if I want this to be a budget program
EXPENSE_DATABASE = "expenses.db"
EXPENSE_TYPES = ("FOOD", "RENT", ... |
9e60a508267078e8f308650a0a2944663fcc0783 | shihongup/MNIST_KNN | /MNIST_KNN/MNIST_KNN_Py.py | 6,107 | 3.9375 | 4 |
# coding: utf-8
# <h1><font size="6">CSCI 6364 - Machine Learning</font></h1>
# <h1><font size="5">Project 1 - MNIST</font></h1>
# <p><font size="4"><span style="line-height:30px;">Student: Shifeng Yuan</span><br>
# <span style="line-height:30px;">GWid: G32115270<span><br>
# Language: Python<font><br>
# <span style="... |
4c53ba02b1b8aa08839f8d938c0f0ec358ec0a91 | ebertti/PAA-PUCRio | /fastpower.py | 256 | 3.90625 | 4 | #-*- coding: utf-8 -*-
def FastPower(a,b) :
if b == 1:
return a
else:
c = a*a
ans = FastPower(c,b/2)
if b % 2 != 0:
return a*ans
else:
return ans
if __name__ == "__main__":
print FastPower(2, 9) |
8025ca02c2bfda5094529b9cf719eb7a89bb6afc | dsnair/python3-examples | /python1/01_bignum.py | 188 | 3.6875 | 4 | # Print out 2 to the 65536 power
# (try doing the same thing in the JS console and see what it outputs)
from math import pow
print("2^2 is", pow(2, 2))
print("2^65536 is", pow(2, 65536)) |
ce354a9afa400dd931f6b76e94c70e86f40243db | bannavarapu/Competetive_Programming | /competetive_programming/week1/day4/second_largest_tree.py | 1,249 | 4.1875 | 4 |
def find_second_largest(root):
# Find the second largest item in the binary search tree
elements=[]
elements.append(root)
values=[]
while(len(elements)>0):
temp=elements.pop()
values.append(temp.value)
if(temp.left is not None):
elements.append(temp.left)
... |
c65b9a90def083856515f772682986094dcc596a | ErdenebatSE/resource-of-python-book | /7-python/function/squares.py | 486 | 4.3125 | 4 | # Модулийн тодорхой хэсгийг импортлох
""" from functions import square
for i in range(3,6):
print(f"{i} -н квадрат: {square(i)}") """
# Модулийг бүхэлд нь импортлох
""" import functions
for i in range(3,6):
print(f"{i} -н квадрат: {functions.square(i)}")
"""
# Модулийг дахин нэрлэх
import functions as f... |
a17135f97e8ab8687a75e52c02e2292373677b1f | 2648226350/Python_learn | /pych-eight/8_3to8_5.py | 547 | 3.96875 | 4 | #8-3
def make_shirt(size, words):
print("This T-shirt is "+str(size)+" yards in size, and it was printed with '"+words+"'.")
make_shirt(34,'Warrios')
make_shirt(words = 'Rise',size = 55)
#8-4
def make_big_shirt(size, words = 'I love Python'):
print("This T-shirt is "+str(size)+" yards in size, and it was printe... |
5eca1fa7a68665227b38cd6249b90199adfdf792 | SonjaZucki/Lektion12 | /sum.py | 179 | 3.703125 | 4 | def sum_numbers(num1, num2):
result = num1 + num2
return result
print(sum_numbers(2, 8))
print(sum_numbers(10, 3))
print(sum_numbers(87, 30))
print(sum_numbers(74, 112)) |
383ba0ecde3b55400966390764cdbf9effe7c567 | adithyakumar303/python | /quiz.py | 2,136 | 4.0625 | 4 | print("genaral knolsdge quiz")
score=0
print("\n")
print("1. who is the first man on the moon")
answer=input("enter you answer: ")
if answer == "neil armstrong":
print("answer is correct")
score=score+1
else:
print("anser is wrong")
print("\n")
print("2. who is the first man to climb mount everest")
answer=... |
5673c2fca3e69019f2ca443a09226ea8a8595a74 | Poloeli303/mandelbrot | /mandelbrot.py | 1,890 | 4.53125 | 5 | #Mandelbrot Set Program
#Graphs the Mandelbrot set iteratively (function is NOT recursive)
#Written by Dr. Mo, Fall 2019
import pygame
import math
import cmath
pygame.init()
pygame.display.set_caption("mandelbrot") # sets the window title
screen = pygame.display.set_mode((800, 800)) # creates game screen
screen.fi... |
379344e8cdfb21f9ac4b32e4773802447ce476c3 | RIT-CS-Mentoring-Center-Queueing/mmcga_project | /server/rmq_examples/hw_server.py | 994 | 3.578125 | 4 | #!/usr/bin/python3
##
## File: hw_server.py
##
## Author: Schuyler Martin <sam8050@rit.edu>
##
## Description: Initial "hello world" server program for RabbitMQ using pika
##
import pika
#### GLOBALS ####
#### FUNCTIONS ####
def callback(ch, method, properties, body):
print("Got: " + str(body))
#### MA... |
2982c39c1e086231f9ed1528acf290c82d8eb82c | sei1225/python_biginner | /56.py | 390 | 3.71875 | 4 | # def outer(a: int, b: int) -> None:
# def inner() -> int:
# return a + b
# return inner
# f = outer(1, 2)
# r = f()
# print(r)
def circle_area_func(pie: float) -> None:
def circle_area(radius: int) -> float:
return pie * (radius ** 2)
return circle_area
ca1 = circle_area_func(3.... |
38517484c7aac9bb4ba767d08f6a492e10e96895 | zmmille2/playground | /swapper.py | 1,095 | 3.5625 | 4 | from collections import defaultdict
if __name__ == "__main__":
num_tests = int(raw_input())
while num_tests > 0:
string = raw_input()
forward_x = 0
forward_y = 0
forward_best = 0
backward_x = 0
backward_y = 0
backward_best = 0
for index in x... |
2797d337634abfed1890e8b1a96ec202f145e80a | epsequiel/LPTHW | /ex32.py | 765 | 4.21875 | 4 | #! /usr/bin/python
# Ejercicio 32 pagina 106
the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# Ciclo sobre una lista
for number in the_count:
print "This is the count %d" % number
# Mismo tipo de ciclo
for fruit in fruits:
pr... |
3e79a67ea7ffd78a7ef1d629b6f6cd122cdf8c09 | MrLoh/ALP2-Uebungen | /U04/A1 - mergesort.py | 4,347 | 3.75 | 4 | # Aufgabenteil a)
def is_sorted(L):
'''Kontrolliert ob eine Liste sortiert ist, für ansteigend sortierte Listen wird 1 zurüch gegeben, für absteigend sortierted Listen -1, für unsortierte 0 und für Listen mit gleichem Element None.'''
sort = None
i = 0
while sort == None and i+1 < len(L):
if L[i] < L[i+1]:
#L... |
3acb35589324d9b6b1841a7bbd72a548d5b6589f | yukatherin/project-euler | /my_solutions/p66.py | 1,089 | 3.609375 | 4 |
from math import sqrt
import numpy as np
def is_square(n):
return sqrt(n)==int(sqrt(n))
def solvable_for(x,D):
y = (x**2-1)/float(D)
return is_square(y) and y>0
def argmax_min(maxD):
max_x = 10**8
Ds = set([i for i in range(2,maxD+1) if not is_square(i) ])
for x in range(1,max_x):
n... |
613ae55a27ccff2a521695c0f209704569893e49 | gschen/sctu-ds-2020 | /1906101100-卢栎冰/Day20200225/作业test3.py | 474 | 3.9375 | 4 | # 3.(使用def函数完成)找出传入函数的列表或元组的奇数位对应的元素,并返回一个新的列表
# 样例输入
# 1,2,3,4,5,6,7
# 样例输出
# 1, 3, 5, 7
# x=[1,2,3,4,5,6,7]
# def f(x):
# return x=2*n+1
# print(x) 错的
def f(x):
list=[]
for i in range(len(x)):
if i%2==1:
list.append(x[i])
return list
print(f([1,2,3,4,5,6,7,8,9]))
def f(x):
... |
61712a005f494d877132ce0c33d6058776c9a9e4 | acastro84/Intro-to-Python | /Lab5b.py | 5,964 | 4.375 | 4 | #Cleans up previous code a user menu. Imports package conversionlabs to perform the conversion functions.
#import the module needed for the conversions
import conversionslabs
#Set constraints for the menu:
MILES_TO_KM = 1
FAH_TO_CELSIUS = 2
GAL_TO_LITERS = 3
POUNDS_TO_KG = 4
INCHES_TO_CM =5
QUIT_CHOICE = 0
QUIT... |
14b935b0b7c78cfb1be6eb9ecaf78f012e075ad8 | jandirafviana/python-exercises | /my-python-files/aula07_desafio006.py | 886 | 4.1875 | 4 | print('=== DESAFIO 006 ===')
print('Crie um algoritmo que leia um número e mostre o seu dobro, triplo e raiz quadrada:')
n = int(input('Digite um número:'))
print(f'O dobro de {n} é {n*2}, o triplo é {n*3} e a raiz quadrada é {n**(1/2):.2f}.')
n = int(input('Digite outro número: '))
dobro = n*2
triplo = n*3
raiz = n... |
a9d71a0ed6825624fea6e099bc1e829b69eda285 | CReesman/Python_Crash_Course | /Python_Crash_Course_Book/CH5/stages_of_life_5_6.py | 1,083 | 4.40625 | 4 | '''
5-6
Stages of Life: Write an if-elif-else chain that determines a person’s stage of life. Set a value for the variable age, and then:
*If the person is less than 2 years old, print a message that the person is a baby.
*If the person is at least 2 years old but less than 4, print a message that the person is a todd... |
09729d23b344960ffee4ab15c5817923fb84c2bc | algebra-det/Python | /OOPs/Polymorphism_Method_Overriding.py | 833 | 4.125 | 4 | class A:
def show(self):
print("In A show")
class B:
pass
a1 = A()
a1.show()
b1 = B()
#b1.show() # this will not work as show is not present in class B
print("__________")
class Al:
def show(self):
print("In A show")
class Bl(Al):
pass
al1 = Al()
al1.show()
bl1 = Bl()
b... |
88cf63f62ac4c58413519b2d00b94fde2c123b86 | wbkusy/pythonalx | /Arytmetyka.py | 554 | 4.15625 | 4 | # 1. przypisz do zmiennych x i y jakieś wartości liczbowe kożystając z funkcji print wypisz na ekranie podstawowe działania arytmetyczne
# (dodawanie, dzielenie, odejmowanie, potęgowanie, mnożenie, dzielenie z resztą, dzielenie całkowite)
# uruchom program kilka raz dla różnych wartości
x = 13
y = 6.3
print("x=", x, "y... |
1c52cabacf6958d664ea9d4803faa7109f4ce2ea | Ynjxsjmh/PracticeMakesPerfect | /LeetCode/p0239/I/sliding-window-maximum.py | 2,175 | 3.875 | 4 | # -*- coding: utf-8 -*-
# ********************************************************************************
# Copyright © 2022 Ynjxsjmh
# File Name: sliding-window-maximum.py
# Author: Ynjxsjmh
# Email: ynjxsjmh@gmail.com
# Created: 2022-06-28 10:03:33
# Last Updated:
# By: Ynjxsjmh
# Description: You are giv... |
1bd0781093c119be099ede8f1260207e682e59b0 | Pradeepsuthar/pythonCode | /PythonProgramsTraining/classes (1)/exh.py | 882 | 3.703125 | 4 | try:
bill = int(input("Enter bill amount:- "))
quantity = float(input("Enter quantity:- "))
rate=bill/quantity
print("RATE:- %0.2f"%rate)
except Exception as ex1:
print(type(ex1)," : ",ex1)
try:
marks=[90.2,34,56.87,15]
rno=int(input("Enter roll number:- "))
print("Marksof r... |
799c8c958c1f82c2bf8ad522efc7deda894228c5 | atulgupta9/DigitalAlpha-Training-Programs | /Day2/prog1.py | 250 | 4.28125 | 4 | # Write a program which will find all
# such numbers which are divisible by 9 but are
# not a multiple of 5,between 0 and 3000 (both included). Print them on screen
for x in range(0, 3000):
if x % 9 == 0 and x % 5 != 0:
print(x)
|
1fb1320979773158abbb95b91417e69512f0c5c4 | JasonkayZK/Python | /Python_Fundamental_Lesson/3_Exception_File/file/Readlines.py | 169 | 3.546875 | 4 | file = open("test.txt", "r")
print(file.readlines())
file.close()
# Use for ... in ... clause
file = open("test.txt", "r")
for line in file:
print(line)
file.close()
|
846389d288b41f2cdea794e0b90c7a0088b5452b | bondarchukb/patterns | /behavior/chain_of_responsibility.py | 1,418 | 3.640625 | 4 | class WeirdCafeVisitor(object):
def __init__(self, cafe_visitor=None):
self.cafe_visitor = cafe_visitor
def handle_food(self, food):
print("just pass")
if self.cafe_visitor is not None:
self.cafe_visitor.handle_food(food)
class BestFriend(WeirdCafeVisitor):
def __init_... |
4518d571c62dc4b32335b4eff9a9343b299e175e | mingyyy/onsite | /week_02/mini_projects/02_bottles.py | 1,762 | 4.3125 | 4 | '''
--------------------------------------------------------
99 BOTTLES OF BEER LYRICS
--------------------------------------------------------
https://www.reddit.com/r/beginnerprojects/comments/19kxre/project_99_bottles_of_beer_on_the_wall_lyrics/
-- GOAL --
Create a program that prints out every lin... |
b68da7030cf713c2fc0c53483df835cf9b3be83f | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4194/codes/1630_2946.py | 250 | 3.71875 | 4 | ml=float(input("Media dos laboratorios: "))
mt=float(input("Media dos trabalhos: "))
mp=float(input("Media das provas: "))
var1=round(ml/100, 2)
var2=round(mt/100, 2)
var3=round(mp/100, 2)
notafinal=round((var1*25+var2*30+var3*45),2)
print(notafinal) |
8cdfeb75b07c506db6523f312ff52727a4a903e2 | ming-log/Multitasking | /03 协程/06 生成器.py | 344 | 3.859375 | 4 | # !/usr/bin/python3
# -*- coding:utf-8 -*-
# author: Ming Luo
# time: 2020/9/8 15:55
# 列表生成式
nums = [x*2 for x in range(10)]
# 生成器generator
nums = (x*2 for x in range(10))
# 使用next()方法取生成器的值
next(nums)
# 生成器是一种特殊的迭代器
# 生成器都是迭代器,但是迭代器不一定是生成器
|
6fa86c826862497c0e21e25c9d71777ca5629982 | erika-r/CA268_python | /week7/hash.py | 254 | 3.90625 | 4 | def main():
lst = [1, 5, 27, 35, 11, 15, 105, 95, 31]
hashset = HashSet()
for x in lst:
hashset.add(x)
print(hashset)
#all numbers that end in the same number are all indexed the same eg 5,35,15
if __name__ == "__main__":
main() |
3e61587f7e3c19ef6ba6131b080b234bc3d93e16 | brandonhillert/StructeredProgramming | /Mastering Mastermind/mastermind_comp_vs_me.py | 4,439 | 4.03125 | 4 | """"BRON : 2.1 A Simple Strategy
YET ANOTHER MASTERMIND STRATEGY
Department of Philosophy, University of Groningen, The Netherlands
Barteld Kooi
"""
import itertools
import random
"""Deze functie genereert een random combinatie uit de lijst
https://pynative.com/python-random-choice/"""
def random_combinatie_computer... |
7fc6d6bb5303815e46d847e793b0140b014296ad | ElliotSis/Projets | /IA/TP IA Polytechnique/TP1/Miscellaneous/antenna.py | 1,061 | 4.0625 | 4 | import math
from utilities import *
# Class Antenna
# Represents an Antenna
# - Coordinates
# - Radius
# - Enclosed points
class Antenna:
# When an antenna is created, we first enclose only one point
def __init__(self, point):
self.center = point
self.radius = 1
self.points = []
... |
871a180c4b62fc550a0887beb398ca61907d34cc | hadassa5sf/cleanFunction.py | /presisionMach_Function.py | 11,273 | 3.921875 | 4 | import pandas as pd
import numpy as np
import math
import xlsxwriter as xlsw
"""
CHANGING ROW AND COLON AND WORK WITH DATAFRAME - VERY GOOD SITE:
https://www.askpython.com/python-modules/pandas/update-the-value-of-a-row-dataframe
ADDING NEW LIST TO A DATAFRAME
import pandas as pd
info= {"Num":[], "NAME":[]... |
6c4f4eb8bb911da17184707281d15dae751042c8 | EricRovell/project-euler | /deprecated/037/python/037.py | 1,209 | 3.828125 | 4 | # primes generator [left_limit; right_limit]
def prime(left, right):
for possiblePrime in range(left, right + 1):
for number in range(2, int(possiblePrime ** 0.5 + 1)):
if possiblePrime % number == 0:
break
else:
yield possiblePrime
# returns a list of all truncation of the given number
#... |
89bc3339e32a09673bc5b2536ac68852281975b1 | weiguozhao/LeetCodes | /src/_python/hot100/53_MaximumSubarray.py | 2,296 | 3.703125 | 4 | # coding:utf-8
from typing import List
class Solution:
"""
problem 53
https://leetcode-cn.com/problems/maximum-subarray/
给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
示例:
输入: [-2,1,-3,4,-1,2,1,-5,4],
输出: 6
解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。
进阶:
如果你已经实现复杂度为 O(n) 的解法,尝试使用更为... |
1530299c56d70e7f8d3d6249478e478ad19db9c8 | adrgrc26/Learning-Python | /fizzbuzz.py | 935 | 4.25 | 4 | #!/usr/bin/env python3
# Write a program that prints the numbers from 1 to 100
# For multiples of 3 print “Fizz” instead of the number
# For the multiples of 5 print “Buzz”
# For numbers which are multiples of both 3 and 5 print “FizzBuzz”.
for i in range (1, 101):
if i % 3 == 0 and i % 5 == 0: print ('FizzBuzz')
... |
8f5feed067f82d046f142fd20b668f4516eb8e83 | Ayushkumar11/Data-structure-Algo | /problem_1.py | 1,399 | 4.3125 | 4 | def sqrt(number):
"""
Calculate the floored square root of a number
Args:
number(int): Number to find the floored squared root
Returns:
int: Floored Square Root
"""
if number == 0 or number == 1:
return number
if number < 0:
return -1
... |
3e1f6e26f98aef8bc22d23faa57f8bb6c87c2b7c | yashms25/DataStructure-using-python | /Dequeue(Double-Ended-queue).py | 1,134 | 4.125 | 4 |
class Deque:
def __init__(self):
self.queue= []
def addRear(self, elem):
self.queue.append(elem)
def addFront(self, elem):
self.queue.insert(0, elem)
def removeFront(self):
if len(self.queue) == 0:
print("Dequeue Is Empty")
else:
self.que... |
2d934f98de2d2915f873f133ca42ff2bafd0481e | KATO-Hiro/AtCoder | /ARC/arc051-arc100/arc052/a.py | 213 | 3.65625 | 4 | # -*- coding: utf-8 -*-
def main():
s = input()
result = ''
for si in s:
if si.isdigit():
result += si
print(result)
if __name__ == '__main__':
main()
|
ab8f4a0bf797053a530019049ca438242a8eb38e | ngxtop/ngxtop | /ngxtop/utils.py | 546 | 3.796875 | 4 | import sys
def choose_one(choices, prompt):
for idx, choice in enumerate(choices):
print(("%d. %s" % (idx + 1, choice)))
selected = None
if sys.version[0] == "3":
raw_input = input
while not selected or selected <= 0 or selected > len(choices):
selected = input(prompt)
... |
fad02c5d656c1a8e84be35d68e8852620795f424 | park950414/python | /第二章/4triangle.py | 414 | 3.5625 | 4 | import turtle
turtle.setup(1000,1000,200,200)
turtle.pensize(2)
a=1
for i in range (3):
turtle.fd(200)
turtle.seth(120*a)
a=a+1
turtle.seth(-120)
a=1
for i in range (3):
turtle.fd(200)
turtle.seth(-120+120*a)
a=a+1
turtle.seth(0)
turtle.penup()
turtle.fd(200)
turtle.pendown()
turtle.seth(-120)
a... |
dc3a0eeb1e2d572f53b7f1dd2f76a201cc41dd0d | manoflogan/comscore-takehome | /datastore_importer.py | 2,301 | 3.859375 | 4 | """Entry point for importer and datastore. It accepts arguments in two ways.
1. through the file argument. The invocation would be something like
python importer_datastore.py datastore.csv
2. through standard input such as
python importer_datastore.py < datastore.csv
"""
import csv
import fileinput
import logging
... |
0b52da3c563d6c19cb26850d35485f9932308f8b | nivipandey/python | /string/str3.py | 84 | 3.65625 | 4 | s1="good"
s2=input("enter age ")
s3=input("enter name")
print(s1+" "+s2+" "+s3+" ")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.