blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
2033a54418a3cd3e99a6f6c327d60aaf263fbbc1 | 62100006/Project-PSIT | /data.py | 729 | 3.640625 | 4 |
""" Project : Covid-19
Team : ไอแห้งเป็นโคโรนา เลิฟยูเป็นบร้าคือเรานะ
Data : Age
Year : 2020
"""
def age():
import csv
# Open File csv
file = open('covid_data.csv')
data = csv.reader(file)
table = [row for row in data]
month = ['03', '04', '05', '06', '07', '0... |
38278ae8a0fb4c08810f7ac0a4b132fceadadd1d | HeywoodKing/mytest | /MyPractice/filter (3).py | 2,847 | 4.03125 | 4 | # -*- coding utf-8 -*-
# 素数为在大于1的自然数中,除了1和它本身以外不再有其他因数。
# 质数又称素数。一个大于1的自然数,除了1和它自身外,不能被其他自然数整除的数叫做质数;否则称为合数。
# 质数(prime number)又称素数,有无限个
# 求质数(素数)的方法
#
# def get_odd(n, L):
# R = []
# E = []
# for x in L:
# if(x % n == 0):
# R.append(x) # 非素数
# else:
# E... |
c60d35683fcd456d5fc2b8137cb00391d7e81d35 | BayoOlawumi/computer-applications-MTECH | /assignment3 - olawumi abayomi(EEE_12_9579)/chapter8_problem4.py | 467 | 4.09375 | 4 | def counter(my_string, my_letter, given_position):
count = 0
for each_letter in my_string[given_position:]:
if each_letter == my_letter:
count+=1
return count
str_given = input("Enter a string: ")
letter_given = input("Enter the letter you want to count: ")
position_given = int(input("E... |
24852d3b51ed81f742ccccaf4824dbe758b5bd3a | enbattle/Learning-Data | /Handwritten Digit Classification/compare1And5.py | 4,015 | 3.640625 | 4 | import matplotlib.pyplot as plt
'''
Takes a list of lists, representing a (n x m) grayscale image, and flips it over the vertical axis
n := rows
m := columns
'''
def flipImage(image):
start = 0
start = 0
end = len(image) - 1
# Run loop to switch image[start] and image[end] rows unt... |
774b6caac2a80feb9af8c96ce821d08c283e066b | danielcanuto/revisao_python | /maior_lista.py | 253 | 3.765625 | 4 | def maior_elemento(lista):
maior = lista[0]
for x in lista:
if x > maior:
maior = x
print(x)
return maior
b = [ -15, -5, 0, -2]
x = [5, 9, 2, 8, 8, 15, 1, 5]
print(maior_elemento(x))
print(maior_elemento(b))
|
0909457824fe344a7259ac3d3836d9249326db42 | jadenpadua/ICPC | /Python/tryhard/queuesUsingTwoStacks.py | 2,033 | 4.375 | 4 | class MyQueue:
def __init__(self):
"""
Initialize your data structure here.
"""
# intialize the two stacks and size of queue
self.pushStack = []
self.popStack = []
self.size = 0
# push element to push stack and increase size of queue
def push... |
ee88e7ac173be44136106193bc836eccd173c847 | HymEric/LeetCode | /python/27.py | 592 | 3.65625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/10/1 0001 15:03
# @Author : Erichym
# @Email : 951523291@qq.com
# @File : 27.py
# @Software: PyCharm
"""
note: change the element value in original list
"""
class Solution:
def removeElement(self, nums: list, val: int) -> int:
k=0
cnt=nums.count(val)
... |
76885ea67e8f4928cfe88c608ded7cd4d19c439b | AlspachS/MTH451-Numerical-Methods | /venv/Source/Homework7/Homework7_2.py | 1,870 | 3.65625 | 4 | # Problem 6.4:
#
# For the data set:
#
# S = {(1, −8), (4, −1), (8, 2), (15, 3)}
# a. Find the least squares regression line.
# b. Find the least squares regression parabola.
from numpy import zeros, linspace
from numpy.linalg import solve
from matplotlib.pyplot import plot, show
def leastSquaresLinear(x, y):
... |
ad74125a26ff64fa51228f8aaa72cb7c241f3e43 | tung491/algorithms | /data_structure/heap.py | 1,207 | 3.546875 | 4 | import heapq
import math
from typing import Any
class MinHeap:
def __init__(self):
self.heap = []
def list_heapify(self, input_list: list) -> None:
heapq.heapify(input_list)
self.heap = input_list
@staticmethod
def get_parent_location(i: int) -> int:
location_i = (i -... |
171556edbb5ede01078179a9e6395e054b441ba0 | Nigirimeshi/leetcode | /0166_fraction-to-recurring-decimal.py | 3,139 | 4.25 | 4 | """
分数到小数
链接:https://leetcode-cn.com/problems/fraction-to-recurring-decimal
给定两个整数,分别表示分数的分子 numerator 和分母 denominator,以字符串形式返回小数。
如果小数部分为循环小数,则将循环的部分括在括号内。
示例 1:
输入: numerator = 1, denominator = 2
输出: "0.5"
示例 2:
输入: numerator = 2, denominator = 1
输出: "2"
示例 3:
输入: numerator = 2, denominator = 3
输出: "0.(6)"
官方解... |
c871f9a1b54c5a09cfff385553a866f01d42b31d | biowink/clue_hackathon_code | /predict.py | 8,506 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Script used to predict with an already trained LSTM model
"""
from os.path import join as pj
import numpy as np
import pandas as pd
from model import get_model, get_weight_path
from preprocessing import symptoms_of_interest_dict, data_dir, prepare_data_for_predictio... |
89b058ac12af4035a6f838127d443f17cfe5c450 | asdwergo/python-tut | /funnyname2.py | 653 | 3.65625 | 4 | import sys
import random
def main():
print("random name\n")
first=( 'ka', 'kar', 'karr', 'kay', 'kayy', 'ki', 'ke', 'kee', 'ko', 'koe')
middle=('aa' ,'ar', 'arr', 'aye', 'ei', 'ae', 'aee', 'ao', 'aoe')
last=('la', 'lar', 'larr', 'lay', 'layy','li', 'le', 'lee', 'lo', 'loe')
while True:
firstN=random.choice(fir... |
e90bac08922fcd9eb4b5f4dcd761ffb0edbfbd0d | yoda-yoda/my-project-euler-solutions | /solutions/37.py | 1,391 | 3.890625 | 4 | #!/usr/bin/python
"""
Author: Denis Karanja,
Institution: The University of Nairobi, Kenya,
Department: School of Computing and Informatics, Chiromo campus
Email: dee.caranja@gmail.com,
Task: 27(Truncatable primes eg 3797->379->37->3 and 3797->797->97->7)
License type: MIT :)
Status: PENDING...
"""
def is_prime(num):
... |
0edf837046461597c545c55c47aa74198d860794 | shouliang/Development | /Python/LeetCode/7days/69_my_sqrt.py | 597 | 4.21875 | 4 | '''
求平方根
69. Sqrt(x):https://leetcode.com/problems/sqrtx/
思路:利用二分查找的思路,逐渐缩小范围
'''
import math
class Soultion:
def mySqrt(self, x):
if x == 0 or x == 1 : return x
low,high = 1 ,x
res = 0
while low <=high:
mid = low + ((high - low)>>1)
if mid * mid == x :
... |
b5ae2209aae46ccedeb141e78aa8d6b78ae61638 | Aasthaengg/IBMdataset | /Python_codes/p02957/s768325868.py | 164 | 3.59375 | 4 | #template
def inputlist(): return [int(k) for k in input().split()]
#template
A,B = inputlist()
if (A+B) % 2 == 0:
print((A+B)//2)
else:
print("IMPOSSIBLE") |
a77cfdb4d0aa52f41e491ba9127866f011c46bae | Lurgic-error/boring-stuff-python | /loops/for.py | 399 | 3.765625 | 4 | numbers = list(range(1, 10))
for number in numbers:
pass
# print(f'{number}')
# Iterating by Sequence Index
fruits = ['apples', 'banana', 'mangoes', 'pineapples']
for index in range(len(fruits)):
print(f'{index} - {fruits[index]}')
for i in range(9):
if(i == 2):
print('about to conti....... |
7be1d73c7e167ed75b49721c2740dc96fe30ae95 | Akanksha-Verma31/Python-Programs | /String Function:endswith.py | 154 | 3.984375 | 4 | my_str = "Python Programming"
print(my_str.endswith("Programming"))
# checks whether the word/string is is ending with the provided word in quotes or not
|
392089002606e5c0059010352540941b42c66daf | spk2dc/GeneralAssembly_Archive | /4_APIs_and_full_stack/w10d03/student_labs/lists_ranges.py | 459 | 4.3125 | 4 | # exercise 1
students = ['name1','name2','name3','name4']
print(students[0])
print(students[-1])
# exercise 2
foods = ('food1','food2','food3','food4')
for i in foods:
print(f'{i} is good')
# exercise 3
for i in foods[-2:]:
print(f'{i} is good')
# exercise 4
home_town = {
'city': 'city1',
'state': 's... |
fdbde0087e52601ba24dd70927d56b2b7de01105 | M1c17/ICS_and_Programming_Using_Python | /Week5_Object_Oriented_Programming/Lecture_5/classRabbitTag.py | 2,411 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 29 12:48:47 2019
@author: MASTER
"""
class Animal(object):
'''Everything is an object: implements basic operations
in Py'''
def __init__(self, age):
self.age = age
#define data attributes internally not pass in
... |
97679a812b793547e0cab8582c438d9f5f1301cf | cGantan/practiceLab | /rotateArray.py | 583 | 3.625 | 4 | #Source: LeetCode
#Given an array, rotate the array to the right by k steps, where k is non-negative.
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
def rev(arr, l , r):
for i in range((r... |
4c14a1959f38739537d6e3de9c9f4449ce2bf581 | Nikola-Putnik/Projet2_Groupe_B_2-Partie-2-Web | /0-divers/idée.py | 1,067 | 4.21875 | 4 | """
Ce code affiche les moyennes de chaque cours et la moyenne générale
"""
import sqlite3
# Accès à la base de données
conn = sqlite3.connect('inginious.sqlite')
# Le curseur permettra l'envoi des commandes SQL
cursor = conn.cursor()
données = {}
l1=[]
moyenne = 0
for row in cursor.execute("SELECT course, avg(grad... |
bd5efff8b10999265eb58d585a30b665a2da6214 | phyrenight/inventory | /index.py | 3,422 | 4.125 | 4 | import product
from inventory import Inventory
def addWarehouse(warehouses):
"""
args: warehouses a list that stores all the warehouses
function: gets data for the warehouse from the user.
returns: none
"""
storage = {}
print "Enter a name for the warehouse:"
storage['nam... |
4de7c4bcae39b9eaaab2c476a86c9c21d242f280 | stephanosterburg/coding_challenges | /hackerrank/countSwaps.py | 398 | 3.59375 | 4 | def countSwaps(a):
count = 0
for i in range(len(a)):
for j in range(len(a)-1):
if a[j] > a[j+1]:
a[j], a[j+1] = a[j+1], a[j]
count += 1
print("Array is sorted in {} swaps.".format(count))
print("First Element: {}".format(a[0]))
print("Last Element... |
1a08da14d7e527f8a8521380c67a69e93276de30 | cshoaib05/Python_programs | /HackerFights/cutboard.py | 871 | 3.5 | 4 | import numpy as np
def fillboard(n,m,x,y):
if(((n*m)-(x+y))%2==0):
print("YES")
print(((n*m)-(x+y))//2)
get_Indexes(n,m,x,y)
else:
print("NO")
def valid_index(i,j,n,m,x,y):
count=0
for a in range(0,n):
for b in range(1,m):
if(a!=i and b!=j):
count=count+1
continue
break
#print(count)
if... |
4b432e68268d5400fb7f2e03c4cb276c8c5b8d6d | artinbz/scrah | /Term 2/dr-_god10.py | 113 | 3.953125 | 4 | side = input ('what is your first side:')
side = int (side)
area = side * side
print ('area of square is:',area)
|
91473b74a25b4b10234b87b2bee67f54f501cca7 | dbetm/cp-history | /Concursos/CodeJam/2023_last_time/roundA/C_rainbow_sort.py | 977 | 3.515625 | 4 | # solved
# Tag(s): implementation, maps
def print_color_set(color_id_map: dict, case: int):
id_color_map = {value: str(key) for key, value in color_id_map.items()}
sorted_map = dict(sorted(id_color_map.items()))
print(f"Case #{case}:", " ".join(sorted_map.values()))
if __name__ == "__main__":
t = ... |
dd1de08ba0ca8e8018847ce987ec577ecab55ce6 | pavandata/learningPythonTheCompetitiveWay | /codewars/6kyu/YourOrderPlease.py | 735 | 3.984375 | 4 | """
Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result.
Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0).
If the input string is empty, return an empty string. The words in the input String will... |
0e19b8177020faec76d5ef0aac7acceea78dbfa5 | weidongcao/finance_spider | /src/main/com/dong/spider/spider_66buke.py | 2,522 | 3.921875 | 4 | """
使用Python爬虫爬取自己指定66buke网小说
"""
import json
import requests
from bs4 import BeautifulSoup as bs
import re
headers = {
"User-Agent": (
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36"
),
"Referer": "https://www.66buke.... |
1f7f8ecf01f3189e9e756d072f68907f216052c9 | bbusenius/Projects | /Algorithmic_Thinking/Degree_Distributions.py | 2,690 | 3.859375 | 4 | """
Simulation for comparing the degree distribution of a scientific paper citation
graph with that of a randomly created directed graph based on the DPA algorithm
that sets edges between nodes preferentially.
"""
# Graph library
import graph as g
# Plotting library
import matplotlib.pyplot as plt
CITATION_URL = "h... |
7ca9d08c3f002b3c96dbf568dc9dc9c40f5deb76 | warpalatino/public | /Machine learning/ML/traditional_ML/regressions/DS1_stat_multi_linear_reg_dummies.py | 2,309 | 3.890625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
# -------------------------
# load data, it contains SAT, GPAs but also attendance as dummy variable
# ------------
raw_data = pd.read_csv('../data/1.03. Dummies.csv')
# print(raw_data.head())
# print(raw_data.descri... |
0b6b434226cba52a9c19f597358d78bf2ef6b5d6 | danielsummer044/EDUCATION | /remove A str.py | 159 | 3.8125 | 4 | string = "qwerty bjo adgjl fome anyr rekan aodo"
words = string.split(" ")
result = [i for i in string.split() if not i.startswith('a')]
print(result) |
e08256ef89b3f1d6c069926a677a1879b350ae82 | Mclovinn/minesweeper | /model/board.py | 1,094 | 3.53125 | 4 | class Board:
bombs = [(1,1)]
def __init__(self, size):
self.size = size
self._board = dict()
self._rows = list()
self._init_board()
def _init_board(self):
for x in range(self.size[0]):
row = list()
for y in range(self.size[1]):
... |
cb12715c1f5d4ee6eea3f4d2691980d31fcdbce3 | random-user-00/hasher | /hasher/__init__.py | 832 | 3.5 | 4 | """
File hash generator written in Python. Supports generating hash for multiple algorithms at same time.
Usage example
>>> import hasher.filehasher
>>> hash = hasher.filehasher.generate("/tmp/file1", "md5")
>>> hash
{'/tmp/file1': {'md5': '0d5ea07883d0ccff5c9dedf79f9e6631'}}
>>>
>>> multiple_hashes = hasher.filehashe... |
b42d70786a06c49727c4f0e28e9de2fcb778d5ff | SushmitaY/mca101_2017 | /5.Percentage.py | 1,159 | 4.15625 | 4 | def calcPercentage(totalMarks,maxMarks):
'''
objective: To calculate the percentage of the marks obtained by a student
approach: -> Dividing total marks by maximum
-> Multiplying this result with 100 to produce the final result
parameters: -> totalMarks : Total marks obtained ... |
2db4e6b280b4d81793fbcc8980e8d91a293eec54 | ruirodriguessjr/Python | /Listas/ex13Lendo10NumerosMostrandoInversamente.py | 238 | 4.1875 | 4 | #Faça um Programa que leia um vetor de 10 números reais e mostre-os na ordem inversa.
lista = list()
for c in range(1, 11):
valor = float(input(f'Informe o {c}º número: '))
lista.append(valor)
lista.sort(reverse=True)
print(lista) |
64bb507ce75c7a4d4ef4f5c23360df331d0b16fb | SakshiSSingh/Basic | /HackerRank/Tree traversal.py | 651 | 3.78125 | 4 | class Tree:
def __init__(self, key):
self.root = key
self.left = None
self.right = None
def preOrder(tree):
if tree:
print(tree.root)
preOrder(tree.left)
preOrder(tree.right)
def postOrder(tree):
if tree:
postOrder(tree.left)
postOrder(tree.... |
ff904849f5dd7ada7067b19200b2c817181f14d1 | git874997967/LeetCode_Python | /easy/leetCode717.py | 778 | 3.75 | 4 | #717. 1-bit and 2-bit Characters
# We have two special characters:
# The first character can be represented by one bit 0.
# The second character can be represented by two bits (10 or 11).
# Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.
def isOneBitCharacter(b... |
343f4854fa66fb1ab3221b45c31e2f1cdca155d1 | Redwanuzzaman/Python-Practicing | /Inheritance.py | 580 | 3.859375 | 4 | class Person:
def __init__(self, fname, lname):
self.firstname = fname
self.lastname = lname
def printname(self):
print(self.firstname, self.lastname)
class Employee(Person):
def __init__(self, fname, lname, company_name):
super().__init__(fname, lname)
self.company = company_name... |
7a168594a6ced5e4529204bedd6d04eb437b3754 | nmoskova/Python-advanced | /03-Multidimensional-lists/even_matrix.py | 190 | 3.5625 | 4 | rows = int(input())
matrix_even = []
for row_index in range(rows):
row = [int(x) for x in input().split(", ")]
matrix_even.append([n for n in row if n % 2 == 0])
print(matrix_even) |
05c6cabf6dd7ebd5d251cb5f9c18062da881bfde | xusongtaola/Python | /charpter3/l.py | 181 | 3.6875 | 4 | #coding: utf8
#计算1+2+3+...+n的累积和
n = int(input("请输入n的值:"))
total = 0
for i in range(1, 1+n):
print(str(i-1) + "---" + str(total))
total += i
print(total)
|
dbbd7b3829b36ab0134a5ad42df283e4f909b44f | fanyuan1/Project-E | /problem_46.py | 309 | 3.578125 | 4 | from projecteuler import isPrime
from math import sqrt
i = 1
def checker(n):
for i in range(1,int(sqrt(n/2))+1):
if isPrime(n-2*i*i):
return True
return False
def run():
i = 1
while 1:
n = 2*i+1
if isPrime(n) or checker (n):
i += 1
continue
return n
print(run()) |
c107fbd32c77118ab0cd35d94f38a1aaa205aa1c | zendox/python-lesson | /factorial.py | 103 | 3.71875 | 4 | def factorial(n):
if n < 1 :
return 1
else :
number = (n * factorial(n-1))
return number |
c57c8148c347059bf79e4a140805b47d66cdd183 | bledidalipaj/hackerrank | /ginortS.py | 1,055 | 4.03125 | 4 | """
You are given a string S.
S contains alphanumeric characters only.
Your task is to sort the string S in the following manner:
All sorted lowercase letters are ahead of uppercase letters.
All sorted uppercase letters are ahead of digits.
All sorted odd digits are ahead of sorted even digits.
Input Format
... |
e79eeb80f9fa0ca6c25a5e1e6a0196ad5ee0ebf3 | geekyarthurs/ann_cnn_rnn | /2variable_gradient_descent.py | 1,177 | 3.796875 | 4 |
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#READING THE GIVEN DATA FILE
dataFrame = pd.read_csv("ex1data2.txt", header=None)
#ASSIGNING X AND y values to train our model.
X = dataFrame[[0,1]].values
y = dataFrame[2].values.reshape((-1,1))
X = (X - np.mean(X,axis=0)) / np.std(X,axis=0)... |
847ecb3f26f288c15a80e9dc9999ea20ca3ad142 | wiecekmalgorzata/DataRangers-Python | /ZadaniePython2.py | 624 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 21 13:48:55 2018
@author: Gosia
"""
##### ZADANIE 1
import moj_folder.moje_funkcje as fn
fn.napisik("Pozdro Jaco")
##### ZADANIE 2
def double(x):
if isinstance(x, (int, float))==True:
double_x=x*2
else:
double_x=[i*2 fo... |
8adbe55935af3813a7122767a245fff5f9ff3f39 | ntkaggarwal/Array-3 | /Rotate_array.py | 708 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 7 00:58:00 2020
"""
#Problem 3 Rotate array
# TC - O(n)
# SC - O(1)
# Yes, this solution worked. First reverse the whole array then reverse till k nad then reverse the rest n-k
class Solution:
def reverse(self,nums,start,end) -> None:
while start ... |
4ee1259129e7435e90e8923e27ade040242636f5 | zhengxiaocai/baseex | /01lxf/pyex005.py | 178 | 3.625 | 4 | # 循环
# 语法结构
# while expression:
# expr_true_suite
# 简单while示例:循环打印1~10
i = 1
while i < 11:
print(str(i)+' ',end='')
i += 1
|
84bf5e1b33bd843560bf26aa716bce5903589a3c | codehearts/pickles-fetch-quest | /engine/game_object/tests/test_physical_game_object.py | 1,637 | 3.546875 | 4 | from ..physical_game_object import PhysicalGameObject
from unittest.mock import Mock
import unittest
class TestPhysicalGameObject(unittest.TestCase):
"""Test functionality of physical game objects."""
def test_create_physical_game_object(self):
"""Physical game objects are initialized with the given ... |
8de006d23477100712b76c963523931f2133962d | ramyaramprakash/AUTOMATED-UNI-VARIATE-ANALYSIS-USING-PYTHON- | /Graphfunction.py | 12,997 | 3.953125 | 4 |
# coding: utf-8
# In[1]:
# Loading neccesary packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os
# In[65]:
def Graphs0(dataframe):
"""
Creates histogram and boxplot for all numeric columns in dataframeframe
Used for creating histogram and boxplot of all the... |
8e40f8c3da0de040bad9f39a1bf7834e9b191456 | Flipswxtch/Python-Crash-Course | /Chapter 6/try_it_6_7.py | 859 | 3.78125 | 4 | people = {
'kevin' : {
'first_name' : 'kevin',
'last_name' : 'kennedy',
'age' : '31',
'city' : 'columbus',
},
'ben' : {
'first_name' : 'ben',
'last_name' : 'aune',
'age' : '30',
'city' : 'columbus'
},
'ryen' : {
'first_nam... |
ecee22d25bce3505176564533495cd295fc96ac0 | mitchell-johnstone/PythonWork | /PE/P061.py | 4,238 | 4.125 | 4 | # Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and
# are generated by the following formulae:
#
# Triangle P3,n=n(n+1)/2 1, 3, 6, 10, 15, ...
# Square P4,n=n2 1, 4, 9, 16, 25, ...
# Pentagonal P5,n=n(3n−1)/2 1, 5, 12, 22, 35, ...
# Hexagonal... |
e544bc0d70cf7b657f38dd71608c19f6018af505 | udiallo/GermanPoliticiansTwitter | /handle_tweets.py | 5,189 | 3.5 | 4 | import os
import tweepy as tw
import pandas as pd
consumer_key= '???'
consumer_secret= '???'
access_token= '???'
access_token_secret= '???'
def get_all_tweets(screen_name):
# Twitter only allows access to a users most recent 3240 tweets with this method (??? not for me)
# authorize twitter, initialize tweepy... |
d1eda393d31aac02608c6b81b13ba8c1e008bd60 | Strycnine/Scraping_Weather | /temperature.py | 780 | 3.578125 | 4 | import urllib.request
from bs4 import BeautifulSoup
header = "'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'"
def temp(city):
url = 'https://google.com/search?q=weather+in+' + city
request = urllib.request.Request(url)
req... |
8b5b5bd276757cfc5a0d51095fc6031e12f822bf | flyalt/Exywt | /Exywt/面向对象/利用属性实现分页.py | 811 | 3.734375 | 4 | # -*- coding: utf-8 -*-
# @Time : 2018/4/2 上午10:59
# @Author : ZS
# @Email : @163.com
# @File : 利用属性实现分页.py
# @Software: PyCharm
class Page:
def __init__(self, current_page):
try:
p = int(current_page)
except Exception as e:
p = 1
self.page = p
de... |
b2c19419a55bd8ca634348867d85504b99e8814a | albusdemens/Ripasso_coniche | /Circonferenza.py | 752 | 3.703125 | 4 | # This script plots, for a given centre and radius, the corresponding circle
from pylab import *
figure(figsize=(8,8))
ax=subplot(aspect='equal')
print(" Dato un punto ed un raggio, questo script disegna la circonferenza corrispondente \n")
cen_x = input(" Seleziona la X del centro \n")
cen_y = input(" Seleziona la Y... |
7b2aa7d3c36b88e860f3436e0a75a13bf2855778 | maodunzhe/clean_code | /array/4sum.py | 1,185 | 3.5 | 4 | '''
make use of threeSum
and also pay attention to the point below
time: O(n ^ 3)
space: O(1), space is the extra space used in the progress and the returned space
'''
class Solution(object):
def fourSum(self, nums, target):
res = []
nums.sort()
for i in range(len(nums) - 3):
if i and nums[i] == nums[i - 1]:
... |
0bbd740c5c8181493cd4309d735474c5527d2602 | lechiang/e-mission-server | /CFC_DataCollector/recommender/user_utility_model.py | 3,581 | 3.75 | 4 | # Phase 1: Build a model for User Utility Function (per Vij, Shankari)
# First, for each trip, we must obtain alternatives through some method
# (currently Google Maps API), alongside the actual trips which were taken.
# Once we have these alternatives, we can extract the features from each of the
# possible trips. Now... |
5940eb6734fc97f1303819fc772e994fdcb6bed2 | cyx2048/CompanyPython | /CompanyPython_DailyTest/day_test/test4.py | 436 | 3.953125 | 4 | """
编写一个程序,从控制台接收一系列逗号分隔的数字,并生成一个列表和一个包含每个数字的元组。
假设向程序提供了以下输入:
34、67、55、33、12、98
那么,输出应该是:
[‘34’,‘67’,‘55’,‘33’,‘12’,‘98’]
(‘34’、‘67’、‘55’、‘33’、‘12’、‘98’)
"""
s=input("input:")
l=s.split(",")
t=tuple(l)
print(l)
print(t) |
dd4d5793780703ae7c9225b5acebde0ec4bfdadf | gl051/interview-questions | /count_substrings.py | 377 | 4.21875 | 4 | """
Given a string and a substing
Then find all the occurences of the substring in the string
Input: dhimanman, man
Output: 2
"""
def count_substring(input_string, pattern):
if input_string is None or len(input_string) == 0 or pattern is None or len(pattern) == 0:
return None
tokens ... |
946c0a825152c272d664744a7410127a78b8964e | joyce-lam/prep | /backtracking/Q3.py | 553 | 3.703125 | 4 | # Permutations
# Given a collection of numbers, return all possible permutations.
class Solution:
# @param A : list of integers
# @return a list of list of integers
def permute(self, A):
res = []
l = 0
r = len(A) -1
def helper(a, l,r,res):
if l == r:
k = a[::]
... |
81692c4088de982ee06161fb8b5e0a98d830b8a1 | sienning/algojour1-ENG | /tri/insertion_sort.py | 1,635 | 3.734375 | 4 | # ENG Léna
# Insertion sort
import sys
import time
start_time = time.time()
listeDep = []
nbComp = 0
nbIteration = 0
def is_int(value):
try:
int(value)
return True
except:
return False
def convert(str):
liste = str.split(';')
for i in liste:
if is_int(i):
listeDep.append(i... |
3790bfb5f52d352291322e190ad997ad94789b3f | lishulongVI/leetcode | /python3/225.Implement Stack using Queues(用队列实现栈).py | 3,389 | 3.71875 | 4 | """
<p>Implement the following operations of a stack using queues.</p>
<ul>
<li>push(x) -- Push element x onto stack.</li>
<li>pop() -- Removes the element on top of the stack.</li>
<li>top() -- Get the top element.</li>
<li>empty() -- Return whether the stack is empty.</li>
</ul>
<p><b>Example:</b></p>
<pre>
My... |
f12ae7a2684a423fd970ea6fde321e1432b90fee | bhavitavayashrivastava/Python-Code | /1) basic.py | 426 | 4 | 4 | ''' This is basic Python program with escape sequences '''
# Problem statement Print
1) \\
2) /\/\/\/\/\/\/\ these mountain ranges
3) "this is awesome place " (Include spaces using escape sequence)
4) \" \n \t \' print this as output
print(r'To print as it is ')
print("this is \\\\ double backsla... |
12592ab51529f5aef9c44514bfbc177f74d6064a | Marcus893/algos-collection | /cracking_the_coding_interview/5.1.py | 513 | 3.671875 | 4 | Insertion: You are given two 32-bit numbers, Nand M, and two bit positions, i and
j. Write a method to insert Minto N such that M starts at bit j and ends at bit i. You
can assume that the bits j through i have enough space to fit all of M. That is, if
M = 10011, you can assume that there are at least 5 bits between j ... |
e16d7993c3478dfe683a17846296bb6508dd3a37 | bettercallkyaw/All-Python-Fields | /Object Oriented Programming/13_special_methods.py | 940 | 4.0625 | 4 | from copy import copy
class Human:
def __init__(self,first,last,age):
self.first=first
self.last=last
self.age=age
def __repr__(self):
return f'Human named {self.first} {self.last} aged {self.age}'
def __len__(self):
return self.age
def __add__(self,other):
... |
eb39ad2da64af7d25f7248a102845256f7974382 | plan-bug/LeetCode-Challenge | /microcephalus7/categories/twoPointers/283.py | 333 | 3.625 | 4 | # for 문
# nums 돌며 0 있을 시 삭제
# append 로 0 삽입
from typing import List
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
for i in nums:
if i == 0:
nums.remove(i)
nums.append(0)
solution = Solution()
print(solution.moveZeroes([0, 1, 2, 3]))
|
44d356f31d7e155d805698531d1755abe25ed44f | diegolinkk/exercicios-python-brasil | /exercicios-com-listas/exercicio08.py | 449 | 4.15625 | 4 | # Faça um Programa que peça a idade e a altura de 5 pessoas, armazene cada informação no seu respectivo vetor.
# Imprima a idade e a altura na ordem inversa a ordem lida.
idades = []
alturas = []
for _ in range(5):
idades.append(int(input("Digite a idade: ")))
alturas.append(float(input("Digite a altura: "))... |
79f60f1d2edd388fbb2dd3772aa27989bdf0eaed | jtm172022/assignment-6 | /ps2.py | 2,040 | 4.03125 | 4 | ###### this is the second .py file ###########
####### write your code here ##########
def tic_tac_toe():
board = [1, 2, 3, 4, 5, 6, 7, 8, 9]
end = False
win_commbinations = (sum=15)
# our output look
def draw() :
print( '\n -----')
print( '|' + board[0] + '|' + board[1] + '|' + board[2] + '|')
print( ' -----')
pri... |
e0d14325016e125a934ef8bba645817d07e743ce | Israelgd85/Pycharm | /excript/app-comerciais-kivy/Python(Udemy-Claudio Rogerio/Exe_lista_4/exe-17.py | 501 | 3.84375 | 4 | #17) Escreva uma função que receba como argumento uma lista que poderá ter
# valores duplicados e retorne uma nova lista sem que haja valores iguais.
#Lista: [1,2,3,3,3,3,4,5]
#Retorno: [1, 2, 3, 4, 5]
lista = [9,1,2,3,2,4,4,5,6,7,8,8]
def func_numeros_iguais(n):
i = 0
while i < len(lista):
p = lista[... |
45db056f82be3487527c9ce2d1aedef30d208277 | edursantos/pythontest | /ex005.py | 325 | 3.953125 | 4 | print('Tabuada')
n1=int(input('Digite um número qualquer'))
n2= n1*1
n3=n1*2
n4=n1*3
n5=n1*4
n6=n1*5
n7=n1*6
n8=n1*7
n9=n1*8
n10=n1*9
print('{0} x 1 = {1} \n{0} x 2 = {2} \n{0} x 3 = {3} \n{0} x 4 = {4} \n{0} x 5 = {5} \n{0} x 6 = {6} \n{0} x 7 = {7} \n{0} x 8 = {8} \n{0} x 9 = {9}'.format(n1,n2,n3,n4,n5,n6,n7,n8,n9,n1... |
000172c452a04c77bf414ac57456e3e890c4885c | yaim97/python_test | /第4周月结代码/python_mysql.py | 1,074 | 3.546875 | 4 | # 导入包
import pymysql
# 链接数据库
db = pymysql.connect(
host="localhost",
user="root",
password="xxxxxx",
database="test",
)
# 定义游标
cursor=db.cursor()
# 创建表
sql_create_table="CREATE TABLE User(id int, name varchar(255))"
cursor.execute(sql_create_table)
# 插入数据--1
sql_insert="INSERT INTO User VALUES(0,'y... |
1e64d80d889c69875a0089910803464856caa1c0 | imjkdutta/Important_Training | /Training/Python/redirection.py | 627 | 3.8125 | 4 | #!/usr/bin/python
"""
Script:redirection.py
Author:Jiban Dutta
Date:20-Apr-2017
Purpose:understanding Redirection from python perspective .
"""
import sys
#Remembering the refernce is sys.stdout
stdout_ref = sys.stdout
#opneing a file for redirectining the output.
f = open('output_red.txt','w')
#mapping t... |
c4689473348c4c8877669d8b7beaace3457d54f0 | Rebornown/-scan | /toposcan_modules/py3PortScanner/build/lib/pyportscanner/etc/service_port.py | 1,115 | 3.5625 | 4 | from functools import total_ordering
@total_ordering
class ServicePort(object):
"""
A class wrapper for storing the information
parsed out from nmap-services.txt file,
including the service name, port number, protocol and open frequency.
Sorting of the ServicePort object is done in the ... |
108a2cf967347b0f2a5421dbde2a18b6c94a4cbe | lyjdwh/sicp-python | /hog/hog_grader.py | 5,020 | 3.578125 | 4 | """Automatic grading script for the Hog project.
Expects the following files in the current directory:
hog.py
dice.py
ucb.py
autograder.py
This file uses features of Python not yet covered in the course.
"""
__version__ = '2.3'
from autograder import test, run_tests, check_func, check_doctest, test_eval, run_tests... |
55c85b9881b068c8c4b834788418f1ca0b3022ac | skylizer/easytry | /lect03/fractal_tree_v1.0.py | 1,407 | 4.09375 | 4 | """
作者: 杨光璞
功能: 分形树绘制
版本: 1.0
日期: 08/11/2018
功能:利用递归函数完成分形树绘制
"""
import turtle
def draw_branch(branch_length):
if branch_length <= 20:
turtle.pensize(1)
turtle.pencolor('green')
else:
turtle.pensize(2)
turtle.pencolor('brown')
if br... |
8bd701121bc2433223abd331cca79734f0ca427e | Shubhanshu-Nishad/akpython-cek-19 | /lar3.py | 161 | 3.90625 | 4 | a=int(input("enter fist"))
b=int(input("enter sec"))
c=int(input("enter third"))
if(a>b)and(a>c):
print(a)
elif(b>a)and(b>c):
print(b)
else:
print(c) |
90a5f280d20425bf7a25d2db5c41f398bce79a3e | sourav-coder/GeeksForGeeks-Solutions | /Reverse words in a given string .py | 253 | 3.75 | 4 | # python programs by sourav
# code
for _ in range(int(input())):
s = input().split('.')
st=''
for i in range(len(s)-1,-1,-1):
# print(s[i],end='.')
if i==0:
st+=s[i]
else:st+=s[i]+'.'
print(st)
|
7b300c7a56b8d5ba88dab9bad0be234994214a3f | deepsmaganti/Pythonlocate | /Python/InterviewPrep/merge_interval.py | 1,061 | 3.59375 | 4 |
class Interval:
def __init__(self, s=0, e=0):
self.start = s
self.end = e
def __repr__(self):
return "[{}, {}]".format(self.start, self.end)
class Solution(object):
def merge(self, intervals):
if not intervals:
return intervals
intervals.sort(key=lambd... |
93cc19312378a63bae316df2c5b228019e829e70 | tyrakriv/2019Winter-CPE101Projects | /image-conversions/fade.py | 3,658 | 3.9375 | 4 | # PROJECT 5
#
# Name: Tyra Krivonak
# Instructor: S. Einakian
import sys, math
# This function will return an output file called faded.ppm that fades a given image
def fade():
# Try opening file. If no file exists, print error message
# If provided last three arguments are not integers, raise an e... |
f0e77878ddea34b24a84f275bb523b7ec7f7565d | BHAVJOT14/HackerRank-Solutions | /10 Days of Statistics/Day 4/Day 4 - Binomial Distribution I.py | 490 | 3.78125 | 4 |
def fact(N):
if N == 0:
return 1
else:
return N * fact(N - 1)
def combi(N, X):
result = fact(N) / (fact(N - X) * fact(X))
return result
def bino(X, N, P):
Q = 1 - P
result = combi(N, X) * (P ** X) * (Q ** (N - X))
return result
if __name__ == '__main__':
L, R = list(m... |
cf98781f763aaceca0e64875607a95eb2b8d80ff | HLNN/leetcode | /src/2327-largest-number-after-digit-swaps-by-parity/largest-number-after-digit-swaps-by-parity.py | 1,550 | 4.125 | 4 | # You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits).
#
# Return the largest possible value of num after any number of swaps.
#
#
# Example 1:
#
#
# Input: num = 1234
# Output: 3412
# Explanation: Swap the digit 3 with the digi... |
2e4b83ab37b05d4f3a2609c8ecef1696f16174e8 | RavuriRupasri/python-programs | /online-questions/q7.py | 561 | 4.125 | 4 | '''
You're given strings J representing the types of stones that are jewels, and S representing the stones you have.
Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.
The letters in J are guaranteed distinct, and all characters in J and S are letters. ... |
cf52adc33fb3db63b4f011c5e1d5be365d81c7d6 | ivanmartinezmorales/adventure-game | /utils/Stack.py | 469 | 3.9375 | 4 | """
Stack is a class written to use it when it comes to keeping track of all the movements that a player has made
"""
def Stack(object):
def __init__(self):
self.items = []
def push(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
... |
a4e535b9dd0c878a36b5d7a2b2b7db389edcc1a4 | TheNoobGlitch/Help-me-Vex-ppl | /try.py | 552 | 4.21875 | 4 | largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
value = float(num)
if smallest is None :
value = smallest
elif value < smallest :
smallest = value
if largest is None :
... |
4f95d192280bf5c8cd935042ab27e8e3fb616b5c | Andrewzh112/Data-Structures-and-Algorithms-Practice | /Breadth First Search III.py | 3,462 | 3.546875 | 4 | from collections import Counter
from heapq import heappush, heappop, heapify
# Alien Dictionary
class Solution:
"""
@param words: a list of words
@return: a string which is correct order
"""
def alienOrder(self, words):
indegrees, graph = self._construct_graph(words)
if graph is No... |
540914afeb1a2dacdfa425f079c76a6667d44f92 | a01745762/Mision_03-1 | /Trapecio.py | 898 | 3.71875 | 4 | #Autor: Brandon Julien Celaya Torres - A01745762
#Descripición: Calcula el área y perímetro de un trapecio con las bases y la altura.
def area (baseMayor, baseMenor, altura):
area = ((baseMayor+baseMenor)/2) * altura
return area
def perimetro (baseMayor, baseMenor, altura):
segmento = ... |
f763a6d1478a06867a78f56deb9cc74085f99526 | hessamg/My-Random-Python-Fun-Projects | /Travel planner/Travel_Planner.py | 1,353 | 4.21875 | 4 | # Sam Ganjian
# 3 April 2018
def plan_journey(trip_list):
"""Plans the Journey starting from your location.
Args:
trip_list: It is a list of places with [starting position, destination].
Returns:
the trip_list orginized.
"""
index = 1
start = trip_list[0][0]
destinat... |
e62f44a131e0b55b2376b3cf3e49ee7e315b1b6b | vidhik2002/login-registration | /core/wordgenerator.py | 250 | 3.921875 | 4 | import random
count = 0
miss = 0
WORDS = ('north', 'sound', 'west', 'east')
word = random.choice(WORDS)
typed_word = input()
while word:
if word == typed_word:
count += 1
elif word != typed_word or word == "":
miss += 1
|
9b628f11d2e3adc7241f7bf88f4360d28d4e8324 | olexander-movchan/labs-algo | /salesman.py | 958 | 3.546875 | 4 | #!/usr/bin/env python3
import math
import itertools
class Vector(object):
def __init__(self, x, y):
self.x = x
self.y = y
def __sub__(self, other):
return Vector(self.x - other.x, self.y - other.y)
def length(self):
return math.sqrt(self.x ** 2 + self.y ** 2)
def __... |
f04d290b9efd2232ea655bc01d1744f88b835153 | swifmaneum/ContainerPacking | /src/DeepReinforcementLearning/AgentEnvironmentClasses/aiRuleBase.py | 1,042 | 3.78125 | 4 | def part_fits_in_module(part, module):
return (module.length >= part.length and module.width >= part.width) or (
module.length >= part.width and module.width >= part.length)
def calculate_wasted_space(part, module):
return module.length * module.width - part.width * part.length
def is_best_fitti... |
e7c238addad38240e4dad5f39f178a27b18e9580 | cesnik-jure/Python_SmartNinja | /Python tecaj/After_01/Functions.py | 2,217 | 4.46875 | 4 | # Create a function that writes the Fibonacci series to an arbitrary boundary:
def fib(n): # write Fibonacci series up to n
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
# Now call the function we just defined:
fib(float(inp... |
9b6e8ecac4174401f786d22b2420172e2e65a70c | ovan1997/python_no1 | /lesson3/orice.py | 926 | 3.890625 | 4 | print("exercitiul1")
Celsius = int(input("Introduceti grade Celsius: "))
Fahrenheit = (Celsius * 9/5) - 32
print (Fahrenheit)
Fahrenheit = int(input("Introduceti grade Fahrenheit: "))
Celsius = (Fahrenheit - 32) * 5/9
print (Celsius)
print("exercitiul2")
a = input('introdu_cuvin :')
if a[0] == a[-1] and a[1... |
832bcfdaccafba7f4c0df42ddceca11645e5a584 | yanjun91/Python100DaysCodeBootcamp | /Day 2/day-2-start/main.py | 187 | 3.859375 | 4 | #Data Types
# String
print("Hello"[-1])
print("123" + "345")
# Integers
print(123 + 345)
123_456_789.11 # same as 123,456,789.11 in real world
# Float
3.14159
# Boolean
True
False |
784956454e66f24c70500da5008f15b203b2e42b | Nayanijain/Coffee-Machine | /coffee_machine.py | 2,948 | 4.09375 | 4 | # Write your code here
water = 400
milk = 540
beans = 120
cups = 9
cash = 550
action = ''
while action != 'exit':
action = input("Write action (buy, fill, take, remaining, exit):")
if action == 'buy':
buy = input("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:"... |
adfe90a4f289de216f6a495572051d8afc105875 | Gyurgitsa/python_lectures | /lekcija#11_lists_dictionary/dictionary.py | 154 | 3.765625 | 4 | box = {"height": 120, "width": 45, "length": 30}
print(box["height"])
print(box.get("weight" , 10))
for key, value in box.items():
print(key, value)
|
67ffb9fe3d582022d99da3fd734dee8597760d8d | gregschullo/python-crash-course | /python-basics/chapter03-introducing-lists/3-4-guest-list.py | 121 | 3.875 | 4 | guest_list = ["Cy Young", "Robin Yount", "Babe Ruth"]
for i in guest_list:
print (i + ", would you like to come to dinner?")
|
5ab601654665893beb79123013666d469469392c | aefernandes/FinalProject | /code/FlaskApp/app/builder.py | 1,815 | 3.8125 | 4 | from skiplistclass import SkipList
import csv
class Builder(object):
"""Implements an abstract skiplist builder class"""
def __init__(self, csvfile, keyindex, keyname):
self.csvfile = csvfile
self.keyindex = keyindex
self.keyname = keyname
self.skiplist = SkipList()
# parse the csv, and create a list of ... |
be638ab620a073656993e894117c1825869d938b | emcconville/HT16K33 | /examples/FourDigit/thinking.py | 961 | 3.53125 | 4 | #!/bin/env python
# FourDigit - Thinking
# Indicate to user that the computer is working
from __future__ import print_function
import time
from .HT16K33 import FourDigit
# Enable device
digit = FourDigit(bus=0,address=0x70).setUp()
# Tell operator process has started
print("Starting HT16K33.FourDigit thinking...(C... |
7fa14a23c7702dc4ae82b8d997af9afd491df739 | walney/Projetos | /Estrutura_de_dados/BubbleSort/bubbleSort.py | 813 | 4.0625 | 4 | def bubblesort(vetor):
for i in range(0, len(vetor)-1): # Laço de "passadas" / iterações, que percorrerá o vetor até que a lista esteja ordenada
for j in range(0, len(vetor)-1 - i) : # Exclui sempre o ultimo indice, que já é o maior da lista
if vetor[j] > vetor[j + 1]: #Verifica s... |
2e826510be59a1cea45d2c922ab6f8a1ec260ada | TBudden/Year9DesignCS4-PythonTB | /2PointsonLineCalculationPage.py | 1,521 | 3.59375 | 4 | import tkinter as tk
import math
def submit():
print("Calculating...")
x1 = float(entr.get())
x2 = float(enth.get())
y1 = float(ente.get())
y2 = float(entt.get())
mx = round((x1 + x2)/2,2)
midpointx.append(mx)
my = round((y1 + y2)/2,2)
midpointy.append(my)
m = round((y2 - y1)/(x2 - x1),2)
l = math.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.