blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e727b0f0a0416ba695b263ab9109342a894b1156
a123aaa/python_know
/Python知识清单/字符串(str)对齐.py
1,213
4.03125
4
arr='hello,Python' print(arr.center(20,'*')) #****hello,Python**** print(arr.ljust(20,'*')) #hello,Python******** print(arr.ljust(10)) #hello,Python print(arr.ljust(20)) #hello,Python 空格 print(arr.rjust(20,'*')) #********hello,Python print(arr.rj...
ab86ec527e8bf779159c384224dbe656f11a4345
nandha-batzzy/Python-Projects-and-Learning
/Code forces Simple probs/ep9_Petya and Strings.py
216
4.0625
4
strn1 = input("Enter the first string: ").lower() strn2 = input("Enter the second string: ").lower() if strn1 > strn2: print(1) elif strn1 < strn2: print(-1) elif strn1 == strn2: print(0)
67fd064339b61f06bff67050d28021f1bd69b567
TvylorMvde/Numeric_Matrix_Processor
/Numeric Matrix Processor/task/processor/processor.py
5,492
3.8125
4
import numpy as np class Matrix: def __init__(self, row, column): self.row = row self.column = column self.matrix = [] def create_matrix(self): for i in range(self.row): numbers = list(map(float, input().split())) self.matrix.append(numbers) @stati...
f83f048f2e826feb6f7b68d77983e1d4777b739b
rds504/AoC-2020
/solutions/day2.py
731
3.71875
4
import re from tools.general import load_input_list input_data = load_input_list("day2.txt") pattern = re.compile("^([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)$") valid_p1, valid_p2 = 0, 0 for i in input_data: m = pattern.match(i) if m: lower = int(m.group(1)) upper = int(m.group(2)) ...
59968a36318f933642a56ac1b633113c24ad5da1
Kimuda/Phillip_Python
/while_loops/14_compiled_while.py
630
4.03125
4
phrase1=input("enter a phrase ") phrase2=input("enter a phrase ") letter=input("enter a letter ") phraselength1=len(phrase1) phraselength2=len(phrase2) counter1=0 counter2=0 while phraselength1>=0: if phrase1[phraselength1-1]==letter: counter1=counter1+1 phraselength1=phraselength1-1 #print(counter1) ...
5d483761d4900248b6c1894feea768f7508c49d2
ryanloughlin25/interview-practice
/interview_cake/making_change/ryan/making_change.py
1,503
3.75
4
from itertools import islice from collections import defaultdict """ bother, I've implemented a function to return the set of combinations that sum to the amount. It should have just been a function to return the number of combinations. """ def making_change(amount, denominations): result = [] for index, deno...
e8ad205ed7bfac59827e24fd0bf65000025d4275
DanSGraham/code
/Other/Python/StockMarketProgram/timeConverter.py
2,162
3.96875
4
#A program to convert time to EST #By Daniel Graham import convertTimeToSeconds import time January = 31 February = 28 March = 31 April = 30 May = 31 June = 30 July = 31 August = 31 September = 30 October = 31 November = 30 December = 31 months_list = [January, February, March, April, May, June, Jul...
f552921c9f25d358ca20fe905858ae66815092ed
lichkingwulaa/Codewars
/5 kyu/5_kyu_Directions_Reduction.py
876
3.75
4
""" https://www.codewars.com/kata/directions-reduction/solutions/python """ def dirReduc(arr): i = 0 while True: if i + 1 - len(arr) >= 0: return arr if sorted([arr[i],arr[i+1]]) in [['NORTH', 'SOUTH'] , ['EAST', 'WEST']]: del arr[i] del arr[i] i = 0 else: i += 1 a = dirReduc(['EAST', 'NORTH', '...
903bce7d48f37f2341831c18b58e23c9dfedc02c
chc1129/introducing-python3
/chap10/timeCtrl.py
638
3.90625
4
import time now = time.time() print(now) print(time.ctime(now)) print(time.localtime(now)) print(time.gmtime(now)) tm = time.localtime(now) print(time.mktime(tm)) now = time.time() print(time.ctime(now)) fmt = "It's %A, %B %d, %Y, local time%I:%M:%S%p" t = time.localtime() print(t) print(time.strftime(fmt, t)) fr...
e8c39a3ad8896eeb5a26b1c2c471974c6a0b7d7c
Chevtastic/CS110
/input01.py
369
3.90625
4
import random colorlist = ['orange', 'red', 'blue', 'yellow', 'turqoise', 'black', 'white', 'green'] print("Hello there!") name = input("What is your name? ") print("Nice to meet you",name,"!") color = input("Here's a question for you...What is your favorite color? ") print(name, "your favorite color is", color) print(...
355e2e0b88d685bcd0ba0462f2b51c342e6784f2
R281295/Proyectos
/Python/Ahorcado/Ahorcado.py
1,827
3.890625
4
def pedirPalabra(): return input("Escribe tu palabra: ") def toAsteriscos(frase): asteriscos = "" for i in range(len(frase)): if frase[i] == " ": asteriscos += " " else: asteriscos += "*" return asteriscos def pedirLetra(): try: return input("Elige u...
c33ae19dd1c6a6c7a425e948698b2df0409e9429
Mahrjose/BRACU-CSE110
/Assignment 01/Problem 10.py
130
3.828125
4
user_input = int(input()) if not (user_input % 2 == 0) or not (user_input % 5 == 0): print(user_input) else: print("No")
433c430e15872d4f248021879c98f2891b04f493
llathrop/udacity-classprojects
/udacity-cs373/kalmanFilter.py
1,160
3.609375
4
#!/bin/python from mystatslib import * from math import * import random import itertools # Write a program that will iteratively update and # predict based on the location measurements # and inferred motions shown below. #Kalman Filter:- Measurement update step def kalmanUpdate(mean1, var1, mean2, var2): new_...
5f3705794701b138224f8af95ab96506aedcba4f
kelmory06/FR-2017-10-10--201554422---201554041-
/Cliente-Servidor-protocolo-HTTP.py
4,760
3.515625
4
# FR-2017-10-10--201554422---201554041- Cliente en el protocolo HTTP #!/usr/bin/python # Complete el codigo, en la seccion que dice COMPLETE de acuerdo al enunciado # dado en este enlace https://goo.gl/1uQqiB, item 'socket-http-client' # import socket import sys try: # esta estructura permite capturar comportamiento...
2273e97e1b7e653abb73412a11ec00bf86da130a
psymen145/LeetCodeSolutions
/965.univalued-binary-tree.py
1,075
4.03125
4
# 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 isUnivalTree(self, root: TreeNode) -> bool: # bfs -> queue if not root: retu...
91a5f389132a5453fc7a6a2696a521c39ca92adf
CodyDeepPlay/LeetCodePractice
/Q345_ReverseVowels.py
2,649
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 10 23:13:41 2021 @author: mingmingzhang 345. Reverse Vowels of a String Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases. Example 1: Input:...
b281fbd7a81dbfdab11ca5f23e7bfa72d0c956e6
vincentchen1/learnpython
/Chapter 8/pets.py
1,809
4.3125
4
#positional arguments match each argument in the function call with a parameter in the function definition #order matters in positional arguments def describe_pet(animal_type, pet_name): """Display information about a pet""" print(f"\nI have a {animal_type}.") print(f"My {animal_type}'s name is {pet_name.t...
86cfee87cfa73ede55783fb2035ab6d288ce1efb
breezekiller789/LeetCode
/378_Kth_Smallest_Element_In_A_Sorted_Matrix.py
764
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/ # 用binary search,先把matrix每一個element取出來放在Array裡,然後Sort Array, # 最後再用binary search就可以找到了。 matrix = [[1, 5, 9], [10, 11, 13], [12, 13, 15]] k = 5 # ==============Code Starts=============== Array = []...
dcf92a5f08d2936029e6578b9163213b56a277ff
s-m-kashani98/loopFinder
/Finder.py
688
3.84375
4
loop= [] def addToLoop(x): if loop[0] == x: return True loop.append(x) return False def makeStep(a,pos): temp = [] for i in a: if pos[1] == i[0]: temp.append(i) return temp def loopFinder(a,pos): step = makeStep(a,pos) for k in step: x = addToLoo...
add5efba749583c0fbef0ac6b62091002d206211
karankrw/Data-Structures-and-Algorithms
/Algorithms on Graphs/Week 1 - Decomposition 1/Reachability.py
777
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 20 22:08:34 2020 @author: karanwaghela """ def reach(adj, x, y): visited = [0] * len(adj) return explore(adj, x, y, visited) def explore(adj, x, y, visited): if x == y: return 1 visited[x] = 1 for i in range(len(adj[x]...
5161fac9a2b584dd2525bf75dd51d2e3d02926b5
oknashar/interview-preparation
/googlePY/OA/Maximum-Time.py
1,498
3.828125
4
''' ref: https://leetcode.com/discuss/interview-question/396769/ You are given a string that represents time in the format hh:mm. Some of the digits are blank (represented by ?). Fill in ? such that the time represented by this string is the maximum possible. Maximum time: 23:59, minimum time: 00:00. You can assume tha...
58e1a1395b0ef8642803d2bdaf45d6580c1dd5f2
katerina-ash/Python_tasks
/Вычисления/Разность времени.py
1,122
4.125
4
# Задача «Разность времени» # Условие # Даны значения двух моментов времени, принадлежащих одним и тем же суткам: # часы, минуты и секунды для каждого из моментов времени. Известно, # что второй момент времени наступил не раньше первого. Определите, # сколько секунд прошло между двумя моментами времени. # Программа на...
c917d9dc87548ceca8bfe1eda10ac9e45c006eda
ps-raghotham-rao/Learning-Python
/Python/linkedlist+bst.py
1,026
4.15625
4
# class Node: # def __init__(self,key): # self.left = None # self.right = None # self.value = key # # A function to insert a new node with the given key value # def insert(root,node): # if root is None: # root=node # else: # if root.value<node.value: # if root.right is None: # root.right=node # ...
41aa6d30cc7aecfb5f547354731cd59b2b50ea7f
ec0629/python-recipes
/002-truthiness.py
380
3.703125
4
# Data Science from Scratch by Joel Grus # all takes an iterable and returns True if all values are Truthy print(all([True, 1, []])) # False since [] is Falsy # any takes an iterable and returns True if any values are Truthy print(any([False, [], 1])) x = None # always return a number safe_x = x or 0 print(safe_x) ...
c6d6b199a9847579e7a6576828901157fcc7329c
anshu-pathak/python-basic
/Basic-Programs/add_two_num.py
261
3.9375
4
x = 10 y = 20 z = x + y print(z) # Performe the add operation on the bases of the user enter values. # Store input numbers num1 = input('Enter first number: ') num2 = input('Enter second number: ') # Add two numbers sum = float(num1) + float(num2) print(sum)
be485b7c3a1329d83141cdff21597f1db80c751f
c-eng/holbertonschool-higher_level_programming
/0x0F-python-object_relational_mapping/4-cities_by_state.py
600
3.53125
4
#!/usr/bin/python3 """lists all cities from the database hbtn_0e_4_usa """ if __name__ == "__main__": import MySQLdb from sys import argv db = MySQLdb.connect(user=argv[1], passwd=argv[2], host='localhost', port=3306, db=argv[3]) cursor = db.cursor() cursor.execute("SELECT ...
e6cf7abd7bf1b9cc74b32b4e5574c6c1c9921466
daniel-reich/turbo-robot
/EWZqYT4QGMYotfQTu_20.py
2,309
4.125
4
""" Tap code is a way to communicate messages via a series of taps (or knocks) for each letter in the message. Letters are arranged in a 5x5 _polybius square_ , with the letter "K" being moved to the space with "C". 1 2 3 4 5 1 A B C\K D E 2 F G H I J 3 L M N O P 4 Q R S ...
7e5579cd4bf62a8c5b5dcaa52dd86b2dc6236b9a
satfail/Python
/02_Fundamento/loops2.py
317
4.1875
4
coches = ["ok","ok","ok","ok","ok","ok","ok"] for estado in coches: if estado == "error": print("Se paro la linea de producción") break print(estado) else: print("Todos los coches estan bien") #En python podemos poner un else a un loop y si no encuentra #un break da la salida del else!
a563186d64ba9f92dc3f52dca156b90545e0f61b
dondon17/algorithm
/BOJ/2630.py
556
3.546875
4
import sys myinput = sys.stdin.readline n = int(myinput()) tree = [list(map(int, myinput().split())) for _ in range(n)] cnt = [0, 0] def quadTree(y, x, n): base = tree[y][x] flag = True for row in range(y, y+n): for col in range(x, x+n): if tree[row][col] != base: quad...
ebb812faa546ab844dbad77ab347e0e52f551396
mragankyadav/LeetCode_Solved
/sudokuSolver.py
1,615
3.75
4
class Solution(object): def solveSudoku(self, board): """ :type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead. """ for i in range(len(board)): board[i]=list(board[i]) self.solver(board) def solver(se...
694f64f6e0046a30f881fe86258d44c2988bcea3
dgurjar/monopoly_ai_simulator
/monopoly_ai_sim/auction.py
1,545
3.640625
4
from monopoly_ai_sim.board import RentIdx from random import shuffle class MonopolyAuctionItem: def __init__(self, name, item=None): self.name = name self.item = item class MonopolyAuction: def __init__(self, auction_item, players): self.auction_item = auction_item # You aren...
ef5547c1185c34cfdb497e814c3fb2b1a6963b9b
alankrit03/LeetCode_Solutions
/82. Remove Duplicates from Sorted List II.py
995
3.65625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def deleteDuplicates(self, head: ListNode) -> ListNode: if not head or not head.next: return head curr = None wh...
7decbc49788a3161cfb56fcc61a62a63bf84ec93
samwasden/data_python
/data_presenter.py
1,622
3.609375
4
import plotly.graph_objects as go file = open("CupcakeInvoices.csv") cupcakes = [] invoice_totals = [] all_invoices = 0 #variables I created to store data to be used for data visualization choc = [] van = [] straw = [] #Parsing through the csv file and saving the data I need for line in file: print(line) ...
7a2140c8a43584de078213b6c40ac3c922796bb9
atsushinee/leetcode
/leetcode/496. 下一个更大元素 I.py
2,252
4
4
""" 给定两个没有重复元素的数组 nums1 和 nums2 ,其中nums1 是 nums2 的子集。找到 nums1 中每个元素在 nums2 中的下一个比其大的值。 nums1 中数字 x 的下一个更大元素是指 x 在 nums2 中对应位置的右边的第一个比 x 大的元素。如果不存在,对应位置输出-1。 示例 1: 输入: nums1 = [4,1,2], nums2 = [1,3,4,2]. 输出: [-1,3,-1] 解释: 对于num1中的数字4,你无法在第二个数组中找到下一个更大的数字,因此输出 -1。 对于num1中的数字1,第二个数组中数字1右边的下一个较大数字是 3。 对于num1...
7219d65cbe2124e2e937a33aaaa722fa4e4ebc2e
ThomasZumsteg/project-euler
/problem_0133.py
1,005
3.515625
4
#!/usr/bin/python """http://projecteuler.net/problem=133""" from time import time from itertools import count from common import prime_generator from sys import stdout def main(): big_num = 100000 prime_sum = 2 + 3 + 5 for p in prime_generator(block=100100): if p <= 5: continue if p >= big_num: break stdout....
b1b5100e358850d7cbbb8f94bccc46c67a67ec7f
PerryP1/AdvanceDataAnalyticsBootcamp
/EmployeePay.py
330
3.6875
4
import sys print('Name is :', sys.argv[1]) print('Pay Rate :', sys.argv[2]) print('Hours :', sys.argv[3]) name = sys.argv[1] payrate = int(sys.argv[2]) hours = int (sys.argv[3]) if hours <= 40: pay = payrate *hours else: othours = hours - 40 pay = 40 * payrate + othours * 1.5 * payrate print ("Pay is "...
746f78352cb843912d13f9705c3eae17bbd708d6
olaborde/-Google-IT-Automation-with-Python
/Using Python To Interact With OS/coursera/week3/Basic Regular Expressions/wildcards.py
1,172
4.5625
5
import re ''' Character classes are written inside square brackets and let us list the characters we want to match inside of those brackets ''' print(re.search(r"[Pp]ython", "Python")) print(re.search(r"[a-z]way", "The end of the highway")) print(re.search(r"[a-z]way", "What a way to go")) print(re.search(r"cloud[a-...
f5d570b9404a5ddcf35749a9d7be20f8dd584105
CircuitLaunch/CoLab-Reachy
/software/Motor_Control_Scripts/Step1_Camera_Rasp_pi_wKeyBoardInput.py
1,483
3.59375
4
''' This is a code that runs on Rasp pi. What it does: Allowing the user to input keyboard commands and communicate them (say number 1 or 0) over I2C. Rasp Pi controls the Arduino ''' from picamera import PiCamera from time import sleep import sys from smbus2 import SMBus addr = 0x8 # bus address bus = SMBus(1) # in...
56963aaeb87c5b89e64a416d3b97d56cc572d7a5
gauravsonawane01/Exercises
/Decorator_ex.py
656
3.84375
4
""" Write different methods for addition,substraction,division,multiplication of number. Write decoratoe which will call above methods only id 1.Only 2 input values are allowed 2.Both inputs should be of type integer 3.Both input values are positive integer only """ def add(a,b): print(a+b) def substract(a,b): ...
40fd3314630da5c008da2d49e523cdb07aa13936
candilek/Python-Projeler
/Atm_makinesi.py
1,045
3.5625
4
print("""***************************** Atm Makinesine Hoşgeldiniz. İşlemler; 1-Bakiye Sorgulama 2-Para Yatırma 3- Para Çekme 4-Havale Programdan çıkmak için q'ya basın. *************************************** """) bakiye =1000 while True: işlem= input("işlemi seçiniz: ") if (işl...
9d570c03fd375880356ba9a630a368b81a74b72f
spettigrew/cs-module-practice1
/formatted_strings.py
323
4.0625
4
""" 1. Assign three different types of data to the three variables "a", "b", and "c". 2. Use a format string to inject the data from your three variables into the string. """ # Modify the code below to meet the requirements above. a = "Colette's Birthday!" b = 6 c = 9.30 print("Yay! It's %s Age: %d. Date: %.2f." % (a...
d6d67130cb8f1a33eeb73d7ddcfe6db371ae90cf
SparksFlyMe/python_learning
/forDemo.py
1,096
4.09375
4
# author: KaiZhang # date: 2021/8/3 22:16 for letter in 'Python': # 第一个实例 print("当前字母: %s" % letter) pass fruits = ['banana', 'apple', 'mango'] for fruit in fruits: # 第二个实例 print('当前水果: %s' % fruit) pass # 通过序列索引迭代 fruits = ['banana', 'apple', 'mango'] for index in range(len(fruits)): print('当前水果 : %s'...
3d1bdc750f809164a722d54ead0d0173b3801611
jagadeeshwithu/Data-Structures-and-Algos-Python
/BubbleSort.py
450
4.15625
4
""" Bubble Sort implementation Time complexity: O(n2) Space complexity: O(1) """ def BubbleSort(inputlist): n = len(inputlist) if n <= 1: return inputlist for i in range(n): for j in range(1, n): if inputlist[j-1] > inputlist[j]: inputlist[j-1], inputlist[j...
9c82f9823a05c17571af59c16f64f8cc6e6002ea
xavierwwj/socket_test
/non_daemon_thread.py
1,758
4.09375
4
""" - For non-daemon threads, the program will wait till these threads are done at the end of the program before exiting - Specifically, at the end of the program, there will be a call .join() for the non-daemon alive threads. - This is a blocking call that awaits completion of the thread. - If you look at the sou...
bf5e303b370032a71b6f4c3f5432241c16460d47
andyundso/python-exercises
/P05/1_3_Vangsted_Fixed.py
2,319
3.84375
4
############################## # P05 - 1.3 Battleship ############################## # Import import random import copy import sys ############################## # Definitionen def spielbrett_neu(): ''' Neues Spielbrett erzeugen ''' global board row = [" O"] * 10 for a in range(15): ...
22e3bfadd94fbdb53aab71f716e03af21ce226e1
InternalHell/Algorithms-Python
/selection_sort.py
343
3.90625
4
from random import * def selection_sort(list): for i in range(len(list)-1): for j in range(i+1, len(list)): if list[j] < list[i]: list[i], list[j] = list[j], list[i] return list list = [randint(1, 1000) for i in range(10)] print(f'Your start list: {list}\nSorting list: {s...
f1e19a700c57d73801ceb8bab0dec548836ae4ba
fuyangchang/Practice_Programming
/LearnPythonHardWay/ex40.py
848
3.78125
4
# -*- coding: utf-8 -*- class Song(object): def __init__(self, lyrics): self.lyrics = lyrics print type(self) def sing_me_a_song(self): for line in self.lyrics: print line def sing_me_twice(self): for line in self.lyrics: print line for line...
8e3c631b68e8816b5c0b96e25db2be44d10d3239
usman-tahir/rubyeuler
/add_first_n_odd_int.py
275
4.15625
4
#!/usr/bin/env python # add first n odd integers def add_odd_integers(n): def _add_odd_int(n,counter,next,acc): if counter == n: return acc else: return _add_odd_int(n,counter+1,next+2,acc+next) return _add_odd_int(n,0,1,0) print add_odd_integers(9)
18d749524baf7679be685eeb4db1e2d997bc2eaf
shodhak/bio-playground
/utils/partsort.py
4,025
3.71875
4
#!/bin/env python """ partial sort of a file. Useful when some columns are known to be sorted, but within a group defined by those column, some other columns are out of order. e.g., if you have a bed file and you know it's already sorted by (or even just grouped by) chromosome, you can sort by start, stop w...
91c4442cea28cfd49f8c86552d1148b8fa75aa12
raphamoral/Exercicicios_PythonBrazil_Mackenzie_PYTHONPRO
/Funções PythonBrasil/PythonBrasil Exercicio1duvida de def.py
219
3.90625
4
numero = int(input("Digite um numero")) def imprimir_triangulo_de_numeros(): lista = [numero] lista2 = lista * numero for r in lista2: listafinal = [r] * r return(listafinal) r += 1
7a3e8b9f62d89e21e01e6295ceff478fd52c706c
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/5. STRINGS/SEQUENCES & STRINGS.py
189
3.625
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 5 07:04:31 2017 @author: Sandbox999 """ filelist=list(range(2000,2020,2)) print(filelist) for item in filelist: print(item)
7a5f3f0bdcfa000aa2e14af12e738bb5d5d02834
Uthaeus/w3_python
/33.py
379
4.28125
4
# Write a Python program to sum of three given integers. However, if two values are equal sum will be zero. def sum_of_three(a, b, c): if a == b or a == c or b == c: result = 0 else: result = a + b + c return result print(sum_of_three(1, 2, 3)) print(sum_of_three(1, 2, 2)) print(sum_of_three(1, 1, 2)...
8ac4e83aeac45db150cecd711c54a8633cf5282f
tracymeng2000/PyMaze
/grid.py
2,356
3.59375
4
from cell import Cell from direction import Direction from random import randint class Grid: def __init__(self, rows, cols): self._rows = rows self._cols = cols self._grid = self.prepare_grid() self.configure_cells() @property def rows(self): return self._rows ...
43371076b595a042813d8545da4b24ba4a51556d
sfwarnock/python_programming
/chapter2/convert_exercises_2.4.py
469
4.4375
4
# convert.py # A program to convert Celsius temps to Fahrenheit # # Pseudocode: Input the temperature in degrees Celsius (call it c) # Calculate fahrenheit as (9/5) c + 32 # Print a table of Celsius temps and Fehrenhrit equivalents every 10 degrees from 0C to 100C. def main(): c = -10 for temp in ra...
e8bb981dcca99c926f98224830667e3572ebd716
Ilijaxyz/pythonPath
/rockpaperscissors.py
1,745
4.03125
4
from random import choice def endGame(): machine_choice = None print("Play again? Y/N") is_playing = input() if is_playing and is_playing.lower().startswith("y"): machine_choice = choice(["rock", "paper", "scissors"]) playGame(machine_choice) else: print("Thanks for playing...
3ebd80807b603749c5075e41c6974bf238831b70
kaysiz/kenorb
/scripts/python/Quartz/mouse.py
2,863
3.515625
4
#!/usr/bin/python # Script simulating mouse events in macOS. # See: https://stackoverflow.com/q/281133/55075 import sys from AppKit import NSEvent import Quartz class Mouse(): down = [Quartz.kCGEventLeftMouseDown, Quartz.kCGEventRightMouseDown, Quartz.kCGEventOtherMouseDown] up = [Quartz.kCGEventLeftMouseUp, Q...
6820cd52316dc5bca7f89c75c7e7a1a6972981dd
tioguil/LingProg
/-Primeira Entrega/Exercicio03 2018_08_28/atv12.py
1,154
4.09375
4
# 12. Uma fruteira está vendendo frutas com a seguinte tabela de # # preços: # # Até 5 Kg Acima de 5 Kg # # Morango R$ 2,50 por Kg R$ 2,20 por Kg # # Maçã R$ 1,80 por Kg R$ 1,50 por Kg # # Se o cliente comprar mais de 8 Kg em frutas ou o valor total da # # compra ultrapassar R$ 25,00, receberá ainda um desconto de 10%...
f25948c52fa6aef295232b8b7fa4ec49352cf245
jeffsouza01/PycharmProjects
/Ex027 - PrimeiroUltimoNome.py
453
4.03125
4
''' Exercício Python 027: Faça um programa que leia o nome completo de uma pessoa, mostrando em seguida o primeiro e o último nome separadamente. ''' nomec = str(input('Digite seu nome completo: ')).strip() print(f'Muito prazer em te conhecer, {nomec}!') nomeDividido = nomec.split() primeiroNome = nomeDividido[0] ulti...
ec6b9a741e1d3876d203aa89375ef03c6c1fc9ef
felipmarqs/exerciciospythonbrasil
/exercicios de tuplas_listas_dicionários/vogais.py
389
4.125
4
#Crie um programa que tenha uma tupla com várias palavras(não usar acentos). DEpois disso, você deve mostrar para cada palavra quais sao as suas vogais tupla = ('feijao','arroz','salada','batata','banana','brocolis','amora') for p in tupla: print(f"\n Na paralavra {p.upper()} temos ",end='') for letra in p: ...
93c4a0bb5627e5715dca951272209f4e66829645
asenal/loop2hash
/loop2hash.py
1,700
3.796875
4
#!/usr/bin/env python #-*- coding=utf-8 import sys,re import pprint #-------- a naive config parser def loop2hash(file,sep=None): # set config in param-list to enable config update. ''' Loop a config file, split each line into key & value. Usage: python $0 data/example.config A config file is merely a plain text ...
b2e4a5f95eaba181c8ab655615ee5c4c4e5d6234
jwoojun/CodingTest
/src/main/python/algo_expert/Implementation/문제선정하기.py
400
3.515625
4
def main(): num = int(input()) array = list(map(int, input().split())) array.sort() answer, nb = [], 0 while (nb<len(array)): if len(answer) == 0: answer.append(array[nb]) elif array[nb] > answer[-1]: answer.append(array[nb]) nb += 1 if len(a...
b0f04cd84bce02f40f3e5a9e41aca5098915b136
555Russich/geekbrains1
/venv/3rdless.py
3,556
4.03125
4
# Функции и работа с файлами # max(1, 2, 3) # print(max('zz', 'aaa', key=len)) # print(round(1.98754, 3)) # 3 знака после запятой for index, char in enumerate('qwerty', start=3): print(index, char) # def say_hello(name): # создаем функцию, которую можем вызывать в последствии # print('Hello', name) # say_hel...
92911484dcd4c512d2b9849fd3a92bf52e41063e
chriskang97/CS_412
/HW_3/HW_3.py
4,607
3.609375
4
import fileinput import operator import collections ## Step 1: Reading Information from File counter = 0 support = 0 unique_item = [] indiv_trans = [] miscellaneous = ['\n', ' '] for line in fileinput.input('input.txt'): ### Determine Min Support if counter == 0 : support = int(line) ### Transac...
698d08620beb3524016d50e70abcf27353978e81
alikhalilli/Algorithms
/.z/Sorting/SelectionSort.py
579
4.09375
4
""" @github: github.com/alikhalilli Time Complexity: O(n^2) Space Complexity: O(1) """ def swap(arr, i1, i2): temp = arr[i2] arr[i2] = arr[i1] arr[i1] = temp def selectionSort(arr, asc=False): n = len(arr) for i in range(n): best_index = i for j in range(i, n): if as...
447f470d5d2babb1c3dd0c8d0ebbfe987556086f
nana-agyeman1/Global-code-py-2k19
/global.py
461
4.125
4
#converting 32deg to radians import math import datetime #degree = 32 #radian = degree*(math.pi/180) #print(radian) # Calculating surface area and Volume of a sphere #radian = float(input('Radius of sphere: ')) #surface_area = 4 * math.pi * radian **2 #volume = (4/3) * (math.pi * radian **3) #print("Surface Area is: ...
497ecd45f4d18e84ac5fd2c07e609abc898af6d7
jossy254-git/OOP2_PROJECTS
/functions.py
505
3.640625
4
def courses(*args): for subject in args: print(subject) courses("big data","CCNA", "OOP2") #keyword arguements def courses(**kwargs): for key,value in kwargs.items(): print("{}:{}".format(key, value)) #overriding arguements def kenya(county = "mombasa"): print("i am from " + county) kenya() kenya("Na...
c750bd682dd5579ce9520204b6c646e5afb207b1
jekuszynski/bch5884jek
/assignments/python_scripts/.ipynb_checkpoints/convert_F_to_K-checkpoint.py
256
3.8125
4
#!/usr/bin/env python3 #https://github.com/jekuszynski/bch5884jek/tree/master/assignments # -*- coding: utf-8 -*- print("What is the temperature in \u2109 ?:") t = input() c = round(((int(t)-32)*(5/9))+273.15,3) print("The temperature in K is: " + str(c))
c8e3fb1cecc1bb30e70def3aa24c8d9ca8f86fbb
alex-code4okc/advent_of_code_2019
/Day_1/day_1_solution.py
608
3.703125
4
import math def fuel_requirement_by_mass(mass): calculation = math.floor((mass/3))-2 return calculation def recursive_fuel_requirement_by_mass(mass): fuel = int(math.floor((mass/3)))-2 print(fuel) if(fuel>=0): return fuel+recursive_fuel_requirement_by_mass(fuel) else: retu...
a73ae83e0703d946a73c7fc2ecf3910f0bc30dd4
priyankamadhwal/Python-Practice
/hackerrank/Collections.OrderedDict().py
322
3.6875
4
from collections import OrderedDict N = int(input()) allItems = OrderedDict() for _ in range(N): curr = input().split() item, price = " ".join(curr[:len(curr)-1]), int(curr[len(curr)-1]) if item in allItems : allItems[item] += price else: allItems[item] = price for x in allItems: print(x,allItems[x]...
84c82087e2610b961f9350b69cad523ff3f3e67a
lovroselic/Coursera
/Capstone/Week2/UniversalString.py
1,258
3.734375
4
#python3 ''' this problem is quite similar to problem 2. use 3 mers as example. 000=0, 001=1 ..., 111=7. to build graph, simply connect number to number*2%8 and number*2%8+1. for example vertex 6 (110) is conect to 6*2%8=4 (100) and 6*2%8+1=5 (101). after this the problem is exactly this sample as problem two. whe...
cd4345f971a9b54a0a77089f1b770a2a24d31e72
HaroldCCS/python
/python/platzi/1_Basico/adivina_el_numero.py
459
3.765625
4
import random def run(): adivina = random.randint(1, 100) encontrado = True preguntar = 0 print('Ingresa un numero mayor a 0: ') while adivina == preguntar: if adivina > preguntar: preguntar = int(input('Ingresa un numero mayor: ')) else: preguntar = int(inp...
13491d5c79907a2585d010970b3692e459c4dc3a
iisdd/Courses
/python_fishc/20.0.py
498
3.96875
4
''' 0. 请用已学过的知识编写程序,统计下边这个长字符串中各个字符出现的次数 并找到小甲鱼送给大家的一句话。 (由于我们还没有学习到文件读取方法,大家下载后拷贝过去即可) 请下载字符串文件: string1.zip (55.49 KB, 下载次数: 23394) ''' str1 = '' with open ('string1.txt') as s: for each in s: str1 += each for each in str1: if each.isalpha(): print(each , end ='')
0853bc577366ae4f7c69aed6b906cb4b19ae2749
nimerritt/programming_practice
/chp4/depths.py
765
4.15625
4
""" Question 4.3 from Cracking the Coding Interview 6th Edition List of Depths: Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth (e.g., if you have a tree with depth 0, you'll have 0 linked lists). """ import trees def depths(root, depth_lists, depth): # invari...
f5626b39e4d5dd6240a455e9c80ba76838d183b2
borntoburnyo/AlgorithmInPython
/medium/1663_smallest_string_with_a_given_numeric_value.py
1,039
3.5
4
from collections import deque class Solution: def getSmallestString(self, n, k): i = 0 # Need a deque container, since we need to construct the string from end backward dek = deque() while i < n: if k - 26 > n - i - 1: # If K is larger than 26, the remaining can at leas...
0137e9bd89943a006c58e3a57a293ff8b739c499
polyglotm/coding-dojo
/coding-challange/leetcode/easy/~2021-10-08/1725-number-of-rectangles-that-can-form-the-largest-square/1725-number-of-rectangles-that-can-form-the-largest-square.py
928
3.96875
4
""" 1725-number-of-rectangles-that-can-form-the-largest-square leetcode/easy/1725. Number Of Rectangles That Can Form The Largest Square URL: https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/ """ from typing import List class Solution: def countGoodRectangles(self, rectangles: L...
896dc4631cc3002ba5d8852fda4b3548c981248a
Valentin-Rault/tic-tac-toe
/tic-pygame/main.py
1,168
3.59375
4
import pygame from tic_tac_toe.constants import WIDTH, HEIGHT, SQUARE_SIZE, SQUARE_PADDING, \ BOARD_PADDING_TOP, BOARD_PADDING_LEFT, RED from tic_tac_toe.game import Game from minimax.algorithm import minimax FPS = 60 WIN = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_...
4d9f2846696cc7fe51568b1fcf02fab86e6bd5d7
pilihaotian/pythonlearning
/leehao/learn120.py
245
3.78125
4
# 测试 def test1(x): x = x + x # add return new print(x) def test2(x): x += x # iadd return self print(x) a1 = [100] test1(a1) # [100, 100] print(a1) # [100] a2 = [100] test2(a2) # [100, 100] print(a2) # [100, 100]
f6074927e190d596658ae5ce00253a84ef620dea
Pereirics/Exercicios_Curso_Python
/ex045.py
1,336
3.859375
4
import random print('Bem-vindo ao jogo do "Pedra, Papel e Tesoura"!') user = str(input('Escolha qual você quer jogar: ')).strip().lower() cpu = random.choice(['pedra','papel','tesoura']) if user == 'papel' and cpu == 'papel': print(f'O CPU escolheu {cpu}!') print('É um EMPATE!') elif user == 'papel' and cpu ...
22baea23fcb40cf4c07a08b094cd970229d4b4a5
rpereira91/AI
/N_Queens/nqueens_heuristic.py
6,394
3.828125
4
#Name: Ralph Pereira #Desc: A huristic search that uses two different 2-D array's, one to store the queens and one to store the values. # The values are calculated after each move of the queen, the queens are initally placed randomly. # Each move is is done by the row, a loop itrates through the array an...
f606afb3b70cd6ff98b9b0c18e2f1c31f8345e90
MiroVatov/Python-SoftUni
/Python Advanced 2021/TUPLES AND SETS/Exercises 03. Periodic Table.py
286
3.703125
4
num = int(input()) unique_elements = set() for _ in range(num): element = input().split() if len(element) > 1: for el in element: unique_elements.add(el) else: unique_elements.add(''.join(element)) print('\n'.join(unique_elements))
d636049961df1094866c0c350510a18c3d12623d
ankovachev/SoftUni
/PythonADV/01_lists_as_stacks_and_queues__lab/10_cups_and_bottles.py
1,314
3.65625
4
import sys from collections import deque from io import StringIO input1 = """4 2 10 5 3 15 15 11 6 """ input2 = """1 5 28 1 4 3 18 1 9 30 4 5 """ input3 = """10 20 30 40 50 20 11 """ sys.stdin = StringIO(input1) cups = deque() bottles = deque() cups_input = input().split() bottles_input = input().split() is_filled_a...
9eaaced9444abb393e1ccc3b1cfbb5eb45859ec0
manemarron/mate-computacional
/alumnos/manemarron/proyecto/Robot-Simulation/modules/utils.py
704
3.640625
4
# -*- coding: utf8 -*- import numpy as np def rk4(f, y, t, dt): """ Integrates an ordinary differential equation using the order 4 Runge-Kutta method :param f: function Function to be integrated :param y: array Array containing previous state :param t: float Number represen...
fc5e70fb3365ff653e01036da0681f7853d56078
deepikaasharma/removing-items-from-a-list
/main.py
456
4.125
4
"""Use .remove() to remove an item from a list""" # fruit_list = ['apple', 'pear', 'peach', 'mango', 'pear'] # fruit_list.remove('pear') # print(fruit_list) """Use del to remove index of an element""" num_list = list(range(0, 9)) # remove the last element in the list del num_list[-1] print(num_list) # remove th...
bc5a8de9ccf420d055ddb5a1c4bd4875e73ffcf6
ppli2015/leetcode
/1 Two Sum.py
1,269
3.6875
4
# -*-coding:cp936-*- __author__ = 'lpp' # 使用哈希表 # 避免同一个数字 3+3=6 # 可以扫描一次就完成 class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i in range(len(nums)): if (target - nums[i]) in nums...
5b96fc21f893b2a29ddf084bd877b3d07711bdce
nasserso/materias
/MC102/lista susy/lab04.py
988
3.84375
4
''' O programa recebe 4 valores que representam pesos e tenta encontrar equilíbrio em uma balança com os mesmos. O programa mostra "sim" caso o equilíbrio possa ser feito, e "nao" caso contrário. ''' #Verifica todas as permutações de pesos def temPermutacaoValida(peso): permutacaoEhValida = False for...
db861c6ded96b69a69b2a232cd574d9f4bde58b7
Akagi201/learning-python
/cmd/argparse2.py
187
3.65625
4
import argparse parser = argparse.ArgumentParser() parser.add_argument("square", help="display a square of a given number", type=int) args = parser.parse_args() print(args.square ** 2)
703bef5d5d5ac9b9eff50fdcfef3b247c0a2b6c1
rkandekar/python
/DurgaSir/sa_filter.py
157
3.5625
4
l=[1,2,3,4] def funDouble(x): if(x%2==0): return x l2=list(filter(funDouble,l)) print(l2) l3=list(filter(lambda x:x%2==0,l)) print(l3)
633afccd23dde6ef6071dab950e57d15141dda59
yl29/pe
/q0001.py
226
3.703125
4
from time import * def p1(num): sum = 0 for i in range(1,num): if i % 3 == 0 or i % 5 == 0: sum += i return sum start = clock() print p1(1000) print clock() - start, "seconds" #print p1(1000)
68e0493c293a4e40cdd976662c85c229f0ea13d4
q13245632/CodeWars
/Reverse polish notation calculator.py
1,716
3.859375
4
# -*- coding:utf-8 -*- # author: yushan # date: 2017-03-23 def calc(expr): if not expr:return 0 lst = expr.split(" ") stack = [] for i in lst: if i.isdigit(): stack.append(int(i)) if "." in i: stack.append(float(i)) if i == "+": a = stack[-1]...
2d4d888fa7a6a4c32722bc79ca180496d1c983ee
jzendejas/Random-Wiki-Article-Browser
/test_loop.pyw
124
3.78125
4
#!/usr/bin/env python3 ask = 'n' while ask == 'n': print("looping") ask = input("y/n").lower() print("exited loop")
4d52cc9953e13fa75a2b2fe2b62c02143100aba3
lrw3716740/study
/dailyTest/day07List.py
107
3.53125
4
l=[1,2,3,4,5] #print max(l) #print min(l) del(l[1]) print l l.insert(2,23) print l l.sort() print l
51dc0b4396bb3eab965a4daa17edb46cc03542df
fatihsencer/algohack21
/soru2/2.py
527
3.5
4
op_file = open('toplamlar.txt','w') def digits(nb1): total = 0 while nb1 > 0: total += nb1 % 10 nb1 = int(nb1 / 10) return total with open('sayilar.txt','r') as file: line = file.readline() while line: number = digits(int(line.strip())) op_fil...
eab1c8b55e235eb2b04fe664335a0796d6a43a55
sowmya8900/Python-Practice
/Class_vs_Instance.py
903
3.796875
4
class Person: def __init__(self,age): # checking if the age is negative or positive if (age < 0): self.age = 0 print("Age is not valid, setting age to 0.") else: self.age = age def amIOld(self): # Printing the statement depending upon the age ...
c01a2be57546c095fa91ce7f288fb4e86a4a87fa
abdulwahid211/Project-Euler-in-Python
/SolutionForProblem_1.py
335
4.21875
4
# # Multiples of 3 and 5 # Problem 1 # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # # Find the sum of all the multiples of 3 or 5 below 1000. num = 1000 sum = 0 for x in range(0, num): if x%3==0 or x%5==0: sum = sum ...
d4441a0180cf145c0f7bb72a6487aa4979fc81e2
Sujankhyaju/IW_pythonAssignment3
/data structure and algorithm problem/2.py
344
4.03125
4
# Insertion Sort def insertion(lst): for i in range(1,len(lst)): currentvalue = lst[i] index = i while index > 0 and lst[index-1]>currentvalue: lst[index] =lst[index-1] index -= 1 lst[index]= currentvalue lst = [2,9,6,1,0,5,7,3] insertion(lst) print(...
a041eb1326889239a561de365e0873f223f31961
andrewStich/Facebook-Interview-Python
/solution.py
10,269
4.09375
4
import pandas as pd # Thank you for interviewing! This should take approximately 1 hour of your time; you may use up to 3 if necessary. #Feel free to call ********** for 15 minutes of help. Please pay attention to code quality, use 'Pythonic' coding style when possible, and comment like you normally would. Use any d...
2aa556b46db3f7aca4065431d91ccdb460cd1127
CodeDeemons/Python-Tkinter-Gui-Project
/Email_Sender/main.py
4,074
3.84375
4
from tkinter import * import smtplib from tkinter import messagebox # making tkinter window root = Tk() root.geometry('500x500') root.title('Email Sender @_python.py_') root.resizable(False, False) root.config(bg="#fff") # variable for Entry box Email = StringVar() Password = StringVar() To = StringVar() Subjec...
060d869ff8c8ff2f96f12ed144303918e087346a
AkashMullick/IntroToCompSci
/SquareRootNewtonRhapson.py
206
3.9375
4
epsilon = 0.01 y = int(input("Square root of: ")) guess = y/2.0 while abs(guess**2 - y) >= epsilon: guess -= (((guess**2) - y)/(2*guess)) print("The square root of " + str(y) + " is about " + str(guess))
09977f7bb06342d557f788306cd560a102fb5849
aswinvk28/titanic-survival-exploration
/predictions.py
1,136
3.5625
4
import os import sys import csv def import_csv(file_path): file = open(file_path, 'r') csvreader = csv.reader(file, delimiter=',') prediction_data = PredictionData() for line in csvreader: prediction_data.append(line) return prediction_data def predictions_0(data): """ Model ...
111f6cb7cda1796488bffea3f9ada5ff3d9fcaeb
obernardovieira/learn-testing
/PythonTest/calculator.py
628
3.65625
4
class Calculator(object): def __init__(self): self.history = [] def sum(self, x, y): result = x + y self.history += [[x, '+', y]] return result def sub(self, x, y): result = x - y self.history += [[x, '-', y]] return result def mul(self, x,...