blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2b5bafb5e471328a715ee74006e62b9c00f5bfc3
gjxfree/python
/code/code_2.3.py
192
4.21875
4
# 将”to be or not to be”字符串倒序输出 word = 'to be or not to be' new_word = [] i = len(word) while i: i -= 1 new_word.append(word[i]) print(''.join(new_word))
d1a8ac3b20b646e4ecde7d010ce5e67efed1e10d
karbekk/Python_Data_Structures
/Interview/Python_Excercises/Error_Handling_Exceptions/raise.py
4,987
3.984375
4
How do I manually throw/raise an exception in Python? Use the most specific Exception constructor that semantically fits your issue. Be specific in your message, e.g.: raise ValueError('A very specific bad thing happened') Don't do this: Avoid raising a generic Exception, to catch it, you'll have to catch all othe...
49aa08d196e1fce7c58fcce097ba842bfff34bef
ngonzo95/BarrenLandAnalysis
/BarrenLandAnalysis/model/field.py
883
3.640625
4
from shapely.geometry import box, Polygon class Field: """ Represents a field using a shapely polygon. """ def __init__(self, len, width): self._fieldPolygon = box(0, 0, len, width) def area(self): """ Returns a list representing the area of the feild. If the feild has ...
867c5455bd9e543f7fa299ddcd47e2953bafbe59
TungstenRain/Python-turtle_attempt
/polygon_turtle.py
2,016
4.25
4
""" This module contains code from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Chapter 4: Case Study in Think Python 2 Note: Although this is saved in a .py file, code was run on an interpreter to get results Note: Using Python 3.8.5 """ import math import turtle...
95f62cf82684a60b5a6b8b580a59001aea328130
ChangxingJiang/LeetCode
/0101-0200/0109/0109_Python_2.py
972
3.6875
4
from toolkit import ListNode from toolkit import TreeNode class Solution: def sortedListToBST(self, head: ListNode) -> TreeNode: # 异常情况处理 if not head: return None # 二分处理 values = [] while head: values.append(head.val) head = head.next ...
e6e241487186b62a9aaa63ee0218dc994ee8fcaa
chidamodu/SQL
/SQL _ assessment _ VR-AR_revision.ipynb
4,019
3.6875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: SQL exercises Table: email_events Columns: user_id, event, campaign, date Example: dan, open, quest, 2019-07-01 Question #1: Write a query that accomplishes the following: return a list of email campaigns run during June 2019 and the number of opens per campaign Ques...
47f48222eae9d146a75a4f67e31c19436045be66
NickTrossa/Python
/programas/BatallaNaval/version2.7/batallanaval.py
1,992
3.8125
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 9 19:18:16 2014 @author: alumno """ import random # Armo el tablero y lo muestro tablero = [] for x in range(5): tablero.append(["O"] * 5) def print_tablero(tablero): for fila in tablero: print " ".join(fila) print "Juguemos a la batalla naval!" print_tablero...
90689ae35a3976095ac2b7a01452ebfa16dd7ef8
granthoechst/124_pa3
/plus_min_gen.py
332
3.703125
4
import numpy as np import sys # usage: python plus_min_gen.py n def gen_plus_min(): plus_min_list = [] for i in range(0,100): x = np.random.random_integers(0,1) if x == 0: plus_min_list.append(-1) else: plus_min_list.append(1) return plus_min_list print gen...
883d3df76b00cc8ada27b9dfad5dfa5f68940fbd
matteosan1/python_code
/threading/threading.py
6,180
3.703125
4
import threading class MyThread ( threading.Thread ): def run ( self ): print 'Insert some thread stuff here.' print 'It'll be executed...yeah....' print 'There's not much to it.' import threading class MyThread ( threading.thread ): def run ( self ): ...
4b9bbcd3960c4e0706ef9a0e0333352bdf28aa8a
CircularWorld/Python_exercise
/month_01/teacher/day16/exercise02.py
706
3.96875
4
""" 迭代员工管理器 """ class EmployeeIterator: def __init__(self, data): self.data = data self.index = -1 def __next__(self): self.index += 1 if self.index < len(self.data): return self.data[self.index] else: raise StopIteration() class EmployeeM...
5e9c95d435af45e37963dcc92881805625e86b02
krnets/codewars-practice
/6kyu/Transform To Prime/index.py
1,907
4.34375
4
# 6kyu - Transform To Prime """ Given a List [] of n integers, find minimum mumber to be inserted in a list, so that sum of all elements of list should equal the closest prime number. List size is at least 2 . List's numbers will only positives (n > 0). Repeatition of numbers in the list could occur. ...
3418e2d2e72413ad210f025e92b620ff1388822c
tehmasta/advent-of-code-2020
/day_1/day1.py
559
3.671875
4
import math from itertools import combinations with open("puzzle_input.txt") as puzzle_input: puzzle_input = [int(line.strip()) for line in puzzle_input] num_entries = [2, 3] def find_solution(puzzle_input, num_entries): for potential_set in combinations(puzzle_input, num_entries): if sum(potential_s...
06a0adaca5b56f9f54dd3b8384f641366c1e6afc
cuqjc/curso_python
/second_hangman_.py
3,203
3.765625
4
import random import os def normalize(s): replacements = ( ("á", "a"), ("é", "e"), ("í", "i"), ("ó", "o"), ("ú", "u"), ) for a, b in replacements: s = s.replace(a, b).replace(a.upper(), b.upper()) return s def run(): with open('./hangman/data.txt',...
7e8b60d060abfd81b030d1e2855f4ed016dc7ab7
KaterynaShydlovska/python
/fundamentals/fundamentals/Students_and_Grades.py
1,096
4.21875
4
length = int(input("How many students do you have?")) listOfStudents = [] while length: students = {} name = input("Students name: ") if not name: print("Invalid name, try again..") name = input("Students name: ") students["Name"] = name grade = input("Students garde: ") while ...
d816688d1dd993893769ffd8cb435565c842475c
jhiltonsantos/ADS-Algoritmos-IFPI
/Atividade_Fabio_02b-Revisao_Condicional/fabio_02b_02_fem_masc.py
307
3.875
4
def main(): sexo = input('Digite o sexo(F-Feminino || M-Masculino):') if sexo == 'F' or sexo == 'f': print('Sexo Feminino.') elif sexo == 'M' or sexo == 'm': print('Sexo Masculino.') else: print('Sexo Invalido.') if __name__ == '__main__': main()
6d044556688ac43c30646d6acebb2ddab75a64ee
CapaBE/Python
/ex3_HouseMaxSize.py
1,923
4.09375
4
class House: "The house that can contain many rooms" def __init__(self, available_space=100): self.rooms = [] self.available_space = available_space self.totalsize=0 def add_rooms(self, *room): for item in room: if self.size() + item.size > self.a...
41594f29b28316ed90bd8648ad947381a5fc96f3
doubleLLL3/Leetcode-Exercise-Codes
/Array/onlyOne.py
413
3.5
4
# nums = [4,1,2,1,2] # for i in range(len(nums)): # check = nums.pop(0) # if check in nums: # nums.pop(nums.index(check)) # print(check) # continue # print(check) from collections import defaultdict nums = [4,1,2,1,2] hash_table = defaultdict(int) for i in nums: hash_...
147e99f32b430080412234ac9429c8a3cfa0a37d
lenapy/learn_urllib
/examples/basic.py
1,083
3.703125
4
import urllib.request import urllib.parse """ get request """ x = urllib.request.urlopen('https://www.google.com/') # print(x.read()) """ post request, if we need to put some date to request, for example some search request """ url = 'http://www.pythonprogramming.net' values = {'s': 'basic', 'submit': 'search'} data ...
77b842a8e509f69c52666f0742f61ab84e149db8
1050669722/LeetCode-Answers
/Python/problem0016.py
2,304
3.59375
4
# -*- coding: utf-8 -*- """ Created on Fri May 17 10:34:43 2019 @author: Administrator """ class Solution(): def threeSumClosest(self, nums: list, target: int) -> int: nums = self.merge_sort(nums) closest= nums[0] + nums[1] + nums[2] for k in range(len(nums)): #for在内部迭代出最近目标或直接找到目标返回,没有在内部...
f956cb490adc7d1bdec931890ccdc0a5add56039
bheki-maenetja/small-projects-py
/courses/8_things_you_must_know_in_python/Exercise Files/challenge/min_max_challenge.py
1,164
4.03125
4
import string DICTIONARY = 'dictionary.txt' letter_scores = { 'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, ...
c98a308c1940331fd6670d1bebe62880da2e9fcc
pfpimenta/biocomp2019
/lista3parte2/e3-2.py
6,389
3.9375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # exercicio a da lista 3 parte 2 de Biologia Computacional # Pedro Foletto Pimenta, outubro de 2019 ### import sys # tree class class Tree: # initialization def __init__(self): self.left = None self.right = None self.left_dist = None s...
bcd88abcac9daaa4c7c0e11f08e2345d39bdd5bc
sebsanscartier/nhlstats
/Documents/test.py
735
3.546875
4
import requests import json headers = { 'Content-Type': 'application/json'} def get_team_stats(): #fetches all the the team from the best team api_url = 'https://statsapi.web.nhl.com/api/v1/teams?expand=team.stats' response = requests.get(api_url, headers=headers) if response.status_...
ac2a502ce7300cd8ac00c77702b6e06341ba2d4e
sunnyyeti/Leetcode-solutions
/23 Merge k Sorted Lists.py
1,559
4
4
# You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. # Merge all the linked-lists into one sorted linked-list and return it. # Example 1: # Input: lists = [[1,4,5],[1,3,4],[2,6]] # Output: [1,1,2,3,4,4,5,6] # Explanation: The linked-lists are: # [ # 1->4->5, # 1->3-...
35566557894c66eb2a39bf1cc18c6b244fea15af
tristenallgaier2023/bikers
/src/models.py
945
3.953125
4
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np class Bike_Classifier(nn.Module): """ This class creates a neural network for classifying bikers as casual(0) or member(1). Network architecture: - Input layer - First hidden layer: fully connected layer of s...
b8470e288cba262e885c0c8dede2b83119b8e15f
ethanl2014/CSE-331-Projects
/CSE-331-Projects/Project3/proj3/Stack.py
4,378
4.0625
4
################################### # PROJECT 3 - STACK # Author: Ethan Lee # PID: A48941153 ################################### class Stack: # DO NOT MODIFY THIS CLASS # def __init__(self, capacity=2): """ Creates an empty Stack with a fixed capacity :param capacity: Initial s...
8e521e958ba014089a9cdcfaf8d715da9cd3a129
EduardoSlonzo/python_project
/Exercicio_em_python/Numeros_pares.py
330
3.8125
4
n = int(input("Quantos numeros você vai digitar? ")) vet = [0 for x in range(n)] for i in range(n): vet[i] = int(input("Digite um numero: ")) pares = 0 print("\nNumeros pares") for i in range(n): if vet[i] % 2 == 0: print(vet[i], end=" ") pares = pares + 1 print(f"\n\nQuantidade de pares = ...
ac9a7487c26747b77dabb17f670540d940340979
SapnaDeshmuk/list_questions_python
/split.py
121
3.578125
4
str2="sapna" str2lst=list(str2) print(str2lst) stob1="hi hello welcome python is awesome" stob2=stob1.split() print stob2
00085e26d7077509a518417a29db42c4f6e2581a
SilasA/Random-Scripts
/defintegral.py
681
3.984375
4
# A simple script to find an estimate for the area under the curve # f(x) on interval [x, y] with n number of rectangles with # p end point import math def f(x): return 15 / x # function here def estimate(x, y, n, p): rectWidth = (y - x) / n itr = rectWidth * p + x areaAccum = 0.0 for i in range(...
98337bd816547c7f24890aea931d168f79923156
mertturkmenoglu/python-examples
/examples/old_examples/examples/exception_handling.py
270
3.8125
4
# Exception handling program numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] try: for i in range(len(numbers)): print(numbers[i]) # Throws error print("11th element = %d" % (numbers[10])) except IndexError: print("Index Error. Check your index!!!")
c0d39b2bf9752f2e25e2de0cf3a930d6d065c35a
rafaelperazzo/programacao-web
/moodledata/vpl_data/25/usersdata/132/11936/submittedfiles/av1_3.py
214
3.875
4
# -*- coding: utf-8 -*- from __future__ import division import math a=input('digite o valor de a:') b=input('digite o valor de b:') i=a while True: if a%i==0 and b%i==0: print(a) break i=i-1
69468fce187cecd3983adaa139aaf0784e4cbb2d
georgejordan3/learnpython3thehardway
/learnpython3thehardway/ex19.py
1,444
4.4375
4
# Uses the function def to define cheese_and_crackers def cheese_and_crackers(cheese_count, boxes_of_crackers): # Formats cheese_count to the printed string print(f"You have {cheese_count} cheeses!") # Formats boxes_of_crackers to the printed string print(f"You have {boxes_of_crackers} boxes of crackers!")...
3167f92859c3f0379ddfca007757f81311021532
tonikarppi/yks
/yks.py
2,011
4.34375
4
def plus(a, b): """ Returns the sum of a and b. """ return a + b def minus(a, b): """ Returns the difference between a and b. """ return a - b def times(a, b): """ Returns the product of a and b. """ return a * b def divided_by(a, b): """ Returns the ratio o...
3a2b9bcf4f64d0cec913e75ee6d92d4ecdcb81a3
komalkri-dev/character-o-graph
/A_to_J.py
4,013
3.765625
4
import turtle def draw_A(offset): a = turtle.Turtle() a.speed(4) a.color("yellow") a.up() a.forward(offset) a.down() a.left(73.5) a.forward(72.1) a.right(147) a.forward(72.1) a.backward(28) a.right(106.5) a.forward(25.9) a.hideturtle() def draw_B(offset): #...
c262ed6a76ff62230cb46c13303a2a4dfc60c31f
cossta/Validador-Palindromo
/palindromo 0.2.py
5,837
3.703125
4
""" Importando Tkinter """ from tkinter import * from tkinter import messagebox from tkinter import filedialog """Colores utilizados: 1. 2a1a5e 2. f45905 3. fb9224 4. fbe555 5. dfddc7 El orden de los colores va desde el más oscuro hasta el más claro""" root = Tk() miFr...
d0b79b946d99e31a3f4d8cbc26392de7be46ce30
maumneto/IntroductionComputerScience
/CodeClasses/LoopCodes/cod5.py
236
3.640625
4
for i in [1,2,3,4,5]: print(i) print('--------------------') for j in [5,4,3,2,1]: print(j) print('--------------------') for k in [5,1,2,3,7]: print(k) print('--------------------') for i in range(15,0,-2): print(i)
b3250c0ca5faff622c7c298e85505a9000e4a577
haha001/Test
/test.py
503
4
4
sup = "MUHAHAHA" #Python er sjovt nok I guess print("Hello World!") #Det er dog lidt mærkeligt uden delimiter print("Mit navn er Simon",sup) print("To plus to er lig med", 2 + 2) print("To ganget med 0 er lig med", 2 *0, '\n') #True false? med print :O print("Er 3 + 2 større end 7 -1?") print(3 + 2 > 7 - 1) #Dette ...
0ab22da9dd4c4bc2c29f7f4a1492d14d628ef17c
thesharpshooter/codeforce
/day9/word.py
194
3.859375
4
string = raw_input() lower_count = sum(map(str.islower,string)) upper_count = sum(map(str.isupper,string)) if lower_count < upper_count: print string.upper() else: print string.lower()
a538d732e9efe761dbb663b582748b8d9a38e54a
haruto0519/haruto_hirai
/game_project.py
682
3.625
4
#-----import statements----- import random as rand import turtle as trtl spot = trtl.Turtle() import turtle as score_writter spot.showturtle() spot.shape("circle") spot.shapesize(2) spot.color("red") spot.speed(8) score = 0 #def update_score(): def clicked(x, y): score =+ 1 new...
55c4c0d4bab880af134ed5dc11a8707749ec0b08
Lominelo/infa_2021_Litovchenko
/lab_2/упр 10.py
327
3.984375
4
import turtle turtle.shape('turtle') def circlel(t): for i in range (0,100): turtle.forward(t) turtle.left(360/100) def circler(t): for i in range (0,100): turtle.forward(t) turtle.right(360/100) for j in range (0,12): circlel(1) circler(1) turtle.left(36...
fb2b39f3d591ceb4a752a4af36ae9046b6145c8c
devw/hackerrank
/src/basic.py
2,645
4.375
4
def reverse_words_order_and_swap_cases(sentence): # Implement a function that takes a string consisting of words separated by single spaces and returns a string containing all those words but in the reverse order and such that all cases of letters in the original string are swapped, i.e. lowercase letters become up...
f18ee93eb0accf94bf8fcab95c9a4c9101cf234c
alishahussain/Level0-Module5
/_03_nested_loops/amazing_rings/amazing_rings.pyde
1,123
3.96875
4
""" Go to the recipe to run the demonstration before starting this program """ def setup(): # Set the size of your sketch to be a rectangle like in the recipe demonstration # Call the noFill() command so all the ellipses will be transparent def draw(): # Use a for loop to make the first set of rings ...
a5ca5154e4dd500ad7404fef8f978a7489d60b2c
w3cp/coding
/python/python-3.5.1/7-input-output/6-format-3.py
426
3.65625
4
# table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678} for name, phone in table.items(): print('{0:10} ==> {1:10d}'.format(name, phone)) table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678} print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; ' 'Dcab: {0[Dcab]:d}'.format(table)) table = {'Sjoerd': 4127, 'J...
6b4ae9e4025626e8c044086725a5957658686412
selik/destructure
/examples/fips.py
2,136
3.5
4
#!/usr/bin/env python3 ''' Suppose you're trying to estimate someone's median household income based on their current location. Perhaps they posted a photograph on Twitter that has latitude and longitude in its EXIF data. You might go to the FCC census block conversions API (https://www.fcc.gov/general /census-block-co...
2cf8dccc58b6139ccceff9253e2711a8d1a4b8b0
q42355050/260201026
/lab05/example1.py
109
4.09375
4
number = int(input("Enter the number: ")) for i in range(10): print(number, "x", i+1, "=", number*(i+1))
1765819a9a5b7c5630561baba67d8f9d3a05e700
Sandhya99999/AllPrograms
/PythonPrograms/Series.py
436
4.0625
4
TermNumber = int(input('Enter a number upto which you want to print the terms like this series(1, 4, 27, 256, .....):')) print('The terms in the above series upto', TermNumber, 'are', end = '') TermCounter = 2 Product = 1 while Product <= TermNumber: print('', Product, end = '') Counter = 1 Product = 1 ...
f2fa03f3b76f1d02d91d226778c45aff63c43e7e
ulaireatea/Python
/Exercicios/ex038(Comparando números).py
267
4.03125
4
n1 = float(input('Digite um valor: ')) n2 = float(input('Digite outro valor: ')) if n1 > n2: print('O primeiro número digitado é maior.') elif n1 < n2: print('O segundo número digitado é maior.') else: print('Os dois números digitados são iguais.')
4b13761b39d27f39e013376e6a37612f3c4c1e00
lschanne/DailyCodingProblems
/year_2019/month_05/2019_05_10__min_edit_for_valid_parentheses.py
1,018
4.28125
4
''' May 10, 2019 Given a string of parentheses, write a function to compute the minimum number of parentheses to be removed to make the string valid (i.e. each open parenthesis is eventually closed). For example, given the string "()())()", you should return 1. Given the string ")(", you should return 2, since we mus...
221b998428b7fb4be63380bc07ec957360006fbe
bobhancock/pythonsysadmin
/text/starts_ends_with.py
290
3.71875
4
filename = "foo.txt" print(filename.endswith("txt")) # True print(filename.startswith("foo")) # True print(filename.startswith("bar")) # False print(filename.startswith( ("bar", "bob", "foo") )) # True print(filename.startswith("o", 1)) # True print(filename.startswith("oo", 1, 3)) # True
0f59d7ef7c8fb3833cbc99dc39bb3aeb3222f247
bhusalashish/DSA-1
/Data/Hashing/Subarray with zero-sum/Hashing.py
853
3.96875
4
''' #### Name: Subarray with zero-sum Link: [link]() #### Sub_question_name: Hashing Link: [link]() Iterate and find the current sum and add to set() If sum is 0 or sum is present in set() ; zero substring exists **Prefix Sum** arr[] = {1, 4, -2, -2, 5, -4, 3} If we consider all prefix sums, we can notice that ...
f3d6284b4e4fb8aef7495b2fa6f732179cf96a33
znnznn/coursera
/week2/while/digital st n.py
106
3.625
4
n = int(input()) i = 1 while (i ** 2) <= n: m = i ** 2 print(m, end=' ') i = i + 1 print(' ')
5b9eac13c6ce7a7d2a82c787be68af5d1b9a5e40
shlokKh/interview-practice
/chapter4/p9.py
663
3.53125
4
''' My logic is for every level it 2^h h = the height ''' def weave_list(l1, l2, results, prefix): if len(l1) == 0 or len(l2) == 0: result = prefix results.append(result + l1 + l2) return headFirst = l1.pop(0) print(headFirst) prefix.append(headFirst) weave_lis...
5584c075d2da0a6f180ea6dbc4fe74cf369d0bf6
kyleetaan/git-pythonmasterclass
/src/basics/stringSlice.py
254
3.65625
4
# 0123456789012345678901234 letters = "abcdefghijklmnopqrstuvwyz" print(letters[16:13:-1]) print(letters[4::-1]) print(letters[:-9:-1]) for i in range(1, 13): print("No. {0:<2} squared is {1:<3} and cubed is {2:<4}".format(i, i**2, i**3))
326bf08efdb2a680919bb95949c84b03944e8f82
henzelis/Python_Learning2020
/regex_password_cheker.py
452
3.65625
4
import re pattern = re.compile(r"[A-Za-z0-9@#$%]{8,}") while True: password = input('Please input password that contain letters, numbers, symbols $%#@, and at least 8 char long: ') check = pattern.fullmatch(password) try: if password == check.group(): print('Your password acce...
5cca6d8d30ea83613cb40c62b6f6acbc26ee49a5
GoncalvesCarol/algoritimos1_2021
/cursoPythonIniciante/somaDoisNumeros.py
99
3.75
4
x = input("Informe um número ") y = input("Informe um número ") z = int(x) + int(y) print (z)
b8432951e84bc639a863e2e2ec618e08c56d472b
ZhiyuSun/leetcode-practice
/1-100/054_螺旋矩阵.py
2,356
4.03125
4
""" 给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。   示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/spiral-matrix 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ # 2021.03.02 直奔题解,模拟法 from typing import List class Solution: def spiralOrder(sel...
228b82484be51baefa52875bef00de199ccd4120
sureshmelvinsigera/linkedlist
/checkPalindrome.py
2,223
3.890625
4
''' Given a singly linked list of characters, write a function that returns true if the given list is palindrome, else false. The list below is palindrome: {Empty List} 1 1 -> 2 -> 2 -> 1 ''' from linkedlist import Node from linkedlist import LinkedList ''' Approach 1 (Using stack): 1) Traverse the given list from he...
57b0133b81edab740c7c641c2112bb7a8e693deb
Barathkumar-09/Games
/stone_paper_scissors.py
1,280
4.15625
4
''' Stone Paper scissor game: Points : 1. if paper and rock then paper wins 2. if paper and scissor then scissor wins 3. if rock and scissor then scissor wins ''' import random score=computr=flag=0 computer = ["p", "s", "r"] max=int(input("Enter the maximum score! :")) #print(random.choice(comp)) print("""p=pape...
06e05c8cb3439eb41f2bd286c51d4111a1eae94b
sergiodealencar/courses
/material/curso_em_video/ex072.py
1,025
4.03125
4
# numeros = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, # 11, 12, 13, 14, 15, 16, 17, 17, # 19, 20) # extenso = ('zero', 'um', 'dois', 'três', 'quatro', # 'cinco', 'seis', 'sete', 'oito', 'nove', # 'dez', 'onze', 'doze', 'treze', 'quatorze', # 'quinze', 'dezesseis', 'dezese...
517b96f69ba4faa2e17fdb9b2644f3fe0ff0c55b
Hansung-Lee/TIL
/Algorithm/baekjoon/11655_ROT13.py
338
3.609375
4
msg = input() result = "" for m in msg: code = ord(m) if 64 < code < 91: code += 13 if code > 90: code -= 26 result += chr(code) elif 96 < code < 123: code += 13 if code > 122: code -= 26 result += chr(code) else: result +...
7128d17bfab3b3fcf99ed36af792837c18558b5e
JuyeonYu/Algorithm_DataType
/ReverseWord.py
230
3.796875
4
def reverse_word(str): word_list = str.split(" ") reversed_list = [""] * len(word_list) for index, value in enumerate(word_list): reversed_list[len(reversed_list) - index - 1] = value return reversed_list
5ae4c195730d26475155ca0a8bee894ae41a413b
PlanckConstant/Python-course
/Lesson14.py
1,270
3.875
4
l = [1, 2, 3, 'hello', ['test', 10], 'word', True] l2 = list('hello') l3 = list((1, 2, 5)) #Кортеж внутри списка l4 = [i for i in 'hello'] #каждый символ в строке l5 = [i for i in 'hello word' if i != ' '] #Кроме ' ' l51 = [i+'(str)'+i for i in 'hello word!' if i not in [' ', '...
02d23a19396a5304adb3276c3ac6870fabaad524
bhoj001/python_tutorial
/ex_1.5_datatype_frozenset.py
2,449
4.15625
4
''' author: bhoj bahadur karki date: 2020-jan-19th purpose : about frozenset in python set vs frozenset: There are currently two built-in set types, set and frozenset. The set type is mutable — the contents can be changed using methods like add() and remove(). Since it is mutable, it has no hash value and cannot be...
9b58a579b3d5e2a210d16101bd965147253be111
tansonlee/sorting-algorithms
/main.py
975
4
4
from bubble_sort import bubble_sort from insertion_sort import insertion_sort from selection_sort import selection_sort from merge_sort import merge_sort from quick_sort import quick_sort from tree_sort import tree_sort class Person: def __init__(self, name, age): self.name = name self.age = age person1 = Person...
d3c746dd701543862e0a3cfeb92f95bcc2f2520b
Pincaptain/idea-bag-solutions
/prime-factorization/service/factorization_service.py
503
3.96875
4
import math class FactorizationService(object): def prime_factorization(self, number: int) -> list: if number < 2: return [] factors = [] while number % 2 == 0: factors.append(2) number /= 2 for i in range(3, int(math.sqrt(number)) + 1, 2): ...
24cf1c3cf3fd7dd1112fbfc1a40a37c8691ce91a
minhthe/practice-algorithms-and-data-structures
/Binary Search/isSquare.py
487
3.546875
4
''' https://leetcode.com/problems/valid-perfect-square/ ''' class Solution: def isPerfectSquare(self, num: int) -> bool: def f(num, l , r): while l<=r: mid = int( (r-l)/2 + l ) if mid * mid == num: return True if mid * mid > num: ...
b2a0b8d00c912a1e189271fb623923ce563c7f26
yangh9596/Algo-Leetcode
/Leetcode/257_Binary paths.py
731
3.921875
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 binaryTreePaths(self, root): """ :type root: TreeNode :rtype: List[str] """ def p...
3abeca784381d1cb1031663faf4de96e8cc82eac
ceucomputing/automarker
/test1/submission_D.py
145
3.6875
4
# Addition Problem # Student D try: x = int(input("Enter x: ")) y = int(input("Enter y: ")) print(x + y) except: print('Error')
3004a31a95acbe4ee9062d80d85daf0dfae79409
emilcw/tdde23-labbar
/tdde23-labbar/lab8/lab8C.py
1,746
3.515625
4
"""Implementation av remove-funktion i lab8C, körexempel ligger i lab8C_test och förklaringar till hur funktionen fungerar ligger i Forklara8C.txt. Var Samtliga funktioner hör hemma finns angiver ovanför funktionen""" #Denna funktion hör hemma i calendar.py def remove(cal_name, d, m, t1): "String x ...
1a1ac2a5ec05c06fcfe38d53d8f6dcb2f293c4f1
okeonwuka/PycharmProjects
/ThinkPython/swampy-2.1.5/mysquare1a.py
294
3.53125
4
# Exercise 4.3 # 4.3.1 from TurtleWorld import * # For some reason we need to initialise TurtleWorld() otherwise # error world = TurtleWorld() # Function that draws a square def square(): t = Turtle() for i in range(4): fd(t, 100) lt(t) # Draw a square square()
351d4169be4efc2b2ab4f7a05430c1cbe0f7d6bc
vukakarthik/PyTrain
/08_classes-basics/02_inheritance.py
1,032
4.0625
4
class Person: def __init__(self, name, age): self.name = name self.age = age def introduceyourself(self): print("My name is " + self.name) print("My age is " + str(self.age)) class Teacher(Person): # this class inherits the class above! def __init__(self, name, age): ...
256ab64bd14ae59d67214ac8e69fc85be9bc22f5
joyrexus/CS212
/homework/unit_4/bridge/refactor/search.py
2,904
3.859375
4
class Path(list): ''' Representation of a path (sequence of states). ''' def __init__(self, *args): super(Path, self).__init__(args) # make paths comparable by cost def __lt__(self, other): return self.cost < other.cost def __le__(self, other): return self.cost <= other.cost def __gt__...
cef1af5538f7814e55fdedf636ab1fdce73a0387
denisela1/work_log
/csv_funcs.py
8,397
4.15625
4
import csv from datetime import datetime import re import os def clear(): """Function to clear screen as the program runs.""" if os.name == 'nt': os.system('cls') else: os.system('clear') def read_file(): """ Function to read the csv file and return data as a dictionary, dates be...
829bdd85d2b9e1d814463b7c969416b67d4db018
JuleeKeenanRivers/Keenanrivers_julee
/PyLesson_07/Lesson07.py
178
3.96875
4
number = int(input("Enter a number:")) digits = 0 num = number while number > 0: digits += 1 number = int(number/10) print("There are", digits, "digits in", num)
b3f371c4d5eda88722c3b4d1d9fd57317d2e9de5
gvattiku/rpiFacedetection
/face_detection.py
856
3.5625
4
""" Takes pictures from the Raspberry Pi Camera at regular intervals. Detects faces and sends cropped pictures of faces to the server """ import cv2 import requests SERVER_URL = 'http://127.0.0.1:5000/image' cascPath = "/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" faceCascade = cv2.CascadeClassi...
cc6cecf83bf32c1d445c32d1362ced90f5570869
Ratna04priya/-Python-worked-problems-
/prob_-_soln/complex_no_add.py
568
4.25
4
# Adding complex numbers import math class comp: def __init__(self,x,y): self.x=x self.y=y def __add__(self,other): return comp(self.x + other.x, self.y + other.y) def __str__(self): string = str(self.x) string = string +" " + str(self.y)+ "i" return string k= input("Enter the real part of complex 1:...
864a6cec0205a883059d1ae8e5da436895e707e0
SeanyDcode/codechallenges
/completed/dailychallenge4.py
955
3.859375
4
# From dailycodingproblem.com # # Daily Challenge #4 # # Given an array of integers, find the first missing positive integer in linear time and constant space. # In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. # # For ex...
776df1c84aba5e4589c55bba35f2e050d8c6ce9e
yadvi12/Lariox-Automation
/aws.py
881
3.90625
4
# Importing OS Module import os # This function will set the color of text to blue. os.system("tput setaf 4") def aws(): print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> AWS AUTOMATION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") print(" ") ...
2a4e1c3b69d7152ba1bb4e36e7176c23c8d86ede
Yanjiao-Ao/LeetCode
/01delete_duplicate.py
521
3.515625
4
def delete_duplicate(nums):#解题思路:双指针;优化,如果存在一个没有重复数的列,会多话时间,所以直接 head = 0 tail = 1 if len(nums) ==0: return 0 if len(nums) == 1: return 1 while(tail<len(nums)): if nums[head] != nums[tail]: nums[head +1] = nums[tail] head +=1 tail +=1 ...
5367ebc9586710caa234d11302c196bea86a47d7
Prakashchater/Daily-Practice-questions
/practice.py
208
3.59375
4
def cummilative(arr): l = [] j = 0 for i in range(len(arr)): j += arr[i] l.append(j) return l if __name__ == '__main__': arr = [10,20,30,40,50] print(cummilative(arr))
845bcabcb6f01a88bfbd4588d66682c63ce5cd09
ktsstudio/kts-school-backend
/1-asyncio/cpu_multi.py
294
3.515625
4
import time from threading import Thread COUNT = 50000000 def countdown(n): while n > 0: n -= 1 t1 = Thread(target=countdown, args=(COUNT,)) t2 = Thread(target=countdown, args=(COUNT,)) begin = time.time() t1.start() t2.start() t1.join() t2.join() print(time.time() - begin)
f151df27a4ddbb1ee9a6b93a80e513acec6c6473
Huzo/Othello-and-The-Journey-games-duck-typing
/Elf.py
1,652
3.53125
4
# CSCI3180 Principles of Programming Languages # # --- Declaration --- # # I declare that the assignment here submitted is original except for source # material explicitly acknowledged. I also acknowledge that I am aware of # University policy and regulations on honesty in academic work, and of the # disciplina...
09b4b2043efdbb4aaab0977ef118ee7e6f671cae
abdirahman-mahat/password-locker
/user.py
1,414
3.96875
4
import unittest class User: """ Class that generates new instances of contacts. """ user_list = [] # empty user list def __init__(self,name,username,password): self.name = name self.username = username self.password = password """ __init__ method that helps...
aa14d0fc151617d7cd549badf364d8b7224f92cc
brugnara/exercism
/python/raindrops/raindrops.py
215
3.953125
4
def convert(number): ret = '' ret += 'Pling' if not number % 3 else '' ret += 'Plang' if not number % 5 else '' ret += 'Plong' if not number % 7 else '' return ret if ret != '' else str(number)
b37c1779ef3da92161849e977d7c84a526d3bcbc
sashaobucina/interview_prep
/python/easy/increasing_order_search_tree.py
1,318
4.0625
4
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def __eq__(self, other): return (type(self) == type(other)) and (self.val == other.val) and (self.left == other.left) and (self.right == other.right) def increa...
6ad7aeae0bb87aa6b43d4020a91b5b4d90986aa0
DayDayGu/LeetCode
/344. Reverse String/xia.py
372
3.625
4
class Solution: def reverseString(self, s): """ :type s: List[str] :rtype: void Do not return anything, modify s in-place instead. """ len_str = len(s) i = 0 while ( i < len_str // 2 ): swap_index = len_str - i - 1 s[i], s[s...
282a32db61016f7f8daf6cfd3ac203cf740dba6e
albahnsen/pycircular
/pycircular/utils.py
5,319
4.21875
4
import numpy as np import pandas as pd def date2rad(dates, time_segment='hour'): """Convert hours to radians Parameters ---------- dates : array-like of shape = [n_samples] of hours. Where the decimal point represent minutes / 60 + seconds / 60 / 100 ... 0 <= times[:] <= 24 time_...
572166b6a02c7f355aaa78677a8a69296d7367b4
luisfbarajas/practicepython
/console/Numero-mayor-de-tres.py
451
3.96875
4
# Definir una función max_de_tres(), que tome tres números como argumentos y devuelva el mayor de ellos. def takeANumber(): print('Enter a number: ') return input() def maxNumber(n1,n2,n3): if n1>n2 and n1>n3: return n1 elif n2>n2 and n2> n2: return n2 else: return n3 n1...
9c23555626b99f28ea17c12e657738c12938f031
ianmiell/lucid
/cron_reader
2,250
3.8125
4
#!/usr/bin/env python3 import sys import time import datetime def usage(): print('An argument of the form HH:MM must be supplied within appropriate bounds (ie 00:00 - 23:59).') sys.exit(1) def main(): # Pick up argument 1 and split into HH and MM. try: arg = sys.argv[1].split(':') if len(arg[0]) != 2 or len(...
6b790a90077fd47b94fc97598691bd4253824c72
aniruddhamurali/python-algorithms
/src/math/number-theory/primes/prime_sieve.py
495
4.1875
4
# Uses the Sieve of Eratosthenes to generate a list of primes below a number def sieve(n): """Return a list of the primes below n.""" prime = [True] * n result = [2] append = result.append sqrt_n = (int(n**.5) + 1) | 1 # ensure it's odd for p in range(3, sqrt_n, 2): if prime[p]: ...
d7e42005ea388211fc8e095696e10fece22c9c2b
H602602/AI-Python-
/session 6/P1.py
407
4.1875
4
a=10 if a>5 : print(a,"Is greater than 5") elif a<5 : print(a,"Is less than 5") elif a==10 : print(a,"Is equal to 10") else : print(a,"Is not equal to 10") # a=10 # if a>5 : # print(a,"Is greater than 5") # if a<5 : # print(a,"Is less than 5") # if a==10 : # print(a,...
5c9edc51e13252b9ca0a700fd91e5e52747b67b8
MadhaviSattiraju/Python-coding
/primeno.py
168
4.0625
4
n=int(input("Enter a number")) count=0 for i in range(1,n+1): if n%i==0: count+=1 if count==2: print(n,'is prime') else: print(n,'is not a prime')
66e6fba3d331346d1e751304f7e1cbaae61dc0dc
UMBC-CMSC-671-F20/code
/ms3.py
661
3.796875
4
""" 3x3 magic square problem """ import constraint as c p = c.Problem() p.addVariables(range(0, 9), range(1, 9+1)) p.addConstraint(AllDifferentConstraint(), range(0, 9)) p.addConstraint(ExactSumConstraint(15), [0,4,8]) p.addConstraint(ExactSumConstraint(15), [2,4,6]) for row in range(3): p.addConstraint(ExactSumC...
f0b1b37312a79a38af32bdb4237738d9b560a3fb
Aparna-Shankar/Python-Tutorial
/File Objects.py
3,211
4.03125
4
""" File Objects ****************************************************************************************************** Reading from files ****************************************************************************************************** """ f = open('File_test.txt','r') # Here f is the file object print(f.nam...
aa7ea8fc5291d423e6e13a27a717661ae8d8965e
the-strawman/cspath-datastructures-capstone-project
/Soho-Restaurants-master/script.py
4,457
4.25
4
from trie import Trie from data import * from welcome import * from hashmap import HashMap from linkedlist import LinkedList # Printing the Welcome Message print_welcome() # Entering cuisine data food_types = Trie() eateries = HashMap(len(types)) for food in types: food_types.add(food) eateries.assign(food, L...
807892fdfb7de4451753eac1104445d1185730ca
asimali5/asimali
/PycharmProjects/Loops/check.py
736
3.90625
4
def print_word(): ar=[] ar3={} with open('bc.txt')as file_object: contents=file_object.read() for word in contents.split(): if word in ar: continue else: counter=0 fl=len(contents.split()) for word2 in contents.split(): if word.lower...
17c7cc996f2edd6ce3d18f23e238c3ffc386254c
vxiaohan/LeetCodeProblems
/3_LongestSubstringWithoutRepeatingCharacters/LongestSubstringWithoutRepeatingCharacters.py
972
3.859375
4
import unittest class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ stringList = list(s) stringLength = len(stringList) if stringLength == 0: return 0 maxLength = 0 headIndex = 0 ...
6e763d69c805fdcd1159590918179b4c01aafc04
cunhasb/Data-Structures-Python-
/linked-list/test-linked-list.py
2,109
3.875
4
import linked_list import unittest class TestGetPosition(unittest.TestCase): """ Test the get_position function from the linkedlist library """ def test_get_position(self): """ print (ll.get_position(3).value) Test that the invoking get_position(3) will return the correct valu...
c3854622cc23fadd15c6213339730c2fbbe531fa
scottenriquez/wiki-depth
/depth_search.py
3,016
3.703125
4
import threading import wikipedia MAX_THREADS = 125 def depth_search(user_start_page, depth_row, target_page, pages_hit, depth): """ #user_start_page: the Wikipedia page instantiated from the user's command line arguments #depth_row: a list of links to all Wikipedia pages in a given depth #target_pag...
65264806184c94c816974e103795c6c260b8bbd6
kkaya10/Python_Examples
/port_scanner.py
774
3.734375
4
import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) target = input("[+] Enter Target IP: ") port_list = list() def scanner(port): try: sock.connect((target, port)) return True except: return False while True: target_ports = int(input("[+] Type port...
d013a491e2138eeffbeb61188af604d142a96f93
joshmurr/text_encoder
/text_encryptor.py
1,564
3.953125
4
#!/uer/bin/python # -*- coding: utf-8 -*- # Text Encryptor -- by Josh Murr from random import randint everything = [] def makeEverything(): for i in range(32,127): everything.append(chr(i)) def generateKey(a, n): key = [] for i in range(n): key.append(ord(a[randint(0,len(a)-1)])-32) ...