blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6ab32412fd38d034e07222b198ab45e80ff4e10c
pondycrane/algorithms
/python/tree/convert_sorted_array_to_binary_search_tree.py
1,089
4.09375
4
import collections import typing import base.solution from lib.ds_collections.treenode import TreeNode class Solution(base.solution.Solution): def convert_sorted_array_to_binary_search_tree(self, nums: typing.List[int]) -> TreeNode: if not nums: return None def dfs(l, r): if l > r: ret...
d529d539a406b7b4ac25a123554e3582ed53847e
Zemke/euler100
/20.py
189
3.8125
4
#!/usr/bin/env python def fact(n): product = 1 while n > 0: product *= n n -= 1 return product fact10 = fact(100) summ = sum([int(i) for i in str(fact10)]) print(summ)
e40dc758e1bbc7da9545da627703262cdf179b11
jdanray/leetcode
/reverse.py
395
3.515625
4
# https://leetcode.com/problems/reverse-integer/ class Solution(object): def reverse(self, x): neg = False if x < 0: neg = True x = -x p = -1 y = x while y > 0: p += 1 y //= 10 p = 10 ** p r = 0 while x > 0: d = x % 10 r += (d * p) p //= 10 x //= 10 if neg: r = -r l...
14c940a9f124d6ca2b2e355e2c0db8e266a613fe
aCatasaurus/ProjectEuler
/p4/four.py
913
4.25
4
#!/usr/bin/env python3 # Find the largest palindrome made from the product of two 3-digit numbers. # brute force method def is_palindrome(num): s = str(num) for i in range(0, len(s) // 2): if s[i] != s[-i - 1]: return False return True def palindromes(digits, base=10): t = 0 ...
d9c42d7f5b0f0c81b0780e72c225583c495057d8
samer2point0/uni
/FOC/exc1/part1.py
1,043
4
4
"""This module should filter and sort uk phone numbers from the text file provided. """ import re def isValid(num): #returns true if the passed number starts with 44 and has 12 numbers if len(num)==12 and num[:2]=='44': return True else: return False def formatNum(num): #transform number form...
f2c028622728491d34467fb3ac4c1c445627b0f3
gsahinpi/pythodmidterm2
/triangle.py
989
3.859375
4
import turtle def drawTriangle(points,color,turtle): turtle.up() turtle.goto(points[0][0],points[0][1]) turtle.down() turtle.goto(points[1][0],points[1][1]) turtle.goto(points[2][0],points[2][1]) turtle.goto(points[0][0],points[0][1]) def midpoint(p1,p2): return [(p1[0]+p2[0])/2,(p1[1]+p2[1...
c5b844a832b38508b90382daed280756dda9b0d9
pyKis/GeekB
/Lesson-2/Lesson-2 task-2.py
594
3.609375
4
def get_sign(x): if x[0] in '+-': return x[0] my_list = ['в', '5', 'часов', '17', 'минут', 'температура', 'воздуха', 'была', '+5', 'градусов'] i = 0 while i < len(my_list): sign = get_sign(my_list[i]) if my_list[i].isdigit() or (sign and my_list[i][1:].isdigit()): if sign: ...
5dcded01ded23fc00547ef6a6a5cac3392b7dbde
akash1601/algorithms_leetcode_solution
/solutions/numberOfIslands.py
499
3.609375
4
def numberOfIslands(nums): count = 0 for i in range(len(nums)): for j in range(len(nums[0])): if nums[i][i] == '1': self.dfs(nums, i, j) count += 1 return count def dfs(self, nums, i, j): if i < 0 or j < 0 or i >= len(nums) or j >= len(nums[0]) or nums[i][j] != '1': return nums[i][j] = '#' self.df...
1f55d7e64f1dbcab01c7534e67b36d0033b1ae6d
rrkas/Exercism-Python
/29_meetup/meetup.py
825
4
4
import calendar from datetime import date class MeetupDayException(Exception): pass def meetup(year: int, month: int, week: str, day_of_week: str) -> date: cal: calendar.Calendar = calendar.Calendar() # all those days in month matching_days: list[date] = [d for w in cal.monthdatescalendar(year, mont...
e58dadc4bcbaa0bd49978a936f08702fd2ad9f2b
stefanGT44/Math-Expression-Interpreter
/lexer.py
8,942
3.9375
4
INTEGER, PLUS, MINUS, MUL, DIV, EOF, LEFT, RIGHT, LOG, SIN, COS, TAN, CTG, SQRT, POW, COMMA, GREATER, LESS\ , GREATER_E, LESS_E, EQUALS, EQUALS_I, EQUALS_NOT, VAR, D_VAR, FLOAT, TRUE, FALSE = ( 'INTEGER', 'PLUS', 'MINUS', 'MUL', 'DIV', 'EOF', 'LEFT', 'RIGHT', 'LOG', 'SIN', 'COS', 'TAN', 'CTG', 'SQRT...
f9535f2853f7d7de41d61d24984692141c40d0e4
prtk94/cec-rest-api
/test.py
500
3.5625
4
import pandas as pd import numpy as np months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] year_data= [] for i in months: print(f"reading excel for solar data in month {i}") month_df = pd.read_excel(f"Datasets/Solar {i}.xlsx") print(f"file read: Datasets/Solar {i}.xlsx") month_df.set_...
dbc38bb54f545d7f17a2b55b14d6ec397257ea24
here0009/LeetCode
/Python/726_NumberofAtoms.py
5,294
4.4375
4
""" Given a chemical formula (given as a string), return the count of each atom. The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name. One or more digits representing that element's count may follow if the count is greater than 1. If the count is 1, ...
a3ece277966e38c0de5d242c8115d8e2ba870c48
saigono/leetcode
/981.time_based_key_value_store.py
836
3.546875
4
# https://leetcode.com/problems/time-based-key-value-store/ from bisect import bisect from collections import defaultdict class TimeMap: def __init__(self): """ Initialize your data structure here. """ self._timestamps = defaultdict(list) self._data = defaultdict(list) ...
f794b2aca859f63da22f2f57851e98689a237acf
Ethan0507/Algorithmic-Toolbox
/week1_programming_challenges/3_16_diagonals/16-diagonals.py
2,242
3.703125
4
def check_up(grid,index,n): up_ele = grid[index - n] if up_ele != '_': return grid[index] == up_ele else: return True def check_up_left(grid, index, n): up_left_ele = grid[index - (n + 1)] if up_left_ele != '_': return grid[index] != up_left_ele else: return True...
3351169269a91ac145037e008260591bb4718a8a
michaelhuang/LintCode_Python
/Flip_Bits.py
397
3.796875
4
import ctypes class Solution: """ @param a, b: Two integer return: An integer """ def bitSwapRequired(self, a, b): c = ctypes.c_uint32(a ^ b).value # both a and b are 32-bit integers count = 0 while c: c &= c - 1 count += 1 return count if _...
61dcdb00b9ac69a04567bcb083d03c1f93c0ac49
alphaf52/document-qa
/docqa/data_processing/span_data.py
7,647
3.703125
4
from typing import List import numpy as np from docqa.data_processing.qa_training_data import Answer """ Utility methods for dealing with span data, and span question answers """ def span_len(span): return span[1] - span[0] + 1 def span_f1(true_span, pred_span): start = max(true_span[0], pred_span[0]) ...
ef890521122c285a618371657d37da6cbe5344eb
Aasthaengg/IBMdataset
/Python_codes/p02723/s209599494.py
99
3.53125
4
import sys s = input().strip() if s[2] == s[3] and s[4] == s[5]: print("Yes") else : print("No")
5ab518a635636197d60d67aa4cb562e5c060f7b8
Lawrence-tng/Sudoku-Solver
/Solver.py
5,268
3.578125
4
import pygame import time pygame.font.init() board = [ [7, 8, 0, 4, 0, 0, 1, 2, 0], [6, 0, 0, 0, 7, 5, 0, 0, 9], [0, 0, 0, 6, 0, 1, 0, 7, 8], [0, 0, 7, 0, 4, 0, 2, 6, 0], [0, 0, 1, 0, 5, 0, 9, 3, 0], [9, 0, 4, 0, 6, 0, 0, 0, 5], [0, 7, 0, 3, 0, 0, 0, 1, 2], [1, 2, 0, 0, 0, 7, 4, 0, 0],...
654a82405b581296580c3b8579bd24536c71a357
jepebe/aoc2018
/aoc2017/day4.py
1,330
3.8125
4
import itertools def passphrase_is_valid(line): words = line.split() valid_words = [] for word in words: if word in valid_words: return False else: valid_words.append(word) return True def passphrase_is_valid_wo_anagram(line): words = line.split() used...
6dd7949f4dc1de5c249f6e99dcb79dee1b8ec86a
anderssv49/python-course-gbg
/extralab/symbolic.py
2,217
3.6875
4
from parse_symbolic import * ######################################################################### ### part 1: derivatives of polynomials and more general expressions ##### ######################################################################### def derivative(exp): # TODO: return the derivative exp of an arbit...
cc1cc1045ee9e6b42b28f0bcb7fa1a1a6247f285
charmip09/Python_Training
/TASK2_Range.py
206
3.96875
4
''' Write a program in Python which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200. ''' print(*[x for x in range(2000, 3201) if not(x%7) and x%5])
d2a10980ac0ff133e06916cfd5e9cab29ab8b947
Chakyllfcu/Pythonprojects
/Unidad 2/Ejercicio 9.py
497
3.796875
4
import math print("Para hacer una hamburguesa se necesita 1 pan, 2 carnes, 1/5 de libra de tocineta. Calcule cuantas haburguesas se pueden hacer segun la cantidad de estas materias primas que existen en un almacén.") p = input("Inserte el numero de panes en almacen: ") c = input("Inserte el numero de carnes en almacen:...
c835639ed2b77b529034947ca338752581217d40
wusanpi825117918/study
/Day01/p_12类型转换.py
775
4.03125
4
''' 类型转换 ''' # 转换成整数类型 print(int(1)) print(int(1.1)) print(int('1')) # print(int('1.1')) # 转换错误 # print(int('abc')) # 转换错误 # 转换成浮点类型 print(float(1)) print(float(1.1)) print(float('1.1')) print(float('1')) # print(float('abc')) # 转换错误 # 转换成字符串类型 print('| ' + str(1) + ' |') print('| ' + str(1.1) ...
836626458194c0c848e7c96f520da5a4e74f47ab
essanhaji/python-3-tp
/exo/trening/2.py
374
4.28125
4
firstName = str(input("enter your first name :")) middleName = str(input("enter your middle name :")) lastName = str(input("enter your last name :")) firstName = firstName.capitalize() middleName = middleName.capitalize() lastName = lastName.capitalize() fullName = "{first} {middle:.1s} {last}" print(fullName.forma...
539f1f967c50ad7d2e9a59e371ec13685258b421
itdevline/process_vs_thread
/threadTest.py
1,092
4.1875
4
import random import threading """ *** MULTITHREADING *** Advantage: - Shared memory - low memory usage - I/O-bound applications (For example: networking) - Easy UI (user interface) communications - Access global variables. Disadvantages: - Not killable the child threads - If you have one CPU core then not faster the...
267afbe2b2f792eb06e3dbb88adcc62e962fa31d
Sumitsami14/NAI
/Coding games/Power of Thor.py
664
3.65625
4
#https://www.codingame.com/training/easy/power-of-thor-episode-1 #Dominika Stryjewska s16722 import sys import math north= "N" south = "S" east = "E" west = "W" light_x, light_y, initial_tx, initial_ty = [int(i) for i in input().split()] while True: remaining_turns = int(input()) walk = "" ...
171c68799ffe5446a522dc8d32fa8bbcc187f94c
markanson25/python-fundamentals
/09_exceptions/09_04_files_exceptions.py
3,137
4.34375
4
''' In this exercise, you will practice both File I/O as well as using Exceptions in a real-world scenario. You have a folder containing three text files of books from Project Gutenberg: - war_and_peace.txt - pride_and_prejudice.txt - crime_and_punishment.txt 1) Open war_and_peace.txt, read the whole file content and...
c008b2121ea3e072925bd5ccb895257bbcd87be0
hristoboyadzhiev/course-robotics-npmg
/word-counting-demo/word-counting.py
558
3.625
4
import re def myFunc(item): return item[1] if __name__ == "__main__": file = open("wikipedia.txt", "rt", encoding="utf-8") counts = dict() for line in file: words = set(re.split("[\s\.,?!\[\]\(\)\'\"=:;]+", line)) # print(words) for w in words: if(len(w) <= 3): ...
3645ab2a746909fb25afe1afddaef94d43516a06
Subham6240/college-python-assignment
/python 2nd assignment/temperature coonversion.py
321
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 10 12:37:39 2020 @author: SUBHAM """ x=float(input("enter temp.")) u=input("enter unit c/f ") if u=='c': temp=float((9*x/5)+32) print("temp. is",str(temp),"F") elif u=='f': temp=float(5*(x-32)/9) print("temp is :",str(temp),"C") else : print("wrong unit"...
3813e0283506c63781f71de04a08b785555be8bf
abhiwalia15/practice-programs
/multiplication_table.py
139
3.828125
4
def table(): n=int(input("ENTER ANY NUMBER\n")) for i in range(1,11): p = n*i print(str(n)+' * '+str(i)+' = '+str(p)) table()
f4dd7f39fb1c767711a6fc0dfdaf2562c2f0b07c
dinneel002/derekUdemyPython
/moreonstrings/acronmyn.py
188
4.1875
4
original_string = input('convert to acronmy :') original_string=original_string.upper() list_of_words = original_string.split() for word in list_of_words: print(word[0],end="") print()
c37ff9a8813a9492ab7c71b1b9dd8756947e49cd
cdeepakait/MonkVisitsCoderland
/MonkNiceString.py
440
3.609375
4
total = int(input()) def niceness(letter, allstring): print("letter, allstring", letter, allstring) if len(allstring) == 0: print(0) else: allstring.append(letter) allstring.sort() try: print(allstring.index(letter)) except ValueError: print(...
ed3c86bf6246400138f57db4c8b3cb0919c2288c
poojakancherla/Problem-Solving
/HackerRank Problem Solving/PrintLinkedList.py
369
4.15625
4
import LinkedListBase as l # Function to print the elements of a linked list def printLinkedList(head): curr = head while(curr): print(curr.data) curr = curr.next llist_count = int(input()) llist = l.SinglyLinkedList() for _ in range(llist_count): llist_item = int(input()) llist.inse...
283a21a625ae91698351bbd4377443ab521d99b0
eazapata/python
/Ejercicios python/PE3/PE3E3.py
323
4
4
#PE3E3 Eduardo Antonio Zapata Valero #¿Qué función te informa del tipo de dato tiene almacenado una variable? #Haz una prueba con los distintos tipos de datos que conoces. a=int(input("Escriba un numero entero ")) print (type (a)) b=float(input("Escriba un número decimal ")) print (type (b)) c=input("Escriba un nombre ...
9982a3aa8852aa457b8f43cb8097b331240d9e15
Percygu/my_leetcode
/链表/反转链表/92.反转链表-ii.py
781
3.671875
4
# # @lc app=leetcode.cn id=92 lang=python3 # # [92] 反转链表 II # # @lc code=start # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: pre = N...
ef3f7526a507cc2519a9c319bb70f21c12f322dd
rafhaeldeandrade/learning-python
/2 - Variáveis e tipos de dados em Python/Exercicios/ex43.py
846
3.9375
4
""" 43. Escreva um programa de ajuda para vendedores. A partir de um valor total lido, mostre: * o total a pagar com desconto de 10%; * o valor de cada parcela, no parcelamento de 3x sem juros; * a comissão do vendedor, no caso da venda ser a vista (5% sobre o valor com des¬conto) * a comissão do vendedor, no caso da v...
11eb2cf5905bbfeac586ba7e51bc6c5e1534af25
Crown0815/ESB-simulations
/critical_angle_simulation.py
918
3.828125
4
from math import * def critical_angle(candy_radius, rod_length, rod_radius): angle = 0 old_result = 0 while angle < pi/2: result = critical_angle_equation(candy_radius, rod_length, rod_radius, angle) if old_result * result < 0: break old_result = result angle +=...
92b9c87cd086770fa062605887c8cbff31873cf7
swapnilz30/python
/examples/area_of_circle.py
129
4.3125
4
#!/usr/bin/python3.6 pi = 3.142 r = input("Enter the radius: ") area = pi * int(r) * int(r) print("The area of circle: ", area)
d550221b1acfb3558ebfd94d52b95f4c56d90458
karanguptak9/pythonPractice
/12.py
96
3.703125
4
my_range = range(1, 21) print([10 * x for x in my_range]) #we use a for loop inside the range
f37243482f8658e9a81d08013268fa2ad521bb6b
Ansh-Kumar/Ansh-Fun-and-Learn
/Ansh Learn/WeatherWearer.py
455
4.1875
4
rainy = input("How is the weather? Is it raining? (y/n)").lower() cold = input("Is it cold outside? (y/n)").lower() if (rainy == 'y' and cold == 'y'): print("You should wear something extra warm and take an umbrella.") elif (rainy == 'y' and cold != 'y'): print("Just take an umbrella.") elif (rainy != 'y...
893127b37b101f853ee3c1cfab593cfa27d84529
Go-Trojans/trojan-go
/code/goboard/game_winner.py
4,215
3.671875
4
""" Author : Puranjay Rajvanshi Date : June 9th 2020 File : game_winner.py Description : Decides the game winner. """ """ Big Idea for the code written in this file: =========================================== Assuming any go board size. Given: given a board state, determine who's the winner 0 : blank site ...
de3db976b72ed65f536307efdb5363fda277e30e
afrizaldm/latihan-python
/latihan2.py
1,845
3.953125
4
# nilai < 90 dan nilai > 80 A # nilai < 80 dan nilai > 70 B # nilai < 70 dan nilai > 60 C # D nilai = 76 if nilai > 80 and nilai < 90: print("A") elif nilai >70 and nilai < 80: print("B") elif nilai >60 and nilai < 70: print("C") else: print("D") # jika nilai > 80 dan absen kurang dari 3 maka lulu...
077c64dd9a48db72a5f0ad6abe5c7e96f8f93079
courtneycampbell15/ProjectGutenberg
/methods.py
625
4.0625
4
# this method takes in a .txt file and returns the number of words in the file def get_total_number_of_words(file): wordCount = 0 f = open(file, "r") # read first line line = f.readline() while line: # do whatever line = f.readline() wordCount = wordCount + 1 f.close() ...
1560e2212321e69391810b05dea2fab1501a8b39
tloszabno/tl_en
/tlen/parser.py
554
3.6875
4
__SEPARATOR__ = "-" def parse_file(file_path): result = [] with open(file_path) as fs: for entry in fs: chunks = entry.split(__SEPARATOR__) if len(chunks) == 0: continue english_word = chunks[0].strip() if len(english_word) == 0: ...
6099a21cda4297fe3a54bf2f514b325591678e9f
curiousboey/Learning-Python
/Logical operators.py
265
4.03125
4
print(10 > 5) print(10 >= 5) print(10 <= 5) print(10 != 5) #not equal to print(10 == 5) print((10 > 5) and (1 > 3)) print((10 > 5) and (1 < 3)) print("and operation = ",(10 > 5) and (1 < 3) and "A" == "c") print((10 > 5) or (1 > 3)) print(not("james" == "Maria"))
cfe26137917dfbae3d4880909af70441b81f9fbf
Xomia4iwe/lesson_005
/Drawing_tools/house.py
1,117
3.59375
4
import simple_draw as sd def triangle(point, length, angle=0): for _ in range(3): v = sd.get_vector(start_point=point, length=length, angle=angle, width=3) v.draw() angle += 120 point = v.end_point def house(point_x, point_y, color, length, height, row): sd.rectangle(right_...
e3657982e304e98ea3ce2a1df049a3e65a89d7ad
francoistourlonnias/MesFonctions
/Python/Formation Python/formationPython2017_2/Ex5-3/Ex5-3-Done.py
8,108
3.734375
4
""" Exercise 5.3 Polymorphism """ class Trip: def __init__(self, departCity=None, arriveCity=None, departTime=None, departDay=None, arriveTime=None, arriveDay=None): self.departCity = departCity self.arriveCity = arriveCity self.departTime = departTime ...
493fa8342af9aab2c5d1efcd56759f0b6f29f9a1
lemonnader/LeetCode-Solution-Well-Formed
/math/Python/0066-加一.py
983
3.59375
4
# 66. 加一 # 给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。 # # 最高位数字存放在数组的首位, 数组中每个元素只存储一个数字。 # # 你可以假设除了整数 0 之外,这个整数不会以零开头。 class Solution(object): def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ if len(digits) == 0: return [] # 进位标识 ...
ef8e90e95f6ffa4096f8422a33e56503796d7005
fxalban8/Python-FOR_Loop
/Printing_elements_of_a_list.py
228
4.5
4
#The FOR command can be used to show the elementos of a list #let's create a list people=["M1","M2","F1","F2","F3"] #let's print each element of the list in one single line each other for item in people: print(item)
14ef5daf0727532527ec2a3d5a7bdd9fb8dec33a
joshwassum/cse210-student-batter
/batter/game/handle_collisions_action.py
4,782
3.5625
4
import random import sys from game import constants from game.action import Action from game.point import Point class HandleCollisionsAction(Action): """A code template for handling collisions. The responsibility of this class of objects is to update the game state when actors collide. Stereotype: Con...
bafab7a5d5777d6582d6d51dda7795a83a20fa69
AndersonFSP/Curso-em-V-deo-Python
/010-ConvertendoMoedas.py
155
3.625
4
real = float(input('Digite o valor em R$ a ser convertido: ')) dolar = real / 3.76 print('Com R${:.2f} você pode comprar US${:.2f} '.format(real, dolar))
ff938f135473154417ca946abc7ecac6d2b2c57e
Aasthaengg/IBMdataset
/Python_codes/p03679/s700974907.py
130
3.546875
4
x,a,b=map(int,input().split()) if 1<=(b-a)<=x: print('safe') elif (b-a)>x: print('dangerous') else: print('delicious')
a718e57efa86b5ce435f2670b14063dabd95691f
jvanvari/LeetCode
/python-solutions/sorting/selection_sort.py
714
4.03125
4
from typing import List # compare 1 element with all # find the smallest element in unsorted list # second time we locate the smallest item in the list starting from the second element in the list def selection_sort(nums: List[int]): l = len(nums) for i in range(l-1): # works with l also for j in ran...
9c9c7e304f8339acef5ac83f021279b768be0c26
shasank-shah/pycharmProjects
/pythonProjects/learningClasses/demo_inherirance.py
694
3.953125
4
# to get methods of other class into current class # single level inheritance class A: # super class def feature1(self): print("feature 1") def feature2(self): print("feature 2") class B(): # sub class def feature3(self): print("feature 3"...
a2150ca2209bfc404f2b6770784846b18368fe1b
DhruvGodambe/python_oop
/encapsulation.py
981
4.28125
4
# creating a class with a private variable 'origin' class Company: def __init__(self, name, net_worth, rating): self.name = name self.net_worth = net_worth self.rating = rating self.__origin = "India" # adding __ makes it a private variable print(" __origin from init functio...
af84a03c1ecf8b39c288adfd1d309cdb243036e4
G-M-C/War-Card-Game
/war.py
2,207
3.859375
4
from deck import Deck from player import Player player_one = Player(input("Enter Name of Player 1 : ")) player_two = Player(input("Enter Name of Player 2 : ")) new_deck = Deck() new_deck.shuffle_cards() for i in range(26): player_one.add_cards(new_deck.deal_one()) player_two.add_cards(new_deck.deal_one()) g...
3ec384fafbbe4a4ae0ad2264976e99b1a2916265
axisonliner/0502_project
/lesson2_homework.py
1,551
4.03125
4
from datetime import date import random date_now = date.today() def input_data(date_now): while True: input_name = raw_input("Enter your name: ") if input_name: break while True: input_year = raw_input("Enter your birth year: ") if input_year.isdigit() and len(input...
a2b8f1f6d1557f483af767f7c5c2948df1e29631
xerifeazeitona/PCC_Basics
/chapter_02/exercises/07_stripping_names.py
534
4.5625
5
# 2-7. Stripping Names # Use a variable to represent a person’s name, and include some whitespace # characters at the beginning and end of the name. Make sure you use each # character combination, "\t" and "\n" , at least once. # Print the name once, so the whitespace around the name is displayed. # Then print the name...
2c2912ec2aa50d2dac67938d47a77b8c3fbd3872
Bak4riba/zombieDice
/ZombieDice.py
1,772
3.515625
4
""" PUCPR - ANALISE E DESENVOLVIMENTO DE SISTEMAS ALUNO: MATHEUS BAKAUS BRUNO MATERIA: RACIOCÍNIO COMPUTACIONAL """ from random import randint shots = 0 brains = 0 steps = 0 # DEFININDO DADOS # T = TIROS, C = CEREBROS, P = PASSOS diceGreen = 'CPCTPC' diceYellow = 'TPCTPC' diceRed = 'TPTCPT' copo = [] pontos = [] f...
162f4c2fd3e416492f8b6bb0e4f002cc05d9a25b
RRoundTable/CPPS
/array_and_string/Reorder_Data_in_Log_Files.py
1,625
3.75
4
''' link: https://leetcode.com/problems/reorder-data-in-log-files/ You have an array of logs. Each log is a space delimited string of words. For each log, the first word in each log is an alphanumeric identifier. Then, either: Each word after the identifier will consist only of lowercase letters, or; Each word ...
1f86763ac124049c5dc4fd0740bb79df6e060a13
jonnysassoon/Projects
/DataStructuresAndAlgorithms/DataStructures/ArrayStack.py
592
3.546875
4
""" Author: Jonny Sassoon Program: Stack Implementation of LIFO Data Structure """ class Empty(Exception): pass class ArrayStack: def __init__(self): self.data = [] def __len__(self): return len(self.data) def is_empty(self): return (len(self) == 0) def push(self, elemen...
fda0276e0631b8652d53ceab36d9622c95bac2a1
vivekjha1213/Algorithms-practice.py
/data structure using python.py/array_question/problem_8.py
333
3.78125
4
def Min(arr,n): res = arr[0] for i in range(1,n): res= min(res,arr[i]) return res def Max(arr,n): res=arr[0] for i in range(1,n): res = max(res,arr[i]) return res arr =[15, 16, 10, 9, 6, 7, 17] n=len(arr) MIN=Min(arr,n) MAX=Max(arr,n) print(MIN) print(MAX) Range=MAX-MIN...
06b46838e6f5d845be8ad4e6330311b3a6682364
Vimvimvim/gittutorial
/Test.py
135
3.703125
4
def validation(): name = input("What is your name?") print("Hello",name,",you are a beautiful fucking bastard.") validation()
2fea15e492274c3d85248a7081883cbb8798aa88
jonghoonok/Algorithm_Study
/Implementation/Resorting.py
628
3.640625
4
def quick_sort(arr): if len(arr) <= 1: return arr pivot = arr[0] tail = arr[1:] left = [x for x in tail if x < pivot] right = [x for x in tail if x >= pivot] return quick_sort(left) + [pivot] + quick_sort(right) chars = list(input()) alphas = [] nums = [] for char in chars: ...
b789d3c6d1b8fef2f113b0a264f0c2e92b60fff1
CarlosFer27/Python
/ValidaUsiarioContraseña/ValidacionUsuarios/valida_usuario.py
480
4.15625
4
contador = 1 while(contador == 1): nombre = input("\nIngresa tu usuario: ") caracteres = len(nombre) alfanumerico = nombre.isalnum() if(caracteres < 6): print("\nEl nombre de usuario debe contener al menos 6 caracteres") elif(caracteres > 12): print("\nEl nombre de usuario no puede contener más de 1...
201a8ce0ca1f599eeb6ce7996733d6dd14b41ba4
rdasxy/programming-autograder
/problems/CS101/0038/solution.py
207
3.671875
4
# solution.py from divider import Divider x = int(raw_input()) y = int(raw_input()) d = Divider() try: print "Quotient is %d" % d.divide(x, y) except ValueError: print "Cannot divide by zero"
3cb46797192c9281b3b8bf3cd05a2c521dca6d06
jbmaillet/cpu_cgroup_calc
/cpu_cgroup_calc.py
2,529
3.78125
4
#!/usr/bin/python3 import sys import argparse def percent_to_share(percent_list): total_percent = sum(percent_list) if total_percent < 100: added_group_share_percent = 100 - total_percent print("Adding a group with {0}% of shares to reach mandatory 100%..." .format(added_group_sh...
35a5ded7d1e074aab70c394573bab617a126df88
randompyslices/randomslices
/a_random_sample_of_python/sample_no_repeats.py
827
3.796875
4
#!/usr/bin/env python from random import randint import numpy as np from timeit import timeit def sample_without_repeats(M,N): while True: s = [randint(0,M) for i in xrange(0,2*N)][:N] if len(set(s)) == N: return s def sample_no_repeats(M,N): while True: s = np.random.rand...
8966dd253242fe974e2c463d44f75383af7b03ac
Aaryan-R-S/Python-Tutorials
/Practice Problems/x+y.py
392
3.65625
4
def move(mylist): for i in range(len(mylist)-1): if mylist[i] == '1': mylist[i] = '0' if mylist[i+1] == '0': mylist[i+1] = '1' else: mylist[i+1] == '0' return mylist if __name__ == "__main__": a = list('1011111111111') print(a)...
dfe934033830d20983bdcb0d5746598b937b224a
Antohnio123/Python
/Practice/a.makarov/Lection8-ExamWork/Task6-finished.py
2,108
3.671875
4
def myformat (string, *args): simple = False numerate = False class WrongPositions(Exception): pass def Poscheck(): if simple == numerate == True: raise WrongPositions() if not isinstance(string, str): print("Введённые аргументы не являются строками, передайте ст...
9c4e73ad9212216daf7e9320b854da6ba61be4ca
jingong171/jingong-homework
/闫凡/2017310390-闫凡-第五次作业-金融工程17-1/10-6加法运算.py
400
3.78125
4
#使用try-excpet代码块来处理异常 try: #输入第一个数 num1=input('请输入两个数字,计算他们的和,请输入第一个数字') #输入第二个数 num2=input('请输入第二个数字') #执行计算并打印 num=float(num1)+float(num2) print('他们的和为'+str(num)) #处理异常 except ValueError: print('请输入两个数字,不要输入文本')
363a6223e3af958569cc18ec2975261a400701af
lollinim/date-a-scientist
/capstone/dating_skeleton_Question1.py
3,955
3.5
4
import pandas as pd from matplotlib import pyplot as plt from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.naive_bayes import MultinomialNB #1.) Import Data to Dataframe: df = pd.read_csv("profiles.csv") '''Extract Ethinicty/Religion Name from first w...
4a9532569b20b98c6489c2af042e6a0da955999b
shashwatkathuria/Data-Structures-And-Algorithms
/Shortest Path - Bellman Ford - All Sources/allpairsbellman.py
7,303
3.6875
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 9 07:31:55 2018 @author: Shashwat Kathuria """ # BELLMAN FORD ALL PAIRS SHORTEST PATH ALGORITHM - USING DYNAMIC PROGRAMMING # ALL PAIRS SHORTEST PATHS # Assignment answers # g3 = -19 # g2, g1 = negative cycle def main(): # Reading the input file...
28b488720006468617062d6ba12271f80022c42c
copycat123/Vending_machine
/Vending_machine.py
680
4.125
4
sodas = ["pepsi", "cherry coke", "sprite"] chips = ["Doritos", "chetoz"] candy = ["Snickers", "M&M", "Twizz"] while True: choice = input("Would you like a SODAS, some CHIPS , or a CANDY? ").lower() try: if choice == "sodas": snack = sodas.pop() elif choice == "chips": ...
04b8548da41d9f7bde9040cd120b5d245e05e782
RobertoRGM/Curso_Python
/ex014.py
191
3.953125
4
#Conversor de temperaturas t = float(input('Informe a temperatura em °C:')) f = ((9 * t) / 5) + 32 print('A temperatura de {:.2f}°C convertida em Farenheit é {:.2f}°F'.format(t,f))
6dab702837eb43e69c7a42247755da14a706e034
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/prmkov001/question1.py
1,484
3.640625
4
#Kovlin Perumal #Print Menu print("Welcome to UCT BBS") print("MENU") print("(E)nter a message") print("(V)iew message") print("(L)ist files") print("(D)isplay file") print("e(X)it") message = "no message yet" #initialize selection variable sel = input("Enter your selection:\n") #Close if sel = X if sel ...
8e2ad9dfd7fd7a7073ce65d65c2607b07bff010b
nnar2201/python1
/Nayanarrays.py
1,589
3.890625
4
''' JDoe_JSmith_1_4_2: Read and show an image. ''' import matplotlib.pyplot as plt import os.path import numpy as np # “as” lets us use standard abbreviations '''Read the image data''' # Get the directory of this python script directory = os.path.dirname(os.path.abspath(__file__)) # Build an absolute filename f...
c12fe8deb91d2c168b0f17766ea0dac4f8b0edca
StuQAlgorithm/AlgorithmHomework
/3rd/homework_1/id_69/103-BinaryTreeZigzagLevelOrderTraversal.py
1,468
4.09375
4
# Given a binary tree, return the zigzag level order traversal of # its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). # For example: # Given binary tree [3,9,20,null,null,15,7], # 3 # / \ # 9 20 # / \ # 15 7 # return its zigzag level order tr...
456afc6db24ba6806a1b0f2017fabb808a342c6c
brez/yijing
/yijing/iching.py
1,685
3.703125
4
# -*- coding: utf-8 -*- """ "Countless words count less than the silent balance between yin and yang" - Lao Tzu, Tao Te Ching """ import random YIN = 0 YANG = 1 TAILS = 2 HEADS = 3 THREE = 3 HEXAGRAMS = { 1: '䷁', 2: '䷖', 3: '䷇', 4: '䷓', 5: '䷏', 6: '䷢', 7: '䷬', 8: '䷋', 9: '䷎', 10: '䷳', 11: '䷦', 12: '䷴', ...
e928dea8a91e45e1c2dce549d81edd3622a93c5c
Fisher-Wang/ps_image_alignment
/points.py
1,038
3.59375
4
import pygame import math class Points: def __init__(self, screen): self.screen = screen self.points = [] self.RADIUS = 10 def update(self, events): for event in events: if event.type == pygame.MOUSEBUTTONDOWN and event.button == pygame.BUTTON_LEFT: p...
b2615c0b9f8e0e7565497568bea9defc6745bc66
raghulrage/Python-programs
/Basic-programs/balancing scale.py
1,926
3.734375
4
l=[[3,4],[1,2,7,7]] l=[[13,4],[1, 2, 3, 6, 14]] l=[[5,9],[1, 2, 6, 7]] m=max(l[0]) n=min(l[0]) d=m-n l2,l3,l4,l5=l[1],[],[],[] for i in range(len(l2)-1): if(l2[i]+l2[i+1]==d): l3.append([l2[i],l2[i+1]]) if(l3==[]): for i in l2: l4.append(l[0][0]+i) l5.append(l[0][1]+i) for i in range...
d7024b91bea18daffaecba5828334af17e6a8135
giuliana-marquesi/estudo-python
/coursera/decomposicao_fatores.py
704
3.84375
4
def main(): num = int(input("Digite um numero: ")) primo = 2 multiplicidade = 0 while num > 1: while num % primo == 0: num = num // primo multiplicidade = multiplicidade + 1 if multiplicidade > 0: print("Fator", primo, "multiplicidade", multiplici...
408092919abea01fd0d181587703f22ff8e7af4b
abhisoniks/interviewbit
/tree/symmetricBinaryTree.py
615
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: # @param A : root node of tree # @return an integer def isSymmetric(self, A): return self.areChildSymmetric(A.left,A.right) ...
a8cb5666101f28a519e21286012130267e1b12ef
ParkerCS/ch-web-scraping-bernhardtjj
/weather_scrape.py
1,240
4.0625
4
# Below is a link to a 10-day weather forecast at weather.com url = "https://weather.com/weather/tenday/l/USIL0225:1:US" # Use urllib and BeautifulSoup to scrape data from the weather table. import urllib.request from bs4 import BeautifulSoup # Print a brief synopsis of the weather for the next 10 days. # Include the ...
9c653e97fde549a940aeceaf7ef0cfa8f8f2b419
kunalverma75/AprioriAlgorithm
/Apriori_Algorithm_for_Generating_Frequent_Itemsets.py
12,188
4.15625
4
#!/usr/bin/env python # coding: utf-8 # # Apriori Algorithm for Generating Frequent Itemsets # ##### by Kunal Verma # ## Introduction # Apriori invented by Rakesh Agarwal and Ramakrishnan Srikant in 1994 is # a well known algorithm in data mining. Apriori Algorithm is used in finding frequent itemsets. Identifying...
48f628e97bec99fbff3f16c7a3c4b04d21377e3a
bilalc97/LeetCodePractice
/is_permutation.py
843
4.03125
4
def is_permutation(s1, s2): """ Return True is s1 and s2 are permutations of each other and False otherwise. :param s1: str :param s2: str :return: bool """ if len(s1) != len(s2): return False else: s1_dict = {} for i in range(len(s1)): if s1[i] in s1...
14a9fe882f17a6e409ceb8498cad8514f7163abe
erauner12/python-scripting
/Linux/Python-Essentials/9-python-modules.py
2,109
4.15625
4
#!/usr/bin/python3.6 # nothing print("") # functions # create first function: def sayHello(): print("Hello") sayHello() print("--") usernames = [ { 'name' :'bcranston', 'priv' :'admin', 'password' :'millennium' }, { 'name' :...
515c1352dec92a056848bd742aa365a1d2b0dde2
AdriaSalvado/M03
/ejercicio-pares.py
154
4.03125
4
# coding: utf8 # Adrià Salvadó # numero=input ("Escribe un numero ") if (numero%2==0): print "Que bonito número par" else: print "Que número mas vulgar"
59b3ebd4baa6d21e90fbb186377fbf6ff688dda0
nkmeng/python_examples
/0021/0021.py
683
3.53125
4
# -*- coding: utf-8 -*- """ 第 0021 题: 通常,登陆某个网站或者 APP,需要使用用户名和密码。密码是如何加密后存储起来的呢?请使用 Python 对密码加密。 """ import hashlib SALT = '8#@ia0o' def encrypt_password(password): sha1 = hashlib.sha1() password = password + SALT sha1.update(password.encode('utf-8')) return sha1.hexdigest()[3:33] def validate_pass...
660a7fb51832d409d2fb3705a9daad463a890c2a
ifmylove2011/student
/exercise/ex16.py
296
3.84375
4
# 输出指定格式的日期 import time print(time.time()) localtime = time.localtime(time.time()) print("本地时间为 :", localtime) localtime = time.asctime(time.localtime(time.time())) print("本地时间为 :", localtime) print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
49a94908210ded0a914afbbc754bd396f7bd2ec9
arnauddesombre/Asteroids
/Asteroids.py
41,175
3.59375
4
# ---------------------------------------------------------------- # # Asteroids # # Developped by Arnaud Desombre (arnauddesombre@yahoo.com) # # ---------------------------------------------------------------- # # Open source ** PLEASE DISTRIBUTE ** and ...
1f638e8c4d8c6e0787d9cbad7ae7dcb4fc5156a7
mauro-20/The_python_workbook
/chap2/ex48.py
1,304
4.3125
4
# BirthDate to Astrological Sign day = int(input('enter your day of birthday: ')) month = input('enter your month of birthday: ') sign = '' if month == 'dec' and day >= 22 or month == 'jan' and day <= 19: sign = 'capricorn' elif month == 'jan' and day >= 20 or month == 'feb' and day <= 18: sign = 'aq...
9eed33de4070fed698e27654832995b1b47905d4
rogeriosilva-ifpi/teaching-tds-course
/programacao_estruturada/20192_166/Bimestral2_166_20192/Parte_1/Renato_Wilames/segunda questão.py
464
3.953125
4
def main(): senha = input('digite sua senha: ') cara = 8 maiu = 1 minu = 1 nume = 1 quanti = len(senha) lma = 'ABCDEFGHIJKLMNOPQRSTUVXWYZ' lmi = 'abcdefghijklmnopqrstuvxwyz' if quanti >= 8: print('sua senha é segura') elif quanti < 8: print('sua senha não é segura...
b4eed4041a09e97220584b3b3bcafaf1e1fb3de0
KuyaKen/1jazzymonkey
/python_work/animals.py
132
3.6875
4
animals = ['Dog','Cat','Whale','Mouse'] for animal in animals: print(animal) print(f"\tA {animal.lower()}, is not an object\n")
eecdf39a6eb0d7f6ec881419716bcea7350a57f8
Sibinvarghese/PythonPrograms
/object oriented programming/student constructor.py
672
4
4
class Student(): college_name="lumniar" def __init__(self,id,name,course,total): self.id=id self.name=name self.course=course self.total=total def printValues(self): print("Roll No=",self.id) print("name=",self.name) print("College_Name=", Student.col...
5de3448e681412859c7c07fa93302cf8dea13051
MikaPY/HomeworkPY
/hw5.py
1,705
3.71875
4
# Импорт одного модуля. import time # Импорт нескольких модулей. import random, os # Импорт некоторых методов или же переменных. from math import ceil # Импорт метода ceil # Псевдонимы для модулей(сокращения). import Template as tem # Обращение к модулю,как tem. # Импорт из модуля math, pi и ceil from math im...
ebf0a9d82c03eb4273aba54333ed9f2e97ac34d0
sarthak-789/CP1_CIPHERSCHOOLS
/1431_Kids With the Greatest Number of Candies.py
360
3.546875
4
# link : https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/ class Solution: def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]: m=max(candies) l=[True]*len(candies) for i in range(len(candies)): if candies[i]+extraCandies < m: ...
5c27d12642f5f71274dfb0e4966a7597e510f795
miseop25/Back_Jun_Code_Study
/back_joon/문자열처리/back_joon_1769_3의배수/back_joon_1769_ver1.py
301
3.8125
4
if __name__ == "__main__": N = (input()) cnt = 0 while int(N) > 9 : temp = 0 for i in N : temp += int(i) N = str(temp) cnt += 1 if int(N)%3 == 0 : answer = "YES" else : answer = "NO" print(cnt) print(answer)
e77c434d3fd1c2c251370144e61360e3655b4be4
byhwdy/learning-ml
/my_algorithm/gd_1.py
491
4.0625
4
""" 用梯度下降最小化一些简单函数 """ def f1(x): """ 待最小化的函数 """ return x**2 def d1(x): """ 导数 """ return 2 * x def train(x, f, d, learn_rate, epochs): """ Args: x: 自变量 f: 函数 d: 导数 learn_rate: 学习率 epochs: 迭代次数 Returns: """ for epoch in range(epochs): x -= learn_rate * d(x) return x, f(x) if __name__ == '...
660c9ade0cf1114e9249868b83514b0d77cd1de7
Michael-Nath-HS/MKS21X
/ai/testers/newlinkedlists.py
2,636
4.09375
4
class Node: #Init object def __init__(self,data): self.data = data self.next = None def __str__(self): return "NODE VALUE: %d" % self.data class LinkedList: def __init__(self): self.head = None def printlist(self): # Prints contents of a linked list # Sets ...