blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
193540613f946c508d39c1556caeed9a7d25cd76 | fangedscorpion/CS4341_CWJG | /Assignment2/Chromosome.py | 817 | 3.59375 | 4 | import abc
class Chromosome(object):
__metaclass__ = abc.ABCMeta
# This method initializes the chromosome for generation 0
@abc.abstractmethod
def initialize(self):
pass
# This method checks if a chromosome is legal
@abc.abstractmethod
def checkLegality(self):
pass
#... |
6bed6d1ae32c1c7df5996140fa7a8fbb4abd875f | asmitashrestha/Scissors-Paper-Rock | /index.py | 1,033 | 4.03125 | 4 | import random
user_count=0
computer_count=0
options =["scissors","paper", "rock"]
while True:
user_input =input("Type scissors/paper/rock or quit :")
if user_input =="q":
break
if user_input not in options:
continue
random_number =random.randint(0,2)
#scissor=0,p... |
5512432017fc9247f4530ce715684c9814849291 | christianwang/python_learning | /binary.py | 502 | 3.90625 | 4 | def binary_search(list, item):
low = 0
high = len(list) - 1
while low <= high:
mid = int((low + high) / 2)
guess = list[mid]
if guess == item:
return mid
if guess > item:
high = mid - 1
else:
low = mid + 1
return None
my_list... |
2d06c851b7ae0af73c625ce3e755b9246d30ca3c | BMPATIL/Python-project | /sub.py | 119 | 3.8125 | 4 | a = int(input("Enter 1st value: "))
b = int(input("Enter 2nd value: "))
print("The result of ", a, "-", b, " = ", a-b)
|
be6984d4f5858565e9628aa54482387810765665 | Descent098/schulich-ignite-winter-2021 | /Session 4/Solutions/Exercise 2.py | 2,905 | 4 | 4 | """Exercise 2: The Sprite is Right
Steps:
1. Made Player inherit from sprite (line 33)
2. Added super.__init__() call and image attributes (lines 35-38)
3. Updated move() and teleport (lines 42-43 and 47-48)
4. Added and drew player group (lines 50-52 and 97)
"""
import sys
import os
import pygame
""... |
05a2eece1e470e7324b753635da58de637b61b7c | Descent098/schulich-ignite-winter-2021 | /Session 3/Solutions/Exercise 1.py | 1,266 | 4.34375 | 4 | """Exercise 1: Country Roads
Steps:
1. Fill out fill_up() so that it fills the fuel level to the gas tank size (line 18)
2. Fill out drive() so that it removes the amount of fuel it should for how far you drove(line 22)
3. Fill out kilometres_available so that it returns the amount of kilometers left based... |
f166183b27dd435af43f99663f554975799af9f2 | bee040811/DBMS | /parse.py | 557 | 3.625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
parse csv file to user
"""
import csv
import sys
import json
from pprint import pprint
def main(argv):
type = sys.argv[1].split(".")
if(type[1] == "csv"):
spamreader= csv.reader(open(sys.argv[1], 'rU'), dialect=csv.excel_tab)
for row in spamread... |
87e31bafcfa7c33bb97a6eab844f0cb45f2238f3 | pdhuddy/daily-python-challenges | /daily_python_5-11.py | 244 | 3.84375 | 4 | def displayAreas(x,y):
print("Area of triangle: " + str(x*y*0.5))
print("Area of rectangle: " + str(x*y))
def main():
length = int(input("Input the length: "))
height = int(input("Input the height: "))
displayAreas(length, height)
main() |
6f8d57a462b43e7148c37506866cabf82f629f30 | pdhuddy/daily-python-challenges | /daily_python_5-26.py | 459 | 3.890625 | 4 | def main():
run = True
while(run):
inp = input("Enter d for dog, h for human, or q for quit: ")
if inp is "d":
dogAge = int(input("Enter your dog's age: "))
print("Your dog is " + str(dogAge*7) + " in human years")
elif inp is "h":
humanAge = float(input("Enter your human's age: "))
print("Your huma... |
e9afefcc8fff21593870f9005a10c67b5689a14a | pdhuddy/daily-python-challenges | /daily_python_5-27.py | 178 | 3.984375 | 4 | def fizzbuzz(num):
fb = ""
if num % 3 == 0:
fb += "FIZZ"
if num % 5 == 0:
fb += "BUZZ"
print(fb)
def main():
num = int(input("Enter a number: "))
fizzbuzz(num)
main() |
827b148f38c6feb19c4a7396d4a25fce00bdbcb2 | tshardey/DQ_Portfolio | /Statistics/Projects_Advertising/ProgrammingAdvertising.py | 7,028 | 3.765625 | 4 |
# coding: utf-8
# # Potential Online Programming Advertising Markets
#
# ## Project Goals:
#
# Find out markets would be best to advertise in for a new subscription service that offers Web and Mobile Development courses.
# In[78]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from colle... |
440292842c0f867ed77fd27ff115d148c0cdc3cf | MrsKamran/PythonDeliverable1 | /python-exercise.py | 2,791 | 4.03125 | 4 | # exercise-01 Vowel or Consonant
alphabet = input("Please enter a letter from the alphabet (a-z or A-Z): ")
if alphabet in ('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U'):
print("The letter %s is a vowel."%alphabet)
else:
print("The letter %s is a consonant."%alphabet)
# exercise-02 Length of Phrase
in_str =... |
cbe8a292d4eb05c07111bbb76bc0eeaf5112127b | cgcaruzo/frro-soporte-2019-10 | /practico_02/ejercicio_06.py | 1,020 | 3.859375 | 4 | # Implementar la clase Persona con un constructor donde reciba una fecha de nacimiento.
# La clase además debe contener un método edad, que no recibe nada y devuelva la edad de la
# persona (entero).
# Para obtener la fecha actual, usar el método de clase "now" de la clase datetime (ya importada).
from datetime import... |
372ada2ea4a95af8471e42296f7fc1bcdbe32bdf | cgcaruzo/frro-soporte-2019-10 | /practico_01/ejercicio-02.py | 379 | 3.546875 | 4 | # Implementar la función mayor, que reciba tres números y devuelva el mayor de ellos.
def maximo(a, b, c):
if a > b :
if a > c :
return a
else :
return c
else :
if b > c:
return b
else :
return c
# si no falla es porque esta bie... |
6c9287851f5bbbdf097a54bc4db111a9eb71d36c | djsea/study | /day10/2.py | 102 | 3.609375 | 4 | def mymax(x, y):
the_max = x if x > y else y
return the_max
ma = mymax(y=30, x=20)
print(ma) |
82c0b652fd0437611ba9d8c3d021bea2e4322fab | marcheiligers/python_type_explorer | /explore_type.py | 563 | 3.703125 | 4 | def explore_type(obj, name = "", indent = 0, indent_spaces = 4):
indent_str = ""
for i in range(0, indent * indent_spaces):
indent_str += " "
type_name = str(type(obj)).split("'")[1]
type_str = "{} <{}>".format(name, type_name).strip()
if type_name == "dict":
print "{}{} {{".format(indent_str, type_s... |
f8939d583917850a4bb08081ac7226c0a5211c04 | SherDG/Oxygen2020 | /GenerateWithFault.py | 579 | 3.59375 | 4 | #!/usr/bin/python
import csv
import random
records=90
#print("Making %d records\n" % records)
fieldnames=['id','name','age','city']
writer = csv.DictWriter(open("peopleWithFault.csv", "w"), fieldnames=fieldnames)
names=['Deepak', 'Sangeeta', 'Geetika', 'Anubhav', 'Sahil', 'Akshay']
cities=['Delhi', 'Kolkata', 'Chenn... |
11f2fe6006aaab7e7550d0df79250a097441e587 | Kuailun/TransportTradition | /Server/try.py | 59 | 3.65625 | 4 |
t = [1,1,2,3,4]
if 5 in t:
print(1)
else:
print(2) |
cb8b06ce8958e7d5cd401d3aa1e51cc4d0d4420f | AlvinKang/MovieTrailer | /media.py | 730 | 3.859375 | 4 | class Movie():
# Constructor
def __init__(self, movie_title, movie_summary,
movie_poster_url, movie_trailer_url):
"""
Creates a Movie object with title, summary, poster image, and link to
trailer. All arguments take in string inputs.
Args:
movie_tit... |
701413c59077d08d36a8979062a3256e228a175c | wierWu/arithmetic | /python/word_search2.py | 356 | 3.921875 | 4 | def findWords(board,words):
trie={}
for w in words:
t = trie
for c in w:
if c not in t:
t[c]={}
t = t[c]
t['#']='#'
print(trie)
def bfs(board,y,x,):
return
if __name__ == "__main__":
board = [['o','a','a','n'],['e','t','a','e'],['i','h','k','r'],['i','f','l','v']]
words = ["oath","pea","e... |
e07bf516f3d271b15c42d8f97afdd650ad85b43a | wierWu/arithmetic | /python/medianSlidingWindow.py | 1,312 | 3.8125 | 4 | def medianSlidingWindow( nums, k):
if nums is None or len(nums) <k or k<2:
return []
slid_median_arr=[]
is_even = k%2==0
median_k=k//2
import collections
import copy
windows_num_dp = collections.deque()
sum=0
for i in range(0,len(nums)):
value = nums[i]
sum +=value
if i<k:
windows_num_dp.append... |
dd29ea41437ef40746dc5df10398a3b9ca4c1389 | tic0uk/python-100daysofcode | /day-5-fizzbuzz-game.py | 420 | 4.28125 | 4 | # replicating a game called fizzbuzz that children play;
for i in range(1,101):
# if number is divisible by both 3 or 5 say "fizzbuzz"
if (i % 3 == 0 and i % 5 == 0):
print ("fizzbuzz")
# if number is divisible by 3 say "fizz"
elif i % 3 == 0:
print ("fizz")
# if number is divisible by 5 say "buzz"
el... |
cda68253822d87cdad1f500fc897ba18e727d744 | tic0uk/python-100daysofcode | /day-27-mile-to-km-converter/main.py | 891 | 3.921875 | 4 | # Miles to Km Converter
from tkinter import *
def button_clicked():
miles = float(num_miles.get())
result = miles * 1.609
num_km.config(text=f"{result}")
window = Tk()
window.config(padx=20, pady=20)
window.title("Mile to Km Converter")
text_is_equal_to = Label(text="is equal to")
text_is_equal_to.grid... |
ee3605add464dc74ceb8e47fc6138302362e9d90 | tic0uk/python-100daysofcode | /day-11-blackjack.py | 3,895 | 4.0625 | 4 | # A game of blackjack (also known as 21)
# The solution I came up with wasn't the same as the teachers recommended way but it works so
# I'll put it up here and learn for future lessons.
from replit import clear
from art import logo
import random
cards = [11,2,3,4,5,6,7,8,9,10,10,10,10]
def play_game():
user_resp... |
ad34edb703892622abea1507144d0d0bd65e5074 | Alves5/codigosempython | /avf-13.py | 177 | 3.578125 | 4 | somaP = 0
somaI = 0
for e in range(1,101):
if e % 2 == 0:
somaP += e
else:
somaI += e
print(f"Soma dos números pares: {somaP}\nSoma dos números ímpares: {somaI}") |
8930698fcbd50f4b049d630059d7b594ad061bad | N0NamedGuy/Bitcho | /fun_thread.py | 699 | 3.59375 | 4 | '''
Created on Nov 2, 2011
@author: David
'''
import threading
# code from
# http://softwareramblings.com/2008/06/running-functions-as-threads-in-python.html
class FunThread(threading.Thread):
"""
Runs a function in its own thread
"""
def __init__(self, target, args = []):
"""
Ini... |
c4d6de737478a1c1d7d4b2cafa296466b9f2190f | Jaep0805/PersonalProjects | /ConnectFour/main.py | 4,284 | 4.0625 | 4 | #board
#display board (using 2d array)
#turn
#play game
#check win
#check rows
#check columns
#check diagonal
#check tie
#flip player
#ai implementation
import random
board = [['_','_','_','_','_','_','_'],
['_','_','_','_','_','_','_'],
['_','_','_','_','_','_','_'],
['_','_','_'... |
af0a56d4c53bdd9c6d73d33d45b212af63becdad | himanshuguptan/domainNameChecker | /check_domain.py | 944 | 3.75 | 4 | import menu
from check_availability import is_available
import handle
while True:
menu.print_app_menu()
user_input = input(": ").rstrip()
# Get input from the user
while True:
try:
user_input = int(user_input)
break
except ValueError:
user_input = inp... |
6c5c94a2c8d405c9159cb18279e01314485a2485 | annbgn/uni_projects | /pandas_iris/utils.py | 159 | 3.765625 | 4 | def grouper(x, lower, higher):
if x <= lower:
return 'Small'
elif lower < x <= higher:
return 'Medium'
else:
return 'Large' |
4b88131b589761baf17e03992be46cb9742c0a62 | praemineo/backpropagation | /backpropagation.py | 1,720 | 4.15625 | 4 | import numpy as np
#define sigmoid function
def sigmoid(x):
return 1 / (1 + np.exp(-x))
# X is a unit vector
x = np.array([0.5, 0.1, -0.2])
# target that we want to predict
target = 0.6
#learning rate or alpha
learnrate = 0.5
#weight that we initialize
weights_input_hidden = np.array([[0.5, -0.6],
... |
872c6e7abefc7532092d4fea8923a52947fc72f2 | Jim-Maar/Bundeswettbewerb-and-algorithms | /Projecteuler.net Aufgaben/Euler 5 Smallest multiple.py | 447 | 3.828125 | 4 | awnser = 0
def smallest_multiple(m):
n = 1
while awnser == 0:
if n % 10000000 == 0:
print(n)
teilbar = True
for i in range(2, m+1):
if n % i != 0:
#print(n,"nicht teibar durch",i)
teilbar = False
break;
... |
e0729004f49ae128e67f4f6fc173cb320c93d8c1 | Jim-Maar/Bundeswettbewerb-and-algorithms | /Bundeswettbewerb Aufgaben/bwinf 37 Runde 2 Lisa rennt.py | 12,222 | 3.546875 | 4 | from turtle import *
import math
def dist(x1,x2,y1,y2):
return((y1-y2)**2+(x1-x2)**2)**0.5
def collision(x1,x2,x3,x4,y1,y2,y3,y4):
if ((x1 != x3 or y1 != y3) and (x2 != x3 or y2 != y3)) and ((x1 != x4 or y1 != y4) and (x2 != x4 or y2 != y4)):
den = (x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)
if d... |
3ff200c4d0ccaaefd84a70b6780004ae5a4e223c | pdturney/similarity-of-cellular-automata | /scoring_reverse.py | 871 | 3.578125 | 4 | #
# Scoring Reverse
#
# Peter Turney, December 7, 2020
#
# For each rule, find its reversal.
#
import scoring_functions as sfuncs
#
# open a file for storing the unpacked rules
#
rule_file_name = "reverse_rules.txt"
rule_file_handle = open(rule_file_name, "w")
#
# make a list of B/S rules (born/survive --... |
c66318a31ccd43f9623733d5a30fc0f657186b78 | terryyuan400/python | /practice/while.py | 253 | 3.953125 | 4 | #!/usr/bin/python
number = 23
while True:
guess = int(raw_input("Enter an integer:"))
if guess == number:
print "you guess it."
break
elif guess < number:
print "higer"
else:
print "lower"
print "Done"
|
2b0dd65957e78b41573cfb64ed8ca873bf51b9fe | nuzcraft/RLTut | /helpers/vline.py | 205 | 3.53125 | 4 | # draws a vertical line on the map
def vline(map, x, y1, y2):
if y1 > y2:
y1,y2 = y2,y1
for y in range(y1, y2 + 1):
map[x][y].blocked = False
map[y][y].block_sight = False |
e3e44381208bfdad90326d7f120eb8a312364e0a | SnowSuno/SortingAlgorithmVisualizer | /algorithms/shell.py | 508 | 3.796875 | 4 | NAME = 'Shell Sort'
INFO = 'Time complexity\n' \
' Ω(n log(n))\n Θ(n log(n)²)\n O(n log(n)²)\n\n' \
'Space complexity\n' \
' O(1)'
def sort(s):
skip_index = (5, 3, 1)
for k in skip_index:
for _ in skip_insertion_sort(s, k):
yield
def skip_insertion_sort(s, k):
... |
1e97c326897ea4ded57f0a2d968409504f2892b1 | SnowSuno/SortingAlgorithmVisualizer | /algorithms/merge.py | 1,163 | 4 | 4 | NAME = 'Merge Sort'
INFO = 'Time complexity\n' \
' Ω(n log(n))\n Θ(n log(n))\n O(n log(n))\n\n' \
'Space complexity\n' \
' O(n)'
def sort(visual):
s = visual[:]
for _ in merge_sort(s, visual, 0):
yield
def merge_sort(s, visual, start_index):
n = len(s)
if n == 1:
... |
d29b07c2824c443b28550afe05dbf87531761891 | SMITPATEL2107/CORE-PYTHON | /NETWORKING/SERVER.py | 716 | 3.640625 | 4 | import socket
def client_program():
host=socket.gethostname() #as both the code is running on the same pc
port=5000 #socket server port number
client_socket=socket.socket() #instantiate
client_socket.connect((host,port)) #coonect to the server
message=input("->") #take input
whil... |
950c55f784e955be84361b1242daff81a38bbbf1 | ho-hwa/python_algorithm | /problem12/binary_rec.py | 393 | 3.671875 | 4 | #binary_rec.py
def binary_sub(a,x,first,last):
if first>last:
return -1
mid = (first + last)//2
if x == a[mid]:
return mid
elif x < a[mid]:
return binary_sub(a,x,first,mid-1)
else:
return binary_sub(a,x,mid+1,last)
return -1
def binary_search(a,x):
return binary_sub(a,x,0,len(a)-1)
d = [1, 4, 9, 16, ... |
c581b5afaeba85d7226c8e88171806851601417a | Gabriel-Azevedo-Ferreira/PCACorrCircle | /PCACorrCircle/__init__.py | 3,244 | 3.890625 | 4 | from sklearn.decomposition import PCA
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from adjustText import adjust_text
def create_correlation_table(A, B, names_cols_A, names_cols_B):
"""
Compute the correlation coefficients and return as a DataFrame.
A and B: 2d matrixes. The col... |
7218cd9f60de0d5b669aeeb0d849cbad4d5a0dde | gnaumenko/python_test | /lesson3.py | 81 | 3.671875 | 4 | list = ["d", "a", "f"]
list2 = [1, 2, 3, 4, 5]
x = 3
print list[(list2[x%2]+x)%3] |
7517fc5a882955ca9e9389f7b0f755cfd6a8cb51 | gnaumenko/python_test | /lesson_1.py | 147 | 3.703125 | 4 | a = 2
b = 7
print (a)
print(b)
if a == b:
print ('equal')
print(a)
else:
print('not equal')
print ('end')
a = 10
% ostatok ot deleniz |
f560423d5fca24a9dd3b88175d6fa63d8a3e62dc | MOOC-Learner-Project/MOOC-Learner-BigQuery-Data-Science-Analytics | /extract/json2csv.py | 9,422 | 3.5 | 4 | import os
import json
import csv
from preprocess_util import *
class JSON2CSV:
"""Convert BigQuery JSON to CSV tables.
"""
def __init__(self, read_dir, save_dir, dict_of_fields):
"""Initialize the converter.
:param read_dir: the directory of JSON files
:param save_dir: the director... |
2c5716c91af11f829252828c33fb00553faf887a | 20centcroak/pyRevealjs | /pyRevealjs/slide.py | 2,950 | 3.796875 | 4 | import re
import sys
import logging
import os.path as path
class Slide:
"""
The Slide class defines a Slide used in a Presentation.
A slide is defined by its id, filename and title, and optionally a part number and a version number.
The filenames points on a disk location where the slide content can... |
8df68d9358650de679b903403c557e7fa265c2c7 | Nelsong2211/python-challenge | /PyBank/main.py | 1,575 | 3.75 | 4 | import os
import csv
PyBank_csv = os.path.join("Resources", "02-Homework_03-Python_PyBank_Resources_budget_data.csv")
months= []
totalNetChange = []
totalmonths = 0
totalNet = 0
biggestNum = 0
biggestMonth = ""
smallestNum = 0
smallestMonth = ""
with open(PyBank_csv, "r") as Bank_file:
csvreader = csv.reader(B... |
4e2c2e380d7a8c872dcc13e780a7c7f0951015ab | LeoSeliverstov/2.3_Primes | /main.py | 297 | 3.640625 | 4 | import itertools
def primes():
num = 1
while True:
num += 1
count = 0
for i in range(1, num + 1):
if num % i == 0:
count += 1
if count == 2:
yield num
print(list(itertools.takewhile(lambda x: x <= 31, primes())))
|
c202a48186bc33da41ae1268683569c555dcc08a | YakubovKirill/restaurant-python-telegram-bot | /Menu.py | 595 | 3.515625 | 4 | class Menu:
def __init__(self):
self.current_menu_level = 0
self.current_category = ''
def getLevel(self):
return self.current_menu_level
def getCategory(self):
return self.current_category
def incLevel(self):
self.current_menu_level += 1
def d... |
5502635d258cc2c88fd4f2f31587d86a081e244d | tunguyenthaison/PongGame | /separation.py | 997 | 4 | 4 | from turtle import Screen, Turtle
SIZE = 20
MOVE_DISTANCE = 20
WIDTH = 1000
HEIGHT = 600
LEFT_CENTER = - WIDTH // 2 + 3 * SIZE
RIGHT_CENTER = WIDTH // 2 - 3 * SIZE
TOP_PADDING = HEIGHT//2 - 2*SIZE
BOTTOM_PADDING = -HEIGHT//2 + 2*SIZE
STARTING_POSITIONS = []
LENGTH = 27
MID = (LENGTH - 1) // 2
for _ in range(0, LENG... |
5a47d18b0353a71db8c6d177beed9cbda00ab3b6 | birdcar/exercism | /python/scrabble-score/scrabble_score.py | 584 | 4.1875 | 4 | from typing import Dict
# Generates a mapping of letters to their scrabble score e.g.
#
# { 'A': 1, ..., 'Z': 10 }
#
SCORE_SHEET: Dict[str, int] = dict(
[(x, 1) for x in 'AEIOULNRST'] +
[(x, 2) for x in 'DG'] +
[(x, 3) for x in 'BCMP'] +
[(x, 4) for x in 'FHVWY'] +
[(x, 5) for x in 'K'] +
... |
3c982f2f0f3c547b21e7d1b83a7bb008b0e4b52b | birdcar/exercism | /python/meetup/meetup.py | 1,533 | 3.890625 | 4 | import calendar as cal
import datetime as dt
from typing import Literal
VALID_DAY = Literal[
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
]
VALID_WEEK = Literal["1st", "2nd", "3rd", "4th", "5th", "last", "teenth"]
DAYS = {day: n for n, day in enumerate(cal.day_name)}
WEEKS = {
"... |
b8d83171ae85bd53f1ae975de65a451a00e5274d | gabrielsmenezes/URI-problems | /2172.py | 183 | 3.609375 | 4 | entrada = input().split(' ')
x = int(entrada[0])
m = int(entrada[1])
while x != 0 and m != 0:
print(x*m)
entrada = input().split(" ")
x = int(entrada[0])
m = int(entrada[1])
|
b2fbc8105ccac8da5c963058b3083740a528b4a8 | gabrielsmenezes/URI-problems | /1281.py | 420 | 3.625 | 4 | n = int(input())
while n > 0:
produtosDaFeira = {}
m = int(input()) #numero de produtos na feira
for i in range(1,m+1):
entrada = input().split(" ")
produtosDaFeira[entrada[0]] = float(entrada[1])
p = int(input())
valorTotal=0
for i in range(1,p+1):
entrada = input().split(" ")
valorTotal = val... |
6b13137e4cfd9d666301f5e611c30278c85cfdc5 | gabrielsmenezes/URI-problems | /2473.py | 461 | 3.859375 | 4 | valores = ['azar', 'azar', 'azar', 'terno', 'quadra', 'quina', 'sena']
entrada = input().split(' ')
apostaDoFlavinho = set()
for numero in entrada:
apostaDoFlavinho.add(int(numero))
entrada = input().split(' ')
apostaGanhadora = set()
for numero in entrada:
apostaGanhadora.add(int(numero))
numerosAcertadosPorF... |
6ae8b6748060f426ef2b553d948775e3ef71ed97 | deckheart/CS4210-Machine-Learning | /Assignment 2/naive_bayes.py | 3,720 | 3.5625 | 4 | #-------------------------------------------------------------------------
# AUTHOR: Dakota Eckheart
# FILENAME: naive_bayes.py
# SPECIFICATION: Classify instances with high confidence using Naive Bayes algorithm
# FOR: CS 4210- Assignment #2
# TIME SPENT: 1 hour
#-------------------------------------------------... |
d7025c13f88527f24d10fc1a9b131f0c7e7bd627 | TheAughat/Setting-Out | /Python Practice/app4.py | 641 | 4.15625 | 4 | # The following block of code writes the times table for anything till times 10. Users can enter 'please stop' to quit
print('Writes the times table for anything till times 10. Enter "please stop" to quit.')
while True:
print()
tables = input("Which number do you want to see the tables of? ")
number ... |
950d10a0943c0c670e6405f9bce08ef1b7470c46 | kavindamain99/password_generator | /passord_gen.py | 784 | 3.796875 | 4 | import random
import string
def pw_generate(length=8):
count=0
pswrd=""
while length>count:
number=random.randrange(1,9)
strnumber=str(number)
pswrd=pswrd+strnumber
count = count + 1
lowletter=random.choice(string.ascii_lowercase)
pswrd=... |
a4aa0f51cab1dcd8ff68fd10735ca3fccc7ec9b7 | Nishanbuyo/python-program-solutions-3 | /It Academy console App/academy.py | 5,302 | 3.984375 | 4 | import csv
class Academy:
student_fields = ['roll', 'name', 'course', 'paid', 'remaining']
def __init__(self,balance):
self.balance = balance
def display_menu(self):
print("--------------------------------------")
print(" Welcome to IT Academy")
print("-------------------... |
41e335f99ad6c56ceb560040499029980b666560 | denotepython/LQ_LeetCode | /array/33.search in rotated sorted array.py | 364 | 3.71875 | 4 | class Solution(object):
def search(self, nums, target):
length = len(nums)
flag = False
for i in xrange(length):
if nums[i] == target:
flag = True
return i
break
if flag == False:
return -1
if __name__ == "__main__":
result = Solution().search([1,2,3,4,-2,-1],-1)
print result
#确定没在逗我?遍历一次... |
c72d55f0e9deacd4a1fa90509be4eee879bfd750 | denotepython/LQ_LeetCode | /array/48.rotate image.py | 860 | 3.78125 | 4 | # -*- coding:utf-8 -*-
class Solution(object):
def rotate(self, matrix):
length = len(matrix)
#temp = matrix #问题出在这里,这里temp和matrix指向了同一内存
temp = [[0 for col in range(length)] for row in range(length)]
for i in xrange(length):
for j in xrange(length):
temp[j][length-i-1] = matrix[i][j]
for i in xrang... |
f24368854b411ebb602363110f3b43515fec4ab0 | denotepython/LQ_LeetCode | /array/66.plus one.py | 453 | 3.59375 | 4 | class Solution(object):
def plusOne(self, digits):
num = 0
for i in digits[::]:
num = num * 10 + i
num += 1
ans = []
while num != 0:
ans.append(num % 10)
num /= 10
ans.reverse()
return ans
"""
:type digits: L... |
aa21593711b4fe95fd0b2b66e9d18fdc81332cd2 | divyasandeep/test5 | /addition.py | 114 | 4.03125 | 4 | # Addition of 2 numbers
a =int(input('Enter Value for A: '))
b= int(input('Enter Value for B: '))
c= a+b
print(c) |
569083c8c9079f802299e9974cf3d6f58b317e13 | suparna3110/DocCreator_python | /nat.py | 2,727 | 3.765625 | 4 | import emoji
import docx
import string
import random
import os
import functools
import operator
# instance creation of a word document
document = docx.Document()
check = 0
# function for finding emoji in the string
# function for finding emoji in the string
def is_emoji(s,emojiEnabler):
global check
print(c... |
445571cda4808aac200b0ee97288fee9674c78cc | alfa-netology/hw-oop | /modules/own_classes.py | 2,842 | 3.515625 | 4 | import modules.own_functions as functions
class Student:
def __init__(self, name, surname, gender):
self.name = name
self.surname = surname
self.gender = gender
self.finished_courses = ['Введение в программирование']
self.courses_in_progress = []
"""
grades:
... |
5015f16b1719c3fd7b88a97300d854971f7f32ed | mxie622/Python_Tool | /Anomaly_Detection.py | 4,046 | 3.53125 | 4 | # Method 1: standard deviation
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(1)
anomalies = []
ind = [] # Anomalies position
# multiply and add by random numbers to get some real values
random_data = np.random.randn(500) * 20 + 20
# Function to Detection Outlier on one-dimentional datasets.
def fi... |
038bf29f609e848aa652979c88f1935f0fb92ce4 | ptangra/Lab2Instr | /Lab1.py | 3,230 | 4.125 | 4 | import math
class Calculator:
def __init__(self, x, y):
self.x = x
self.y = y
def Add():
"""Func for adding numbers"""
num1 = int(input("Enter first number:"))
num2 = int(input("Enter second number:"))
retur... |
7cd8f96dfb84dc2e92da8de7f2db736ac1a100db | ManasweeA/CodeOffDuty_HackathonSubmission | /AI/DataGenerators/tenouse_prediction_data.py | 3,628 | 3.625 | 4 |
import random
import csv
class TenouseData:
def __init__(self):
self.City = ['Pune', 'Mumbai', 'Bangalore', 'Hyderabad']
self.Quarter = [1, 2, 3, 4]
self.HouseStructure = ['Bungalow', 'Building', 'Row_House']
self.HouseType = ['Furnished', 'Unfurnished']
self.BHK = [1, 2, 3... |
32a4fba0a74b1bfb082ff5df4e2c135b13c0a627 | kacurez/MIRUN | /test/shouldcompile.py | 4,385 | 3.5 | 4 | """
shouldcompile: simple utility to test the return value of a program/compiler.
as the arguments it accepts the program/compiler(relative path) to test and list of directories/files, if the list is empty then it uses only the current working directory.
It travers through the specified directories looking for .c files... |
bce2ae14d37df7bda0d4df0d6d50aa86f4fe77e6 | GuilhermeBites/UriSubmissions | /1035.py | 184 | 3.546875 | 4 |
a,b,c,d= input().split()
a,b,c,d = int(a),int(b),int(c),int(d)
if ((b>c)and(d>a)and(c+d>a+b)and(c>0)and(d>0)and(a%2==0)):
print("Valores aceitos")
else:
print("Valores nao aceitos") |
d969a5a2b642277e499e2c6cafe59c947e7be3f3 | AliHassanUOS/PythonProgramaAndProject | /dictionaryinpython.py | 2,338 | 4.1875 | 4 | # print("Dictionary in python")
# print()
#
#
# print(dic[2])
#
# print(dic)
# dic = {1: 'ali', 2: 'hassan', 3: 'rubab', 4: 'ahmad'}
#
# print(11 not in dic)
# dic = {1: 'ali', 2: 'hassan', 3: 'rubab', 4: 'ahmad'}
# print(dic)
# print()
# dic.clear()
# print(dic)
# dic = {1: 'ali', 2: 'hassan', 3: 'rubab', 4: 'a... |
292a379690150483dd06746dcbfdc596ce36ce9e | AliHassanUOS/PythonProgramaAndProject | /Project2.0Python.py | 7,330 | 4.25 | 4 | print("ALLAH is greatest ")
#
# def RemoveDup(li):
# emptylist = []
# for i in li:
# if i not in emptylist:
# emptylist.append(i)
# return emptylist
#
#
# result=RemoveDup(['a', 'b', 'c', 'a', 'b', 'ab', 'ba'])
#
# print(result)
# string1 = "capital first and last letter in string"
#
#... |
1cabb3e6a643fcb1d052eda08e4a1fd96f0f820c | AliHassanUOS/PythonProgramaAndProject | /OopPractice.py | 1,709 | 4.28125 | 4 | print("ALLAH")
# class calculator(object): # create calculator class
#
# def add(self, x, y):
# return x + y
#
# def sub(self, x, y):
# return x - y
#
# def mul(self, x, y):
# return x * y
#
# def divide(self, x, y):
# return x // y
#
#
# obj = calculator()
# while Tru... |
165188c0177d58fe4b9785f6040a1d898f87ab52 | thomasleese/snakes-on-a-plane | /xplane/autopilot.py | 2,313 | 3.578125 | 4 | """
A very simple autopilot designed to simplify testing of planes by providing an
existing framework for getting a plane in the air.
"""
from . import packets
from .io import Protocol
from .packets import units
class TakeoffMixin:
_takeoff_state = None
_takeoff_heading = None
_takeoff_altitude_target = ... |
b5e014d5b890149edd7e158fd3153ab835d9d3c3 | creep1g/Datastructures-RU | /class13/BST.py | 2,050 | 3.90625 | 4 | '''Binary Search Tree'''
class Node:
def __init__(self, data=None, right=None, left=None):
self.data = data
self.right = right
self.left = left
def __str__(self):
return str(self.data)
class BinarySearchTree:
def __init__(self):
self.root = None
def add(sel... |
92610d6365d8eb63955b47647314889ec0fef0b7 | creep1g/Datastructures-RU | /practice-tests/FinalExamSpring2020_solutions/P3/boolean_tree.py | 3,228 | 3.765625 | 4 |
class TreeNode:
def __init__(self, value, left = None, right = None):
self.value = value
self.left = left
self.right = right
def __str__(self):
if self.left == None:
return str(self.value)
else:
return str(self.value) + "(" + str(self.... |
b02a35793e817f814534a9be0b13028ad910fea6 | creep1g/Datastructures-RU | /class12/generaltree.py | 1,134 | 3.96875 | 4 | class Tree_Node:
def __init__(self, data=None):
self.data = data
self.children = []
class Tree:
def __init__(self):
self.root = None
def populate_tree(self):
self.root = self.populate_tree_recur()
def populate_tree_recur(self, parent_name="", level=0):
tree = ... |
3266a0eb4945348bb937dea439d2e6edf248e2a5 | creep1g/Datastructures-RU | /PA5/bucket.py | 3,848 | 3.828125 | 4 | class NotFoundException(Exception):
pass
class ItemExistsException(Exception):
pass
class Bucket:
class Node:
def __init__(self, key, value, Next):
self.key = key
self.value = value
self.next = Next
def __eq__(self, other):
if (self.key == ... |
92b7c8b57e5214aefe48382d97ef92b485e1df2f | creep1g/Datastructures-RU | /Recursiveprogramming/power.py | 473 | 4.0625 | 4 | def power(base, exp):
if exp == 0:
return 1
else:
return base * power(base, exp-1)
if __name__ == '__main__':
user_input = ""
while user_input != "q":
try:
user_input = input("Please enter two numbers(base, exp): ")
base, exp = user_input.split(", ")
... |
03c3fd54cdf49fcb5266082aa324bc6f68c89e9a | creep1g/Datastructures-RU | /PA2/recursion_base.py | 4,468 | 4.0625 | 4 | class Node:
def __init__(self, data = None, next = None):
self.data = data
self.next = next
def print_to_screen(head):
'''Recursively walks through linked list and prints out each elment'''
if head != None:
print(head.data, end=" ")
print_to_screen(head.next)
else:
... |
7ef1c1084463e2fce105ca1d1a66675ad36dee93 | creep1g/Datastructures-RU | /practice-tests/FinalExamSpring2020/P4/wait_list.py | 1,739 | 3.828125 | 4 |
class Student:
def __init__(self, id, name, phone, address):
self.id = id
self.name = name
self.phone = phone
self.address = address
def __str__(self):
return str(self.id) + " " + str(self.name) + " " + str(self.phone) + " " + str(self.address)
class F... |
58a57d8e6d9c6be4210d2def0d108275408f942e | wgibbons21/aoc2017 | /03/mwinn/day3.py | 4,549 | 3.96875 | 4 | # --- Day 3: Spiral Memory ---
#
# You come across an experimental new kind of memory stored on an infinite two-dimensional grid.
#
# Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up while
# spiraling outward. For example, the first few squares are allocated... |
59fc0aa6fdd890da20c22e654392fd9274b72c08 | Akash20x/Resize-label-dynamically-Tkinter | /check.py | 2,160 | 3.515625 | 4 |
from tkinter import*
from PIL import Image,ImageTk
from tkinter import Tk, Label, Button
from tkinter.filedialog import askopenfilename
import tkinter as tk
root = Tk() # Create main tkinter window
root.title("image edit")
root.geometry('1000x600+500+100')
root.resizable(False,False)
Tk().withdraw(... |
96e0c3a3e4e16ee9e2224560fa2d3d5a21b27f1a | n0phx/django-talkalot | /talkalot/utils.py | 483 | 3.765625 | 4 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
def is_date_greater(date_a, date_b):
"""Return whether date_a is greater than date_b. In case any of them is
None, treat the one with None as the lesser. If both of them are None,
date_a will not be considered as greater."""
if date_a is ... |
9208bc3b8e1ef3b6ef3e291d410057f926b0a2ac | kenedilichi1/calculator | /main.py | 917 | 4.15625 | 4 |
def add(x, y):
''' Adds 2 numbers '''
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
return x / y
isRunning = True
while isRunning:
choice = input("operator: ")
if choice in ('add', 'subtract', 'multiply', 'divide'):
num1 = fl... |
b93eb2ff91c82e78de6897661a41459f79762e60 | martasobota/python-tasks | /codility python 2.7/cyclic_rotation.py | 203 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def solution(A, K):
if len(A) == 0:
return 0
elif K == 0:
return A
else:
m = K % len(A)
return A[-m:] + A[:-m]
|
ae63e0649c95b820550cfe68d790cc63730e4c42 | martasobota/python-tasks | /daftcode/exercises_3/task_2.py | 1,774 | 3.96875 | 4 | """
Link to task description [PL]:
[zadanie 2]
https://github.com/daftcode/zajecia_python_mini_edycja3/blob/master/zajecia_3/praca_domowa/praca_domowa.txt
"""
class MyIter():
def __init__(self, *args):
print('__init__ called')
if len(args) == 0:
raise TypeError("At least 1 argument expe... |
daf18fa46afc67f775a964b02b7da316039a2b71 | martasobota/python-tasks | /daftcode/exercises_1/task_2.py | 610 | 3.6875 | 4 | ### Stworzyć listę 100 list, każda z liczbami od 0 do 100. Potem dla każdej j-tej z tych list wewnętrznych na jej końcu
### dodać sumę jej pierwszych j elementów. spodziewany efekt: [ [0, 1, 2, 3, ..., 100, 0], [0, 1, 2, 3, ..., 100, 1], [0, 1, 2, 3, ..., 100, 3], ..., [0, 1, 2, 3, ..., 100, 5050] ]
a = list(range(101... |
d3903302ada2d20f82fb117610ea44d90a6142de | martasobota/python-tasks | /misc/most_frequent_number.py | 924 | 4.0625 | 4 | # Find the most frequently occuring item in an array
def most_frequent(given_list):
max_item = None
item_occurences = 0
check = dict()
for n in given_list:
if n in check:
check[n] += 1
else:
check[n] = 1
if check[n] > item_occurences:
item_occ... |
5c148dc26bbcca22f2d2b2266f6cdcac6b102860 | XVR147/python1 | /Algorithms/mergesort.py | 730 | 4.0625 | 4 |
# Insertion sort between 2 arrays
array = [2, 8, 9, 4, 3, 6, 12]
def sort(a1):
if len(a1) > 1:
middle = len(a1)//2
half1 = a1[:middle]
half2 = a1[middle:]
sort(half1)
sort(half2)
i = 0
j = 0
k = 0
while i < len(half1) and j < len(half2)... |
2d36f51f6c5ffc29bdf2c2b7f92103175aa4231e | shahadatku/Python | /string_pattern.py | 144 | 3.9375 | 4 | string=input("Enter a string: ")
a=len(string)
for i in range(0,a):
for j in range(0,i+1):
print(string[i],end=" ")
print() |
bcf1a5c05759b1cf4040c6fddbbdbe4e92f9976d | Prithvi103/code-with-me | /Design Circular Deque {Medium}.py | 3,857 | 4.34375 | 4 | """
Design your implementation of the circular double-ended queue (deque).
Your implementation should support following operations:
MyCircularDeque(k): Constructor, set the size of the deque to be k.
insertFront(): Adds an item at the front of Deque. Return true if the operation is successful.
insertLast(): Adds an i... |
8a4a09865d205160bc4fdbcbedbd77e8d1f48124 | Prithvi103/code-with-me | /Longest Mountain in Array {Medium}.py | 2,314 | 4.125 | 4 | """
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold:
B.length >= 3
There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]
(Note that B could be any subarray of A, including the entire array A.)
Given an array A of int... |
d536cabbf0e41b9ca3e246ed9b8443dee1c1aca2 | CursedHD/PyTournament---Repeated-2x2-Games | /strategies/chris.py~ | 3,786 | 3.6875 | 4 | # Strategy: demo
# parameters: game (string), player (int), history (list of tupels)
# returns: "a" or "b" (string)
import random
import tournament
class chris:
def move(self, game, player, history):
# if history is empty, we are in the very first round. Let's cooperate!
if gam... |
4f9d8ee6ae7f821c6970192e089e8cf0f961ed3a | jenjohmar/superpy | /turnover.py | 2,933 | 3.765625 | 4 | import argparse
from helpers import *
# 1. variable bought_list gets the output (list) of get_bought(), sold_list gets the output (list) of get_sold() (with the date passed into get_inventory and exp_list get the ouput (list) of get_expired()
# 2. if user passes in "all" the turnover of complete inventory is disp... |
b0275f48df07915c5eb7bc42c46e2965676dbbc3 | Dima77711/Home_work | /165.py | 128 | 3.828125 | 4 | def palindrom(s):
if s[::1] == s[::-1]:
return True
else:
return False
print(palindrom("шалаш"))
|
d06db392c067cdc95065a603634f869b119a38dc | ghdwpaks/school | /dir2/p4.py | 129 | 3.65625 | 4 | a= "a:b:c:d"
b = a.split(":")
for i in range(len(b)) :
print(b[i],end="")
if i != len(b)-1 :
print("#",end="")
|
43acc8f815c76cb30ede74d78a9c70bfe5f44e3c | NElight/LearnPython2.7 | /yzg/MyClass.py | 639 | 3.625 | 4 | #!/usr/bin/python
#-*- coding:utf-8 -*-
class Employee:
empcount = 0
def __init__(self,name,salary):
self.name = name;
self.salary = salary
Employee.empcount += 1
def desplaycount(self):
print "total count %d" % Employee.empcount
def desplayemployee(self):
... |
326a62a85a831240ff0d0e66ef6e6f41e8ce395f | thsh77/data-wrangling | /filter/handlers.py | 4,412 | 3.640625 | 4 | class Handler:
"""
An object that handles method calls from the Parser.
The Parser will call the start() and end() methods at the
beginning of each block, with the proper block name as a
parameter. The sub() method will be used in regular expression
substitution. When called with a name such as... |
ba27cd264ee19bb103eb4d6c072ef632bb8a47b0 | Vladimir624/Python_base | /lesson2/lesson_2_homework.py | 1,496 | 3.625 | 4 | # Task_1
# simple_list = [55, 'Задание № 1', 44.5, None]
# print(simple_list)
#
# for simple in simple_list:
# print (f"{simple} == {type (simple)}")
# Task_2
# super_list = ['11', '22', '33', '44', '55']
# if len(super_list) % 2 == 0:
# i = 0
# while i < len(super_list):
# el = super... |
3ce6518f38c1439087e290c3a8fd001703e054f0 | EdithFelicia/SourceCodePraktikumAlpro | /71200645_STRING.py | 2,576 | 3.9375 | 4 | # Universitas Kristen Duta Wacana
# Edith Felicia Putri
'''
Ani dan Andi ingin membuat permainan kata. Dengan ketentuan
sebagai berikut.
a. Pilihan katanya hanya: teman dan pulang yang lower. Selain
itu user akan keluar dari program.
b. Kesempatan bermain hanya sekali.
c. Teman: Babak pertama dalam kalimat... |
f62bfabf432d8ff1a8ebd900e56215318e7c04ad | NoahBlack012/reference | /linked_lists.py | 2,534 | 3.921875 | 4 | class Node:
def __init__(self, value, next_node=None):
self.value = value
self.next_node = next_node
class LinkedList:
def __init__(self, head):
self.head = head
# Get data of element at given index
# O(n)
def read(self, index):
current = self.head
current_in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.