blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0905fa566192dded1e476cc5ce6cc7e108b66cbc
cuixd/PythonStudy
/1.变量类型与占位符输出语句/variables.py
647
3.8125
4
# -*- encoding:utf8 -*- print('我爱中国') x = 2 y = '3' print('hahahah') print(2 ** 3) print(10 % 4) # 显示变量类型 print('变量x的类型:', type(x)) print('变量y的类型:', type(y)) # 字符串相加表示拼接,字符串与数字N相乘表示重复N次字符串 print("'a'+'b'=", 'a' + 'b') print("'a'*3=", 'a' * 3) # 多行注释赋值给变量,形成带换行的多行字符串 multi_line = ''' 床前明月光, 地上鞋两双, 举头看床上, 一对狗男女。 ''' p...
a2fda1af8607a0d16dcd1165c9f126a2876b92d4
Aasthaengg/IBMdataset
/Python_codes/p02419/s010373163.py
156
3.75
4
W = input().lower() T = '' while True: txt = input() if txt == 'END_OF_TEXT': break T += txt.lower() + ' ' print(tuple(T.split(' ')).count(W))
8d00699b2243da5ff89cdd4e45ef0b170d399763
P4Kubz/no_quiero_otro_repositorio_aaaaaaaaaa
/While/While1.py
104
3.90625
4
numero = 12 while numero > 1: print("Mi número {} es mayor que 1".format(numero)) numero -= 1
c5385503e53c240a58e7af92939f23428359f888
allo0001/gb_algorithms
/les1/task1.py
438
3.859375
4
""" Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь. """ n = input('Введите трехзначное число :') while len(n) != 3 or not n.isdigit(): n = input('Введите трехзначное число :') a, b, c = map(int, n) print(f'Сумма - {a + b + c}') print(f'Произведение - {a * b * c}')
9e047a64ea21e428fd21815d4d46df2f1af0c370
girishalwani/Training
/python/python fundamentals/IO Operations/prog_6.py
329
4.21875
4
""" Write a program to count the frequency of a user entered word in a txt file. """ filename=input("enter file name -> ") word = input("enter the word to find its frequency in text file -> ") f1=open(filename,'r') string = f1.read() freq = string.count(word) print("frequency of ",word," in",filename," = ",freq) f1...
5d9d5de0c43ec7e048da8df9a1712261866d59c6
Unainigo/PortafolioUnaiI-igo
/prueba.py
260
4.125
4
for i in ["unai", "pablito", "olga", "charlie", "mary", "fermin", "navarro"]: if i == "olga" or i == "mary": print(i + " es una chica de la cuadrilla") else: print(i + " no es una chica de la cuadrilla") print("el programa simple de prueba acaba aqui")
0efd9eddc56f16c3ff37e4247e59bffaae1e95c2
nikel4610/sparta_coding
/알고리즘공부/week4/fibo_recursion.py
744
3.765625
4
#input = 20 숫자가 크면 느림 #def fibo_recursion(n): # 구현해보세요! #if n == 1 or n == 2: #fibo_recursion(3) = fibo_recursion(2) + fibo_recursion(1) # return 1 #return fibo_recursion(n - 1) + fibo_recursion(n - 2) #print(fibo_recursion(input)) # 6765 input = 50 #숫자가 커도 빠름 # memo 라는 변수에 Fibo(1)과 Fibo(2) 값을 ...
634e40905d53e732d6adad1cce29c91253cd4a13
FernandoOseias/URI
/Iniciante/1073.py
112
3.515625
4
n = int(input()) pares = [i for i in range(2, n+1, 2)] for i in pares: print('{0}^2 = {1}'.format(i, i**2))
6a0d3775e95e6c0ccc9dc504f3eeb1e9071bee1e
ivanmmarkovic/Problem-Solving-with-Algorithms-and-Data-Structures-using-Python
/trees/tree-traversal/treenode.py
1,288
3.890625
4
class TreeNode: def __init__(self, key=None, left=None, right=None): self.key = key self.left = left self.right = right def insert_root_value(self, key=None): self.key = key def insert_left(self, key=None): self.left = TreeNode(key, self.left) def insert_right(...
220827f4f277fcd7e43c35e38fe955fa2897297b
gunbux/Advent-of-Code-2019
/Day 1/aoc1.2.py
1,473
3.921875
4
#! python3 # AOC 1 - Advent of Code Problem 1 #TODO: Save input as variable import os import math file = open('aoc1.txt','r') modules = file.readlines() ###Debuggin statement ##for i in modules: ## print(i) total_fuel = 0 def fuel_calc(number): return math.floor((float(number)/3))-2 for mod in modules: ...
d1998968ff4c66d5195b08b1f5a8463129c4021c
Pyk017/Competetive-Programming
/Interview_Preparation_Questions/Interview_Questions(Coding_Club_PSIT)/Find_Missing_Element_Sequential_Array.py
486
3.8125
4
""" Given an array containing n distinct numbers taken from 0, 1, 2, ..., n. Find the one that is missing from the array. Input : [3, 0, 1] Output : 2 Input : [9, 6, 4, 2, 3, 5, 7, 0, 1] Output : 8 """ def find_missing(a): count = [0]*(max(a)+1) for i in a: count[i] += 1 if 0 in count: r...
edb3aed103f80437335a9e898fa378e110d26c08
InvincibleNobita/BasicPythonProjects
/Guess the number/Number Guessing game.py
1,567
4.3125
4
from random import randint """ Welcome! This a number guessing game where you will start with 3 lives in order to guess a number or numbers between 0-20. So you them smartly.Wait... it sounds boring.So, here's the twist. If you guessed the number correctly in first attempt, you'll get double o...
8dcdb168a021d7fa5b47750d2d86709e4ad24dd3
grigor-stoyanov/PythonOOP
/iterators_generators/squares.py
481
3.625
4
# generator solution def squares(n): current_num = 1 while current_num <= n: yield current_num ** 2 for el in squares(5): print(el) print(list(squares(5))) # iterator solution class Squares: def __init__(self, end): self.end = end self.start = 1 def __iter__(self): ...
a7ba67c87aa7bd5f5b86d583d3a5d50284167832
WisTiCeJEnT/elab-ku
/03x-Subroutines-I/03.py
268
4.3125
4
from math import pi def sphere_volume(r): return 4/3*pi*r**3 def sphere_surface_area(r): return 4*pi*r**2 r = float(input("Enter sphere radius: ")) print(f"Sphere volume is {sphere_volume(r):.2f}") print(f"Sphere surface area is {sphere_surface_area(r):.2f}")
5a9b7dc0f0291c0436395887c88f1e78ab65fde8
nneessen/balanced-stats-api
/app/helpers.py
244
3.671875
4
def format_number(hex): return int(hex, 16) # noqa F523 def hex_to_int(hex, dec): num = int(hex, 16) / 10 ** dec if num - int(num) == 0: # If num is a whole number. return int(num) else: return round(num, 8)
063fd88972a279f6e294f701a00d5f660e9d5f8b
Dragon-Boat/PythonNote
/PythonCode/Python进阶/模块/导入模块.py
2,543
3.5
4
#coding=utf-8 #author: sloop ''' Pythonos.pathģṩ isdir() isfile()뵼ģ飬úжָĿ¼ļǷڡ ע: 1. лƽ̨ԲԵҲǷеļкļ÷/data/webroot/resource/pythonļк/data/webroot/resource/python/test.txtļҿԲ¡ 2. ȻҿڱϲǷӦļкļ import os print os.path.isdir(r'C:\Windows') print os.path.isfile(r'C:\Windows\notepad.exe') ''' import os print os.path.isdir(r'C:\...
21bbdc96998d3baed1205b217b1d0b2bb8a8a728
Dragonet-D/leetcode
/leetcode/110-BalancedBinaryTree/index.py
535
3.75
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 isBalanced(self, root: TreeNode) -> bool: def getHeight(root): if root is None: return 0 leftHeight, rightHeight = getHei...
91588e7739330b428c7f6a6bbd643da891fc9f67
shuowenwei/LeetCodePython
/Medium/LC538.py
811
3.796875
4
# -*- coding: utf-8 -*- """ @author: Wei, Shuowen https://leetcode.com/problems/convert-bst-to-greater-tree/ https://labuladong.gitee.io/algo/2/18/24/ LC230, LC538, LC1038 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val =...
b7334619203ede00db110e50a91bbe327b1d2629
EdmondWang/studypy
/c4-loop.py
130
3.90625
4
''' Task Read an integer . For all non-negative integers , print N * N. ''' a = int(input()) for i in range(0, a): print(i * i)
7a5164a624b65e6cd158a55ede67ed23d67feab1
SkiMsyk/AtCoder
/BeginnerContest109/B_Shiritori.py
438
3.546875
4
N = int(input()) words = [] rule_length = True rule_2time = True rule_startEnd = True for i in range(N): word = input() if 1 > len(word) or len(word) > 10: rule_length = False if word in words: rule_2time = False if i !=0 and words[-1][-1] != word[0]: rule_startEnd = False ...
1bf10e36053edf162ae4cde0ce09e53980069ccd
cgardner3/Python-Programs
/homework1.py
2,494
4.0625
4
''' This program's goal is to make a program that will allow the user to input information about a book including the code, cost, number of volumes you have, how many peeple will be in the class, whether or not the book is requred and if its been used in the past. After that it will give the customer all of the data, a...
b741d24d908e2dbd035c524341071545dcea0b07
NataliaWojcik1/Python
/04/Zadania_domowe2345.py
2,343
3.875
4
# 2▹ Nie korzystając z funkcji wbudowanej min(), napisz funkcję znajdującą minimalną wartość z 3 liczb. minimum_of(a, b, c). # def minium_of(a,b,c): # if a < b and a <c: # print('A jest najmniejsze') # elif b < a and b <c: # print('B jest najmniejsze') # elif c < a and c <b: # prin...
27f332a1e8b9ef7fff0ee8833633f9e975d89b93
ketanAggarwal58/Python
/assignment/even_no.py
188
3.96875
4
def even_no(n): for x in n: if x%2 == 0: print(str(x)+" is a even no.") else: print(str(x)+" is a odd no.") a = [1,2,3,4,5,6,7,8,9] even_no(a)
e45e3fb214c7923dc588003e1db7b94eb6647557
fujihiraryo/aizu-online-judge
/ITP1/06B_FindingMissingCards.py
222
3.5
4
n = int(input()) cards = [] for i in range(n): m, n = input().split() cards.append((m, int(n))) for m in ["S", "H", "C", "D"]: for n in range(1, 13 + 1): if (m, n) not in cards: print(m, n)
5314ab11bc879968b787433c5d4b51dc1ea787e0
sandeepkumar8713/pythonapps
/21_firstFolder/24_largest_rectangle_in_histogram.py
2,687
3.765625
4
# https://www.geeksforgeeks.org/largest-rectangle-under-histogram/ # https://leetcode.com/problems/largest-rectangle-in-histogram/ # Question : Find the largest rectangular area possible in a given histogram where the largest # rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars #...
45c0d2cca04069ecdc56a71b3ecaa92db6b79b49
sebutz/java-to-python-in-100-steps
/python-code/tips/newshit/tip2_enum.py
420
3.953125
4
# enum # Currency - USD, EUR. INR from enum import Enum class Currency(Enum): USD = 1 EUR = 2 INR = 3 print(Currency.EUR) # iterate for currency in Currency: print(currency) # create print(Currency(1)) # Currency.USD print(Currency.EUR.name) # EUR print(Currency(1).name) # USD print(Currenc...
3c66fb5026ac27fdcb8bad3573a1e151d82fb666
carlosjimz87/PyClean
/Pythonic/looping.py
108
3.84375
4
data = [1, 2, 3, 4, 5, 6, 7, 9] for d in data: print(d) print() for d in reversed(data): print(d)
cf542092ee2eb94ba74cae37ac10547146153219
alchemistwu/dummy_leetcode_solution
/169. Majority Element.py
362
3.515625
4
from typing import List class Solution: def majorityElement(self, nums: List[int]) -> int: count_dict = {} for item in nums: if item not in count_dict.keys(): count_dict[item] = 1 else: count_dict[item] += 1 if count_dict[item] > l...
853f35d10dcc58442c9c1dcdfa6f778eef709bbb
chamod-gamage/CCC-solutions
/2016_J3.py
428
3.6875
4
word = input() palindrome = 0 if len(word)==1: palindrome = 1 for i in range(len(word)): for j in range(min(len(word[:i+1]),len(word[i:]))+1): if word[i-j:i+1] == word[i:i+j+1][::-1] and j*2 + 1 > palindrome: palindrome = j*2 + 1 if i+j < len(word)-1: if word[i-j:i+1] ==...
0fc763feb7150780eb289a35190b372693c15fbd
jaggerkyne/learn_python_the_hard_way
/mystuff/exercise_28/study_drills.py
1,014
4.09375
4
#--coding: utf-8 -- # Another code written by Jagger Kyne # Copyright 2006 - 2014 Jagger Kyne <jagger.kyne@gmail.com> __author__ = 'Jagger Kyne' # 1. There are a lot of operators in Python similar to != and ==. Try to find out as many "equality operators" as you # you can. They should be like < or <= # Comparison Ope...
d4ce92db201ca0bfa202be6633389a7cbc035a80
ChiDojAugust2017/ListType
/List_Type.py
554
4.3125
4
some_list = ['magical unicorns', 19, 'hello', 98.98, 'world'] total = 0 string = '' is_string_only = True is_number_only = True for item in some_list: if type(item) is int or type(item) is float: total += item is_string_only = False elif type(item) is str: string += item + ' ' ...
e06064ef3b562e6ab48272e3b9c00762182f1174
toookah/cs917
/list.py
133
4.21875
4
list=[1,2,3,4,5] print(3) #list1=[x for x in list] list1=list[0:3] print(list1) list2=list[:] print(list2) print('January' in list)
c733316ece4f2f5df6cf4cbfffcbf37ccd9b4c3c
ethan9carpenter/pythonprogramming.net
/practicalMachineLearning/kNearestNeighbors/__init__.py
950
3.640625
4
url = 'https://pythonprogramming.net/k-nearest-neighbors-intro-machine-learning-tutorial/' description = ( """ Classifies a featureset by 'voting' among the k featuresets (k-nearest-neighbors) that are closest to it in a multidimensional space. Does so by taking the euclidian distance (numpy.linalg.nor...
b31fd86f16be5e9f71778178e4884a66bbb61693
sphilmoon/nado
/tkinter/frames/5_listboxes.py
971
3.71875
4
from tkinter import * # opening the GUI window root = Tk() root.title("Nado GUI") root.geometry("640x480") #root.geometry("640x480+300+100") # w x h + x + y coordinants. root.resizable(False, False) # x, y resizable is disabled. listbox = Listbox(root, selectmode = "extended", height = 0) listbox.insert(0, "apples...
44d7b1e3efb916a7dc1f18f5f611ad67519ae6d9
harshadesara/TicTacToeGUI
/tttgui.py
10,850
3.578125
4
import pygame q = pygame.init() display_width = 800 display_height = 600 gameDisplay = pygame.display.set_mode((display_width, display_height)) white = (255, 255, 255) black = (0, 0, 0) red = (200, 0, 0) light_red = (255, 0, 0) green = (34, 177, 76) light_green = (0, 255, 0) yellow = (200, 200, 0) light_yellow = (255,...
997c8a37dd4963c686a79aa3302c7ab66b1e89de
heatherstafford/unit3
/numberGuessingGame.py
363
3.8125
4
#Heather Stafford #2/28/18 #numberGuessingGame.py from random import randint num = randint(1,100) total = 0 while True: guess = int(input('Enter a number between 1 and 100: ')) total = total + 1 if guess == num: print('You got it in', total, 'tries') break elif guess > num: ...
45c015dfefc12dbc08a3e943f6294c6d3a9c3f21
JChemtai123/training101
/indentation.py
155
3.875
4
print("Kisumu") print("Nairobi") equality = len("Nairobi") == len("Kisumu") print(equality) if (equality): print("Kisumu and Nairobi are the same")
571bab3ba3b8897b9b01e73017595736bddfec8d
tlming16/Project_Euler
/python/p004.py
629
3.71875
4
#! /usr/bin/python3 # -*- coding:utf-8 -*- # @author:mathm # @email :tlming16@fudan.edu.cn class solution: def __init__(self): pass def is_palindrome(self,num:int): s=str(num) return s[:]== s[::-1] def get_the_largest_num(self): res=0 for i in range(999,100...
17ef9585ee59944842ef1dbcf9f1b483e1e1478b
aevans1910/coding_interview_prep
/decrypt-message.py
1,748
4.4375
4
"""An infamous gang of cyber criminals named “The Gray Cyber Mob”, which is behind many hacking attacks and drug trafficking, has recently become a target for the FBI. After intercepting some of their messages, which looked like complete nonsense, the agency learned that they indeed encrypt their messages, and studied ...
879f3cd42e208936be49440364ab843dbe045a4f
drshah96/Python-for-Everybody
/1 - Getting Started with Python/Python scripts/function.py
687
3.9375
4
#Basic Function def thing(): print('Hello') print('Fun') thing() print('Zip') thing() #Random Function Program x = 5 print('Hello') def print_lyrics(): print("I'm a lumberjack, and I'm okay") print('i sleep all night and I work all day.') print('Yo') print_lyrics() x = x + 2 print(x) #Greating in D...
73350bf1d37e74053034d7391b67698bcb5bd395
rahulraibit/AlgorithmWithPython
/TreesAndGraphs/FirstCommonAncestor.py
1,182
4.0625
4
#First Common Ancestor: Design an algorithm and write code to find the first #common ancestor #of two nodes in a binary tree. Avoid storing additional nodes in a data #structure. NOTE: This is not #necessarily a binary search tree class Node: def __init__(self, data): self.left = self.right = None ...
de89d87b37c8d703ce8f7f853315f80479cfe2bf
elek/codejam
/codejam/2008/08r1b/crop_triangles/brute_force.sh
798
3.609375
4
#!/usr/bin/python2 def calc_rectangles(points): counter = 0 for a in range(len(points)): for b in range(a+1,len(points)): for c in range(b+1,len(points)): if ((points[a][0] + points[b][0] + points[c][0]) % 3) == 0: if ((points[a][1] + points[b][1] + points[c][1]) % 3) =...
040d90ae202b6ce4d2caf7fbb4d7a93092f5556a
vpc20/leetcode-may-2020
/KClosestPointsToOrigin.py
1,355
3.875
4
# We have a list of points on the plane.Find the K closest points to the origin(0, 0). # # (Here, the distance between two points on a plane is the Euclidean distance.) # # You may return the answer in any order.The answer is guaranteed to be unique(except for the order that it is in.) # # Example 1: # Input: points = ...
98ee6f3fd39936ebbf48f5d257ff881a61fc38ce
molonti/CursoemVideo---Python
/Mundo01/Exercicios/ex005.py
214
4.15625
4
n = int(input('Digite um numero: ')) a = n - 1 s = n + 1 print('o número {}, tem como antecessor {} e o sucessor {}'.format(n, a, s)) print('o número {}, o antecessor {} e o sucessor {}'.format(n, (n-1),(n+1)))
3630307c827bb1b991d26d755170f2ad30532fa0
SentientOrange/Rubiks-Cube
/v2/agent.py
1,468
4.28125
4
# Contains the code base for an agent class that acts on the rubik's cube import cube as c class Agent: def __init__(self, cube): """ Initialize the Agent using the proper parameters The reference to a Rubik's cube must be passed in """ self.cube = cube # All actions are performe...
707936e7e25c2d922213c2979958632de08ac477
mmcd2886/sp500_wikipedia
/wikipedia_cik_ticker.py
1,134
3.765625
4
#!/usr/bin/env python # coding: utf-8 # In[2]: #A script to extract the SP500 table from Wikipedia and convert it to a CSV #conda install -c conda-forge wikipedia import wikipedia as wp import pandas as pd #enter the address for the wikipedia page and save to html variable html = wp.page("List_of_S%26P_500_compani...
6b8190de6e2af2ea2db3a0bf7de9f261d3017193
Toby-Tan/tanjiahao
/python_ck/class/class_11day/ck_11_zy.py
889
3.625
4
import threading import time import queue # goods = [] goods_queue = queue.Queue() class Producer(threading.Thread): def run(self): count = 0 while True: if goods_queue.qsize() < 50: for i in range(200): count += 1 goods = '生产{}...
02245660b40068c1ee097672a19c8538c3157a89
thedern/algorithms
/recursion/fibonachi.py
690
4.40625
4
def fibonacci_iterative(n): a, b = 0, 1 for _ in range(n): # range 0, n, includes lower, excludes upper # variable swap: a = b, b = a + b a, b = b, a + b return a def fibonacci_recursive(n): # base case if n < 2: return n # add two previous terms to get curr...
ba897e673464e6e13e6a25135c7ddecbce59b6c5
ankitk29kothari/Step2success
/Python/2.form_entry_with _id.py
1,596
3.5
4
############################# # # # Step2success.in # # copyright # ############################## # Selenium is used for Gui testing as well as we can use it for web scrapping and web automation to fill up forms in complex sites and tools. #pip install ...
56148360d05086b7e3072969815a760642d8821d
somnadh/numpy-Basics
/sinNcosin.py
491
4.09375
4
# trignometic operations using matplotlib and numpy import numpy as np import matplotlib.pyplot as plt x=np.arange(0,3*np.pi,0.1) print("=========================") n=input("enter which operation do u want\n 1 sin \n 2 cos \n 3 tan") if n=='1': y = np.sin(x) plt.plot(x, y) plt.show() elif...
50173862a66149060bd5e0935773e089997e988a
Sanngeeta/loop
/division_or_not division.py
849
3.8125
4
i=0 while i<=50: if i!=0: print(i) i=i+5 i=0 while i<=50: if i%5==0: print(i) i=i+1 i=1 while i<=100: if i%14==0 and i%7==0: print(i,"Navgurukul") elif i%7==0: print(i,"Nav") elif i%14==0: print(i,"Gurukul") i=i+1 counter=1 while counter...
bac706e581da89ebdd376e4e1dafc85818afb7c0
z727354123/pyCharmTest
/2018-01/01_Jan/08/01-生成器.py
431
4.03125
4
# 定义一个 生成器 # 生成器 表达式 listA = [str(i)+str(a) for i in range(0, 2) for a in range(3, 5) if (a + i)%2 == 0] iterA = (i for i in range(0, 200)) print(listA, type(listA)) print(iterA, type(iterA)) print(next(iterA)) print(next(iterA)) # print(next(iterA)) # StopIteration iterB = iterA.__iter__() print(next(iterB)) print...
537c809b133952aebdb78985f7e864435b1774c8
LionWar22/Lista_de_exercicios
/ex12.py
931
4
4
velocidade = 110 distancia = 640 partida = 20 tempo = distancia/velocidade #CAlcula tempo chegada = partida + tempo #Calcula chegada while (chegada >= 24): #Laço de repetição que sertifica de a chegada estar entre 0 e 23h chegada = (partida + tempo) - 24 #Enquanto a hora de chegada é maior que 24h se subt...
a7d34bf70f9f2add31293177e17b249c29eaad40
icoding2016/study
/PY/leetcode/sum_of_2_ints.py
2,914
3.984375
4
""" 371. Sum of Two Integers Medium Given two integers a and b, return the sum of the two integers without using the operators + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = 2, b = 3 Output: 5 Constraints: -1000 <= a, b <= 1000 """ from utils.testtools import test_fixture class Solution...
c201552c0721bc9ae70bd3f901366e3e37d19276
Granc3k/optical-illusion
/illusion/illusion1.py
558
3.59375
4
from graphics import Canvas CANVAS_WIDTH = 540 CANVAS_HEIGHT = 430 SIZE = 100 GAP = 10 LINES = 4 SQUARES = 5 def main(): canvas = Canvas(CANVAS_WIDTH, CANVAS_HEIGHT) canvas.set_canvas_title("Illusion 1") y1 = 0 for j in range(LINES): x1 = 0 for i in range(SQUARES): y2 = y1...
5be99d18ca80336c442bf82332254ea46e542c80
Wulff-1996/Black_Jack_Python_Exam_Updated
/hand.py
280
3.578125
4
class Hand: def __init__(self): self.cards = [] def add_card(self, card): self.cards.append(card) def __str__(self): hand_string = 'hand: ' for card in self.cards: hand_string += f'{card}, ' return hand_string
cd3d726ce920ad66ae50cc6cf8805899f8d86b54
raviabhiram/Problem-Solving
/Python/valid_palindrome.py
356
3.75
4
""" Author: Abhiram Ravi Bharadwaj Source: Leetcode Problem: https://leetcode.com/problems/valid-palindrome """ def isPalindrome(s): t = [ch.lower() for ch in s if ch.isalnum()] i = 0 while i < len(t) - i - 1: if t[i] != t[len(t) - i - 1]: return False return True def main(): isPalindrome("A man, a plan, a ...
77addbdb52ea393d0bc53d4c6357d57fce795a8c
CodeForFun-r/Competitive-Programming
/codechef/pall01.py
129
3.609375
4
for i in range(int(input())): num = input() if num == num[::-1]: print('wins') else: print('losses')
66c53c91df764239e2c86c1030b895691a631e18
thomasngn673/Python-with-ATBS
/regexNotes.py
8,180
3.984375
4
import re phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') # assigns Regex object to phoneNumRegex # r before \d creates a raw string, which prints all the text following it regardless of char type mo = phoneNumRegex.search('My number is 415-555-4242.') # searches (message) for phoneNumRegex # creates a "match"...
4b49574761a7cbd7daa953615e556ff3ba1bfcda
miltonleal/MAC0110_Introduction_Computer_Science_IME_USP
/Ex. do Paca/Aula 7/P_7.9.py
386
4
4
# Dados N, M > 0 calcular o Mínimo Múltiplo Comum entre N e M def main(): # leia N e M N = int(input("Entre com N: ")) M = int(input("Entre com M: ")) # primeiro candidata a mmc é o próprio N mmc = N # vamos testar todos os múltiplos de N while mmc % M != 0: mmc = mmc + N # imprimir o mmc ...
5ef2f6cd8e3a82a3cf92cbc9f287035f4bcbe05d
DahuK/Learning
/216CombinationSumIII.py
1,478
3.78125
4
''' Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Ensure that numbers within the set are sorted in ascending order. Example 1: Input: k = 3, n = 7 Output: [[1,2,4]] Example 2: Input: ...
dbc4a6ec496e48c255d5766b05c7982c06bec712
goodGopher/HWforTensorPython
/DZ3to09032021/number_of_digits.py
873
4.03125
4
"""Frequency of using digits in the range of numbers.""" def main(): """Print of using digits in the range of numbers.""" print("Введите границы диапазона:") print("Введите первое число: ",end = "") x1 = input() print("Введите второе число: ",end = "") x2 = input() if x1.isdigit() and x2.is...
cac1d8731919d3d79d6f417ebc6657182e870b5b
iwaaaaaaaaaaaaaaag/atCoder
/algorithm/nibun_tansaku.py
455
3.6875
4
search_list = list(range(100)) left_index = 0 right_index = len(search_list) target = 70 i = 0 while True: i += 1 middle_index = (left_index + right_index) // 2 if search_list[middle_index] < target: left_index = middle_index continue elif search_list[middle_index] > target: ...
c273c6401dc5ca94291babb4f923eb9237146b54
Aasthaengg/IBMdataset
/Python_codes/p02400/s107540407.py
91
3.875
4
from math import pi r = float(input()) print (format(r**2*pi, '.6f'),format(r*pi*2, '.6f'))
f8b69b6b50ea0a57362d5d77fad63be88ce22d39
rafaelmorgado/logica-algoritmos
/EstruturaDeDecisao/l2ex23.py
234
4.15625
4
''' 23) Faça um Programa que peça um número e informe se o número é inteiro ou decimal. Dica: utilize uma função de arredondamento. ''' num = float(input("Entre com um número: ")) print("Número arredondado:", round(num, 2))
752d437b5669ec9485063c5e5ab38418d0e82959
IsraelCavalcante58/Python
/Aprendendo Python/exercicios/ex067.py
425
4
4
'''Faça um programa que mostre a tabuada de vários números, um de cada vez, para cada valor digitado pelo usuário. O programa será interrompido quando o número solicitado for negativo''' cont = 0 soma = 0 while True: n = int(input('Quer ver a tabuada de qual número? ')) if n < 0: break for c in ran...
c0bc07faa3d1436eb42ec3c9304a510992e23f37
marioacc/dataStructuresAndAlgorithmsRanceD.Necaise
/structures/array.py
5,477
3.671875
4
#Array ADT import ctypes class Array: def __init__(self, size): assert size > 0 , "Array size must be > 0" self._size=size # Creates the array structure PyArrayType = ctypes.py_object * size self._elements = PyArrayType() self.clear(None); # Return the length of...
eb362b69af7fdba876f902e76a1e4053d0ed9e0e
chyidl/chyidlTutorial
/root/os/DSAA/DataStructuresAndAlgorithms/python/greedy_algorithms_activity_selection_implement.py
2,536
4.09375
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # # greedy_algorithms_activity_selection_implement.py # python # # 🎂"Here's to the crazy ones. The misfits. The rebels. # The troublemakers. The round pegs in the square holes. # The ones who see things differently. They're not found # of rules. And they have no respect ...
8392b12fa83b9f45299b0f2d4ceadc02e0c761eb
summit01singh/Python
/ex38.py
249
4.09375
4
import turtle def draw_triangle(t,sz): """draw a triangle of size sz""" for i in range(3): t.forward(sz) t.left(120) wn = turtle.Screen() wn.bgcolor("green") alex = turtle.Turtle() draw_triangle(alex,150) turtle.mainloop()
6db308baae5ad1acfdabbf0b2472b3cee6196575
EachenKuang/LeetCode
/code/111#Minimum Depth of Binary Tree.py
1,470
3.6875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): # 1 递归,特别需要注意,在计算叶子节点时与maxDepth的区别 def minDepth(self, root): """ :type root: TreeNode :rtype...
631f701902b122c752c60bd54136c96cab2dad4e
Robertren/MyLeetcodePython
/109.Convert-Sorted-List-to-Binary-Search-Tree.py
1,097
3.84375
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class ...
00362f31a7495f96b91ce7f69a13a3832b12d025
Eradch/-2
/4.py
154
3.796875
4
string = input('Ведите слоа через пробелы - ').split() for i, word in enumerate(string, 1): print(f'{i}, {word[:10]}')
25d1aa40b91651dd03e3b417f62931832d6eea57
runt18/demo
/demo.py
854
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Outdated style string formatting print "This is an old-style string formatting %s" % "Test" # Replacement fields not explicitly numbered print "{} is {}".format("life", "hard") # Mutable default argument used def test(a, b=None): if b is None: b = [] pa...
ce6a8748d4c00aae05c4b86c7b92adb739147874
oroV2/company-coding-questions-geeksforgeeks
/Array/Sum of Array.py
1,011
3.9375
4
""" Given an integer array Arr[] of size N. The task is to find sum of it. Example 1: Input: N = 4 Arr[] = {1, 2, 3, 4} Output: 10 Explanation: 1 + 2 + 3 + 4 = 10. Example 2: Input: N = 3 Arr[] = {1, 3, 3} Output: 7 Explanation: 1 + 3 + 3 = 7. Your Task: Complete the function sum() which takes array ...
9b91f038355ec3d9802e1b06cc1806cd5d6d65b0
gangmiss/my_python
/_03python高级编程/_10_01死锁的解决方案.py
881
3.875
4
""" 死锁:两个线程都在等待对方释放锁,结果都没有释放,占用着线程锁 """ from threading import Thread,Lock import time class ThreadA(Thread): def run(self): print("1111111111") time.sleep(1) if ta.acquire(): print("------1--------") if tb.acquire(timeout=2): #非堵塞(看门狗):等它2秒钟,如果占用他的线程还没有释放锁,我就不堵塞在这了...
80540f47e6ac98e7dbcd39c52c57d65e3945004b
yubaoliu/Algorithm
/python/insertion-sort.py
327
4.21875
4
def insertionSort(arr): for i in range(1, len(arr)): key=arr[i] j=i-1 while j>=0 and key<arr[j]: arr[j+1]=arr[j] j-=1 arr[j+1]=key #Driver code to test above arr=[12,11,13,5,6] insertionSort(arr) print("Sorted array is:") print arr for i in range(len(arr)): print("%d" %a...
f744ae0629378a3e372d6ee0d8c81e53cafd47f6
poojithayadavalli/sorting
/k array ele with min difference btwn max and min ele.py
953
3.71875
4
""" Dhruva is facing difficulty in solving the following problem Given an array of n integers and a positive number k. We are allowed to take any k integers from the given array. The task is to find the minimum possible value of the difference between maximum and minimum of K numbers. Input: First line indicates i...
f6da424d82b2935a95458cd29bb7a7c40a0f2cbc
amberhappy/-offer
/25-复杂链表的复制.py
1,655
3.765625
4
#输入一个复杂链表 # (每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点), # 返回结果为复制后复杂链表的head。 # (注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空) # *解题思路: # *1、首先第一步 复制原来的链表,顺次连接形成新链表 # *2、第二步,利用原节点的random指向,来用复制的相应节点的random # *3、最后一步,将复制好的链表拆分出来,或者说将 偶数位的节点重新拆分合成新的链表,得到的就是复制的链表 # -*- coding:utf-8 -*- # class RandomListNode: # d...
989d8d9b4340c6f741150087638f6e83aeaf674c
GhulamMustafaGM/PythonChallenges
/SortedLists.py
2,151
4.3125
4
# Sorted lists numbers num_strings = ['25', '100', '61', '49'] num_ints = [10, 100, 59, 49] num_floats = [2.4, 6.0, 1.245, 0.242857] num_lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # Summary of each list print("\t\tSummary Table") print("\nThe variable num_strings is a " + str(type(num_strings)) + ".") print("It conta...
0d74c821f57891ccf2cff696ab5e1ff18c0b4601
harikaharika/local1
/myexperiments/1even in loop.py
8,052
4.0625
4
# 1.Even and Odd numbers from given number using For & While Loops? # a=int(input('enter a number:')) # for i in range(a): # if i%2==0: # print(i) # else: # pass # print('Odd Numbers:') # i=0 # while i<=a: # if i%2!=0: # print(i) # i+=1 # 2.Biggest & Smallest number in a list us...
6948582050a17c9fad92d1e811ccc3b3bc56fd29
AlexanderPanagyurski/Python-Developing
/07. ListsAndDictionaries/Lists/WhichAreIn.py
212
4.125
4
words = input().split(", ") text = input() new_list = [word for word in words if word in text] print(new_list) # for word in words: # if word in text: # new_list.append(word) print(new_list)
a2f3e9607b8032a2b8fd51a8e8f5efb78d517e48
maulikb-emipro/Python-Training
/taskDatetime.py
1,947
4.1875
4
from datetime import timedelta, date, time, datetime import pytz """ Create Date, Time and Timezone object """ from pytz import timezone d = date(1996, 12, 27) t = time(19, 5, 33) """ Combines date and time object """ dt = datetime.combine(d, t) print(dt) """ Addition in Datetime """ newDate = dt + t...
3efa8955045b9eaeb3315c2b7ad860270fdb9866
mithun2595/1337csol
/44.py
806
3.546875
4
class Solution(object): def isMatch(self, s, p): """ :type s: str :type p: str :rtype: bool """ i=0 j=0 star_p = -1 star_s = -1 while i<len(s): if j<len(p) and (p[j] == '?' or s[i] == p[j]): i = i + 1 ...
2f8e6ae16a375e3d441131929e5d7e0accc79dea
paulmoon/projecteuler
/pe039.py
754
3.515625
4
""" From http://en.wikipedia.org/wiki/Pythagorean_triple, In a Pythagorean triple, m > n, a = m^2 - n^2 b = 2mn c = m^2 + n^2. If p = a + b + c, then p = 2m^2 + 2mn. If the maximum value of p is 1000, then the max value for m is 22 (quadratic formula). """ import fractions import time start = time.clock() array = [0...
d25e062e0b90d58842496f393cc6fc09cbc1a314
skinzy91/MITx-6.00.1x-2
/week_5/pset_5/problem_4.py
530
3.78125
4
# Problem 4 - Decrypt a Story # Now that you have all the pieces to the puzzle, please use them to decode the file story.txt. # The file ps6.py contains a helper function get_story_string() that returns the encrypted version of the story as a string. # Create a CiphertextMessage object using the story string and use d...
6e4cf712479b32fccb53698e868c1f2d882e9d81
NicsonMartinez/The-Tech-Academy-Basic-Python-Projects
/Python File Input-Output/Directory Drill.py
1,703
3.640625
4
# DRILL: # Drill Description: # For this drill, you will need to write a script that will check a specific folder on the hard drive, # verify whether those files end with a “.txt” file extension and if they do, print those qualifying # file names and their corresponding modified time-stamps to the console. # # Requirem...
befb4afac0255b303f5c76b71676d99f32da1375
avilesdiana/GooglePython
/Loops.py
10,854
4.375
4
#WEEK 3 #Exercise by Diana Aviles print("\n Introduction to loops\n") #Anatomy of a While Loop """ x=0 while x < 5: print("Not there yet, x=" + str(x)) x = x + 1 print("x = " + str(x)) """ # More while loop Examples """ def attempts(n): x = 1 while x <= n: print("Attempt " + str(x)) x...
cad47aa656d283a2caee441a0e4c00cf3a768005
nkukarl/leetcode
/5.1.12 Populating Next Right Pointers in Each Node.py
814
3.5625
4
class TreeLinkNode: def __init__(self, val): self.val = val self.left, self.right = None, None self.next = None class Solution: def connect(self, root): node = root while node: tmp = None cur = None while node: if not ...
535ea348c83ec4137909c50343fbbb3cdf9919aa
athenanv/6034artificialintelligence
/lab5_Bayes and Graphs/lab5.py
9,220
3.59375
4
# MIT 6.034 Lab 5: Bayesian Inference # Written by 6.034 staff from nets import * #### Part 1: Warm-up; Ancestors, Descendents, and Non-descendents ############## def get_ancestors(net, var): "Return a set containing the ancestors of var" parents = list(net.get_parents(var)) ancestors = [] whil...
742ba1794892db9923e442dd92b020dcbe5eaecd
yura-seredyuk/ItStep
/ITS #15/LESSON/sort_obj.py
189
3.6875
4
class Kitty: def __init__(self, name, age): self._name = name self._age = age print("Meow!") def __lt__(self, other): return self._age < other._age
7b173c18f849cf87229ac39ad0073292e5767598
fahadaleem/Python-Basics
/input.py
337
4.28125
4
## taking user input with 'input()' function name = input("What is your name? ") print("Hi "+ name) # Exercise ## Ask two questions: person's name and favourite color, and print the message like Fahad Likes Green full_name = input("What is your full name? ") color = input("What's your favourite color? ") print(name...
325639886bc52d8fe2d7b4cc3ae4fb78f8ad5227
sapog15/sonia-zaychenko
/eeeeee.py
279
3.765625
4
cars = ["Audi", "BMW", "Porsche"] print(cars[0]) print(len(cars)) cars.append("Tesla") print(cars) #6 a=["Audi R8 e tron", "Mercedes Benz gle 400", "Tesla Model S"] b=["Лада Калина", "Запорожець"] if len(a)>len(b): print("Олексій") elif len(b)>len(a): print("Олег")
af2c9ce260480bc7b28fd48f5ca95ab3ced6dc6c
BoringRicky/python_test
/notes-lxf/func_params_test.py
1,717
3.953125
4
def calc(*numbers): sum = 0 for i in numbers: sum+=i return sum #将 list或者tuple 当做 可变参数,需要在前面添加一个 * print(calc(*[1,2,3,4,5])) extra={'gender':'F','city':'Beijing'} #如果传入一个dict,只会传入dict的拷贝,不会影响原dict的内容 def person(name,age,**kw): print('name:',name,'age:',age,'other:',kw) person('Ricky',28) pers...
869c594b346dc25d521cc8b1e3b413b1ef621b7d
saurabh-pandey/AlgoAndDS
/leetcode/dp/max_profit.py
1,198
4.0625
4
#URL: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ #Description """ You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Ret...
a1d42db565367d6acb9b7d530bb3a3cc103ea12e
ntkjer/ds-algos
/searching/symbol_tables/sequenital_search_st/sequential_search_symbol_table.py
1,143
3.859375
4
class Node(object): def __init__(self, key=None, value=None, next=None): self.key = key self.value = value self.next = next class SequentialSearchST(object): def __init__(self, first=None): self.first = first def get(self, key): current = self.first ...
62166736e48c1f390517af98c66694618a1fd3c1
Mahrjose/BRACU-CSE110
/Assignment 04/Problem 09.py
192
3.84375
4
print( [ num for num in [ int(num) for num in input("Enter 10 numbers separated by comma(,):").split(",") ] if num % 2 != 0 ] )
2098a6e928d1279b7793deafc83fb99c378899e3
RamnathShanbhag/APS-2020
/string_construction.py
452
4.15625
4
#Amanda has a string of lowercase letters that she wants to copy to a new string. She can perform the following operations with the given costs. She can perform them any number of times to construct a new string : p # 1)Append a character to the end of string p at a cost of 1 dollar. # 2)Choose any substring of p and a...
cba45c4548f5728a0de3b0348322523bee6065eb
wilsoncgj/A-Beginners-Guide-To-Python
/A Beginners Guide To Python/strings_templates.py
924
3.9375
4
import string # Initialise the template with ¢variables that # will be substitute with actual values template = string.Template('$artist sang $song in $year') print(template.substitute(artist='Freddie Mercury', song='The Great Pretender', year=1987)) import string # Initialise the template with $variables that # will ...
e4c5bec16bc57a5cd391675acc7dd1637690757b
zjy-T/Codewars
/[6 Kyu] Find the Unique Number.py
911
4.09375
4
#There is an array with some numbers. All numbers are equal except for one. Try to find it! def find_uniq(arr): # Sort the array arr.sort() n = len(arr) # Check for first element if arr[0] != arr[1]: return arr[0] # Check for all the elements # if it is different its # adj...
e601fac19cbe5d3619dcd1c2ce4cba75b9f507aa
liuyajune/runoob
/exec97.py
509
3.59375
4
#/usr/bin/env python #-*- coding:utf-8 -*- ''' 题目:从键盘输入一些字符,逐个把它们送到磁盘上去,直到输入一个#为止。 程序分析:无。 重点: while 循环使用, 标准输入输: stdin,stdout sys模块的使用 stdout.write 输出到屏幕 ''' from sys import stdout #fileName = input('input filename:') with open('test97.txt', 'w') as f1: ch = input("input char") while (ch != '#'): f...