blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
028026f8713a6648910c355f1901106b37a84cc3 | lbd1607/goingGreen2 | /goingGreen2.py | 3,278 | 4.15625 | 4 | #Laura Davis
#1 May 2016
#This program will calculate the energy difference after of going green by
#comparing energy bills from the year prior to making the switch and the year
#following the switch. It will aggregate two years' worth of data and
#compute the savings. The data will be saved in file savings.txt and
... |
7502a34ab41ad79cb009927fb08c32986cc6deed | omuga/INF-349-Programacion-Competitiva | /Codeforces/579A - Raising Bacteria.py | 269 | 3.53125 | 4 | import math
__author__ = 'Obriel Muga'
def raising_bacteria(x):
binario = '{0:b}'.format(x)
num = 0
for i in binario:
if i == '1':
num = num + 1
return num
if __name__ == "__main__":
x = int(input())
print(raising_bacteria(x))
|
1b8d5ac4015043828db9de4149cf8436ea2dc710 | anshul0412/python-openCv | /chapter4.py | 410 | 3.671875 | 4 | import cv2
import numpy as np
#draw shaped and to put text on images
#first we will create a matrix filled with 0{black}
img= np.zeros((512,512,3),np.uint8)
#print(img)
#img[:]= 0,0,0
cv2.line(img,(0,0),(300,300),(0,0,255),5)
cv2.circle(img,(300,300),50,(255,0,255),10)
#text on images
cv2.putText(img,"openCV",(300... |
3d163a491a3b9a6e5a0d9b486e03eae055e72366 | PengZhang2018/LeetCode | /algorithms/python/DiameterOfBinaryTree/DiameterOfBinaryTree.py | 994 | 3.84375 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def diameterOfBinaryTree(self, root: TreeNode) -> int:
self.result = 0
def dfs(node: TreeNode):
if not node: return 0
... |
cedd1379bb5e1f1ce488aa020930d1b8aa1e15d9 | Seinu/MIT-6.00-OCW | /Problem-Set-2/ps2_hangman.py | 2,480 | 4.125 | 4 | # 6.00 Problem Set 3
#
# Hangman
#
# -----------------------------------
# Helper code
# (you don't need to understand this helper code)
import random
import string
WORDLIST_FILENAME = "words.txt"
def load_words():
"""
Returns a list of valid words. Words are strings of lowercase letters.
Dependin... |
91e1b3a828db781c99832a91c3d1fc767aa627ab | gyanmittal/regression | /naive_word2vec_skipgram.py | 6,335 | 3.53125 | 4 | '''
Author: Gyan Mittal
Corresponding Document: https://gyan-mittal.com/nlp-ai-ml/nlp-word2vec-skipgram-neural-network-iteration-based-methods-word-embeddings
Brief about word2vec: A team of Google researchers lead by Tomas Mikolov developed, patented, and published Word2vec in two publications in 2013.
For learning wo... |
524c6be0c5e02796ab23b923801a444e726923e4 | dominichipwood/euler_project | /30.py | 244 | 3.546875 | 4 | def s5pd(n): #sum of 5th powers of digits
digits=[int(t) for t in list(str(n))]
return sum(d**5 for d in digits)
nums=[]
n=2
for n in range(2,1000000):
if s5pd(n)==n:
nums.append(n)
print(nums)
print(sum(nums))
|
8b1152515efff7f1bd5b96aa24528537d58eb9ec | itamar141456/card_proj_with_roei | /test_Card_Game.py | 2,413 | 3.765625 | 4 | from unittest import TestCase
from Card_Game import CardGame
from player_class import Player
from Card_class import Card
class TestCardGame(TestCase):
def setUp(self):
Player1 = Player('roie')
Player2 = Player('itamar')
self.game1 = CardGame(Player1, Player2, 5)
def test_b... |
dd046c13b9c5fa5c8662310764520de556b0ec87 | daniel-reich/turbo-robot | /39utPCHvtWqt5vaz9_18.py | 2,095 | 4.34375 | 4 | """
You will be given a list of string `"east"` formatted differently every time.
Create a function that returns `"west"` wherever there is `"east"`. Format the
string according to the input. Check the examples below to better understand
the question.
### Examples
direction(["east", "EAST", "eastEAST"]) ➞ ["we... |
d237c9652b2f01632a8b88805011fb87c9144419 | tkobayas/deeplearningfromscratch | /hamegg/list/sort.py | 92 | 3.796875 | 4 | list = ["B", "X", "F", "G", "C"]
list.sort()
print (list)
list.reverse()
print (list)
|
35b39d0a32b2bf635e8d93e9e4ef2d5091fc5bfb | meihei3/SortCollections | /sortCollections/bogo_sort.py | 452 | 3.671875 | 4 | import random
from typing import List
def bogo_sort(ary: List[float]):
def is_sorted(ls: List[float]):
for _p, _next in zip(ls[:-1], ls[1:]):
if _p > _next:
return False
return True
while not is_sorted(ary):
random.shuffle(ary)
return ary
if __name_... |
90220d82506c3bade29d18489c5be1786098438d | felipeandrademorais/Python | /Basico/Funcoes_python.py | 1,489 | 3.75 | 4 | #Função com Parâmetros Default
def login(usuario="root", senha="123"):
print("Usuario: ", usuario)
print("Senha: ", senha)
login("Felipe","FeLi2705")#A passagem de argumentos é opcional
#Função com argumentos posicionais e nomeados
def dados_pessoais(nome, sobrenome, idade, sexo):
print("Nome: {}\nSobren... |
785e73f4cb8a1c6a2691f7a9c475362d5f9fff48 | nicoirm/AI_Car_Raspberry-pi | /Self-driving trolley based on ANN/sigmoid.py | 330 | 3.921875 | 4 | #!/usr/bin/env python
"""Sigmoid Function"""
from numpy import power, e
def sigmoid(x_value):
"""Return the sigmoid value"""
return 1.0/(1.0 + power(e, -x_value))
'''
from matplotlib import pyplot as plt
import numpy as np
for x in range(-100,100,2):
y = 1.0/(1 + np.power(np.e, -x))
plt.plot(x,y,'sigmoi... |
055f8f2a2563c17a1afa964bb5ba21cc0d77fe57 | cdavid719/investor | /mainlog.py | 539 | 3.640625 | 4 | from data import Username, Password
from user import User
import functionslog as function
user = User()
user.fname = input("Enter your first name >> ")
user.lname = input("Enter your last name >> ")
user.username = input("Enter your last username >> ")
function.actions(user.fname, user.lname, "username")
user.password... |
77a644dc456306da7d70ffec757ca7f4783b4043 | hyprr/pruthvi-IT | /lab7.py | 236 | 4.15625 | 4 | a=int(input("enter the value of a"))
b=int(input("entre the value of b"))
c=int(input("enter the value of c"))
if a>b and a>c:
print("a is greater than b")
elif b>c:
print("b is greater than c")
else:
print("c is greater than b")
|
3d881dd453548d8c80c04e5b10d8e7033dbb1f5d | AnjaliG1999/DSA | /Arrays/frequency.py | 526 | 4.0625 | 4 | dict = {}
def findFrequency(arr):
global dict
for key in arr:
dict[key] = [dict.get(key, 0) + 1]
def frequency1(arr, val):
findFrequency(arr)
return dict[val] if val in dict else 0
def frequency2(arr, val):
count = 0
for key in arr:
if key == val:
count += ... |
1799e33a7277f0341e1e5cd2eca5fab027fe4e9b | chawasitCPECMU/Software-Engineering | /CPU-Scheduling-Algorithm/dataset.py | 836 | 3.703125 | 4 | from numpy.random import uniform, shuffle
def generate(n=60, distributions=None):
"""Return a generated list of number by given list of range and distribution tuple
eg. spec = [(2, 8, 0.7), (20, 30, 0.2), (35, 40, 0.1)]
"""
if distributions is None:
distributions = [(2, 8, 0.7), (20, 30, 0... |
597f0ddfb06bd60f19d0bf418e810aad68630224 | p-koo/libre | /libre/model_zoo/cnn_local.py | 2,603 | 4.125 | 4 | from tensorflow import keras
def model(
input_shape,
output_shape,
activation="relu",
units=[24, 48, 96],
pool_size=[25, 4],
dropout=[0.1, 0.2, 0.5],
):
"""Creates a keras neural network with the architecture shown below. The
architecture is chosen to promote learning in the first laye... |
5b44db030c4a35e7e1e914f3f59602f1c4334849 | vasilchenkos/stepik-python-basics | /2.4/cytozin.py | 453 | 3.828125 | 4 | """Вывести количество элементов в строке по введенному символу"""
genome = input("Введите строку: ")
cnt = 0
for nucle in genome:
if nucle == "c":
cnt+=1
print(cnt)
"""Вывести количество элементов в строке по введенному символу без цикла"""
genome = input("Введите строку: ")
print(genome.count("c"))
|
acafe633abcaa583cf6a48694a00281818ee4c34 | MarineChap/Machine_Learning | /Clustering/Section 24 - K-Means Clustering/K_means.py | 2,391 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Part 3 : K-means cluster in following the course "Machine learning A-Z" at Udemy
The dataset can be found here https://www.superdatascience.com/machine-learning/
Subject : Mall want segments his clients in function of the Age, Annual Income (k$) and Spending S... |
6d9beee211571c771d5359d7f3f1e71a6565efdf | rymo90/kattis | /eligibility.py | 456 | 3.5 | 4 | n = int(input())
for _ in range(n):
data = input().split()
name= data[0]
temp= data[1]
postSecondStudieYear = temp[0:4]
temp2= data[2]
bithYear= temp2[0:4]
course= data[3]
if int(postSecondStudieYear) >= 2010 or int(bithYear) >= 1991:
print(name+" "+"eligible")
else:
... |
6e08cd0ea3a664a95c3bfe9a5e457d12dcf9f50f | phpons/mutation-testing-calculator | /src/calculator.py | 490 | 3.65625 | 4 | def is_number(a):
return isinstance(a, (int, float))
def validate_input(a, b):
if not is_number(a) or not is_number(b):
raise ValueError("Input values must be numbers.")
def sum(a, b):
validate_input(a, b)
return a + b
def subtract(a, b):
validate_input(a, b)
return a - b
def mult(a... |
fb1efc6afd4f77901699f5ebb894f7eeb4530f5c | vinitony12/calc | /add.py | 112 | 3.671875 | 4 | x = eval(input('Enter the first no:'))
y = eval(input('Enter the second no:'))
z = x - y
print('The diff is',z)
|
58ae65d067f889d967d6270a31063a935959e995 | marekbojko/stochastic-processes | /discrete/utils.py | 1,357 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 20 11:56:26 2019
@author: Marek
"""
import numpy as np
import itertools
class Checks(object):
"""Mix-in class containing input value checking functions."""
def _check_increments(self, n):
if not isinstance(n, int):
raise Typ... |
297d05baf8a2fc57dbb1c45881c0982f8970d600 | NimishVerma/PyDSALGO | /findWaysToClimb.py | 668 | 4.21875 | 4 | """
This problem was asked by Amazon.
There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters.
For example, if N is 4, then there are 5 unique ways:
1, 1, 1,... |
08e941e2a4d0e596e7154c5f43bdffc758941eda | johan-bh/Pygame-Game | /scoreboard.py | 2,597 | 3.53125 | 4 | import pygame.font
from pygame.sprite import Group
from ship import Ship
class Scoreboard():
"""A class to keep track of scores."""
def __init__(self,ai_settings,screen,stats):
self.screen = screen
self.screen_rect = screen.get_rect()
self.ai_settings = ai_settings
self.stats = stats
#Font settings and sc... |
b7a1f37b71ccff294540c87e749e59601549ebe6 | eazow/leetcode | /79_word_search.py | 1,247 | 3.6875 | 4 | # -*- coding:utf-8 -*-
class Solution(object):
def exist(self, board, word):
"""
:param board: List[List[str]]
:param word: str
:return: bool
"""
if board is None or len(board) == 0 or len(board[0]) == 0:
return word is None or word == ""
for i in... |
701dfbd03f54e73557b33def4183a44666826ed8 | wxx17395/Leetcode | /python code/剑指offer/39. 数组中出现次数超过一半的数字.py | 1,003 | 3.765625 | 4 | """
数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。
你可以假设数组是非空的,并且给定的数组总是存在多数元素。
示例 1:
输入: [1, 2, 3, 2, 2, 2, 5, 4, 2]
输出: 2
限制:
1 <= 数组长度 <= 50000
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-lcof
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
"""
class Solution:
def majori... |
a44e157902000894cdd2e36be5548d6f4c23d609 | phibzy/InterviewQPractice | /Solutions/MinimumRemoveToMakeValidParentheses/minRemove.py | 3,317 | 3.828125 | 4 | #!/usr/bin/python3
"""
@author : Chris Phibbs
@created : Tuesday Feb 23, 2021 11:48:12 AEDT
@file : minRemove
"""
# Only parentheses? Letters/numbers as well?
# Length of string? Empty string? Max length?
# Guaranteed to be at least one parenthese?
# Any rules regarding starting with open/closi... |
c52becc40f609d5e57b10e02a710b1e99b8fa11e | jaroldhakins/AirBnB_clone | /models/engine/file_storage.py | 1,632 | 3.671875 | 4 | #!/usr/bin/python3
"""
Write a class FileStorage
"""
import json
from os.path import exists
from models.base_model import BaseModel
from models.user import User
from models.amenity import Amenity
from models.city import City
from models.place import Place
from models.review import Review
class FileStorage:
"""
... |
8987dcfd442fd2ef6da2469909a6a811b97f8143 | asmaHelmy/improve_education_v1.0.0 | /helper.py | 3,812 | 4.1875 | 4 | import pandas as pd
def train_cats(df):
'''
this function is to help proveide categorical type (encoding)
for the categorical variables.
# Arguments
df : data frame that holds training data set
# Return
it provide an inplace process to interpret categorical variables
'''
for la... |
253ddfc40318017a57c7afdc250f8be4c70f26a3 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/bob/a01530f42bad4cd6a0c4c78378bfedbd.py | 465 | 4.09375 | 4 | #
# Skeleton file for the Python "Bob" exercise.
#
def hey(what):
#If there is no characters then return no talking case
if not what.strip():
return('Fine. Be that way!')
#Checks if the string is all capitals
if what.isupper():
return('Whoa, chill out!')
#Check for question mark at the end and returns... |
fa8185e18ba45b8a10e7c84a701931b032ed5d98 | g0ve/IN3110 | /assignment4/blur.py | 1,187 | 3.5 | 4 | import argparse
from blur_1 import main as blur_1
from blur_2 import main as blur_2
from blur_3 import main as blur_3
"""
This program is a user interface. It has diffrent options, which all can be viewed with --help.
This makes it possible to run all of the 3 implementation of image blurring.
"""
parser = argparse.A... |
e6d4f0f18eccead8c0ee124b7b2c62c6904bfc96 | AngelValAngelov/Python-Advanced-Exercises | /Multidimensional Lists - Exercise/01. Diagonal Difference.py | 409 | 3.90625 | 4 | matrix_size = int(input())
matrix = []
for _ in range(matrix_size):
row = input().split()
matrix.append([int(x) for x in row])
primary_diagonal_sum = 0
secondary_diagonal_sum = 0
for i in range(matrix_size):
primary_diagonal_sum += matrix[i][i]
secondary_diagonal_sum += matrix[i][-i - 1... |
8b4a42ba3793428ca9d602971ebc23eae3429db1 | alferesx/programmingbydoing | /SpaceBoxing.py | 804 | 4 | 4 | weight = float(input("Weight: "))
print("1-Venus")
print("2-Mars")
print("3-Jupiter")
print("4-Saturn")
print("5-Uranus")
print("6-Neptune")
planet = int(input("Choose a planet: "))
if planet == 1:
gravity = 0.78
weight = weight * gravity
print("Weight: " + weight)
elif planet == 2:
gravity = 0.39
weight... |
d60c88c956839b5a85914645dc8057a42727f178 | Plotkine/HackerRank | /Hard/en_cours_Matrix_Layer_Rotation.py | 1,431 | 3.703125 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
from copy import deepcopy
# Complete the matrixRotation function below.
def matrixRotation(matrix,r):
res = deepcopy(matrix)
m = len(matrix)
n = len(matrix[0])
for _ in range(r):
ring = 0
while ring <= min(m,n) / ... |
9a8be9762b0923d6abb2c582098866119efe4866 | jsillman/astr-119-hw-1 | /variables_and_loops.py | 456 | 3.9375 | 4 | import numpy as np #importing numpy
def main():
i = 0 #initialize i to 0
n = 10 #and n to 10 as integers
x = 119.0 #initialize x to 119 as a float
y = np.zeros(n,dtype=float) #array of 10 zeros as floats
for i in range(n): #loop from 0 to 9
y[i] = 2.0 * float(i) + 1.0 #setting y elements... |
629bf83bc9c5c83fe87774222080b9db36f085e6 | JavierEsteban/TodoPython | /Ejercicios/OperadoresBasicos/Python -Ojala/Clase 2.py | 303 | 3.609375 | 4 | #Trabajando con Fechas
from datetime import time
from datetime import date
from datetime import datetime
def main():
fecha = date.today()
print(fecha)
print(fecha.day)
print(fecha.year)
print(fecha.month)
print(str(fecha).replace("-",""))
if __name__ == "__main__":
main()
|
d5b7118fe34a8f2319cfc3cb24a09f89f8e6ee5f | FrankFang0830/pyc1 | /lab1-2.py | 563 | 3.828125 | 4 | data = [('John', ('Physics', 80)), ('Daniel', ('Science', 90)),
('John', ('Science', 95)), ('Mark', ('Maths', 100)),
('Daniel', ('History', 75)), ('Mark', ('Social', 95))]
def sort_by_course_name(o1: tuple) -> str:
return o1[0]
if __name__ == '__main__':
result = {}
for element in data:
... |
1359fcb2241b2dea2f53da9b998a93f0bdb9bd0c | BryanTorresCalle/Practica3_ciber | /punto2.py | 1,121 | 3.515625 | 4 | import time
from hashlib import sha256
import random as rand
import matplotlib.pyplot as plt
def punto2():
n = int(input("Ingrese un número entre 1 y 10 "))
interacciones = 0
while n < 1 or n > 11:
n = int(input("Ingrese un número entre 1 y 10 "))
print ("Ingrese un n valido")
while T... |
712460951c008d5a70849ed6a6dd7183cd7226b1 | RasPat1/withdrawlolz | /project_euler/p9.py | 727 | 4.25 | 4 | """
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 + c = 1000.
Find the product abc."""
import itertools
import math
def p9_bf(abc_sum):
loop_count = 0
product = 0
... |
76ade0d85f202b89622f90c57b0816018cd983a7 | qz267/leet-code-fun | /PY/wordSearch/main.py | 1,087 | 3.65625 | 4 | '''
Created on May 16, 2013
@author: Yubin Bai
'''
def wordSearch(matrix, w):
'''
search for words in matrix
'''
def _search(x, y, step, w):
'''
backtrack
'''
if step == len(w):
result[0] = True
return
if result[0] or x < 0 or x >= len(ma... |
51469703dcca375964c1d8834c8f35b0587344f1 | sunilmummadi/Linked-List-1 | /reverse_Linked_List.py | 1,593 | 3.90625 | 4 | # Leetcode 206. Reverse Linked List
# Time Complexity : O(n) where n is the size of the array
# Space Complexity : O(n) where n is the size of the recurssive stack
# Did this code successfully run on Leetcode : Yes
# Any problem you faced while coding this : No
# Approach: Move head to the last node in the list re... |
0bd6707cc54dbc678638a2978d7c4fb701dd4e43 | yibwu/leetcode | /src/sum_of_even_numbers_after_queries_985.py | 1,032 | 3.515625 | 4 | class Solution:
def sum_even_after_queries(self, A, queries):
res = []
for q in queries:
val = q[0]
i = q[1]
tmp = A[i]
A[i] += val
if not res:
res.append(self.get_sum_of_even(A))
else:
... |
e5bcdaa58257ecad81638e89946f0dd0714797a6 | vraj152/projectcs520 | /readingData.py | 2,419 | 3.5 | 4 | import numpy as np
"""
This method reads entire file and returns as a list
Params:
souce_file = file path
total_images = dataset size
length = length of pixel
width = length of pixel
Returns:
Entire file in list
"""
def load_data(source_file, total_images, length, width):
datasetFile = op... |
1e96e2a651e0fbc0908f6643943768cc63ef4625 | adam-weiler/GA-OOP-Inheritance-Part-3 | /system.py | 2,367 | 4.03125 | 4 | class System():
all_bodies = [] #Stores all bodies from every solar system.
def __init__(self, name):
self.name = name
self.bodies = [] #Stores only bodies from this solar system.
def __str__(self):
return f'The {self.name} system.'
def add(self, celestial_body):
i... |
232de43b0ba94630052e4af70341c7ea4a517328 | FawneLu/leetcode | /tree_traverse.py | 1,664 | 4.1875 | 4 | #递归
##前序
def recursion_preorder(self,node):
if not node:
return
else:
print(node.elem,end=' , ')
self.recursion_preorder(node.left)
self.recursion_preorder(node.right)
##中序
def recursion_inorder(self,node):
if not node:
return
else:
self.recursion_inorder(node.left)
print(node.elem,end=' , ')
... |
8f87b699dbbca585d0437251a0ed5b7d45147f7d | rkantamneni/CS550-FallTerm | /hw_assignments:class_notes/class926.py | 646 | 3.875 | 4 |
import sys
import random
for x in range(1):
orig=random.randint(1,10)
again='y'
while again=='y':
num = int(input('Write a number between 1 and 10: '))
if num==orig:
print('You guessed correct')
else:
print('You guessed incorrect')
if num>orig:
print('Too high')
elif num<orig:
print('Too low')
aga... |
b95232d64e40dd0b888ed16755553a86556fa19e | carolinegbowski/exercises_day_1 | /08-sum-of-divisors.py | 333 | 3.640625 | 4 |
def divisor_data(num):
data = []
divisors = [divisor for divisor in range(1,(num + 1)) if (num % divisor == 0)]
data.append(divisors)
sum_of_divisors = sum(divisors)
data.append(sum_of_divisors)
number_of_divisors = len(divisors)
data.append(number_of_divisors)
return data
print(diviso... |
7d2fcf6dab55913a82951cc6aa29802481865315 | vikinglion/Python | /python_work/valid_parentheses.py | 682 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding=utf-8 -*-
SYMBOLS = {')': '(',}
SYMBOLS_L, SYMBOLS_R = SYMBOLS.values(), SYMBOLS.keys()
def check(s):
arr = []
for c in s:
if c in SYMBOLS_L:
# 左符号入栈
arr.append(c)
elif c in SYMBOLS_R:
# 右符号要么出栈,要么匹配失败
... |
ef202ab8f94cbdfc846e7707834373cd9d2d73c3 | adamfitzhugh/python | /kirk-byers/Scripts/Week 7/exercise3b.py | 889 | 4.0625 | 4 | """
Expand the data structure defined earlier in exercise3a. This time you should have an 'interfaces'
key that refers to a dictionary.
Use Python to read in this YAML data structure and print this to the screen.
The output of your Python script should look as follows (in other words, your YAML data structure
shou... |
1878bd997f5dbb47bfcca12604392d00d5cbb688 | mkyu0917/pystudy | /quiz/quiz01_3.py | 706 | 3.765625 | 4 | students = [
{
"name": "kim",
"kor" : 80,
"kor" : 90,
"math" : 80
},
{
"name": "Lee",
"kor" : 90,
"kor" : 85,
"math" : 85
}
]
score = dict()
print(score)
av... |
2dd9904e49dc6509fe5ae4ae0e3687d9ae9038b9 | gbpaixao/FamousProblems | /Graphs/Prim/prim_heap.py | 1,966 | 3.90625 | 4 | # Prim algorithm
# The strategy of using heap was to add tuples of (edge_weight, x_position, y_position) in order
# to collect the edge with mininum weight at each iteration
# input where n is weight of each edge
# 0,2,1,0,0
# 2,0,1,2,3
# 1,1,0,0,4
# 0,2,0,0,2
# 0,3,4,2,0
from heapq import heappop, heappush
import ra... |
43d404cf60504c9cdaed69a9651b1982f2a5b295 | hawkinmogen/Python-CheckiO-Problems | /Convert to Roman Numerals/convert2RomanNums.py | 613 | 3.859375 | 4 | # Link to my solution on CheckiO:
# https://py.checkio.org/mission/roman-numerals/publications/hawkinmogen/python-3/first/share/7e771838405cfd368ffb68b6f0e16292/
def checkio(data):
result=""
NUMERALS=(('M',1000),('CM',900),('D',500),('CD',400),('C',100),('XC',90),
('L',50),('XL',40),('X',10),('IX... |
820d6b68f60f7ee454b1b97a2152eb1a769d10c9 | Akshat1276NSP/CBJRWDhome_assignment | /Python revision full course/8.py | 225 | 3.796875 | 4 | story = "asd qwe rty uio pas dfg hjk lzx cvb nm asdiha piqwjeo jakjsscmbd"
#string functions
print(len(story))
print(story.endswith("UUUUUUUUUUUUUU"))
print(story.count("a"))
print(story.capitalize)
print(story.find("Har"))
|
d349ca11d405495089fc3faa52d6b41408ecfded | PilarPinto/holbertonschool-higher_level_programming | /0x03-python-data_structures/1-element_at.py | 242 | 3.5 | 4 | #!/usr/bin/python3
def element_at(my_list, idx):
if idx < 0:
return (None)
if idx > len(my_list):
return (None)
for number in range(0, len(my_list)):
if (number == idx):
return(my_list[number])
|
0dcde054b1b28afb53ad264ccb1d925e2fba5462 | gameboy1024/ProjectEuler | /src/problem_77.py | 925 | 3.671875 | 4 | # -*- coding: utf-8 -*-
'''
Prime summations
Problem 77
It is possible to write ten as the sum of primes in exactly five different
ways:
7 + 3
5 + 5
5 + 3 + 2
3 + 3 + 2 + 2
2 + 2 + 2 + 2 + 2
What is the first value which can be written as the sum of primes in over five
thousand different ways?
... |
ad7bda035e84700fb77bc7bb16cfda78089aeb21 | bellatrixdatacommunity/data-structure-and-algorithms | /leetcode/linked-list/remove-linked-list-elements.py | 1,620 | 3.84375 | 4 | '''
203. [Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements/)
Remove all elements from a linked list of integers that have value val.
Example:
Input: 1->2->6->3->4->5->6, val = 6
Output: 1->2->3->4->5
'''
# Solution
# Definition for singly-linked list.
# class ListNode:
# ... |
3f1fb96b6cc36f251c4499098079362c0aa4b1fb | rain-zhao/leetcode | /py/Task238.py | 1,610 | 3.515625 | 4 | # 给你一个长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积。
#
# 示例:
# 输入: [1,2,3,4]
# 输出: [24,12,8,6]
#
# 提示:题目数据保证数组之中任意元素的全部前缀元素和后缀(甚至是整个数组)的乘积都在 32 位整数范围内。
# 说明: 请不要使用除法,且在 O(n) 时间复杂度内完成此题。
# 进阶:
# 你可以在常数空间复杂度内完成这个题目吗?( 出于对空间复杂度分析的目的,输出数组不被视为额外空间。)
from typing import List
c... |
f0f05ac675cf03380a7ed79a441e942d5101dc6d | ai-times/infinitybook_python | /chap12_p244_code1.py | 252 | 3.578125 | 4 | n = int(input("어떤 수를 판별해줄까요? "))
success = True
t=2
while t<n :
if n%t == 0 :
success = False
break
t += 1
if success == True :
print("소수 입니다.")
else :
print("소수가 아닙니다.")
|
0db9989084c71d6b718536820a9403ea783947ba | DarrenGibson/Python-Udemy-Course | /falseevaluations.py | 683 | 3.59375 | 4 | #=================================================================#
# false evaluations
#-----------------------------------------------------------------#
'''
Date : Tue 14 Aug 2018 04:02:21 PM PDT
Author : Darren Gibson
Title : Python Udemy Course
Resources : https://www.udemy.com/python-the-complete-pyt... |
b64ee0acc25c260a83feb941d750f075e60812c8 | purujeet/internbatch | /grat4.py | 278 | 4.1875 | 4 | w=int(input('w:'))
x=int(input('X:'))
y=int(input('y:'))
z=int(input('z:'))
if w>=x and w>=y and w>=z:
print('w is greater')
elif x>=w and x>=y and x>=z:
print('x is greater')
elif y>=w and y>=x and y>=z:
print('y is greater')
else:
print('z is greater')
|
b9833255433dc4712d348e7ab89b3235381ecf55 | mjip/Decoding-Running-Key-Ciphers | /code/FinalProject.py | 28,895 | 3.546875 | 4 | #!/usr/bin/python3
import random
import sys
import time
import string
import re
import argparse
from math import inf
from math import log
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import MultinomialNB
from sklearn.svm import LinearSVC
def accuracy(correct, guess... |
62faa56ee8c2d7916a03b304a1351da410594347 | eldanielh31/FiguritasTurtle | /Figuras/Pentagono.py | 389 | 3.703125 | 4 | from turtle import Turtle
class Pentagono:
def __init__(self, lado):
self.lado = lado
def getLado(self):
return self.lado
def setLado(self, nuevoLado):
self.lado = nuevoLado
def construir(self, tortuga):
for _ in range(5):
tortuga.pencolor("yellow")
... |
58e444e06552672f0b021fd573532350d906332b | D-cyber680/100_Days_Of_Code_Python | /NATO+Phonetic+Alphabet+for+the+Code+Exercise/main.py | 647 | 4.25 | 4 | # Keyword Method with iterrows()
# {new_key:new_value for (index, row) in df.iterrows()}
import pandas
data = pandas.read_csv("nato_phonetic_alphabet.csv")
#TODO 1. Create a dictionary in this format:
phonetic_dict = {row.letter: row.code for (index, row) in data.iterrows()}
print(phonetic_dict)
#TODO 2. Create a li... |
4617e499f9a78bdbb6bdb53d689670d7baa9a1ba | iscorgis/GH_BK_Exercises_PY | /POO/Kata_4.py | 1,310 | 3.546875 | 4 |
class Animal():
#Properties
__especie = ''
__peso = 0
__altura = 0.0
#methods
def __init__(self,especie,peso,altura):
self.__especie = especie
self.__peso = peso
self.__altura = altura
#getters / setters
#Investigar decoradores
def get_especie(self):
... |
9dfdc5b761da0dbf85be87240836f6ff58fcd573 | ajwwlswotjd/2020_python_class | /ex8.py | 497 | 3.71875 | 4 |
# 구구단 게임[2단계]
# 1. 구구단 문제를 출제하기 위해, 숫자 2개를 랜덤하게 저장한다.
# 2. 저장된 숫자를 토대로 구구단 문제를 출력한다.
# 예) 3 x 7 = ?
# 3. 문제에 해당하는 정답을 입력받는다.
# 4. 정답을 비교 "정답" 또는 "땡"을 출력한다.
import random as rnd
num1 = rnd.randint(1,9)
num2 = rnd.randint(1,9)
if int(input("%d x %d = ? : " % (num1,num2))) == num1 * num2 :
print("정답")
else :
p... |
bff98681a315080fbad6f15850919540c3d2921d | malachyo/BFS | /uniqueinorder.py | 598 | 3.859375 | 4 | # def unique_in_order(sequence):
# pos = 0
# newstr = ""
# for x in sequence:
# pos += 1
# x = pos
# if x == pos-1:
# newstr = sequence.replace(x, "")
#
# print(newstr)
#
#
# unique_in_order('AAABCBDBAABDBDCC')
def unique_in_order(sequence):
sequence = " ".join... |
ff33ee4666ea407b79984cbdf73248c8bdf2343d | DongliangGao/DoubanMovieSpider | /douban/mysql.py | 1,828 | 3.515625 | 4 | # -*- coding:utf-8 -*-
import MySQLdb
class MySQL:
'''
数据库操作:连接、建表、插入数据
'''
def __init__(self):
try:
self.db = MySQLdb.connect('localhost', 'root', 'password', 'douban', charset = 'utf8')
try:
self.cur = self.db.cursor()
except MySQLdb.Error... |
d46abce1ecd81fa8ae33512baa111758db16b3e7 | hello-wangjj/Introduction-to-Programming-Using-Python | /chapter10/10.18.py | 958 | 3.765625 | 4 | def main():
queens=8*[-1]
queens[0]=0
k=1
while k>=0 and k <=7:
# Find a position to place a queen in the kth row
j = findPosition(k,queens)
if j < 0:
queens[k] = -1
k -= 1 # back track to the previous row
else:
queens[k] = j
k += 1
printResult(queens)
def findPosition(k,queens):
start=... |
9177ad9cb2ef06f9b520edd715f000185b15be5a | FruitSenpai/Genesis | /GenesisProgram/Scripts/Graph/admix/AdmixGroup.py | 926 | 3.84375 | 4 | class AdmixGroup:
"""Stores Group attributes as well as all individuals belonging to the group."""
name = ""
orderInGraph = 0
dominance = 1
def __init__(self, name, order):
"""Initializes an AdmixGroup object along with its properties."""
self.name = name
self.orderInGraph = order
self.dominance = 1 #init... |
f6a4164191417772d3f382dc19774a1334e2df02 | Ishaangg/python-projects | /radius_of_circle.py | 101 | 3.75 | 4 |
radius = 20
area = radius * radius * 3.142
print("the area of circle of radius", radius, "is", area) |
98c6216fec9a4e06a88210d5c376708d0f6b124f | techmexdev/Networking | /udp_server.py | 674 | 3.5 | 4 | from socket import *
server_port = 3000
# create UDP socket
server_socket = socket(AF_INET, SOCK_DGRAM)
# bind socket to local port
server_socket.bind(('localhost', server_port))
print(f'UDP server ready on port {server_port}... ')
while True:
# read from UDP socket we just created
# 4096 is reccomended bu... |
2de1c25685595bd71474cd33ec96024fa07fa572 | nisarbasha/pythonClass | /Day1/math_class.py | 486 | 3.5625 | 4 | import math
x = abs(-7.25)
print(x)
print("***************")
x = pow(5, 3)
print(x)
print("***************")
x = math.sqrt(49)
print(x)
print("***************")
x = math.ceil(1.8)
y = math.floor(1.4)
print(x)
print(y)
print("***************")
x = math.pi
print(x)
print("***************")
print(math.isclose(50,... |
2ac6b46be7824d70a827399b7f2e6ad7f5f69c08 | cebarrales/quartic_rxn | /test.py | 1,427 | 3.703125 | 4 | #!/usr/bin/python3
'''
This module calls the quartic_rxn function that found the
optimized coefficient of the equation a*x**4 + b*x**3 + c*x**2.
It requires the activation energy and the reaction energy of the
chemical reaction.
Example
-------
Consider a reaction which has an activat... |
30205406b140cd4504f698014acc58a3272e2f00 | callmexss/Python_Crash_Course | /Chapter4/times_of_3.py | 241 | 3.546875 | 4 | # -*- coding: utf-8 -*-
# @Author: callmexss
# @Date: 2018-06-01 00:25:02
# @Last Modified by: callmexss
# @Last Modified time: 2018-06-01 00:25:47
numbers = [n for n in range(3, 31, 3)]
for number in numbers:
print(number) |
690c6c92d4831ef103d775da2b3c8809983b1393 | Ferosima/Python_Lab | /5-Laba/3.py | 12,355 | 3.8125 | 4 | # 12. Вивести значення цілочисельного виразу, заданого у вигляді рядка S. Вираз визначається наступним чином:
# <Вираз> :: = <цифра> | <Вираз> + <цифра> | <Вираз> - <цифра>
# получился прикольный калькулятор, который может строить деревья
from tkinter import *
root = Tk()
w, h = 800, 800
canv = Canvas(root, width=w, h... |
e6389ecd5757d8a0e31712b93044ba54038f8527 | LiuY-ang/leetCode-Medium | /addTwoNumber.py | 941 | 3.65625 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
p1,p2... |
ebbc23f2fa8882c9aeed4180a09fd7e6b0a8fcef | mikwit/adventofcode | /mikwit/all_2019/day1/numberadder.py | 544 | 3.8125 | 4 |
def file_summator(input_file="", current_number=0):
in_file = open(input_file, "r")
total = current_number
for line in in_file:
total += int(line)
return(total)
# input_file = open("input.txt", "r")
# # print(input_file.read())
# # for line in input_file.read():
# # print (li... |
c9b1f744ac5d3c0904e40d278ceddd9a399159e0 | JozeeLin/learn-AI | /deep-learning-nn/nn/AddLayer.py | 1,140 | 3.65625 | 4 | from MulLayer import MulLayer
class AddLayer(object):
def forward(self, x,y):
out = x+y
return out
def backward(self, dout):
dx = dout * 1
dy = dout * 1
return (dx, dy)
if __name__ == '__main__':
apple = 100
apple_num = 2
orange = 150
orange_num = 3
... |
23738de02206fa48b61549f11cfeefb8fbf4b713 | M01eg/gb_python_basics | /homework2/task2.py | 1,042 | 4.4375 | 4 | '''
Урок 2
Задание 2
Для списка реализовать обмен значений соседних элементов,
т.е. Значениями обмениваются элементы с индексами 0 и 1,
2 и 3 и т.д. При нечетном количестве элементов последний
сохранить на своем месте. Для заполнения списка элементов
необходимо использовать функцию input().
'''
def task2():
supe... |
ce82e84ed062cf7f69e117e065d479496847fa08 | ES2Spring2019-ComputinginEngineering/final-project-final-megabrett | /EnergyandPopulationData.py | 1,740 | 3.5 | 4 | # Getting Energy Usage/Person
import matplotlib.pyplot as plt
def createEnergyandCityLists():
cities = []
city_energy = []
pop = []
energy_per_person = []
file = open("Monthly-Electricity-Consumption-for-Major-US-Cities.csv")
split_character = ','
for line in file:
data_line = line.... |
e6c77231dc9e30066fb48dceae1f625eca6d8077 | conwayjj/AdventOfCode2020 | /day2/day2_2.py | 622 | 3.75 | 4 |
def validatePassword(password):
words = password.split()
lower, upper = words[0].split('-')
lower = int(lower)
upper = int(upper)
character = words[1][0]
pw = words[2]
if (pw[lower-1] == character) ^ (pw[upper-1] == character):
return True
else:
return False
with open("""C:\\tmp\\adventCo... |
740f57265dfb7da255f81c2e133bb128664c021a | liseyko/CtCI | /leetcode/p0073 - Set Matrix Zeroes.py | 2,253 | 3.5 | 4 | class Solution:
def setZeroes(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
if not matrix: return
m, n = len(matrix), len(matrix[0])
rows, cols = set(), set()
for ... |
66e931c63e3981bc905e98763d22b20489038bcf | zzz686970/leetcode-2018 | /476_findComplement.py | 158 | 3.578125 | 4 | def findComplement(num):
result = "".join(["1" if char=='0' else "0" for char in str('{0:b}'.format(num))])
return int(result, 2)
print(findComplement(5))
|
71dabf4442d9d2ec64b93e56318a25937bfeef8f | gloria-aprilia/Programming-Practice | /Python/Algorithm Practice/E6_ListTuple.py | 120 | 3.578125 | 4 | data = input("Please enter a set of number(, to separate): ")
print(list(data.split(",")))
print(tuple(data.split(","))) |
9ed00b9b8e991c345f0c69635da3df7695141d2c | uohzxela/fundamentals | /sorting/sort_list.py | 1,061 | 3.921875 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def sortList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head or not head.next:
... |
417619e07c467dcbe6ba12ce794441aeb86aafd1 | pranaymate/pythonExercises-1 | /easy/housePassword.py | 962 | 4.0625 | 4 | # The password will be considered strong enough
# if its length is greater than or equal to 10 symbols,
# it has at least one digit,
# as well as containing one uppercase letter and one lowercase letter in it.
# The password contains only ASCII latin letters or digits.
def password_validator(data):
if len(data) >... |
4120ab747229be6cf1b73fbd66acfc1eebee5a9d | gabrieltemtsen/My-First-Github-Project | /My first Github Program.py | 2,035 | 4.15625 | 4 | def gpa():
courses = int(input("How many courses have you offered so far:"))
course_limit = 0
wgp = 0
total_credit = 0
for numbers in range(course_limit, courses):
print ("Enter score for course ", numbers+1)
score = int(input())
print("Enter Credit Unit for course:... |
0dbf71b6b636441d19bf294a4cc28b9f45647228 | Sandr0x00/algorithms | /hilbert_curve/__init__.py | 928 | 3.53125 | 4 | #!/usr/bin/env python3
class HilbertCurve:
def __init__(self, n):
self.n = n
# convert (x,y) to d
def xy2d (self, x, y):
s = self.n // 2
d = 0
while s > 0:
rx = (x & s) > 0
ry = (y & s) > 0
d += s * s * ((3 * rx) ^ ry)
x, y =... |
32ff6068d538d9b5f124f31ba619a85a43fe8d9b | anurpa/bioinformatics_scripts | /adaptor_finder.py | 1,528 | 3.796875 | 4 | #import required modules
from Bio import SeqIO
import argparse
#Define a function to count frequencies of substrings in a FASTQ file
def find_adaptors(args):
"""
Get frequencies of substrings of length k across all sequences in a
fastq file(f).
Args:
f: FASTQ file
k: length of su... |
66e70a0f6d81628973c082f97258ac829c2e3baf | nmasamba/learningPython | /22_dict.py | 776 | 4.5625 | 5 |
"""
Author: Nyasha Pride Masamba
Based on the lessons from Codecademy at https://www.codecademy.com/learn/python
This Python program shows an example of using the dictionary (dict) data structure.
It is useful to think of dictionaries as key:value pairs, so in that sense a dict
record can be indexed by its key. The... |
0f6d8b9be2d07d8f03b5c1fa946a1debf97b003a | ezioitachi/Big-Data | /Coursera-Algorithms&Data/AlgorithmicToolbox/week2/fibonacci_last_digit.py | 210 | 3.578125 | 4 | # Uses python3
n = int(input())
def Fibo(n):
F = [None]*(n+2)
F[0] = 0
F[1] = 1
if n <=1:
return F[n]
else:
for i in range(2,n+1):
F[i] = (F[i-1] + F[i-2]) % 10
return F[n]
print(Fibo(n))
|
7a982d495a0e21a0bbdb83b7c6586c36b875504f | yunzhuz/code-offer | /second/23.py | 1,698 | 3.53125 | 4 | class node():
def __init__(self,data):
self.data = data
self.next = None
def xunzhao(head):
if not head.next or not head.next.next:
return None
meetingnode = panduan(head)
if meetingnode == None:
return None
pcount = meetingnode.next
count = 1
while pcount !=... |
22e06236be3cba4637cba74806c11581f1de5d8c | radhikaluvani/repo | /daily-programs/20200823/list.py | 123 | 3.640625 | 4 | a = [1,5,7,8,10,12,23,25,60,89]
b = int(input("enter number: "))
c = []
for i in a:
if i < b:
c.append(i)
print(c) |
80cd0654162b9d29d3ed43ee3829ff31449b1bb5 | timManas/PythonProgrammingRecipes | /project/src/ObjectOrientedConcepts/ChangingClassMembersExample/ChangingClassMembersExample.py | 1,500 | 3.5625 | 4 | # from project.src.ObjectOrientedConcepts.ChangingClassMembersExample.CSStudent import * # This works
from project.src.ObjectOrientedConcepts.ChangingClassMembersExample import CSStudent # This doesent work ?
def main():
student1 = CSStudent("Tim", 12345)
student2 = CSStudent("John", 346)
student3 = ... |
e0c6493f0d3602baa8e812108f88d786829a3324 | brantheman60/Old-Python-Projects | /Pyzo/15-112/Week 4/Sorting Algorithms.py | 2,632 | 4.3125 | 4 | # https://www.cs.cmu.edu/~adamchik/15-121/lectures/Sorting%20Algorithms/sorting.html
import random, time
def bubbleSort(arr): # compares adjacent elements
for i in reversed(range(0, len(arr))):
for j in range(1,i+1):
if arr[j-1] > arr[j]:
temp = arr[j-1]
arr[j-1... |
0599927cfb7aa1db9b996f4d09935e07eedc43b4 | NJT145/my_github_repository_Python | /PyCharm_Projects/CS_372_01/Lecture_codes/code_week4/graph2.py | 1,737 | 3.859375 | 4 | class Node:
def __init__(self, label):
self.label=label
self.neighbors=[]
def __str__(self):
temp_str=str(self.label) + ": "
for node in self.neighbors:
temp_str+=node.label + " "
return temp_str
def addNeighbor(self, node):
self.neig... |
438ddb8d0c98ed24f5ac2758a40a57e7023f1f5f | Wainhouse/DFESW3 | /w3_exercises.py | 2,467 | 4.21875 | 4 | # 1) Write a Python function to find the Max of three numbers.
# def max_of_two(x, y):
# if x > y:
# return x
# return y
# def max_of_three(x, y, z):
# return max_of_two(x, max_of_two(y, z))
# print(max_of_three(-5, 4, 8))
# 2)Write a Python function to sum all the numbers in a list.
# def su... |
df373658afcfffc5036a9c06a3e85cdab1ae4fce | DidiMilikina/DataCamp | /Machine Learning Scientist with Python/22. Machine Learning with PySpark/02. Classification/07. Evaluate the Decision Tree.py | 1,494 | 4.09375 | 4 | '''
Evaluate the Decision Tree
You can assess the quality of your model by evaluating how well it performs on the testing data. Because the model was not trained on these data, this represents an objective assessment of the model.
A confusion matrix gives a useful breakdown of predictions versus known values. It has f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.