blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
8076fc00362f6e4fffa62c4eada5a6b018815490 | kaichimomose/CS-2-Tweet-Generator | /Challenges/rearrange.py | 533 | 3.859375 | 4 | import random, sys
def rearrange(params):
word_List = params
length = len(params)
rearrange_order = ""
for i in range(0, length):
number = random.randint(0, len(word_List)-1)
if rearrange_order == "":
rearrange_order = word_List[number]
else:
rearrange_o... |
81c6ba6d86ac953a5cde2011f92eaa71e2802159 | PowerfulCheese/COMP9021_19T1 | /quiz_4.py | 2,292 | 3.640625 | 4 | # Uses Heath Nutrition and Population statistics,
# stored in the file HNP_Data.csv.gz,
# assumed to be located in the working directory.
# Prompts the user for an Indicator Name. If it exists and is associated with
# a numerical value for some countries or categories, for some the years 1960-2015,
# then finds out the... |
d35a2becbe1cfe364da351179d1c3bcc96dee08f | wfgiles/P3FE | /Week 12 Chapter 10/CH 10 slides2.py | 1,065 | 3.90625 | 4 | ##counts = {'chuck' : 1, 'annie' : 42, 'jan' : 100}
##lst = counts.keys()
##print lst
##lst.sort()
##for key in lst:
## print key, counts[key]
##-------------
##d = {'a':10, 'b':1, 'c':22}
##print d.items()
##
##print sorted(d.items())
##--------------
##SORT BY VALUE
##d = {'a':10, 'b':1, 'c':22}
##
##print d.items... |
4debe7a25bebf1fe8657f0d969942ab468bcebe5 | lembuss/My-Python-Codes | /ownsplit.py | 754 | 3.875 | 4 | # program performs a split on a sentence into individual words
def mysplit(strng):
new = []
splitword = []
spaces = 0
lngth = len(strng)
for i in range(lngth):
if ord(strng[i]) == 32:
spaces +=1
else:
continue
start = 0
space = ''
for i in ran... |
5823262448e085ef699c18a3a5c3894b0fc933b2 | Takashiidobe/learnPythonTheHardWayZedShaw | /ex15.py | 706 | 4.0625 | 4 |
#imports from the system arguments
from sys import argv
#the script is always the first arg, and then the filename is the second
script, filename = argv
#simplifies the open(filename) command
txt = open(filename)
#a little line that says what we're doing
print(f"Here's your file {filename}:")
#prints out the conten... |
85e80af755ba6b7eea23f3c1a28ada68d6e10ab8 | jasminecronin/intro-to-cs-I | /Coursework/Assignments/Assignment 3/assignment3.py | 8,428 | 4.40625 | 4 | """Assignment 3: AI Training
This program plays a game of nuts. There are a number of nuts on a table, and
two players take turns picking up 1-3 nuts. The player to pick up the last nut
loses. This game can be played with 2 human players, one player against an
untrained AI, or one player against a trained AI.
Author: ... |
f152e68bf28c50ba1803d19aa797d2f88669bf29 | m-strasser/gutenpy | /guten.py | 6,203 | 3.71875 | 4 | #!/usr/bin/env python3
"""
Scrapes books from gutenberg.spiegel.de
"""
import click
import requests
from bs4 import BeautifulSoup
class Book:
"""
Stores information about a book.
"""
def __init__(self, url):
self.url = url
self.author = None
self.title = None
self.year ... |
d2f43274936e7f233b434e561b5ada086e8ad66d | rhj0970/C200-Intro-to-Computing-Python | /Assignment11/fullbfs.py | 2,031 | 3.6875 | 4 |
import random as rn
class Stack:
def __init__(self):
self.stack=[]
def empty(self):
return self.stack == []
def pop(self):
if not self.empty():
return self.stack.pop(0)
def push(self,x):
self.stack.insert(0,x)
def __str__(self):
return str(self.s... |
c97e20616a9ab2253e7bea03e1582fbd66b82798 | karthikeyansa/python-placements-old | /python-day-2/prob21.py | 50 | 3.515625 | 4 | n=str(input("enter the string: "))
print(n[::-1])
|
6e655cf3e290a93d2a3eda9fd540ff8871715423 | sydneykleingartner/darkpixels | /step1.py | 616 | 3.953125 | 4 | #step one of the project
#goal: python program that loads image and prints it
#>>>from PIL import Image
#>>>im = Image.open('grace-hopper.png', ' r')
def main ():
#importing the Image module of PIl
from PIL import Image
#creating an Image object
#opening the image for reading mode (so then we can do stuff wit... |
d36aa4310a3c50c13edd9e5177c5601ade1a9747 | indrajithbandara/uri-questions | /uri_2486.py | 414 | 3.796875 | 4 | #UNDONE
while(True):
number = input()
xs, ys = [],[]
status = 0 #0 => function, 1 => not revertble, 2 => not a function
if(number == 0):
break
for i in range(number):
listaxy = raw_input().split()
x,y = listaxy[0], listaxy[2]
if(x in xs):
status = 2
if(y in ys and status != 2):
status = 1
xs.a... |
b0d8e290335b154ab3949d301d7a3516100c40ef | gnuwind/LearnPython | /LearnPythonTheHardWay_Exercise(Python3)/ex5.py | 721 | 3.765625 | 4 | def inches2cm(inches):
return inches * 2.54
my_name = 'Zed A, Shaw'
my_age = 35 # not a lie
my_height = 74 # inches
my_height_cm = inches2cm(my_height)
my_weight = 180 # lbs
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'
print("Let's talk about %s." % my_name)
print("He's %d inches tall." % my_height)
print(... |
a9ceebfda6179b006879615a4ec5e4e3cd497ee7 | FlyingMedusa/PythonELTIT | /Python from scratch/003PrimeNumbers.py | 399 | 4.1875 | 4 | #Write a program that prints the prime numbers from 1 to 100.
#A prime number is a number that is divisible only by 1 and itself.
not_prime = []
prime = []
for i in range(2,101):
for j in range(2,i):
if i%j == 0:
not_prime.append(i)
break
if i not in not_prime:
prime.ap... |
fa407414041b19ceaace9db20329207053222181 | Samruddhi9369/Real-Time-Facial-Expression-Recognition | /FacialExpressionRecognizer-CNN/model/fer2013DataGenerator.py | 4,302 | 3.625 | 4 | from keras.utils.np_utils import to_categorical
import pandas as pd
import numpy as np
import random
import sys
# This file separate training and validation data. While generating data, we classified Disgust as Angry.
# So resulting data will contains 6-class balanced dataset that contains Angry, Fear, Happy, Sad, Sur... |
650912dfeabb54aa1626b875056902198b547349 | pavankumarag/ds_algo_problem_solving_python | /practice/hard/_45_max_path_sum_in_binarytree.py | 1,138 | 4.1875 | 4 | """
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree.
Example:
Input: Root of below tree
1
/ \
2 3
Output: 6
See below diagram for another example.
1+2+3
Reference: https://www.geeksforgeeks.org/find-maximum-path-sum-in-a-binary-tree/
"""
class... |
22e69663629513ecb24133238e9522805f20e2f4 | mylessbennett/python_fundamentals2 | /exercise7.py | 716 | 3.796875 | 4 | runner_speeds = []
count = 1
i = "y"
while i == "y":
distance = float(input("How far did person {} run (in metres)? ".format(count)))
time = float(input("How long did it take for person {} to run {} metres? ".format(count, distance)))
speed = distance / (time*60)
runner_speeds.append(speed)
count +... |
462c2ca454c929dc627b7214bc2da7155a883427 | johnathan-dev/codingbat-solution | /python/String-2/end_other.py | 285 | 3.640625 | 4 | def end_other(a, b):
checker = ""
if(len(a) >= len(b)):
i = -len(b)
while(i < 0):
checker += a[i].lower()
i += 1
return checker == b.lower()
else:
i = -len(a)
while(i < 0):
checker += b[i]
i += 1
return checker.lower() == a.lower() |
3339f87f62653ea740d4f8d94604c79bbe7686d7 | SamuelDodet/Belgian_Houses_Price_Prediction | /utils/utils.py | 4,620 | 3.90625 | 4 | import warnings
import numpy as np
import sklearn
def drop_row_without_value(arg, database):
"""
delete row with empty value in df data
arg = name of the columns
"""
nan_value = float("NaN")
database.replace("", nan_value, inplace=True)
database.dropna(subset=[arg], inplace=True)
def repl... |
110edba851495174b45363b539c3741eb1273288 | raulperod/La-cena-de-los-filosofos | /filosofo.py | 1,814 | 3.515625 | 4 | import threading
import time
import random
class Filosofo(threading.Thread):
def __init__(self, id_filosofo, lista_de_palillos):
threading.Thread.__init__(self)
self.id_filosofo = id_filosofo
self.lista_de_palillos = lista_de_palillos
self.palillo_izquierdo = (self.id_filosofo+1) %... |
2f63c153ddd8bf757016c9286ba314bb93b3d1ff | essie-prog/This-is-Jeopardy-codecademy-project | /script.py | 697 | 3.65625 | 4 | import pandas as pd
pd.set_option('display.max_colwidth', -1)
project_data = pd.read_csv("jeopardy.csv")
print(project_data.head())
project_data.rename(columns =
{'Show Number' : "show_number",
' Air Date' : "air_date",
' Round' : "round",
' Category' : "category",
' Value' : "value",
' Question' : "question",
' Answ... |
64bd34801ec0a09f2f745d0acdd3bc2832a53ee7 | san042/python-dsa | /mergeSort.py | 1,262 | 4.0625 | 4 | # MergeSort
datas = [ 12,19,31,4,23]
print("Initial State: ", datas)
def mergeSort(datas):
if len(datas) > 1:
mid = len(datas) //2
#breaking by left from offset:mid position
data_left = datas[:mid]
#breaking by right from offset:mid position
data_right = datas[... |
1cb8870211c31a7a32dfe894f90ce032a076e41f | alyssonalvaran/kaizend | /session-6/test_lower.py | 196 | 3.59375 | 4 | def lowercase(x):
return x.lower()
def test_lowercase():
assert lowercase("TEAM KAIZEND") == "team kaizend"
def test_lowercase2():
assert lowercase("Team Kaizend") == "team kaizend"
|
5b3af7476665df38d47e9618df056fa80bd2b593 | jkopczyn/WEwUT-python | /ch4_overspecific/src/movie.py | 2,286 | 3.546875 | 4 | TYPE_NEW_RELEASE="New Release"
TYPE_REGULAR = "Regular"
TYPE_CHILDREN = "Children"
TYPE_UNKNOWN = "Unknown"
MOVIE_TYPES = set([TYPE_NEW_RELEASE, TYPE_REGULAR, TYPE_CHILDREN, TYPE_UNKNOWN])
class Movie(object):
def __init__(self, name, movietype=TYPE_UNKNOWN, actors=None):
self.name = name
self.acto... |
bef486db710139a36b42b619828392c4e6c0a57c | VitrSantos/cursoemvideo | /ex035.py | 540 | 4.15625 | 4 | #Exercício Python 35: Desenvolva um programa que leia o comprimento de três retas e diga ao usuário se elas podem ou não formar um triângulo.
print(20*"-=")
print('Analizador de triângulos')
print(20*"-=")
x = float(input('Digite o cumprimento da primeira reta: '))
y = float(input('Digite o cumprimento da segunda reta:... |
d570c013aa49ba58f43e39c4b34cb0dda91a0a43 | goodluckparis/Louplus | /jump7.py | 102 | 3.734375 | 4 | a = 0
while a < 100:
a += 1
if a % 7 ==0 or a % 10 == 7 or a //10 == 7:
pass
else:
print(a)
|
2d52c0218e2c248d3adcdb92701907d65d422726 | sumitshyamsukha/nets213-final-project | /src/analysis/analysis.py | 1,061 | 3.59375 | 4 | import csv
from math import sqrt
import operator
def ratings(ratings):
confidence = []
for i in ratings:
u = 0
d = 0
for j in ratings[i]:
if 'up' in j.lower():
u = u + 1
if 'down' in j.lower():
d = d + 1
confidence.append((... |
bd1abd26c8096cf7a12f44c5f5a5cb7de1dd0ece | hyoging/CodingTest | /예제1.py | 130 | 3.671875 | 4 | a = "life is too short."
print(a[3:7])
print(a[2:])
print(a[:9])
print(a[:])
list1 = [1,2,3,4,5]
for a in list1:
print(a+1)
|
631768ba74b765b5956bf91067eccf5117c920b9 | jianhui-ben/leetcode_python | /445. Add Two Numbers II.py | 2,693 | 4 | 4 | #445. Add Two Numbers II
#You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
#You may assume the two numbers do not contain any leading zero, except t... |
a92986f6c43c750053312c8549017520f6881162 | neelshet007/PythonTuts | /oops2.py | 331 | 3.640625 | 4 | class Employee:
no_of_leaves=8
pass
harry=Employee()
rohan=Employee()
harry.name="Harry"
harry.salary=4554
harry.role="Instructor"
rohan.name="Rohan"
rohan.salary=4554
rohan.role="Student"
print(Employee.no_of_leaves)
print(Employee.__dict__)
Employee.no_of_leaves=9
print(Employee.__dict__)
print(Employee.no... |
5c5ee4027d45f1ba6b4a3e6dc0a7ef848b5a4247 | Kai-Wei-626/leetcode---Kai | /086. Partition List.py | 1,087 | 3.875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def partition(self, head, x):
"""
:type head: ListNode
:type x: int
:rtype: ListNode
"""
dummy = ListNode(0)
... |
07ca2e8fb083d7e1b69ddb4392e75fbd3ad60831 | raghuprasadks/pythontutoriallatest | /workshop/Rangefunction.py | 306 | 4.5625 | 5 | #range(stop)
range1 = range(5)
print(range1)
#range(start,stop)
range2 = range(5,10)
print(range2)
#range(start,stop,step)
range3 = range(2,10,2)
print(range3)
#Using in for loop
for i in range1:
print('range1 ',i)
for i in range2:
print('range 2 ',i)
for i in range3:
print('range 3 ',i)
|
81670374c682e383aa31442f625a9f7717db4fde | ami-doshi/DP-5 | /unique-path-recursion.py | 793 | 3.546875 | 4 | class Solution:
def uniquePaths(self, m: int, n: int) -> int:
#first tried brute recursive method - 2^m*n
#2. Recursion with Table - m*n
#3. DP with table
#4. DP with single row
if m == 1 or n == 1:
return 1
return self.helper(m,n, 0, 0)
... |
1c1ea5b29f13877c2956c0129b670228b72d0f23 | QingfengYang/demo-code | /python3/rb_sort/MergeSort.py | 1,267 | 3.71875 | 4 | #!/usr/bin/env python
# encoding: utf-8
import sys
class BadBoundary(Exception):
def __init__(self, msg):
super(BadBoundary, self).__init__(msg)
class MergeSort:
# sort arr including [start_index, end_index]
@staticmethod
def merge_sort(arr: [int], start_index: int, end_index: int):
... |
9bbf42aae446a240923f00399103c1f854539cca | yingkexu/pythongame | /NN2N3.py | 326 | 3.765625 | 4 | def add0(a, b):
return a + b
def times0(a,b):
return a * b
def divide0(a,b):
return a / b
print('input n')
n = int(input())
print('input n2')
n2 = int(input())
print('input n3')
n3 = int(input())
print('input n4')
n4 = int(input())
asonsum = add0(n,n2)
ssum = times0(n3,asonsum)
print(divide0(ssum... |
91fcd6e52b811c547c93bb95f3cd97ebe75d8d6d | BlazeKl/T2grafos | /funciones/conexo.py | 889 | 3.53125 | 4 | # x es el arreglo bidimensional (matriz)
# n es el largo del arreglo, matriz n*n cuadrada
#n es la cantidad de vertices o nodos
from numpy.linalg import matrix_power
def is_conexo(x,n):
arrgl = [[0 for x in range(n)] for y in range(n)]
matc=[[0 for x in range(n)] for y in range(n)]
for i in range(0,n):
... |
7cf2cb0a2a345f5d2ac36af1f2862dd167823ad2 | turbek/helloworld | /100doors.py | 122 | 3.734375 | 4 | #looks for the square numbers between 1-10
#the square numbers have odd divider
y = [x * x for x in range(1,11)]
print(y)
|
8cdcc2b2ad0a668588985568e0f2a5b6d9d59d60 | calebxcaleb/Sneak-Game | /bullet.py | 820 | 3.71875 | 4 | import Paint
import pygame
class bullet:
player_copy = None
x = 0
y = 0
r = 10
speed = 0.5
x_speed = 0
y_speed = 0
def __init__(self, AI, player):
self.player_copy = player
self.x = AI.x
self.y = AI.y
self.setup()
def setup(sel... |
372b13663866fe4bc667d4350ce2e4aa6fe1422b | kavisha-nethmini/Hacktoberfest2020 | /python codes/stack.py | 1,591 | 4.28125 | 4 | class Stack:
def __init__(self):
self.items = []
def push(self, item):
return self.items.append(item)
def pop(self):
if self.is_empty():
return print("Stack is Empty")
return self.items.pop()
def is_empty(self):
return self.items ... |
4fd6984d6550aebead797db5b3b733a1dc6c3ee9 | yqxd/LEETCODE | /60PermutationSequence.py | 972 | 4.03125 | 4 | '''
The set [1,2,3,...,n] contains a total of n! unique permutations.
By listing and labeling all of the permutations in order, we get the following sequence for n = 3:
"123"
"132"
"213"
"231"
"312"
"321"
Given n and k, return the kth permutation sequence.
Note:
Given n will be between 1 and 9 inclusive.
Given k wi... |
3658b727b2f5f1cca3a9b354a085516bea5624cb | basvasilich/leet-code | /409.py | 364 | 3.5625 | 4 | # https://leetcode.com/problems/longest-palindrome
class Solution:
def longestPalindrome(self, s: str) -> int:
h = set()
for char in s:
if char in h:
h.remove(char)
else:
h.add(char)
if len(h) < 2:
return len(s)
e... |
7c49110e9f236b766bfd3d093c82b74f8dbf63a3 | jcbrockschmidt/project_euler | /p015/solution.py | 503 | 3.890625 | 4 | #!/usr/bin/env python3
import math
from time import time
def count_lattice_paths(n):
"""
Counts the total number of possible routes in an `n`x`n` grid
from the top left to the bottom right moving only down and right.
"""
return int(math.factorial(2 * n) / math.factorial(n)**2)
if __name__ == '__m... |
6828934406c5c49d7a7ee97b8e8068a117591b31 | bazadactyl/leetcode-solutions | /src/p009-palindrome-number/solution.py | 503 | 3.625 | 4 | class Solution:
@staticmethod
def isPalindrome(x):
"""Leetcode runtime: 588ms
:type x: int
:rtype: bool
"""
def recurse(num_str):
if len(num_str) in [0, 1]:
return True
elif num_str[0] == num_str[-1]:
return recurse(... |
9e81d4cba3d18e394dc49542d51e9a85540b803e | PedroTrujilloV/Python | /Python MIT course/week1_extemp.py | 548 | 4.0625 | 4 | varB = 2
varA = 3
if type(varA)== str:
if type(varB) == str:
lenA=len(varA)
lenB=len(varB)
if lenA == lenB:
print('equal')
elif lenA>lenB:
print('bigger')
else:
print('smaller')
else:
print('string involved')
elif type(varB) =... |
d28f185f42f247ec04de51a7d7ca5745c9fb0bef | apcor/202006-GB-Python-Basics | /hw6/hw6_task3.py | 1,892 | 4 | 4 | '''Реализовать базовый класс Worker (работник),
в котором определить атрибуты:
name, surname, position (должность), income (доход).
Последний атрибут должен быть защищенным и ссылаться на словарь,
содержащий элементы:
оклад и премия, например, {"wage": wage, "bonus": bonus}.
Создать класс Position (должность) на базе к... |
76a1fd0a5a1b4fbc6bb3fb4bc92d5bca5fdfdb15 | lidia01/chavez_cabrera_rojas_barturen | /rojas_baturen/EJERCICIO035.py | 217 | 3.5 | 4 | #ventade camisetas
#Declarar
numero_de_camisetas=0
numero_camisetas=int(input("ingrese numero de camisetas:"))
#Procesing
costo=400*numero_camisetas
if(costo>500):
print("buena:")
else:
print("mala")
#fin_if
|
f64bd900b8f144b21d500527dae0ad041e7e39e0 | roeisavion/roeisproject2 | /תרגילי פונקציות/7.py | 268 | 3.984375 | 4 | def big(a,b):
if a>b:
return a
return b
def small(a,b) :
if b>a:
return a
return b
def between(x,y):
for i in range(x,y+1) :
print(i,end=' ')
a=int(input("enter a"))
b=int(input("enter b"))
between(small(a,b),big(a,b))
|
fd8e1dce2a0ab9799e90b37c5282a060c5656aec | AdamZhouSE/pythonHomework | /Code/CodeRecords/2524/60781/276987.py | 368 | 3.609375 | 4 | n=input()
str1=input()
pan=0
if(str1=='3 1 7 2 5'):
print('3 1 2 7 5',end=' ')
pan=1
if(str1=='1 2 3 4'):
print('1 2 3 4',end=' ')
pan=1
if(str1=='1 3 4 2'):
print('1 3 2 4',end=' ')
pan=1
if(str1=='6 4 5 8 1'):
print('6 4 1 5 8',end=' ')
pan=1
if(str1=='9 7 5 4 3'):
print('9 7 5 4 3... |
1b885001aa6f17d9679c599703b95e3d6a2cbdde | ansari3492/default-dictionary-named-tuple | /mohammed_burhan_cc26.py | 349 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 21 12:02:54 2018
@author: Lenovo
"""
from collections import OrderedDict
d = OrderedDict()
for _ in range(int(input())):
item, space, quantity = input().rpartition(' ')
d[item] = d.get(item, 0) + int(quantity)
print(d[item])
for item, quantity in d.items... |
3fdd909a0937eb5eb67ddf02e555a47e50ca0b0b | buy/cc150 | /Node.py | 435 | 3.75 | 4 | class Node:
def __init__(self, data=None, next=None):
self.data = data
self.next = next
def __str__(self):
return '{ data: ' + str(self.data) + ' | next: ' + str(self.next) + ' }'
def setNext(self, node=None):
if node is None:
return None
self.next = node
return self
if __name__... |
3fb6713a6f74f622ea11c1c8e70f09fba52bdc55 | pszelew/Rekrutacja-Robocik | /zadanie1/boat/vector3.py | 1,238 | 4.0625 | 4 | from __future__ import annotations
import math
class Vector3:
"""
A class used to represent a connection to 3D Vector
Attributes
----------
x : float
Value of x-axis
y : float
Value of y-axis
z : float
Value of z-axis
Methods
-------
dist(sec_ve... |
e194316900bb7da30e43debb1eaf04bf4b54d8d5 | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/leetcode/lc-all-solutions/337.house-robber-iii/house-robber-iii.py | 499 | 3.65625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def rob(self, root):
"""
:type root: TreeNode
:rtype: int
"""
def dfs(root):
if not root:
... |
830553e6529d546eb6cc88b09d7b1253ee7ac763 | vinitapenmatsa/supervisedlearning-practice | /classification.py | 1,804 | 3.765625 | 4 | #%%
#Exploring data sets
from sklearn import datasets
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
# Iris keys dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names', 'filename'])
iris = datasets.load_iris()
#print(iris.DESCR)
#print(iris.target_names)
... |
845fbbedeb04ffd13c430459aa3078189b99e0f4 | alvinooo/advpython | /py2/solns/Flask/app/views.py | 4,840 | 3.5 | 4 | # views.py - views
from flask import render_template, flash, redirect, session, url_for, request, g
from flask_login import login_user, logout_user, current_user, login_required
from app import app, db, lm
from .forms import LoginForm, RegisterForm, CreateBookForm, DeleteBookForm
from .models import User, Role, Book
"... |
9d14c96a545193c5d96b8210f8ff4a468a235c31 | soumitra9/Competitive-Coding-7 | /meeting_rooms2.py | 1,091 | 3.84375 | 4 | # Time Complexity : Add - O(n log n)
# Space Complexity : O(n)
# Did this code successfully run on Leetcode : Yes
# Any problem you faced while coding this : No
'''
0. Sort the meetings
1. Use min heap to acces the room that has earliest end time
2. So we make a min hap based on ending time.
3. If start time of an inc... |
404b1ab13c3c2c05d0ad9e115fea6a6adcd25349 | hkskunal077/Operating_System_Programming | /OSCodeLab2SJFpreemtive.py | 1,436 | 3.53125 | 4 | #NON_PREMPTIVE SJF WITH SAME ARRIVAL TIME = 0
n=int(input("Process Count\n"))
processes=[]
for i in range(0,n):
processes.append(i)
#Process list upgraded
arrival_time = []
print("Enter Arrial time correspondingly?? ")
for proc in range(n):
arrival_time.append(int(input()))
#Arrival Time list upgraded
... |
18aaf5a7ac37603a43bcbcb25210d13aa359f7ba | shadowp2810/python_MapMarkerGenerator | /mapGen.py | 4,142 | 3.5625 | 4 | import folium #used for visualizing geospatial data
import pandas #data analysis and manipulation tool or library
data = pandas.read_csv( "importedFiles/Volcanoes.txt" ) #creates a data frame
theLatitudes = list(data["LAT"]) #makes a list from the LON column from Volcanoes.txt
theLongi... |
955d24fd199d5b80073170d9301c42100aaec812 | sarveshdakhane/Python | /Algo and DS in Python/DoubleLinklist.py | 1,542 | 4.15625 | 4 | class Node:
def __init__(self, Value=None):
self.Previous = None
self.Value = Value
self.Next = None
class DoubleLinkList:
def __init__(self):
self.Head = None
def Insert_at_begining(self,ele):
NewNode=Node(ele)
if self.Head == None:
self.He... |
9bfa6f7d7bda131f54206c59ffd5f08252e3d5b2 | srwhite5/rockPaperScissors | /rockPaperScissors.py | 1,894 | 4.125 | 4 | '''
Created on May 3, 2020
@author: ITAUser
'''
from random import random
keepPlaying = True
while keepPlaying == True:
print("Welcome to Rock Paper Scissors.")
print("Best 2 out of 3 wins. Press 'q' to quit")
rock = 1
scissors = 2
paper = 3
playerScore = 0
computerScore = 0
wh... |
fc44df2828b95146de312a9ac03ef78bca964055 | JessicaKarinaLopezMarroquin/Python_Crash_Course | /JKarinaLopezM/1Loops.py | 219 | 3.765625 | 4 | robots = ["nomad","Ponginator","Alfred"]
for robot in robots:
print(robot)
for num,robot in enumerate(robots):
print(num,robot)
count = 1
while count < 5:
print(count)
count = count+1
input()
|
cab021dec1177a4b7c776ce2e4a822492dda52c4 | panarnold/python-projects | /python-theory/operator-and-function-overloading.py | 2,950 | 3.65625 | 4 | #operator overloading: te same operacje daja inny behawior dla obiektów innych klas
#wbudowane funkcjonalnosci pythona mają taką konwencję nazwy, ze daje sie double underscory do nich
# np __len__() koresponduje do len(), a __add__() do operatora '+'
# z defaulta, wiekszosc wbudowanych funkcji i operatorow nie bedzie ... |
6375417beabdf08d9438e422be79be2a859b41be | jawhelan/PyCharm | /PyLearn/Exercise Files/07 Loops/iterators_else.py | 408 | 4 | 4 | #!/usr/bin/python3
# iterators.py by Bill Weinman [http://bw.org/]
# This is an exercise file from Python 3 Essential Training on lynda.com
# Copyright 2010 The BearHeart Group, LLC
def main():
my_string = 'this is a string '
item = 0
while(item < len(my_string)):
print(my_string[item], end='')
... |
b9e7bdfc9215715682b3ffb40e3c4b360faabf94 | Warriorchief/Euler38_PandigitalMultiples | /Euler38_PandigitalMultiples.py | 1,510 | 4.0625 | 4 | """
Euler38_PandigitalMultiples
Take the number 192 and multiply it by each of 1, 2, and 3:
192 × 1 = 192
192 × 2 = 384
192 × 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576.
We will call 192384576 the concatenated product of 192 and (1,2,3)
The same can be achieved by starting with 9 an... |
4bf912c62c2b83e35bf50a22c0e1a86ef1271f4c | msj2/prj_Eul | /Find the Prime Factors of 600851475143 | 2,041 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# untitled.py
#
# Copyright 2016 keshanna <keshanna@VATAPI>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the Lic... |
0b1518c0359db230e0cdc0117783affcb6cce0d7 | toddlerya/Core-Python-Programming-Homework | /Chapter_6/6-17.py | 449 | 3.75 | 4 | #!/usr/bin/env python
# coding:utf-8
"""
6–17.方法.实现一个叫 myPop()的函数,功能类似于列表的 pop()方法,用一个列表作为输入,
移除列表的最新一个元素,并返回它.
"""
def myPop(alist):
new_list = alist[:-1]
return new_list
if __name__ == "__main__":
get_list = input("Please input your list: \n")
print "The initializing list is %s" % get_list
pr... |
377f1b437e5d14f078cf1383feab6978edb95f4a | pathim/advent_of_code_2020 | /6/main.py | 498 | 3.828125 | 4 | count=0
count_every=0
with open('input') as f:
current=set()
every_letter=set(chr(ord('a')+x) for x in range(26))
everyone=set(every_letter)
for line in f:
line=line.strip()
if not line:
count+=len(current)
current=set()
count_every+=len(everyone)
everyone=set(every_letter)
continue
current.upd... |
247b362986c745c55642f3490c53399ecb9c3015 | olivier555/projet_metaheuristiques | /solution.py | 7,914 | 3.59375 | 4 | """
This class describes a solution (wihtout considering the data)
"""
import numpy as np
class Solution():
def __init__(self, n, sensors = None):
""" We initialize the solution with a boolean list
or a list of False if no list is provided.
"""
if sensors is None:
sens... |
a804bc91859358f8ec4fe8e174ede457a67e3c2b | japawka/Bakery | /S03 Klasy/24 word without clases.py | 472 | 4 | 4 | cake_01 = {
'taste': 'vanilia',
'glaze': 'chocolade',
'text': 'Happy Brithday',
'weight': 0.7
}
cake_02 = {
'taste': 'tee',
'glaze': 'lemon',
'text': 'Happy Python Coding',
'weight': 1.3
}
def show_cake_info(cake):
print('{} cake, with {} glaze, with text "{}", and weight of {} kg... |
ff9ed762c56160222e580326943fd0353db9a7e1 | PavelBLab/machine_learning | /assignment_3/assignment_3.py | 7,146 | 3.734375 | 4 | import numpy as np
import pandas as pd
import warnings
warnings.filterwarnings('ignore')
'''
Question 1
Import the data from fraud_data.csv. What percentage of the observations in the dataset are instances of fraud?
This function should return a float between 0 and 1.
'''
def answer_one():
df = pd.read_csv('frau... |
0b2c3420df3186dbc09c3f3051e0e1a75b9dc7ac | swang2000/DP | /Lengthofsubarrays.py | 1,693 | 3.78125 | 4 | '''
Given an array of N elements, you are required to find the maximum sum of lengths of all non-overlapping subarrays with
K as the maximum element in the subarray.
.
Input:
First line of the input contains an integer T, denoting the number of the total test cases. Then T test case follows.
First line of the test case... |
9fc6878b630793ae255e495f7ff520161a2ed4e7 | nanoman08/ud120-projects | /tools/word_counts.py | 2,447 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 01 11:52:39 2016
@author: CHOU_H
"""
"""Count words."""
from collections import Counter
def count_words(s, n):
"""Return the n most frequently occuring words in s."""
a = s.split(' ')
# TODO: Count the number of occurences of each word in s
b = Counter(a)... |
a9f96cafc9f3ed842b2d49e1a9423ef0551959e1 | Shreyash-310/Sololearn_practice | /sololearn_exception.py | 572 | 4.21875 | 4 | """try:
num1 = 7
num2 = 2
print(num1/num2)
print("Done calculation")
except ZeroDivisionError:
print("error occured due to zero division ")"""
"""try:
word = "spam"
print(word/0)
except:
print('An error occured !')"""
"""try:
num1 = input(": ")
num2 = input(": ")
print(floa... |
b552d4bd1701e71a2fe98ba64ef3d69785115460 | ssb2920/SEM-6 | /SPCC/Codes/prac1/prac1.py | 5,197 | 3.53125 | 4 | import random
ops = ['+', '-', '/', '*', '=', '%']
table = {}
def free_addr():
addr_list = [table[sym]['addr'] for sym in table]
addr = random.randint(0, 2000)
while addr in addr_list:
addr = random.randint(0, 2000)
return addr
def create_table(exp):
for sym in exp:
if sym in ops... |
be9a12f3290f3d33e4f7b58ebfa8519959642be1 | agranadosb/pymugen | /pymugen/fasta/chromosome.py | 4,924 | 3.890625 | 4 | from typing import TextIO
from pymugen.fasta.sequence import Sequence
class Chromosome(object):
"""Class that represents a chromosome.
Using this class a sequence can be obtained as list, for example, if we want to get
a sequence that starts at position 123 and finish at 456, we can get it using:
`... |
2a5244bc9a3abe27aaa771b0bc27eeb5f480c661 | pwlolk/Prace_domowe | /PD02/pd02_04_1_i_ost_cyfra.py | 507 | 4.0625 | 4 | #Wyświetlanie pierwszej i ostatniej cyfry danej liczby
print("Wyświetlanie pierwszej i ostatniej cyfry danej liczby".upper())
while True:
number = input("Podaj liczbę: ")
first_digit = number[0]
last_digit = number[-1:]
print("Pierwsza cyfra: " + str(first_digit))
print("Ostatnia cyfra: " + str(last... |
bef5d16b5c52b3f37b2046bd452608b8af2c9de1 | namratapandit/python-project1 | /code/repeatloop.py | 1,400 | 4.28125 | 4 | # program to take 2 numeric inputs and and operation selection from user
# the program repeats until the user does not exit
# Perform operations like add, sub, mul, divide
# keep repeating till user exits
# also handle exceptions for invalid inputs
def main():
validinput = False
# while loop runs till valid en... |
d28441524dee87dd23b91a1f61dd80dcaa027b84 | hearues-zueke-github/python_programs | /math_numbers/number_series_1.py | 670 | 3.578125 | 4 | #! /usr/bin/python3.5
import decimal
import math
import numpy as np
import matplotlib.pyplot as plt
from decimal import Decimal as D
decimal.getcontext().prec = 2000
pi = D("3.1415926535897932384626433832795028841071693993751058209749445923078164062862089986280348253421170679")
def calc_unknown_series():
str... |
fa2bd1501fd31e17c1e5957edf0257fc7fca5d32 | wangfang1111-gif/py_test | /s01/day01/guess age for.py | 265 | 3.71875 | 4 | #author:wang fang
for i in range(0,5):
Age = int(input("please input you guess age:"))
if Age > 46:
print("please guess smaller")
elif Age < 46:
print("please guess bigger")
else:
print("you are right,guess it")
break
|
d27395edd1bd1cfe950c6c584e073c90a4aec3d3 | mh70cz/py | /misc/fibonacci_test.py | 2,569 | 3.609375 | 4 | """ test fibonacci """
import unittest
import fibonacci as fib
class TestFib(unittest.TestCase):
""" test basic functionality """
fib_0_based_26 = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,
377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711,
28657, 46368, ... |
083db3a8bc159aa095dfd03a0b42ca91825aeba6 | sourabhjain19/aps-2020 | /Code Library/108_superfactorial.py | 186 | 3.515625 | 4 | def superfactorial(n):
fact=[1]*(n+1)
for i in range(1,n+1):
fact[i]=fact[i-1]*i
res=1
for i in fact:
res*=i
return res
print(superfactorial(4)) |
540466ff5d98cbba5f96f1577a4e7efbe4e40586 | xszhaob/python_in_action | /hello.py | 1,434 | 3.671875 | 4 | from bs4 import BeautifulSoup,NavigableString
import re
html_doc = """
<html><head><title>The Dormouse's story</title></head>
<body>
<p class="title"><b>The Dormouse's story</b></p>
<p class="story">Once upon a time there were three little sisters; and their names were
<a href="http://example.com/elsie" class="siste... |
bea7a5c8ea1f3c5651d6b5c1dd52a87b62b52daa | PujaNaval/Python-Programs | /stringmethods.py | 1,013 | 4.09375 | 4 |
str = (input('Enter string'))
print (str)
cap = str.capitalize() #first letter of string is capital
print (cap)
cen = str.center(10,'H') #total width of the string and fill character
print (cen)
l = len(str)
print ("Length of string is %d"%(l)) #find length of the string
c = str.count('s',0... |
c1968b466bb5be258550df3dcdfa9c0b7e95f596 | soneyaa/Python-Assignment | /Python Assignment/module2/exercise6/roulette_wheel.py | 730 | 4.0625 | 4 | p=int(input("Enter the pocket number"))
if p>36:
print("Error! The pocket number is out of range")
else:
if p==0:
print("Pocket is GREEN")
elif p>=1 and p<=10:
if p%2==0:
print("Pocket is BLACK")
else:
print("Pocket is RED")
elif p>=11 and p<=18... |
50bf1a875b64b08c63fdee0ea056ec66af2a0dfa | AllisonLiuxz/algor_learning | /newcoder/Full Permutation.py | 648 | 3.515625 | 4 | # -*- coding:utf-8 -*-
class Solution:
def Permutation(self, ss):
# write code here
if not ss:
return []
def gen_permutation(s):
if not s:
return None
if len(s) == 1:
return [s]
tmp = []
for i in ran... |
97422da2bc876a538752a72d7389a2804b70a65c | ashco/leetcode | /2020-09/04-fibonacci.py | 555 | 3.671875 | 4 | # return n character of fibonacci sequence
# 0 1 1 2 3 5 8 13 21 34
class Solution():
def __init__(self):
self.cache = {
0: 0,
1: 1
}
def fibonacci(self, n):
if n in self.cache: return self.cache[n]
res = self.fibonacci(n - 1) + self.fibonacci(n - 2)
... |
5c314e7cbcf77379916116651a4cbf9617216f32 | Yuchen1995-0315/review | /01-python基础/day06/exercise04.py | 980 | 3.671875 | 4 | # 练习1:["无忌","张翠山","张三丰"]-->{"无忌":2,"张翠山":3,"张三丰":3}
# key: 列表元素, value: key的长度
list_names = ["无忌", "张翠山", "张三丰"]
dict_names = {item: len(item) for item in list_names}
print(dict_names)
# 练习2:姓名列表: ["无忌","赵敏","周芷若"]
# 房间号:[101,102,103]
# 将两个列表合并为字典,key:姓名列表元素,值:房间列表元素.
list_names = ["无忌", "赵敏", "周芷若"]
... |
d393637088cb97b05e8fae25e44c8cba6d022f4f | raja1208/web-scrap | /extract.py | 4,194 | 3.71875 | 4 | import these two modules bs4 for selecting HTML tags easily
from bs4 import BeautifulSoup
# requests module is easy to operate some people use urllib but I prefer this one because it is easy to use.
import requests
# I put here my own blog url ,you can change it.
url="https://www.oyorooms.com/"
#Requests module use t... |
f1ced9ef0165afc9805a3b55401ed422a2818a68 | P-1702/Recruitment_Tasks_2021 | /PathPlanning/path_planning/scripts/MapClass.py | 2,594 | 3.96875 | 4 | #!/usr/bin/env python3
class Map:
# will hold array of values representing the walls in the maze
# the values will be integers.
# TopLeftRightBottom convention with values as 8-4-2-1
# basically a square with say top and bottom walls only will have value = 8(top) + 1(bottom) = 9
def __init__(self... |
94645a0051ca6011b2de9a8dbf0af16727aa57da | MuhammadOmaryassir/Wattary-Core-1 | /Core/RECOMMENDER.py | 5,328 | 3.8125 | 4 | """ Wattary's Brain """
# Note: This file Require Numpy , Pandas and Sci-kit learn Modules
# Importing the modules
import numpy as np
import pandas as pd
import sklearn
from sklearn.neighbors import NearestNeighbors
<<<<<<< HEAD
=======
<<<<<<< HEAD
from sklearn import preprocessing
=======
>>>>>>> master
import ran... |
94e619e438b347a7965f9138c4adaaf6a6c0cf4d | PacktPublishing/Mastering-Object-Oriented-Python-Second-Edition | /Chapter_8/ch08_ex1.py | 11,636 | 4.03125 | 4 | #!/usr/bin/env python3.7
"""
Mastering Object-Oriented Python 2e
Code Examples for Mastering Object-Oriented Python 2nd Edition
Chapter 8. Example 1.
"""
# noisyfloat
# ================================
import sys
def trace(frame, event, arg):
if frame.f_code.co_name.startswith("__"):
print(frame.f_cod... |
09507ae470aedc63ee1ae3fb33014982e51681c1 | Dgriffin12/511_Python_Stuff | /Extra_511_PY/Book.py | 1,194 | 3.5625 | 4 | from Item import Item
class Book(Item):
def __init__(self, type_in, call_num, book_title, subjects_in, author_in, desc_in, pub_in, city_in, year_in, series_in, notes_in):
self.type = type_in
self.call_no = call_num
self.title = book_title
self.subjects = subjects_in
self.auth... |
06e939d591998dbbcc0919cea1e2d77582ffe411 | abednarski79/lirc-controller | /src/lab/PipeTryOut.py | 1,533 | 3.59375 | 4 | from multiprocessing import Process, Pipe
import time
class Executor:
def __init__(self, subConn):
self.subConn = subConn
def execute(self):
command = 0
while(command != 9):
command = self.subConn.recv()
time.sleep(2)
print "executing: " + str(command... |
3dc098cacdb4ba5832e227b82a06cfc208255374 | BlueDragon23/advent-of-code2017 | /day17p2.py | 408 | 3.59375 | 4 | def iterate(state, current_pos, val):
"""
returns next_pos
"""
next_pos = (current_pos + 316) % val
#state.insert(next_pos + 1, val)
if next_pos == 0:
state[1] = val
return next_pos + 1
if __name__=="__main__":
current_pos = 0
state = [0, 0]
for i in range... |
d3a98c9d8f2100435144bfcddc586039baa07497 | DatabaseCoder/MyPythonWork | /SortAlgo/MergeSort.py | 1,033 | 4.3125 | 4 | # Merge Sort code in Python
def merge_sort(NumberList):
"""
Merge sort code to sort Number List
Call this code like - merge_sort([34,12,78,90,24,67])
"""
length = len(NumberList)
if length > 1:
midpoint = length // 2
left_half = merge_sort(NumberList[:midpoint])
right_half = merge_sort(NumberList[midpoint:... |
ba85df0fc81b1feaa28bb5258865bcf242c43acb | vns25/Computer-Networks | /HW1- Echo Assignment/client.py | 950 | 3.5 | 4 | #Vanshika Shah
#! /usr/bin/env python3
# Echo Client
import sys
import socket
# Get the server hostname, port and data length as command line arguments
host = sys.argv[1]
port = int(sys.argv[2])
count = int(sys.argv[3])
data = 'X' * count # Initialize data to be sent
# Create UDP client socket. Note the use of SOCK_... |
4c4c9fbab2c0b2ab448ec38042ab42040b201def | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4357/codes/1650_2449.py | 333 | 3.890625 | 4 | a=float(input("digite o numero"))
b=float(input("digite o numero"))
c=float(input("digite o numero"))
d=float(input("digite o numero"))
e=float(input("digite o numero"))
f=float(input("digite o numero"))
x=(c*e-b*f/a*e-b*d)
y=(a*f-c*d/a*e-b*d)
if (a*e-b*d!=0):
mensagem= "Tem soluçao "
else:
mensagem="Nao tem soluçao"... |
0cbfeb94c521bb6aa829ac01e5ae74dc84ad9ddf | Camerash/cs231n | /Assignment1/cs231n/classifiers/softmax.py | 4,097 | 3.75 | 4 | import numpy as np
from random import shuffle
from past.builtins import xrange
def softmax_loss_naive(W, X, y, reg):
"""
Softmax loss function, naive implementation (with loops)
Inputs have dimension D, there are C classes, and we operate on minibatches
of N examples.
Inputs:
- W: A numpy array of shape ... |
bb7e011af58577aeb02f97b7813ebe1efeb884fa | Lor3nzoMartinez/Python | /SPR19/Notes/AAA_oopPracticeAndNotes.py | 2,337 | 4.34375 | 4 | import math
print("\nSome OOP notes:\n")
# OOP Practice ############
class Dog:
# Class Attribute
species = 'mammal'
# Initializer / Instance Attributes
def __init__(self, name, age):
self.name = name
self.age = age
Philo = Dog("Philo",12)
Dani = Dog("Dani", 11)
Emma = Dog("Emma",... |
552ffd7b70bcf52274e63d7928a3b7103a176354 | OutlawOne55/Algorithm_study | /Algorithm_Python/Study_00/que_04.py | 99 | 3.5 | 4 | s = input()
x = 0
for i in range(len(s)):
x = x + int(s[i])
print(x)
print(int(s) % x is 0)
|
20959e93e401c570c3b931753370ddfc0182eed8 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2648/49823/309012.py | 157 | 3.75 | 4 | import random
n=int(random.random()*2)
if n==0:
print('whatthemmfun',end='')
elif n==1:
print('whatthefun',end='')
elif n==2:
print('Case 1: 4')
|
ecb95816d0eba2dd2dce67347258f436ea8033db | Nehrumathy/project187 | /project2.py | 102 | 3.8125 | 4 | # project187
fact=1;
n=int(input("Enter n:"));
for i in range(1,n+1):
fact=fact*i;
print(fact);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.