blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
cac09d4e227031074f5410dfd921662ab4eab769 | dxb350352/python_learn | /10函数.py | 329 | 3.671875 | 4 | #!/usr/lib/python3
a = [1, 2, 3]
print(a)
a = "d"
print(a)
def go(a, b=1):
print(a, b)
go(a=2)
def gogo(a, *xx, **yy):
print(a)
for t in xx:
print(t, "xx")
for k, v in yy.items():
print(k, v, "yy")
gogo(1, 2, 3, 4, aa=1, bb=2)
sum = lambda a1, a2: a1 + a2
print(sum(1, 2))
prin... |
489ba1128bd957c366c2d019167b5316938c3196 | cryoyan/rs_data_proc | /learning_codes/learn_retry.py | 1,516 | 4.09375 | 4 | #!/usr/bin/env python
# Filename: learn_retry
"""
introduction: some code to understand the retrying model.
# https://github.com/rholder/retrying
# https://pypi.org/project/retrying/
# https://www.jb51.net/article/170781.htm
authors: Huang Lingcao
email:huanglingcao@gmail.com
add time: 02 February, 2021
"""
import... |
86d86437fa88b798840771e3c24241187e3c55b6 | Wangi-C/Python-Data-Structure-Algorithm | /2장(기본자료구조와 배열)/sum_1ton.py | 238 | 3.6875 | 4 | def sum_1ton(n):
result = 0
i = 1
while i < n+1:
result += i
i += 1
return result
x = int(input("x의 값을 입력하세요.:"))
print(f"1부터 {x}까지 정수의 합은 {sum_1ton(x)}입니다.") |
0ba47fc11dbe4502d3f176ed2817f705f6a56f55 | pateljay1397/Hackerrankepython | /hello.py | 1,333 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 22 18:33:58 2020
@author: patel
"""
import random
def hello():
print("Hello World This Jerry is here")
print(random.randrange(1,15))
hello()
x=10.5
y="Jerry"
print(y[2:5])
print(y[-5:-3]+y[2:5])
x=int(x)
print(x)
x=str(x)
print(len(y))
print(y.strip())... |
0fc23f8fad34e0ffbf48c8a9b5090385e8403023 | juanfariastk/FunnyAlgorithms | /CountCoins/count_coins.py | 881 | 4.15625 | 4 | def return_coins(user_money : int, coin_list : list) -> list:
"""Function that returns the minimum amount of coins to convert
a given amount of money
Args:
user_money (int): provided amount of money
coin_list (list): list with the value of coins
Returns:
list: minimum amount of... |
700d98afaea2e687ceafcc9257119a3bdc4fc65e | MUDIT-SINGH001/SEARCHING-AND-SORTING | /middle of 3.py | 85 | 3.6875 | 4 | if A<B and B<C:
print(B)
elif C>A and C<B:
print(C)
else:
print(A)
|
de5eb39f0cb1835031222313c32b72dda0735233 | osamamohamedsoliman/BFS-1 | /Problem-1.py | 1,149 | 3.765625 | 4 | # Time Complexity :O(n)
# Space Complexity :O(n)
# Did this code successfully run on Leetcode : yes
# Any problem you faced while coding this : no
# Your code here along with comments explaining your approach
class Solution(object):
def levelOrder(self, root):
"""
:type root: TreeNode
:rty... |
929d5190f5d3c9156071b32b38f2f349ce4df49c | akankaku1998/3-to-10-Sides-Shapes | /main.py | 338 | 3.859375 | 4 | import turtle as t
import random
tim = t.Turtle()
colours = ["CornflowerBlue", "DarkOrchid", "IndianRed", "DeepSkyBlue", "LightSeaGreen", "wheat", "SlateGray", "SeaGreen"]
for x in range(3, 11):
tim.color(random.choice(colours))
for y in range(x):
tim.forward(100)
tim.right(360/x)
screen = t.Screen()
sc... |
c696b1c507015801bc043bd64e67f134a6262a64 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2480/61135/299404.py | 228 | 3.5625 | 4 | T=int(input())
for a in range(0,T):
N=int(input())
num=input().split(" ")
num=list(int(b) for b in num)
num=sorted(num,key=lambda x: x%2)
for c in range (0,len(num)):
print(num[c],end=" ")
print() |
c262c2d0598946432f7578822d0c994db64d9a0a | Sheko1/SoftUni | /Python-Fundamentals/Classes-and-Objects/Lab/03_email.py | 1,044 | 3.6875 | 4 | class Email:
def __init__(self, sender, receiver, content):
self.sender = sender
self.receiver = receiver
self.content = content
self.is_send = False
self.mails = []
def send(self):
self.is_send = True
def get_info(self):
return f"{self.sender} says ... |
a8028c387cd7614526d1621c9ac1761441383cad | venkatarahul189/Python-deep-learning | /ICP2/icp2(2).py | 173 | 3.71875 | 4 | set = 0
a = int(input('num:'))
while a != 0:
if (a % 2) == 0:
a = a/2
set = set + 1
else:
a = a - 1
set = set + 1
print(set) |
220b749a1ba503a49b70001665df477ff2b5ca22 | ramneetbrar/Lotto-Draws-Analysis | /finalAssignment.py | 18,849 | 3.984375 | 4 | #global variables:
userInputFile = "" #input file that user chooses to gather data
listOfDraws = [] #list of draws, including all information (lall in provided code)
listOfDatesOfDraws = [] #list of dates of draws from listofdraws(lall)
listOfNumsDrawn = [] #list of draw numbers from listofdraws(lall)
listOfDrawJackpot... |
9949031a632c2cf49d75013680d76c02aa269778 | michealodwyer26/MPT-Senior | /Labs/Week 7/moneyConverter.py | 1,309 | 3.921875 | 4 | '''
program for euro to dollar conversion using the rate = 1.23
'''
from tkinter import *
# Set up the window
root = Tk()
root.title("Money Converter")
root.geometry("300x200+100+100")
# make the interface
convLabel = Label(root, text="Euro to Dollar Converter")
convLabel.grid(row=0, column=1, columnspan=2)
# euro ... |
d82e794a21ed08c918e5529691940d4b49e116a2 | KATO-Hiro/AtCoder | /Others/code_festival/CODE_THANKS_FESTIVAL_2017_A/ProblemB.py | 314 | 3.546875 | 4 | # -*- coding: utf-8 -*-
# CODE THANKS FESTIVAL 2017(Parallel)
# Problem B
if __name__ == '__main__':
s = input()
i = 0
count = 0
while len(s) > 0:
if s[i:] == s[i:][::-1]:
print(count)
exit()
else:
i += 1
count += 1
|
3fc03d86f82c5158eb664dab9e609e7655ef1df4 | tatikondarahul2001/py | /24122020/8.py | 165 | 3.6875 | 4 | d={"R.No":1206,"Name":"Rahul","Course":"B.Tech"}
d["marks"]=46
d["percentage"]=99.4
print(d)
print(d["Course"])
d.pop("Course")
print(d)
print(d.popitem())
print(d)
|
534ca659fc8fcf5a86d392ddbeafa04fb5db22d4 | m-242/passwd_gen | /generator.py | 1,218 | 4.15625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# A simple password generator, outputs X words from a given dic, in camelCase.
import argparse
import random
import sys
import os
def args_parsing_and_checking():
parser = argparse.ArgumentParser()
parser.add_argument(
"--nb_words",
help="The number... |
fcea157629d648a72a3a52d87609de7a62839050 | umunusb1/PythonMaterial | /python2/14_Code_Quality/02_unit_test/example.py | 298 | 3.765625 | 4 | # ch6_example.py
def first(num_list1):
num_list1.sort()
return num_list1[0]
def last(num_list):
num_list.sort()
return num_list[-1]
if __name__ == '__main__':
list_nums = [7, 9, 5]
print 'last(list_nums)', last(list_nums)
print 'first(list_nums)', first(list_nums)
|
03a36c0b07f013c120af1d894095a4019b3decc4 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2671/60835/295824.py | 903 | 3.796875 | 4 | '''
for q in range(int(input())):
def to_int(bin_res):
res = 0
for x in range(len(bin_res)):
res = res + int(bin_res[x])*(2**x)
return res
n = int(input())
bin_res = "1"*n
res = to_int(bin_res)
print(res)
'''
# Python 3 program to count all
# distinct binary stri... |
83df86c9c93857be028860ecdcc39d783dfca884 | besseddrest/python-exercises | /leetcode/20-valid-parentheses.py | 1,382 | 4.09375 | 4 | # https://leetcode.com/problems/valid-parentheses/
"""
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Note... |
90e78eb586104f49f8b642b6dd0f5a3268f51e91 | GORAofSecurity/project1 | /fib.py | 126 | 3.796875 | 4 | #!/usr/bin/python
n = int(input())
num=1
fib0=0
fib1=1
for n in range(1,n):
num=fib1+f0
fib0=fib1
fib1=num
print(num)
|
88fba382e8a2f6b88bfdabcbc4f9e7bc89cd13fb | deboraOli/exercicios-python | /untitled/exer16.py | 321 | 4.0625 | 4 | fruits=["apple","banana","cherry"]
for x in fruits:
if x == "banana":
continue
print(x)
print("--------------")
for y in range(7):
print(y)
print("-----------")
for b in range(2,8):
print(b)
print("--------------")
for c in range(8):
print(c)
else:
print("Finaly finished!"... |
894ec7535a2aeb074c52003655b126a1df454c95 | sayunikd/simonsays | /scripts/append_list.py | 329 | 3.625 | 4 | import time
import random
colors = ['R', 'G', 'B', 'Y']
def append_list():
n=random.randint (0,3)
colors.append(colors [n])
color_string = ' ' .join (colors)
for i in range(0,len(colors)):
print colors[i] .lower()
time.sleep(1)
if __name__=='__main__':
try:
append_list()
except KeyboardInterrupt:
print 'G... |
01afa8ed8bde2b2a5a0a866d618fc281bcd81282 | PikeyG25/Python-class | /pseudocode example.py | 467 | 4.25 | 4 | ##Pseudocode:
##num1: input from the user;
##num2: inpout from the user;
##
##check numbers if num1 and num2 are all digits
##if both are digits tell user
##if one or the other is a digit tell user
##if neither are digits tell user
num1 =input("enter a number")
num2 =input("enter a number")
if num1.isdigit() and num2... |
0eab1b4bb4fc88f133ea39b296c01e023cbe6c7b | jdanray/leetcode | /removeDuplicates3.py | 344 | 3.53125 | 4 | # https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/
class Solution(object):
def removeDuplicates(self, s, k):
if not s:
return ""
r = 1
for i in range(1, len(s)):
if s[i] == s[i - 1]:
r += 1
else:
r = 1
if r == k:
return self.removeDuplicates(s[:i - r + 1] + s[... |
d6f1df9df25b43531b21a89d187165969d29228d | grvn/aoc2020 | /09/day9-2.py | 896 | 3.578125 | 4 | #!/usr/bin/env python3
from sys import argv
from itertools import combinations
from collections import deque
def find_fault(input: list, preamble_size: int):
preamble = deque(input[:preamble_size][::-1])
values = input[preamble_size:]
for value in values:
done = True
for x,y in combinations(preamble,2):
... |
455a4e3b40f56b4c749229e993553bb3434c0849 | aqueed-shaikh/submissions | /6/zhu_steve/3-madlibs/word.py | 901 | 3.90625 | 4 | import re
VOWEL_PAT = re.compile('[aeiou]')
ADJACENT_VOWEL_PAT = re.compile('[aeiou]{2,}')
class Word:
_word = ""
def __init__(self, word):
self._word = word
def __str__(self):
return self._word
def plural(self):
return self._word + 's'
def gerund(self):
w = sel... |
bfa777ca55fbf7ae7c7bfd153720cdf8ff6ec509 | Nagendracse1/Competitive-Programming | /backtracking/Ratndeep/nqueen problem.py | 1,070 | 3.53125 | 4 | def safe(chess,row,col,n):
for i in range(row):
if chess[i][col]==1:
return False
temp=col-1
for i in range(row-1,-1,-1):
if temp==-1:
break
if chess[i][temp]==1:
return False
temp-=1
temp = col+1
for i in range(row-1,-1,-1):
... |
3c1eff2188a79290f6a11144a836d5c544c264f2 | techehub/pythonbatch20 | /while2.py | 404 | 4.1875 | 4 | while True:
val = input ("Do you want to calculate #")
if val =="Q" or val=="q":
break
a = input("Enter num1 #")
b = input("Enter num2 #")
op = input("Type#")
if op == '+':
result = int(a) + int(b)
elif op == '-':
result = int(a) - int(b)
elif op == '*':
... |
47eb9df6c172d484177439b408a6d186887897c8 | FabioCostaR/aprendendoPYTHON | /Desafio35.py | 467 | 4.125 | 4 | #Desenvolva um programa que leia o comprimento de três retas e dia ao usuario se
#elas podem ou não formar triangulo.
r1 = float(input('digite o tamanho da reta 1 :'))
r2 = float(input('digite o tamanho da reta 2 :'))
r3 = float(input('digite o tamanho da reta 3 :'))
print('-='*20)
if (r1<r2+r3) and (r2<r1+r3) ... |
89428ee4e39f1c11fabe5f86e47ebb5001edd223 | makurek/leetcode | /476-number-complement.py | 954 | 4.25 | 4 | '''
Given a positive integer, output its complement number. The complement strategy is to flip the
bits of its binary representation.
Note:
The given integer is guaranteed to fit within the range of a 32-bit signed integer.
You could assume no leading zero bit in the integer’s binary representation.
Example 1:
Input:... |
97212ace37ec1fb55643d73f509fda6b6c104d59 | AICDEV/python-uk-training | /basics/03_map.py | 234 | 3.828125 | 4 | ####################
# map
# => https://docs.python.org/3/library/functions.html#map
####################
def square(n):
return n**2
numbers = list(range(1,50))
square_numbers = list(map(square, numbers))
print(square_numbers) |
4c6b752e1c97b1e36a73919934065f3a1106636d | dunber123/CIS2348 | /Homework1/Homework2.19.py | 1,202 | 4.15625 | 4 |
lemon = float(input("Enter amount of lemon juice (in cups):\n"))
water = float(input("Enter amount of water (in cups):\n"))
agave = float(input("Enter amount of agave nectar (in cups):\n"))
serves = float(input("How many servings does this make?\n"))
print('\nLemonade ingredients - yields','{:.2f}'.format(serve... |
cc0ded2172af0ef3cd6dba4433e472b5abcedd73 | Manish-Thakur/Programming | /pattern3.py | 440 | 4.15625 | 4 | # program to print a pattern
n=int(input("Enter the limit: "))
for i in range(1,n+1):
for j in range(1,n+1):
if j>=n+1-i: #check condition, if true then print star else print space
print("*",end='')
else:
print(" ",end='')
print() #this will print... |
5fea6b29a2a33656a53613b12e4072f15c0ead6a | adi19012001/CaptchaGUI | /palindrome.py | 220 | 4.3125 | 4 | # palindrome
a=input("\nEnter word to check whether it is palindrome or not")
b=reversed(a)
if list(a) == list(b):
print("\nThe word is palindrome")
else:
print("\nThe word entered is not a palindrome")
|
55064775b5636945f19c4e9a2a74f640a27fbf64 | rpolnx/python-graphics | /main.py | 677 | 3.640625 | 4 | import matplotlib.pyplot as plt
def main():
print("Generation numbers")
list_x, list_y = generatePoints()
writeFile(list_x, list_y)
draw_graph(list_x, list_y)
# noinspection PyPep8Naming
def writeFile(x, y):
f = open("graphic.txt", "w+")
for i in x:
f.write(str(i) + "==>" + str(y[i])... |
b63d9aa3e7de3242001900ebbbf3ea1da118d016 | pauvrepetit/leetcode | /165/main.py | 897 | 3.5 | 4 |
class Solution:
def compareVersion(self, version1: str, version2: str) -> int:
v1 = list(map(int, version1.split('.')))
v2 = list(map(int, version2.split('.')))
v1Len = len(v1)
v2Len = len(v2)
if v1Len > v2Len:
v2 += [0] * (v1Len - v2Len)
else:
... |
9c4c06554b2ca59ad39716b5cf5d9457697e122e | Dochko0/Python | /Python_Fundamentals/02_Python_Intro_Functions_Debugging/tasks/g_greater_two_values.py | 231 | 3.953125 | 4 | value_type = input()
val1 = input()
val2 = input()
def compare_values(a, b):
if a > b:
printable(a)
else:
printable(b)
def printable(greater_value):
print(greater_value)
compare_values(val1, val2)
|
a7085c14c1cc4fc284859602a601298453a515d5 | robertmccraith/Euler | /p51.py | 576 | 3.5625 | 4 | primes = [2,3]
def prime_under(x):
p = primes[-1]
while x > primes[-1]:
p += 2
if len(filter(lambda a: p%a == 0, primes)) == 0:
primes.append(p)
import itertools
from math import sqrt
# for x in itertools.count(10000001,2):
# print x
x = 56003
replacements = []
for i in ran... |
0f05f6453345424087a1c7db5bf6d4795730ed18 | BarryZM/dig-text-similarity-search | /dt_sim/data_reader/misc_io_funcs.py | 1,388 | 3.53125 | 4 | import os
import os.path as p
from pathlib import Path
from typing import Union
__all__ = ['check_unique', 'clear_dir']
def check_unique(test_path: Union[str, Path], count_mod: int = 0) -> str:
"""
Checks for path uniqueness.
Appends '_{count_mod}' to path (before file extension) if not unique.
Usef... |
80e32d7dcb64ad4a11a5a29fb4c4a1954e9440c4 | galibce003/Python-Functions-Files-and-Dictionaries | /txtFile_open_read_count_1.py | 1,051 | 3.734375 | 4 | x = open("C:/Users/Mehedi Hassan Galib/Desktop/Python/gf.txt","r")
y = x.read() #Read just return the strings
print(y[:5])
x = open("C:/Users/Mehedi Hassan Galib/Desktop/Python/gf.txt","r")
y = x.readlines() #readlines return a list
#each line will be the value of the list
print(y)
... |
80ec15ca3293091968a903e8a046ef8a775a9a29 | eddy0/algorithm | /python/array/345. Reverse Vowels of a String .py | 1,013 | 3.9375 | 4 | """
Write a function that takes a string as input and reverse only the vowels of a string.
Example 1:
Input: "hello"
Output: "holle"
Example 2:
Input: "leetcode"
Output: "leotcede"
Note:
The vowels does not include the letter "y".
"""
"""
思路:
反转元音字母,
先把 str 转为 list
利用 while 循环, 一个从前往后遍历, 一个从后往前遍历,
swap 指针, 如果不在数组... |
2d00330c91bbf4a8aaddea4530c83a9b0b4afa87 | iamsiva11/Codingbat-Solutions | /string1/combo_string.py | 544 | 4.125 | 4 | """
Given 2 strings, a and b, return a string of the form
short+long+short, with the shorter string on the outside
and the longer string on the inside.
The strings will not be the same length, but they may be empty (length 0).
"""
def combo_string(a, b):
short_str=""
long_str=""
if(len(a)<len(b)):
short_str=a
... |
907caf76266344cc2ca53cde8b3c5c97f2763c63 | fafusha/graph-turtle | /graph-turtle.py | 2,690 | 4 | 4 | from math import *
from turtle import *
# Creating an oriented graph graph type
class Graph:
# Initilizing infinite value
INF = 10**10
# Initilizing self
def __init__(self):
self.vertices = {}
self.vertices_count = 0
self.matrix = []
# Determening the ammount of vertic... |
80156da74b2b016c1835b498467d6991eb86f835 | xwzl/python | /python/src/com/python/learn/obj/PropertyDecorator.py | 1,847 | 4.21875 | 4 | # 既要保护类的封装特性,又要让开发者可以使用“对象.属性”的方式操作操作类属性,除了使用 property() 函数,Python 还提供了 @property 装饰器。
# 通过 @property 装饰器,可以直接通过方法名来访问方法,不需要在方法名后添加一对“()”小括号。
#
# @property 的语法格式如下:
#
# @property
# def 方法名(self)
# 代码块
#
# 而要想实现修改 area 属性的值,还需要为 area 属性添加 setter 方法,就需要用到 setter 装饰器,它的语法格式如下:
#
# @方法名.setter
# def 方法名(self... |
7160d6ee1994d460ff133eefb2dd5092836b39ef | nilestate15/PY101HW | /PY101/Week2/HW1/HW1wk2p4.py | 775 | 3.90625 | 4 | #Week 2 HW1
#Niles Tate
#Problem 4 (same as 3 but using with function)
def MK_choose(characters):
#Number of inputs
fighters = 2
#opens file and writes to it
with open(characters, "w") as o:
for i in range(fighters):
p1_choose = input("Please choose character")
#enters ... |
80bb6cf7326162a3f74b6d130d5b226472b0ce84 | shelkesagar29/Python-Quizes | /list_operations.py | 454 | 4.15625 | 4 | import sys
list1=[1,2,3,4,5,6,7,8,9]
list1.append(10)#adds new item to the end of the list
print(list1)
list1.insert(3,15)#insert new item at given index
print(list1)
print(list1.pop())#Removes and resturns last item in a list
print(list1)
print(list1.pop(2))#Removes and returns element at ith position
print(list1.sort... |
59b0ef34b763815b2180456fbaf64da7ccf92c53 | imperialself/adventofcode2020 | /day06/part2.py | 1,007 | 3.984375 | 4 | # Find the number of questions (letters) a group answered yes unanimously
# Return sum of all groups' unanimous letters
# https://adventofcode.com/2020/day/6
# Make each group of people into a list within the customs list
customs = []
for group in open('input').read().split('\n\n'):
customs.append(group.splitlines())... |
ac1f18e6e51788ad966110262cdac4a8aaa991cc | heoblitz/algorithm_study | /백준_알고리즘/10039.py | 122 | 3.78125 | 4 | sum = 0
for _ in range(5):
grade = int(input())
if grade < 40:
grade = 40
sum += grade
print(sum//5) |
7a9f02c4e16c01abf04f5a9f5caaecc2e9152d9d | rafaelperazzo/programacao-web | /moodledata/vpl_data/396/usersdata/294/80995/submittedfiles/av1_programa2.py | 652 | 3.703125 | 4 | # -*- coding: utf-8 -*-
#COMECE AQUI ABAIXO
n1= int(input('Digite o primeiro número: '))
n2= int(input('Digite o segundo número: '))
n3= int(input('Digite o terceiro número: '))
n4= int(input('Digite o quarto número: '))
n5= int(input('Digite o quinto número: '))
n6= int(input('Digite o sexto número: '))
s1= ... |
40e80221272b51112ef31de51aa5387287373b9e | Busc/Coding-Interviews | /01 算法和数据操作/11 旋转数组的最小数字.py | 1,128 | 3.59375 | 4 | # -*- coding:utf-8 -*-
class Solution:
def minNumberInRotateArray(self, rotateArray):
# write code here
left, right = 0, len(rotateArray)-1
# 考虑到数组本身就是有序的情况
mid = 0
while rotateArray[left] >= rotateArray[right]:
if right - left == 1:
return rotateA... |
48c060953fa9f09e82f10984d20550c454334c07 | ethrlrnr/python-misc | /anagrams.py | 2,348 | 4.125 | 4 | def are_anagrams(str1, str2):
str1dict = {}
str2dict = {}
for i in str1:
if ord(i) >= 97 and ord(i) <= 122 or (ord(i) >= 65 and ord(i) <= 90):
if i.lower() not in str1dict:
str1dict[i.lower()] = 0
str1dict[i.lower()] += 1
for i in str2:
if ord(i) >... |
44b0a0e3fa7b2005f15f7821260caaf10fe17c40 | kiponik/Python | /Lecture3/Task2.py | 595 | 3.609375 | 4 | def user_details(a, b, c, d, e):
print(
"Ваше имя: " + a + "Ваша фамилия: " + b + "Ваш год рождения: " + c + "Ваш email: " + d + "Ваш номер телефона: " + e, sep=' ')
name = input('Введите имя ')
surname = input('Введите фамилия ')
birth_date = input('Введите ваш год рождание ')
email = input('Введите почт... |
69da073d6ffd58d60a95270fe52721b8389be17a | kallemoen/python_projects | /word-counter/main.py | 1,457 | 4.03125 | 4 | # [ ] Open file and remove every special character
# [ ] Split words into a list
# [ ] Cycle through each word creating a dict for each word and counting every time a word is mentioned
# [ ] Cycle through values filtering out top 10 words
# Creates a list of lists from txt file
# traffic_file = open('article.txt', 'r... |
298da6e01025cc6bdda2efffffe7fe5399190141 | dheena18/python | /day11ex4.py | 242 | 4.0625 | 4 | numbers= [1, 2, 4, 5, 7, 8, 10, 11]
def filterOddNum(num):
if(num % 2) == 0:
return False
else:
return True
oddfilter = filter(filterOddNum, numbers)
print("The odd numbers in the list are: ", list(oddfilter)) |
ec84a42c6cd807e3fcaf08902e2cad9470607fbc | DunnyDon/FYP_PredictingHumanBehaviour_Using_CallDetailRecords | /SVM_CrossVal.py | 1,202 | 3.5 | 4 | import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import datasets
from sklearn import svm
import pandas as pd
from sklearn.model_selection import cross_val_score
dataframe = pd.read_csv("ML_Data.csv")
dataset = dataframe.values
# split into input (X) and output (Y) variables
#print d... |
fa0c0eb525bc5a5be09043d6b300a9aa7c42f724 | smirnown/MyPythonClasses | /data_structures/linked_lists/my_doubly_linked_list.py | 7,873 | 4.09375 | 4 | """This module contains my custom doubly linked list and double node classes."""
class MyDoubleNode:
"""
This is my attempt to code a node for use in doubly linked lists.
It contains pointers to both the next and previous nodes in the list.
"""
def __init__(
self,
value=0
... |
491b47b0192acf9119f026fbc80bf813ba8590ec | mansoniakki/PY | /If_the_else.py | 499 | 4.0625 | 4 | print("###############using if then else################")
age=17
if age > 17:
print("You can bye liquer")
else:
print("You can not buy liquer")
score=85
print('The grade was: ',end=' ')
if score < 60:
print('F')
elif 60 <= score <70:
print('D')
elif 70 <= score < 79:
print('C')
elif 80 <= score < ... |
b179eda7cd4a06582a88b2b9e53c8bf65ae2c5f9 | Kawser-nerd/CLCDSA | /Source Codes/AtCoder/abc035/D/4920287.py | 1,532 | 3.671875 | 4 | import heapq
class PriorityQueue:
def __init__(self):
self.__heap = []
self.__count = 0
def empty(self) -> bool:
return self.__count == 0
def dequeue(self):
if self.empty():
raise Exception('empty')
self.__count -= 1
return heapq... |
db0af2094e50c2e031355640e74f3cbec3628969 | Margarita-Sergienko/codewars-python | /6 kyu/Find the missing letter.py | 853 | 4.0625 | 4 | # 6 kyu
# Find the missing letter
# https://www.codewars.com/kata/5839edaa6754d6fec10000a2
# Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.
# You will always get an valid array. And it will be always exactly one letter be missing. Th... |
8fa30bb9c7873f2847341b8d64bb84987553a6a5 | Kaushty/Expense-Tracker | /operations.py | 1,031 | 3.59375 | 4 | from helper import getDateRangeFromWeek, getEntriesBetween
def getWeeklyData(startDate, endDate, rangedData):
weeklyData = getEntriesBetween(rangedData, startDate, endDate)
weeklyTotal = 0
print(f'Report from {startDate} to {endDate}')
for index, row in weeklyData.iterrows():
print(row['Date'], row['Name']... |
11b1176796dfb6a7bd908536ad822603cc36bfbe | Kontowicz/Daily-coding-problem | /day_065.py | 821 | 4.21875 | 4 | # Given a N by M matrix of numbers, print out the matrix in a clockwise spiral.
def clockwise(row, column, array):
k = 0; l = 0
while (k < row and l < column) :
for i in range(l, column) :
print(array[k][i])
k += 1
for i in range(k, row) :
... |
7db3556efc88cd3d511632383bf648e3a4aaecfc | talidemestre/open-source-home-speaker | /archive files/workinghowiwantbutwhy.py | 2,307 | 3.625 | 4 | import time
UserVoiceInput = "set an alarm for five thirty seven"#placeholder voice-interpreted text
UserVoiceInput = UserVoiceInput.lower()
VoiceArray = UserVoiceInput.split(" ")
hourList = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
minuteMono = ["ten", "elev... |
6a5ca44347b7e9f95d9afd2636104e258b6d0a57 | bacinger/AdventOfCode2018 | /day-11.py | 1,752 | 3.609375 | 4 | serial_number = 5791
"""
1. Find the fuel cell's rack ID, which is its X coordinate plus 10.
2. Begin with a power level of the rack ID times the Y coordinate.
3. Increase the power level by the value of the grid serial number (your puzzle input).
4. Set the power level to itself multiplied by the rack ID.
5. Keep onl... |
81651c66ce69a2c744f27ec502d5fae04b31eb4d | sam20596/programas--phyton | /ENCONTRAR VARIABLES EN UNA LISTA.py | 187 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 26 11:11:59 2020
@author: Xp
"""
lista=["R1","R2","R3","R4","S1","S2","S3"]
for i in lista:
if "S" in i:
print (i) |
ca719724a5f1bca78ab453588478d400d94187ac | ledovsky/instagram-analysis | /app/utils.py | 1,422 | 3.515625 | 4 | import csv
import requests
import json
def get_json(url, params=None):
'''
Wrapper around requests.get with custom header and json.loads
todo: error handling
'''
headers = {
'Cache-Control': 'no-cache',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/... |
e9fefb7907f53eb6f0eaada5550f3edc5e8adf52 | ClaudioCarvalhoo/you-can-accomplish-anything-with-just-enough-determination-and-a-little-bit-of-luck | /problems/LC333.py | 1,077 | 3.78125 | 4 | # O(n)
# n = numberOfNodes(root)
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def largestBSTSubtree(self, root: TreeNode) -> int:
res = [0]
... |
bdf03d00958c1e5710b4fb207e693be2c8f2089e | Linkstrange/n-queens | /n_queens_solver.py | 1,109 | 3.71875 | 4 | # A class that can solve the n queens problem given a specific board
class NQueensSolver:
def __init__(self, board):
self.solutions = []
self._board_size = board.get_size()
self._board = board
def solve_n_queens(self, col=0):
# If all queens are placed add 1 to the solutions a... |
170d287f7daa880f7a4e26553bf5cf840ac68f6c | iamGauravMehta/Hackerrank-Problem-Solving | /Algorithms/Strings/hackerrank-in-a-string.py | 430 | 3.640625 | 4 | # HackerRank in a String!
# Developer: Murillo Grubler
# Link: https://www.hackerrank.com/challenges/hackerrank-in-a-string/problem
q = int(input().strip())
for a0 in range(q):
word = ['h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k']
s = input().strip()
for i in range(len(s)):
if len(word) == 0:
... |
8d888023490587dc7a2cd754ded26adbe3b77d7b | hpf0532/algorithms_demo | /leetcode/141_环形链表.py | 2,103 | 3.90625 | 4 | # -*- coding:utf-8 -*-
# author: hpf
# create time: 2020/10/25 23:18
# file: 141_环形链表.py
# IDE: PyCharm
# 题目描述
# 给定一个链表,判断链表中是否有环。
#
# 如果链表中有某个节点,可以通过连续跟踪 next 指针再次到达,则链表中存在环。 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。注意:pos 不作为参数进行传递,仅仅是为了标识链表的实际情况。
#
# 如果链表中存在环,则返回 true 。 否则,返回 false 。... |
1352c2a411becf18eb0f1b1a1c64c7b328ab81b5 | MarekKarmelski/python-scripts | /arb_2_rom.py | 834 | 3.96875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Convert arabic number to roman number function."""
def arb_2_rom(arabic_number):
"""Convert arabic number to roman number function."""
roman_numerals = {
0: [1000, 'M'],
1: [900, 'CM'],
2: [500, 'D'],
3: [400, 'CD'],
4: ... |
33f7018c4a59997cbfddf0fe5059dc9e8ed27699 | sunpyopark/CoderByte-Python-Easy | /05-SimpleAdding.py | 462 | 3.59375 | 4 | '''
From CoderByte: "Using the Python language, have the function SimpleAdding(num)
add up all the numbers from 1 to num. For the test cases,
the parameter num will be any number from 1 to 1000."
'''
#1-Add up all the numbers from 1 through num (no more than 1000).
#Return - The result of the addition
def simple_addin... |
d4e05654b4b79aac510774b28f69a9e1f5f3a25e | kantegory/studying | /algorithms/lab3/bogosort/bogosort.py | 553 | 3.5625 | 4 | from random import *
from time import *
def correct_order(data):
count = 0
while count + 1 < len(data):
if data[count] > data[count + 1]:
return False
count += 1
return True
def bogosort(data):
while not correct_order(data):
shuffle(data) # randomize data
re... |
f63988293b9a7136ce94ea569fe2f8d037ee3224 | msznajder/allen_downey_think_python | /ch12.py | 5,337 | 4.59375 | 5 | ## Chapter 12 Tuples
## 12.1 Tuples are immutable
# A tuple is a sequence of values.
# The values can be any type, and they are indexed by integers, so in that respect tuples are a lot like lists.
# The important difference is that tuples are immutable.
t = 'a', 'b', 'c'
# Although it is not necessary, it is... |
8a222ba5145c8b7ec84ea01fa5e2e22971c8a49a | AliOssama/Code-Samples | /Coin heuristic.py | 650 | 4.09375 | 4 | #This program shows the efficiancy of a heuristic development
#This function inputs an array of coins values and the length of that array
def coinValue(coinsV, n):
#initially comparing the far left and right coins
num1=coinsV[0]
num2=coinsV[n-1]
#this will be our max profit
maxValue=0
... |
76eff488215bf09c94cb2e6939f07530dd84d3ec | LuisTavaresJr/cursoemvideo | /ex47.py | 183 | 3.921875 | 4 | print('Vamos mostrar na tela todos números pares entre 1 a 50!')
for c in range(0, 51):
if c % 2 == 0:
print(c, end=' ')
for c in range(0, 51, 2):
print(c, end=' ')
|
d49324055676a2756bbec94103360ef8e370d288 | gabriel-roque/python-study | /01. CursoEmVideo/Mundo 01/Aula 07 - Operadores Aritimeticos/Desafio09.py | 582 | 3.921875 | 4 | valor = int(input('De qual numero gostaria obter a tabuada: '))
print('-------------')
print('{} x 1 = {}'.format(valor,(valor*1)))
print('{} x 2 = {}'.format(valor,(valor*2)))
print('{} x 3 = {}'.format(valor,(valor*3)))
print('{} x 4 = {}'.format(valor,(valor*4)))
print('{} x 5 = {}'.format(valor,(valor*5)... |
d3154ee3ed0ee6e298aa15f5ef1e9a7435b59a51 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_199/2897.py | 2,508 | 3.640625 | 4 | def flip_shit(file):
input_list = file.readlines()
cases = int(input_list[0])
for i in range(1, cases + 1, 1):
pancake_row = input_list[i].split()[0]
size = int(input_list[i].split()[1])
print('Case #' + str(i) + ': ' + str(check_flips(pancake_row, size)))
def chec... |
604975b34d28c5915cffcc26899f90a98f76c876 | nithyaah16/KATTIS-PROBLEMS | /Sort_of_Sorting.py | 441 | 3.65625 | 4 | state = True
while state==True:
n=int(input())
dic={}
if n != 0:
for i in range(n):
x=input()
if x[0:2] not in dic:
dic[x[0:2]]=[]
dic[x[0:2]].append(x)
else:
dic[x[0:2]].append(x)
dic1=sorted(dic)
... |
bc76ad80a00172ae50b29d2cdcdc09a2eec9a724 | Gingertonic/python-for-rubyists | /oo/oo.py | 824 | 3.796875 | 4 | class Language:
_all = []
def __init__(self, name, eng_name):
self.name = name
self.in_english = eng_name
self.words = {}
self._save()
def _save(self):
self._all.append(self)
def add_word(self, english, translation):
self.words[english] = translatio... |
904dce6db4488af830518510042332f05f9bc3e3 | musram/python_progs | /practice/stack/test_stack.py | 749 | 3.6875 | 4 | from stack import *
def test_stack_push():
animals = Stack()
animals.push("CAT")
assert animals.top.value == "CAT"
animals.push("DOG")
assert animals.top.value == "DOG"
return animals
def test_stack_pop():
animals = test_stack_push()
assert animals.pop() == "DOG"
assert anima... |
ea3ab3f3ad8598072df9676ec58a3230a39989f8 | sashakrasnov/datacamp | /26-manipulating-time-series-data-in-python/1-working-with-time-series-in-pandas/01-your-first-time-series.py | 1,006 | 4.875 | 5 | '''
Your first time series
You have learned in the video how to create a sequence of dates using pd.date_range(). You have also seen that each date in the resulting pd.DatetimeIndex is a pd.Timestamp with various attributes that you can access to obtain information about the date.
Now, you'll create a week of data, i... |
2313efd48b20a624818369b8f9fe8c6bb9880570 | 2709-devansh/Number-Guessing-Game | /guessingGame.py | 1,480 | 4.15625 | 4 | import random
number = random.randint(1,9)
chances = 0
while chances < 5:
guess1 = int(input("Enter Your Guess:"))
if guess1 == number:
print("Outstanding, You guessed the number in the 1st Chance")
chances = chances + 1
break
else:
print("Oh! you missed but don't... |
7d65c12d474b5ca1432cc36e9ce52eeece5f1c55 | xKuroiUsagix/python-online-marathon | /sprint01/question03.py | 443 | 3.859375 | 4 | def isPalindromeNew(word: str) -> bool:
letters = set(word)
is_only_one = False
if len(word) % 2 == 0:
for i in letters:
if word.count(i) % 2 != 0:
return False
else:
for i in letters:
if word.count(i) % 2 != 0 and not is_only_one:
... |
94bf0a3465387cc987600b5fbbcf17b0ae069955 | BenTildark/sprockets-d | /DTEC501-Lab5-1/lab5-1-q5.py | 1,319 | 4.28125 | 4 | """
Write a program which asks the user to enter their first name and start and stop(end) values for the loop.
The start value can be greater than or less than the end value.
The program should display
Please enter your first name:
followed by
Hi <FirstName>, please enter the start value:
Thank you <FirstName>, p... |
a94d33802c84144e8ad72b8283e6f2c80d49e1a0 | nonas-hunter/warmup_project | /warmup_project/scripts/finite_state_machine.py | 9,314 | 3.53125 | 4 | #!/usr/bin/env python3
""" This code implements the finite state controller described in https://comprobo20.github.io/in-class/day05.
In this version we will use the ROS smach library
There are three states: moving forward, moving backward, and turning left. The initial state is moving_forward.
The rules ... |
fc872ec9dfaff8309d28fe326ea01ced8a4518d5 | vivekaxl/LexisNexis | /ExtractFeatures/Data/kracekumar/alphabet_soup.py | 766 | 4 | 4 | T = int(raw_input())
def count_hackercup(sentence):
len_of_sentence = len(sentence)
# Remove all the not required letters from the sentence
eligible_letters = ""
for char in sentence:
if char in "HACKERCUP":
eligible_letters += char
max_words = len(eligible_letters)/len("HACKERC... |
a8e369e9631e0237cd88141f80a9098d1717efaf | goateater/MyCode | /python_refresher/python_numbers.py | 308 | 4 | 4 | #!/usr/bin/env python
x = 1
y = 1.234
z = True
print(x)
print(y)
print(z)
x = 3
y = 8
sum = x + y
print(sum)
# Python 3
x = int(input("Enter x: "))
y = int(input("Enter y: "))
sum = x + y
print(sum)
# Python 2
x = int(raw_input("Enter x: "))
y = int(raw_input("Enter y: "))
sum = x + y
print(sum)
|
8731645e9f23d05d0adc162af36559111b41cb2a | NishanthMHegde/NumpyPractice | /MatrixMultiplication.py | 281 | 4.09375 | 4 | import numpy as np
#For matrix multiplication, the number of columns of first array must be equal to number of rows of second array
A = np.matrix([2,4,5,14,16,21]).reshape(2,3)
B = np.matrix([5,-10,15,24,31,-4]).reshape(3,2)
print(A)
print(B)
print(A*B)
print(np.matmul(A, B))
|
d6c4d5350ed627f8f4c5f5b16446d4ac0eeb8388 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2673/60898/317215.py | 228 | 3.671875 | 4 | t=eval(input())
x=eval(input())
if x==4:
y=eval(input())
if y==15:
print(7)
print(10)
else:
print(7)
print(1)
elif x==5:
print(6)
print(1)
elif x==6:
print(4)
print(2)
|
85a4859318af1484646e16a61c564baad5f77fe7 | milindmalkani1/keyValueDataStore | /main.py | 4,718 | 3.5 | 4 | import threading
import json
import os
import time
'''
search for a particular key in the file and converts the entire file
in a python dict obj, will also be use-full
during the reading of a particular key and checking if a key
is present inside the dictionary or not
'''
def searchKey(keyForSearching, givenPathS):
... |
0394aef6837b864a5adafdf239a6afe3fa5b7853 | santakung-07/CP3-Thanayos-Thongsrinuch | /assignment/Exercise5_1_Thanayos_T.py | 477 | 4.125 | 4 | # exercise 5_1 +, -, *, / เลข 2 จำนวนโดยยรับ input
print("Calculated 2 number\n","Results will be shown as +, -, *, / respectively")
firstNum = int(input("First number: "))
secondNum = int(input("Second number: "))
print(f"{firstNum} + {secondNum} = {firstNum+secondNum}")
print(f"{firstNum} - {secondNum} = {firstNum-se... |
fd88b03721658283a87f128bcdf782b9526afd9f | Chebroluntihin/pythontrng | /ifcond.py | 165 | 3.90625 | 4 | x=(int(input("Enter an integer")))
y=(int(input("Enter an integer")))
if(x>y):
sum=x+y
print(sum)
elif(x<y):
sub=x-y
print(sub)
else:
print("No") |
4c7572e0124f0ccddae590893ca97f81a82fbd45 | chiheblahouli/holbertonschool-higher_level_programming | /0x0A-python-inheritance/2-is_same_class.py | 216 | 3.796875 | 4 | #!/usr/bin/python3
"""
function that return true if object is exactly
"""
def is_same_class(obj, a_class):
"""return true if obj is the exact class a_class, otherwise false"""
return (type(obj) == a_class)
|
6d0702099e71e5065cc3a1bdfeb152995fccdc81 | loki2236/Python-Practice | /src/Ej2.py | 439 | 3.71875 | 4 | #
# Dada una terna de números naturales que representan al día, al mes y al año de una determinada fecha
# Informarla como un solo número natural de 8 dígitoscon la forma(AAAAMMDD).
#
dd = int(input("Ingrese el dia (2 digitos): "))
mm = int(input("Ingrese el mes (2 digitos): "))
yyyy = int(input("Ingrese e... |
aba3dae2e5040c814cbc961753594b28e5100826 | Jamaliela/Modules | /a06_genes_solved.py | 6,423 | 3.84375 | 4 | ######################################################################
# Author: Scott Heggen & Emily Lovell TODO: Change this to your names
# Username: heggens & lovelle TODO: Change this to your usernames
#
# Assignment: A06: It's in your Genes
#
# Purpose: Determine an amino acid sequence given an in... |
1689d15d28983b199d27b49a6b0ca346b148322c | ouoam/CE_Data-Structures | /02.Stack/lab3.py | 1,957 | 4 | 4 | class Stack:
maxSize = 4
def __init__(self):
self.item = []
def push(self, i):
if not self.isFull():
self.item.append(i)
return True
else:
return False
def size(self):
return len(self.item)
def isEmpty(self):
... |
5314782f3426695be56e9c0b7b15b94860aaeddc | shreeyamaharjan/AssignmentIII | /A_d.py | 927 | 4.15625 | 4 | def mergeSort(nums):
if n > 1:
mid = n // 2
left_list = nums[:mid]
right_list = nums[mid:]
mergeSort(left_list)
mergeSort(right_list)
i = j = k = 0
while i < len(left_list) and j < len(right_list):
if left_list[i] < right_list[j]:
... |
345343ab5066a28d1d5609ec9d7da58e3fd2d1c1 | okinawaa/Python_basic | /Python_basic/For_one_sentence.py | 431 | 4.03125 | 4 |
#example 1
# students = [5,6,7,8,9]
# print(type(students))
# students = [i+100 for i in students] < ---------
# print(students)
#example 2 :
# students = ["Iron man" , "Thor" , "I am Groot"]
# students = [len(i) for i in students] < ------------
# print(students)
... |
a90aac1fa5632b5f52782329180f88b4a37257d8 | liujigang82/ContainerNum | /textProcessing.py | 3,338 | 3.5625 | 4 | from utils import get_encode_code
global str
# calculate the confidence of the string to be container number. 4 letter + 7 digits
def str_confidence(input_str):
str_list = input_str.split(" ")
numbers = 0
words = 0
for item in str_list:
if len(item) == 4 and item[len(item)-1].lower() == "u":
... |
56b53c6b4461a62ce27db79f17b68a3c3c7fcc1e | bovenson/notes | /Coding/Algorithm/Code/LeetCode/Python/0000-0050/0018.py | 1,864 | 3.8125 | 4 | #!/bin/python3
# coding: utf-8
"""
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Note: The solution set must not contain duplicate quadruplets.
For example, given array S = [1, 0, -1, 0,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.