blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
24a27609d78be6a95322c562a1bd94558650eada | charvey/advent-of-code | /2020/12.py | 1,971 | 3.53125 | 4 | from aocd import data, submit
import math
input = data
def manhattan(pos):
return abs(pos[0]) + abs(pos[1])
def turtle():
x = 0
y = 0
a = 0
for line in input.splitlines():
action = line[0]
value = int(line[1:])
if action == "N":
y += value
elif actio... |
5d0689cfb3f59669f78b7b36a62dc7163ad4e2c2 | astronstar/leetcodeoffer | /51.py | 1,217 | 3.640625 | 4 | # 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。
# 示例 1:
# 输入: [7,5,6,4]
# 输出: 5
class Solution:
def reversePairs(self, nums: List[int]) -> int:
self.cnt=0
def merge(nums,start,mid,end):
tmp=[]
i=start
j=mid+1
while i<=mid and j<=end:
... |
f8b43e00093f66e7077e2e7b7fd40dc8b1ae3c54 | resteumark24/mark.py | /probleme/3.Sa se afiseze media numerelor pare.py | 946 | 4.09375 | 4 | #l = []
#num = int(input("How many numbers: "))
#for i in range(num):
# numbers = int(input("Enter number: "))
# l.append(numbers)
#print(sum(l)//3)
#l = []
#num = int(input("How many numbers: "))
#for i in range(num):
# numbers = int(input("Enter number: "))
# l.append(numbers)
#for i in ran... |
c97f9c7a326a2c2fc94e13bfa7ceffa3bb1ce93e | Andrey-Liu/shiyanlou-code | /FindDigits.py | 258 | 3.734375 | 4 | #!/usr/bin/env python3
import sys
if len(sys.argv) < 2:
print("Wrong parameter!")
print("./FindDigits.py file")
print("Target file: ", sys.argv[1])
fd = open(sys.argv[1])
a =''
for char in fd.read():
if char.isdigit():
a += char
print(a)
|
99184493a8e2ebac472a716de7b4393ad2412d2b | msyamkumar/cs220-f20-projects | /lab-p1/double.py | 88 | 3.953125 | 4 | x = input("please enter a number: ")
print("2 times your number is " + str(2*float(x)))
|
38e98e84ec6119fe50f0191ee264915476d8b9c5 | wangxf108/Python-OOP-Practice | /python-OOP-practice.py | 1,231 | 3.921875 | 4 | from random import randint
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def falls_in_rectangle(self, rectangle):
if rectangle.lowleft.x < self.x < rectangle.upright.x\
and rectangle.lowleft.y < self.y < rectangle.upright.y:
return True
else:
return ... |
710a365b283c6820fd425099bb0105ee5aa263f5 | utkamioka/attribute-access-dict-py | /test_map.py | 2,681 | 3.5 | 4 | from unittest import TestCase
from map import Map
class TestMap(TestCase):
def test_getattr(self):
m = Map(a=10, b=20, z=Map(x=100, y=200))
self.assertEqual(m.a, 10)
self.assertEqual(m.b, 20)
self.assertEqual(m.z, dict(x=100, y=200))
self.assertEqual(m.z.x, 100)
se... |
a63e75c9e007312315a2a83666720aa3caac4aca | ryanmiddle/CSCI102 | /Lab1B-Fibonacci.py | 465 | 4.28125 | 4 | #Ryan Middle
#CSCI 101 - A
#Python Lab 1B - Fibonacci
a=1 #initializing n var in fibonacci sequence
b=0 #initializing n-1 var in fibonacci sequence
c=1
n=int(input("please enter how many numbers in the Fibonacci sequence you would like to see")) #initializing step var
for i in range (1, n, 1):
print(c)
c=a+b #fibona... |
636ff58f648e8d64499c174d6b692ebdc96424b9 | justenpinto/coding_practice | /interviewcake/hashtables/inflight_entertainment.py | 1,534 | 4.6875 | 5 | """
Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane
usually lands before they can see the ending. So you're building a feature for choosing two movies whose total runtimes
will equal the exact flight length.
Write a function that takes an integer f... |
bc537211bef91b1014ebfc98c787e2093fcba762 | Apache0001/Curso-de-Python | /Aula01/aula09-1.py | 1,230 | 3.9375 | 4 | nome = "Pablo Oliveira Mesquita".upper() #coloca toda string em CAPS
print('PABLO' in nome)
nome.replace('PABLO','Gabriel') #Substitui uma palavra por outra
print(nome)
frase = "Curso em vídeo python"
print(frase.title()) # title coloca toda palavra em maiuscula
frase2 = "Curso em video"
print(frase2)
print(fras... |
bb9d4bd95fd2d9a938e84ef2a177f98bdf90f301 | Meghkh/connect_four | /project/connect_four.py | 5,489 | 4.28125 | 4 | """
Connect Four game
about/instructions
STILL TO DO:
- win condition sanitization to stay in range - COMPLETE but needs testing
- user input sanitization to stay in range
- have win condition terminate game - COMPLETE
- include row and column identifiers to improve UX
"""
#print ... |
dd0aed2410415d13f471a3aeac271dcc0a6a865b | stvnorg/checkio-python | /days-diff.py | 145 | 3.5 | 4 | from datetime import date
def days_diff(date1,date2):
return abs(date(date1)-date(date2)).days
print (days_diff((1982, 4, 19), (1982, 4, 22)))
|
0b90088d47e7f29b1d4224049cdcb675286bfae1 | ZpRoc/checkio | /c07_pycon_tw/p06_calculate_islands.py | 3,920 | 4.21875 | 4 | # ---------------------------------------------------------------- #
# Calculate Islands
# Help the robots calculate the landmass of their newly discovered island chain.
# (Matrix, geometry)
# ---------------------------------------------------------------- #
# The Robots have found a chain of islands in the mid... |
58228957d7ddc53a3acad8ba997db379ffbac68c | frankiegu/python_for_arithmetic | /力扣算法练习/day65-验证二叉搜索树.py | 2,323 | 3.765625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/5/4 20:49
# @Author : Xin
# @File : day65-验证二叉搜索树.py
# @Software: PyCharm
# 给定一个二叉树,判断其是否是一个有效的二叉搜索树。
#
# 假设一个二叉搜索树具有如下特征:
#
# 节点的左子树只包含小于当前节点的数。
# 节点的右子树只包含大于当前节点的数。
# 所有左子树和右子树自身必须也是二叉搜索树。
# 示例 1:
#
# 输入:
# 2
# / \
# 1 3
# 输出: true
# 示例 2:
#
# 输入:
# 5
# ... |
a6394f553ccd92bf360f41cb339df72893d816bb | Eyasluna/Data-Structures-Algorithms-Nanodegree-Program | /P0/Task3.py | 3,314 | 4.25 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
import re
import itertools
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 3:
(080... |
ee1eb7575c775880099853f55de5c4d271962e74 | DouglasKosvoski/URI | /1151 - 1160/1156.py | 106 | 3.578125 | 4 | total = 1
n = 3
m = 2
while n <= 39:
total += (n/m)
n += 2
m *= 2
print('%.2f' % (total))
|
ecb2ef2e489e495a7674b7caa0b1a24fe8336610 | deepakbhavsar43/Python-to-ML | /Machine_Learning/Case_Study/Logistic_Regression_Titanic_Dataset/Inbuilt/Inbuilt.py | 2,536 | 3.53125 | 4 | from dataframe import DataFrame
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
import matplotlib.pyplot as plt
from sklearn.metrics import accuracy_score
from userInput import *
import pandas as pd
import pickle
class Dataset:
def __init__(self):
... |
4d27d5c8c4f121832db0359a4b6757a8f1400329 | trustthedata/Intro-Python | /src/obj.py | 2,005 | 3.90625 | 4 | # Make a class LatLon that can be passed parameters `lat` and `lon` to the
# constructor
class LatLon:
def __init__(self, lat, lon):
self.lat = lat
self.lon = lon
def set_lat(self, lat):
self.lat = lat
def get_lat(self):
return self.lat
def set_lon(self, lon):
self.lat = lat
def get... |
26e3398adb6b366480a87b2e3bd0cc03e88cce58 | S-web7272/tanu_sri_pro | /basics/for_with_condition.py | 128 | 4.0625 | 4 | # print all numbers divisible by 3 in range of 1-100
for i in range(1,100):
if i % 3 ==0:
print(i,end=' ')
|
29b83e5b7cfcd1f3467ebf6c3fcccf46d46f2f57 | dmitri-mamrukov/coursera-data-structures-and-algorithms | /course4-strings/assignments/assignment_003_suffix_tree_from_array/test.py | 10,178 | 4.125 | 4 | #!/usr/bin/python3
import functools
import unittest
import suffix_tree_from_array
class Util():
@staticmethod
def _suffix_compare(word, i, j):
"""
Compares suffixes without generating entire suffixes.
Idea:
To compare the suffixes word[i:] and word[j:], compare the letters
... |
0a5cf6a35034bc10b39e4a3866b0e1d89396c7f9 | Maffanyamo/Tic-Tac-Toe | /Simple Tic-Tac-Toe (1)/task/tictactoe.py | 1,396 | 3.796875 | 4 | m = [[" ", " ", " "], [" ", " ", " "], [" ", " ", " "]]
i = 1
char = "Y"
def main():
print_grid(m)
while i <= 9:
coordinates()
if i == 10:
print("Draw")
def x_or_o(i, char):
if i % 2 == 1:
char = "X"
else:
char = "O"
return char
def coordinates():
x, y = input("Enter the co... |
3efc5a58e7e042f867ee04b8011ba6a44eac9f07 | NightFlightCaptain/python-common | /Algorithms/qiwsir/average_score.py | 1,036 | 3.921875 | 4 | # -*- coding:utf-8 -*-
# __author__ = 'wanhaoran'
"""
问题:
定义一个int型的一维数组,包含40个元素,用来存储每个学员的成绩,循环产生40个0~100之间的随机整数,
(1)将它们存储到一维数组中,然后统计成绩低于平均分的学员的人数,并输出出来。
(2)将这40个成绩按照从高到低的顺序输出出来。
"""
import random
def make_score(num):
scores = [random.randint(0,100) for i in range(num)]
return scores
def less_average(score):... |
f4633b1fd954589282a09ec4c352ad1b33e677ea | gergely-k5a/building-ai | /4. Neural networks/1. Logistic regression/20. logistic-regression.py | 340 | 3.546875 | 4 | import math
import numpy as np
x = np.array([4, 3, 0])
c1 = np.array([-.5, .1, .08])
c2 = np.array([-.2, .2, .31])
c3 = np.array([.5, -.1, 2.53])
def sigmoid(z):
return 1 / (1 + math.exp(-z))
# calculate the output of the sigmoid for x with all three coefficients
print(sigmoid(c1 @ x))
print(sigmoid(c2 @ x))
pri... |
e0127d0b24e8bfa8d90841bb5c5ea5755f95ef8a | yon-cc/LaboratorioVCSRemoto | /main.py | 634 | 4.1875 | 4 | import math
print("""Bienvenido usuario, para resolver la ecuacion cuadratica, primero ingrese el
valor del numero que acompaña a la elevada al cuadrado, luego el que acompaña a la
x y por último ingrese el numero sin la x.""")
a=int(input("1."))
b=int(input("2."))
c=int(input("3."))
d = b**2 - (4*a*c)
if d > 0:... |
db33be9d8bf3e26008ba2f2dff74629a90119e99 | alina2002200/pythonhmwrk | /hypot14.py | 173 | 3.625 | 4 | import turtle
import numpy as np
turtle.shape('turtle')
def strmm(n):
for i in range(n):
turtle.forward(150)
turtle.right(180-180/n)
strmm(11)
|
865367029d14c77f6e006a3de285701874b0e894 | 35sebastian/Proyecto_Python_1 | /CaC Python/EjerciciosPy2/Ej1.py | 843 | 3.90625 | 4 | #
# Mi resolución:
#
# edad= int(input("Ingrese su edad:"))
# if edad < 18:
# print("Según tu edad eres menor de edad")
# else:
# print("Según tu edad eres mayor de edad")
#
def validarEdad(edad):
while edad < 1:
print("%d no es una edad valida!!!" %edad)
edad = int(input('... |
61efde5b13a9f16e32bd2afa6e2a1de0fae69cdc | SMDXXX/Practice-Materials | /if_statement.py | 660 | 4.1875 | 4 | x = 5
y = 8
z = 5
a =3
"""
if x>y:
print("x is grater than y") #stement is flase will not do anything
"""
"""
if x<y:
print("x is grater than y")#console will print
"""
"""
if z<y>x:
print('y is greater than z and less than x')#console will print
"""
"""
if z<y>x>a:
print('y is greater than z a... |
ecdd8cfe980b0e60ea261110a4d418a07689889f | yszpatt/PythonStart | /pythonlearn/汉诺塔.py | 529 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2018-05-05 23:22:04
# @Author : Your Name (you@example.org)
# @Link : http://example.org
# @Version : $Id$
def hanoi(n, x, y, z):
if n == 1:
print(x, '---->', z)
else:
# 将前n-1个盘子移动到y上
hanoi(n - 1, x, z, y)
# 将最底下的盘子... |
57e21d20f16307c5034c60ea5046cb6302e8c7fc | Simonnn-a/jiangzy11 | /homework1.py | 2,548 | 3.859375 | 4 | #_*_ conding:utf-8 _*-
#@Time:2020/9/16 &{TIME}
# 1、用print函数打印多个值
a=1
b=2311
c=65533
print(a,b,c)
# 2、用print函数不换行打印
print('111',end='')
print('222')
# 3、导入模块的方式有哪些
import
from xxxx import xxxx
# 4、python有哪六种数据类型?不可变数据类型有哪些?可变数据类型有哪些?
Python中的数据类型包括:number(int,float,bool,complex)、string、tuple、list、dict、set
不可变类型:number... |
7f6cbf72c3be8ca9c496c596d68394aa8bbd84a3 | haotwo/pythonS3 | /day3/员工信息表.py | 1,081 | 3.8125 | 4 | # -*- coding:utf-8 -*-
#作者 :Lyle.Li
#时间 :2019/9/26 17:13
#文件 :员工信息表.py
"""python员工信息表操作"""
import sys
import os
def select1():
with open('peopledb','r',encoding="utf-8") as f:
line = f.readlines()
for i in line:
print(i)
def select():
msg = '''
请输入或复制查询命令例如:
1. select ... |
73a8d9cde292188513b5b25d12331c8c0ec6a1e9 | zhulingchen/P1_Facial_Keypoints | /models.py | 2,652 | 3.578125 | 4 | ## TODO: define the convolutional neural network architecture
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
# can use the below import should you choose to initialize the weights of your Net
import torch.nn.init as I
class Net(nn.Module):
def __init__(sel... |
1f358be10453a473710a8711a3f1a9b79dac2753 | llewellyn123/Dissatation-files | /load and display maze.py | 1,195 | 3.90625 | 4 | from mazelib import *
import random
mazename=""
mazesize=9
mazenum=999
mazearray=[[[0 for _ in range(mazesize)] for _ in range(mazesize)] for _ in range (mazenum)]
import numpy as np
#displays maze using "#" as walls
def displaymaze(a,maze):
lineprint="#"
print("############")
for i in ... |
9048d68bf1d6c698d3a0548a71e039f09bdfa39d | ben0bi/ThereWillBeLED_Python | /BeSymbols_x_4.py | 3,790 | 3.859375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# FONT to be used with BeLED.py
# BeSymbols: Some symbols in height 4, like CAL for Calendar, DAT for Date, etc.
# Ben0bi fonts are determined by their size.
# by oki wan ben0bi @ 2018
# Font consists of char arrays.
# a char array has a specific amount of lines w... |
4ebaebb325d4e88a98be2373352e72c0cf6c2274 | rayturner677/polishing_skills | /17_April/stringPrac.py | 729 | 3.921875 | 4 | string1 = input("Enter:")
string2 = input("Enter:")
nw_string1 = []
def sortFunction():
if string1 > string2:
newString(string1, string2)
else:
newString2(string1, string2)
def newString(string1, string2):
for i in string1 or i == ".":
if i in string2:
nw_string1.app... |
5c00c862946d6a156d4cee0e30c05b3594a6eb86 | Felipet144/Library_Python_Project | /Tarea_6.py | 5,008 | 3.78125 | 4 | import csv
from collections import Counter
# Menu
def menu():
print(
'Bienvenidos al menú de la biblioteca, \n 1. Solicitar un prestamo. \n 2. Consultar día con más solicitudes. \n 3. Consultar autor más solicitado. \n 4. Consultar libro más solicitado. \n 5. Consultar todos los libros prestados de... |
c12363d76f1c5a8f50bdf418ba954339f3e1393f | krastykovyaz/python_hse | /Исключающее ИЛИ.py | 155 | 3.953125 | 4 | def xor(x, y):
return x == 0 and y == 1 or x == 1 and y == 0
x = float(input())
y = float(input())
if xor(x, y):
print('1')
else:
print('0')
|
c603f2787f989ee092b4b4106203185ab55d6853 | koking0/Algorithm | /算法与数据结构之美/Algorithm/Greedy/01.找零问题.py | 660 | 3.671875 | 4 | # 假设商店老板需要找零 n 元钱,钱币的面额有:100元、50元、20元、5元、1元,如何找零使得所需钱币的数量最少?
def changeMoney(Denomination: list, amountOfMoney: int):
"""
:param Denomination: 钱币的所有面额
:param amountOfMoney: 找零的目标金额
:return: 不同面额钱币的张数和找不开的金额
"""
count = [0 for _ in range(len(Denomination))]
for index, value in enumerate(Denomination):
count[i... |
4b0c89c828134415e4ad1da02a50c6dbf49c664e | rohini-nubolab/Python-Learning | /str_palindrome.py | 254 | 4.4375 | 4 | #Python program to check given string is Palindrome or not
def isPalindrome(s):
return s == s[::-1]
s = "MADAM"
result = isPalindrome(s)
if result:
print("Yes. Given string is Palindrome")
else:
print("No. Given string is not Palindrome")
|
9be74a761703ee5b6ae9cbf29f93645aab2dd250 | shweta4377/GNEAPY19 | /venv/Session7B.py | 1,230 | 4.5 | 4 | class Customer:
# Constructor
def __init__(self, name="NA", phone="NA", email="NA"):
self.name = name
self.phone = phone
self.email = email
c1 = Customer()
# print(c1.__dict__)
c1.name = input("Enter Customer Name: ")
c1.phone = input("Enter Customer Phone: ")
c1.email = input("Enter... |
cdcc4497fcec7f94defaa489309ba82920a1b1e2 | vkaplarevic/MyCodeEvalSolutions | /python/vine_names.py | 1,014 | 3.8125 | 4 | #! /usr/bin/env python
import sys
def find_vine(vines, letters):
wSet = {word: list(word) for word in vines}
result = []
for vine in vines:
to_add = True
for letter in letters:
if letter not in wSet[vine]:
to_add = False
else:
index ... |
777729b7abb5449104350186cf3da131ec31bd52 | ELFUCAR/PYTHON-PROJECTS-2019 | /random1.py | 147 | 3.609375 | 4 | import random
avg=0
sum=0
n=1000
for x in range(n):
x=int(random.random()*6)+1
sum=sum+x
# print(x)
avg=sum/n
print (avg)
|
680105c9406c526f8f21d54b56d4d9ae31738307 | 7vgt/CSE | /Andrew Esparza-HangMan.py | 1,375 | 3.984375 | 4 | import random
win = "False"
the_count = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
guesses = 10
letters_guessed = []
word_bank = ["futuristic house", "milk and cookies", "snowy forest", "boomerang","spooky house","video game",
"do you know the way","raindrop droptop","jellyfish","thirtyvirus"]
word = random.cho... |
f76b8dd912cfe8f90a364b7761eef073b38954b6 | xanderyzwich/Playground | /python/tools/numbers/print_count_reversed.py | 365 | 4.125 | 4 | """
Print the numbers 1 to 100 in reverse order
"""
def count_reversed(input_integer):
if input_integer == 100:
print(input_integer)
return
else:
count_reversed(input_integer+1)
print(input_integer)
def print_count_reversed():
print_count_reversed(1)
if __... |
75d687107cae9c3deeafbef9f25379fdceef70c2 | poplock1/Lightweight_ERP | /hr/hr.py | 6,266 | 3.671875 | 4 | """ Human resources module
Data table structure:
* id (string): Unique and random generated identifier
at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters)
* name (string)
* birth_year (number)
"""
# everything you'll need is imported:
# User interface module
im... |
9ce8c4e3c059066a2b20089e39ddbc898f7c4bd8 | Rahmanism/pythonlearn | /02_01.py | 1,460 | 4.0625 | 4 | # Chapter 02
# lambda functions:
myfunc = lambda x: x * 2
print(myfunc(3))
a = [(3,4), (7,1), (5,9), (2,2)]
a.sort()
print(a)
a = [(3,4), (7,1), (5,9), (2,2)]
a.sort(key = lambda x: x[1])
print(a)
# double elements using map and lambda
a = [1, 3, 4, 0.5]
print(list(map(lambda x: x*2, a)))
# say big or small using... |
6d837254bcda03b85a75ad659894e9c5b3ff6ad6 | Girishn-lab/PythonPratice | /Classes/MenuSetGet.py | 997 | 3.765625 | 4 | setprice = None
class Menu:
def __init__(self):
self.menu_items = []
def add_items(self, item, price):
self.menu_items.append(item)
self.menu_items.append(price)
def show(self):
return self.menu_items
def set_price(self, item, setprice):
for k, v in enumerat... |
faeaf1249610116a4c905bb4b04f1d85ecc5d7ed | rafaelperazzo/programacao-web | /moodledata/vpl_data/107/usersdata/219/52023/submittedfiles/questao3.py | 253 | 3.734375 | 4 | # -*- coding: utf-8 -*-
p=int(input('Digite um numero p:'))
q=int(input('Digite um numero q:'))
contador=0
i=2
while i<(p) and (q):
if p%i==0 and q%i==0:
contador=contador+1
if q==p+2:
print('S')
else:
print('N')
|
62f958100d52bb930255be0a3e161ac12a4d9bf6 | brettimus/yum-yum-cake | /q5-v3.py | 712 | 3.84375 | 4 | # InterviewCake (Beta Exercise 5)
# Brett Beutell
# June 17, 2014
# Define rectangles as hashes
# r = {"x" : x, "y" : y, "width" : w, "height" : h}
def find_r_int(r1,r2):
result = {}
left_rect, right_rect = (r1,r2) if r1["x"] <= r2["x"] else (r2,r1)
if left_rect["x"] + left_rect["width"] < right_rect["x"]:
retur... |
0c84351c8fca55befc8cc7e055e2e4567ff5d444 | Andkeil/AirBnB_clone | /tests/test_models/test_city.py | 813 | 3.859375 | 4 | #!/usr/bin/python3
"""unittests for City"""
import unittest
import datetime
from models.city import City
class TestCity(unittest.TestCase):
"""class TestCity"""
def setUp(self):
"""setup"""
self.city = City()
def test_city(self):
"""testing for a type of the attributes and
... |
b608a2a313fe598cd0a71e7e9274361cd23412d5 | Oskar-watto/connet-four | /dragon shadow monster legends fighting dragon heroes dragon monster killing dragons sharknado powerup drgon slayer dragon fighting 3.py | 8,719 | 4.03125 | 4 | import random
import time
#asking for name because why not
def getname():
name = input("enter name:")
time.sleep(3)
print(name + " is now playing: dragon shadow monster legends fighting dragon heroes dragon monster killing dragons sharknado powerup dragon slayer dragon fghting 3")
#printing some ... |
3f6909b6683cde312ba18ff075cbb409ecc2cc93 | vinit-patel/Seaborn | /Barplot with data values.py | 747 | 3.5 | 4 | import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
df = sns.load_dataset("tips")
groupedvalues=df.groupby('day').sum().reset_index()
pal = sns.color_palette("Greens_d", len(groupedvalues))
rank = groupedvalues["total_bill"].argsort().argsort()
#Here the rank function is required since the values... |
9c1ce5ab9239b4b3c22d0d4b93a5082c41349667 | rubengr16/BeginnersGuidePython3 | /5_numbers_booleans_none/1_int.py | 588 | 4.34375 | 4 | # Integral numbers are represented by int type indepently from their size
integer = 1
print(integer)
print('x type:', type(integer))
x = 1111111111111111111111222222222233333333333333333333333333333334444444444444444444444555555555555
print(integer)
print('x type:', type(integer))
# int() function can be used to cast... |
53d2f291dd099896c3399c84eaa17bba3778384b | yeshwanthreddy12/Demo | /venv/prime.py | 112 | 3.90625 | 4 | num=90
for i in range(2,num):
if num%2==0:
print("not prime")
break
else:
print('prime') |
4bcc211eea9666c58640f5d73970318ca32fa03e | haoknowah/OldPythonAssignments | /Gaston_Noah_NKN328_Hwk12/033_crayonColors.py | 2,087 | 4.1875 | 4 | def crayonColors():
'''
crayonColors=checks the file with the 1990 crayon colors, removes the ones
listed in the file that were discontinued, and adds the ones listed in
the file that were added to production
@param original=file with the list of colors in 1990
@param removed=file with list of colors discontinued
@... |
7de65c53935db2d0ed4ba01139a338b99586e491 | The-afroman/validate_emails_python | /emailCheck.py | 881 | 3.53125 | 4 | from validate_email import validate_email
import csv
valid_email_list = []
invalid_email_list = []
with open('data.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for i in readCSV:
email = i[0]
#print(email)
is_valid = validate_email(email , verify=True)
if is_va... |
e46137d3fd33abdab6a3b082e2bda097a04e537e | SahilMund/A_ML_Cheatsheets | /Machine Learning A-Z Template Folder/Part 6 - Reinforcement Learning/Section 32 - Upper Confidence Bound (UCB)/UpperConfidenceBound.py | 1,686 | 3.71875 | 4 | # Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Ads_CTR_optimisation.csv')
#implementing UCB
N=10000 #Representing the number of customers
d=10 #Representing the no of ad versions
ads_selected=[]
#[0]*d represents a vector... |
f6a775b831f4f0183a829014696e16ca81e6bdf4 | conradylx/Python_Course | /10.03.2021/Podsumowujace/exc8.py | 1,401 | 3.515625 | 4 | # Napisz program, który będzie sprawdzał, czy nasz samochód kwalifikuje się do zarejestrowania jako zabytek.
# Program zacznie ze stworzonym słownikiem o trzech kluczach:
# marka (str)
# model (str)
# rocznik (int)
# Wypisze ten słownik na ekran (bez żadnego formatowania)
# ... |
ed889bd716ca8b4148dbbe91ecc50a58414a2bc8 | AlekseyOgorodnikov/python-algortims | /main_reversed_array.py | 1,036 | 4.09375 | 4 | def inverse_array(arr: list, n: int):
""""
Обращение массива (задом - наперед)
в рамках индекса от 0 до n-1
"""
for i in range(n//2):
arr[i], arr[n - 1 - i] = arr[n - 1 - i], arr[i]
return arr
# arr.reverse()
# return arr
# a = arr
# first = 0
# last = n - 1
# w... |
9842d91525ccd044f9dfb59aaef5bda8cc93aa03 | chapman-cpsc-230/hw2-Jake-Adams | /Cooling.py | 355 | 3.953125 | 4 | import math
t_tea = float(input("Temperature of the Tea: "))
t_air = float(input("Temperature of the Air: "))
t_min = float(input("Number of Minutes: "))
print("Minute Temperature")
print(" 0 ", t_tea)
time = 1
while time < t_min:
t_tea = t_tea - .055* (t_tea-t_air)
print(" ", time ," ", "... |
ecc1e51f73d5063187d7eb1da163df733749a631 | wyattyhh/Little-Simulated-System | /Database.py | 1,321 | 3.546875 | 4 | import sqlite3, random
# Randomly generate 6 characters from given characters
def generateID():
characters = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789@_#*-&"
results = ""
for n in range(6):
x = random.choice(characters)
results += x
return(results)
# Genertate ran... |
6621d7c5f20858b70e21dbd542a48695a5150a90 | JorgeHernandezRamirez/PythonLearning | /generator.py | 1,283 | 3.640625 | 4 | import unittest
class GeneratorTest(unittest.TestCase):
def test_shouldIterateFromGeneratorFunction(self):
generator = self.getIteratorNumericValues();
self.assertEqual(next(generator), 0)
self.assertEqual(next(generator), 1)
self.assertEqual(next(generator), 2)
self.assert... |
497275871ae0913a2097e41b2bca3396e1518eba | JeonJe/Algorithm | /4.programmers/프로그래머스_jungle/프로그래머스_햄버거 만들기.py | 581 | 3.59375 | 4 | def solution(ingredient):
answer = 0
stack = []
for i in range(len(ingredient)):
if ingredient[i] != 1 :
stack.append(ingredient[i])
else:
#스택의 마지막 4개가 빵야채고기빵 순서이면
if len(stack) >= 3 and ''.join(map(str,stack[-3:])) == "123":
answer += 1
... |
017f44d46e148a8bc1f1a523f9e1bc18b64314ad | kta95/CS50-Python | /pset7/houses/import.py | 1,012 | 4.03125 | 4 | # TODO
import csv
from sys import argv
import sqlite3
con = sqlite3.connect("students.db") # connect to database
cur = con.cursor()
if len(argv) != 2: # check if the number of command-line arguments is correct
print('Usage: python import.py characters.csv')
exit(0)
file_name = argv[1]
with open(file_name,... |
40b5c9f42adb1fc3f0493115334422b6d4823252 | marcosValle/ML | /CS229/week1/gradientDescent.py | 1,535 | 3.625 | 4 | import math
import matplotlib.pyplot as plt
import numpy as np
def h(x, t0, t1):
return t1+t0*x
def J(data, t0, t1):
j = 0
for d in data:
j += math.pow((h(d[0], t0, t1) - d[1]), 2)
return j/(2*len(data))
#gradientFunction
def gradientJ(data,t0,t1):
t0_grad = 0
t1_grad = 1
m = len(... |
0e25ef9c33f0bc08c8cdd2780470728ea6c8e38b | iniej/camelcase_with_unittest | /test_camelcase.py | 468 | 3.671875 | 4 | import camelcase
from unittest import TestCase
class TestCamelCase(TestCase):
def test_camelcase_sentence(self):
self.assertEqual('helloWorld', camelcase.camel_case('Hello World'))
self.assertEqual('', camelcase.camel_case(''))
self.assertEqual('helloWorld', camelcase.camel_case(' Hello ... |
8c010946744d3d3c1d1e2857f99858bf98edbc3a | jeffscott2/ceiling-zero | /week_2_code/csv_helper.py | 383 | 3.5 | 4 |
import csv
class CsvHelper:
def __init__(self, filename):
self.filename = filename
def get_rows_exclude_header(self):
csv_file = open(self.filename)
csv_row_reader = csv.reader(csv_file, delimiter=',' )
csv_row_reader.__next__()
rows = []
for csv_row in csv_ro... |
263a3eb803c4f30c79a52c58631393f3a6b87fc7 | CrunchyPancake/Unruly-Knife | /male_female_distribution.py | 1,670 | 3.78125 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = pd.read_csv("database.csv-", low_memory=False)
def get_age_interval(start, end, gender):
return gender[(gender['ALDER'] > start) & (gender['ALDER'] < end)]
def make_plottable(dataset):
out_dict = {}
for entry in dataset:
... |
e273fc320d6c81c8ce7aa2d91a2ae4bd61c9ec6b | JackoQm/Daily_Practices | /LeetCode/AC/283*.py | 926 | 3.84375 | 4 | '''
From: LeetCode - 283. Move Zeroes
Level: Easy
Source: https://leetcode.com/problems/move-zeroes/description/
Status: AC
Solution: Using two pointer
'''
class Solution:
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums... |
62e687779c000a167efcc1e5c9097fa6404bfe7b | jiinmoon/Algorithms_Review | /Archives/Leet_Code/Old-Attempts/0109_Convert_Sorted_List_to_Binary_Search_Tree.py | 698 | 3.5625 | 4 | """ 109. Convert Sorted List to BST
Question:
Given a singly linked list where elements are sorted in ascending order,
convert it to a height balanced BST.
"""
class Solution:
def sortedLinkedListToBST(self, head):
if not head or not head.next
return head
slow, fast = head, ... |
32691a8cdde211e0ae842f3a18ec91eaecf2ebbb | aliseas/ProgrammingLab | /WEEK8/model&plot.py | 2,188 | 3.734375 | 4 | """
Estendere la classe CSVFile che avete creato la scorsa lezione, aggiungendo
i seguenti metodi
"""
class CSVFile():
def __init__(self,name):
self.name = name;
def get_data(self,name,start,end):
if start>end:
raise Exception('Start value cannot be > end value')
my_file = open(name,'r')
with open(name,... |
ed10eabc51b51465f957f48f81f5759803d6d949 | say2sankalp/pythonproj | /handling except.py | 168 | 3.765625 | 4 | while True:
try:
x=int(raw_input("Please enter a number :"))
break
except Valueerr:
print "Oops! that was no valid number. Try again.."
|
6781a0ce90b76fe5afe0c0ca500c5e30cc8c3a5e | AlienWu2019/Alien-s-Code | /oj系统刷题/递推求值.py | 150 | 3.53125 | 4 | n=int(input())
def F(n,a):
if a==1:
return F(n-1,2)+2*F(n-3,1)+5
elif a==2:
return F(n-1,1)+3*F(n-3,1)+2*F(n-3,2)+3
F(n,1)
|
e542e10d3b77eb570f7044c0c78b745e982100f4 | Xfan0225/python-BasicPrograming | /五一思维训练/因子数之和.py | 790 | 3.78125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 1 16:16:28 2019
@author: xie
"""
import math
#import time
#start=time.perf_counter()
def make(n): #计算因子数的函数
ans = 0
if n == 1:
return 1
elif n == 2:
return 2
elif n == 3:
return 2
else:
... |
fd0614ff6abe278f4c63b62a988f4efebe2cdf12 | c940606/leetcode | /test1.py | 2,215 | 4 | 4 | from collections import defaultdict
# This class represents a directed graph
# using adjacency list representation
class Graph:
def __init__(self, vertices):
# No. of vertices
self.V = vertices
self.userPath = []
# default dictionary to store graph
self.graph = defaultdic... |
b83d7216748e58b73d8b344a8f29f3b1ff39ac82 | vtphan/Graph | /example.py | 872 | 4.25 | 4 | from graph import Graph, DGraph
print("Example of unweighted undirected graph")
G = Graph()
G.add(2,3) # add edge (2,3); (3,2) is automatically addeded.
G.add(3,5) # add edge (3,5); (5,3) is automatically addeded.
G.add(3,10) # add edge (3,10); (10,3) is automatically addeded.
print(... |
b698a07ad051636bd545ba4f7426d46877d2dfda | fireflyso/DevNote | /Algorithms/sort/base/base.py | 1,516 | 3.734375 | 4 | # -*- coding: utf-8 -*-
class Base:
sort_arr = [23,5,8,122,32,45,72,342,2,89,12,34,11,9,77]
sort_model = [23,5,8,122,32,45,72,342,2,89,12,34,11,9,77]
action_times = 0
def __init__(self,name = "玄学"):
self.name = name
print(" --- 开始进行 {} 排序 ---".format(self.name))
print("排序前... |
5f569cd6a9065de64cc4c3d933e2975e7adc1a97 | souza-pedro/Scripts_GPI | /Anexar_Ordem_SAP2.py | 7,063 | 3.53125 | 4 | import sys
import easygui as g
import os
import pandas as pd
# Escolha da pasta de Destino
def main():
#Escolhe a pasta padrão
escolher_pasta(c_origem, c_destino)
#Extrai Nº das Ordens
Lista_Ordens(c_origem)
#Anexa arquivos
anexa_SAP(c_origem)
#Renomeia arquivos e coloca em pasta desti... |
df7b45feb94ff1e42b8121997a0124c9f1524687 | ongsuwannoo/Pre-Pro-Onsite | /The Bridge.py | 726 | 3.90625 | 4 | """ The Bridge """
def main():
""" input """
country = ['Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', \
'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Ireland', \
'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', ... |
0fcbda0c1dfe2058d6b86d6fa266dc0db75914c7 | fiolj/biblio-py | /yapbib/bibdb.py | 3,146 | 3.65625 | 4 | import sqlite3 as sq
from . import helper
DB_TBLNM = 'biblio'
def create_dbconnection(db_file):
"""create a database connection to the SQLite database
specified by the db_file
Parameters
----------
db_file : file-like (string or handle or Path)
Filename of the database
Returns
-------
Sqlit... |
6055155008c55cf55031cf0e7f3f3ecb44cd3255 | mike1806/python | /udemy_function_3.py | 218 | 4 | 4 | # find out if the word "dog" is in a string
def dog_check(mystring):
if 'dog' in mystring.lower():
return True
else:
return False
dog_check('dog ran away')
'dog' in 'dog ran away'
|
f465d9176ddd21092f6f0a249d1de57df453a5da | JanikThePanic/bricks-on-walls | /main.py | 1,010 | 3.703125 | 4 | import actions, rooms, var, art, monsters
#Imports other files
#The main loop used to start the game, and will be called again for replay
def start_game():
#ASCII Art for title
art.title()
#Confirms that the user wants to play
userIN = input("\nType 'Enter' to begin the adventure.\n").lower()
#Will not accept a... |
ae5a41a6c857b81d0a6f95b929abca95d8285e6a | bMedarski/SoftUni | /Python/Fundamentals/Functions and Debugging/08. Multiply Evens by Odds -2.py | 353 | 3.78125 | 4 | def sum_even(a):
rez = 0
for j in a:
if int(j) & 1 == 0:
rez += int(j)
return (rez)
def sum_odd(a):
rez = 0
for j in a:
if int(j) & 1 == 1:
rez += int(j)
return (rez)
n = input()
if n[0] == "-":
line = n[1:]
else:
line = n
result = sum_odd(lin... |
61975ee33a7eea859baf812d3548804b0f88442a | Sujan-Kandeepan/Exercism | /exercism/python/bob/bob.py | 523 | 3.890625 | 4 | def hey(question):
hasletters = False
for i in question:
if not i.isalpha() and i not in ['1','2','3','4','5','6','7','8','9','0', "?"]:
question = question.replace(i, " ")
if i.isalpha(): hasletters = True
question = question.strip()
print(question, question.upper(), haslett... |
9b3dbfe6337ff989ed16e87cfd8e26a73bc8a7a9 | DimonAgon/math-one | /test/test_simplified_formula_is_same_as_long_one_case_30.py | 679 | 3.53125 | 4 |
def compute_simplified_formula(A, B, C):
b_diff_c = B - C
a_intersect_b_diff_c = A & b_diff_c
return a_intersect_b_diff_c
def set_difference(X, Y):
"""# True \ False = True
# True \ True = False
# False \ True = False
# False \ False = False
That is z must be in X and must not be in Y
"""
retu... |
908513286b729825bb62349d8cf491dd3d62ad7e | YohannesGetu/RSA-Factoring-Challenge | /rsa | 1,075 | 4.34375 | 4 | #!/usr/bin/python3
from sys import argv
import math
"""gets the first two factors of any number"""
def is_prime(num):
"""checks if a number is prime"""
i = 3
if num % 2 == 0:
return False
while i * i <= num:
if num % i == 0:
return False
i += 2
return True
def... |
8fdff07d65e604520f234dc6cea9132135606874 | daniel-reich/turbo-robot | /FATFWknwgmyc7vDcf_2.py | 2,369 | 3.984375 | 4 | """
My friend required some help with an assignment in school and I thought this
would be a nice addition to be added as a challenge here as well.
Create a function that takes a sentence and returns a modified sentence abided
by these rules:
* If you encounter a **date** within the sentence, **in the format DD/M... |
1b0610210c66486c27d67ecd6742e8b5137190c3 | cikent/Python-Projects | /Automate-The-Boring-Stuff-With-Python/Section_06_Lists/Lesson_16_Similarities_Between_Lists_&_Strings/SequenceDataTypes.py | 860 | 4.125 | 4 | """
Sequence Data Types
-------------------------
Description: Lists aren’t the only data types that represent ordered sequences of values. For example, strings and lists are actually similar if you consider a string to be a “list” of single text characters. The Python sequence data types include lists, strings, range ... |
3f95078c5c5c6901c6383b9a71b9e48141776a7e | vicentedr96/Fundamentos-de-python | /Estructuras de datos/ListaEnlazada_Simple/Listas_Enlazadas.py | 2,133 | 3.671875 | 4 |
from Nodo import Nodo
class Listas_Enlazadas():
#constructor
def __init__(self):
self.__primero=None
self.__size=0
def get_size(self):
return self.__size
def visualizar(self):
tmp=self.__primero
while(tmp!=None):
print(tmp.get_datos())
... |
bd7d21e6c48490b6e513423be546d53dd6ef878e | IsmailTitas1815/Data-Structure | /codeforces/Catalan number.py | 203 | 3.5 | 4 | def catalan(li,n):
for i in range(2,n+1):
for j in range(0,i):
li[i] += li[j]*li[i-j-1]
return li[n]
n = int(input())
li = [0]*(n+2)
li[0] = 1
li[1] = 1
print(catalan(li,n))
|
7b3be06c7f53af4fd4ac56f1d37090041211a1d0 | akshala/Data-Structures-and-Algorithms | /graph/partyMe.py | 1,018 | 3.59375 | 4 | class Graph:
def __init__(self, n):
self.vertices=n
self.graph={}
self.incomingGraph={}
def addEdge(self, u, v):
# outgoing edges
if u in self.graph.keys() and v not in self.graph.values():
self.graph[u].append(v)
else:
self.graph[u]=[v]
def remainingEdge(self):
for vertex in range(0, self.vert... |
e21b0b1c3b908a2c47df9b91e6eae03337572c2b | AlkaffAhamed/fip_powerx_mini_projects | /mp_calc/app/serverlibrary.py | 6,630 | 3.8125 | 4 |
def mergesort(arr, key):
if len(arr) < 2:
return arr
mid = len(arr) // 2
print(arr)
left = arr[:mid]
right = arr[mid:]
mergesort(left, key)
mergesort(right, key)
i = j = k = 0
while i < len(left) and j < len(right):
if key(left[i]) < key(right[j]):
arr... |
a34251fab9e9a497d5baf8fc8934c7b4f809748f | bullethammer07/python_code_tutorial_repository | /python_concepts_and_basics/python_list_comprehensions.py | 3,549 | 4.8125 | 5 | #-------------------------------
# Python List Comprehension
#-------------------------------
# NOTE : List Comprehensions use : []
# List comprehension is an elegant way to define and create lists based on existing lists.
#----------------------------------------------------------------------------------------... |
423de51be9be32af209fe28ab348d8c74825a5c0 | CodingProgrammer/Algorithm | /每日一题/35搜索插入的位置.py | 2,639 | 3.921875 | 4 | '''
Descripttion: 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。
你可以假设数组中无重复元素
version: 1
Author: Jason
Date: 2020-12-02 16:12:58
LastEditors: Jason
LastEditTime: 2020-12-02 16:55:47
'''
import random
from typing import List
def GenerateRandomList(number, size):
temp = list()
ra... |
21f4264de16bf8189f86c16796242519b1e34635 | moussadiene/Algo_td1 | /algo_td1_python/Exercice_22.py | 1,254 | 3.703125 | 4 | #coding:utf-8
"""
Exercice 22 :
On se propose de saisir N entiers différents entre 1 et 100 (N étant un entier naturel
compris entre 10 et 50) puis afficher la plus longue séquence croissante tout en précisant la
position du premier nombre de cette séquence.
Exemple : Pour N=15
1 2 3. 1 2 3 ... |
9159cd59da3bd0178d4595099cba3fa7a653889c | Mafyou/HackerRank | /nonDivisibleSubset/main.py | 436 | 3.59375 | 4 | import itertools
#https://www.hackerrank.com/challenges/non-divisible-subset/problem
def nonDivisibleSubset(k, S):
n = len(S)
while n > 1:
sets = itertools.combinations(S, n)
for set_ in sets:
if all((u+v) % k for (u, v) in itertools.combinations(set_, 2)) != 0:
retur... |
eb2829e3df3d2d0334a21b9cf58806409c71cc40 | chl218/leetcode | /python/stuff/0203-remove-linked-list-elements.py | 981 | 3.875 | 4 | """
Given the head of a linked list and an integer val, remove all the nodes of the
linked list that has Node.val == val, and return the new head.
Example 1:
Input: head = [1,2,6,3,4,5,6], val = 6
Output: [1,2,3,4,5]
Example 2:
Input: head = [], val = 1
Output: []
Example 3:
Input: head = [7,7,7,7], val = 7
Output... |
043fb3e49294181627eb4cedeb73dadedffddcb1 | oilneck/comphys | /sources/answer07.py | 486 | 3.578125 | 4 | import matplotlib.pyplot as plt
def fibo(n):
if n==0:
f_p = 0
elif n==1:
f_p = 1
else:
f_p_2 = 0
f_p_1 = 1
for p in range(2, n+1):
f_p = f_p_1 + f_p_2
f_p_2 = f_p_1
f_p_1 = f_p
return f_p
x_list = range(1, 101)... |
511443217f8ceb8232c99e69ff53d3eec166c722 | stellakaniaru/practice_solutions | /century_year.py | 603 | 4.28125 | 4 | '''
Create a program that asks the user to enter their name and age.
Print out a message addressed to them that tells them the year
they will turn a 100 yrs old.
'''
import datetime
#prompt user to enter name and age
name = input('Enter name: ')
age = int(input('Enter age: '))
#get the current year
year = datetime.d... |
7118a1977ca37e00caa400685de7533426d928ce | allisondsharpe/dpwp | /Dynamic Site/dynamic-site/data.py | 3,882 | 4 | 4 | '''
Name: Allison Sharpe
Date: 10-17-15
Class: Design Patterns for Web Programming
Assignment: Dynamic Site
'''
class Data(object): #Data() class created to contain objects and attributes created within those objects for DataObject() class
def __init__(self):
home = DataObject() #Home object instantiated ... |
c966430836ea6a7d5c7ec22a1900ba3a1e7dc064 | leopra/NLPExercises | /exercise16-4.py | 1,181 | 3.609375 | 4 | import nltk
nltk.download('wordnet')
nltk.download('stopwords')
from nltk.tokenize import sent_tokenize, word_tokenize
from nltk.tag import pos_tag
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
strings = "Radio is the technology of signaling and communicating using radio waves. \
Radio wav... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.