blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
04562b1ca1942217a9e5df26c80a7022644d892a | PankillerG/Public_Projects | /Programming/PycharmProjects/untitled/Python_Start/Contest9_I.py | 513 | 3.671875 | 4 | n = int(input())
localLanguages = set()
languagesAll = set()
language = set()
for i in range(n):
localLanguages.clear()
for j in range(int(input())):
localLanguages.add(input())
if i != 0:
language = language & localLanguages
else:
language = localLanguages
languagesAll |= lo... |
4cd848b8a681abe86b23db32a2d2a07489b67b0d | shanjiang1994/The_complete_guide_in_Python_for_DA-DS | /py_files/LeetCode.py | 1,220 | 3.6875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Two Sum
# In[21]:
# Question
# Check full description of question from LeetCode
nums = [2, 7, 11, 15]
target = 9
# In[22]:
# Brute Force ----- O(N^2)
for i in range(len(nums)):
for j in range(i+1,len(nums)):
if nums[i]+nums[j] == target:
print(... |
2c2eb5f9f9071046dab4fa73a16c21f4dd32847f | Qhapper/ML | /LeetCode/LeetCode_Python-master/LeetCode_Python-master/Algorithm-Easy/349_Intersection_of_Two_Arrays.py | 742 | 4.09375 | 4 | class Solution:
def intersection(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
if len(nums1) > len(nums2):
return self.intersection(nums2, nums1)
lookup = set()
for i in nums1:
loo... |
c7523c4f9e23b5574c5814b2877fb5105bf758a8 | Bishopbhaumik/python_test | /exp_3.py | 522 | 3.515625 | 4 | class Mobile:
def __init__(self,name):
self.name=name
class Mobilestore:
def __init__(self):
self.mobiles=[]
def add_mobi(self,new_mobi):
if isinstance(new_mobi,Mobile):
self.mobiles.append(new_mobi)
else:
raise TypeError("not of mobile class... |
63f8bc06fe191e10f9d503ddd6fb5fde7eddd3c1 | habibabdo/firstpython | /Errors.py | 338 | 3.796875 | 4 | a=5
b=0
try:
print('Resource opened')
print(a/b)
k=int(input('Enter A Number'))
print(k)
except ZeroDivisionError as e:
print('You Cannot devide by ZERO',e)
except ValueError as e:
print('Invalid input')
except Exception as e:
print('Some thing wrong ')
finally :
print('resources Closed'... |
50e5b1c9881f2e3b7490b513c36667f32fc4614c | Corxrew/SOLS.py | /algo/week4/points_and_segments.py | 1,183 | 3.703125 | 4 | # Uses python3
import collections
import sys
def fast_count_segments(starts, ends, points):
mapp = collections.defaultdict(set)
left_l, point_l, right_l = (1, 2, 3)
count = [0] * len(points)
pairs = []
for i in starts:
pairs.append((i, left_l))
for i in ends:
pairs.append((i, ri... |
a849783909e83c7beff79a83ce3a7aff297ba5fc | ciesielskiadam98/pp1 | /02-ControlStructures/ocena słowna.py | 185 | 3.59375 | 4 | x = int(input("Podaj ocene: "))
tablica = ['celujący', 'bardzo dobry', 'dobry', 'dostateczny', 'mierny', 'niedostateczny']
print("Ocena słownie: {}".format(tablica[len(tablica)-x])) |
b031407332c378c86e0f392ba622a89762e92fcb | pedr0diniz/cevpython | /PythonExercícios/ex096 - Função que calcula área.py | 399 | 4.21875 | 4 | # DESAFIO 096 - Faça um programa que tenha uma função área(), que receba as dimensões de um terreno retangular (LARGURA
#e COMPRIMENTO) e mostre a ÁREA DO TERRENO.
def área(a, b):
print(f"A área de um terreno de {a}m x {b}m é de {a*b}m².")
print('Controle de Terrenos')
print('--------------------')
l = float(inpu... |
79e64452eae897c4ee5c988b7a62cb627f0cd0bf | Arx247/Arnas-2332-oop-labs | /Lab 8/P4.py | 1,575 | 3.84375 | 4 | # Arnas Oonsadao, 633040233-2
"""
Lab 8 OOP (Part 2: Encapsulation, Inheritance, and Polymorphism) : Problem 4
"""
class ComEnStudent:
def __init__(self, name, courses):
self.name = name
self.courses = courses
def __str__(self):
#str(self.name) + " has taken these courses: " + str(self.... |
232755de8d654081bc9dc8fa2ff0eed59cd3d92b | shiran-valansi/problemSolving | /findTriplets.py | 1,760 | 3.765625 | 4 | import time
from collections import defaultdict
def findTheTriples(arr, queries):
"""
given an array of triplets queries
find how many occurrences of each query as a subsequence in the given array
example:
arr = [1,2,3,4,5]
queries = [[1,2,4], [2,4,3], [1,1,1]]
==> [1,0,0]
>>> findTheT... |
aa1ffb9ace4827a7e72f6e6742d7c17d1be58e70 | Heartbeatc/python3.6.6 | /dict/code/day005 ◊÷µ‰/06 修改和查询.py | 1,321 | 3.515625 | 4 | # dic = {"刘能": "王小利", "赵四": "刘晓光", "王木生": "范伟", "谢大脚": "于月仙", "李大国": "小鬼"}
# # dic['王木生'] = "刘伟"
# dic2 = {"刘能": "大阳哥", "赵四": "github", "王木生": "汪峰", "谢大脚": "冯提莫", "王大拿": "金老板"}
# dic.update(dic2)
# print(dic)
#
# # 查询
# dic = {'刘能': '大阳哥', '赵四': 'github', '王木生': '汪峰', '谢大脚': '冯提莫', '李大国': '小鬼', '王大拿': '金老板'}
# # 1. 最直观... |
32b9d791a88a4b2949bc055901462615ab820464 | webclinic017/crypto-exchange-api | /demo/quicksortdemo.py | 797 | 3.96875 | 4 | data =[23,23,12,98,34,36,9,22]
def quicksort(data,low,high):
print(data)
if low<high:
pivot=partition(data,low,high)
quicksort(data,low,pivot)
quicksort(data,pivot+1,high)
def partition(data,low,high ):
i=low-1
j=high+1
piot=data[low]
while True:
for count ... |
34a3cd35e9dbc02f253ab93c404c1556214193b6 | rengenin/algorithms | /sorting/list_flip.py | 245 | 3.65625 | 4 | def list_flip(list):
temp = []
for n in xrange(1, len(list)+1):
temp.append(list[len(list)-n])
flip = temp
return flip
a = [1, 2, 3, 4]
b = ['a', 'b', 'c', 'd']
a_flip = list_flip(a)
b_flip = list_flip(b)
print a, a_flip
print b, b_flip |
80aafaf5952a285ae87e12b40a7cf42d1ab5617b | zT-1337/BenderCommand | /BenderCommand/commands/commandline_only/ModeManCommand.py | 1,371 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
TODO
"""
from commands.Command import command
import keyboard #pylint: disable=E0401
FORWARD = 'w'
BACKWARD = 's'
LEFT = 'a'
RIGHT = 'd'
STOP = 'esc'
FORWARD_NEWLINE = 'w\n'
BACKWARD_NEWLINE = 's\n'
LEFT_NEWLINE = 'a\n'
RIGHT_NEWLINE = 'd\n'
FORWARD_BYTE = FORWARD_NEWLINE.encode("UTF-8")
... |
1833b6ebc8b02289f9b767b6639b6285bbd42a7d | prabhat-123/Customer-Churn-Prediction-Deployment-In-Flask | /predictor.py | 3,794 | 4.15625 | 4 | import numpy as np
import pandas as pd
# Importing the datasets
dataset = pd.read_csv("E:\machine learning project\customer_churn_prediction\dataset\Churn_Modelling.csv")
# Since RowNumber,CustomerId And Surname doesn't provide much information on predicting the customer churning behaviour in a bank
# So, we remov... |
c7874b12afde1f23bcdf0874b773cc772889a545 | LuisAlbertoZepedaHernandez/Mision_03 | /Trapecio.py | 1,577 | 3.9375 | 4 | #Autor: Luis Alberto Zepeda Hernandez, A01328616
#Descripcion: Escribe un programa que lea la base mayor, la base menor y la altura de un trapecio isósceles y que imprima: - Área. - Perímetro.
#Esta función se encarga de calcular el perimetro, llamando a otra función que calculó el lado del trapecio,
#y con es... |
1e1133aef125971dd47e892f3d718acb55d471c2 | aemeadow/01-Guessing | /main.py | 1,667 | 4.1875 | 4 | import sys, random
assert sys.version_info >= (3,7), "This script requires at least Python 3.7"
# number guessing game
secretNumber = random.randint (1,100)
numGuesses = 1
def numFact():
numFact = ["0! In tennis the word ‘love’ means a score of zero", "1! 1 is significant in fraud detection", "2! Only one prime... |
6ea52e2cf0ad435989adc5f584542a69e145086f | ddoynikov/python_lessons | /lesson.py | 167 | 3.78125 | 4 | a = int(input())
if a == 1:
print(0)
elif a % 2 != 0:
print('НЕТ')
else:
step = 0
while a != 1:
a = a / 2
step+=1
print(step)
|
2eb5c6dadeda0d312a464ab65d55b283c3452d2a | sipakhti/code-with-mosh-python | /Excersices/Excercise 1.py | 198 | 4.3125 | 4 | # Write program to display even numbers between 1 to 10
count = 0
for number in range(1, 10):
if number % 2 == 0:
print(number)
count += 1
print(f"We have {count} even numbers")
|
641c65e39fb210b8d7403b4562be7429e2444017 | bewakes/bewakes | /journal/helpers.py | 438 | 3.796875 | 4 | def xor_encrypt(string, password):
"""
Encrypt the string with password
"""
passlen = len(password)
chunks = [string[x:x+passlen] for x in range(0,len(string), passlen)]
xored = [xor_strings(password, x) for x in chunks]
return "".join(xored)
def xor_strings(s1, s2):
"""
xor two str... |
d839e997bb733f3075800884d4073fcb41d98270 | jvalansi/word2code | /word2code/res/translations/BlockTower.py | 1,941 | 3.9375 | 4 | from problem_utils import *
class BlockTower:
def getTallest(self, blockHeights):
input_array = blockHeights
# Josh loves playing with blocks.
# Currently, he has N blocks, labeled 0 through N-1.
# The heights of all blocks are positive integers.
# More precisely, for each i, the height of block i is block... |
5a97325dea58be9fb1735104dd94e269cc7d9b6a | rajdharmkar/Python2.7 | /loops/forloop2.py | 170 | 4.1875 | 4 | #for loop example using index
word = raw_input("Enter any string:")
j = 0
for i in word:
print 'The letter at index {} is {}'.format(j,i)
j +=1
|
82e706cf261384d9f8461a5232e463348bd3b541 | blue-sky-r/Advent-Of-Code | /2021/07/u07.py | 3,576 | 3.796875 | 4 | #!/usr/bin/env python3
__day__ = 7
__year__ = 2021
__motd__ = '--- Year %s -- Day %s ---' % (__year__, __day__)
__url__ = 'http://adventofcode.com/%s/day/%s' % (__year__, __day__)
verbose = 0
class Crabs:
def __init__(self):
pass
def init_pos_csv(self, line: str):
self.subs = list(map(... |
27c4a817f854b4e04e3e5503f4e4bff08dcf9ec5 | jedzej/tietopythontraining-basic | /students/piechowski_michal/lesson_06_dicts_tuples_sets_args_kwargs/frequency_analysis.py | 476 | 3.9375 | 4 | #!/usr/bin/env python3
def main():
n = int(input())
frequencies_dict = {}
for i in range(0, n):
for word in input().split():
frequencies_dict.setdefault(word, 0)
frequencies_dict[word] += 1
frequencies_list = list([-frequency, word]
for wor... |
866f8e23a7cd5887f3e5d0791f9435a921525536 | AaronYXZ/PyFullStack | /Package_And_Syntax/Advanced/OOP_static_class_methods.py | 1,061 | 3.65625 | 4 | class LotteryPlayer:
def __init__(self, name):
self.name = name
self.numbers = (5,9,12,3,1,21)
def total(self):
return sum(self.numbers)
class Student:
def __init__(self, name, school):
self.name = name
self.school = school
self.marks = []
def average(s... |
3652f9b2da34e392927fdbdab658e5827e5e6e0c | Divyapry/Python-Learning-Journey | /trans_n_swap.py | 400 | 4.0625 | 4 | import numpy as np
arr = np.arange(15).reshape(3,5)
print(arr)
print("\n 1. now printing the transpose of the arr ")
print(arr.T)
print("\n 1.1 using the transpose function")
print(arr.transpose())
print ("\n 2. dot product of arrT and arr")
print(np.dot(arr.T,arr))
# transpose() is better as for higher di... |
8bbfff8919ad3d2be84aa5db242013280f5a3e1f | GlassyYang/ComputerNetworkLab | /GBN/lib/lib.py | 542 | 3.515625 | 4 | def checksum(data):
if len(data) % 2:
data += b'\x00'
ans = 0
for i in range(0, len(data), 2):
temp = int.from_bytes(data[i:i+2], byteorder='big')
ans += temp
temp = ans >> 16
if temp != 0:
ans += temp
ans = ans ^ 0x10000
return ans
if __... |
a915fd06c04cea6fb265f9a8fa449bd8e26a844a | KPW10452025/PythonCodeRecipes | /p196_sys_exit02.py | 634 | 3.65625 | 4 | # python的程序有兩中退出方式:os._exit() sys.exit()
# sys.exit()會引發一個異常:SystemExit
# 如果這個異常沒有被捕獲,那麼python解釋器將會退出
# 如果有捕獲此異常的代碼,那麼這些代碼還是會執行
# 捕獲這個異常可以做一些額外的清理工作
# 0為正常退出,其他數值(1-127)為不正常,可拋異常事件供捕獲
import sys
try:
sys.exit(0)
except:
print("over")
finally:
print("finally over")
# over
# finally over
# 使用 sys.exit(0)... |
03b79761fe70d17a6d3bca0c0983e317ca5f5baf | Miguel-Bit-Debug/Curso-em-Video-Python | /ex047.py | 136 | 3.578125 | 4 | """for c in range(2, 50+1, 2):
print(c)"""
#codigo curso em video
for n in range(2, 51, 2):
print(n, end=' ')
print('Acabou') |
81c87c63abdcc847b022b01e6ada61881d6960d2 | Pulkit12dhingra/Python_and_the_Web | /Scripts/API/wikipedia/main.py | 2,015 | 3.546875 | 4 | import wikipedia as wiki
"""
author: Monil [https://www.github.com/MNISAR]
"""
def parse(content, esc):
"""
type(content) = str
"""
d = {}
for c in content.split(esc):
c = c.split(esc[::-1])
if len(c) == 1:
section = c[0]
content = ""
elif len(c) =... |
2a1019cb800ff25ac167fc14a4cef03702cba9f3 | wildwolf2018/python-maths | /Describing Data With Statistics/population_stats.py | 2,542 | 4.28125 | 4 | '''
Calculates the mean, median, variance and standard deviation
Plots the graph of population differences
'''
import csv
import matplotlib.pyplot as plt
#Calculates the mean
def find_mean(data, data_size):
total = sum(data)
mean = total / data_size
return mean
#Calculates the median
def find_median(data, data_... |
346bb65472ea7fb5861fa4fbbae5bf17822b5c01 | daidai21/Leetcode | /Algorithms/Python3.x/214-Shortest_Palindrome.py | 417 | 3.671875 | 4 | # Runtime: 764 ms, faster than 5.17% of Python3 online submissions for Shortest Palindrome.
# Memory Usage: 13 MB, less than 100.00% of Python3 online submissions for Shortest Palindrome.
class Solution:
def shortestPalindrome(self, s: str) -> str:
for idx in range(len(s), -1, -1):
tmp = s[... |
7ea4483a58b155c713a8b0baa1fea3aa357606bb | vitorvicente/LearningPython | /Control Flow/Functions.py | 817 | 3.9375 | 4 | def my_function():
print("Hello from a function")
return
def my_function_2(a):
print("Hello from a function", a)
return
def my_function_3(a="hello"):
print(a, "Hello from a function")
my_function()
my_function_2("hi")
my_function_3()
def my_function_4():
return 1
print(my_function_4())... |
9339dde64ad2f2adcb6cee6613bd3809b851fc06 | jake-albert/py-algs | /c16/c16p14.py | 4,028 | 3.8125 | 4 | from c16p13 import Line
# c16p14
# Best Line: Given a two-dimensional graph with points on it, find a line
# which passes the most number of points.
##############################################################################
# This brute-force approach examines every unique pair of points in the input
# list o... |
eaf268ea9bd53af3ff09c8c9456369063641257c | lightfor/python-learning | /randomExample.py | 300 | 3.796875 | 4 | import random
def compare_num(num1, num2):
if num1 > num2:
return 1
elif num1 == num2:
return 0
else:
return -1
number1 = random.randrange(1,9)
number2 = random.randrange(1,9)
print("num1=", number1)
print("num2=", number2)
print(compare_num(number1,number2))
|
e8065ee12b35001e439e5f1b20decd7f0ab95bbe | 1520773319/NO.2--Python- | /归并排序.py | 837 | 3.828125 | 4 | array=[]
def puts():
num=input()
if num.isdigit():
array.append(int(num))
puts()
def MergeSort(left,right):
result=[]
il=ir=0
while len(left)>il and len(right)>ir:
if left[il]<right[ir]:
result.append(int(left[il]))
il+=1
else:
res... |
5cde33c63d80d2a4a3e22a912eed5e053f96af91 | leonshting/python-mipt-ads | /immutablity101/queues.py | 2,237 | 3.625 | 4 | from immutablity101.stacks import ImmutableStack
class Queue:
def __init__(self):
self._storage = []
def enqueue(self, value):
self._storage.append(value)
def deque(self):
return self._storage.pop(0)
def empty(self):
return len(self._storage) == 0
class ImmutableQu... |
2125010394ed431aef037f61b82c0012b39e87a1 | fatedglory14/Computational-Physics | /poly_diff.py | 265 | 3.984375 | 4 | #Exercise 6.11 Compute the derivative of a polynomial
#Andrew Turner
def diff(p):
diff_poly = {}
for power, coeff in p.iteritems():
if power != 0:
diff_poly[power - 1] = power*coeff
return diff_poly
p = {0: -3, 3: 2, 5: -1}
print diff(p)
|
6fa1af52a4965d5b74ed3274a2b0f2e7aafe7192 | praveenpmin/Python | /inherit1.py | 715 | 4.34375 | 4 | # Python code to demonstrate how parent constructors
# are called.
# parent class
class Person( object ):
# __init__ is known as the constructor
def __init__(self, name, idnumber):
self.name = name
self.idnumber = idnumber
def display(self):
print(self.name)
print(self.idnumber)
#... |
4378ecb75e5badbe0cb896819705a5ac9660ff00 | sniperwlf/python-lines-and-basic-polygons | /polygono.py | 1,098 | 3.71875 | 4 | from graphics import *
from random import randint
def main():
win = GraphWin("Polygono", 400, 400)
win.setCoords(-10, -10, 10, 10)
# Prompt the User for 3 mouse clicks
message = Text(Point(0, 8), "Click en puntos para crear polygono")
message.draw(win)
r = randint(0, 255)
g = ... |
23a53dad847e40e9839d6f6eb4919fe58d2b8477 | Shashank979/Advent-Of-Code-Solutions | /AdventOfCode2019/Problem3/problem3_part1.py | 2,394 | 4 | 4 | #test_input_problem3.txt
'''
Step Process of How To solve :
1. Have Conversion for the wire paths and make list of coordinate tuples for both wires
2. Check all the points of 1st wire if they are in the list of coordinates of the second wire
3. If a point is in the list of coordinates of the other wire then add th... |
0e4ef97a73ca904cb4814c98a258f6efb23a88ab | resul360/Digital_time | /Digital_time.py | 712 | 3.703125 | 4 | #%%
"19/10/2020"
# Digital time with python
import sys
from tkinter import *
import time
def times():
current_time=time.strftime("%H:%M:%S")
clock.config(text=current_time)
clock.after(100,times) # times and delay
root=Tk()
root.geometry("150x120") # frame size
clock=Label(root,font=("times",20,"bold"),... |
3677342f57b94e02923a60654cad3fd541de8032 | HeeTop/algorithm | /LeetCode/problem/LongestCommonPrefix.py | 253 | 3.71875 | 4 | strs = ["abb","aaa","aaa"]
def longestCommonPrefix(strs):
zip_strs = zip(*strs)
res = ''
for item in zip_strs:
print(item)
if len(set(item)) > 1: break
res += item[0]
return res
print(longestCommonPrefix(strs)) |
19b38e90184769d126474a22364a73db5da3d635 | deborabr21/mycode | /listmethods/challenge.py | 373 | 4.03125 | 4 | #!/usr/bin/env python3
icecream= ["flavors", "salty"]
icecream.append(99)
name =input ("What is your name? ")
#F-STRING
print(f"{icecream[-1]} flavors and {name} chooses to be {icecream[-2]}.")
#MIX AND MATCH
print(icecream[2], icecream[0] + " and", name , "chooses to be ", icecream[1])
#PRINT OBJECTS
print(icecream... |
63a867b71408a52f2e44336730274995222e2e61 | descrip/competitive-programming | /ccc/sol/2006/s1.py | 517 | 3.53125 | 4 | p = [input(),input()]
poss = [[] for i in range(5)]
for i in range(5):
for j in range(2):
for k in range(2):
z = (p[0][2*i+j],p[1][2*i+k])
if z[0].islower() and z[1].islower():
poss[i].append(z[0])
else:
poss[i].append(z[0].upper())
x = int... |
e4258e780c7a165578c77cdf93bea8723630b653 | ZubierAbd/Abds-repository | /alarmclcok.py | 275 | 3.765625 | 4 | #this is a credit card validator
def fact (n):
total = 1
while n != 1:
total = total*n
n = n - 1
return total
#print(fact(5))
def fact2(n):
if n < 1:
return 1
else:
return n*fact2(n-1)
print(fact2(5)) |
e84274c1a7e38488d8a0ffdc4a0fb99c3541cce3 | foolchauhan/DataStructureAndAlgorithms | /LeetCode30DaysChallenge/Day_20_BSTFromPreOrder.py | 713 | 3.78125 | 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 bstFromPreorder(self, preorder: List[int]) -> TreeNode:
return self.buildTree(preorder, 0, len(preorder)-1)
def buildTree(self... |
1d44361ba4244cc798e094b8961503ec7b1fac90 | Cybersecurity-Labs/Cybrary-Intermediate-Python | /Module 1/file_store.py | 226 | 4 | 4 | #!/usr/bin/Python3
#takes an arbitrary input and stores it in a file
def main():
file_name = input(‘Filename: ‘)
f.open(file_name,’w’)
f.write(input(‘Insert data to store: ‘))
f.close()
return
main()
|
5a03f2291d7ee48726ce8ccb59c692a3ec563375 | LuisTarma/random-python-scripts | /equal sides on a array.py | 286 | 3.703125 | 4 | def find_even_index(arr):
for i in range(len(arr)):
t = arr[i]
arr.pop(i)
print(arr[:i:], arr[i::])
if suma(arr[i::]) == suma(arr[:i:]):
return i
arr.insert(i, t)
return -1
def suma(v):
s = 0
for i in v:
s+=i
return s
a = [1,2,3,4,3,2,1]
print(find_even_index(a)) |
416de7ac7be58b549038a17678432f7085809069 | srcmarcelo/Python-Studies | /PythonTest/ex007.py | 152 | 3.859375 | 4 | name = str(input('Who is there? '))
if name == 'Marcelo':
print('Only guys who have a big dick have that name.')
print("Welcome, {}.".format(name))
|
92e730a36142ca0e7aee4ae2084e75be488832e4 | mrityunjaykumar911/DSA | /Hackerrank/Data Structures/Arrays/Arrays - DS.py | 1,171 | 4.1875 | 4 | # coding=utf-8
"""
Created by mrityunjayk on 3/10/16.
Website: https://www.hackerrank.com/challenges/arrays-ds
-----------------------------------------------------------------
Problem Statement:
An array is a type of data structure that stores elements of the same type in a... |
699ee21afff43cbf0fb02db40a0365f9d585388f | Raakesh13/leetcode_solutions | /minPath.py | 1,630 | 3.671875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the minimumMoves function below.
def minimumMoves(n, grid, startX, startY, goalX, goalY):
count = 0
visited = []
def pathCount(n, grid, startX, startY, goalX, goalY, count, visited):
print(visited)
if sta... |
a84372c02e561b47529a76040885f0ec62be8085 | ykang/tools-for-data-science-course | /2021spring/2020311476/Linear Regression.py | 1,886 | 3.59375 | 4 | # -*- coding = utf-8 -*-
# 作者:汪成智
# 学号:2020311476
# 创建时间:2021/4/7 20:56
# 开发环境:PyCharm
#导入需要模块
import numpy as np
import math as m
import matplotlib.pyplot as plt
#导入数据
set=np.array([[825,3.5],[215,1.0],[1070,4.0],[550,2.0],[480,1.0],[920,3.0],[1350,4.5],[325,1.5],[670,3.0],[1215,5.0]])
#计算 y=ax+b... |
86f87739688e31e894195bcbccd4e16d8233be64 | xiaoye-hua/DataQuest_codes | /Code/Python foundation/python-programming-advanced/Lambda Functions-111.py | 2,392 | 4.0625 | 4 | ## 1. Introduction to String Manipulation ##
hello = "hello world"[0:5]
foo = "some string"
password = "password"
print(foo[5:11])
# Your code goes here
fifth = 'password'[4]
last_four = 'password'[-4:]
## 2. Omitting Starting or Ending Indices ##
hello = "hello world"[:5]
foo = "some string"
print(foo[5:])
my_... |
e5f558af42908b7fe8fee6b1df9388d0493b876e | Felipev98/Ejercicios | /Ejercicios__2/Ejercicio5.py | 336 | 3.890625 | 4 | #5) Ingresar 10 números mayores a 3 y menores a 8. Mostrar el valor ingresado en
#número y letras.
i = 0
while i != 10:
numeros = int(input('Ingrese un número: '))
if numeros > 3 and numeros < 8:
print(numeros)
else:
print('Número invalido, número tiene que ser mayor a 3 y menor a 8')
... |
8e536597df96ca5d600c1ce3034ad277704c3004 | icesx/IPython | /python-base/src/learn/mult-parm/mult-parm.py | 283 | 3.953125 | 4 | #!/bin/python
# coding=utf-8
'''
Created on 2014年5月17日
@author: i
'''
def method(a,b,*c):
print(a)
print(b)
print("length of c is: %d " % len(c))
for i in c:
print(i)
if __name__ == "__main__":
print("__main__")
method("a","b","c","d","e")
|
afe3143f5b1f9fe1038d0e26b09887f62d9b15f9 | saumyaagrahari123/loop | /q47odd ,even,natural,whole number..py | 470 | 4.21875 | 4 | # write a program to print the following using while loop.
#a-10 even number.
#b-10 odd number.
#c-10 natural number.
#d-10 whole number.
# i=1
# while (i<=10):
# if (i%2==0):
# print("%",i)
i=0
while i<=10:
if i%2==0:
print("even number",i)
if i%2!=0:
print("odd number",i)
if... |
36bf6e6759e22449775ce50dc79d10a59d8a3a59 | topunix/hackerrank | /Interview-Preparation-Kit/Arrays/minimum_swaps.py | 798 | 3.515625 | 4 | import os
# Complete the minimumSwaps function below.
def minimumSwaps(arr):
# Find the index and find if it's in the right place
min_swap = 0
been_relocated = {}
for idx,e in enumerate(arr):
correct = idx + 1
if correct != e:
if correct in been_relocated:
... |
048d9f0a49ad1e7b86b81ab9f7c8674221c33b74 | eurobsonrosa/curso-em-video-python | /ex013.py | 168 | 3.734375 | 4 | print('='*20+' CALCULO SALÁRIO '+'='*20)
salarioA = float(input('Salário atual R$'))
salarioN = salarioA*1.15
print('Salário com aumento R${:.2f}'.format(salarioN)) |
84adc689799f39fc4d7bbac663a27507ded92300 | valnezjr/algProject1 | /projectalg.py | 1,658 | 3.765625 | 4 | listaFilmes = []
filmesUser1 = []
filmesUser2 = []
recomendUser1 = []
recomendUser2 = []
for i in range(10):
listaFilmes.append(input('Digite um filme a ser analizado: '))
print('\n>>>>>USUÁRIO 1<<<<<\n')
for i in range(10):
print('Você já assistiu o filme {}?\n'.format(listaFilmes[i]))
answer = input('Re... |
4c40aa981ce8cd921c5e84bab5f6169bf53f603a | leehour/ProgramProblem | /剑指offer/包含min函数的栈.py | 762 | 3.734375 | 4 | # -*- coding:utf-8 -*-
class Solution:
def __init__(self):
self.stack1 = []
self.stack2 = []
def push(self, node):
# write code here
self.stack1.append(node)
if not self.stack2 or node < self.stack2[-1]:
self.stack2.append(node)
else:
self... |
5fee921356a0325a0f1e062e9691f9b12c1a627e | TheBlueChameleon/Py_Advanced_Exos | /X06/06-solutions.py | 5,318 | 4.25 | 4 | # Note that I only learned how to use pandas myself. I briefly skimmed the docs,
# defined the problem you find in the exercise sheet and went about solving it.
# The lecture notes were written thereafter, when I had a better grasp of the
# methods and functions offered by pandas.
# The below code works, but certainly ... |
b194965a4b0803b6e1bb8c2f9fa760d911ff654b | abbasidaniyal/auto-RSVP | /utils/event.py | 1,118 | 3.796875 | 4 | class Event:
"""
A class to store the details of a single event
Members:
group_name : Name of the group organising this event.
event_id : Unique identifier of this event.
rsvp_status : Status of user's RSVP
"""
def __init__(self, group_name, event_id, rsvp_status=False):
self.... |
be335d42d4082d8d3f9f3f6cafdf418a29e61c18 | zlldt/LintCode | /1546coin-problem.py | 428 | 3.65625 | 4 | class Solution:
"""
@param n: The guest paid
@param m: the price
@return: the sum of the number of banknotes
"""
def coinProblem(self, n, m):
# Write your code here
sum=0
value = n - m
changes = [100,50,20,10,5,2,1]
for change in changes:
if va... |
dde60d505f07212ccd34a7d2f51ebc404c5341cc | biabulinxi/Python-ML-DL | /Python/Day15/exercise3.py | 272 | 3.5 | 4 | # @Project:AID1810
# @Author:biabu
# @Date:18-11-21 下午6:30
# @File_name:exercise3.py
# @IDE:PyCharm
list1 = []
while True:
s = input("输入任意文字")
if s == "":
break
list1.append(s)
for j in enumerate(list1,1):
print("第%d行:%s" % j)
|
b86959a82173d5be97948e4e4d48a900f1033d26 | Addarsh/PythonPrograms | /SelectionSort/selsort.py | 403 | 4.15625 | 4 | #Implementation of selection sort
def swap(arr,i,j):
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
def selectionSort(arr):
for i in range(len(arr)-1):
minimum = arr[i]
pos = i
for j in range(i+1,len(arr)):
if arr[j] < minimum:
pos = j
minimum = arr[j]
if pos != i: swap(arr,pos,i)
if __name__ ... |
d74dcf9ea93fb77e63b2896f00b56501cfb2779a | Elevationacademy/python-class-and-home-flow-control-AliMasarweh | /deck.py | 1,554 | 3.84375 | 4 | import random
colorsToNumber = {'red': 0, 'blue': 1,
'green': 2, 'yellow': 3}
total_numbers = 10
total_colors = 4
class Card:
def __init__(self, number, color):
self.number = number
self.color = color
def __str__(self):
return f"[Number:{self.number}, Color: {self.... |
e0adbdb94fc7166263c40d11eaa4a984e9bf1079 | ajaybhatia/python-practical-2020 | /16-practical.py | 467 | 3.9375 | 4 | '''
Practical 16
Count number of persons of age above 60 and below 90.
'''
persons = [12, 5, 56, 87, 61, 90, 43, 81, 73, 79, 65, 69, 21, 25, 19]
# Method 1
count = 0
for age in persons:
if age > 60 and age < 90:
count += 1
print(f"Number of persons having age above 60 and below 90 are {count}")
# Metho... |
4a000d49c5a8e9a451538e1e517301f99c67346b | wyqdbbwl/Three-Legged-Human-Carring-Robot | /brain_test_a.py | 828 | 3.53125 | 4 | import re
def cc(ag): # casual conversation
i=''
while i!='x':
i=input('human: ')
ag.ex(i) # exchange ideas
class br:
def __init__(self):
self.m=[] # working memory
self.k={} # knowledge
self.s=0 # score
def ex(self,i): # exchange ideas
i=re.split('/(d+... |
bf697ba63579816dbb76f394ea1a9125df6b6496 | subashchandarA/Python-Lab-Pgms-GE8151- | /5.2.2 binary search_recursion_string.py | 603 | 4 | 4 | def binary_search(search,lt):
print(lt)
if(len(lt)==0):
return False
mid=len(lt) // 2
if(search==lt[mid]):
return True
elif(search<lt[mid]):
lt=lt[ :mid]
return binary_search(search,lt)
elif(search>lt[mid]):
lt=lt[mid+1:]
ret... |
a824915dfd1bcf53255911f3a821523ff3a9e5a7 | angeloasl/Python | /LICENSE.md/prova.py | 784 | 3.78125 | 4 | print("Bem Vindo!")
print("")
estoque = open("estoque.txt", "r+")
a = estoque.read(9);
print "Produto1:", a
b = estoque.read(3);
print "Valor1:", b
c = estoque.read(9);
print "Produto2:", c
d = estoque.read(3);
print "Valor2:", d
e = estoque.read(9);
print "Produto3:", e
f = estoque.read(3);
print "Valor3:", f
g = esto... |
a1abc70985b50e2c72904556207391fb3544c83e | blzzua/kopec-cs | /02-fib-cached.py | 272 | 3.5625 | 4 | from typing import Dict
fib_cache: Dict[int, int] = {0: 0, 1: 1}
def fib3(n: int) -> int:
if n not in fib_cache:
fib_cache[n] = fib3(n-1) + fib3(n-2)
return fib_cache[n]
if __name__ == '__main__':
for i in range(100,2566):
print(i, fib3(i))
|
8ef9552d900dc5825a4c34fad8ccc0a4badc5f0f | NhanGiaHuy/CP1404_Pactical | /Prac_01/menu.py | 595 | 4.125 | 4 | def main():
user_name = str(input("Enter Name: "))
print("(H)ello\n(G)oodbye\n(Q)uit\n")
user_choice = str(input("Please Enter Choice!\n"))
while user_choice.upper() != "H" and user_choice.upper() != "G" and user_choice != "Q":
print("invalid menu!")
user_choice = str(input("Please Enter... |
343335fa46e77746f76db0eac7f012b9710db824 | Searge/exercises-python | /modules/50-loops/20-reverse-string/index.py | 214 | 3.515625 | 4 | # BEGIN
def my_substr(string, length):
result_string = ''
index = 0
while index < length:
result_string = result_string + string[index]
index = index + 1
return result_string
# END
|
e682fca0759374bc26660bb103505feb9232d963 | Bristi97/JISAssasins | /Python15.py | 217 | 4.21875 | 4 | #Q15)Program to find the value of x^(y+z)
import math
x=int(input("Enter the value of x:"))
y=int(input("Enter the value of y:"))
z=int(input("Enter the value of z:"))
a=y+z
b=pow(x,a)
print("The value is",b)
|
531719837598f4870a558784a3d9127ceb6d8920 | liuzhipeng17/python3-cookbook | /简化数据结构的初始化.py | 848 | 3.796875 | 4 | #1 question:写了很多用作数据结构的类,不想写太多烦人的__init__函数
#2 solution:
import math
class Structure1:
_fields = []
def __init__(self, *args):
if len(args) != len(self._fields):
raise TypeError('Expected {} arguments'.format(len(self._fields)))
for name, value in zip(self... |
ec40f90e4891e2ffd2b54cacbfeb6ddebdbee059 | rmmcosta/Introduction-to-Computer-Science-and-Programming | /Lesson 19 - Biased random walks, Distributions/histogramTrial.py | 1,564 | 3.78125 | 4 | import sys
sys.path.insert(0, '/home/rmmcosta/Documents/Introduction to Computer Science and Programming/Lesson 17 - Computational Models: Random walk simulation/MySolution')
# print(sys.path)
from randomWalkSimulation import Drunk
import pylab
from specialDrunks import *
def drawDistribution(maxTime, numTrials):
... |
d7fc4b8fe60c42b577da0889ee8dcbe804a5410a | JoannaEbreso/PythonProgress | /Anagram.py | 318 | 4.125 | 4 | def check_if_anagrams(word1,word2):
firstSorted = sorted(word1)
secondSorted = sorted(word2)
if firstSorted == secondSorted:
print("{:s} and {:s} are Anagrams".format(word1,word2))
else:
print("{:s} and {:s} are not Anagrams".format(word1,word2))
check_if_anagrams('iceman','cinema') |
d241dc0417401a8b12bbed6a19f7a1bec20fb5a9 | AngelWings1997/Algorithm-and-Complexity | /Transform and Conquer/Red-Black Tree/red-black tree.py | 20,220 | 4.1875 | 4 | """
# -*- coding: utf-8 -*-
@author: Hongzhi Fu
"""
# implementation of red-black tree
# three operations: search, insert and remove
# the following properties must be satisfied for each insertion and deletion:
# 1. each node is either red or black
# 2. the root node must be black
# 3. All leaf nodes(NIL) are bl... |
0ce955d3ebd7f0c27a87ddef3ac24908750f36fd | lawun330/Python_Basics | /find shortest string.py | 221 | 4.15625 | 4 | #defining function, using it and putting arguments
#return and len() functions
def shorterString(x,y):
print('the shorter String -')
if len(x)<=len(y):
return x
else :
return y
|
d0cef4edc1a577eabe1ced65640d34f46f2706ba | omriz/coding_questions | /513.py | 863 | 4.09375 | 4 | #!/usr/bin/env python3
"""
Given a list of integers and a number K, return which contiguous elements of the list sum to K.
For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4], since 2 + 3 + 4 = 9.
"""
import typing
import sys
def find_cont_elements(l: typing.List[int], k: int) ->... |
7428ac13bb802e8a57f1e71e5a86cc4ccff8974a | Curso-de-Python/Clase10 | /ejercicioModulo.py | 1,890 | 4.1875 | 4 | '''
-----------------------------
EJERCICIO
Creando tu primer módulo
-----------------------------
Este código no es para ejecutarse, aquí encontrarás instrucciones que puedes copiar y pegar en un nuevo Repl para la creación de un módulo
-----------------------------
'''
# En main.py
import modulo
print(modulo.conta... |
39bc8612d47d50936060f2e2894f01ac058644c4 | h-kanazawa/introduction-to-algorithms | /src/binary_search_tree.py | 3,232 | 3.828125 | 4 | # -*- coding: utf-8 -*-
class X:
def __init__(self, key, value, left, right, parent):
self.k = key
self.v = value
self.l = left
self.r = right
self.p = parent
def stringify(self):
return 'k:{}, v:{}, l:{}, r:{}, p:{}'.format(
self.k, self.v, self.l ... |
10026c93f3d5d86991f0dffa7773d6a136d34c96 | wmemon/01_basic_python_assignment_msrit | /20.py | 384 | 3.875 | 4 | from collections import defaultdict
def get_day(num):
num = int ( num )
d = defaultdict ( lambda: "[!]Enter a value between 0 and 6 (both included)",
{0: 'Sunday', 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', 5: 'Friday',
6: 'Saturday'}
... |
6cd38a2397691978de719afd1ba8c5b32c9ef38d | sofiakn/pycoding | /ch01-basic/07sum.py | 218 | 3.96875 | 4 | firstNumber = int(input("what is the first number? "))
secondNumber = int(input("what is the second number? "))
result = (firstNumber + secondNumber)
print(f"The sum of {firstNumber} and {secondNumber} is {result}") |
65ef92d6854f741fff3a359388ca8137e68e1ae1 | Hijiri-Ituki/Challenge_question | /Challenge11_1.py | 227 | 3.84375 | 4 | #1
class Square:
square_list = []
def __init__(self,s):
self.side = s
self.square_list.append(self.side)
square = Square(3)
square = Square(23)
square = Square(54)
print(square.square_list)
|
2e87d470a1c83500fecc87175f1aa49a981e0ff7 | weiaicunzai/Python-Practice-on-Book-Effective-Python-59-Specific-Ways-to-Write-Better-Python | /Item29_Use_Plain_Attributes_Instead_of_Get_and_Set_Methods/property.py | 1,069 | 3.828125 | 4 |
class Old:
def __init__(self, value):
self._value = value
def set_value(self, value):
self._value = value
def get_value(self):
return self._value
old = Old(10)
old.get_value()
old.set_value(13)
# use plain attributes
class New:
def __init__(self, value):
self.valu... |
b609d18defb34b37120350105886fdc3e93ffde4 | shellyalmo/Python-Track---She-Codes | /Files/reverse/reversing_text.py | 363 | 4.09375 | 4 | """In this program I'm reading a text file, and writing a new file that contains each line reversed as well as each original line."""
with open('input.txt','r') as reader:
animals = reader.readlines()
with open('output.txt','w') as writer:
for animal in animals:
writer.write(animal[::-1])
for anim... |
8c274836024f1f8e498850c01decc9b416bf3470 | shaddyx/tiny_reobas | /lib/adc_map_generator/util.py | 244 | 3.609375 | 4 | import math
def distance(a, b):
return abs(a - b)
def find_approx_key(m: dict, value):
closest = list(m.keys())[0]
for k in m:
if distance(closest, value) > distance(k, value):
closest = k
return closest
|
ce96a1f21b2627b6f367afb11123b4708e955002 | DrewBryar/django_generator | /user_prompt.py | 826 | 3.890625 | 4 |
default= True
def start_prompt():
if default:
x = r"C:\Users\abrya\Desktop\Test"
return ('dummy', x, 'app_name')
proj_name = input("Please input Project Name: ")
app_name = input("Please input App Name: ")
proj_location = input("And finally, where would you like this project to be s... |
8449ddc12e72769232cadbb087534461da811b0f | TahirCanata/Class4-PythonModule-Week3 | /ReadNumbs.py | 996 | 3.8125 | 4 |
Liste3 = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen']
Liste2 = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', '']
Liste = ['', '', 'Tw... |
8af1788e5f052fb15d980777bc9f98c0598d2c68 | Iron-Rush/python_pycharm | /day1/listTest.py | 1,071 | 3.6875 | 4 | l = [1,2,4,5,9,9,11]
# 序列元素的下标从0开始
# tuple元素不可赋值
# 基本样式[下限:上限:步长]
print(l[1])
# 2
print(l[0:3:2])
# [1, 4]
print(l)
# [1, 2, 4, 5, 9, 9, 11]
# list元素是可以改变的
l[1] = 100
print(l)
# [1, 100, 4, 5, 9, 9, 11]
# insert在list指定位置插入项目
l.insert(1,"新来的")
print(l)
# [1, '新来的', 100, 4, 5, 9, 9, 11]
# append在List末尾添加一个项目
l.append(... |
2296faa34758cb0a89bf19a587aef4c60e0c10b4 | a-sabi/CP4 | /4.py | 344 | 3.984375 | 4 | years = int(input("Введите количество лет:"))
print("exhibits =", (years * 365 * 8 * 60) // 5)
exhibit = int(input("Введите количество экспонатов:"))
minutes = ((exhibit * 5))
days = (minutes // (8 * 60))
print("years =", (days // 365), "days=", days % 365,
"minutes =", minutes % (8 * 60))
|
9039e0b39635e4eb938a8cc3bd899f523579f3c9 | Pyabecedarian/PyLearning | /S07_用户输入和while循环/S7_02_continue关键字.py | 317 | 3.734375 | 4 | """
与 break 不同, continue关键字可返回至循环开头, 重新测试条件
输入 1 ~ 10 之间的偶数, 使用while循环
"""
current_num = 2
while current_num <= 10:
current_num += 1 # 忘记修改计数器将导致无限循环
if current_num % 2 != 0:
continue
print(current_num)
|
e31f42e5446c92c0ff5cdb09347f43b818253dc9 | CostGranda/Fundamentos_UN | /10-06.py | 136 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat May 7 20:33:12 2016
@author: coste
"""
lista = eval(input())
lista.reverse()
print(lista)
|
2772ac8ba67fe304f8ca8cd376074e7317eab656 | Matias-Gutierrez/practica-con-python | /1°Semestre/pruebas/notas.py | 301 | 3.75 | 4 | a = float(input("Introduzca la nota de la primera unidad: "))
b = float(input("Introduzca la nota de la segunda unidad: "))
c = float(input("Introduzca la nota de la tercera unidad: "))
d = float(input("Introduzca la nota de la cuarta unidad: "))
prom = ((a*0.15)+(b*0.15)+(c*0.2)+(d*0.2))
print(prom) |
b6698b4be637e30f227360a1d1b5df881cb12592 | RocketGeek42/HackerRank | /Python/Introduction/write_a_function.py | 1,559 | 4.5 | 4 | #!/usr/bin/env python
"""
====
Task
====
You are given the year, and you have to write a function to check if the year
is leap or not.
Note that you have to complete the function and remaining code is given as
template.
============
Input Format
============
Read y, the year that needs to be checked.
===========
Cons... |
45dabba6be7c9a473a85f606f750f4f8d0e6ae6e | tangwz/leetcode | /leetcode/python3/word-search.py | 1,044 | 3.5625 | 4 | #
# @lc app=leetcode id=79 lang=python
#
# [79] Word Search
#
class Solution(object):
def exist(self, board, word):
"""
:type board: List[List[str]]
:type word: str
:rtype: bool
"""
is_visited = [[False for _ in range(len(board[0]))] for _ in range(len(board))]
... |
455e8e1a7cbd97b3682496588e3881f58cce2d31 | shreshta2000/If-else_questions_ | /if_else/last_two_digits.py | 153 | 3.921875 | 4 | number=int(input("entre any any number "))
reminder=number%100
last_2_digits=number*0+reminder
if last_2_digits!=0:
print(last_2_digits)
else:
(number) |
1e0d12b5ec538f17b33389c8560aa492d8009bfa | matf-pp/PPI-materials | /01_python_script/1_36.py | 546 | 3.765625 | 4 | # JSON format
#
# Funkcije za rad sa JSON formatom se nalaze u modulu json
import json
ime = input("Unesite ime: ")
prezime = input("Unesite prezime: ")
godine = int(input("Unesite godine: "))
# json.dumps(objekat) vraca string koji sadrzi JSON reprezentaciju objekta x
print("\n-----JSON reprezentacija objekta-----\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.