blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
35bf85148409f47defc9f69624803cc4c4bef288 | Hidenver2016/Leetcode | /Python3.6/958-Py3-M-Check Completeness of a Binary Tree.py | 1,545 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 4 11:13:47 2020
@author: hjiang
"""
"""
Given a binary tree, determine if it is a complete binary tree.
Definition of a complete binary tree from Wikipedia:
In a complete binary tree every level, except possibly the last, is completely filled,
and all node... |
bb3fd152c933e99881888cda2313b64dd2c54894 | EmersonAires/Introducao_a_ciencia_da_computacao_com_Python | /Exercicios_Resolvidos/Parte 1/Semana 6/NIM.py | 3,381 | 4.0625 | 4 | def main():
print("Bem-vindo ao jogo do NIM! Escolha:")
print("1- para jogar uma partida isolada")
print("2- para jogar um campeonato")
modalidade = input("Escolha a modalidade")
teste_modalidade = True
while teste_modalidade:
if modalidade == "1":
teste_modalidade ... |
5d696ea348ea27bc01f53cd7d7fa6fae9b957044 | conanhjj/Cirrus | /src/s3_sample.py | 914 | 3.5 | 4 | import boto
from boto.s3.key import Key
s3 = boto.connect_s3()
bucket_name = "example_bucketadffdks"
bucket = s3.get_bucket(bucket_name)
bucket = s3.create_bucket('iffqjlc6prsf6ieehycjc7jvfu======')
k = Key(bucket)
# put an object (key, content) to the bucket
k.key = '1'
k.set_contents_from_string('Hello World!')
k... |
1bf56f087a9de630cf765f896271ca9b012eb0e7 | rishinkaku/advanced_python | /decorators/decorators_p1.py | 905 | 4.21875 | 4 | """
Декораторы — это, по сути, просто своеобразные «обёртки», которые дают нам возможность делать что-либо до и после того,
что сделает декорируемая функция, не изменяя её.
"""
def my_new_decorator(func_to_decorate):
def wrapper_around_original_function():
print("I'm code which works before original funct... |
5cbd5feb5ce038f0e7f21a68e67566a870d5b3ef | derrickweiruluo/OptimizedLeetcode-1 | /LeetcodeNew/python/LC_329.py | 2,046 | 4 | 4 |
"""
Given an integer matrix, find the length of the longest increasing path.
From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-around is not allowed).
Example 1:
Input: nums =
[
[9,9,4],
[6,6,8],
[2,1,1]
]
Ou... |
a181823661735b0498e7e233960a01eb57135271 | wanony/fun_algos | /symmetric_tree.py | 417 | 3.859375 | 4 |
# check if a binary tree is symmetric
def solution(root_node):
def is_mirror(tree_1, tree_2):
if tree_1 == None and tree_2 == None:
return True
if tree_1 == None or tree_2 == None:
return False
return (tree_1.val == tree_2.val) and is_mirror(tree_1.left, t... |
697c9b82d04105920961bca4a8d47daa68967e06 | beerfleet/udemy_tutorial | /Oefeningen/uDemy/bootcamp/043_read_csv.py | 1,638 | 3.625 | 4 | from functools import wraps
from csv import reader, DictReader
def try_function(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
print(f"********** {fn.__name__} ***********")
resultaat = fn(*args, **kwargs)
print(f"\n")
return resultaat
return wrapper
@try_function
def do_n... |
3fe7709ed267cc40cdfcea4ce60e3c1a8a9702e2 | bertrandmoulard/cs-learning | /01-BigO/merge_sort.py | 747 | 3.640625 | 4 | def merge_sort(a):
if len(a) > 1:
left = merge_sort(a[0:len(a)/2])
right = merge_sort(a[len(a)/2:])
i = 0
j = 0
k = 0
while i < len(left) and j < len(right):
if left[i] < right[j]:
a[k] = left[i]
i += 1
else:
a[k] = right[j]
j += 1
k += 1
w... |
5cd8d88b95caeb2b3f890c8eb8a699834a1cecff | Catherinesjkim/Graphs | /projects/ancestor/ancestor.py | 5,048 | 3.5 | 4 | """
Similar to destination city problem
Key:Value
Parent:Child
Source vertex: find the earliest ancestor
Understand
```
10
/
1 2 4 11
\ / / \ /
3 5 8
\ / \ \
6 7 9
```
Example Input: [(1, 3), (2, 3), (3, 6)]
Starting node: 6
output: 1 (1 and 2 are tied but 1 has a lower id)
starting no... |
58673907a3e3e688791dbce3bd4e3db11f4eda1e | vinny0965/phyton | /1P/meuprojeto/Atividades 1VA/Funções/05.py | 69 | 3.625 | 4 | def reverso(n):
inverte=int(input("n"))
print (inverte[::-1]) |
bbd210655ea9908ba1ac0f4373509817b77a3319 | parhamgh2020/kattis | /Hissing Microphone.py | 169 | 3.90625 | 4 | word = input()
for i in range(len(word)-1):
if word[i] == 's':
if word[i + 1] == 's':
print('hiss')
break
else:
print('no hiss')
|
7d2f0a3d3bb04cd7dc54f38fa42787e9bfbb4c88 | thestrawberryqueen/python | /2_intermediate/chapter13/practice/lexicographical_vector.py | 454 | 3.921875 | 4 | """
Reimplement the __lt__ and __gt__ in the given Vector
class(the one in this section) so that we are comparing
the vector's contents based on lexicographical ordering.
Think of lexicographical ordering as how you arrange words
in a dictionary. For instance, by lexicographical ordering,
'a' < 'ab', 'ab' < 'ad', 'bcd... |
33a8c90f4f3d9b85f7f696f25fc12c4e64c179bb | christian-oudard/project_euler | /058.py | 892 | 3.65625 | 4 | from utility import up_to, is_prime
def spiral_corners():
"""
37 36 35 34 33 32 31
38 17 16 15 14 13 30
39 18 5 4 3 12 29
40 19 6 1 2 11 28
41 20 7 8 9 10 27
42 21 22 23 24 25 26
43 44 45 46 47 48 49
>>> import itertools
>>> list(itertools.islice(spiral_corners(), 4))
... |
fbc166e7368e4dd5d470ac139d2937e9b89553ad | felhix/cours-python | /semaine-2/01-strings.py | 2,243 | 3.671875 | 4 | #! python3
# 01-strings.py - quelques fonctions pour jouer avec les strings
# On peut commencer et finir un string par des guillemets ou des apostrophes
string_1 = "C'est un string"
string_2 = 'Il dit : "string là aussi"'
# les caractères d'échappement (escape characters) permettent de rentrer des caractères impossob... |
12ffd6c5318eeca84c374eb29026a1cc89b03bf6 | AlexandrDorosh/Python_lesson | /Lesson_1/start.py | 2,058 | 4 | 4 | import random
# a = 10 # int
# print(a, type (a))
# a = 10.6 # float
# print(a, type (a))
# a = True # bool
# print(a, type (a))
# a = "Bill" # str
# print(a, type (a))
# name = input("Your name: ")
# age = int(input("Your age: "))
# print(name, type(name))
# print(age, type(age))
# a = int(input("Number 1: "))
# ... |
e7be8780428934ae636830324a6d1959b6483455 | berkcangumusisik/CourseBuddiesPython101 | /Pratik Problemler/14 - String Loops/04 - vowelCount.py | 403 | 4.03125 | 4 | """
Ünlü Sayısı
Belirli bir dizedeki küçük sesli harflerin ( a, e, i, o, ve u) sayısını sayacak bir işlev yazın .
"""
def isVowel(ch):
return ch in ['a', 'e', 'i', 'o', 'u']
def count_vowels(str):
str.lower()
count = 0
for i in range(len(str)):
if isVowel(str[i]):
count += 1
... |
366e26b04348cc04d38f5dbbe59d3b1095444629 | peter6468/sautine | /Python Tutorial/files.py | 567 | 3.84375 | 4 | #python has functions for crud
# open a file
#this creates a file even if it doesnt exist
myFile =open('myfile.txt', 'w')
#get some info
print('Name: ', myFile.name)
print('Is closed: ', myFile.closed)
print('Opening Mode: ', myFile.mode)
#write to file
myFile.write('I love python')
myFile.write(' and javascript')
m... |
622dd9470bd87125382eb791daabfda11b528a75 | EffectoftheMind/Python-A-Excersizes | /states_list_test.py | 679 | 4.03125 | 4 | # Create a mapping of state to abbreviation
states = {'Oregon': 'OR',
'Florida': 'FL',
'California': 'CA',
'New York': 'NY',
'Michigan': 'MI',
'Oklahoma': 'OK',
'Texas': 'TX'}
cities = {'CA': 'San Francisco',
'MI': 'Detroit',
'F... |
0525dd0bac8c9c0afc5910a9251e0c53df34b350 | bpandola/advent-of-code | /2016/day_03.py | 1,024 | 3.953125 | 4 | def count_possible_triangles(triangle_specs):
count = 0
for side_lengths in triangle_specs:
if side_lengths[0] + side_lengths[1] > side_lengths[2]:
if side_lengths[0] + side_lengths[2] > side_lengths[1]:
if side_lengths[2] + side_lengths[1] > side_lengths[0]:
... |
9e6b68fb2a7c64e3b69c93ec3573f2937c50d639 | mukund7296/python-3.7-practice-codes | /swap.py | 1,122 | 3.859375 | 4 |
def clean_text(s: str) -> str:
'''replace a, b, c characters with asterisk - *'''
temp=[]
for i in s:
if i=="a" or i=="b" or i=="c":
temp.append("*")
else:
temp.append(i)
print("".join(temp))
s = 'string sample'
# clean_text(s) == 'string s*mpl... |
4a07dd4185b567f486ed2b9ce88a158316b67423 | henrikkurkela/iot-course | /week-1/numpy-exercise-3.py | 242 | 4.09375 | 4 | # 3. Write a NumPy program to create an array with the values 1, 7, 13, 105 and determine the size of the memory occupied by the array.
import numpy
array = numpy.array([1, 7, 13, 105])
print('Array memory size: ', array.nbytes, ' bytes')
|
3af72ba7d8be64d49053c8fe34893db9fd13279d | sAnjali12/More_exercises | /More_exercises8.py | 259 | 3.703125 | 4 | list1 = [1, 5, 10, 12, 16, 20]
list2 = [1, 2, 10, 13, 16]
list3=list1+list2
index1=0
new_list = []
while index1<len(list3):
if list3[index1] not in new_list:
new_list.append(list3[index1])
index1 = index1+1
new_list.sort()
print new_list
|
a575d1453ca5d5ddf1ec3b7e44c3a26882518666 | hiyorineko/python_AOJ | /ITP1_8_C.py | 700 | 3.640625 | 4 | # 文字のカウント
#
# 与えられた英文に含まれる、各アルファベットの数を数えるプログラムを作成して下さい。 なお、小文字と大文字は区別しません。
#
# Input
# 複数の行にまたがる1つの英文が与えられます。
#
# Output
# 与えられた英文に含まれる各アルファベットの数を以下に示す形式で出力して下さい:
#
# a : aの個数
# b : bの個数
# c : cの個数
# .
# .
# z : zの個数
# Constraints
# 英文が含む文字の数 < 1200
import sys
alph = list("abcdefghijklmnopqrstuvwxyz")
sentence = li... |
f1ee8f0b64137ac62aa1a5b4a7208744bfcd6827 | fashioncrazy9/HackBulgaria_0 | /Week_5/magic.py | 341 | 3.671875 | 4 | #NOT READY -> return to finish
def sum_list(items):
result = 0
for item in items:
result+= item
return result
#print(sum_list([2,0,2]))
def magic_square(square):
is_magic = False
value = sum_list(square[0][0])
index = 0
for row in square:
for item in row:
pas... |
c36f900ec09721bcfe5c732810da4846dc382d0a | AdirB100/Pre-Academic-Scripts | /caesar_cipher.py | 605 | 3.75 | 4 | def caesar_encrypt(plaintext, k):
def encrypt_let(char, n):
if ord(char) not in range(97, 123):
return char
if n >= 0:
n = n % 26
else:
n = -((-n) % 26)
num_char_ord = ord(char) + n
if num_char_ord in range(97, 123):
return chr(... |
210740ed5a634c7800f4a52ee49d9b081fab99b4 | hydrahs/golden_mine | /exercise_1.py | 234 | 4.0625 | 4 |
def myFunction(str):
array = list(str)
array_1 = array.reverse
if (array==array_1):
return True
else:
return False
print(myFunction(str = "dsfasdf"))
""" str.join(array.reverse)
print(str) """ |
bcae120da9e1984e37861b6108c9e4d8be615b2d | ZESop/PythonTest-zesop- | /noob/ReturnFn.py | 1,136 | 3.53125 | 4 | from math import sqrt
# def lazy_sum(*args):
# def sum():
# ax = 0
# for n in args:
# ax = ax + n
# return ax
# return sum
# f = lazy_sum(1,3,5,7,9)
# f1 = lazy_sum(4,8,1,4)
# print(f()+f1())
# 1、2、3的平方和
# def count():
# def f(j):
# def g():
# ... |
a289003083c2eaac28626b36fe7857927dceee0d | DustinYook/COURSE_COMPUTER-ENGINEERING-INTRODUCTION | /PythonWS/Chapter6/test0705_1.py | 918 | 3.9375 | 4 | # 프로그램 목적: 반복문 기초학습
# 1) range(시작, 끝, 간격) -> '시작'이상, '끝'미만, '간격'단위증가
for i in range(3):
print('방문을 환영합니다!')
# 2) in [리스트] -> 리스트의 모든 내용을 출력
for i in ['강아지', '고양이', '망아지', '송아지']:
print(i)
for i in [3, 2, 1]: # 3부터 1까지 거꾸로 출력
print(i) # 출력결과: 3 2 1
# 주의) C 언어의 for(i=3, i>0; i--)와 같은 표현
for i in range(3... |
ae029dee8a516c0057556291c424764d55c323b4 | mindjiver/Euler | /python/problem06.py | 353 | 3.796875 | 4 | #!/usr/bin/env python
def sum_squares(num):
sum = 0
i = 0
while(i<=num):
sum += (i*i)
i += 1
return sum
def square_sum(num):
s = sum(range(1, num+1))
prod = s * s
return prod
num = 10000000
s_sq = sum_squares(num)
sq_s = square_sum(num)
print str(sq_s) + " - " + str(... |
2ced76aeba735e8bb7c749893b25660b771c5a36 | fumster12/week2 | /solution_5.py | 333 | 4 | 4 | # solution_5.py
# by Funmi Dosunmu 1/20/15
# Prime determination
def main():
n = int(input("Enter a whole number: "))
if n < 2:
break
if n > 2 and n % 2 ==0
break
if n > 2 and
if n == prime:
print("The whole number is a prime number")
else:
... |
5e59e44bed33343eb7d12cc4caf42eb0f41d2b9d | silpapravin/Library | /user_menu.py | 1,941 | 3.515625 | 4 | from util import Util
from search import Search
#from datastore import book_list
from datastore import Datastore
class UserMenu():
def display_user_menu(self, user, datastore):
Util.clear_screen()
print(f"Welcome to the library {user.name}, Menu options:")
print("1. Search a book")
... |
3fc03a8c78358354fc154e163d82e7d2c9d839b2 | dan-sf/leetcode | /length_non_dup_sorted_array.py | 1,116 | 3.71875 | 4 | """ Problem statement: https://leetcode.com/problems/remove-duplicates-from-sorted-array/ """
class Solution(object):
def removeDuplicates(self, nums):
"""
Technically this solution isn't fully correct because I am storing the
values to delete. I missed the part of the question that says "I... |
a5f017acd9e7c6ca7b2bde7e5ead0eef8171c163 | nathanridding/advent-of-code-2020 | /day1/report_repair.py | 712 | 3.5625 | 4 | with open('/home/nathan/adventofcode20/day1/data.txt') as f:
data = f.read().splitlines()
#print(data)
test = ['444', '1721', '979', '366', '299', '675', '1456']
def find2nums(data):
for i in range(len(data)):
for j in range(i + 1, len(data)):
if int(data[i]) + int(data[j]) == 2020:
... |
dbe662865f787a44a4cfa76a0429948da9cb9be3 | Varun-JP/python-stuff | /input_avg.py | 1,084 | 3.84375 | 4 | # #basic
# a=35
# a=42
# print(a)
# #basic (again)
# a=input("enter your name")
# print(a)
# # avg of two numbers
# a=input("input first number;")
... |
fa511e6faee16fd1cc666034c69587e40b862737 | Barracudakun/pythonProject_class1 | /class6. Loop/2. For loop.py | 631 | 3.640625 | 4 | # -*- coding = utf-8 -*-
# @Time: 6/19/21 6:28 PM
# @Author: YAO
# @File: 2. For loop.py
# @Software: PyCharm
'''
for 循环
语法:
for 临时变量 in 序列:
重复执行的代码 1
重复执行的代码 2
... ...
str1 = "hello world"
for i in str1:
print(i)
'''
# # break
# str1 = "hello world"
# for i in str1:
# if i == 'o':
# break... |
dc26f90439228ef4a45c9a962717d009a9118d62 | nameofline/CP3-Thanakorn-Jeanusavawong | /assignments/Lecture71_Thanakorn_J.py | 542 | 3.8125 | 4 | def showBill():
print("Myfood".center(10,"-"))
for i in range(len(menuList)):
print(menuList[i],priceList[i])
total = 0
for price in priceList:
total += price
print("total :",total)
menuList = []
priceList = []
while True:
menuName = input("Please Enter Men... |
2493fa829ff7f3d612690d9771d5840b5d9af919 | rootAir/selenium-python | /python-intro/methods_list.py | 293 | 3.828125 | 4 | x = [1, 2, 3]
x.append(4) #Fila
print(f'Valor do append: {x}')
x.insert(4, 0) #Lista
print(f'Valor do insert: {x}')
x.count(2)
print(f'Valor do count: {x}')
x.remove(2)
print(f'Valor do remove: {x}')
x.pop() #Pilha
print(f'Valor do Pop: {x}')
x.reverse()
print(f'Valor do Reverse: {x}')
|
0900136817c2422e1d344a3ac619072b3d40e85d | congyingTech/Basic-Algorithm | /old-leetcode/Tree/BuildTree.py | 1,293 | 3.8125 | 4 | class TreeNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def buildTree(nums1, nums2):
root = TreeNode(nums1[0])
n = len(nums2)
m = len(nums1)
if n == 0 and m == 0: # 当两者都为0的时候停止递归
return None
indInNums2 = nums2.index(nums... |
02049234b0963fa06cc5fbafc01a81c534628ae3 | b02902131/LeetCodePython | /solutions/56/56.py | 472 | 3.6875 | 4 | class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
result = []
intervals.sort()
for interval in intervals:
if len(result) == 0 or interval[0] > result[-1][1]:
result.append(interval)
else:
# result[-1] = [re... |
33eeef480d2b8c4dde48cf75a3b0a6044bb725ad | SaikumarReddySandannagari/Binary-Search-1 | /target_unboundedarray.py | 503 | 3.546875 | 4 | class Solution:
def search(self, reader, target):
if(reader.get(0)==target):
return 0
left=0
right=1
while(reader.get(right)<target):
left=right
right*=2
while(left<=right):
mid=left+((right-left)>>1)
pivot=reader.ge... |
7e42700aaaae1fc5f8d2e8f0f0e934fa5ef919c8 | Code-Khan/SquaredStrings | /squstr.py | 1,959 | 3.96875 | 4 | # This kata is the first of a sequence of four about "Squared Strings".
# You are given a string of n lines, each substring being n characters long: For example:
# s = "abcd\nefgh\nijkl\nmnop"
# We will study some transformations of this square of strings.
# Vertical mirror: vert_mirror (or vertMirror or vert-mirro... |
87a33f2be084abd00a533342655162f55c3de3a6 | heshibo1994/leetcode-python-2 | /233. 数字 1 的个数.py | 677 | 3.890625 | 4 | # 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。
#
# 示例:
#
# 输入: 13
# 输出: 6
# 解释: 数字 1 出现在以下数字中: 1, 10, 11, 12, 13 。
#
# 来源:力扣(LeetCode)
# 链接:https://leetcode-cn.com/problems/number-of-digit-one
# 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
# class Solution(object):
# def countDigitOne(self, n):
# """
# :type n: int
... |
92c17ba0f55dd0f68a5cffd4691b78d213cd15f4 | heroca/heroca | /ejercicio56.py | 339 | 3.890625 | 4 | """
Realizar un programa que solicite la carga de valores enteros
por teclado y los sume. Finalizar la carga al ingresar el valor -1.
"""
valor = 0
acum = 0
while valor != -1:
valor = int(input('valor: '))
if valor > 0:
acum = acum + valor
print('Suma de los valores')
#Imprime el contenido de la variab... |
bdb0feed5c510e57f9cd43a545cc3277a3e8786d | Degelzhao/python | /in_output/input_output.py | 269 | 3.890625 | 4 | # input/output exercises
str1 = input('please input num1: ')
num1 = int(str1)
str2 = input('please input num2: ')
num2 = int(str2)
print('sum: %d + %d = %d'%(num1,num2,num1 + num2))
#tips:当你使用input()时,获取的内容都是str(字符串)类型。 |
85a26045a4935e2f21754e65d8a954ffd2dddf49 | msps9341012/leetcode | /linkedlist/reorderList.py | 1,459 | 3.921875 | 4 | from linkedlist import SingleLinkedList,ListNode
'''
def reorderList(head):
if head==None:
return None
length=0
node=head
while node.next:
node=node.next
length=length+1
fast=head
slow=head
dummy=ListNode(0)
node=dummy
while length>0:
for i in ran... |
0776f0b92a844863da798f0440e7e4477ff2dc88 | jguarni/Python-Labs-Project | /Lab 4/prob7.py | 943 | 3.859375 | 4 | from cisc106 import *
from random import *
def blackjack():
ans = 'yes'
uhand = 0
while (ans == 'yes'):
unumber = randrange(1,11)
print('Your card is',unumber)
uhand = uhand + unumber
print('Your total is',uhand)
if (uhand > 21):
print('You went over 21!'... |
cdcfcb07681818ea46380c89d0f987885c04ffb6 | mzhuang1/kiribati | /combinations.py | 2,530 | 3.75 | 4 | #! /usr/bin/env python
# http://code.activestate.com/recipes/190465/
"""xpermutations.py
Generators for calculating a) the permutations of a sequence and
b) the combinations and selections of a number of elements from a
sequence. Uses Python 2.2 generators.
Similar solutions found also in comp.lang.python
Keywords: ... |
81124c92ef3e9792e70cfbaadf0a2c0e80bf38e3 | lazypandaa/Eswar30 | /python new/23.py | 910 | 3.765625 | 4 | # ============map function===========
number = ["3","34","64"]
number = list(map(int, number))
# for i in range(len(number)):
# number[i] = int(number[i])
number[2] = number[2]+1
print(number[2])
def sq(a):
return a*a
num= [2,3,5,6,76,3,3,2]
square = list(map(sq, num))
print(square)
# Using ... |
86bf379457bb15ffe0e26224569b602b143f5bec | maniero/SOpt | /Python/Collection/Counter.py | 162 | 3.5 | 4 | import collections
numeros = [5, 3, 1, 2, 3, 4, 5, 5, 5]
repetidos = collections.Counter(numeros)
print(repetidos[5])
#https://pt.stackoverflow.com/q/176255/101
|
91d4ba9d9c6dbc08004cda806eeba92daf6da2c0 | Liang-WenYan/Python-Crash-Course | /Chapter7_10.py | 496 | 4.03125 | 4 | places = {}
active = True
while active:
name = input("\nInput your name: ")
place = input("\nIf you could visit one place in the world,where would you go? ")
places[name] = place
repeat = input("\nWould you like to let another person to respond? Input 'no' or 'yes' : ")
if repeat == 'no':
a... |
8afb7667eba0e92c9937a1484512ab0ad9073d1a | evanwike/CS-458 | /HW4/Selenium/main.py | 1,529 | 3.59375 | 4 | from selenium import webdriver
# Opens a new Chrome browser
browser = webdriver.Chrome()
# Navigates to Amazon.com
browser.get('https://www.amazon.com')
# Selects the search bar element by its HTML id
nav = browser.find_element_by_id('twotabsearchtextbox')
# Selects the search button by its tag and class (CSS selecto... |
e6a1307e8697f4d2007ec98a043d75284bc34220 | bruno-victor32/Curso-de-Python---Mundo-1-Fundamentos | /ex08.py | 441 | 4.125 | 4 | #Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros
metros = float(input('Digite o valor a ser convertido em metros: '))
cm = metros * 100
mm = metros * 1000
km = metros / 1000
hm = metros / 100
dam = metros / 10
dm = metros * 10
print('O valor em metros é {}m, em cm {:.0f... |
de14270dcd574866bcd2078f2b0901f6bbe65875 | Timsnky/challenges | /locksmith/locksmith.py | 3,199 | 3.515625 | 4 | # https://app.codesignal.com/challenge/Dfq9AGTczotsS9hqF
class Locksmith:
def __init__(self, itemCount, initialState):
self.itemCount = itemCount
self.initialState = initialState
self.sortedState = self.sortAndReduce()
def sortAndReduce(self):
return list(set(self.initialState... |
f25f8f336819d423f5d345ed51f26b0ef801b133 | Tarun-Sharma9168/Python-Programming | /Evenalltheway.py | 291 | 3.9375 | 4 | def get_only_evens(nums):
new_list=[]
for i in range(len(nums)):
if(i%2 == 0 and nums[i]%2==0):
new_list.append(nums[i])
return new_list
print(get_only_evens([1, 3, 2, 6, 4, 8]))
print(get_only_evens([0, 1, 2, 3, 4]))
print(get_only_evens([1, 2, 3, 4, 5]) ) |
74070ebd178c0fc56e7988307d235db907fb0d8b | byron8899/Python-Projects-and-Practice | /saveironman.py | 824 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 10 17:27:12 2018
@author: byron
"""
'''
Jarvis is weak in computing palindromes for Alphanumeric characters.
While Ironman is busy fighting Thanos, he needs to activate sonic punch
but Jarvis is stuck in computing palindromes.
'''
# Task: Write a program that c... |
3b9f91900d888bd3b42d232f3216c76fe491c304 | jcallejas/learning-python | /basicos/02.py | 219 | 4.125 | 4 | '''
Nombre: Ejercicio 02
Creador: Juan Callejas
'''
a = int(input("Ingrese un primer numero: "))
b = int(input("Ingrese un segundo numero: "))
result = ((3+5*8)<3 and (-6/3*4)+2<2) or (a>b)
print(f"El resultado es:{result}") |
8588cc999d51664cfc37ddcfbf1a34007e5f59da | fedebrest/curso_python | /Resoluciones/TP 2/positivo.py | 185 | 4.09375 | 4 | x=int(input("ingrese un numero positivo: "))
while (x<0):
print(x,"no es positivo!!")
x=int(input("ingrese un numero positivo: "))
print(x, "si es un numero positivo")
|
971b46a614bb2c8f506611c8a43ceb84bc0b77c7 | dykim822/Python | /ch08/person1.py | 1,180 | 3.96875 | 4 | # 객체지향언어의 특정 => 다형성
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def prn(self):
print("===================")
print(f"이름 : {self.name}")
print(f"나이 : {self.age}")
class Student(Person):
def __init__(self, name, age, hobby):
super... |
41506225bf9fcc5dad101e85db6fa322d16e8467 | soundrapandian/python-training | /1-guess/reverse_guess.py | 640 | 4 | 4 | # Think of a number between 0 and 99. Then write a python program
# to guess the number you have thought of
import random
print ("I have guessed a number")
min_range = 0
max_range = 99
guess = random.randint(min_range, max_range)
while True:
answer = input("Is it {} [(y)es/(h)igher/(l)ower]:".format(guess))
... |
3af3ecfed6ecddecc46c21ef734c207b6f57aef1 | nehiwo/DataStruct-by-Python | /MyStack1.py | 1,423 | 3.8125 | 4 | #stack ver Array
class MyStack:
def __init__(self, size):
self.size = size
self.arr = [-1] * size
self.top = -1
def is_empty(self):
if self.top == -1:
return True
else:
return False
def push(self, val):
if self.top == self.size - 1:
... |
753fd551a5889b6ced7a1508c9e28c26b476088b | kking7714/CitySlip_2 | /nathan_functions.py | 1,929 | 3.546875 | 4 | # Dependencies
import requests as req
import json
import zipcodes
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import http.client
from datetime import datetime
import time as time
import csv
# Use the google API to get a list of points of interest
def barfinder(lat, lng):
# Google API Ke... |
cdedd3e52fa2044e7e0a443478be0dcf00db5f17 | hieudtrinh/coursera | /uofm/python/course2_data_structures/week4/w4_assignment_08_04.py | 200 | 3.96875 | 4 | fname = input("Enter file name: ")
fh = open(fname)
lst = list()
for line in fh:
pieces = line.split()
for p in pieces:
if p not in lst:
lst.append(p)
lst.sort()
print(lst) |
e559ed9baf48a1dc3024830480811f0fbaf5b5c3 | MeenaRepo/augustH2K | /A_1_Q6.py | 447 | 4.40625 | 4 | '''
Question 6:
Ask the user for a string and print out whether this string is a palindrome or not.
(A palindrome is a string that reads the same forwards and backwards.)
'''
palinstr= str(input("Enter a Palindrome word : "))
def palin(s):
return s== s[::-1]
is_palindrome = palin(palinstr)
if ... |
2fcf435d394dcf6e4bf036f7de8cbc19b027a34a | GianRathgeb/CodingChallanges | /hard/Is_array_sorted_and_rotated/main.py | 566 | 3.6875 | 4 | # Challange: https://edabit.com/challenge/KEsQGp7LsP3KwmqJ7
# Input: check([3, 4, 5, 1, 2]) ➞ "YES"
# Input: check([1, 2, 3]) ➞ "NO"
def check(arr):
sorted_arr = sorted(arr)
for i in range(0, len(sorted_arr)):
correct_counter = 0
for j in range(0, len(arr)):
print("ARR: {} SORTARR: {}".format(arr, sorted_arr... |
f3f176dfc195c5d5a9c1bc1d1ee1baa15aa6080c | MilanHazra/AppTest1 | /request.py | 491 | 3.53125 | 4 | import requests
import pandas as pd
"""Setting the headers to send and accept json responses
"""
header = {'Content-Type': 'application/json', \
'Accept': 'application/json'}
"""Reading test batch
"""
df = pd.read_csv('TitanikData/titanic.csv', encoding="utf-8-sig")
df = df.head()
"""Con... |
37364784edd3b9e1a018b01dc4d1d55df0a63220 | Tolstr/problem-solving-and-algorithms | /Leetcode_Problems/Parser Goal.py | 553 | 3.953125 | 4 | #https://leetcode.com/problems/goal-parser-interpretation/
# Input: command = "G()(al)"
# Output: "Goal"
# Explanation: The Goal Parser interprets the command as follows:
# G -> G
# () -> o
# (al) -> al
# The final concatenated result is "Goal".
def func(inp):
word=""
output=""
for i in inp:
word+=i... |
43dfdfc9e25a1dc714367e5c65e1e9883782cf65 | LiudaShevliuk/python | /lab17_2.py | 3,176 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
import timeit
def power_by_shift() -> int:
return 2 << 49
def power_by_operator() -> int:
return 2 ** 50
def power_by_pow() -> int:
return pow(2, 50)
def power_by_math_pow() -> int:
return math.pow(2, 50)
def revers_by_map(strings: list) -... |
18a3ea67c4021b81a8726f40912eb77d43de82a6 | jlwgong/hangman | /group_projects/Section_A/tic_tac_toe_sectionA.py | 664 | 3.53125 | 4 | board1 = range(1,10)
a1=" "
a2=" "
a3=" "
b1=" "
b2=" "
b3=" "
c1=" "
c2=" "
c3=" "
def board():
print a1 + "|" + a2 + "|" + a3
print "-----"
print b1 + "|" + b2 + "|" + b3
print "-----"
print c1 + "|" + c2 + "|" + c3
board()
def input4players():
print "player1: choose the coordinate o... |
b0e2eccb55b5201463e529c9d6f9d32b83cf3d1b | fan803/pyAdvance1811 | /day0219/b.py | 680 | 3.5 | 4 | from multiprocessing import Process
from multiprocessing import Pool
from multiprocessing import Queue
from multiprocessing import Value
import time
def read(q):
while True:
print("pqueue size %d" % q.qsize())
r = q.get()
print("get %d" % r)
print("pqueue size %d" % q.qsize())
def wr... |
c32082f55a5439e5347fcb826b4aa69aafddd32a | freakcoder1/suvamdcoder | /rockpaperseccior.py | 1,188 | 3.921875 | 4 | import random
print('Hello User, Welcome to rock, paper, scissors with suvam jaiswal')
print('What is your name?')
User = input()
print("lets begin")
import random
L=["rock","paper","scissor",]
count=0
while(count<=5):
computer=random.choice(L)
user=input("enter rock, paper or scissor")
count+=1
if(user... |
dee96a6bd214396ccfdd6899f58c14b35e6ac0b2 | abderhasan/perceptron-rosenblatt | /perceptron_rosenblatt.py | 850 | 3.515625 | 4 | import numpy as np
input_size = 2 # number of features
lr = 0.1
epochs = 10
X = np.array([
[1,2],
[-1,2],
[0,-1],
])
W = np.array([1.0,-0.8]) # initialize weights
y = np.array([
1,
-1,
-1
])
def activation_function(z):
if z... |
fd13715301b5fdf610dafdd0c5a1da57e5d1f8e6 | AugustinDavid/Tri_Algo | /sorting_functions.py | 4,977 | 3.96875 | 4 | import math
from haversine import haversine
def get_distance_from_grenoble(city):
"""Retourne la distance entre la ville passée en paramètre et Grenoble
Args:
city (dict): Dictionnaire issu du csv. Contient les clés "latitude" et "longitude"
Returns:
int: la distance en km
"""
g... |
37904cf3ce8313bcf9b8554096c775ff3f5826a9 | hemantkumbhar10/Practice_codes_python | /Class_vehicle_milege.py | 343 | 3.71875 | 4 | class Vehicle:
def __init__(self):
print('Inside Constructor')
def identify_distance_that_can_be_travelled(self, fuel_left, mileage):
self.fuel_left = fuel_left
self.mileage = mileage
if self.fuel_left > self.reserve_fuel:
fuel = self.fuel_left - self.reserve... |
fd2c8e9badba4481af1d1d18c5fd32131d6fb6f9 | fxy1018/Leetcode | /472_Concatenated_Word.py | 1,624 | 4.15625 | 4 | """
Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.
A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array.
Example:
Input: ["cat","cats","catsdogcats","dog","dogcatsdog",... |
1458fcec5093fee4eb1181629880e00b4d56803d | real-t/git_learning | /network_bandwidth.py | 998 | 4.34375 | 4 | # 网络带宽计算
# print(100/8)
bandwidth = 100 # 为变量赋值
ratio = 8
print(bandwidth/ratio)
# 练习一字符串
# 定义一个字符串Hello Python并使用print()输出
# 定义第二个字符串Let's go并使用print()输出
# 定义第三个字符串"TheZen of Python"--by Tim Peters并使用print()输出
string1 = 'Hello Python'
print(string1)
string2 = "Let's go"
print(string2)
string3 = '"TheZen of Python"-... |
2c7f2ff23a9de9af3b8aa3613df2982165a21bca | FenixGnom/PythonLessons | /kvadrat.py | 340 | 3.734375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import equation
A = input(u'a: ')
B = input(u'b: ')
C = input(u'c: ')
R = equation.solve(A,B,C)
print(R)
#D = B*B - 4.0*A*C
#if D >= 0.0 :
# x1 = (-B + math.sqrt(D)) / (2.0 * A)
# x2 = (-B - math.sqrt(D)) / (2.0 * A)
#
# print x1, x2
#
#else :
# print u'No sout... |
b1e380b5e375c3243d2998cac7d1841092408a36 | xonic789/python_algorithm | /20210509_start_up_intern/intern2.py | 391 | 3.515625 | 4 | def solution(t, r):
answer = []
# 아이디가 0인 사람이 0번 리프트를 탐
# 아이디가 1인 사람이 1번 리프트를 탐
# 인덱스랑 같으면 넣어주고 같지 않으면
for i in range(len(t)):
if t[i] == i:
answer.append(i)
else:
return answer
print(solution([0,1,3,0], [0,1,2,3])) |
f3997b3a33067a1f7075a4199344d164823feaba | Crissky/Linguagens-de-Programacao | /Atividades/Atividade 01 - Conceitos Gerais/exercicio 1-2 (Conceitos Gerais - Slide 39).py | 734 | 3.828125 | 4 | class Veiculo:
rodas = "0"
tipo = "não definido"
def getRodas(self):
return self.rodas
def getTipo(self):
return self.tipo
def __str__(self):
return self.getTipo() + " possui " + self.getRodas() + " rodas."
class Carro(Veiculo):
rodas = "4"
tipo = "... |
bc0b9c5dc4fc1cfd740f5d4914e667a1c93f83cf | washimimizuku/python-data-structures-and-algorithms | /udemy-data-structures-and-algorithms/12-array-sequences/12.1_introduction.py | 134 | 3.59375 | 4 | # Array Sequence Types in Python
# List
l = [1, 2, 3]
print(l[0])
# Tuple
t = (1, 2, 3)
print(t[0])
# String
s = '123'
print(s[0])
|
d2747bce6dc19df99a7ed6ba672455894e308f78 | Jorgerunza/Taller-TDD-Kata-01-Grupo-8- | /Procesador.py | 374 | 3.578125 | 4 |
class Procesador:
def contador (self,lista):
if (lista == ''):
return [0,0,0,0]
else:
numeros = str.split( lista, ',')
numeros = [int(i) for i in numeros]
respuesta =[len(numeros), min(numeros), max(numeros), sum(numeros)/ ... |
4aa9a4f735fe150d841f00ed5dc2a5acd4823fc0 | JotaCanutto/AtividadesOlist | /AtividadesOlist/MarketplaceWeb/listagem.py | 1,003 | 3.53125 | 4 | marketplaces = ['Mercado Livre', 'Americanas', 'Amazon', 'Submarino']
categorias = ['Eletrodomésticos', 'Alimentos', 'Petshop']
subcategorias = ['Celular', 'Notebook', 'Salgado', 'Doce', 'Coleira']
def exibir_marketplaces()-> str:
lista = ''
for mkt in marketplaces:
lista += f'{mkt}, '
retu... |
7789c060e8b4a6b0f192caef0e590cca80e3af4c | martkjoh/slange | /røkla/test pyp.py | 117 | 3.515625 | 4 | from matplotlib import pyplot as plt
x = [x/10 for x in range(100)]
y = [x**2 for x in x]
plt.plot(x,y)
plt.show()
|
ffd647bcd82ef7e01e77d0be2f8745ef3af86902 | marisol-001/fernandez_caceres | /doble14.py | 337 | 3.515625 | 4 | #ejercicio 18
import os
#declarar
tiempodesalida,tiempodellegada,tiempo_total=0,0,0
tiempodesalida=int(os.sys.argv[1])
tiempodellegada=int(os.sys.argv[2])
tiempo_total=tiempodesalida+tiempodellegada
#procesing
if(tiempo_total>50):
print(tiempo_total,"velocidad excelente")
else:
print(tiempo_total,"velocidad ... |
94010dc987503ecebcd4e4f641d2f5d254f97613 | Saketh143/Django_app | /files.py | 523 | 4.3125 | 4 | # open a file
myfile = open("hello.txt", 'w')
# here myFile is object of class open
# hence , it has some methods and attributes
# lets use them
print("name :", myfile.name) # using name attribute
print("opening mode:", myfile.mode)
print('is closed: ', myfile.closed)
"""write into file"""
myfile.write("i love pyth... |
57afa3f3a76ae5e992158e55ad3c536643ecc39e | MRhys189/python-course | /v_Data_structures/15_Tuples.py | 286 | 4.0625 | 4 | point = 1, 2 # or point=(1,2) for python to read it as a tuple
point2 = (1, 2) + (3, 4)
# print(type(point))
# print(type(point))
point3 = tuple([1, 2, 3, 4])
print(point3)
print(point3[0:2])
w, x, y, z = point3
if 10 in point3:
print("exists")
else:
print("It doesn't exist")
|
a13abc2aa7f142f539b3c62219acf3040ea5c37a | Ishwariya18/set1 | /prefix.py | 288 | 3.515625 | 4 | def commonPrefixUtil(str1,str2):
result="";
n1=len(str1)
n2=len(str2)
i=0
j=0
while i<=n1-1 and j<=n2-1:
if(str1[i]!=str2[j]):
break
result+=str1[i]
i+=1
j+=1
return(result)
def commonPrefix(arr,n):
prefix=arr[0]
for i in range(1,n):
prefix=commonPrefixUtil(prefix,arr[i])
return(prefix)
|
637e22a2025122c25aec2c7cfcc3be7573f2c1f5 | misa5555/py | /string/71_simply_path.py | 779 | 3.65625 | 4 | class Solution:
def simplifyPath(self, path):
"""
:type path: str
:rtype: str
"""
import re
pt = 0
path_list = []
while pt < len(path):
drc = re.match(r'\/[^\/]*', path[pt:]).group()
if drc == "/..":
if path_list... |
c23a3b427dd5e145d515e592cd54f6330e0f18b2 | eray995/Ex_Files_NumPy_Data_EssT | /NUMPY_TUTORIALS_YOUTUBE/Mathematics.py | 390 | 3.890625 | 4 | import numpy as np
a=np.array([1,2,3,4])
print(a)
print(a+2)
b=np.array([1,0,1,0])
print(a+b)
print(a**2)
"""Take the sin"""
print(np.sin(a))
"""Linear Algebra"""
a=np.ones((2,3))
print(a)
b=np.full((3,2),2)
print(b)
print(np.matmul(a,b))
"""Find the determinant"""
c=np.identity(3)
print(np.linalg.det(c))
#... |
ad1d5ef2f394fd584a1572a7eac18ed7bcbec060 | ngoyal16/ProjectEuler | /Project Euler #0022- Names scores/solution.py | 446 | 3.78125 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import sys
def count_word(word):
return sum(ord(c) - 64 for c in word)
name_list = []
count_name = int(raw_input())
for x in range(0, count_name):
name_list.extend([raw_input()])
name_list.sort()
count_check = int(raw_input())
for ... |
146d15408203cc546d44c2696fedb5ff115da266 | Thejessree/python-exercises | /char_balance.py | 230 | 3.703125 | 4 | def char_balance(s1, s2):
flag = True
for char in s1:
if char in s2:
continue
else:
flag = False
return flag
print('s1 and s2 are balanced')
char_balance('pynative', 'tive')
|
95eed4816da9675ef89399bf20730a14dcec4eb4 | Vitkof/Python_Labs | /Lab1/example_4.py | 917 | 4.03125 | 4 | """
Fibonacci 0, 1, 1, 2, 3, 5, 8, 13, 21...
"""
def Fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return Fibonacci(n-1)+Fibonacci(n-2)
def Slow_Henerator(n):
print('\n*** Slow Henerator! ***')
for i in range(n):
print('n={}, Fn={... |
2ee26bc95f55638c01e0782013a1d6d640aca2fd | ulisseslimaa/SOLUTIONS-URI-ONLINE-JUDGE | /Solutions/1117_Validação_de_Nota.py | 347 | 3.90625 | 4 | while True:
nota1 = float(input())
if (nota1 >= 0.0 and nota1 <= 10.0):
media = nota1
break
else:
print("nota invalida")
while True:
nota2 = float(input())
if (nota2 >= 0.0 and nota2 <= 10.0):
media += nota2
break
else:
print("nota invalida")
print... |
bd630ea9f3c411ad39c1079e5b633bfd83024231 | dwaq/advent-of-code-solutions | /2019/01/1-counter-upper.py | 185 | 3.65625 | 4 | import math
filepath = 'input.txt'
total = 0
with open(filepath) as fp:
for line in (fp):
num = int(line.strip("\n"))
total += (math.floor(num/3)-2)
print(total) |
739ba6838f8e023ee9d97f273c2cee752c385a49 | Niranjana55/basic_problems | /35_number_of_prime_num_between_m_and_n.py | 306 | 3.9375 | 4 | #number of prime number between m and n
lower=int(input("enter the number m:"))
upper=int(input("enter the number n:"))
for i in range(lower,upper+1):
if(i>1):
for num in range(2,i):
if(i%num==0):
break
else:
print (i)
|
90d044d296cd0f1b5f6543f82ccb13386cabe1fd | EduardoEspinosaLahoz/Primera-Evaluaci-n | /tabla_de_multiplicar_while.py | 264 | 3.984375 | 4 | def tabla_de_multiplicar_while():
numero=input("Que tabla quieres que escriba?")
#for i in range(numero,0,-1):
i=numero
while(i>0):
print str(numero)+ " x "+ str(i)+ " = " + str (numero*i)
i=i-1
tabla_de_multiplicar_while()
|
fa3c4d77dbfcdaac4151bb3f7e54f98d26abe9df | Christopher-DeLaTorre/BankAccount | /BankAccount.py | 1,546 | 3.8125 | 4 | import random #import to have random number for account_number
num = range(10000000, 99999999)
class BankAccount():
routing_number = 111111111 #attibute unchanged
def __init__(self, full_name): #instance variable subject to change / different per person
self.full_name = full_name
self.account_nu... |
0a07ba9c48fb18d5421cb66fc604b86ff8853f6e | tmacjx/py_struct | /queue_exam/__init__.py | 396 | 3.71875 | 4 | """
# @Author wk
# @Time 2019/8/3 16:07
FIFO 先进先出
[4]
['dog', 4]
"""
class Queue(object):
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def enqueue(self, item):
self.items.insert(0, item)
def dequeue(self):
return self... |
199a1b2af3ccb140f9b10ea673bde2e324fb4949 | seung2435/chatbot | /day2/bithumb.py | 632 | 3.65625 | 4 | # Bithumb의
import requests
from bs4 import BeautifulSoup as bs
url = "http://www.bithumb.com"
res = requests.get(url).text
doc = bs(res, 'html.parser')
# coinlist = doc.select('.coin_list')
# css선택자로 링크를 긁어오면 제대로 긁어올 수 없음
# result = doc.select_one('tr.one:nth-child(1) > td:nth-child(1) > p:nth-child(2) > a:nth-chil... |
b5f53155b854fc39c030824c4b20ea8fb072b848 | blue-sky-r/Advent-Of-Code | /2022/07/u07.py | 8,174 | 3.546875 | 4 | #!/usr/bin/env python3
__day__ = 7
__year__ = 2022
__motd__ = '--- Year %s -- Day %s ---' % (__year__, __day__)
__url__ = 'http://adventofcode.com/%s/day/%s' % (__year__, __day__)
verbose = 0
class Dir:
def __init__(self):
self.data = []
def add_file(self, name, size):
""" add new file... |
5972448dc0bdb1fb153f16faa79930c6530d77a3 | blueones/LeetcodePractices | /binaryTreeLevelOrderTraversal102.py | 2,207 | 3.765625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution1:
def levelOrder(self, root):
if root==None:
return [[]]
flagList=list()
flagList.append(root)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.