blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
61d4b86dcb0f9c266deaaaf52187786037526e6d | wroblewskiwojciech161/Studies | /python course/lab4/zad3.py | 1,837 | 3.734375 | 4 | """lista 4 zad3 Wojciech Wroblewski """
import random
class Node(object):
def __init__(self, value):
self.value = value
self.children = list([])
def insert_child(self, child):
self.children.append(child)
"""funkcja przechodzenia po drzewie bfs i dfs w zaleznsci od typu"""
def t... |
07a6ac427683854a9df8e5fcbde76e18fc476ee9 | christopherfan/Agile_learn_CI | /Python_CI_Test/k_means.py | 6,958 | 3.796875 | 4 | ###
# Implement simple k-means clustering using 1 dimensional data
#
##/
import unittest
from random import sample
###
# Helper functions
# Fill in TODOs where needed
##/
def pick_centroids(xs, num):
"""Return list of num centroids given a list of numbers in xs"""
###
# TODO select and return centroids ... |
1e4db6caa6915e23a3d4eab02342931b6629715f | IdeaventionsAcademy7/chapter-1-part-1-beginnings-Nikki1550 | /ch1_09.py | 263 | 3.65625 | 4 | # Nikki
# Problem #9
# Chapter 1 Problem Set Part 1
number_str = input ("Choose a number:")
number_int = int (number_str)
number_int = (number_int + 2)
number_int = (number_int * 3)
number_int = (number_int - 6)
number_int = (number_int / 3)
print (number_int)
|
37e1437fadc98301cf300ed47beca51e5733411f | chungbuk-machine-learning-team10/score_program | /grade_program--2.py | 2,109 | 3.71875 | 4 | class Student :
def __init__ (self) :
self.hakbunlist = []
self.namelist = []
self.korlist = []
self.englist = []
self.mathlist = []
flag = True
print("프로그램을 종료하려면 학번에 '0'을 입력하시오")
while flag:
hakbun = input("학번을 입력하시오 : ")
... |
5acb2dd33df9b6578ff1c9f0c471048c7000a4bc | FurkS/TextAdventure | /text_adventure.py | 10,852 | 4.09375 | 4 | import time #Imports a module to add a pause
#Figuring out how users might respond
answer_A = ["A", "a"]
answer_B = ["B", "b"]
answer_C = ["C", "c"]
yes = ["Y", "y", "yes"]
no = ["N", "n", "no"]
back = ["Back", "back"]
shoot = ["Shoot", "shoot"]
#Grabbing objects
key = 0
torch = 0
knife = 0
gun = 0
required = ("\nY... |
18024f87b8e7ba9b64a40a02343160a6e975b870 | Beks667/exam4 | /exam4_4.py | 257 | 3.609375 | 4 | def summa(numbers):
result = 0
while numbers> 0:
result += numbers % 10
numbers //= 10
return result
print(summa(1234567895))
# print(sum(map(int, list(input('insert numbers and i sum it:'))))) |
b06d6984f020ad6cba8256b81ae5c3b70f6916bd | facetrollex/msdp-python-homework | /guess_the_number.py | 339 | 3.890625 | 4 | import random
randomNumber = random.randint(1, 100)
userNumber = -1
while userNumber != randomNumber:
print('I made up a number. Can you guess it?')
userNumber = int(input())
if userNumber < randomNumber:
print('Too low!')
elif userNumber > randomNumber:
print('Too high!')
print('Congrat... |
539fadb2fc145e48a70950cd77d804d77c9cec07 | roachaar/Python-Projects | /national debt length.py | 1,937 | 4.5 | 4 | ##############################################################################
# Computer Project #1: National Debt
#
# Algorithm
# prompt for national debt and denomination of currency
# user inputs the above
# program does simple arithmetic to calculate two pieces of informati... |
96723c4e759019d845f9fe2f1220f7317d35b9d4 | roachaar/Python-Projects | /simple drawing of shapes.py | 3,481 | 4.46875 | 4 | ##############################################################################
# Computer Project #2: Drawing Randomly Colored Figures
#
# Algorithm (after importing turtle, random, and time)
# prompt for circles or squares
# squares:
# 1: enter a side length to start with
... |
18f7e659448c5edcc16473887ab25bdacad67d4c | stephub-gitchmond/FirstRoguelike | /src/attrs/movable.py | 403 | 3.609375 | 4 | from attrs import Attr
class Movable(Attr):
""" Flags that the given object can move """
def __init__(self):
Attr.__init__(self)
def selfmover(self):
""" Returns True if the object can move under it's own power """
return False
class MovableCreature(Movable):
def __init__(s... |
3597d031334cadd8da79740431f5941c2adb38c5 | BeryJAY/Day4_challenge | /power/power.py | 531 | 4.34375 | 4 | def power(a,b):
#checking data type
if not((isinstance(a,int) or isinstance(a,float)) and isinstance(b,int)):
return "invalid input"
#The condition is such that if b is equal to 1, b is returned
if(b==1):
return(a)
#If b is not equal to 1, a is multiplied with the power function and call... |
f81d22a631aa744f24c3b1122c2932de2318accc | Amos94/Sort-the-odd | /solution.py | 407 | 3.578125 | 4 | def sort_array(source_array):
for i in range(0, len(source_array)):
for j in range(i, len(source_array)):
if(source_array[i] % 2 == 1 and source_array[j] % 2 == 1):
if(source_array[j] < source_array[i]):
aux = source_array[i]
source_array[... |
b62533f4a5449d0ae6b06e206770f76553d463bf | bhaveshmunot1/RecViz | /visualizer.py | 2,027 | 3.578125 | 4 | import inspect
import RecViz
def fib(n):
x = RecViz.EnableLogging(inspect.currentframe())
if(n==0):
return x.LogAndReturn(0)
elif(n==1):
return x.LogAndReturn(1)
return x.LogAndReturn(fib(n - 1) + fib(n - 2))
def binary_search(value, items, low=0, high=None):
"""
Binary searc... |
511d35743234e26a4a93653af24ee132b3a62a7a | AntoanStefanov/Code-With-Mosh | /Classes/1- Classes.py | 1,465 | 4.6875 | 5 | # Defining a list of numbers
numbers = [1, 2]
# we learned that when we use the dot notation, we get access to all methods in list objects.
# Every list object in Python has these methods.
# numbers.
# Wouldn't that be nice if we could create an object like shopping_cart and this object would have methods
# like this:... |
a8f7dceb7daec1a665e215d9d99eeb620e73f398 | AntoanStefanov/Code-With-Mosh | /Exceptions/7- Cost of Raising Exceptions.py | 1,849 | 4.5 | 4 | # As I explained in the last lecture, when writing your own functions,
# prefer not to raise exceptions, because those exceptions come with a price.
# That's gonna show you in this lecture.
# From the timeit module import function called timeit
# with this function we can calculate the execution time of some code.
# ... |
1f7f8382c688f22fe10e8057185ce55307c90b1d | AntoanStefanov/Code-With-Mosh | /Exceptions/4- Cleaning Up.py | 706 | 4.375 | 4 | # There are times that we need to work with external resources like files,
# network connections, databases and so on. Whenever we use these resources,
# after, after we're done we need to release them.
# For example: when you open a file, we should always close it after we're done,
# otherwise another process or anoth... |
009d8caa7fcf17ee98126408602345c5e5d40382 | pedrolisboaa/pythonpro-pythonbirds | /pythonBrasil/EstruturaDeDecisao/salario.py | 1,226 | 3.65625 | 4 | class Salario:
def __init__(self, salario):
self.salario = salario
self.novo_salario = None
self.percentual = None
self.valor_aumento = None
def realizar_aumento_salarial(self):
if self.salario < 281:
self.percentual = 20
self.valor_aumento = self... |
91dc1d2f54c0cf7ad75ff9f9449b5c46051c4b4c | pedrolisboaa/pythonpro-pythonbirds | /exercicios/busca_linear.py | 616 | 4.125 | 4 | """
Crie um programa que recebe uma lista de inteiros e um valor que deve ser buscado.
O programa deve retornar o índice onde o valor foi encontrado, ou -1, caso não encontre o valor.
"""
tamanho_lista = int(input('Digite o tamanho da sua lista:'))
lista = []
for i in range(tamanho_lista):
inserir_lista = int(in... |
daef9e7f7e8544aa0d4171a688be9b024b82e2e6 | pedrolisboaa/pythonpro-pythonbirds | /1 - Tipos Básicos/condicoes.py | 215 | 3.96875 | 4 | idade = 3
if idade >= 18:
print('Maior de de idade')
else:
print(f'Menor de idade')
idade = 65
if idade <= 18:
print('Maior de de idade')
elif idade > 60:
print(f'Idoso')
else:
print('Adulto') |
e4c08b5c3ea3a3cf02bf42f0ae0cd4eb69325d70 | pedrolisboaa/pythonpro-pythonbirds | /exercicios/busca_binaria.py | 1,078 | 4.03125 | 4 | """
Escreva um programa que cria uma lista de 100 números aleatórios inteiros ordenados e solicita
um número para o usuário. Use a busca binária para encontrar a posição do número fornecido na lista,
ou retorne -1 se ele não for encontrado.
"""
#Funções
def numero_aleatorio():
from random import randint
nume... |
a71f1a3638ea6e2315b52e9070f9b78b3a9984db | daria-andrioaie/Fundamentals-Of-Programming | /a10-911-Andrioaie-Daria/test_iterable.py | 3,563 | 3.625 | 4 | import unittest
from iterable_data_structure import Iterable
class TestIterable(unittest.TestCase):
def setUp(self):
self._my_collection = Iterable()
self._my_collection.append(4)
self._my_collection.append(1)
self._my_collection.append(5)
def test_get_item(self... |
a12230a5edc331e0989940c8ecd1243b9415aba9 | daria-andrioaie/Fundamentals-Of-Programming | /a12-911-Andrioaie-Daria/main.py | 2,983 | 4.46875 | 4 | from random import randint
from recursive import recursive_backtracking
from iterative import iterative_backtracking
def print_iterative_solutions(list_of_numbers):
"""
The function calls the function that solves the problem iteratively and then prints all the found solutions.
:param list_of_num... |
962b1861914c884ad8e1da4db8c1bc0b4d117225 | daria-andrioaie/Fundamentals-Of-Programming | /e2-911-Andrioaie-Daria/Domain/Flight.py | 807 | 3.59375 | 4 | class FlightException(Exception):
def __init__(self, msg):
self._msg = msg
class Flight:
def __init__(self, id_, departure_city, departure_time, arrival_city, arrival_time):
self._id = id_
self._departure_time = departure_time
self._departure_city = departure_city
... |
41891f9a090ead7873bf5c006f423238a48f05db | daria-andrioaie/Fundamentals-Of-Programming | /a12-911-Andrioaie-Daria/iterative.py | 2,158 | 4.5 | 4 | from solution import is_solution, to_string
def find_successor(partial_solution):
"""
The function finds the successor of the last element in the list.
By "successor" of an element we mean the next element in the list [0, +, -].
:param partial_solution: array containing the current partial so... |
410ad24612645ded58ac678b81db7e981da9ff3c | pollardk123/lab-06-review- | /saytwice.py | 71 | 3.8125 | 4 | word = input("Give me a word to say twice.")
print(word + " " + word)
|
45c9890c07838bf15ef11a6edacd36c3600470fd | Toyib32/Python-Projects-Protek- | /Chapter05_Praktikum2_no13.py | 185 | 3.625 | 4 | from random import randint
toyib = 0
while True:
bil = randint(0, 10)
print(bil)
toyib = toyib + 1
if bil == 5:
break
print("Jumlah perulangan : " + str(toyib))
|
aa0ea77df7e398e6c64c93e329a3bb2b5892318d | Toyib32/Python-Projects-Protek- | /program03_Praktikum05.py | 852 | 3.75 | 4 | # lakukan input
bIndo = int(input("Masukkan nilai Bahasa Indonesia :"))
ipa = int(input("Masukkan nilai IPA :"))
matematika = int(input("Masukkan nilai Matematika :"))
# lakukan cetak
print("-------------------------------------"+"\n")
if(bIndo >= 60) and (ipa >= 60) and (matematika >= 70):
p... |
40098e9797724adeefa8080a832fb2befdb0fde7 | Toyib32/Python-Projects-Protek- | /Program05_praktikum05.py | 5,992 | 3.5625 | 4 | # keterangan jumlah gaji pokok berdasarkan golongan
A = 10000000
B = 8500000
C = 7000000
D = 5500000
# keterangan jumlah potongan berdasarkan golongan
potA = 2.5
potB = 2.0
potC = 1.5
potD = 1.0
# tunjangan karyawan dan status
tunjanganIstriSuami = 10
tunjanganAnak = 5
# lakukan input
kodeKaryawan = input("Masukkan... |
173e532f193c14a0bd2c5cdc1ddd02e9b19dc708 | Toyib32/Python-Projects-Protek- | /Program02_Praktikum05.py | 584 | 3.75 | 4 | # lakukan input
bIndo = int(input("Masukkan nilai Bhs Indonesia :"))
ipa = int(input("Masukkan nilai IPA :"))
matematika = int(input("Masukkan nilai Matematika :"))
# lakukan cetak
print("-------------------------------------"+"\n")
if(bIndo < 0) or (bIndo > 100) or (ipa < 0) or (ipa > 100) or... |
71a0292fec7a8780c4463f20ff7c25ae979566ff | TinlokLee/Algorithm | /quick_sort.py | 677 | 3.859375 | 4 | def quickSort(li):
arr = []
low = 0
high = len(li) - 1
if low < high:
mid = partition(li, low, high)
if low < mid - 1:
arr.append(low)
arr.append(mid - 1)
if mid + 1 < high:
arr.append(mid + 1)
arr.append(high)
w... |
467d03fd9fff4c3ce6e5d343b1ea314842a5916d | dandung2012/treasure-island-start-1 | /main.py | 2,089 | 3.65625 | 4 | print('''
_ _ _ _
| | (_) | | | |
| |_ _ __ ___ __ _ ___ _ _ _ __ ___ _ ___| | __ _ _ __ __| |
| __| '__/ _ \/ _` / __| | | | '__/ _ \ / __| |/ _` | '_ \ / _` |
| |_| | | __/ (_| \__ \ |_| | | | __/ \__ \ ... |
92770e13dfdf209d1ebd7df83c12711544059961 | fedeserral/patho_pdb_domain | /MOAD_PDBIND/toMolar.py | 400 | 3.734375 | 4 | import math
def toMolar(valor,unidad):
"""Toma una concetracion y su unidad para convertirla a Molar y calcular su logaritmo negativo"""
units_convertion={
"M^-1":0.1,
"M":1,
"mM":0.001,
"uM":0.000001,
"nM":0.000000001,
"pM":0.000000000001,
"fM":0.0000000... |
3d1aa38d0fec00ba3d6f14bf02a9e89b750ecc04 | pf4d/issm_python | /issm/holefiller.py | 1,405 | 3.625 | 4 | import numpy as np
from scipy.spatial import cKDTree
def nearestneighbors(x,y,data,goodids,badids,knn):
'''
fill holes using nearest neigbors. Arguments include:
x,y: the coordinates of data to be filled
data: the data field to be filled (full field, including holes)
goodids: id's into the vertices that ha... |
df439bb9e90ea98b0af05f6166b92309345be375 | pf4d/issm_python | /issm/expwrite.py | 1,407 | 3.65625 | 4 | import numpy as np
def expwrite(contours,filename):
"""
EXPWRITE - write an Argus file from a dictionary given in input
This routine writes an Argus file from a dict containing the fields:
x and y of the coordinates of the points.
The first argument is the list containing the points coordinates
and... |
a2decc917e89781b6e68985d3a498f7d8f277c58 | gringonivoli/tdd-own-stuff | /prime_numbers/prime_numbers.py | 284 | 3.5625 | 4 | from typing import List
from prime_numbers.int import Int
class PrimeNumbers:
def __init__(self, numbers: List[int]):
self._numbers = numbers
def __iter__(self):
for number in self._numbers:
if Int(number).prime():
yield number
|
cfeb817c096d6ef18cc2ce3a3309b089657d62d9 | Digital-Turnstile/Katas | /python/sumOfList.py | 164 | 3.59375 | 4 | #by Max
def get_sum(a,b):
if(b < a):
temp = a
a = b
b = temp
sum = 0
for i in range(a, b + 1):
sum += i
return sum
|
5acd3a00c3f55ed88b9d5e531b90df4bc378c9c8 | susnchen/CavernEscaper | /main.py | 22,114 | 4.03125 | 4 | #Game created for grade 10 Computer Science Summative
#By: Susan Chen, Ashley Yim, and Lauryn Seto
#For: ICS2O1, Ms. Valin
import pygame
from pygame import *
import random
#These are the settings of the game
pygame.init()
timecounter = 0
x = 40
timearray = [1500,1450,1400,1350,1300,1250,1200,1150,1100,1050,1000,950,90... |
14f9a0cda50b98077b8101b763b331426a8e9265 | ThreeSRR/BayesianNetwork | /BayesianNetworks.py | 8,181 | 3.515625 | 4 | import numpy as np
import pandas as pd
from functools import reduce
## Function to create a conditional probability table
## Conditional probability is of the form p(x1 | x2, ..., xk)
## varnames: vector of variable names (strings) first variable listed
## will be x_i, remainder will be parents of x_i, p1, ... |
65708f13c0f9818de52ddc81892ad680e417471f | xDacKer/Python-Projects | /Casino Blackjack App.py | 20,365 | 4.1875 | 4 | #!/usr/bin/env python3
#Classes Challenge 37: Casino Blackjack App
import random
class Casino():
"""Class to create a casino"""
def __init__(self, wallet):
"""Initialize attributes"""
# Wallet to change "money for chips"
self.wallet = wallet
def display_info(self):... |
fca81bf6d3894bdbfd8a718a636081fe9824375d | briannaf/aoc2020 | /day_6/day6_part2.py | 998 | 3.96875 | 4 | # AOC 2020,
# Day 6, Part 2
# Objective: Same input list and same objective as part one, but instead of the
# sum including each question at least one group member has answered 'yes'
# to, it must instead include how many questions every group member answered
# 'yes' to.
import string
from day6_part1 import pa... |
dd50f24e95058c9cf0046a4a69b3ed50977decee | briannaf/aoc2020 | /day_11/day11_part1.py | 2,592 | 3.734375 | 4 | # AOC 2020,
# Day 11, Part 1
# Objective: This puzzle seems to be like Conway's game of life, but with
# different rules.
# The input is a seating chart. '.' represents floor, 'L' represents empty
# seats, and '#' represents an occupied seat.
# Rules:
# - An empty seat with no occupied seats adjacent to it bec... |
a56266a1d5ec62816d6f297a084f6e6b9f8bccca | vvitsenets/Exercise | /ex2_final.py | 976 | 3.515625 | 4 | import matplotlib.pyplot as plt
#from scipy.misc import derivative
def func(x):
y = (x - 5)**2
return y
def derivative(y):
z = 2 * (y - 5)
return z
#def plot():
# a = []
# b = []
# for x in range(-30,30):
# y = (x - 5)**2
# a.append(x)
# b.append(y)
# plt.plot(a, b)
... |
8932cec86e113e828bee24ee4c2446561c3920fd | debanehita/gisp2019 | /db_conn_test.py | 2,630 | 3.625 | 4 | """
This program implements functions to get a data source from either a PostgreSQL database or a geoserver instance (GeoJSON)
"""
def get_data_from_postgres(conn, qry):
"""
Gets a list of 'DictRows' from a PostgreSQL database. A DictRow can be indexed numerically or by column name, In other
words it beha... |
f4c136c7b02571ac53cc24628bab5da3f297b244 | Wellington-Black/classes_lab_2- | /bus_lab_start_code/src/bus.py | 1,083 | 3.53125 | 4 | class Bus:
def __init__(self, route_number, destination):
self.route_number = route_number
self.destination = destination
self.passengers = []
def drive(self):
return "Brum brum"
def passenger_count(self):
return len(self.passengers)
def pick_up(s... |
188f40751d81ea50ccd4575e6a0bf1b09c31ab49 | zaeemyousaf/zaeem | /softDevelopement/memoryTest_1.0_python/MemoryTest_Functions.py | 7,346 | 3.96875 | 4 | ''' Author: Zaeem Yousaf
Email: quaidzaeem@gmail.com
Date: 01-02-2017
version: 1.0
python: 3
Teacher: Sir Naghman at PakTurk
'''
''' Function list
1): mkCards(n,types) returns an array of size n, contains 'types' types of data
2): mkGrid(cardsArray,rows,cols) returns two dimensional array of size 'rows' and 'columns'... |
8d496315e98ce7d62cb80a170db65e7ed457a62f | ubante/poven | /projects/odds/nba_finals.py | 1,588 | 3.609375 | 4 | from __future__ import print_function
import random
from collections import defaultdict
iterations = 999
odds_game_for_t1 = 0.90
win_count = defaultdict(int)
for i in range(1, iterations+1):
print("Iteration #{0:2}: ".format(i), end="")
t1_wins = 0
t2_wins = 0
scores = ""
game_number = 1
w... |
19427a712ae5bc8eafdb273e2d078c9226e9683b | ubante/poven | /projects/cached_results/somethinglib.py | 4,502 | 3.765625 | 4 | import sys
import time
class Cache:
def __init__(self, ttl=10):
self.list = []
self.single_value = None
self.insertion_time = None
self.expiration_time = None
self.ttl = ttl
def is_expired(self):
if not self.expiration_time:
return True
now... |
16eecae1f8156d8b6d98566674c77d8e9d102953 | ubante/poven | /projects/math/primcal.py | 655 | 3.9375 | 4 | """
From http://www.murderousmaths.co.uk/games/primcal.htm
"""
def prime_number_trick():
# The first 25 primes
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
83, 89, 97]
print "The columns are (prime, squared, plus 17, modulo 12)"
for prime ... |
f4228338d9560f019955e0e2a1c1871e210f7104 | ubante/poven | /projects/graph/graph.py | 4,950 | 4.25 | 4 | #!/usr/bin/env python
from __future__ import print_function
import sys
from pydotting import PyGraph
"""
This is a bidirectional graph of nodes.
I found this helpful:
https://www.codefellows.org/blog/implementing-a-singly-linked-list-in-python/
https://github.com/johnshiver/algorithms/blob/master/linked_list/linke... |
a24d6e2e38cf7fb33c50e2c344c7cf7ab687e232 | lincherryz/weatherApp | /src/weather_api.py | 5,358 | 4.5625 | 5 | from configparser import ConfigParser
import requests
from datetime import datetime
import calendar
"""
WRITEUP FOR USE
---------------------
get_today_weather(ZIP, COUNTRY)
-for this function, you have to pass in a zipcode and country abbreviation.
-It returns "final" which is the city, country, temp_fahrenhei... |
72a8b533936f7f30007706f07679af73a8754c20 | GOD-A01375315/Tarea-07-2 | /listaParejas.py | 718 | 3.875 | 4 | #encoding: UTF-8
#Autor: Genaro Ortiz Durán
#Hacer una funcion que tome como entrada una lista y regrese cada pareja de datos intercambiados.
def intercambiarDatos(lista):
Lista=[]
if len(Lista)%2==0:
for i in range(0,len(lista)-1,2):
Lista.append(lista[i+1])
Lista.append((list... |
85a98bc99cb510db0d943feb5ced2b072ddbf7e5 | Angelpacman/ambiental-matlab | /capitulo_01/ejercicio_09_identidades_trigonometricas.py | 498 | 3.5625 | 4 | ##% ##%elaborado por Resendiz Aviles Jose Angel
from math import *
import numpy as np
x = 5*pi/24
##% ecuacion(a)
lado_izquierdo1 = sin(2*x)
lado_derecho1 = 2*sin(x)*cos(x)
##% ecuacion(b)
lado_izquierdo2 = cos(x/2)
lado_derecho2 = sqrt( (1+cos(x)) / 2)
def comparacion(Li,Ld):
if Li == Ld:
... |
6b5c1983a4830b0bfaab76c4b0aa132aab61da1a | abcapo/Computacion-2019 | /58089-Agustina-Capo/clase 2/ronam_numbers.py | 2,021 | 3.65625 | 4 | def roman_to_decimal(roman_number):
if roman_number=='I':
return 1
else:
return 2
def roman_to_decimal(roman_number):
decimal-number=0
for letter in roman_number:
if letter == 'I':
decimal-number= decimal-number + 1
if letter == 'V':
decimal-number... |
e20694d9bda88d6ef5e163ae5036dd6824c37c77 | harvey345/convert-temperature | /C_T.py | 249 | 3.6875 | 4 | ct=input("(1):華氏~攝氏 (2):攝氏~華氏 :\n")
if ct=="1":
tem=float(input("請輸入現在溫度: "))
print("攝氏", (tem-32) * 9/5,"度")
else:
tem=float(input("請輸入現在溫度: "))
print("華氏",tem * 9/5 + 32,"度") |
95ed69215345ded0a6a3691331be66f0c202401f | ayushdhumal/Leetcode-Problems | /Easy problems/Convert BST to Greater Tree [Python Solution].py | 873 | 3.640625 | 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 convertBST(self, root):
#Getting the value of nodes in an ascending way(inorder traversal) and storing 'em in an array
de... |
dde6edfc3e9e6ca42573c1d98162ab1b3c79d993 | m1nus0ne/poker | /Scripts/Card/Card.py | 512 | 3.734375 | 4 | from enum import IntEnum, Enum
class Card(object):
def __init__(self,suit: Enum, value: Enum):
self.suit = suit
self.value = value
def __str__(self):
return '{} of {}'.format(self.value.name,self.suit.name)
class Value(Enum):
two = 0
three = 1
four = 2
five = 3
six =... |
697eefb4cbfa8e85495d2f1fda828584f2c073d6 | Jeans212/Named-Entity-Recognition | /entity_naming.py | 1,805 | 3.890625 | 4 | """
This is the 'entity_naming' module.
Named entities help us understand more about what is being
referred to in a given text so that we can further classify the data.
Since named entities comprise more than one word,
it is sometimes difficult to find these from the text.
"""
# importing libraries
from p... |
eda0bd97444c998711093db45b3b7de02b3af661 | yusufa84/PythonBaseCamp | /Assignments/palindrome.py | 412 | 3.796875 | 4 | def palindrome(s):
#Better way of doing the test
return s == s[::-1]
''' Not so better way of doing the same thing
count = 0
flag = True
while count < len(s):
# print('Char: %s, s[len(s)-1]: %s' %(s[count],s[len(s)-count-1]))
if s[count] != s[len(s)-count-1]:
return Fa... |
b16d4f96607325b7b429bf04ddeb2f4529a99b14 | xthebat/iu4-2k21-mlni | /ya-flyingbat/sem07/layers.py | 1,669 | 3.53125 | 4 | import numpy as np
from numpy import ndarray
from utils import softmax, to2d
class Layer(object):
def forward(self, x: ndarray) -> (ndarray, ndarray):
raise NotImplementedError
def inputs(self) -> int:
raise NotImplementedError
def outputs(self) -> int:
raise NotImplementedErr... |
55ff9d1d1023e612939f8c93ad1d47ebc78ba1b3 | xthebat/iu4-2k21-mlni | /ya-flyingbat/sem07/visualization.py | 431 | 3.5 | 4 | import numpy as np
from matplotlib import pyplot as plt
def points(start, end, n):
inputs = []
for x in np.linspace(start, end, n):
for y in np.linspace(start, end, n):
inputs.append((x, y))
return np.array(inputs).transpose()
def visualize(inputs, outputs):
x = inputs[0, :]
... |
f0cca0b80d04f9da92a1858f9301a146940bc176 | Ricky-Lim10/Mean-Median-Mode | /MMM.py | 341 | 3.609375 | 4 | import statistics
import pandas as pd
df=pd.read_csv("SOCR-HeightWeight.csv")
data=df["Height(Inches)"].tolist()
data=df["Weight(Pounds)"].tolist()
mean=sum(data)/len(data)
median=statistics.median(data)
mode=statistics.mode(data)
print("The mean is:", mean)
print("The median is:",median)
print("The mod... |
82a71eece0293936cf4d85e357e7763362d6b32e | JacyntaRyan/clientServers-Python | /server1.py | 1,453 | 3.546875 | 4 | import socket
import sys
# checks all characters are letters and that the first letter is uppercase
def is_valid(data):
return data.isalpha() and data[0].upper() == data[0]
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Bind the socket to the port
# to listen to all address... |
b3ea210f0b0f3a421aecac2e50d2337f3dacc7f9 | SALib/SALib | /src/SALib/util/util_funcs.py | 3,906 | 3.515625 | 4 | import pkgutil
import csv
import numpy as np
def avail_approaches(pkg):
"""Create list of available modules.
Parameters
----------
pkg : module
module to inspect
Returns
-------
method : list
A list of available submodules
"""
methods = [
modname
... |
2a106a0cc21ed6bd2ec5dcf2f8b69e9fd74bd74b | Helen-Sk-2020/Loan_Calculator | /Topics/For loop/Speech generation/main.py | 164 | 3.90625 | 4 | number = input()
numbers = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
for x in number:
x = numbers[int(x)]
print(x)
|
cadf064f80d6485f87c26aa35748cada35533fa8 | Helen-Sk-2020/Loan_Calculator | /Topics/Elif statement/Particles/main.py | 312 | 3.828125 | 4 | s = input()
e = input()
if s == '1/2' and e == '-1/3':
print("Strange Quark")
elif s == '1/2' and e == '2/3':
print("Charm Quark")
elif s == '1/2' and e == '-1':
print("Electron Lepton")
elif s == '1/2' and e == '0':
print("Neutrino Lepton")
elif s == '1' and e == '0':
print("Photon Boson")
|
877f397f3d0597e27fd468aea42dea909e604a2a | Helen-Sk-2020/Loan_Calculator | /Topics/Elif statement/What day is it/main.py | 142 | 3.640625 | 4 | offset = float(input())
time = 10 + offset
if time < 0:
print('Monday')
elif time < 24:
print('Tuesday')
else:
print('Wednesday')
|
4487ac47b06147e0ef009f838c2d6edda6aa3a73 | Greck-18/Test | /main.py | 9,192 | 4.09375 | 4 | import sqlite3
from abc import abstractmethod,ABC
class University(ABC):
'''Абстрактный класс'''
#инициализация бд
_database="university.db"
try:
_connection=sqlite3.connect(_database)
except sqlite3.Error:
raise Exception("You have problem")
_cursor=_connection.cursor()
... |
b54a2006c3bbcbe4bc6573f4e167b8a65544efb6 | sunn-e/mirrorme | /mirrorme.py | 295 | 3.515625 | 4 |
#!pip install pywebcopy
from pywebcopy import save_website
print("Which website you want to mirror?:\n")
_url = input()
print("And where do you want to save it? Insert the path to the folder:\n")
_project_folder = input()
save_website(
url = _url,
project_folder = _project_folder
)
|
45116cfd21edba76d784b511ec1d34ffb962ee05 | atul4595/Python_Practice | /Practice/Function.py | 1,303 | 3.578125 | 4 | # def pos_neg_sort(list1):
# A = list1
# for i in range(0, len(A) - 1):
# if A[i] < 0:
# continue
# for j in range(i + 1, len(A)):
# if A[j] < 0:
# continue
# else:
# if A[i] > A[j]:
# temp = A[i]
# ... |
298130bc268c055660480b7f37b446095ee7e98e | rschwa6308/Arithma | /Check.py | 6,632 | 3.53125 | 4 | # check board
# takes a list of pieces and one piece within the list and returns #of neighbors it has
def get_neighbors(pieces, piece):
neighbors = []
for rest in pieces: # lol rip
if max(abs(piece.grid[0] - rest.grid[0]), abs(piece.grid[1] - rest.grid[1])) == 1 and abs(
piec... |
a91e1f92004336c5a93efca13087a12e245c5a21 | Fillipedem/N-Queens-EA | /survivalselection.py | 2,962 | 3.671875 | 4 | from random import randint
from random import uniform
class SurvivalSelection:
def __init__(self, elitism = 8):
self.elitism = 8
def set_elitism(self, elitism):
cls.elitism = 8
def select_survivals(self, population, offspring, parents):
pass
class ReplaceWorst(SurvivalSelection... |
db4ed9f91883316cee7852ac28b0717b74ceb398 | Roshan021198/Assignment-4 | /ex2.py | 177 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 20 01:06:55 2020
@author: ROSHAN
"""
import math
y = int(input("Enter value for y"))
print(2-(y*math.exp(2*y))+(4*y))
|
44f9d77bd8e1aa4cba920a7b90488e833a30ce1f | alinaka/stepik-algorithms-course | /divide_and_conquer/count_sort/__init__.py | 661 | 3.65625 | 4 | import sys
def count_sort(numbers, n, M):
helper = [0 for _ in range(M + 1)]
result = [0 for _ in range(n)]
for number in numbers:
helper[number] += 1
for i in range(2, len(helper)):
helper[i] = helper[i] + helper[i - 1]
for j in range(n - 1, -1, -1):
result[helper[numbers[... |
a2de874eca7fffcefd2fbf3960d355aafb32b61f | Johnpaul90/python | /isogram.py | 374 | 3.859375 | 4 | def is_isogram(word):
if word == "":
return (word, False)
elif type(word) != str:
raise TypeError("Argument should be a string")
else:
#Now doing the real stuff :p
for i in word:
if word.count(i)>1:
return (word, False)
r... |
3ba27826a1808a5c7e06424cc434d3a8534ca6e5 | iamparul08/Hands-on-P2 | /tuple1_ADID.py | 450 | 4.03125 | 4 |
#printing the elements in tuple
mytuple1_ADID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
print("Values in tuple")
for i in range(len(mytuple1_ADID)):
print(mytuple1_ADID[i])
#adding 100
print("adding 100 to this tuple after converting into list")
#mytuple1_ADID[1] = 100
#since tuple is immutable datatype
l1... |
ccc9c6486d44fcfd8f3b024be73db79a807b6127 | pondjames007/CodingPractice | /BinaryTree/671_2ndMinNode.py | 1,908 | 3.828125 | 4 | # TIPS:
# Go through the tree and find out the minimum val except root
# slow
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def findSecondMinimumValue(self, root: TreeNode) -> int:
... |
900a239663e20818a914149ff081d640c6836aba | pondjames007/CodingPractice | /BinaryTree/951_FlipEquivalentBinaryTrees.py | 568 | 3.84375 | 4 | # TIPS:
#
# Recursive
# check recursively if (1.left == 2.left and 1.right == 2.right) or (1.left == 2.right and 1.right == 2.left)
class Solution:
def flipEquiv(self, root1: TreeNode, root2: TreeNode) -> bool:
if not root1 or not root2:
return root1 == root2
if root1.val != root2.val:
... |
29d20cd7b8d26ea48778e41d35d7c6119c87b3d4 | pondjames007/CodingPractice | /HashTable/676_MagicDictionary.py | 2,507 | 3.703125 | 4 | # TIPS:
# * Use TRIE : SUPER SLOW
# *
# TRIE implementation (not good)
class MagicDictionary:
def __init__(self):
"""
Initialize your data structure here.
"""
self.root = {}
def buildDict(self, dict: List[str]) -> None:
"""
Build a dictionary through a list of... |
d29b9a31e37654e9bca95acc3f6815fad0868cee | pondjames007/CodingPractice | /Geometry/056_MergeIntervals.py | 532 | 3.703125 | 4 | # TIPS:
# check start and end
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
if not intervals: return []
intervals.sort()
ans = [intervals[0]]
index = 0
for start, end in intervals[1:]:
if start <= ans[index][1]:... |
8c6ee32edc5131c47202eceef78a1bbce6f4a56d | pondjames007/CodingPractice | /Greedy/628_MaxProductOfThreeNums.py | 558 | 3.6875 | 4 | # TIPS:
# sort the array
# if nums[-1](max) > 0:
# nums[-1] & (nums[0] & nums[1]) or nums & nums[2] & nums[3]
# if nums[-1] <= 0:
# nums[0] & nums[1] & nums[2]
class Solution:
def maximumProduct(self, nums: List[int]) -> int:
if not nums: return 0
nums.sort()
if nums... |
fcbe59dd47089512f73b75e3ffda9610a520bde4 | pondjames007/CodingPractice | /String/792_NumberOfMatchingSubsequences.py | 1,086 | 3.59375 | 4 | # TIPS:
# * subsequence: letter order matters
# * bisect: use binary search in a SORTED list
# * bisect.bisect_left(list, x): return the index that can insert x in list, if x is in list, it will return the index at left
# * bisect.insort_left(list, x): insert x into the ordered list
#
# * go through the dictionary and ... |
cf59eee8e3004b3611a1c1a81ced8dd1944c4b68 | pondjames007/CodingPractice | /Graph/685_RedundantConnectionII.py | 1,744 | 3.59375 | 4 | # TIPS:
#
# Case 1: No Duplicate Parents -> Same to #684
# Case 2: A node v has 2 parents (u1, u2)
# 2.1: No cycle -> return the second edge that creates duplicate parents
# 2.2: Cycle -> return {u1, v} or {u2, v} that creates the loop
class Solution:
def findRedundantDirectedConnection(self, edges: Lis... |
a43a94fda2b1a6ff937b0ab5df42f12fff90bde1 | sal-7/OMIS485 | /Python_chapter 4/A_temperature.py | 1,206 | 4.125 | 4 | """ /***************************************************************
OMIS 485 P120 - Ch4 Spring 2019
Programmer: Faisal Alharbi, Z-ID 1748509
Date Due:04/07/2018
Tutorials from Chapter 4 - Temperature Exercise.
***************************************************************/"""
#!/usr/bin/env p... |
e1ea6e9417bbb3ecf7690c262ff17e5a8848459f | lkaae2018/Modul2.1 | /tid/tid_time.py | 457 | 3.765625 | 4 | import time;
a=1
tid=time.time()
print ("tiden er:", tid)
print("Groen")
while a==0:
if time.time()-tid >=3:
a=1
tid=time.time()
print ("Gul")
else:
a=0
while a==1:
#
if time.time()-tid >=1:
a=2
tid=time.time()
print("Raed")
else:
a=1
whi... |
73d7eb4d0ebb3dc72e83db2db1f8f1c933049ce7 | pravin-25/DS | /Practical1a.py | 527 | 3.8125 | 4 | arr = [45,3,73,9,23,10,35,22]
def linear_search(arr,n):
for i in range(len(arr)):
if arr[i] == n:
return i
return -1
print(linear_search(arr,9))
def bubble_sort(arr):
len_arr=len(arr)
for i in range(len_arr):
for j in range(0, len_arr-i-1):
if arr[j] > arr[j+1]:
arr[j],arr[j+1] = arr[j+1],arr[j]
... |
3bd6bbad5931a6abb24f26fc1ce0bc3ff93c2e6a | byronrwth/git_leetcode | /tree/BinaryTreePreorderTraversal144.py | 1,664 | 3.859375 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution1:
def preorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
res = []
sel... |
672809dc2532e60b29caf8fed456460b7677a06a | franciszayek/Mancala | /mancala/player/human_player.py | 752 | 3.609375 | 4 | __author__ = 'robby'
import player
# from ..mancala import mancala
import mancala
from read_int import read_int
class HumanPlayer(player.Player):
def take_turn(self, board):
square = None
upper_square_number = len(board) / 2
error_message = "Must enter an integer between 1 and {0}".form... |
6c5588924f086662debef88c00b5fe5ac6c9b4db | yu68/GATE | /TableIO/BamIO.py | 2,026 | 3.53125 | 4 | # Programmer : zhuxp
# Date:
# Last-modified: 03 Oct 2012 16:49:10
import types
import pysam
from xplib.Annotation import Bed
def BamIterator(filename,**kwargs):
'''
iterator for reading a bam file.
Usage:
from xplib.TableIO.BamIO import BamIterator
for read in BamIterator(filename):
... |
48f7e3ee1d356eda254447e928321e6d7a8402c8 | samsolariusleo/cpy5python | /practical02/q07_miles_to_kilometres.py | 661 | 4.3125 | 4 | # Filename: q07_miles_to_kilometres.py
# Author: Gan Jing Ying
# Created: 20130207
# Modified: 20130207
# Description: Program that converts miles to kilometres and kilometres to miles
# before printing the results
# main
# print headers
print("{0:6s}".format("Miles") + "{0:11s}".format("Kilometres") +
"{0:11s... |
2e1e1897d6e0c4f92ee6815c9e1bb607dee10024 | samsolariusleo/cpy5python | /practical02/q12_find_factors.py | 562 | 4.4375 | 4 | # Filename: q12_find_factors.py
# Author: Gan Jing Ying
# Created: 20130207
# Modified: 20130207
# Description: Program that displays the smallest factors of an integer.
# main
# prompt for integer
integer = int(input("Enter integer: "))
# define smallest factor
factor = 2
# define a list
list_of_factors = []
# fi... |
750d0ff689da9aa8aea56e2e9b248df47ed51057 | samsolariusleo/cpy5python | /practical02/q05_find_month_days.py | 956 | 4.625 | 5 | # Filename: q05_find_month_days.py
# Author: Gan Jing Ying
# Created: 20130207
# Modified: 20130207
# Description: Program that displays number of days in the month of a particular
# year.
# main
# prompt for month
month = int(input("Enter month: "))
# prompt for year
year = int(input("Enter year: "))
# define list... |
cce715b6938e2f5c16d6ee158ebfa7e15b4e0645 | samsolariusleo/cpy5python | /practical02/q11_find_gcd.py | 725 | 4.28125 | 4 | # Filename: q11_find_gcd.py
# Author: Gan Jing Ying
# Created: 20130207
# Modified: 20130207
# Description: Program to find the greatest common divisor of two integers.
# main
# prompt user for the two integers
integer_one = int(input("Enter first integer: "))
integer_two = int(input("Enter second integer: "))
# fin... |
8254638df080d0a3b76a0dddd42cf41e393dfed7 | samsolariusleo/cpy5python | /practical01/q1_fahrenheit_to_celsius.py | 453 | 4.28125 | 4 | # Filename: q1_fahrenheit_to_celsius.py
# Author: Gan Jing Ying
# Created: 20130122
# Modified: 20130122
# Description: Program to convert a temperature reading from Fahrenheit to Celsius.
#main
# prompt to get temperature
temperature = float(input("Enter temperature (Fahrenheit): "))
# calculate temperat... |
9c531e58707ba9ea08e3885f29f17e065b44acb8 | gera912/Python-Programming-course | /Python_WWW_API_Web_Search.py | 3,046 | 3.90625 | 4 | # Program Header
# Course: CIS 117 Python Programming
# Name: Gerardo Perez
# Description: Python program that takes NAS website url as an input,
# downloads the html document and decodes the document into a string.
# A list of topics, that are under review, is created to find the
# number of occurrences of these top... |
b31a2cfab8055e42cd2a284dc646b5d19827b1c7 | dmironov1993/codeforces | /509A-Maximum in Table.py | 244 | 3.609375 | 4 | # https://codeforces.com/problemset/problem/509/A?locale=ru
n = int(input())
a = [1]*n
def recursion(i,j):
if j == 1:
return 1
if i == 1:
return 1
return recursion(i-1,j) + recursion(i,j-1)
print (recursion(n,n))
|
0eff1eb04df426f6c04242f9046338f8e5f9d75b | dmironov1993/codeforces | /609A-Flashcards.py | 473 | 3.59375 | 4 | # https://codeforces.com/contest/609/problem/A
n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
def BubbleSort(n, a):
for passnum in range(n-1, 0, -1):
for i in range(passnum):
if a[i] > a[i+1]:
a[i], a[i+1] = a[i+1], a[i]
BubbleSort(n, a)... |
be4b883a559cf4d303921ba42b653b64a0ba3574 | dmironov1993/codeforces | /807A-IsItRated.py | 568 | 3.53125 | 4 | # https://codeforces.com/problemset/problem/807/A
n = int(input())
rank_before = []
rank_after = []
for _ in range(n):
arr = list(map(int, input().split()))
rank_before.append(arr[0]) # before round
rank_after.append(arr[1]) # after round
def IsItRated(a,b):
arr = sum([i-j for i,j in zip(a,b)])
... |
5b808c98402a80c8e455c27fa8b41d69ffb03e06 | dmironov1993/codeforces | /141A-Amusing Joke.py | 628 | 3.5625 | 4 | # https://codeforces.com/contest/141/problem/A
guest = input()
host = input()
letters = input()
def searching(s1,s2,col):
possible = True
s = s1 + s2
if len(s) != len(col):
possible = False
else:
collist = list(col)
idx = 0
while idx < len(s) and possible:
i... |
7fc951df173632dd0ebc189cc0aac6efecd7c7a1 | BDialloASC/AllStarCode | /Paint Shop.py | 2,120 | 3.703125 | 4 | #Bootleg Microsoft Paint
from Processing import *
size(800,800)
white = color(255,255,255) #Create colors to use
red = color(255,0,0)
green = color(0,255,0)
blue = color(0,0,255)
yellow = color(255,255,0)
orange = color(255,165,0)
indigo = color(75,0,130)
black = color(0,0,0)
eraser = color(240,240,240) #List of... |
8e1570c6e03ec4817ab65fdba077df7bad1e97da | justintrudell/hootbot | /hootbot/helpers/request_helpers.py | 490 | 4.46875 | 4 | import itertools
def grouper(iterable, n):
"""
Splits an iterable into groups of 'n'.
:param iterable: The iterable to be split.
:param n: The amount of items desired in each group.
:return: Yields the input list as a new list, itself containing lists of 'n' items.
"""
"""Splits a list int... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.