blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
77f4088fcda44652108fab716f53e2752ebfb0a5 | b0g3r/appendix_assignment_task | /files.py | 565 | 3.546875 | 4 | """
Module with main technical task logic: reading, writing, deleting and processing files.
"""
import os
def get_file_content(file_name: str) -> bytes:
with open(file_name, 'br') as file:
file_content = file.read()
return file_content
def append_content(file_name: str, content: bytes) -> int:
... |
e0598247c2ac3c449dc90e93b84cf037a98ea14d | yjang43/ssc_project | /extract_stats.py | 1,723 | 3.609375 | 4 | """
The script extracts all the links from "https://ssc.wisc.edu/sscc/pubs/stat.htm" targeting specifically
stat related links.
The content of this page was under #RightContentRightCol > div of the page, so I extracted all <a href> tags
with href under that html file.
Few filters were applied because some links directs... |
41508367d50df15065cec2634c52d149a1d3a242 | grudnks/projecteuler | /problem 07/problem_7.py | 322 | 3.75 | 4 | #!/usr/bin/env python3
def is_prime(n):
for i in range(2, int(n**0.5+1)):
if not n % i:
return False
return True
def get_prime(n):
prime_counter, num = 0, 1
while prime_counter != n:
num += 1
if is_prime(num):
prime_counter += 1
return num
print(get_prime(10001))
# Answer: 10474... |
109bafda5225fcf55a894e86625c8da54aef5e21 | grudnks/projecteuler | /problem 04/problem_4.py | 500 | 3.609375 | 4 | #!/usr/bin/env python3
def is_palindrome(n):
return str(n) == str(n)[::-1]
def get_lp(n, m):
palindrome = 0
digits = [0, 0]
n1 = n
while n1 > 99:
n2 = m
while n2 > 99:
prod = n1*n2
if prod > palindrome:
if is_palindrome(prod):
... |
b1cff2e2be5fc5b3c99833102c7382dbe6efe8af | Loser-001/p_008 | /chap6/demo14.py | 564 | 4.15625 | 4 | #位 置:南京邮电大学
#程 序 员:邱礼翔
#开发时间:2020/10/29 19:20
a=20
b=100 #两个整数类对象的相加操作
c=a+b
d=a.__add__(b)
print(c)
print(d)
class Student:
def __init__(self,name):
self.name=name
def __add__(self, other):
return self.name+other.name
def __len__(self):
return len(self.name)
stu1=Student('张三')
s... |
fc2a1870e98be5abae3b215fc719125eae7ccedf | Loser-001/p_008 | /chap4/demo5.py | 624 | 4.1875 | 4 | #位 置:南京邮电大学
#程 序 员:邱礼翔
#开发时间:2020/10/25 16:09
'''
for item in 'python':
print(item)
for i in range(10):
pass
print(i)
for _ in range(5):
print('人生苦短,我用python')
sum=0
for j in range(1,101):
if j%2==0:
sum=sum+j
print(sum)
'''
a=135
print(int(a/100))
print(int(a/10%10))
print(a%10)
'''输出a100... |
17abeb92b7c28098c54ca8c031d6ce8ceaf94018 | seraj20-meet/YL1-201819 | /lab4.py | 420 | 3.75 | 4 | rec1= Rectangle(3,4)
print(rec1.Area())
print(rec1.perimeter())
class person(object):
def __init__(self, name, age, city, gender):
self.name= name
self.age = age
self.city = city
self.gender = gender
def eat(self, food):
print(self.name + " has eaten" + food)
def sleep(self,hours):
print(self.name + "has sl... |
37d51da68cb0e49b2a5068dba9bcbc8ad9b855cd | nikingo/dlmk_workspace | /1_theory/perceptron_sigmoid.py | 806 | 3.578125 | 4 | import os
import glob
import numpy as np
def forward(xs, w):
return np.dot(xs, w)
def sigmoid(xs):
return 1.0 / (1.0 + np.exp(-xs))
def learn(xs, ts, w, lr):
for _ in range(iteration):
#print("w s:", w)
ys = sigmoid(forward(xs, w))
#print("ys:", ys)
En = -(ts - ys) * ... |
5fd3fb7db52d00b3cf648350599acc84b98a6bd0 | fsarda/chiara | /dist_euclidiana_chiara.py | 620 | 3.5 | 4 | # itero por cada punto P
# itero por cada punto diferente a P y calculo su distancia respecto a P
# almaceno cada distancia calculada
# Determino la menor distancia y la retorno
import math
def dist_euclidiana(V1,V2):
distancias=[]
for i in range(len(V2)):
for j in range(len(V2)):
if i!=j:
... |
6a51b15b3f62446b58c4475959b3a861b6c55add | esolovev/ling2020 | /lectures/31.py | 6,332 | 4.09375 | 4 | # Простой пример с запуском одного потока
from threading import Thread, get_ident, active_count
from time import sleep
def my_job():
print("Starting my thread")
print(f'Now {active_count()} threads are running')
print(get_ident())
sleep(3)
print("Finishing my thread")
print(f'Now {active_coun... |
c16a4d2cb51863a144f5a9e33c46467620b8abd9 | LogSigma/unipy | /docstring.py | 916 | 4.5 | 4 | def func(*args, **kwargs):
"""
Summary
This function splits an Iterable into the given size of multiple chunks.
The items of An iterable should be the same type.
Parameters
----------
iterable: Iterable
An Iterable to split.
how: {'equal', 'remaining'}
The method to sp... |
447d5eb9d159b704ae833df52552e02dff88e21d | DavLivesey/greedy_algoritms | /Swallow.py | 696 | 3.78125 | 4 | '''
Во сне Гоша долго играл в игру Лампочка.
Он то выигрывал, то проигрывал.
Ему стало интересно, сколько максимум партий подряд он
получал большее количество очков, чем в предыдущей.
'''
count_strikes = int(input())
strikes = list(map(int, input().split(' ')))
max_combo = 0
max_list = []
for i in range(len(strikes)):... |
10a391f00341fe6e138376cb42f51770e1e0d1b9 | DavLivesey/greedy_algoritms | /Ladder.py | 1,381 | 4 | 4 | '''
Евлампия выбрала себе классный дом.
Правда в нём нет лифтов, хотя этажей много.
Она решила, что ходить по лестницам долго и можно прыгать по ступенькам.
Дом старинный, ступеньки в нём разного размера.
Для каждой ступеньки известно, на какое максимальное
количество ступенек вверх с неё можно допрыгнуть.
Нужно помочь... |
f616610397737d17cffb921d93bf14c414e3b8f1 | Cuuuurry/Leet-Daily | /0084 Largest Rectangle in Histogram/stack.py | 526 | 3.546875 | 4 | from typing import List
class Solution:
def largestRectangleArea(self, heights: List[int]) -> int:
if not heights:
return 0
heights = [0] + heights + [0]
stack = []
candidates = [0]
for i in range(len(heights)):
# print(stack)
while stack... |
1ccded6a40e05eef4258aaa14b4f9805aa7e3045 | Synaxis/py | /ww3/syntax/dataTypes/dataTypes.py | 644 | 3.96875 | 4 | """Built-in Data Types
Python has the following data types built-in by default, in these categories:
Text type: str
Numeric Types: int,float,complex
Sequence Types: list,tuple,range
Mapping Type: dict
Set Types: set,frozenset
Boolean Type bool
Binary Types: bytes,bytearray,memoryview
Getting the Data Type
You can get... |
f6ae4bf3a725d8c5ce62e9c255799963a9228f74 | Synaxis/py | /Overview/basic.py | 381 | 3.953125 | 4 | #print("Hello World")
#print("Hello"[0])
# print number (no quotes)
#print(2)
# print any data type
#print(1,2,3,"Hello")
#Data types
myStr = "Hello"
myInt = 25
myFloat = 1.3
myList = [1,2,3,4,"Hello"]
myDict = {"a": 1, "b": 2, "c": 3}
print(type(myStr), myStr)
print(type(myInt), myInt)
print(type(myFloat), myFl... |
8c12b542361d4ef59f939b6a48967dd98d777356 | richnakasato/interviews | /print_primes.py | 829 | 3.84375 | 4 | def primes(n):
sqrt = 1
while (sqrt*sqrt) < n:
sqrt += 1
primes_list = list()
if n >= 2:
for i in range(2, n+1):
is_prime = True
for j in primes_list:
if not i%j:
is_prime = False
break
if j >... |
ca9ee9c4e9555b4e43bfdc23e8a5fe17a1ccec7f | richnakasato/interviews | /is_bst.py | 965 | 3.8125 | 4 | def helper(min_, node, max_):
if not node:
return True
curr = min_ < node.val <= max_
return curr and
helper(min_, node.left, node.val) and
helper(node.val, node.right, max_)
def is_bst_recurse(root):
if not root:
return False
else:
return helper(fl... |
44cc1efdc3f9e4bf3e96ba2d0b23849cb626aa12 | Nava-7/rasppi | /ag_p.py | 768 | 3.546875 | 4 | def setup_coin_acceptor():
"""Initialises the coin acceptor parameters and sets up a callback for button pushes
and coin inserts.
"""
print('begin setup_coin_acceptor')
# Defining GPIO BCM Mode
GPIO.setmode(GPIO.BCM)
# Setup GPIO Pins for coin acceptor, button and button-led
GPIO.setwarnings(False)
... |
6a7b74917ddc459d656b041d0885686cf98a08df | Revurevathy/BasicPython | /within.py | 154 | 4.15625 | 4 | n = input ('Enter the number ')
if 1000 < n > 2000:
print ' The number is between 1000 and 2000'
else:
print ' The number is not between 1000 and 2000'
|
f98e8b8d2bc7e5e1d1f2e0cc849dd6ca4de7ae41 | azyuqian/findcoursemate | /GPA.py | 3,056 | 3.5 | 4 | import re
import json
def load_json (json_filename):
"""Read the json file and return the content
"""
print(json_filename)
_datafile=open(json_filename)
try:
jsondata = json.load(_datafile)
except ValueError as e:
print ("{} : {}".format(json_filename,str(e)))
print("... |
0f3de1ca9f109820f0a5315fa716a6c882f76c4b | niushencheng/learn-py | /phantom_study/headers.py | 1,344 | 3.546875 | 4 | """
selenium设置自定义请求头
"""
from selenium import webdriver
def init_phantomjs_driver(*args, **kwargs):
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'User-Agent': 'Mozilla/5.0 (Windows NT... |
93fb3e97beb48d19375b11c7be000c01bdf91458 | niushencheng/learn-py | /bs_study/dict_join.py | 228 | 3.703125 | 4 |
if __name__ == '__main__':
dic = {'name': 'zhangsan',
'age': 18,
'sex': 'female'}
test = {'hehe':'hehe'}
for key, value in dic.items():
test['{}'.format(key)] = value
print(test)
|
3129de0e61ac9a3b05f804a3d2eac5bf17b57b9a | kosmitive/qlearn | /policies/Policy.py | 1,113 | 3.5 | 4 | class Policy:
"""Represents a basic policies_nn. It therefore needs a function, which
evaluates successfully the q function"""
def choose_action(self, q, config):
"""This method of a policies_nn basically gets a Q function
and has to return the action to take now. Here you can
speci... |
841e4bc8728cfc13d4da7892f35c899152450c5c | waarengeyevarun/Web-Information-Extraction | /scraping-nonsemi.py | 1,034 | 3.796875 | 4 | #Categorizing Nouns through pos and tokenizing without semi supervised learning
import nltk
nltk.download('punkt')
#opening and reading the text file
import io
with io.open("toread.txt", encoding="latin-1") as my_file:
mytext = my_file.read()
nouns = [] #empty to array to hold all nouns
#finding the n... |
7189ba01c745fb7cb1b4b945d073f9031defefed | jpanda111/LeetCode | /Algorithm/Easy/804_unique_morse_code_words.py | 2,519 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 11 15:57:55 2018
@author: yinjiang
International Morse Code defines a standard encoding
where each letter is mapped to a series of dots and dashes,
"a" maps to ".-", "b" maps to "-...", "c" maps to "-.-."
Given a list of words, each word can be written as a conc... |
135e11329ae25fc72ff7eca675a23605a3c2cb99 | jpanda111/LeetCode | /Algorithm/Easy/617_merge_two_binary_trees.py | 7,676 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 13 10:28:12 2018
@author: yinjiang
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
You need to merge them into a new binary tree. The merge rule is that if two ... |
9ce15397afb785181b32d3345ede03c9f40ccf3b | Masharelli/Quiz-5 | /Exercises/Exercise-8.py | 194 | 3.5625 | 4 | def is_palindrome(string):
return string == string[::-1]
if __name__ == "__main__":
print is_palindrome("aabbaa")
print is_palindrome("abc")
print is_palindrome("radar") |
2fcf952fb0b3c4f37e2ba40dee8fb2e4cd4c8ebb | lemon-lisa/lemon | /day04.py | 5,277 | 3.875 | 4 | '''
1:a=[1,2,'6','summer'] 请用成员运算符判断 i是否在这个列表里面 -- if
2:dict_1={"class_id":45,'num':20} 请判断班级上课人数是否大于5
注:num表示课堂人数。如果大于5,输出人数。
3、list1 = ['胖胖','龙哥','小卒','no longer','心灵治愈','小杨']
列表当中的每一个值包含:姓名、性别、年龄、城市。以字典的形式表达。
并且把字典都存在新的 list中,最后打印最终的列表。--list2=[]
方法1: 手动扩充--字典--存放在列表里面;{} --简单
方法2: 自动--dict()--不强制-- for循环 ,list2.a... |
14d0ec59b68092a8be783aaefb372717c56ee0f7 | lemon-lisa/lemon | /day01.py | 547 | 3.609375 | 4 | #
# name='李瑞轩'
# high=151
#
#
# print('''80期的班花是%s
# gender:人妖
# high:%s
# age:70
# '''%(name,high))
# #
# #
# # print('80期的班草是胖胖,'
# # 'gender:人妖')
# #
# # # print(type(666))
#
# # lemon = '柠檬'
# # print(lemon)
# str1='hello qihang'
# 01234567891011
# -4-3-2-1
# print('胖胖'+str(150))
# a=input('请输入... |
0d6e5cc623801ad4aabb842963fa2db8b9200d1e | l200180186-new/Prak_algostruk | /L200180186_modul7_kelasG/L200180186_Modul7_G.py | 11,158 | 3.765625 | 4 | import re # + importing modul re
s = 'sebuah contoh kata:teh!!' # + deklarasi variable s dengan value string value
cocok = re.findall(r'kata:\w\w\w',s) # + deklarasi cocok dengan value dari memilikiil fungsi findall pada re dengan... |
99c00fc2d375ad5bda5a0be629aaf60c2ce7dd9b | annaganay/lab-2 | /dialogue.py | 5,010 | 3.71875 | 4 | def input_str():
return str(input())
def var_check(counter_i, counter_j, text_for_person, var, opt):
if var in {1, 13, 14, 15, 16, 18}:
return counting_numbers(counter_i, text_for_person, var - 1, opt)
elif var in {2, 3, 5, 6}:
return text(counter_i, text_for_person, var - 1, opt)
... |
34767cf0bea377e1d6fb9870848a520ac4fad0d7 | agnaldom/impactar-ads | /logica-de-programacao/aula3.py | 226 | 4.0625 | 4 | # Operadores, expressoes logicas e estrutura de selecao
#
# Verificar se o numero digita é impor ou par
numero = int(input("Digite um numero: "))
if numero % 2 == 0:
print("Número para")
else:
print("Número impar")
|
7ed95d25e7474dcb6c334790376bd756d62211e4 | agnaldom/impactar-ads | /logica-de-programacao/aula5-1.py | 162 | 3.875 | 4 | # Variavel acumulador
#
cont = 1
soma = 0
numero = int(input("Digite um numero: "))
while cont <= 10:
soma = soma + cont * 2
cont = cont + 1
print(soma)
|
01d68c464d5c9c88ee69622244b4b3aa39473455 | gbrough/tic_tac_toe | /tic_tac_toe_ai_video.py | 3,248 | 3.953125 | 4 | import random
playerLetter = 'X'
computerLetter = 'O'
#define our board
board = [' ' for i in range(10)]
def print_board():
print('#########################')
print(board[1] + '|' + board[2] + '|' + board[3])
print('----------')
print(board[4] + '|' + board[5] + '|' + board[6])
print('----------')
print(... |
0a1bf0f1e7a7e6e1c1300581d3650d74bdb1819d | lishirui-git/hive_tools | /create.py | 254 | 3.625 | 4 | price = 0
while price + 10 <= 200:
strs = ",when (min_build_area > {} and min_build_area <= {}) or (max_build_area > {} and max_build_area <= {}) then '({},{}]'".format(price, price+10,price,price+10,price,price+10)
print strs
price += 10
|
6eb751c3994402409875bc5dbccc17c0c5bcb943 | sanyabas/cryptoprotocols | /05. bit_commitment/main.py | 1,473 | 3.75 | 4 | from secrets import randbits
from Crypto.Cipher import AES
from hashlib import md5
def main():
print("Storing bit with encryption")
encrypt()
print()
print("Storing bit with hash")
hashing()
def encrypt():
key = randbits(16 * 8)
r = randbits(15 * 8 + 7)
b = randbits(1)
input_byte... |
9d07ce046e2c46a928da07c2d6578f7e91d1df9b | kristinamb15/cracking-the-coding-interview | /1_ArraysStrings/1.4.py | 1,286 | 4.15625 | 4 | # 1.4 Palindrome Permutation: Given a string, write a function to check if it is a permutation of a palindrome.
# The palindrome does not need to be limited to just dictionary words.
# You can ignore casing and non-letter characters.
import unittest
# Solution 1
# O(N)
def palindrome_perm(mystring):
mystring = my... |
e6c6cc142d1aee5876b593f1b1d21586010fb4f8 | kristinamb15/cracking-the-coding-interview | /3_StacksQueues/3.4.py | 1,411 | 4 | 4 | # 3.4 Queue via Stacks: Implement a MyQueue class which implements a queue using two stacks.
import unittest
from queue import LifoQueue
class MyQueue:
def __init__(self):
self.tempStack = LifoQueue()
self.queueStack = LifoQueue()
def pushQueue(self, item):
while not self.queueStack.e... |
e5126c908797753a676eb2db42a51ee7c1ab99de | kristinamb15/cracking-the-coding-interview | /2_LinkedLists/2.4.py | 2,267 | 4.09375 | 4 | # 2.4 Partition: Write code to partition a linked list around a value x, such that ll nodes less than x come before all nodes greater than or equal to x.
# The partition element x can be anywhere in the "right partition" - it doesn't have to be in the middle
# Ex: 3, 5, 8, 5, 10, 2, 1 becomes 3, 1, 2, 10, 5, 5, 8
impo... |
28c5b9b66ea0843bd144a842db02998a8f1c2b35 | Prabhat-Thapa45/Flower-Store | /test/test_order.py | 2,435 | 3.578125 | 4 | """ this module tests order.py """
from src.order import Order, cancel
from src.utility.constants import BQ_SIZE, YOUR_CART, STOCK
def test_cancel():
"""
clears items from your cart
"""
cancel()
assert YOUR_CART == []
class TestOrders:
""" has test cases for post requests in order.py """
... |
080405d536c8d311e48800df3bdb8cd9b304c2de | Vladimir4063/Python_PildorasInformaticas | /42.interface_grafica/45.EjemploEntry.py | 2,130 | 3.625 | 4 | from tkinter import *
root = Tk()
miFrame=Frame(root, width=600, height=600)
miFrame.pack()
minombre= StringVar() #Indicamos que se trata de una cadena de caracteres
cuadroNombre = Entry(miFrame, textvariable=minombre) #Caja esta asociada al disparo de la variable
#cuadroTexto.place(x=100, y=100) #Place sirve para ... |
a7464cec4dce2c41580f0c8b7b8dcf7ac2cac23f | Vladimir4063/Python_PildorasInformaticas | /13.condicionalesIV.py | 889 | 4.0625 | 4 | # "and" = "y, si ademas" _____ Obliga a que se cumplan todas las condiciones.
# "or" = "o, sino"
# ______________________________
# distancia > 40km
# nro hermanos > 2
# salario familiar <=20.000
print("Programa de becas.")
distancia_escuela = int(input("Introduce la distancia a la escuela en km: "))
print(distancia... |
78a3bf858c71b6698c8cba9f1f7efdc8942aaaed | Vladimir4063/Python_PildorasInformaticas | /14.2.practica_for.py | 355 | 3.890625 | 4 | """
for i in range(5):
print(f"valor de la variable {i}")
for i in range(5, 50 ,3):
print(f"valor de la variable {i}")
"""
valido = False
email = input("Introduce tu email: ")
for i in range(len(email)):
if email[i] == "@":
valido = True
if valido:
print("Email Correcto.")
else... |
291b132726c8e09b540de1246a4d901dbe880f8c | Vladimir4063/Python_PildorasInformaticas | /34.modulos/Paquete/calculos/calculos_generales.py | 491 | 3.828125 | 4 | def sumar(num1, num2):
print("El resultado de la suma es: ", num1 + num2)
def restar(num1, num2):
print("El resultado de la resta es: ", num1 - num2)
def dividir(num1, num2):
print("El resultado de la division es: ", num1 / num2)
def multiplicar(num1, num2):
print("El resultado de la multiplicacion e... |
174166933803d8d1e0a7e8b1f61c473eb6d54cb2 | Vladimir4063/Python_PildorasInformaticas | /19.0.practica_generador.py | 687 | 3.875 | 4 | def GeneraPares(limite):
num = 1
miLista = []
while num < limite:
miLista.append(num*2)
num = num + 1
return miLista
print(GeneraPares(10))
#___________________________ Generador
def generaPares(limite1):
num1 = 0
while num1 ... |
455cb85b97bf991eb9718c457d849fe58fb67c42 | estradae21/Computer-Science-2 | /N_Queens/N_Queens.py | 3,191 | 3.796875 | 4 | from __future__ import print_function
import sys
import unittest
'''
Ernesto Estrada
Received help: Roach and stackoverflow
Given the location of two queens, find if they are safe
from each other.
'''
def safe(one, two):
if one[0] == two[0]:
return False
if one[1] ==... |
26e56f95b80fede632cac43ae5ef9afd61a52461 | JJCAlready/MachineLearning | /Models/Linear/Trabajos/WorkData.py | 2,386 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Sep 6 01:03:22 2019
@author: soyel
"""
#=======Preprocessing data part==============
# Importing the libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Importing the dataset
dataset = pd.read_csv('Works_Data.csv', s... |
c1d2d073d4e0123355b0968015c26d45aeda18bb | AlexisEnriquez/IBM-Data-Science-Professional-Certificate | /Python for Data Science, AI and Development/07_objects_and_classes.py | 5,873 | 4.6875 | 5 | # Course 4
# Python for Data Science, AI & Development
# 7-Objects and Classes
#Classes
# Import the library
import matplotlib.pyplot as plt
%matplotlib inline
# Create a class Circle
class Circle(object):
# Constructor
def __init__(self, radius=3, color='blue'):
self.radius = rad... |
bafcd6b2dfa1141f52122454cb1201c22ffcfad0 | AlexisEnriquez/IBM-Data-Science-Professional-Certificate | /Data Visualization with Python/05_creating_maps_and_visualizing_goespatial_data.py | 19,759 | 3.75 | 4 | # Course 9
# Data Visualization with Python
# 5- Creating Maps and Visualizing Geospatial Data
''''
enerating Maps with Python
Estimated time needed: 30 minutes
Objectives
After completing this lab you will be able to:
Visualize geospatial data with Folium
Introduction
In this lab, we will learn how to ... |
41d9731ee7fb843409fe414f3570c457ae2440b8 | AlexisEnriquez/IBM-Data-Science-Professional-Certificate | /Data Visualization with Python/03_specialized_vistualization_tools.py | 29,198 | 4.09375 | 4 | # Course 9
# Data Visualization with Python
# 3- Specialized Visualization Tools
''''
Exploring Datasets with pandas and Matplotlib
Toolkits: The course heavily relies on pandas and Numpy for data wrangling, analysis, and visualization. The primary plotting library we will explore in the course is Matplotlib.
... |
476d313fb779cc507312d43453f1fa2c946baefc | AlexisEnriquez/IBM-Data-Science-Professional-Certificate | /Python Project for Data Science/01_webscraping_using_beautifulsoup.py | 15,419 | 4.40625 | 4 | # Course 5
# Python Project for Data Science
# 1- Intro to Web Scraping Using BeautifulSoup
#For this lab, we are going to be using Python and several Python libraries. Some of these libraries might be installed in your lab environment or in SN Labs. Others may need to be installed by you. The cells below will ins... |
c21761b525133e443d97002d0ba6f33a33f13a02 | 00arun00/LeetCode | /py/0-99/3_longest_substring_without_repeating_characters.py | 867 | 3.859375 | 4 | class Solution:
def lengthOfLongestSubstring(self, S: str) -> int:
"""
Takes in a string S and returns the length of the longest
substring without repeating characters
Args:
S : (str) String of chars
Returns:
maxLength : (int)... |
eaac82b9fe0a9bb5eff99d38a3d75cfa23e3cdc6 | jorgepdsML/Threads_Projects_Python | /threading_sub_class_example2/threading_sub_class_python.py | 1,093 | 4.21875 | 4 | """
uso del modulo threading mediante la definición de una sub_clase
la herencia viene de la clase base Thread
"""
import threading
import time
class BThread(threading.Thread):
#atributo de clase
Nthread=0
#overriding el método __init__()
def __init__(self,name="braintels"):
#invocar ... |
a0ce956b3fd906c7b789fe3bc42b2ebbb8c30dc0 | kirthikartm/guvi | /string_greater.py | 70 | 3.640625 | 4 | a,b=input("").split()
if(a<b):
print(b)
elif(a==b):
print(a)
|
3e7fdc77df61bccafd7c060901aa22faa52807b8 | kirthikartm/guvi | /swap_odd_even.py | 91 | 3.5625 | 4 | a=input()
a=list(a)
for i in range(0,len(a),2):
a[i],a[i+1]=a[i+1],a[i]
print("".join(a))
|
9fb91d620e608eeb6a563d8ed8299938f92bb412 | ShehabAhmedSayem/Rosalind-Chapterwise | /Chapter 1/ba1n.py | 991 | 3.90625 | 4 | # Problem Name: Generate the d-Neighborhood of a String
def read_input_from_file(file_name):
with open(file_name, 'r') as file:
string = file.readline().strip()
d = file.readline().strip()
return string, int(d)
def hammingDistance(string1, string2):
distance = 0
for i in range(len(st... |
616067b46918e0940fcf1805d8e3ae12ab0bbf2f | ShehabAhmedSayem/Rosalind-Chapterwise | /Chapter 1/ba1a.py | 691 | 4.15625 | 4 | # Problem Name: Compute the Number of Times a Pattern Appears in a Text
def read_input_from_file(file_name):
with open(file_name, 'r') as file:
string = file.readline().strip()
pattern = file.readline().strip()
return string, pattern
def occurrence(string, pattern):
"""
string... |
f8b875595f336a2d7ad29db2b2f6051f5340f82d | Cmartis/pythonsrc | /examples/automate/ch05_01.py | 555 | 4.28125 | 4 | birthdays = {'rachel':'26th Sept 2006', 'ryan':'9th Jan 2003', 'chris':'28th Jan 1973', 'medha':'8th Sep 1973', 'rita':'14th July 1940'}
while True:
print('enter a name: (blank to quit]')
name = input()
if name == '':
break
if name in birthdays:
print(birthdays[name] + ' is the birthda... |
864401be5d0d0ba69503da811f67cebe37edbaa4 | Mustafa-Filiz/HackerRank--Edabit--CodeWars | /Codewars_12_ROT13.py | 1,234 | 4.65625 | 5 | # ROT13
"""
ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.
Create a function that takes a string and returns the string ciphered with Rot13. If there are numbers or special characters included in the str... |
e6d5d70aae160e33fd3badaf6b9f065f6a22cc4a | Jiwoopark0508/baekjoon_alg | /jiwoo/9461.py | 400 | 3.5 | 4 | import sys
def dynfib( level, a0, a1, a2 ):
if( level == 0 ):
return a0 + a1
elif( level == -1 ):
return a2
elif( level == -2 ):
return a1
elif( level == -3 ):
return a0
else:
return dynfib( level - 1, a1, a2, a0+ a1)
for i in range ( int( sys.stdin.re... |
e19737e24d56428fa44a5b0e28311b91bfc02539 | InovaCidades/PythonFragments | /src/CodeAcademy/04 - Date and Time/Exercicio36.py | 667 | 3.90625 | 4 | #Print the date and time together in the form: mm/dd/yyyy hh:mm:ss.
#To start, change the format string to the left of the % operator.
#Ensure that it has 6 %s placeholders.
#Put slashes and colons and a space between the placeholders so that they fit the format above.
#Then, change the variables in the parentheses ... |
a1a95047638f4f6857ab5f488d15280f95b81390 | InovaCidades/PythonFragments | /src/CodeAcademy/03 - Strings & Console Output/Exercicio21.py | 207 | 3.984375 | 4 | #Create a variable pi and set it to 3.14 on line 4.
#Call str(pi) on line 5, after print.
"""Declare and assign your variable on line 4,
then call your method on line 5!"""
pi = 3.14
print str(pi)
print
|
fa156eed3864ba996a51c74c9b6feecd7385c348 | InovaCidades/PythonFragments | /src/CodeAcademy/03 - Strings & Console Output/Exercicio24.py | 299 | 3.828125 | 4 | #Declare a variable called the_machine_goes and assign it the string value "Ping!" on line 5.
#Go ahead and print the_machine_goes in line 6.
"""Assign the string "Ping!" to
the variable the_machine_goes on
line 5, then print it out on line 6!"""
the_machine_goes = "Ping!"
print the_machine_goes
|
0003e93dd52205d1c011ba71ab8601bfc55961d2 | InovaCidades/PythonFragments | /src/CodeAcademy/05 - Conditionals & Control Flow/Exercicio37.py | 546 | 3.703125 | 4 | #Set each variable to True or False depending on what you think the result will be. For example, 1 < 2 will be True, because one is less than two.
#Set bool_one equal to the result of 17 < 328
#Set bool_two equal to the result of 100 == (2 * 50)
#Set bool_three equal to the result of 19 <= 19
#Set bool_four equal to t... |
d8ad0945acb41da09f474325b940b6b289bd91ad | newemailjdm/intro_python | /121515/conditional.py | 337 | 4.21875 | 4 |
first_name = input("What's your first name")
name_length = len(first_name)
if name_length > 10:
print("That's a long name!")
elif name_length > 3:
print("Nice, that's a name of medium length.")
elif name_length == 3:
print("That's a short name.")
else:
print("Are you sure those aren't ... |
55c2a8aec0bbab5db3427ed6f5dd00cb7b1e1f25 | BhanuJamwal/algorithms | /solveMeFirst.py | 165 | 3.59375 | 4 | def solveMeFirst(num1,num2):
num3=num1+num2
return num3
num1 = int(raw_input())
num2 = int(raw_input())
res = solveMeFirst(num1,num2)
print res |
83a1611d3673951ca106228ea3b28e55c97a85b1 | AnkurPokhrel8/LinkedList | /LinkedList.py | 2,012 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Ankur Pokhrel
"""
class Node: # Node class
def __init__(self, data):
self.data = data
self.next = None
class LinkedList: # Linkedlist class
def __init__(self):
self.head = None
def addNode(... |
8230e757dff85fba84cdee168057e82551707492 | Mint2702/Zakaz2 | /stonks2.py | 558 | 3.59375 | 4 | def get_students():
massive = str(input()).split(" ")
students_on_start = massive[0]
students_on_finish = massive[1]
return students_on_start, students_on_finish
def check_for_devision(first, second):
if int(second[: len(first)]) % int(first) == 0:
return True
elif int(second[: len(fir... |
6243bfacd386b76e0bf1fb38183e40bba96c48d9 | jmason86/python_convenience_functions | /lat_lon_to_position_angle.py | 982 | 4.1875 | 4 | import numpy as np
def lat_lon_to_position_angle(latitude, longitude):
"""Function to translate heliocentric coordinates (latitude, longitude) into position angle
Written by Alysha Reinard and James Paul Mason.
Inputs:
longitude [float]: The east/west coordinate
latitude [float]: The nort... |
61662458348da73355f520cd17ec89ef8b32a727 | phucle1112/Software-Engineering | /SE/Multiplesof3and5/multiplesof3and5.py | 429 | 3.734375 | 4 | ###########################################
# Software Engineering
# Multiples of 3 and 5 below 1000
# Phuc Le - 456061
###########################################
total = 0
result1 = False
result2 = False
for i in range (1, 1000):
result1 = i % 3 == 0 # Sum of all multiples of 3
result2 = i % 5... |
6fb1dbc60a6185deed6e8de6d68d0ce8f16bb05d | oliverkroening/Udacity_DSND_Project05 | /data/process_data.py | 3,272 | 3.609375 | 4 | import sys
import pandas as pd
from sqlalchemy import create_engine
def load_data(messages_path = "disaster_messages.csv",
categories_path = "disaster_categories.csv"):
'''
Function: load and merge message and categorie databases from csv files
Args:
message_path (str): path of me... |
de746dd3ad3baa53b1d629ed91fe4bae2f32a160 | aaron-prindle/new-interview | /removeDup.py | 543 | 3.65625 | 4 | class Node:
def __init__(self,key=None, nxt=None):
self.key = key
self.nxt = nxt
def removeDup(head):
seen = {}
last = None
while(head!=None):
if seen.get(head.key, None):
remove(last, head)
else:
seen[head.key] = True
last = head
head = head.nxt
def remove(last,cur):
las... |
1223238c6a2dc4bc3dc3c0e106f6da437010d9ff | aaron-prindle/new-interview | /lowestCommonAncestor.py | 987 | 3.59375 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x,left=None,right=None):
self.val = x
self.left = left
self.right = right
def inOrder(root,out):
if not root:
return
inOrder(root.left,out)
out.append(root)
inOrder(root.right,out)
def postOrder(root,out... |
c2ffd5731166023f624d641454c76b459805755a | aaron-prindle/new-interview | /anagramss.py | 529 | 3.71875 | 4 | # @param {string[]} strs
# @return {string[]}
def anagrams(strs):
out = []
anagramDict = {}
anagramSet = set()
for word in strs:
sortedWord = "".join(sorted(word))
if sortedWord in anagramDict:
anagramDict[sortedWord].append(word)
else:
anagramDict[sortedWord] = [word]
for key in anagr... |
b9030eeb0121de6157a25fcbc58409d0cd6e7eae | aaron-prindle/new-interview | /findPeak.py | 628 | 3.796875 | 4 | def findPeakElement(nums):
return peakSearch(nums,0,len(nums)-1)
def isPeak(arr,index):
l = -1
r = -1
way = ""
if index!=0:
l = arr[index-1]
way = "right"
if index != len(arr)-1:
r = arr[index+1]
way = "left"
if l < arr[index] > r :
return True,way
return False,way
def peakSearc... |
c68e3f787b40aa277b6c9467f210dd5d1a81b230 | aaron-prindle/new-interview | /minStackLeet.py | 1,269 | 3.890625 | 4 | class ListNode:
def __init__(self,val):
self.val = val
self.nxt = None
class MinStack:
# initialize your data structure here.
def __init__(self):
self.top = None
self.minTop = None
# @param x, an integer
# @return nothing
def push(self, x):
new = ListNode(x)
if not self.top:
... |
a1ec2b2cf6fda75ff5d4e455c56d6a8ca1c81c8a | aaron-prindle/new-interview | /mergeSortedArrays.py | 550 | 3.9375 | 4 | #questions, should i check to make sure there is enough space?
#A is null?
#B is null?
#A is empty?
#B is empty?
def mergeSortedArrays(A,aP,B):
aS = 0
bS = 0
bP = len(B)-1
cur = len(A)-1
while bP>=bS:
print aP
print bP
print "========================================"
if aP >= 0 and A[aP] > B[... |
6ec1488a0ce8362088c192491b43b6079837b172 | hadesLiu/python100d | /day03-分支机构/grade.py | 534 | 3.5625 | 4 | # -*- coding: utf-8 -*-
# @Author : hiro,
# @Mail : hiroliu@yeah.net
# @FileName: grade.py
# @Time : 2019/5/24 9:23 AM
"""
百分制成绩转等级制成绩
90分以上 --> A
80分~89分 --> B
70分~79分 --> C
60分~69分 --> D
60分以下 --> E
Version: 0.1
Author: 骆昊
"""
score = float(input('请输入成绩:'))
if score >= 90:
grade = 'A'
e... |
7a9c22cdc58108bf175cc08bcd9a63b069caec0c | hadesLiu/python100d | /day08-面向对象编程基础/circle.py | 1,412 | 4.3125 | 4 | # -*- coding: utf-8 -*-
# @Author : hiro,
# @Mail : hiroliu@yeah.net
# @FileName: circle.py
# @Time : 2019/6/3 7:27 PM
"""
练习
修一个游泳池 半径(以米为单位)在程序运行时输入 游泳池外修一条3米宽的过道
过道的外侧修一圈围墙 已知过道的造价为25元每平米 围墙的造价为32.5元每米
输出围墙和过道的总造价分别是多少钱(精确到小数点后2位)
Version: 0.1
Author: 骆昊
Date: 2018-03-08
"""
from math import pi
class Circ... |
da3a597f448daafe0adb315b8c0f2b4af401d04c | hadesLiu/python100d | /day07-字符串和常用数据结构/trianglesYangHui.py | 1,433 | 3.734375 | 4 | # -*- coding: utf-8 -*-
# @Author : hiro,
# @Mail : hiroliu@yeah.net
# @FileName: trianglesYangHui.py
# @Time : 2019/6/3 11:00 AM
"""
打印杨辉三角
1
1 1
1 2 1
1 3 3 1
"""
def main():
num = int(input('Number of rows: '))
yh = [[]] * num
for row in range(len(yh)):
yh... |
623d53d3f337179053bb6e7cb2733e134af20058 | hadesLiu/python100d | /day03-分支机构/tax.py | 1,276 | 3.828125 | 4 | # -*- coding: utf-8 -*-
# @Author : hiro,
# @Mail : hiroliu@yeah.net
# @FileName: tax.py
# @Time : 2019/5/26 10:40 AM
"""
输入月收入和五险一金计算个人所得税(2017版)
Version: 0.1
Author: 骆昊
补:
计算公式:
应纳税所得额 = 工资收入金额 - 各项社会保险费 - 起征点(3500元)
diff = salary - insurance - 3500
应纳税额 = 应纳税所得额 x 税率 - 速算扣除数
tax = diff * rate - deductio... |
2d0de51bce458274e104134241c8e486c80ed5f8 | sandipans814/BCSE_Assignments | /OOPS/Python/Assignment2/A2.py | 257 | 3.859375 | 4 | def fib():
a = 0
b = 1
i = 1
while i<=7 :
c = a + b
a = b
b = c
yield b
i = i + 1
fibonacci = fib()
while True:
try:
print(next(fibonacci),end = " ")
except StopIteration:
break |
55da9a4b9981f00d66d30e7b77f1561379237385 | sandipans814/BCSE_Assignments | /OOPS/Python/Assignment 1/A8.py | 188 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 11 17:55:10 2020
@author: Dell
"""
li = [x for x in range(51)]
final_list = list(filter(lambda x : (x%5==0),li))
print(final_list) |
524cbff859764ddb32f7ab3e2e11981076d02af7 | sandipans814/BCSE_Assignments | /OOPS/Python/Assignment2/A3.py | 471 | 3.734375 | 4 | import time
def gp(base,cm=1):
series = []
x = time.time()
while base < 100000 :
series.append(base)
base *= cm
y = time.time()
print("Time inside loop" + str(y-x) + "seconds")
return series
start = time.time()
a = int(input("Enter the value of a: "))
q = int(input("Enter the va... |
6ed7714854261ec7ced8549f05dc599a68d573f5 | sandipans814/BCSE_Assignments | /OOPS/Python/Assignment 1/A7.py | 194 | 3.796875 | 4 | def main():
usr_input = input("Enter 5 numbers : ")
integers_list = list(map(int, usr_input.split()))
print(sorted(integers_list, reverse=False))
if __name__=="__main__":
main() |
16fdab9d7a9023f9b99fcf20dea0b2076da783cc | cmcoder9/web-scraping-challenge | /Missions_to_Mars/scrape_mars.py | 2,423 | 3.546875 | 4 | from splinter import Browser
from bs4 import BeautifulSoup
import time
def init_browser():
# @NOTE: Replace the path with your actual path to the chromedriver
executable_path = {"executable_path": "chromedriver"}
return Browser("chrome", **executable_path, headless=False)
def scrape():
# {} means cr... |
337f9c4898acc3a06c5e371866bc30d1d49e7982 | Ankit1818/My-Captian-Python | /My Captian Python/Task 8.py | 138 | 3.9375 | 4 | def multiply(numbers):
total = 1
for n in numbers:
total *= n
return total
print(multiply((1, 2, 3, 5, 6))) |
83202717f91b6c98ddc664bd2739311a503319ad | jolleyjames/Advent-of-Code-2020 | /day02.py | 2,790 | 3.75 | 4 | '''
Advent of Code 2020, Day 2.
James Jolley, jim.jolley [at] gmail.com
'''
def yield_matches(c, s):
'''
Yields each character c that appears in string s
'''
x = 0
while x < len(s):
if s[x] == c:
yield c
x += 1
def check1(policy, passwd):
'''
Checks if a plainte... |
2d8f767ad7d6538a4c4cb0a46e2240eccf9dec85 | LogicPenguins/BeginnerPython | /CSV_Projs/remove_csv_header.py | 1,305 | 3.625 | 4 | #! python3
# remove_csv_header.py - Removes the headers from .csv files.
from pathlib import Path
import os
import csv
# Creates a seperate folder for modified .csv files.
os.makedirs(f'{Path.home()}\\small-projects-python\\CSV_Projs\\header_removed', exist_ok=True)
# Directory path will vary on different systems.
... |
797bb7a2dacd8bda7ac2322cdec945caa490b381 | LogicPenguins/BeginnerPython | /Collatz Conjecture/collatz.py | 300 | 3.90625 | 4 | def sequence(num):
modified_num = num
while modified_num != 1:
if modified_num % 2 == 0:
modified_num /= 2
else:
modified_num *= 3
modified_num += 1
print(f'{num} failed the collatz sequence')
for i in range(1000000):
sequence(i+1) |
94418a9660befad407049a9b6b6c3e3708c3e394 | LogicPenguins/BeginnerPython | /Udemy Course/HW Funcs & Methods/exer3.py | 444 | 4.375 | 4 | # Write a Python function that accepts a string and calculates the number of upper case
# and lowercase letters.
def case_info(string):
num_upper = 0
num_lower = 0
for char in string:
if char.islower():
num_lower += 1
elif char.isupper():
num_upper += 1
print(f'U... |
a75dd565dd5cb8b373b4a0a435c282582039ef04 | LogicPenguins/BeginnerPython | /Excel_Projs/txt-to-spreadsheet.py | 1,838 | 3.78125 | 4 | #! python3
# txt-to-spreadsheet.py - Takes text file inputs and converts lines in file to excel spreadsheet
# Note: Should change paths in code accordingly
from openpyxl.utils import get_column_letter
import pyinputplus as pyip
from pathlib import Path
import openpyxl
import os
print('How many .txt files would you l... |
92f2f2eb84f3cdd0bde93a5dd767da1f562dd1e4 | LogicPenguins/BeginnerPython | /rpg/start.py | 547 | 3.578125 | 4 | class decorator_class(object):
def __init__(self, original_function):
self.original_function = original_function
def __call__(self, *args, **kwargs):
print(f'Call method executed this before {self.original_function.__name__}')
return self.original_function(*args, **kwargs)
@decora... |
0d8fb57d5dbbe6e2cd1c2231aef59041d1056607 | LogicPenguins/BeginnerPython | /Udemy Course/HW Generators/exer2.py | 239 | 3.796875 | 4 | import random
low = int(input('Low: '))
high = int(input('High: '))
def rand_num(low_param, high_param, n):
for i in range(n):
yield random.randint(low_param, high_param)
for num in rand_num(low, high, 20):
print(num)
|
d79574835a4f1924c0d5fc4160cb3e31788aba42 | madhuri-bh/DSC-assignmentsML-AI | /Python1.py | 572 | 4.25 | 4 | movieEntered = input("Enter a movie")
thriller=["Dark","Mindhunter","Parasite","Inception","Insidious","Interstellar","Prison Break","MoneyHeist","War","Jack Ryan"]
comedy=["Friends","3 Idiots","Brooklyn 99","How I Met Your Mother","Rick And Morty","The Big Bang Theory","TheOffice","Space Force"]
movieEntered = movi... |
c12abc4a3f4acbefc42905a040052b7f7db37690 | zkutasi/adventofcode-2015 | /day18/2.py | 1,171 | 3.53125 | 4 | #!/usr/bin/env python
import sys
w = None
h = None
lights = []
with open(sys.argv[1]) as f:
for line in f.readlines():
lights += [ list(line.strip()) ]
w = len(lights[0])
h = len(lights)
def stuck(lights):
for x in [0, len(lights)-1]:
for y in [0, len(lights[0])-1]:
lights[x][y] = '#'
stuck(ligh... |
208a412a9f6b9afc416e20338a65581392afbc03 | mirakib/Regular-coding | /Reverse Pyramid/Dynamic-solution.py | 333 | 3.734375 | 4 | # this code excutes the same but take user input to proceed
num = int(input())
list_ = [x for x in range(1, num + 1)]
for value in list_:
for space in range(value - 1):
print(" ", end=" ")
if value != num:
print(" {}".format(str(value)) * (2 * (num - value)))
elif value == num:
... |
8ac911a518cc7b332d7c0b30b8331495b211bbaf | Ice-Like/python_midterm | /test020.py | 231 | 3.546875 | 4 | # -*- coding: utf-8 -*-
a = int(input("組數為:"))
aa = []
for i in range(a):
c = input("第 %d 組:"%(i+1))
aa.append(int(c[0])*250+int(c[2])*175)
for i in range(a):
print("第 %d 組應收費用:%d"%((i+1),aa[i]))
|
6f12d8b3912f5571114eb1300f0d2ae194c93b2e | Ice-Like/python_midterm | /test005.py | 163 | 3.859375 | 4 | m = int(input("請輸入階乘值 M : "))
n = 1
i = 1
while i <= m:
n += 1
i *= n
print("超過 M 為 " + str(m) + " 的最小階層 N 值為:" + str(n)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.