blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
2a75684ce1ab551cc6ad4e4f64ed1029b48d0c33 | indigobuffalo/HackerRank-Python | /arrays/hourglasses_in_matrix.py | 1,129 | 3.65625 | 4 | """
https://www.hackerrank.com/challenges/2d-array
Given a 6 X 6 2D Array, A:
1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
we define an hourglass in A to be a subset of values with indices in this pattern:
a b c
d
e f g
There are hourglasses in A, and an hourglass sum is the sum of an... |
0205d034af59a4aeadb18ba8ff01bc03f4026180 | RedDirtBits/Wemos-LoLin32-Lite | /wifi.py | 1,239 | 3.6875 | 4 | import network
import utime
import config
wlan = network.WLAN(network.STA_IF)
def wifi_connect(ssid=config.SSID, passwd=config.WIFI_PASSWD):
"""
Connects to WiFi. Will attempt three times to connect. Uses the LEDs for visual
indication of network connection status. RED when disconnected, GREE... |
8fe048a8202dc5c70b44ada66177fb9402de9769 | daytonpe/car-evaluation-neural-net | /NeuralNet.py | 14,235 | 4.34375 | 4 | ####################################################################################################
# CS 6375.003 - Assignment 3, Neural Network Programming
# This is a starter code in Python 3.6 for a 2-hidden-layer neural network.
# You need to have numpy and pandas installed before running this code.
# Belo... |
831bf89c031dda402ce526765f57c33ec65be4e0 | ascott1043/selection_sort_fixed | /selection_sort_fixed.py | 5,824 | 4.75 | 5 | def multi_selection_sort_codebasics(arr, sort_by_list):
"""In this approach we sort the entire array by the last key in the array, and
then sort it again for each additional key we use in reverse order. So in our
example the array gets sorted by last name, and then again by first name.
That means if... |
250c9137d09691705324d755c429ee5d27ae1ee1 | mrdimemes/password_keeper | /SQLProcessor.py | 23,523 | 3.515625 | 4 | import datetime
import mysql.connector
from mysql.connector import Error
from mysql.connector import errorcode
class SQLProcessor():
'''
Class for interaction with MySQL server.
'''
def __init__(self, host_name, user_name, user_password, db_name):
self.connect_to_database(host_name, user... |
3a7899608a565e2b1ebfa3e4ec0d8692cf55c577 | DanielRopars/Intro_OOP | /point.py | 1,734 | 4.21875 | 4 | from math import sqrt
from math import abs
class Point:
x = 0.0
y = 0.0
def __init__(self, x, y):
self.x = x
self.y = y
def dist_to(self, p):
return sqrt((self.x - p.x)**2 + (self.y - p.y)**2)
def abs(self):
return sqrt(self.x**2 + self.y**2)
class Rectangle:
... |
c3385102449222f5299716e94c76148e97b635ef | KRBhavaniSankar/NLTK | /3.Processing&UnderstadingText/removing_stopwords.py | 1,229 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri APR 27 15:06
@author: Bhavani
"""
from nltk.tokenize import sent_tokenize,word_tokenize
from nltk.corpus import stopwords
import re
data = "All work and no play makes jack dull boy. All work and no play makes jack a dull boy."
words = word_tokenize(data)
#print(words)
stopWo... |
03af20ee792a52633089d58ba12ae2bf358910e4 | RoyGithubAccount/my_tensorflow | /mnist_nn.py | 3,533 | 3.859375 | 4 | """
Neural network that predicts what a hand written number of out of MNIST data set
The objective of this program is to understand how a NN is wired together and how it works
"""
#help the program to find the mnist data
import sys
sys.path.append('/tensorflow/lib/python3.5/site-packages/tensorflow/examples/tutorial... |
bd3828eb177b6591d3d9bc85004f3aea42238302 | desiredominique/adivinhacao_py | /adivinhacao.py | 1,835 | 3.90625 | 4 | import random
def jogo_adivinhacao():
print("---------------------------------")
print("Bem vindo ao Jogo de Adivinhação!")
print("---------------------------------")
numero_secreto = round(random.randrange(1,101))
total_de_tentativas = 0 #esse numero é só o valor de inicialização, não s... |
933b9416c03a8c4f655f821e96d1a92a88f834a0 | Jyotika999/STEPS-AND-SNAKES | /BASICS OF MAKING GAMES USING PYTHON DEVELOPMENT/Tut5 # USE OF KEYBOARD IN HANDLING THE EVENTS.py | 666 | 4.0625 | 4 | ## In this tutorial , we will learn about handling the events and the use of arrows in controlling these stuffs
import pygame
pygame.init()
# Creating window
gameWindow = pygame.display.set_mode((1200, 500))
pygame.display.set_caption("My First Game - Blank")
# Game specific variables
exit_game = False
game_over = ... |
55243a0b37e2fc2e93c9cec7a0e4553a4e59f94d | AnggaBudi100/Angga-Budi-Irawan-171011400039 | /Angga_Budi_Irawan_171011400039.py | 1,223 | 3.625 | 4 | import numpy as np
import sklearn
import matplotlib.pyplot as plt
import pandas as pd
# Memanggil dataset
dataset = pd.read_csv('Salary.csv')
#Sumbu X adalah Lama Trading dan Sumbu Y adalah Akurasi
X = datasets.iloc[:, :-1].values
Y = datasets.iloc[:, 1].values
# Melakukan Splitting dataset pada Traini... |
02b2e9d7691af1b8c943e52eb78d2e0ce541a3e2 | SaraAlhaddadi/triangles-and-shapes | /inverse_triangle.py | 264 | 3.859375 | 4 | # Prepared by : Shvm-k
#program to print like this
'''
12345
1234
123
12
1
'''
for i in range(5,0,-1):
for j in range(5,0,-1):
if(i==j):
for s in range(1,6):
if (s<=i):
print(s,end="")
else:
print(" ",end="")
print("") |
d267b1a419e8d9fa0b0f012999d3b7a3b2d58bf1 | wezham/sec-tools | /EmailPermutor/email_permutor.py | 1,343 | 3.578125 | 4 | class EmailPermutor:
def __init__(self, name, company_name):
self.name = name;
self.company_name = "@" + company_name;
self.emails = []
self.permute_over_names()
self.print_emails()
def permute_over_names(self):
split_names = self.name.split(' ')
try:
... |
db4c0ffed3f944393f245cfb18da5f1f37a4f589 | TheAshpak/Projects_For_Learning | /Machine_Learning/Naive_Bayes/Naive_bayes_car.py | 2,188 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jun 5 20:30:21 2021
@author: theas
"""
import pandas as pd
import numpy as np
#importing data set
car=pd.read_csv("D:/DataScience/Class/assignment working/Naive Bayes/NB_Car_Ad.csv")
#checking data
car.head()
#checking null value
car.isna().sum()
#dro... |
df425b90bac476d42fca8895b8aee6e1f7598ca4 | TheAshpak/Projects_For_Learning | /Machine_Learning/Recommondation_System/rec_game.py | 1,614 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 27 14:18:42 2021
@author: theas
"""
#importing libraries required for data processing
import pandas as pd
import numpy as np
from sklearn.neighbors import NearestNeighbors
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("dark")
%matplotl... |
e9b34db6f896931957d9d37e3b4c6bff71d1de97 | TheAshpak/Projects_For_Learning | /Machine_Learning/Recommondation_System/rec_movie.py | 3,360 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 27 13:07:05 2021
@author: theas
"""
#importing require packages for manipulation of data
import pandas as pd
import numpy as np
#loading package to the pandas dataframe
movie=pd.read_csv("D:\DataScience\Class\Assignments\Recommondation system/Entertainment.csv... |
89e291692fcf541d1c1a2ca4c134a2d85b080a94 | Miaotaizhou/Rush | /algorithms/greedy.py | 1,775 | 4.09375 | 4 | #! usr/bin/python3
# *-* coding=UTF-8 *-*
__author__ = "Rush"
'''
假设小偷有一个背包,最多能装20公斤赃物,他闯入一户人家,发现如下表所示的物品。
很显然,他不能把所有物品都装进背包,所以必须确定拿走哪些物品,留下哪些物品。
价格(美元)={电脑:200, 收音机:20, 钟:175, 花瓶:50, 书:10, 油画:90}
重量(kg)={电脑:20, 收音机:4, 钟:10, 花瓶:2, 书:1, 油画:9}
最大重量20kg,物品数量6件
在对问题求解时,总是做出在当前看来是最好的选择,不追求最优解,快速找到满意解
'''
cl... |
bda6e9d4620e10a2d2b8e317ca1c547693f98008 | danielherfurth/python-challenge | /PyBank/main.py | 1,991 | 3.75 | 4 |
# doing it without csv module for the fun of it
from statistics import mean
import os
def val_sort(list_to_sort):
"""
Args:
list_to_sort: a list of lists to be sorted by the second value in each list.
Returns:
a list sorted by the second value in each sublist.
"""
list_to_sort.so... |
4e5fd6d4174f9bc1a55a1f0d784afbff50cc70db | rhythmehta/hire-assistant-problem | /the hire-assistant problem.py | 6,914 | 4.21875 | 4 | #!/usr/bin/env python
# coding: utf-8
# ## The Hire-Assistant Problem.
#
# Imagine that you need to hire a new assistant. Every day an agency sends a new assistant for you to interview. If the assistant is better than your current assistant, then you fire your current assistant and you hire the better assistant. You ... |
58a4eb233b26b13f6dd980dfec6a8c54183a9326 | k018c1072/Paiza_Python | /Monster_evolution.py | 506 | 3.53125 | 4 | Current = [int(i) for i in input().split()]
N = int(input())
Evolution = [[i for i in input().split()] for j in range(N)]
Evolved_monster = []
for i in Evolution:
if Current[0] >= int(i[1]) and int(i[2]) >= Current[0]:
if Current[1] >= int(i[3]) and int(i[4]) >= Current[1]:
if Current[2] >= in... |
5ac1ef9d3d82d6addf2b24ed3f6d4ffd12a5ef8c | k018c1072/Paiza_Python | /Pyramid.py | 71 | 3.5 | 4 | N = int(input())
p = 0
for i in range(1, N + 1):
p += i
print(p)
|
7b32ff7e71a8f04733d2a147acb4fb416e0af1b3 | arnoringi/forritun | /Assignment 7 (Functions)/7_5) Palindrome.py | 679 | 4.375 | 4 | # palindrome function definition goes here
def palindrome(string):
SPECIAL = """ .,:;?!_-"'()"""
is_true = False
for char in string:
for digits in SPECIAL:
if char == digits:
string = string.replace(char, "")
for char in string:
if char == char.upper():
... |
45e0900defbc2e4cf58aae6932026d6a4036f8dc | arnoringi/forritun | /Assignment 10 (Lists)/10_2) Unique letters.py | 428 | 4.09375 | 4 | import string
# Implement a function here
def list_letters(sentence):
my_list = []
for char in sentence:
if char.isalpha() and char not in my_list:
my_list.append(char)
else:
continue
return my_list
# Main starts here
sentence = input("Input a sentence: "... |
4467807cc4866cccbf6798214eeffc795ac501d2 | arnoringi/forritun | /Assignment Questions (Other)/prime.py | 275 | 4.09375 | 4 | n = int(input("Input a natural number: ")) # Do not change this line
# Fill in the missing code below
if n > 1:
for i in range (2, n):
if (n % i) == 0:
print("Not Prime")
break
else:
print("Prime")
else:
print("Not Prime") |
3201bacd9f61ca6b0972cb7395de87e8bbd773da | arnoringi/forritun | /Final exam (2019)/distribution.py | 2,433 | 3.59375 | 4 | class Distribution:
def __init__(self, file_stream='', distribution=''):
''' Create a dict of numbers upon creation'''
self.a_dict = {}
if file_stream != '':
for line in file_stream:
line.strip().split()
for number in line:
if ... |
538d7207323d38171535504789eca16f52c1b2e5 | arnoringi/forritun | /Assignment 6 (Strings)/6_6) First initial and lastname.py | 295 | 4.0625 | 4 | name = input("Input a name: ")
lastname, first_name = name.split()
#Til að eyða kommunni
for char in lastname:
if char == ',':
lastname = lastname.replace(char, "")
first_inital = first_name[0].capitalize()
lastname = lastname.capitalize()
print(first_inital + ". " + lastname) |
c8bd3e83ea448eec687d026bbf71d343bbcede9a | arnoringi/forritun | /Assignment 12 (More on functions)/12_4) Check for consecutive values.py | 801 | 4.09375 | 4 | def is_valid(input_list):
try:
for digit in input_list:
int(digit)
check = int(input("Consecutive check: "))
return check
except ValueError:
return None
def consecutive_check(check, input_list):
value = False
previous_int = 0
current_int = 0
for num... |
23dd995a5208cdce1e01cbb45441a4c71eb08895 | arnoringi/forritun | /Assignment 5 (Algorithms and git)/5_2) Sequence.py | 400 | 4.03125 | 4 | #1 Generates the first n numbers in a sequence
#2 We add the three most recent numbers together, n amount of times
#3 1, 2, 3, 6, 11, 20, 37, ___, ___, ___, …
#4 1, +1, +1, +3, +5, +9, +17
n = int(input("Enter the length of the sequence: ")) # Do not change this line
num1 = 1
num2 = 1
num3 = 0
for i in range(n):... |
587e220a18e8874586013a5ef7b82790ef2b471e | arnoringi/forritun | /Assignment 14 (Dictionaries)/14_1) Name and number.py | 553 | 4.125 | 4 | def add_to_dict(number, name, my_dict):
my_dict[name] = number
return my_dict
# Main program starts here
my_dict = {}
while True:
name = input("Name: ").strip()
number = input("Number: ").strip()
my_dict = add_to_dict(number, name, my_dict)
more_data = input("More data (y/n)? ").lower()
i... |
ea1eeffbf41cf98defbe9a9c6150739499db3dc0 | arnoringi/forritun | /Assignment 7 (Functions)/7_6) Date check.py | 1,641 | 3.890625 | 4 | def valid_date(date):
is_true = False
conditions = 0 #The conditions must reach 5 for the date to become valid
count = 0
#Condition 0 (Intiger check)
for turn in range(8):
if turn == 2 or turn == 5:
pass
elif date[turn].isdigit():
count += 1
if c... |
91bba554ed61e42b663a3c1c392fe723b7fe77b5 | arnoringi/forritun | /Assignment 6 (Strings)/6_2) Slicing.py | 95 | 3.890625 | 4 | a_str = input("Input a string: ")
# your code here
b_str = a_str[-2:] + a_str[:-2]
print(b_str) |
a9f47d458efa303e3049bd787b17b9dbe2462e32 | arnoringi/forritun | /Assignment 6 (Strings)/6_7) Intiger to binary.py | 389 | 3.984375 | 4 | my_int = int(input('Give me an int >= 0: '))
# Fill in the missing code
quotient = my_int
remainder = 0
bin_str = ''
for index in range(7): #8-bit binary
remainder = quotient % 2
quotient = quotient // 2
if remainder == 0:
bin_str = bin_str + '0'
else:
bin_str = bin_str + '1'
bin_str =... |
0b5457d7780de8a3bc86cb33e3b85ae766f8bef6 | arnoringi/forritun | /Assignment 19 (More on classes)/19_1) Natural number.py | 1,065 | 4.0625 | 4 | class NaturalNumber:
def __init__(self, number=0):
if number == str(number) or number < 0:
self.__num = None
else:
self.__num = number
def __str__(self):
return str(self.__num)
def __add__(self, other):
try:
number = self.__num + other.__... |
923f3255b6cd59942d89b14332abeda63991d6de | winstc/ListMaker | /file_handler.py | 2,762 | 3.765625 | 4 | #!/usr/bin/python3.5
# Written by Winston Cadwell
# file_handler classes used by List Maker to manipulate files
# these classes are used for all file actions in List Maker
# The CSVFile class contains files for csv file manipulation
# The XLSX class contains files for excel file manipulation
import csv # import csv l... |
7726128968b66ffc754265cf5b4881868a554600 | rossfraser81/Binary-Hexadecimal-Converter | /main.py | 1,373 | 4.1875 | 4 | print("Welcome to the Binary Hexadecimal Converter App")
#user input for max value and create lists
max_value = int(input("\nWhat is the maximum binary and hexadecimal value you would like to compute: "))
decimals = list(range(1,max_value+1))
bnry = []
hexa = []
for num in decimals:
bnry.append(bin(num))
hexa.ap... |
97e7c67ac5443130a6a4e55f8cbe583b255724fe | atulgolhar/python | /iteratingOverDict.py | 404 | 3.578125 | 4 | #iteratingOverDict.py
>>> d
{'x': 1, 'y': 2, 'z': 3, 'a': 4, 'b': 5, 'c': 6, 'd': 7}
>>> for yyy in d.items():
print(yyy)
('x', 1)
('y', 2)
('z', 3)
('a', 4)
('b', 5)
('c', 6)
('d', 7)
>>> for zzz in d.keys():
print(zzz)
x
y
z
a
b
c
d
>>>
>>> for xxx in d.values():
print(xxx)
1
2
3
4
5
6
7
>>> ... |
e796f01936fba6b9bf1c5dfcc4eae9fe8bab4d61 | atulgolhar/python | /fibonacciDynamic.py | 212 | 4.15625 | 4 | #!/usr/bin/env python3
# fibonacciDynamic.py
fibs = [0,1]
num = int(input('How many Fibonacci numbers do you want? '))
for i in range(num-2):
fibs.append(fibs[-2] + fibs[-1])
print(fibs)
print(len(fibs))
|
5a1766ef02fcd16085a373318b11b39340f61656 | atulgolhar/python | /classCreation.py | 462 | 3.875 | 4 | # Create your own basic class
# classCreation.py
>>> class Person:
def set_name(self, name):
self.name = name
def get_name(self):
return self.name
def greet(self):
print('Hello world, I am {}'.format(self.name))
>>> foo = Person()
>>> bar = Person()
>>> foo.set_name('Luke Skywalker')
>>> bar.set_name('Ana... |
7efda8a60877eed58a1d71682ebdff7b37027f69 | atulgolhar/python | /exceptionsClausev2.py | 2,098 | 4.125 | 4 | # exceptionsClausev2.py
# So now I added more than one except clause:
>>>
>>> def CatchingExceptionsCodeBlock():
try:
x = int(input('Enter the 1st number: '))
y = int(input('Enter the 2nd number: '))
print(x/y)
print('Happy New Year! This works.') ... |
13fdbbb64881082b3317bb9f0765d3d3cd1688e6 | atulgolhar/python | /fibonacci.py | 387 | 3.890625 | 4 | #!/usr/bin/env python3
#fibonacci.py
#multiple methods to execute fibonacci (interpreter vs command line)
def fib1(n):
a, b = 0, 1
while b < n:
print(b, end=' ')
a, b = b, a+b
print()
def fib2(n):
result = []
a, b = 0, 1
while b < n:
result.append(b)
a, b = b, a+b
print()
return result... |
86d0319e0289a56c4359747fc7709b995521c19a | atulgolhar/python | /exceptionsClausev1.py | 721 | 3.921875 | 4 | # exceptionsClausev1.py
# use Python shell
>>> try:
x = int(input('Enter the first number:'))
y = int(input('Enter the second number:'))
print(x/y)
except ZeroDivisionError:
print("No way Jose")
Enter the first number:4
Enter the second number:7
0.5714285714285714
>>> def tryError:
SyntaxError: invalid synt... |
44c725b2f1162b8ca123c5f541247c9d9a72ce46 | nghia71/mcc-tools | /test_run.py | 3,302 | 3.71875 | 4 | from math import ceil, sqrt
from random import choice, shuffle
import sys
from mcc_api import Pegasus
#
# Determine if a number is a prime by looking at the remainder
# when divided the number by all integers
# between 2 and the number's square root
#
def is_prime(number):
for i in range(2, ceil(sqrt(number)+1)):... |
014b340695b0098105c39b6205aadce03a6a14f0 | aveirinha/210CT-Coursework | /week3_ex1_basic.py | 926 | 4.34375 | 4 | #Time Complexity: O(n)
import string
def mirrorWords( word_list, word_list_rev):
"""This function recieves a list of words
and prints every word on the list in
reversed order and returns them in a new """
if len(word_list) == 0:
words_rev = ' '.join(word_list_rev)
print(words... |
83e3fa11ef0a87f68cee7974b607278f67d838fa | aquaruiz/Python-Primer | /Computing_with_formulas/1liter.py | 641 | 3.5625 | 4 | volume = 1 # 1 liter
volume = volume * 1000 # in cubic cm cm3
def read_densities(filename):
infile = open(filename, 'r')
densityes = {}
for line in infile:
words = line.split()
dens = float(words[-1])
if len(words[:-1]) == 2:
substance = words[0] + ' ' + words[1]
... |
f902cdde8877ace39cbc6cf0046d56a1ce970d94 | aquaruiz/Python-Primer | /Functions_and_branching/my_sum.py | 337 | 3.65625 | 4 | def my_sum(lis):
s = 0
for el in lis:
if type(el) == str:
s = ''
break
elif type(el) == list:
s = []
break
for el in lis:
s += el
return s
print(my_sum([1, 3, 5, -5]))
print(my_sum([[1, 2], [4, 3], [8, 1]]))
print(my_sum(['Hello... |
9c9937a85a5d730bab77606e41fa7df28af15467 | tinbaj/FileParser-Cloud | /ReadFile.py | 18,232 | 3.5 | 4 | # ReadFile.py
"""
This file contains class ReadFile which has functions to parse xml, csv and text files
"""
import operator
import os
import re
import xmltodict
import Packages
import itertools
from datetime import datetime
Logger = Packages.LoggerDetails()
log = Logger.setLogger()
class ReadFile:
def __init__... |
016aaf5c9fba0b71360161903ae20ff16611150b | felixichters/space-turmoil | /selfmade_tools/old/pixel_to_nt.py | 99 | 3.625 | 4 | y = int(input("y coord: "))
x = int(input("x coord: "))
addr = int(((y/8)*32)+x/8)
print(hex(addr)) |
a254c95a09705a1ca7d71387a32e2c05ef69ff64 | 3pacccccc/zhihu_spider | /zhihu_spider/zhihu_spider/function/common.py | 395 | 3.875 | 4 | # -*- coding:utf-8 -*-
__author__ = 'maruimin'
def str_to_int(text):
#将'12,545'字样的字符串转换为数字
int_dict = text.split(',') #将传进来的text split为一个dict
a = 0
b = len(int_dict)
for x in int_dict:
a = a + int(x)*1000**(b-1)
b = b-1
return a
if __name__ == '__main__':
str_to_... |
4144a7b2393888ca458c01eb5b1c8115320120ca | brianhenk/euler-python | /problem-3.py | 514 | 3.8125 | 4 | # The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?
import math
num = 600851475143
#num = 13195
orig_num = num
found = True
while found:
#print("Finding divisors of {0}".format(num))
found = False
for divisor in range(2, int(math.sqrt(num))):
if ... |
9515608174a1b8602b489f9a5ab9f02922b46075 | RybaPila-IT/Neural-Network | /network.py | 15,466 | 3.90625 | 4 | import numpy as np
import matplotlib.pyplot as plt
import json
import sys
class AccuracyMetric:
"""Class computing accuracy of predicted samples.
Accuracy is expressed as the ratio: correct_guesses / all_guesses.
"""
@staticmethod
def metric_value(x, y):
"""Metric computes ration of corr... |
e7809655e6b3c7519c2926378f90182a70bf6a73 | RafaelFerSilva/python3DoBasicoAoAvancado | /intermediario/12 - GroupBy.py | 866 | 3.578125 | 4 | from itertools import groupby, tee
alunos = [
{'nome': 'Luiz', 'nota': 'A'},
{'nome': 'Rafael', 'nota': 'B'},
{'nome': 'Denise', 'nota': 'C'},
{'nome': 'Marlene', 'nota': 'D'},
{'nome': 'Fatima', 'nota': 'A'},
{'nome': 'Monika', 'nota': 'A'},
{'nome': 'Fernanda', 'nota': 'B'},
{'nome'... |
1df7d48b76c516eb6efb568c3e8830bc20f5662c | NolanBabits/compsci101 | /labs/lab4/Part 4/sums.py | 353 | 3.59375 | 4 | import numpy as np
def sumColumn(matrix):
return np.sum(matrix, axis=1)
matrix = np.loadtxt('test.txt').astype(int)
x = 1
sum = sumColumn(matrix)
for i in sum:
print("sum of column {x} = {sum}".format( x = x , sum = i))
x += 1
x = 1
for i in matrix:
print("sum of row {x} = {sum}".format(x=x,... |
1f32959163a166c7608f3df6c497362e247d9c00 | artyomudin/task3 | /lesson13/task2.py | 391 | 3.8125 | 4 | #method = 'up'
def myfunc(func):
return func
def thefunc(word, method):
if method == 'up':
print(word.upper())
elif method == 'down':
print(word.lower())
else:
print('what?')
def somefunc(*args, multiplier=2):
mylist = [num*multiplier for num in args]
print(mylist)
m... |
1b0c66433fa92fc525ee0c64de4e4db7717e09fa | artyomudin/task3 | /lesson22/task2.py | 316 | 3.921875 | 4 | def is_pallindrome(looking_string):
if len(looking_string) <= 1:
return True
if looking_string[0] != looking_string[-1]:
return False
return is_pallindrome(looking_string[1:-1])
b = is_pallindrome('ssassass')
print(b)
m = is_pallindrome('mom')
print(m)
o = is_pallindrome('o')
print(o) |
4fb219eb939d1f59e8f933e1d4d7260506c778be | anlutfi/dl4cvtools | /preprocessors/simplepreprocessor.py | 530 | 3.84375 | 4 | import cv2
def simplePreprocessor(width, height = -1, interpolation = cv2.INTER_AREA):
"""simplePreprocessor(width, height = -1, interpolation = cv2.INTER_AREA)
returns a function f(img), that resizes an image img
to a width X height resolution,
using the interpolation algorithm provided
... |
8e7cbc30256be581d82ffeb420cb19ed4d715cf9 | joedonahoe/python | /dice.py | 1,972 | 3.78125 | 4 |
## Rolling Dice Simluator
## By Joe Donahoe
## Idea from https://knightlab.northwestern.edu/2014/06/05/five-mini-programming-projects-for-the-python-beginner/
## 2019.01.13. JSD. Created program with basic 3d7.
import random ## needed for random numbers
def ConductExperiment ( number_of_rolls, number_of_dice, ... |
7d324f51aeefd51403c1b682ad7079ec9e08da3b | monistery/little-basement | /Code/pythonwork/标志(bool变量)的应用.py | 188 | 3.5625 | 4 | prompt = "\nTell me something"
prompt += "(Enter 'quit' to end): "
active = True
while active:
message = input(prompt)
if message == "quit":
active = False
else:
print(message)
|
5deca1a7dc9a16b477bd3388b5a006a58fb2cd6b | monistery/little-basement | /Code/pythonwork/test.py | 59 | 3.6875 | 4 | a = ['1', '2', '3']
n =3
for i in range(0,n):
print(a[i])
|
309ade2a40b4543a93bd65ec0c05bf09193fad94 | bbk0529/ProcessDiscovery | /discover.py | 5,673 | 3.578125 | 4 | def listSearch(T,keyword, start=0):
try :
idx = T.index(keyword,start)
except :
return []
return [idx] + listSearch(T,keyword,idx+1)
def search (L, pl,pr,tl,tr, lm, rm,rep ):
pl = pl-lm
pr = pr+rm
tl = tl-lm
tr = tr+rm
pattern=[L[pl : pr], pl, pr]
target=[L[tl :tr... |
ff960a498267ffb55658d654eede0b1c4efdc59e | ram89toronto/1kpythonrun | /5.py | 216 | 3.953125 | 4 | # Write a python program to accept a single character from a keyboard
# input varaible
char = input(" Please enter a character : ")
# Display the single character
print("Single character entered is : ",char[0])
|
c65be387b94ad3f5ec38ba1f4f91b260922f6b71 | ram89toronto/1kpythonrun | /22.py | 226 | 4.1875 | 4 | # write a program to display Equilateral Triangle using *
# input variable
star = int(input(" Enter number lines of Equilateral triangle :"))
n=star+2
# Logic & display
for i in range(1,star):
print(" "*(n-i) + "* "*(i))
|
fd73980ff343110b8c27fda35270ca42e08b3850 | ram89toronto/1kpythonrun | /7.py | 625 | 4.09375 | 4 | # Write a python program to accept 3 numbers in the same line and display their sum?
# Also, write a logic to accept 3 numbers separated by comma.
# Input Varialbe
var1 , var2 , var3 = [int(i) for i in input(" Enter three numbers : ").split()]
var_1, var_2, var_3 = [int(j) for j in input(" Enter three numbers separ... |
1c7007842341c60b15561e14f5f478950d2cb13f | ram89toronto/1kpythonrun | /10.py | 431 | 4.09375 | 4 | # Write a python program to display and find sum of three numbers using command line arugments
# importing required pacages
import sys
#input varialbes
n1 =int(sys.argv[1])
n2 =int(sys.argv[2])
n3 =int(sys.argv[3])
# logic
sum = n1+n2+n3
len = len(sys.argv)
# Display of output
print("Length of arguments {}".format(... |
a86a79f00d346c876efe6019f4eabe719648fe92 | shiran-valansi/Iteresting-Questions | /next_right_tree.py | 1,192 | 3.984375 | 4 | # Definition for binary tree with next pointer.
class TreeLinkNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
self.next = None
class Solution:
# @param root, a tree link node
# @return nothing
def connect(self, root):
"""connects the ... |
3a2780991f4ed5425bb2c4c779518af02cca0ac2 | shiran-valansi/Iteresting-Questions | /inorder_traversal.py | 645 | 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 inorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
inorder = []
self.... |
64adfa1061a26978f6c6aa7f691338cce236bc7d | chenxianpao/memo | /algorithms/quicksort.py | 1,424 | 3.90625 | 4 | def quicksort(q_list, start, end):
if start < end:
i, j = start, end
base = q_list[i]
while i < j:
while (i < j) and q_list[j] >= base:
j -= 1
q_list[i] = q_list[j]
while (i < j) and q_list[i] <= base:
i += 1
q_... |
6857fb2151ae3cbc8bf2bd7df99c825987eb2b41 | goodstart57/TIL | /Algorithm/code/brute_force/combination_recursive.py | 283 | 3.59375 | 4 | li = [2, 3, 4, 5]
def combination(n, r):
if r == 0:
print(memory)
elif n < r:
return
else:
memory[r - 1] = li[n - 1]
combination(n - 1, r - 1)
combination(n - 1, r)
r = 2
memory = [None for _ in range(r)]
combination(len(li), r) |
5243e06edbb0c28139a4c5dee4fd0a405beddf7a | ldirer/deploy-app-docker | /backend/fixtures.py | 7,025 | 3.515625 | 4 | from typing import List
from backend.app import QuizQuestion
class SampleStore:
"""Just a class so that I can automatically put samples in a list. Slightly overkill.
Technically putting all this at class level is a bit 'dangerous' as any error will kill the app if this
module is imported.
Everything... |
84e7a4bfb23c83a76c4f6f3d483fe6ee773ca0e0 | sophiezhng/CS50-Harvard-Problem-Set-Solutions | /pset6/hello.py | 147 | 4.3125 | 4 | # Ask what is name and save input in variable "name"
name = input("What is your name?\n")
# Print hello statement w/ name
print(f"hello, {name}")
|
3f3ac82bada621670d683ec7387aaa3ded5da8c6 | MarynaNogtieva/python_algorythms | /merge_sorts/merge_sort_1.py | 1,104 | 4 | 4 | def merge(arr, aux_arr, low, high, mid):
print(low, mid, high)
for i in range(high):
aux_arr[i] = arr[i]
i = low
j = mid + 1
for k in range(len(arr)):
# i has a limit - mid of arr. if i exceeds it's limit
if i >= mid:
arr[k] = aux_arr[j]
j += 1
# j has a limit - end of arr - high ... |
3c0e865e21858edb4a377030deea57cc48632b07 | MarynaNogtieva/python_algorythms | /data_structures/stack/linked_list_stack.py | 1,283 | 3.9375 | 4 | class Node:
def __init__(self, value, next_node=None):
self.value = value
self.next = next_node
class Stack:
def __init__(self, top=None, bottom=None):
self.top = top
self.bottom = bottom
self.length = 0
def push(self, value):
new_node = Node(value)
if self.length == 0:
self.bottom... |
c7b9e312faeccb9fddb55a4bb3a9ecebb1eb1b4c | qiqinn/DTS | /Tugas Sesi 4 - Muthaqin Dean.py | 433 | 3.8125 | 4 | timeHour = int(input("Start time in hours(0-12) : "))
timeMinute = int(input("Start time in minutes(0-59) : "))
timeDur = int(input("Event duration in minutes(0-300): "))
startTime = str(timeHour) + "." + str(timeMinute)
print("Start time : ", startTime)
durMinutes = (timeHour * 60) + timeMinute + timeDur
durHours... |
32cea03f40b6bec33231d4dd1401a65011ba8094 | TwoIceBing/Java | /src/First/StudentsMS.py | 3,695 | 3.828125 | 4 | '''
Created on 2017年12月7日
这是一个学生管理系统
@author: jzp
'''
def showMS():
print('-' * 30)
print(' 学生管理系统1.0')
print('1.添加学生信息')
print('2.删除学生信息')
print('3.修改学生信息')
print('4.查询指定学生信息')
print('5.查询所有学生信息')
print('6.退出系统')
print('-' * 30)
students = []
# 1.添加学生信息
def add... |
7f2df5a206745ee2740bb2e8dc8bd77f701c87da | gorkemunuvar/Distance-Between-Locations | /services/polygon.py | 1,026 | 3.796875 | 4 |
from shapely.geometry import Point
from shapely.geometry.polygon import Polygon
from constants import MKAD_KM
def inside_polygon(lat: float, lon: float) -> bool:
# To understnad if the specified address is located inside the MKAD
# I used a simple mathematical trick. It check if the given point
# is ins... |
3446cbd000bff18eeef30b8954a0fd56789f4919 | sophannachhorn/python_1 | /exam4/ex4.py | 166 | 3.796875 | 4 | result = True
while result == True:
number = int(input())
if number == 72:
print("win")
result = False
else:
print("again") |
c7a4b005ccb6dfdddd367f31b4bcb1da2ad45d8e | torubylist/learning | /python_learning/alg/find_same_nums.py | 256 | 3.546875 | 4 | a = [1,2,3,4,5,6]
b = [3,5,6,7,8]
i = j = 0
result = []
while i < len(a) and j < len(b):
if a[i] < b [j]:
i = i + 1
elif a[i] > b[j]:
j = j + 1
else:
result.append(a[i])
i = i + 1
j = j + 1
print(result)
|
ad4c5f06f5c9630b1d004ac08aa162ecaa9ba08a | jasonyang295/Connect4Game | /connect4advanced.py | 5,413 | 3.890625 | 4 | #we are now going to create the finished version of the game with better graphics
import sys
import numpy as np
import pygame
import math
RED = (255, 0,0)
YELLOW = (255, 255, 0)
BLUE = (0,0,255)
BLACK = (0,0,0)
from numpy.lib.function_base import piecewise
ROW_COUNT = 6
COL_COUNT = 7
def checkwin(board, piece):
... |
6eff3a0a1e391067b53fd541f667b06f4d57c5f4 | DAPLEXANDER/UFFTESTING | /Que tipo de numero es.py | 306 | 4.0625 | 4 | ''' Programa para ver si un numero es odd o even
'''
number = int(input("Introduzca cualquier numero: "))
if (number%2==0):
print("El número es even")
else:
print("El número es odd")
#Se puede oprimir F5 para correr el modulo en IDLE
#input("Oprimir enter para salir")
input("Oprima enter para salir")
|
1a0e9182a93a910582cdc0eaf09ea91477bc61c8 | codevibess/MOW-SN | /scripts/actorsDataset/kNN/knn.py | 3,676 | 3.640625 | 4 | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.colors import ListedColormap
import seaborn as sn
import pylab as pl
from mlxtend.plotting import plot_confusion_matrix
# Import LabelEncoder for data encoding
from sklearn import preprocessing
from sklearn.model_selection import tra... |
19c5994b12131be24d2fffdd15934c55e0c2b0c1 | codevibess/MOW-SN | /scripts/actorsDataset/scriptsForPreparingData/merge_files_3.py | 5,088 | 3.71875 | 4 | import csv
import time
import json
from create_proper_JSON import *
from create_CSV_header import *
def create_list_of_ids(array_of_jsons):
'''
create_list_of_ids [Fuction create list of film metadata ids]
[We use this function to create array of only ids of film_metadata ids
and then use it when we ... |
c68138d96b8b1e39a56b33ac178966e73afcce3d | hayato540101/fundamentals | /Py_Official_tutorial/2-9章/イテレータの実装.py | 312 | 3.515625 | 4 | class Container:
pass
for 文の in に使えるようにします( iterable にします)。 最も小さい iterable を実装していきます。
>>> # 何も起こらない。とにかくエラーが発生しないことを目標に。
>>> for element in Container():
... print(element)
>>> |
845f7864f1de6fc85ec4a57cbf2db42f78a7a394 | psingapan/Python-3 | /Dicts_Assignment.py | 1,454 | 3.953125 | 4 |
##Problem 1: There are 5 students in a class who have taken a test and received scores as follow. Tom got a 75.
##Joe Got a 65. Alice got an 85. Bob got a 45. Jane got a 99. Create two lists, names and scores, to
##hold this information.
student_names=['Tom','Joe','Bob','Alice','Jane']
student_scores=[75,65,45,85,99]... |
d6d7ecfa05ad0be44f661fb86e2987ffa4340136 | Titash21/Python-Representation-of-LinkedList | /linkledistDelete.py | 2,116 | 4.28125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class Linked_List:
def __init__(self):
self.head=None
#Insert the data at the front of the Linked_List
def insert_at_front(self,data):
new_node=Node(data)
if self.head==None:
self.head=new... |
13e8d7deb64ae3efd7d3a502e8ad6d12060b15a8 | NamNamju/DataAnalysis | /Training/example3.py | 1,028 | 3.6875 | 4 | import numpy as np
array = np.random.randint(1, 10, size = 4).reshape(2,2)
print(array)
# 데이터에 곱셈
result_array = array * 10
# 서로 다른 형태의 Numpy 연산
array1 = np.arange(4).reshape(2, 2)
array2 = np.arange(2)
array3 = array1 + array2
print(array3)
# 브로드캐스트
array1= np.arange(0, 8).reshape(2, 4)
array2 = np.arange(0, 8... |
512ff4d40913ef6a8ca51beb45ec7089a83b9eac | joekreatera/python_va_basic_python_3 | /08_05_2021/practice3.py | 557 | 4.28125 | 4 | """
Muestra la distancia a la que dos objetos circulares (bala y enemigo)
deberian de estar para NO chocar y la distancia a la que realmente están.
Puedes pedir las siguientes entradas:
x,y de bala y enemigo
radio de bala y enemigo
"""
from math import sqrt
x1 = int(input('X enemigo:'))
y1 = int(input('Y enemigo:'... |
2df031a6e1486f31ee582b6e8c52abe007066ff8 | joekreatera/python_va_basic_python_3 | /08_05_2021/practice4.py | 687 | 4.125 | 4 | """
En un juego de plataforma de laberintos, hay que saber si la celda en la que esta
el player y el enemigo es la misma. Si lo esta, entraran a una batalla.
Para poder saber si estan cerca, el mundo cuenta con una reticula. Los mov. solo
opuede ser hacia adelante o atras, arriba o abajo. El programa puede pregunt... |
8d71192cd1dc30d9b9ce0e49a2e966b55885135f | kishvanchee/pybites | /8/test_rotate.py | 786 | 3.734375 | 4 | from rotate import rotate
def test_small_rotate():
assert rotate('hello', 2) == 'llohe'
assert rotate('hello', -2) == 'lohel'
def test_bigger_rotation_of_positive_n():
string = 'bob and julian love pybites!'
expected = 'love pybites!bob and julian '
assert rotate(string, 15) == expect... |
1dc136501f05a2b658b80c3c9a34211b69ad956b | iftikhar92/Python-Key-scripts | /p7-list-3.py | 201 | 3.625 | 4 | a = 1
t1 = ["apple1", "banana1", "cherry1"]
for x in range(0,3,1):
a = a + 1
t1.append ("xyz" + str (a))
if (x==3):
break
print (t1)
t1.insert(2, "mmm")
print (t1)
|
aa1d74076bb9a38f6dfb967c2f02e3d30fecf801 | iftikhar92/Python-Key-scripts | /p7-funct-1.py | 137 | 3.765625 | 4 | def addnum1(x,y):
z = x + y
return z
def main():
a=2
b=8
m = 0
m = addnum1 (a,b)
print (m)
main() |
fa4361e7872c6a617928ab9e589481f0c788ac76 | ruotianluo/rtutils | /rtutils_cli/gdrive_wrapper.py | 326 | 3.578125 | 4 | import argparse
import sys
import os
import re
def simplify(url):
url = re.split("[/\\\]", url)
return [_ for _ in url if len(_) == 33][0]
def main():
args = sys.argv[1:]
args = [simplify(x) if 'http' in x else x for x in args]
print('gdrive '+' '.join(args))
# os.system('gdrive '+' '.join(ar... |
c2b11a145e2f4eb41992fdb954da8ba94cea14a0 | Sunnez/Euler-s-method | /improved_euler.py | 760 | 3.890625 | 4 | import math
print("Let's begin")
#--- You need to change the number from here ---
def f(x,y): #return answer of equation
return x*y**2-y/x #CHANGE: put a function f(x,y) here #type "math.exp(-y)" instead of e**(-y)
DELTA_X = 0.05 #CHANGE: delta x
FINAL_X = 1.5 #CHANGE: final value of x
x=1 #CHANGE: nitial v... |
8a9832e0c73394a9c48d5e6062607c3deccc1b69 | Bourn3x/Monash-Final-Year-Project | /Main/Unit Tests/unittest_preprocess_removeStopWords.py | 2,486 | 3.59375 | 4 | import unittest
from nltk.corpus import stopwords
def removeStopWords(inputSentence):
"""
Arguments:
inputSentence (str): A written review
Returns:
outputSentence (str): The written review with stop words filtered out
"""
outputSentence = []
inputSentence = inputSentence.split(... |
037a531eb1faf07452db4a9b6cdce1702bca1dad | nohaz-h/aoc2020 | /day02.py | 1,182 | 3.53125 | 4 | infile = './data/input.day02'
data = open(infile).read().split('\n')[:-1]
def answer(data):
counter = 0
for d in data:
pos, letter, password = d.split(' ')
minpos, maxpos = pos.split('-')
# only read first character in letter
letter = letter[0]
minpos, maxpos = int(minp... |
3f8cd5fcb611fa4e343c5aff29f92988b87fd2f8 | dineshbhonsle14/master | /coding/1.1_isUnique.py | 728 | 3.609375 | 4 | import unittest
def isunique(string):
char_set=[False for _ in range(128)]
for chr in string:
val=ord(chr)
if char_set[val] is False:
char_set[val]=True
else:
print "{} {}".format(chr,char_set[val])
return False
print "{} {}".format(chr,char_set[val])
ret... |
6bc9a44ab3e1ff3b0f0a0cad19a1d7ffc944dd27 | shayany/Python_Assignment | /week4/ass47.py | 1,156 | 3.515625 | 4 | import re
from ass45 import weather_update_retrieve
def extremePlaces():
"""
This function shows the hottest and coldest places in Norway
"""
try:
listOfPlaces=weather_update_retrieve("",13,0)[1:] #Get weather information for all the places
result = u"\n".join(u"\t".jo... |
7513bda5a849d2f2bff4767d623b0a1c82707f3a | gwiedeman/eadmachine | /source/EADtoSpreadsheet/func/encoding.py | 196 | 3.765625 | 4 | # -*- coding: utf-8 -*-
def strip_non_ascii(string):
''' Returns the string without non ASCII characters'''
stripped = (c for c in string if 0 < ord(c) < 127)
return ''.join(stripped) |
388d3e4c16992cfe7ac88ff4c1a50d94862242fd | cpe202spring2019/lab1-tyrakriv | /location_tests.py | 2,532 | 3.828125 | 4 | import unittest
from location import *
class TestLab1(unittest.TestCase):
def test_repr(self):
"""Tests the location of SLO to find if it represented correctly"""
loc1 = Location("SLO", 35.3, -120.7)
self.assertEqual(repr(loc1),"Location(SLO,35.3,-120.7)")
"""Tests the location of... |
fafe677b4c216e8f624afd01296ce3d0718b8123 | MihaiStrejer/ProjectEuler-Python | /Helpers/ListHelpers.py | 348 | 3.5 | 4 | __author__ = 'Mihai'
class ListHelpers:
@staticmethod
def find_highest_numbers_indexes(lst, k):
""" Find the index of the n highest numbers in a list """
return sorted(range(len(lst)), key=lambda x: lst[x])[-k:]
_instListHelpers = ListHelpers()
find_highest_numbers_indexes = _instListHelpers.... |
62f5bcea4d7ea9d53764ccafa476eeb670ce7cd9 | litmie/StegBlocks-TCP | /testing/client.py | 3,711 | 3.625 | 4 | """Client of StegBlocks TCP Method
This script simulates the client side of the server-client telecommunication using the StegBlocks TCP method. The number of packets sent based on the encoding of the encode table.
The script uses Scapy as the tool to manage packets, and requires Scapy be installed within Python envir... |
f508496393f0b96c7dbbcc3331bc81b08bc4ba14 | zshwuhan/ai-ml-clustering | /src/cluster/bikmeans/sim.py | 911 | 3.546875 | 4 | """
Bisecting K-means with least overall similarity.
@author Aaron Zampaglione <azampagl@my.fit.edu>
@course CSE 5800 Advanced Topics in CS: Learning/Mining and the Internet, Fall 2011
@project Proj 03, CLUSTERING
@copyright Copyright (c) 2011 Aaron Zampaglione
@license MIT
"""
from core import BiKMeans
class BiKMean... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.