blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
1c44d808df7fc717f16ed5a27bf8c6104b8fc4c2 | thejacobhardman/Rock-Paper-Scissors | /Game.py | 11,519 | 3.84375 | 4 | # Jacob Hardman
# Intro To Programming
# Professor Marcus Longwell
# 3/27/19
# Python Version 3.7.3
# Look up Coding Colorado
# Importing pkgs
import os
import random
# Clears the screen
def cls():
os.system('cls' if os.name=='nt' else 'clear')
########################################################## GLOBAL VA... |
d157aec623b861fcdaa73445b12817575e7bbf9f | cbarillas/Python-Biology | /lab02/coordinateMathSoln.py | 2,550 | 4.25 | 4 | #/usr/bin/env python3
# Name: Carlos Barillas (cbarilla)
# Group Members: none
from math import *
class Triad:
"""
This class calculates angles and distances among a triad of points.
Points can be supplied in any dimensional space as long as they are
consistent.
Points are supplied as tupels in n-d... |
2da68ad98a6a06111ce78866dcc3422e850b07b4 | Jeramir1/python_projects | /tktest.py | 1,508 | 3.59375 | 4 | from tkinter import *
import webbrowser
from pytube import YouTube
def download():
linkfordl = str(link_field.get())
print(linkfordl)
yt = YouTube(linkfordl)
#Showing details
button = Button(new, text='Downloading',fg='Black',bg='Blue',command=())
button.grid(row=6, column=1)
print("Ti... |
79e608419942dba075b9305cb81b538ef54e0ac7 | wintermute-cds/round | /integrationtests/create.py | 230 | 3.75 | 4 | from decimal import *
min = Decimal('-10.0')
max = Decimal('10.0')
step = Decimal('0.0001')
places = 3
current = min
while current <= max:
print('{0} {1}'.format(current, round(current, places)))
current = current + step |
2e65fcb903a06c8909575d22b5943fe03ee7f2ec | ecmarsh/algorithms-py | /rob_max_money_2.py | 2,197 | 3.71875 | 4 | """
213. House Robber II
You are a professional robber planning to rob houses along a street.
Each house has a certain amount of money stashed. All houses at this
place are arranged in a circle. That means the first house is the neighbor
of the last one. Meanwhile, adjacent houses have security system connected
and it... |
ff3cf51d67d83b70c42b5355873387bf97168400 | kareemgamalmahmoud/python-automate-logo-on-photo | /logo_adder.py | 1,228 | 4.21875 | 4 | import os
from PIL import Image
# first we will take the name of the logo
# that the user want to add .
# then , take the name of the folder the we
# will add the photos after adding the logo .
LOGO_NAME = 'face.png' #input('enter the logo name with extention : ')
FOLDER_NAME = 'with logo image' #input('enter the fo... |
fa76ed9400b59ec392eb79fb694bd242b77c6514 | fto0sh/100DaysOfCode | /Day6.py | 546 | 3.765625 | 4 | Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x = int(1) # x will be 1
>>> y = int(2.8) #y will b 2
>>> z = int("3") # z will be 3
>>> print(x ,y ,z)
1 2 3
>>> x = float(1) #x will be 1.0
>>> y = float(... |
1f75110ebdadb66ca2590518582f1a33b7fe8b77 | mongoz/itstep | /lesson4/analyze_number.py | 465 | 4.15625 | 4 | a: int = int(input("Enter the integer number\n\t"))
if a % 2 == 0 and a > 0:
smile_parity = "Even positive number"
print(a, "is the", smile_parity)
elif a % 2 != 0 and a > 0:
smile_parity = "Odd positive number"
print(a, "is the", smile_parity)
elif a % 2 == 0:
smile_parity = "Even negative ... |
9c1c8b2a714eabc2d3e8229c1709403d91045615 | nickyfoto/lc | /python/204.count-primes.py | 3,032 | 3.84375 | 4 | #
# @lc app=leetcode id=204 lang=python3
#
# [204] Count Primes
#
# https://leetcode.com/problems/count-primes/description/
#
# algorithms
# Easy (28.73%)
# Total Accepted: 235.3K
# Total Submissions: 813K
# Testcase Example: '10'
#
# Count the number of prime numbers less than a non-negative number, n.
#
# Exampl... |
bdd095d2646c562f68b0accfbbd651b596b89bd7 | IrisJohn/Floor-Regression-Model1 | /Floor-Regression Mode-M5A.py | 3,964 | 3.5 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import warnings
warnings.simplefilter('ignore')
#plt.style.use('dark_background')
# In[2]:
data = pd.read_csv('Transformed_Housing_Data2.csv')
data.head()
# # Task:
# 1. T... |
10b73f06c48cded9a9b7c5a8afdae237faa4a173 | Rodin2333/Algorithm | /剑指offer/42和为S的两个数字.py | 889 | 3.546875 | 4 | #!/usr/bin/env python
# encoding: utf-8
"""
输入一个递增排序的数组和一个数字S,在数组中查找两个数,
使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的。
"""
class Solution:
def FindNumbersWithSum(self, array, tsum):
"""
:param array: 有序数组
:param tsum: 和
:return:
"""
left = 0
right = len(array) - 1
... |
85369103c51dce6aeca3ef8a715a965f18fd781f | BulavkinV/GVD | /Point.py | 251 | 3.609375 | 4 | class Point():
def __init__(self, x, y):
self.x = x
self.y = y
def getPointsTuple(self):
return (self.x, self.y)
@staticmethod
def distance(cls, p1, p2):
return ((p1.x - p2.x)**2 + (p1.y-p2.y)**2)**.5 |
4f2f9ad63fd3eabe0b879ba7e8ce6159eff66344 | shcherbinushka/6115-preparation-for-the-credit-Python-3-semester | /12. Поиск максимума и подсчёт количества элементов, равных максимальному .py | 793 | 4.28125 | 4 | def max_search(): ### Программа ищет максимальный элемент в последовательности за один проход
x = -1 ### Текущий считываемый элемент
max_element = float('-inf') ### Текущий максимальный элемент
equal = 0 ### Колво элементов, не равных данному
whil... |
7a062102077d245d0bc58fc342c3510d0c54bd44 | Atramekes/Algorithms | /Recursion/Baguenaudier.py | 1,140 | 3.78125 | 4 | # !/usr/bin/python
# Algorithms
# @Author: Kortez
# @Email: 595976736@qq.com
import sys
import test_Recursion
outputs = []
def flip(seq, func):
""" Process a one/zero sequence seq according to func.
@param seq (list[int]): the unprocessed sequence
@param func (int): to do which function
... |
ae12ae8eb2eab5ce1fa11423f2e76e172a393d46 | brdayauon/interviewPreparation | /symmetricTreeRecursive.py | 689 | 3.8125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
return self.isMirror(root,root)
def isMirror(self, p: TreeNode, q: T... |
ea4c04c7520923f10fc7dddb903e3539aff45466 | lantzmw/LeetCode-Practice | /p5/solution.py | 2,751 | 3.953125 | 4 | class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
longest = ''
adjuster = 0
#go in reverse order through a string
for ss in range(len(s),0,-1):
substring = s[0:ss]
palindrome = self.findPalindrome(substring)
print("ss: %d longest %s palindrome %s" % (... |
10d13fc2d365ac5ed02d93ce14ed5f4cd3d3a08d | njpayne/pythagoras | /Archive/pickle_cellphone.py | 1,217 | 4.40625 | 4 | # The pickle module provides functions for serializing objects
# Serializing an object means converting it into a stream of bytes that can be saved to a file for later retrieval
# The pickle modules dump function serializes an object and writes it to a file
# The load function retrieves an object from a file and deseri... |
4a7031ab9fa6adfc7f301f41de0ddd578bea4758 | DrQuestion/PoCS2 | /Collections 7.py | 1,614 | 3.953125 | 4 | from collections import deque
if __name__=='__main__':
t=int(raw_input()) #number of testcases
for _ in xrange(t): #iterating over the test cases
n=raw_input()
l=map(int,(raw_input().split()))
d=deque(l) #created a deque containing all the values of the test case analyzed
for _ i... |
5ce604bf3cf39181579cefddf903379f17a4bc6a | girishgupta211/algorithms | /python/betright_python.py | 4,577 | 3.859375 | 4 | # Lembda function
MU = 8
a = lambda x, y: (x * MU) / y
print(a(2, 3))
# 5.333333333333333
# # Shallow copy
import copy
class A(object):
pass
a = A()
a.lst = [1, 2, 3]
a.str = 'cats and dogs'
b = copy.copy(a) # Here string will be pointing to new location as this is immutable
# b = a # here both will point to ... |
e469b8fbe24dbf153c592749933745343103182d | CatarinaBrendel/Lernen | /curso_em_video/Module 2/exer037.py | 682 | 3.71875 | 4 | print "\033[32m-=\033[m" * 25
print "\033[30m Calculadora Conversora\033[m"
print "\033[32m-=\033[m" * 25
numero = int(raw_input("Digite um numero inteiro: > "))
print '''Escolha agora sua opcao:
[1] converter para BINARIO
[2] converter para OCTAL
[3] converter para HEXADECIMAL'''
opcao = int(raw_input... |
6aac0625e4acfcc80609d03706b4d3f43e488dc6 | benjaminhuanghuang/ben-leetcode | /0063_Unique_Paths_II/solution.py | 4,231 | 4.03125 | 4 | '''
63. Unique Paths II
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 respectively in the grid.
For example,
There is one obstacle in the middle of a 3x3 grid as illustrated below.
[
[0,0... |
9509ef1f28b7e75915cbb75b97ad472d9af81bab | anobhama/Intern-Pie-Infocomm-Pvt-Lmt | /OOPS concept/single_inheritance.py | 1,033 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Aug 14 00:16:23 2020
@author: Anobhama
"""
#single inheritance
#single parent and child class
class rectangle:
def __init__(self,l,b):
self.length=l
self.breath=b
def arearect(self):
area = self.length * self.breath
print("The area of ... |
3ea038cdf2e0efaf412c0625a57752c0df15b3b0 | wentingsu/Su_Wenting_spring2017 | /Final/codePY/Analysis3.py | 3,949 | 3.515625 | 4 |
# coding: utf-8
# # Analysis 3 : analyse the variable
# * merge the 2015 and 2016 rank country table and create a new column to show the change of the rank for each contry and out put to a new csv.
# In[1]:
import pandas as pd
# from pythainlp.segment import segment
import seaborn as sns
import numpy as np
import... |
4637e9d335b2c1c971ca999d1e05ec9f14351602 | xz1082/assignment5 | /tw991/assignment5.py | 4,560 | 3.546875 | 4 | import string
class interval:
def __init__(self, string_raw):
string2 = string.replace(string_raw,' ','')
middle_place=string2.find(',')
if (string2[0] == '[') & (string2[len(string2)-1] == ']') & (int(string2[1:middle_place]) <= int(string2[middle_place+1:len(string2)-1])):
self... |
41813f38835bb12fb3f50727e66ee4e41cfeacde | YonelaSitokwe1811/intro_pyhthon | /Intro_python/printmonth.py | 739 | 4.21875 | 4 | name_of_month = (input("Enter the month('January',...,'December') :\n"))
first_weekday = input("Enter start day('Monday',...,'Sunday') :\n")
number_of_days=31
month={'January','February','March','April','May','June','July','August','September','October','November','December'}
weekdays = {'Monday': 0, 'Tuesday': 1... |
cde7809cb01e3484166fb6efd432c437d6c5f749 | jphiii/phabricator-tools | /py/phl/phlsys_timedqueue.py | 2,751 | 3.65625 | 4 | """Priority queue for objects with associated delays.
Usage example:
>>> tq = TimedQueue(); tq.push('a', datetime.timedelta()); tq.pop_expired()
['a']
"""
# =============================================================================
# CONTENTS
# --------------------------------------------------------------... |
2fecb50cd5b96a72af407dae5fa9be0db7393340 | ibrahim-sma/eulers_project | /problem_9.py | 1,410 | 4.1875 | 4 | # @author : Ibrahim Sma
# @github_location: https://github.com/ibrahim-sma
# @email: ibrahim.sma1990@gmail.com
# @LinkedIn: www.linkedin.com/in/ibrahim-sma
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Problem 9 - Special Pythagorean triplet
# A Pythagorean triplet is a set of t... |
36ca8beaa89545e13be0c755aaadbd7d069b3fd5 | gagewooldridge/python-fizzbuzz | /FizzBuzz.py | 777 | 4.1875 | 4 | # This program will take the numbers 1-50 and evaluate them for the following criteria:
# Number divisible by three and five: Output = FizzBuzz
# Number divisible by three but not five: Output = Fizz
# Number divisible by five but not three: Output = Buzz
# Number divisible by neither three or fiv... |
04008ec747f430bc5b911d077f2a10771166ef94 | sam1017/pythonstudy | /matrix_test.py | 1,747 | 3.5625 | 4 | import time
class matrix():
def __init__(self, matrix_view):
self.matrix_view = matrix_view
self.row = len(matrix_view)
self.column = len(matrix_view[0])
def show(self):
print("this matrix is " + str(self.row) + " * " + str(self.column))
for rows in self.matrix_view:
... |
f3598dc6f4ce9911382ad94038511b26c0578c2f | Anirban2404/LeetCodePractice | /409_longestPalindrome.py | 1,592 | 3.890625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 30 10:57:00 2019
@author: anirban-mac
"""
"""
409. Longest Palindrome
Given a string which consists of lowercase or uppercase letters, find the length
of the longest palindromes that can be built with those letters.
This is case sensitive, for ... |
4641422529eec41c1a0c8986b5a453b3769e1b9d | johnfelipe/progress | /courses/cs101/lesson02/quiz01/abbaiza.py | 368 | 3.71875 | 4 | # Define a procedure, abbaize, that takes
# two strings as its inputs, and returns
# a string that is the first input,
# followed by two repetitions of the second input,
# followed by the first input.
def abbaize(x, y):
# return x + y + y + x
return x + y * 2 + x
print(abbaize('a', 'b'))
#>>> abba
... |
ef04c38a04d7d36375230aede6d529f99cb76a90 | corentinloirs/python-eval | /huffman/codec.py | 4,226 | 3.6875 | 4 | #Codec va faire appel à la libraire heapq, pour gérer l'ordonnancement des noeuds selon leur valeur
#On pourrait s'en passer, en triant à chaque itération la liste de
#dictionnaire des noeuds selon les keys. heapq le fera pour nous
#Heapq.heappop pop le dico de key la plus basse
#Heapq.heappush ajoute le noeud au heap
... |
012dd0c23fd57ad6dc859ccee21ae5ff2662f3ab | nn-nagar/test | /task2.py | 267 | 3.828125 | 4 | phrase = input("Type in : ")
phrase_splited = phrase.split(' ')
# to remove duplicated
word_list = []
for i in phrase_splited:
if i not in word_list:
word_list.append(i)
else:
continue
word_list.sort()
print((' ').join(word_list)) |
1a095c99dff7d886a6db9385f8ad5ed6977e46fe | davecomeau/movie-trailer-website | /media.py | 1,427 | 3.875 | 4 | import webbrowser
class Movie():
""" Movie class
Movie objects contain information about a movie, including description
and preview URLS. Each object can open its preview trailer in a webbrowser.
Attributes:
title: A text field containing the name of the movie
storyline: A Text field that stores a... |
9056a1ac9d967dc481da7b2304a8388a13dcfb89 | wansook0316/problem_solving | /210701_백준_FBI.py | 306 | 3.515625 | 4 | import re
import sys
input = sys.stdin.readline
fbi = []
p = re.compile("FBI")
for i in range(5):
if p.search(input()) != None:
fbi.append(i + 1)
fbi.sort()
if not fbi:
print("HE GOT AWAY!")
else:
print(" ".join(list(map(str, fbi))))
# N-FBI1
# 9A-USKOK
# I-NTERPOL
# G-MI6
# RF-KGB1 |
8d7d7298d7686273c3d577f0a2b4800195cffec7 | fengjiaxin/prepare_work | /leetcode_tag/LinkedList/19.删除链表的倒数第 N 个结点.py | 758 | 3.890625 | 4 | # 给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。
#
# 进阶:你能尝试使用一趟扫描实现吗?
#
# 输入:head = [1,2,3,4,5], n = 2
# 输出:[1,2,3,5]
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def removeNthFromEnd(self, head: ListNode,... |
ddcc737a7d8a8beac8743556829a9d81e05ee408 | madhab-p/py-code | /src/root/pyconcpets/factorial.py | 859 | 3.703125 | 4 | '''
Created on Apr 11, 2017
Synopsis:
This document exhibits how doctest module can be used
for testing of the module.
@author: pneela
'''
def factorial(x):
'''
>>> factorial(5)
120
This function should not be called with very a large number
>>> factorial(1329283)
... |
dad314976c4558d510d5b359628673c72864314b | vpistola/project_euler | /euler45.py | 865 | 3.796875 | 4 | '''
Project Euler 45: After 40755, what is the next triangle number that is also pentagonal and hexagonal?
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, …
Pentagonal Pn=n(3n-1)/2 1, 5, 12, 22, 35, …
Hexagonal Hn=n(2n-1) 1, 6, 15, 28, 45... |
a89c3eeacce98261039ea21e5094528c92c3cbbf | yejiahaoderek/Email-Spam-Classification | /email_preprocessor.py | 9,300 | 3.734375 | 4 | '''email_preprocessor.py
Preprocess Enron email dataset into features for use in supervised learning algorithms
Jiahao (Derek) Ye
CS 251 Data Analysis Visualization, Spring 2020
'''
import re
import os
import numpy as np
def tokenize_words(text):
'''Transforms an email into a list of words.
Parameters:
-... |
de7f4d3d1edba01bcf760dfd8b55e2822649ce05 | BinceAlocious/python | /DataStructures/linkedList.py | 1,121 | 3.921875 | 4 | class Node:
def __init__(self,data=None):
self.data=data
self.next=None
class Linked_list:
def __init__(self):
self.head=Node()
def append(self,data):
new_node=Node(data)
cur=self.head
while(cur.next!=None):
cur=cur.next
cur.next=new_node
... |
48800ccf99842580ff9b17d144260e61aa50e0d7 | ramishtaha/Some_Basic_Programs_to_Better_Understand_PythonProgramming | /Life_In_Weeks.py | 588 | 4.03125 | 4 | # Greetings.
print("Welcome to the Life in Weeks Calculator")
# Below code Calculates How many years you have till you turn 90 and stores it in a variable.
age = int(input("Please Enter Your Current Age:\n"))
yrs_remaining = 90 - age
# Below code Calculates the number of Days, Weeks, Years from the above calculated v... |
cd4bdce361bda1dff7b0772022b1a2c168388f60 | lychunvira18/learning-python-bootcamp | /week01/ex/09_random_loop.py | 102 | 3.703125 | 4 | import random
N = input("Enter a number: ")
for x in range(int(N)):
print(random.randrange(100))
|
d4cbae1ce859d37d97d88e6975cf214542ef6d6a | ImranAvenger/uri-python | /1248.py | 838 | 3.578125 | 4 | n = input()
for nIndex in range(n):
alimentos = raw_input()
alimentosManha = raw_input()
alimentosAlmoco = raw_input()
cheat = False
alimentosRestantes = []
for alimento in alimentos:
alimentosRestantes.insert(len(alimentosRestantes), alimento)
for alimentoManha in alimentosManha... |
320f6bedfd5317a624404163bbb7c7e2a974ebb6 | SlyesKimo123/ComputadoraScience2 | /Object Oriented Programming/OOP_Chap16#2.py | 804 | 3.921875 | 4 | class Point:
def __init__(self, initX, initY):
""" Create a new point at the given coordinates. """
self.x = initX
self.y = initY
def getX(self):
return self.x
def getY(self):
return self.y
def distanceFromOrigin(self):
return ((self.x ** 2) + (self.y ... |
ecdc1884f2d586268d6443a26406ee0bd961a8a4 | Tonyhao96/LeetCode_EveryDay | /590_N-ary Tree Postorder Traversal.py | 925 | 3.671875 | 4 | #590_N-ary Tree Postorder Traversal
"""
# Definition for a Node.
class Node:
def __init__(self, val=None, children=None):
self.val = val
self.children = children
"""
#Recursion
#Time complexity: O(n) Space complexity: O(n)
class Solution:
def postorder(self, root: 'Node') -> List[int]:
... |
f70038eccce44b85c981b164bec29ffd605d00fd | int-invest/Lesson3 | /DZ3.py | 289 | 3.6875 | 4 | def my_func(var_1, var_2, var_3):
a = [var_1, var_2, var_3]
a.sort(reverse=True)
print(a[0] + a[1])
my_func(int(input('Введите первое число: ')), int(input('Введите второе число: ')), int(input('Введите третье число: ')))
|
7b45b338da13ed08d00c15fdad2fd3aa091dbcdd | avl-harshitha/WE-Programs | /assessment01/interweave.py | 504 | 3.90625 | 4 | import sys
def largest_str(str1, str2):
return max(str1, str2, key=lambda x: len(x))
def smallest_str(str1, str2):
return max(str1, str2, key=lambda x: -len(x))
def interweave_string():
str1 = sys.argv[1]
str2 = sys.argv[2]
large_str = largest_str(str1, str2)
small_str = smallest_str(str1, ... |
6b1bbc10a853401491a2539790899f6af7dc402d | wengjinlin/Homework | /Day06/Course/core/School.py | 578 | 3.625 | 4 | import Course,C_class
class School(object):
#学校基类
def __init__(self,name,address):
#自有属性
self.NAME = name
self.ADDRESS = address
self.COURSES = []
self.C_CLASSES = []
def create_course(self,name,cycle,price):
#创建课程,并关联
course = Course.Course(name,cycl... |
4a208806b221dbddf77e09711c91cf93d4aab2c4 | liorberi/WorldOfGames | /WorlfOfGames/MemoryGame.py | 982 | 3.828125 | 4 | import time
from random import randrange
import os
def generate_sequence(difficulty):
list = []
for num in range(difficulty):
list.append(randrange(1, 101))
print(list)
time.sleep(3)
cls()
return list
def get_list_from_user(difficulty):
list= []
for num in range(difficulty):
... |
618afab33ac1f5e18d18042d3ed9fc6e4e9f538c | nataliegarate/python_ds | /lists/min_val_list.py | 276 | 3.71875 | 4 | def findMinimum(arr):
if len(arr) == 0:
return None
min_val = arr[0]
for num in arr:
if num < min_val:
min_val = num
return min_val
def findMinimum2(arr):
if len(arr) == 0:
return None
arr.sort()
return arr[0]
|
6ba4a74a78ceff20c5cad7810182879ccf74431d | yohuhu/robot-framework | /test_sample/util.py | 186 | 3.578125 | 4 | from datetime import datetime
def get_current_time():
now= datetime.now()
now_time=now.strftime("%Y-%m-%d-%H_%M_%S")
print(now_time)
return now_time
get_current_time() |
886fd88d18ecafef1779725f8749bfab7283840a | bmaltby/project-euler | /019.py | 784 | 3.796875 | 4 | # 1 Jan 1900 is Monday so 7th Jan 1900 is a sunday
days_in_month = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
leap_years = {}
year = 1900
while year < 2001:
if (year % 4 == 0) and not (year % 100 == 0 and year % 400):
leap_years[year] = True
else:
leap_years[year] = False
year ... |
10aa8696371bb97ca1376bb380055bebc88a128e | asxzhy/Leetcode | /leetcode/question_1556/solution_3.py | 812 | 4.0625 | 4 | """
Loop through the input, add every digit to the result string. If the digits
left in the input is divisible by three, then add a dot to the result string
"""
class Solution:
def thousandSeparator(self, n: int) -> str:
# initialize a string to store the result
res = ""
# conver... |
1cb9b724990a47f8a2206f26bd6992cb13243cf9 | jespererik/sensor-module | /install.py | 3,389 | 3.53125 | 4 | from ConfigParser import RawConfigParser
"""
Example structure of the config file
#General information about the node
[NODE]
NAME = RaspberryPi3
SENSORS = DHT11-Temperature,DHT11-Humidity
LOCATION = Pannrum
#Defines the IP and port the server is hosted on
[NETWORK]
SERVER_IP = 192.168.0.121
SERVER_PORT = 3000
#De... |
9c5d6262ae9b22455159ab34a1c7d9fcb5809599 | monidan/shit-code-python-oop | /Pizzas.py | 2,808 | 3.734375 | 4 |
class Pizza:
def __init__(self, size):
self._size = size
self._price = 0
self.is_discounted = False
@property
def size(self):
return self._size
@property
def size_naming(self):
if self.size == 1:
return 'Маленька'
elif self.size == 2:
return 'Стандартна'
elif self.... |
b94e793846b5e36fe42504ef8d0cea237a179421 | alesalsa10/pdf_to_voice | /pdf_reader.py | 907 | 3.796875 | 4 | #extract text from pdf and read it using google text to speech
import PyPDF2, os
from gtts import gTTS
from sys import argv
pdf_name = argv[1]
txt_name = argv[2]
mp3_name = argv[3]
def text_extractor():
with open(f'{pdf_name}.pdf','rb') as pdf_file, open(f'{txt_name}.txt', 'w',encoding='utf-8') as text_file:
... |
775e7d7f7fa2a1891ee598048dba9989a85baa90 | WXLyndon/Data-structures-and-algorithms-review | /array/merge_sorted_arrays.py | 865 | 3.953125 | 4 | # input:[0,3,4,31], [4,6,30]
# output: [0,3,4,4,6,30,31]
def merge(arr1, arr2):
mergeArr = []
# Check if arr1 or arr2 is empty
if len(arr1) == 0:
return arr2
if len(arr2) == 0:
return arr1
arr1_index = 0
arr2_index = 0
while (arr1_index < len(arr1)) or (arr2_index < l... |
d2d9c3df38af646d3c725297b0a023462a7dea6e | mcclosr5/Python-code | /birthday_021.py | 1,000 | 4.03125 | 4 | #!/usr/bin/env python3
import sys
import calendar
def days(y, m, d):
b = calendar.weekday(y, m, d)
if b == 0:
return "You were born on a Monday and Monday's child is fair of face."
elif b == 1:
return "You were born on a Tuesday and Tuesday's child is full of grace."
elif b == 2:
... |
a8349f6cbee5cdb6458375df35ed7d4414f5adc6 | TheElderMindseeker/pmldl-assignment-1 | /task_2.py | 6,461 | 3.75 | 4 | """Implementation of simulated annealing algorithm for travelling salesman"""
import os
from copy import copy
from math import exp
from random import random, randrange, shuffle
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from geopy.distance import geodesic
from matplotlib.animation import Fu... |
43d0cd15627781349397ae2815a71b787fe3b17d | lucioeduardo/competitive-codes | /2019/Jadson/CP3-CAP2/2.2.1/1.py | 162 | 3.8125 | 4 | lista = [3,1,2,3,4]
lista.sort()
for cont in range(len(lista) - 1):
if lista[cont] == lista[cont+1]:
print("Encontrou")
break
else:
print("Não encontrou") |
0d1aa16281716aa81127bc8595b548f2ef2ee6e0 | Foh-k/algorithm_lecture | /insertion_sort.py | 664 | 3.765625 | 4 | import random
# 0~100の値を持つ15要素配列を乱数で生成
def make_randlist(n=15):
return list(random.randrange(100) for _ in range(n))
# 挿入する.実装方法の関係上後ろから降順か比較をしている
def insertion_sort(lst):
for i in range(1, len(lst)):
idx = i
while(idx > 0 and lst[idx - 1] > lst[idx]):
tmp = lst[idx - 1]
... |
3ef6e2e28e71eddf1dbafa4525a2a9c917e8766d | wobushimotou/Daily | /python/day8.py | 799 | 3.890625 | 4 | #!/usr/bin/env python
# coding=utf-8
#定义类描述数字时钟
from time import sleep
import os
class Clock:
def __init__(self,hour=0,minute=0,second=0):
self.__hour = hour
self.__minute = minute
self.__second = second
def run(self):
self.__second += 1
if(self.__second == 60):
... |
ef552d311969ad338074e638c19069c5f465c5fa | Simranbassi/python_grapees | /ex3a.py | 170 | 4.15625 | 4 | age=int(input("enter the age of the candidate"))
if age>=18:
print("candidate is eligible for the voting")
else :
print("candidate is not eligibble for the voting") |
1d017ea004d23e9bc087833165289e7aa9497c88 | zhangxinli/leetcode | /back/next_permutute.py | 918 | 3.515625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2018-11-18 16:24:36
# @Author : xinli (xinli.zxl@foxmail.com)
# @Link :
# @Version : $Id$
class Solution:
def nextPermutation(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place inst... |
a4907434978c2c20342f82eee54f10e644e05e79 | ArturasDo/Pamoka-Nr.9-Ciklai | /ArturasDo Homework 9.1.py | 578 | 4.0625 | 4 | # Converter: kilometers into miles
print(" ")
print ("It's a converter, that converts kilometers into miles")
while True:
print(" ")
km = input("Please enter number of kilometers: ")
km = float(km.replace(",", "."))
miles = km * 0.621371
print("Result: " + str(km) + " kilometers = " + str(miles) + ... |
5559bf0140430cc15024246df7ced04e0f614997 | DStheG/ctci | /01_Arrays_and_Strings/01_Is_Unique.py | 2,230 | 4.15625 | 4 | #!/usr/bin/python
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1.1 Is Unique
Implement an algorithm to determine if a string has all unique characters.
What if you cannot use additional data structures?
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
im... |
e439ec29ded67a1f183b765666cad6fe69850ac9 | rahuladream/Python-Exercise | /Edugrade/create_2d.py | 467 | 4.03125 | 4 | """
QUESTION 7:
Create a 2-D list from the given input. You will get 2 inputs 1st parameter is the no. of elements in the list and the 2nd parameter is the no. of lists.
the elements inside the list should start from 0 and end at n-1.
Example -
Input - 8 3
Output - [
[0,1,2,3,4,5,6,7],
[0,1,2,3,4,5,6,7],
... |
cbd5e5b257a41e92ad04be1d615d50f06fe86956 | ungerw/class-work | /ch3ex2.py | 302 | 4.125 | 4 | try:
hours = float(input('Hours Worked: '))
rate = float(input('Rate of Pay: '))
if hours <= 40:
pay = hours * rate
print(pay)
elif hours > 40:
pay = (40 * rate) + ((hours - 40) * (rate * 1.5))
print(pay)
except:
print('Please enter a numeric input') |
0ef253599f0c72e5f2876997c0bf0ae7dc950da6 | TanakitInt/Python-Year1-Archive | /In Class/Week 5/username.py | 524 | 4.34375 | 4 | # username.py
# Simple string processing program to generate usernames:
# First initial + first seven characters of last name
def main():
print("This program generates computer usernames.\n")
# get user's first and last names
first = input("Please enter your first name: ")
last = input("Please enter ... |
e3d04afeaf18ae4057eaf0c2a877473a93f06a43 | qmnguyenw/python_py4e | /geeksforgeeks/python/basic/2_11.py | 2,507 | 4.09375 | 4 | How to Get the Tkinter Label Text?
**Prerequisite:**Python GUI – Tkinter
Python offers multiple options for developing a GUI (Graphical User
Interface). Out of all the GUI methods, _tkinter_ is the most commonly used
method. It is a standard Python interface to the Tk GUI toolkit shipped with
Python. Pyth... |
cb8e50b6b433109f1fae871a26205f5041ffae9a | rjc89/LeetCode_medium | /jump_game.py | 558 | 3.71875 | 4 | # https://leetcode.com/problems/jump-game/discuss/774588/Python%3A-Easy!-Linear-Time-O(n)-and-Space-O(1)-oror-Explanation
from typing import List
class Solution:
def canJump(self, nums: List[int]) -> bool:
reachableIndex = 0
for curr in range(len(nums)):
if curr + nums[curr] >= reachab... |
7b16d5c1a3d135a627b29a9495179b3666c4059c | byAbaddon/Book-Introduction-to-Programming-with----JavaScript____and____Python | /Pyrhon - Introduction to Programming/4.2. Complex Conditions - Exam Problems/03. Operations.py | 538 | 4 | 4 | n_one, n_two, operator = int(input()), int(input()), input()
try:
result = eval(f'n_one {operator} n_two')
if operator == '+' or operator == '-' or operator == '*':
is_even = 'even' if result % 2 == 0 else 'odd'
print(f'{n_one} {operator} {n_two} = {result} - {is_even}')
elif operator == ... |
f73473a4fafe47c0f65f2abc9a30da23a4d78d08 | Prateeek73/90PlusBasicPythonCodes | /Codes/14.py | 251 | 3.8125 | 4 | d={'UPPERCASE':0,
'LOWERCASE':0}
for c in input("Enter the sentence"):
if c.isupper():
d["UPPERCASE"]+=1
elif c.islower():
d["LOWERCASE"]+=1
else:
pass
for key,value in d.items():
print(key+" : "+str(value))
|
2c11614a14e3e3d2d5492d42fde3eb665f166f4a | alexandrebarbaruiva/UnBChatBot | /bot/chatbotDAO.py | 3,868 | 3.84375 | 4 | """
Modulo responsavel pela interacao com o banco de dados.
TODO: Melhorar a documentacao
"""
import os
import sqlite3
class DAO():
"""Objeto responsavel por manipular o banco de dados."""
def __init__(self, database_path="chatbot.db"):
self._database_path = database_path
self._is_connected = ... |
03ceee50ed6dd2d7c2c3d1024057dbc01de70c59 | juriadrian/KernelSimulator | /FileSys/File.py | 791 | 3.546875 | 4 | __author__ = 'adri'
class File():
def __init__(self, file_name, inode):
self.name = file_name
self.inode = inode
class INode():
def __init__(self, name):
self.name = name
self.pointer = []
def add_pointer(self, pointer):
self.pointer.append(pointer)
class Dat... |
4808a1b4e8e494715e07f9d3c8eae2c0cadca10b | zh0uquan/LeetcodePractice | /Leetcode238.py | 1,167 | 3.609375 | 4 | class Solution(object):
def productExceptSelf(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
size = len(nums)
res = [1] * size
def helper(output, list, start, end, step=1):
p = 1
for i in range(start, end, step):
... |
d61fd596bc639c3cfa5328871097d441e24b95aa | theTonyHo/armacode | /source/examples/List_GetNextItem.py | 668 | 4.125 | 4 | """
Example:
How to advance to the next item in a list by providing a direction.
The logic here applies to most scriptincg languages. However, ` % totalCount` is unneccessary in Python as it accept index greater than the length of the list.
"""
dataList = ['a','b','c','d','e']
totalCount = len(dataList)... |
b618964112e46449b9be0909db6c8fe832785274 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/anagram/4e6c06c3a90f412ea74eb3ef49621621.py | 1,444 | 4.0625 | 4 | import collections
class Anagram(object):
def __init__(self, word):
# _word is the normalized version of word.
word = word or ""
self._word = word.lower()
# _char_count is a dict containing the count of each character in _word.
self._char_count = collections.Counter(self._word)
def match(self, strings):
... |
7bae8a20bf6f694822e16294311f609792c5c2a5 | bharat-kadchha/tutorials | /core-python/Core_Python/regexpkg/Regex_As_2.py | 698 | 4.5 | 4 | ''' The check_time function checks for the time format of a 12-hour clock, as follows:
the hour is between 1 and 12, with no leading zero, followed by a colon, then
minutes between 00 and 59, then an optional space, and then AM or PM, in upper or
lower case. Fill in the regular expression to do that. How ma... |
de1fd508febf44ff74224b82998f400d3e39dc7e | oliviadxm/python_work | /chapter_6/chapter_6.py | 3,775 | 3.984375 | 4 | #6-1
print("---------6/1---------")
person = {
'first_name': 'hyesung',
'last_name': 'shin',
'age': 39,
'city': 'seoul',
}
print(person['first_name'])
print(person['last_name'])
print(person['age'])
print(person['city'])
#6-2
print("---------6/2---------")
favorite_num = {
'A': 1,
'B': 2,
... |
0eeeabd6e181bfe320b9c5417042415cbc40dc4b | zZedeXx/My_1st_Game | /Unuse/3..py | 457 | 4.09375 | 4 | # Написать функцию,
# принимающую произвольное кол-во чисел и возвращающую кортеж всех целых чисел,
# т.е. все дробные значения отсеиваются функцией.
def Function(*args):
lst = list(args)
for s in lst[:]:
if type(s) == float:
lst.remove(s)
return tuple(lst)
print(Function(2.5, 6.2, 87,... |
bc3d4c5ec5ff266683b7cfc387a3cd16c87e5865 | jdrestre/Online_courses | /Udemy/Python_sin_fronteras_HTML_CSS_Flask_MySQL/ejercicios.py | 984 | 4.03125 | 4 | # dato = input('Ingrese dato: ')
# lista = ['hola', 'mundo', 'chanchito', 'feliz', 'dragones']
# if lista.count(dato) > 0:
# print('El dato existe:', dato)
# else:
# print('El dato no existe :(', dato)
primero = input('Ingrese primer número: ')
try:
primero = int(primero)
except:
primero = 'chanchit... |
81e38c89ddffcfc50842364278c38d5386c43123 | SaiPrathekGitam/MyPythonCode | /oop/account.py | 796 | 3.546875 | 4 | from oop import amount_error as er
class SavingsAccount:
def __init__(self, acno, name, bal):
self.acno = acno
self.name = name
self.bal = bal
def print_details(self):
print("Account Number : ", self.acno)
print("Name : ", self.name)
print... |
37824fc95aa1bb6f02b5242031e3939aa5494ef9 | sandeepkumar8713/pythonapps | /22_secondFolder/37_alphabet_board_path.py | 3,090 | 4.03125 | 4 | # https://leetcode.com/problems/alphabet-board-path/
# https://leetcode.com/problems/alphabet-board-path/discuss/414431/python-O(n)-z-explanation
# Question : On an alphabet board, we start at position (0, 0), corresponding to character board[0][0].
# Here, board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"],
# ... |
a19249f2838b5e596f7d30bd172c29ebc8fdbaab | Dechuan0629/LeetCodePractice | /validPalindrome-Python/validPalindrome.py | 748 | 3.734375 | 4 | class Solution:
def validPalindrome(self, s: str) -> bool:
if ''.join(reversed(s)) == s:
return True
i , j = 0, len(s)-1
temp = list(s)
while i < j:
if temp[i] == temp[j]: #两个指针从两边开始判别,当找到一个不同时,去掉这个如果是回文就返回True,否则返回False
i+=1
j... |
9f57830a4f2fbd2ffaa8d4c3ebd59b83a22fb64e | KHVIII/CS1114- | /hw1/ytc344_hw1_q5.py | 236 | 3.65625 | 4 | def fibs(n):
n0 = 1
yield n0
n1 = 1
yield n1
for i in range (n-2):
result = n0 +n1
n0 = n1
n1 = result
yield result;
def main():
for curr in fibs(1):
print(curr)
|
a4d9fecb830b99ee8cbd3831a07c41aca6fe4e62 | prathimacode-hub/Python-Tutorial | /Beginner_Level/Set.py | 1,078 | 3.5625 | 4 | Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> basket = {"apple","mango","orange","pear","banana","apple"}
>>> basket
{'apple', 'pear', 'banana', 'orange', 'mango'}
>>> a = set()
>>> a.add(... |
383a2c4433018b29a9106cd1db321fa6bb8dc0fd | Sherlynchance/SherlynChance_ITP2017_Exercises | /4-6. Odd Numbers.py | 89 | 3.78125 | 4 | odd = []
for x in range(0,20):
if x % 2 != 0:
odd.append(x)
print(odd)
|
0b4bdaff589b0fbde5c2fcd093524cb041ea111f | pardeepsingal/python-learning | /expression.py | 320 | 4.03125 | 4 | #!/usr/bin/env python3
x=23
y=74
if(x<y):
print('x < y and the value of x = {}, value of y = {} '.format(x,y))
elif(x>y):
print('x > y and the value of x = {}, value of y = {} '.format(x,y))
elif(x==y):
print('x and y are equal and value of x = {} and value of y = {} '.format(x,y))
else:
print('something else') |
dbc75508320e00241242f137950cdbafb8ad977f | E-Wawrzynek/ECEN-2703_Final-Project | /sudoku_generator.py | 4,048 | 3.640625 | 4 | # Suduko Generator, Final Project ECEN 2703
# Ella Wawrzynek & XuTao Ho
import argparse
from z3 import *
import random as rd
import itertools
def generate_board():
number_list = [Int('n%i'%i) for i in range(0,81)]
s = Solver()
for x in number_list:
s.add(And(x >= 1, x <= 9))
for x in range(0... |
acf2ef1a60eec2ba8d1f1cb9828ee07582dbb0d4 | DanielVitas/projektna-naloga-UVP | /physics/vector.py | 1,175 | 4.09375 | 4 | class Vector(object):
def __init__(self, x, y=None):
if y is not None:
self.x = x
self.y = y
else:
self.x = x.x
self.y = x.y
def __add__(self, other):
return Vector(self.x + other.x, self.y + other.y)
def __sub__(self, o... |
81c21c61a850c1cff1cc00968b13b50f80eec3ab | dr-aryone/BiblioPixel | /bibliopixel/layout/geometry/segment.py | 1,539 | 3.59375 | 4 | from . import strip
class Segment(strip.Strip):
"""Represents an offset, length segment within a strip."""
def __init__(self, strip, length, offset=0):
if offset < 0 or length < 0:
raise ValueError('Segment indices are non-negative.')
if offset + length > len(strip):
... |
f86d5e7eb8ae286ff1b8764cef7c88e9b5a69b54 | JojoPalambas/Klyxt | /src/string_utils.py | 199 | 3.78125 | 4 |
def isNumber(s):
if not s or s == "":
return False
for c in s:
if c not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']:
return False
return True
|
53d0e6c3cd43c0439567152fadc0392c17bb8668 | cassantiago/520-python | /Aula1/sintaxeBasica.py | 710 | 4.21875 | 4 | #!/usr/bin/python3
#print('hello word')
#nome = str(input('digite seu nome: ')).upper()
# print (nome)
# print('seu nome é', nome)
# print(input('Digite seu nome: '),'Seja bem vindo')
# print(input('Digite sua idade: '),'idade')
#idade = input('digite sua idade: ')
#print(f'deu nome é {nome}, e sua idade é {idade} ')
... |
9087c608302cafb48297db5ef02e4203674519af | deepeshchaudhari/learnOOPython | /tut6b[filter].py | 196 | 3.6875 | 4 | '''
filter function
'''
def greater_than_2(n):
if n>2:
return True
else:
return False
l = [1,2,12,1,2,1,2,1,222,1,2,1,2]
gt = list(filter(greater_than_2,l))
print(gt)
|
a972b4781fdd651a1147a68dfaf04aaf50971642 | mercolino/monitoring | /lib/sqlite.py | 6,095 | 3.640625 | 4 | import sqlite3
import re
import datetime
class SQLite():
def __init__(self, db_name):
# Error Checks
if not isinstance(db_name, str):
raise TypeError("The name of the database should be a string")
if len(db_name) == 0:
raise ValueError("The database name should not... |
690f57357862c6abee4b98e2fd26961dd275c952 | prativadhikari/Bussi | /countvowelconsonant.py | 453 | 4.09375 | 4 | """
The given program asks a user for a word and
tells how many vowels and consonants the word contains.
"""
def main():
ask = input("Enter a word: ")
vowels = 0
consonants = 0
for i in ask:
if (i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u'):
vowels = vowels + 1
el... |
83725d63e34c648d84a53f6278ddf536d8bab737 | VinhMaiVy/learning-python | /src/Algorithms/00 Implementation/py_kangaroo.py | 498 | 3.734375 | 4 | #!/bin/python3
"""
0 2 5 3
NO
0 3 4 2
YES
43 2 70 2
NO
Modulo
"""
def kangaroo(x1, v1, x2, v2):
result = 'NO'
if (v1 != v2):
jumps = (x2-x1)/(v1-v2)
if jumps > 0 and jumps % 1 == 0:
result = 'YES'
return result
if __name__ == '__main__':
x1V1X2V2 = input().spl... |
9e616d0a72b1a2cca9d766972407e09fa9551076 | zzhyzzh/Leetcode | /leetcode-algorithms/706. Design HashMap/MyHashMap.py | 1,895 | 3.59375 | 4 | class MyHashMap(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.size = 1000
self.buckets = [[] for _ in range(self.size)]
def put(self, key, value):
"""
value will always be non-negative.
:type key: int
:typ... |
4b53c836991db73d12be6310eb20bacd7d6aa45f | 11Q/openPY | /大数据开发语言(Python语言程序设计)-课件/Codes/第01章 程序设计基本方法/rose-1c.py | 1,547 | 3.625 | 4 | #turtle绘制玫瑰
from turtle import*
#global pen and speed
pencolor("black")
fillcolor("red")
speed(50)
s=0.15
#init poistion
penup()
goto(0,600*s)
pendown()
begin_fill()
circle(200*s,30)
for i in range(60):
lt(1)
circle(50*s,1)
circle(200*s,30)
for i in range(4):
lt(1)
circle(100*s,1)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.