blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
8183ac0d88d19c236b69a4b34aa95ce9ca600304 | escray/geektime | /maths/L14DoubleBFS.py | 4,097 | 3.734375 | 4 | # -*- coding: utf-8 -*-
import random
import queue
class Node(object):
def __init__(self, user_id):
self.user_id = user_id
self.friends = set()
self.degree = 0
def set_user_relation(user_num, relation_num):
"""
随机生成用户间的关系
:param user_num: 用户数量 即节点的数量
:param relation_num: 好友... |
ad7af5b89766c31bfb766116388407d4190cfe06 | MariaGabrielaReis/Python-for-Zombies | /List-01/L1-ex002.py | 256 | 4.0625 | 4 | #Exercise 02 - List 01
#Escreva um programa que leia um valor em metros e o exiba convertido em milímetros
print("Conversor: metros- milimetros")
m = float(input('Digite um valor em metros: '))
mm = int(m*1000)
print(m, 'metros em milimetros é ', mm) |
7ee44398b2be0950448e8fcbbf0c63e9bf1c0fee | MariaGabrielaReis/Python-for-Zombies | /List-10/L10-ex001.py | 1,007 | 3.75 | 4 | # A. near_ten #
# Seja um n não negativo, retorna True se o número está a distância de
# pelo menos dois de um múltiplo de dez. Use a função resto da divisão.
# near_ten(12) -> True
# near_ten(17) -> False
# near_ten(19) -> True
def near_ten(n):
if n % 10 <= 2 or n % 10 >= 8:
return True
return False
def test... |
c8db651e07469fb4c5742114ed7261a1106c174b | MariaGabrielaReis/Python-for-Zombies | /List-04/L4-ex005.py | 1,558 | 4.0625 | 4 | '''
“The Python Software Foundation and the global Python community welcome and encourage participation
by everyone. Our community is based on mutual respect, tolerance, and encouragement, and we are working
to help each other live up to these principles. We want our community to be more diverse: whoever you
are, an... |
cece83f2b314d9693985c04c6b1052d46c2b645a | MariaGabrielaReis/Python-for-Zombies | /List-10/L10-ex012.py | 1,140 | 3.5625 | 4 | # L. soma_na_lista #
# Verifica se um número é soma de dois elementos distintos de uma lista
# soma_na_lista(5, [1, 2, 3, 4]) -> True
# soma_na_lista(9, [1, 2, 3, 4]) -> False
# soma_na_lista(0, [1, 2, 3, 4]) -> False
# soma_na_lista(8, [1, 2, 3, 4]) -> False
# soma_na_lista(4, [2, 2, 2, 2]) -> False
# soma_na_lista(4,... |
0c0d6e43383e97d87fdc6afb562af33a00152f8c | MariaGabrielaReis/Python-for-Zombies | /List-02/L2-ex005.py | 576 | 4.125 | 4 | #Exercise 05 - List 02
#Faça um Programa que leia três números e mostre o maior e o menor deles.
print('O maior e o menor nº dentre 3')
#entrada de dados
a = int(input("a:"))
b = int(input("b:"))
c = int(input("c:"))
# JEITO DO PROFESSOR
# se o a for o maior
if a>=b and a>=c: print('Maior: ', a)
# se o b for o maior
e... |
c5dfe2c79ec6867daf063b75290c2f27535ba088 | MariaGabrielaReis/Python-for-Zombies | /List-01/L1-ex011.py | 258 | 3.84375 | 4 | #Exercise 11 - List 01
#Sabendo que str( ) converte valores numéricos para string, calcule quantos dígitos há em 2 elevado a um milhão.
print ('Quantos dígitos tem em 2 ^ 1 milhão?')
x = str(2^1000000)
print('O resultado tem ', len(x) , ' dígitos.') |
8fee55834eae89b12564938517c18a2624765702 | MariaGabrielaReis/Python-for-Zombies | /List-01/L1-ex010.py | 814 | 3.8125 | 4 | #Exercise 10 - List 01
#Escreva um programa para calcular a redução do tempo de vida de um fumante. Pergunte a quantidade de cigarros fumados por dia e quantos anos ele já fumou. Considere que um fumante perde 10 minutos de vida a cada cigarro, calcule quantos dias de vida um fumante perderá. Exiba o total de dias.
pri... |
a2fa134d04bcf3fa1013a90165f76280e4dc9312 | MariaGabrielaReis/Python-for-Zombies | /List-11/L11-ex001.py | 818 | 3.96875 | 4 | # A. donuts
# Para um inteiro n retorna uma string na forma 'Número de donuts: <n>'
# onde n é o valor passado como argumento.
# Caso n >= 10 devo retornar 'muitos' em lugar do número.
# donuts(5) returns 'Número de donuts: 5'
# donuts(23) returns 'Número de donuts: muitos'
def donuts(n):
if n >= 10:
n = 'muitos'... |
d54c1995a90a24513e87f67934bfaad18dc04930 | MariaGabrielaReis/Python-for-Zombies | /List-14/L14-ex004.py | 1,057 | 3.90625 | 4 | # G. Soma em listas invertidas
# Colocamos os dígitos de dois números em listas ao contrário
# 513 vira [3, 1, 5] e 295 vira [5, 9, 2]
# [3, 1, 5] + [5, 9, 2] = [8, 0, 8]
# pode supor que n1 e n2 tem o mesmo número de dígitos
# Não vale converter a lista em número para somar diretamente
def soma(n1, n2):
# MODO D... |
c49017ba0412382d108570e8f442b30a5910e229 | MariaGabrielaReis/Python-for-Zombies | /List-09/L9-ex010.py | 1,319 | 3.796875 | 4 | # J. alarm_clock #
# day: 0=domingo, 1=segunda, 2=terça, ..., 6=sábado
# vacation = True caso você esteja de férias
# o retorno é uma string que diz quando o despertador tocará
# dias da semana '07:00'
# finais de semana '10:00'
# a menos que você esteja de férias, neste caso:
# dias da semana '10:00'
# finais de seman... |
ff0b0a673b91cb04b58b9515c523136d33347fe5 | MariaGabrielaReis/Python-for-Zombies | /List-06/L6-ex007.py | 966 | 3.75 | 4 | # G. dista10
# seja um inteiro n
# retorna True se a diferença absoluta entre n e 100 ou n e 200
# for menor ou igual a 10
# dista10(93) -> True
# dista10(90) -> True
# dista10(89) -> False
def dista10(n):
if abs(n-100) <= 10 or abs(n-200) <= 10:
return True
return False
def test(obtido, esperado):
if obti... |
0de61f328365039254f0d94433370be7375eec43 | MariaGabrielaReis/Python-for-Zombies | /List-10/L10-ex013.py | 1,575 | 3.6875 | 4 | # M.Difícil: Fila de tijolos sem usar loops #
# queremos montar uma fila de tijolos de um tamanho denominado meta
# temos tijolos pequenos (tamanho 1) e tijolos grandes (tamanho 5)
# retorna True se for possível montar a fila de tijolos
# é possível uma solução sem usar for ou while
# fila_tijolos(3, 1, 8) -> True
# fi... |
7eb216f1a81802632c9398df9713a93e6b6a38b7 | stanfay91/PYTHON | /quad.py | 711 | 4.09375 | 4 |
import math
a = int(input("Enter the A coefficient: "))
b = int(input("Enter the B coefficient: "))
c = int(input("Enter the C coefficient: "))
x=int(input("What is x equal to?"))
print("The following Quadratic was entered", a,'X^2',b,'X+',c)
result = (a*x*x +b*x + x)
print("The value of the Quadratic is",re... |
751d25c138535eb8327a7941c075732749e4f09f | ITanmayee/Codeforce | /SumOfRoundNumbers.py | 1,477 | 4.09375 | 4 | """
A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from 1 to 9 (inclusive) are round.
For example, the following numbers are... |
abdd9fbc0423444e3dc78c254421b5183bf2610a | ITanmayee/Codeforce | /Borze.py | 552 | 4.09375 | 4 | """
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet.
"""
borze_code = input()
if... |
a1bf7d26a3d66f3ee972a35d68ef801ae80b100d | ITanmayee/Codeforce | /Ordinary_Numbers.py | 629 | 4.0625 | 4 | """
Let's call a positive integer n ordinary if in the decimal notation all its digits are the same. For example, 1, 2 and 99 are ordinary numbers, but 719 and 2021 are not ordinary numbers.
For a given number n, find the number of ordinary numbers among the numbers from 1 to n.
"""
def same(num):
if num < 10:
... |
55af3992c289525b74a5ea0f3eefd3bb7cbc2052 | Ash3rJkeee/127.abc-hits | /test.py | 3,160 | 4.0625 | 4 | import datetime
from math import sqrt
def is_simple(x):
"""Фукнция определения простоты"""
global simples_set
if x in simples_set: # проверка на вхождение в заране созданное множество простых чисел
return True
else:
# sum_number = 0
# for num in str(x):
# ... |
a17eaf174b4c5a01e5fc16ac88baf5a533cca54c | now-max-zanix/Lesson5 | /z3_l5_bank.py | 1,558 | 4.0625 | 4 | while True:
vznos = input("\nВнесите взнос:")
try:
float(vznos)
except ValueError:
print("ERROR-Вы ввели не число")
continue
else:
vznos = float(vznos)
if vznos < 0:
print("Упс... Вклад не может быть отрицательным")
continue
else:
... |
73a9260d4802add93643806d529e8848b2a11b25 | darshanchandran/PythonProject | /PythonProject/Python programming/learning/test.py | 65 | 3.53125 | 4 | print ("hh")
a = 10
name = 'darsh'
print ("the value of a is",a)
|
03e7a2218937f12112e322ac88ce065cceb7b23f | darshanchandran/PythonProject | /PythonProject/Classes and Modules/Classes/Compositions.py | 336 | 4.28125 | 4 | #This program shows how compositions work with out inheriting the parent class
class Parent(object):
def boss(self):
print("I'm the boss")
class Child(object):
def __init__(self):
self.child = Parent()
def boss(self):
print("Child is the boss")
self.child.boss()
son = Chi... |
a2b5af24bc7fce664024fb0db6bc9887d8db2d73 | darshanchandran/PythonProject | /PythonProject/DBZ/mygame.py | 1,640 | 3.9375 | 4 | # This is a simple scenario based game
class Players(object):
def player(invalue):
newvalue = int(invalue)
print(newvalue)
if newvalue == 1:
print("Hi")
playerpoint = 10
print(f"Goku is the player with points {playerpoint}")
Fight.gokufight()
... |
49fe5540582f959dbff34fa2a46ff80abdeac2ac | Diatemba99/Notebook | /list.py | 650 | 4.125 | 4 | week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saterday", "Sunday"]
print(week[3])
week[1]="Lundi"
print(len(week))
print((week))
print("----------------------------------")
mylist=[1, 56, "hello", [7, 20], True]
print(len(mylist[3]))
mylist.append("Toyota")
print(mylist)
mylist.insert(2, "Z... |
202428476075de93e4aaa63d4245b227993773f6 | KELLY454545/TD3_MBOUKEU_BALOLE | /main.py | 1,696 | 3.90625 | 4 | from mulTwoInt import mul
from addTwoInt import add
import sys
if __name__=="__main__":
reponse= input("voulez vous multiplier?(oui/non) ")
print(reponse)
if(reponse == "oui"):
if(len(sys.argv)==3):
print(sys.argv)
x = int(sys.argv... |
ebb4565aaf454377effee64e4b4aed9f1d9aaa42 | syadavdev/pythonDS | /src/array/max_three_number_from_array.py | 803 | 3.8125 | 4 | """
input:
array : 78 45 198 45 47 100 101 102
output:
max three elements : (198, 102, 101)
"""
import sys
import unittest
def max_elements(arry):
first = -sys.maxsize
second = -sys.maxsize
third = -sys.maxsize
for i in range(0, len(arry)):
if arry[i] > first:
third = second
... |
d70cf2db2fe1b5885a58c5928474d98e566aaa02 | syadavdev/pythonDS | /src/array/quick_sort.py | 1,421 | 3.734375 | 4 | import unittest
import random
def quick_sort(arry, low, high):
if low < high:
divider = partition(arry, low, high)
quick_sort(arry, low, divider - 1)
quick_sort(arry, divider + 1, high)
def partition(arry, low, high):
piviot = arry[high]
i = low - 1
for j in range(low, high):... |
22a59537016dfffc72c1844552cc3bd744e0619c | VladislavErekeshov/sum-between-1-and-n | /sum between 1 and n/sumbetween1andn.py | 277 | 3.828125 | 4 | a = int(input("Введите целое число: ")) # в этой задаче нужно найти сумму всех чисел, стоящих между 1 и n включительно
b = 0
for i in range(1,a+1):
if a < 10*4:
b = b + i
print(b) |
aaaba1c63010dfe4c9c1897b4472e771d249a5b1 | rczyrnik/ProjectEuler | /E052_PermutedMultiples.py | 1,032 | 3.59375 | 4 | '''
It can be seen that the number, 125874, and its double, 251748,
contain exactly the same digits, but in a different order.
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
contain the same digits.
MY NOTES:
has to include 1 (and smallest starts with 1. otherwise 6*2 = 12
different numbers?... |
fd379b0aa3008db474e0297908057cb88b2c4e21 | rczyrnik/ProjectEuler | /E010_PrimeSum.py | 390 | 3.640625 | 4 | #The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
#Find the sum of all the primes below two million.
below = 2000000
sum = 2
i=3
primes=[2]
while i < below:
is_prime=True
for num in primes:
if num > i**.5:
break
elif i % num == 0:
is_prime = False
break
if is_prime == Tru... |
46fd56d930856a976a018e4962f3a42f86d99341 | rczyrnik/ProjectEuler | /E051_PrimeDigitReplacements.py | 2,062 | 4.09375 | 4 | '''
By replacing the 1st digit of the 2-digit number *3,
it turns out that six of the nine possible values:
13, 23, 43, 53, 73, and 83, are all prime.
By replacing the 3rd and 4th digits of 56**3 with the same digit,
this 5-digit number is the first example having seven primes among
the ten generated numbers, yielding... |
950c2e688f58fc4931a79403197abed522e35ff5 | rczyrnik/ProjectEuler | /E041_PandigitalPrime.py | 1,209 | 4.03125 | 4 | '''
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?
'''
def is_pandigital(my_num, my_str):
for x in my_str:
if x not in my_num: re... |
baba768f398fbd1c206a56ab3dea4dc1795f6100 | rczyrnik/ProjectEuler | /E042_CodedTriangleNumbers.py | 1,208 | 3.984375 | 4 | '''
The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1);
so the first ten triangle numbers are:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
By converting each letter in a word to a number corresponding to its
alphabetical position and adding these values we form a word value.
For example, the word... |
24e8ca5a2cbf68af411b1ff75539d537c87e2b26 | ivyclare/Python-for-Everybody-Coursera | /Python for Data Structures/assignment_9.4.py | 1,211 | 4.0625 | 4 | # 9.4 Write a program to read through the mbox-short.txt and
# figure out who has the sent the greatest number of mail messages.
# The program looks for 'From ' lines and takes the second word of those
# lines as the person who sent the mail. The program creates a Python
# dictionary that maps the sender's mail addres... |
c0c7027ee70e6be6a0f9b067fc0f1df9b6276bc0 | EmissaryEntertainment/3D-Scripting | /Week_2/McSpadden_Exercise_2.3.py | 699 | 4.21875 | 4 | #Use each form of calculation besides modulus
print("2 + 5 = " + str(2+5))
print("2 - 5 = " + str(2-5))
print("2 * 5 = " + str(2*5))
print("2 / 5 = " + str(2/5))
print("2 ** 5 = " + str(2**5))
#Calculation whos resluts depend on order of operations
print("160 + 5 * 7 = " + str(160 + 5 * 7))
#Force change order of oper... |
35c1d6938d718bd63f6e34e717df2785106ba89d | EmissaryEntertainment/3D-Scripting | /Week_4/McSpadden_Exercise_4.4.py | 255 | 3.609375 | 4 | #GROWING STRENGTH
strength = 5
print("The players strength is %s." % strength)
while strength < 10:
strength += 1
print("The players strength is %s." %strength)
print("The players strength has reached %s so they must move up a level." % strength)
|
10af8d9ab3f29ed2c32c309ff2358aa48e38a5da | EmissaryEntertainment/3D-Scripting | /Week_3/McSpadden_Exercise_3.3.py | 3,058 | 4.5 | 4 | #WORKING LIST
careers = ["Programmer", "Sales Associate", "Technical Artist", "Teacher"]
print("The index of Sales Associate is: " + str(careers.index("Sales Associate")))
print("Technical Artist" in careers)
print("Baker" in careers)
careers.append("Baker")
careers.insert(0,"Janitor")
for index, career in enumerate(ca... |
ac951d9f278b6ec976a41e167ba50b6388432c96 | EmissaryEntertainment/3D-Scripting | /Week_3/McSpadden_Exercise_3.5_PEP8.py | 522 | 4.15625 | 4 | # ALPHABET SLICE
alphabet = ["a","b","c","d","e","f","g","h","i","j"]
slice = alphabet[0:3]
for letter in slice:
print("First slice: " + letter)
slice = alphabet[4:8]
for letter in slice:
print("Second slice: " + letter)
slice = alphabet[2:]
for letter in slice:
print("Third slice: " + letter)
# PROTECTED L... |
2c709c8d07c8a738177250eb5b4d029c3945dd7b | EmissaryEntertainment/3D-Scripting | /Week_4/McSpadden_Exercise_4.3.py | 897 | 4.25 | 4 | #THREE IS A CROWD
print("-------THREE IS A CROWD-------")
names = ["Jose", "Jim","Larry","Bran"]
def check_list(list):
if len(list) > 3:
print("This list is to crowded.")
check_list(names)
del names[0]
check_list(names)
#THREE IS A CROWD - PART 2
print("-------THREE IS A CROWD - PART 2-------")
def check_l... |
318170f2da288b0e397f04d4ba3d6acdefaef793 | AhmadMWaddah/AMW_Functions_OOP | /AMW Python Package.py | 4,062 | 3.6875 | 4 | import os
# --------------------------------------------------- #
class CharacterFind:
def __init__(self, target_string, icon_symbol):
"""
:param target_string: Provided String To Search Inside.
:param icon_symbol: Character Search For Inside String
:return: -------... |
567addd4e775a0a80665b75a1666cbf1fdda28e9 | KumarjitDas/Algorithms | /Algorithms/Recursion/Python/countdown.py | 911 | 4.5 | 4 | def countdown(value: int):
""" Print the countdown values.
countdown
=========
The `countdown` function takes an integer value and decreases it. It prints
the value each time it. It uses 'recursion' to do this.
Parameters
----------
value: int
an integer value
Returns
-------
... |
4bd3dc16a9ca50040b27748864229a2d4964550b | elice-python-coding/MJY | /python_algorithm/08_Linked_List/18_oddEvenLinkedList.py | 418 | 3.734375 | 4 | '''18. 홀짝 연결 리스트'''
class Solution:
def oddEvenList(self, head):
if head is None:
return head
odd = head
even = head.next
even_head = head.next
while odd and odd.next:
odd.next, even.next = odd.next.next, even.next.next
odd, even... |
ae58a4eb15df3f4bb13f2d67d2cf015975fa612b | elice-python-coding/MJY | /python_algorithm/10_Deque/26_DesignCircularDeque.py | 2,992 | 3.90625 | 4 | '''원형 데크 디자인'''
class ListNode:
prev = None
next = None
def __init__(self, k):
self.value = k
class MyCircularDeque:
front = None
rear = None
len = 0
def __init__(self, k: int):
self.size = k
def insertFront(self, value: int) -> bool:
node = ListNode(value)
... |
61c121d7f87686102a5743c820d4a3d7d683d986 | elice-python-coding/MJY | /python_algorithm/08_Linked_List/16_AddTwoNenmbers.py | 1,187 | 3.515625 | 4 | '''16. 두 수의 덧셈'''
# 내 풀이(틀림)
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
while l1 is not None:
if l1.val + l2.val < 9:
if ten == 1:
result.va... |
3ef73d9e96252e22cd682bf02950e5484f75ef18 | elice-python-coding/MJY | /programmers/3.py | 401 | 3.75 | 4 | def solution(phone_book):
for phone in phone_book:
n = len(phone)
for i in range(len(phone_book)):
print("1: ", phone, phone_book[i])
if len(phone_book[i]) > n:
print("2: ", phone, phone_book[i])
if phone_book[i][:n] == phone:
... |
93aa83d9b737e90e1092bdc3171687093c462a4b | elice-python-coding/MJY | /echcote/07_BinarySearch/7-2.py | 617 | 3.640625 | 4 | '''
재귀 함수로 구현한 이진 탐색 소스코드
'''
def binary_search(array, target, start, end):
if start > end:
return "x"
mid = (start + end) // 2
if array[mid] > target:
return binary_search(array, target, start, mid-1)
elif array[mid] < target:
return binary_search(array, target, mid + 1, ... |
90a7c176f0debceb0f70635eb2dc2144232b607a | catlaughing/ud120 | /datasets_questions/explore_enron_data.py | 2,666 | 3.5625 | 4 | #!/usr/bin/python
"""
Starter code for exploring the Enron dataset (emails + finances);
loads up the dataset (pickled dict of dicts).
The dataset has the form:
enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict }
{features_dict} is a dictionary of features associated with that pers... |
e64aa31725cc60330492277df093242775061ee7 | afiatamanna06/Python_shitttt | /RandomValues.py | 375 | 3.75 | 4 | import random
for item in range(10):
print(random.randint(10, 20))
members = ['Yuki', 'Shigure', 'Ayame', 'Kyo', 'Kagura']
leader = random.choice(members)
print(leader)
#exercise
class Dice:
def roll(self):
thistuple = tuple((random.randint(1,6), random.randint(1,6)))
return thistuple
dice =... |
559af69883b8eecc3161730a61f4dd45d8ea44b7 | afiatamanna06/Python_shitttt | /NestedLoops.py | 193 | 3.921875 | 4 | for x in range(4):
for y in range(3):
print(f'({x}, {y})')
#exercise
numbers = [5, 2, 5, 2, 2]
for x in numbers:
for y in range(x):
print('x', end = '')
print("")
|
fab38368d15a2922f8b45c6301cbe1fee7fc0464 | afiatamanna06/Python_shitttt | /Encapsulation.py | 290 | 3.78125 | 4 | class Car:
def __init__(self, speed, color):
self.__speed = speed
self.__color = color
def set_speed(self, value):
self.__speed = value
def get_speed(self):
return self.__speed
car = Car(20, "silver")
car.set_speed(30)
print(car.get_speed())
|
62630195417324769209bff1e208e952735a8663 | afiatamanna06/Python_shitttt | /OperatorPrecedence.py | 94 | 3.6875 | 4 | x = 10 + 3 * 2
print(x)
x = 10 + 3 * 2 ** 2
print(x)
# exercise
x = (2 + 3) * 10 - 3
print(x)
|
e79a9a836d9b8b152b4e32dc8763ede795fa2689 | afiatamanna06/Python_shitttt | /WhileLoops.py | 89 | 3.546875 | 4 | i = 1
while i<=10:
print(i)
i += 1
j = 1
while j<=5:
print('*'*j)
j += 1
|
603c0f7b36da059e0c39f20b0c263226beae5f9b | mdisner/Python-Programming- | /Tarea3-generador-de-diccionarios.py | 1,902 | 3.53125 | 4 | #!/usr/bin/python
dicc = []
raros = ["$#$", "$%", "&%$#", "&%/", "-.-", "..--//", "o/" ]
"""
Este programa importa un archivo de texto llamado palabras con open, el cual contiene los gustos, nombre, hobbies, de la posible
victima, para cada linea de ese archivo agrega caracteres especiales, numeros y reescribe todo a... |
cf15da4f153cec9d0b40d17d8eacf45662d7be05 | mdisner/Python-Programming- | /Rand.py | 1,610 | 3.96875 | 4 | #!/usr/bin/python
import random
lista1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
lista2 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
lista3... |
4c274b7921becd154b7415c3c49d473eba50dd1c | AceArash/ZTM-Complete-Machine-Learning-and-Data-Science-Zero-to-Mastery | /python/first program/Variables/310_l_m.py | 146 | 3.6875 | 4 | basket = ['a', 'b', 'x', 'c', 'd', 'e', 'f', 'g', 'h']
basket.sort()
sorted(basket)
print(basket)
print(sorted(basket))
print(basket.reverse()) |
de374f42318ba4996f1fe5bb85dda7ccef842d03 | AceArash/ZTM-Complete-Machine-Learning-and-Data-Science-Zero-to-Mastery | /python/first program/Variables/293_strings.py | 203 | 3.828125 | 4 | # Strings : str
# Strings is simply
# type("Hello world")
first_name = 'Arashvir'
middle_name = "Singh"
last_name = "Jamwal"
full_name = first_name + " " + middle_name + " " + last_name
print(full_name) |
3223a6adcb2e9afe6e95dcd67041cd911771a9da | athallahnk/Athallah-Naufal-K_I0320013_Wildan_Tugas3 | /I0320013_exercise3.2.py | 141 | 3.53125 | 4 | list= ['fisika','kimia', 1993,2017 ]
print("Nilai ada pada index 2:", list[2])
list[2]=2001
print("ilai baru ada pada index 2:",list[2]) |
110c972931fe16b1d605396a7d2813388ebf3282 | HossamSalaheldeen/Python_lab1 | /prob3.py | 915 | 4.1875 | 4 | # Problem 3
#-------------
# Consider dividing a string into two halves.
# Case 1:
# The length is even, the front and back halves are the same length.
# Case 2:
# The length is odd, we'll say that the extra char goes in the front half.
# e.g. 'abcde', the front half is 'abc', the back half 'de'.
# Given 2 strings, a a... |
c19c606df66f30e60f49912231625923b65697a8 | aditya2222/py-calculator | /py-calculator.py | 3,449 | 4.03125 | 4 | from tkinter import *
#bind numbers to the text entry so that when a button is pressed it's value is displayed in the text box!
def btnClick(numbers):
global operator
operator = operator+str(numbers)
text_input.set(operator)
#clear function for clear button
def clearDisplay():
global operator
operat... |
2a7963e01f163f9b2c85e8d64de66630914f7328 | JemrickD-01/Python-Activity | /WhichWord.py | 617 | 4.21875 | 4 | def stringLength(fname,lname):
if len(fname)>len(lname):
print(fname,"is longer than",lname)
elif len(fname)<len(lname):
print(lname,"is longer than",fname)
else:
print(fname,"and",lname,"have the same size")
choices = ["y","n"]
ans="y"
while ans=="y":
x=input... |
aa9b9b6dfa497618554fbe901f3f3e21b451acf6 | pophils/Algorithms-and-Data-Structures | /ArrayListADT/Exercises.py | 9,879 | 3.609375 | 4 |
from ArrayListADT.ArrayStack import ArrayStack
from ArrayListADT.ArrayQueue import ArrayQueue
from AppException.ExercisesException import ExercisesException
class Exercises():
"""
Solutions to exercises of chapter 6 (Stacks and queues).
"""
@staticmethod
def __newStack(capacity=None):
"""... |
1463e50062087ff0ac82730da34caaefbca929c4 | pophils/Algorithms-and-Data-Structures | /AbstractBases/Tree.py | 4,220 | 4.375 | 4 |
from abc import ABCMeta, abstractmethod
class Tree (metaclass=ABCMeta):
"""
Class provide abstract implementation of a general Tree ADT.
"""
class Position:
"""
Class represent the position of the node of the tree.
"""
def element(self):
"""
Ret... |
74c0ab1f7fc894f23d3bb34f76af5df2558dcd8d | pophils/Algorithms-and-Data-Structures | /ArrayListADT/ArrayQueue.py | 6,682 | 3.875 | 4 | from math import ceil
from AbstractBases.Queue import Queue as AbstractBaseQueue
from AppException.QueueException import QueueException
from LinkedListADT.LinkedQueue import LinkedQueue
class ArrayQueue(AbstractBaseQueue):
"""
Class implement an array based Queue ADT.
Through an adapter design pattern, ... |
0bb4516d18f9b5e4debec6a660f8bbd5c648bd20 | mholyaee/UOG_Python_99-00-1 | /S05_E3.py | 93 | 3.609375 | 4 | n=int(input("The input is:"))
i=1
while i<=n:
if n%i==0:
print(i)
i+=1
|
a790304d215e2bf20a44baae8307b0d0c8c2ded0 | mholyaee/UOG_Python_99-00-1 | /S10_E2.py | 253 | 3.890625 | 4 | Str=input("Input your Email:")
i=0
dot=False
Sign=False
while i<len(Str):
if Str[i]=='.':
dot=True
if Str[i]=='@':
Sign=True
i+=1
if dot and Sign:
print("Your email is valid!")
else:
print("Not valid!")
|
47da6b50c168b9bd6b1db6ae64c145b64e55247f | mholyaee/UOG_Python_99-00-1 | /S03_E1_Area.py | 139 | 3.890625 | 4 | a=int(input('First:'))
b=int(input('Second:'))
if a>0 and b>0:
print('Area:',a*b)
else:
print(' Please enter valid numbers')
|
e3d19918b11692b0fcf5b2fdb4ec989ee502c0cc | MatthewMasters/AoC2020 | /day_03/part2.py | 597 | 3.609375 | 4 | import numpy as np
def read_map(filename):
return np.array([[['.', '#'].index(c) for c in line.strip()] for line in open(filename).read().strip().split('\n')])
def count_trees(map, slope_x, slope_y):
height, width = map.shape
j = 0
count = 0
for i in range(0, height, slope_y):
count += m... |
72295944b637c588e59ce6c5f798e30f29c55dd5 | MatthewMasters/AoC2020 | /day_09/part2.py | 585 | 3.78125 | 4 | import numpy as np
def check_number(target, prev):
for a in prev:
for b in prev:
if a + b == target and a != b:
return True
return False
def find_contiguous_set(target_num):
for size in range(2, len(numbers)):
for pos in range(len(numbers)):
contig... |
6dfe94cdec6d67b58ab1be46c0b7afd68a9befd5 | mariopetrov9/Programming-with-python-101 | /coding_skills/coding_skills.py | 1,780 | 3.546875 | 4 | import json
import sys
def read_json(filename):
with open(filename, 'r') as f:
data = json.load(f)
return data
def main():
language = ""
data = read_json(sys.argv[1])
result_dict = {
'C++': {
'name': "",
'points': 0
},
'Java': {
... |
3f83814d1a7575aa9a6d8740562537a764ca0332 | Raj-kar/PyRaj-codes | /filter.py | 314 | 4 | 4 | lst = [1, 2, 3, 4, 5, 6, 7, 8]
''' even_lst = []
odd_lst = []
for i in lst:
if i % 2 == 0:
even_lst.append(i)
else:
odd_lst.append(i)
print(odd_lst)
print(even_lst) '''
odd_list = list(filter(lambda x: x % 2 != 0, lst))
even_list = list(filter(lambda x: x % 2 == 0, lst))
print(odd_list)
print(even_list)
|
6d8436e5031cc22b3198010d75a127afbcdaefe8 | Raj-kar/PyRaj-codes | /pattern_3.py | 158 | 3.828125 | 4 | '''
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5 - Half pyramid of numbers
'''
for i in range(1, 6): #[1, 2, 3, 4, 5]
for j in range(1, i+1):
print(j, end=" ")
print() |
d52e1005de68a0ae1c8d5e8db6c304e8e9dfdf4a | Raj-kar/PyRaj-codes | /pattern_1.py | 176 | 3.578125 | 4 | '''
*****
*****
*****
***** - using loop [i = row, j = column ]
'''
row = 4 # 0 - 3
col = 5 # 0 - 4
for i in range(row):
for j in range(col):
print("*", end="")
print()
|
bd4425d18533f4a1db589c7f9b20b84642b0dff1 | Raj-kar/PyRaj-codes | /palindrome.py | 345 | 3.765625 | 4 | def reverseNum(num):
res = 0
while num > 0:
res = res * 10 + (num % 10)
num //= 10
return res
def isPalin(num):
return num == reverseNum(num)
def getNum(start, stop):
for i in range(start, stop + 1):
if isPalin(i):
print(i, end=" ")
def takeInput():
start = int(input())
stop = int(input())
getNum(s... |
6caba9bea554aada682c536b2528dd6b0720b41b | Raj-kar/PyRaj-codes | /dobble_game.py | 1,022 | 4.03125 | 4 | from random import choice, shuffle
words = ['goon', 'loser', 'criminal', 'carbon', 'collection',
'helpless', 'crisis', 'adventure', 'bloodsport', 'mouse']
def get_random_word():
# choose a random word from list of words
rand_word = choice(words)
# remove the word, for stop repetation
word... |
668be3cbb20a118161c033bb30fb221a9b10b0da | Raj-kar/PyRaj-codes | /args.py | 191 | 3.671875 | 4 | # def add(n1, n2, n3=0, n4=0):
# return n1 + n2 + n3 + n4
# print(add(1, 1, 2, 2))
# *args
def add(*args):
res = 0
for i in (args):
res += i
return res
print(add(1, 2, 2, 3, 8, 9))
|
af1ecc1dfb000a8dd0aab062123a29c489a7f426 | Raj-kar/PyRaj-codes | /password.py | 1,300 | 4.28125 | 4 | ''' Homework 1 -
WAP to genarate a secure password.
- 1. password must contains minimim 8 char.
- 2. both upper and lower case.
- 3. must contains two number and one special char.
bonus - shuffle the password, for better security.
Homework 2 -
Optimize the below Code.
'''
# Wap to check a password is secure o... |
b28d9640759978074ac85459e9f720f4415db60a | Raj-kar/PyRaj-codes | /funtions.py | 1,196 | 3.8125 | 4 | # def add(num1, num2):
# print(num1 + num2)
# add(10, 20)
# add(20, 20)
# add(50, 21)
# def greet(name):
# print(f"Hello {name}, welcome again, Good to see you !")
# greet("Raj")
# greet("Akash")
# def sum_of_num(ls):
# add = 0
# for i in ls:
# add += i
# print(add)
# sum_of... |
1b9eca38027da6dbfd2b36a997785acc81223a2f | AndreFreire/code-challenge | /watermelon/main.py | 74 | 3.765625 | 4 | n = int(raw_input())
if n == 2 or n%2 == 1:
print "NO"
else:
print "YES" |
68828445d1194e1737060815b5e1ce28d3b7d31b | DeepakSuryaS/python-developer-program | /internal-interview/sumdb.py | 951 | 3.796875 | 4 | import sqlite3
import csv
conn = sqlite3.connect(database="../internal-interview/test_db_2.db") # if db doesn't exist, it'll be automatically created in the specified path.
cur = conn.cursor()
# Country,Year,life,population,income,region
cur.execute(""" CREATE TABLE CANDIDATES(ID INT, NAME VARCHAR2(32), TEST1 VARCHA... |
5eb2d4e872827f01e74784659fb425031d92bfdd | codicuz/gb_python | /Lesson01/task2.py | 285 | 4 | 4 | try:
seconds = int(input("Введите секунды: "))
except ValueError:
print("Вы ввели не число!")
hours = seconds // 3600
minutes = (seconds - hours * 3600) // 60
sec = (seconds - (hours * 3600) - (minutes * 60)) % 60
print(f"{hours}:{minutes}:{sec}") |
82fc2124669344ca0291a5d9bef9d8f70b01e7b9 | avantikabagri/lecture8 | /3/gradepredict_stubs.py | 2,028 | 4.21875 | 4 |
# reads a CSV from a file, and creates a dictionary of this form:
# grade_dict['homeworks'] = [20, 20, 20, ...]
# grade_dict['lectures'] = [5, 5, 5, ...]
# ...
# params: none
# returns: a dictionary as specified above
def get_data():
return {}
# param: list of lecture excercise scores
# return: total scores for lec... |
befa56c0f16944854efdd055388a423d36c70982 | eriambrioso/PythonPrograms | /mind.py | 1,499 | 3.703125 | 4 | """Never mind"""
# Author: Erika Ambrioso, eambrioso2017@my.fit.edu
# Course: CSE 2050, Fall 2018
# Project: Never Mind
from sys import(stdin, stdout)
DATA = []
DATA = stdin.readline().split(" ")
LENGTH = int(DATA[0])
CODE = DATA[1]
guess = DATA[2]
# The set of letters in the code. This is used to elimimate repetit... |
35716434f481d29147b8323b20675b8c13b7c4ab | pyscript/pyscript | /examples/fractals.py | 3,868 | 3.828125 | 4 | import numpy as np
from numpy.polynomial import Polynomial
def mandelbrot(
width: int,
height: int,
*,
x: float = -0.5,
y: float = 0,
zoom: int = 1,
max_iterations: int = 100
) -> np.array:
"""
https://www.learnpythonwithrune.org/numpy-compute-mandelbrot-set-by-vectorization
""... |
2db0b793458d042c599b98ac92dfdd123ca419d5 | tamarshnirer/cc_aproval | /functions.py | 275 | 3.53125 | 4 | def num_to_years(num):
try:
if num < 0:
year = num/-365
else:
year = 0
except:
return None
return year
def status_int(s):
if s=='C':
return 1
if s=='X':
return 2
else:
return s
|
e106519da86f042cd134f0556c118b7aa790cd57 | zahidmitha/fun_with_zahid | /ex45.py | 5,914 | 4.15625 | 4 | from sys import *
from random import *
class Player (object):
money = 1000
place = 0
deeds = []
# This could go in rules-it applies to what they board does, not what the player does or has
def costs(self):
cost = randint(1,101)
return cost
def buy(self, deed):
self.deeds.append(deed)
self.costs()
de... |
30c9dc1b0e6b450fa53f50d90ef46d864022923e | zahidmitha/fun_with_zahid | /ex43my.py | 4,392 | 3.90625 | 4 | class Scene(object):
def enter(self):
print "This scene is not yet configured. Subclass it and implement enter()"
exit(1)
class Engine(object):
def __init__(self, scene_map):
self.scene_map = scene_map
def play(self):
current_scene = self.scene_map.opening_scene()
... |
0972d728e87dcbb56422a3fa94662479db314b25 | zahidmitha/fun_with_zahid | /ex48.py | 1,327 | 4.03125 | 4 |
class lexicon(object):
def scan(self):
unsorted_words = "111 The door goes south to stopn at the west junction, where it will kill a crimean cat to the east"
words = unsorted_words.split()
direction = {"north" : ('direction', 'north'),
"south" : ('direction', 'south'),
"east" : ('direction', 'east'),
"... |
63018d146bea5fcaf29d18b53b5026e3e54f2d98 | pieisland/BaekJoon | /py/step1/10172.py | 700 | 3.625 | 4 | '''
개 만들기인데.
따옴표와 역슬래시 떄문에 문제가 좀 생겼음
따옴표 같은 경우는 작은 따옴표 세 개 한 거에 넣어서 표현을 하면 되고,
역슬래시 같은 경우에는.. 두 개를 써야 파이썬에서는 하나로 인식을 하는 것 같다. 솔직히 첫 줄은 왜 된건지는 모르곘지만..
따옴표도 역슬래시를 쓴 다음에 쓰면 쉬급이 되는 것 같음..;
'''
print("|\_/|")
print("|q p| /}")
print('''( 0 )"""\\''')
print('''|"^"` |''')
print("||_/=\\\\__|")
print("using only back ... |
2cd8550ab97bd65b1aac6ef39a4b714870af9fed | pieisland/BaekJoon | /py/11399.py | 808 | 3.90625 | 4 | #coding:utf-8
"""
2019.03.12.Tue.
ATM
마찬가지로 그리디 아록리즘.
정렬을 해야되는데, 파이썬 자체에서 정렬을 쉽게 하는 게있어서 그냥 그걸 사용함..
"""
def main():
n=int(input())
#이렇게 받으면 자동적으로 리스트가 되구나.
a = input().split()
#문자열로 저장되어 있으므로 int 값으로 변환
for i in range(0, len(a)):
a[i]=int(a[i])
a.sort()
result=0
#복잡도가O(... |
eace7c772ff991444a826f248305afee9001188b | pieisland/BaekJoon | /py/step13/10866.py | 793 | 3.609375 | 4 | '''
2019.03.27.Wed.
<덱>
'''
n=int(input())
li=[]
for i in range(n):
a=input().split()
if a[0]=="push_front":
li.insert(0, int(a[1]))
elif a[0]=="push_back":
li.append(int(a[1]))
elif a[0]=="pop_front":
if len(li)==0:
print(-1)
else:
print(li.pop(... |
d8d532e7f80c74a1da77212ad1fac5fc137f0ce3 | Sheersha-jain/network_programming | /server.py | 868 | 3.734375 | 4 | #SERVER CODE
"""
This code opens the web server at port 62.
In a second screen, open a client with Telnet. If we use
the same machine for the client and server :
$ telnet 127.0.0.1 62.
If we use another machine as client, we need to type the according
IP address of that machine which can be find using ifconfig.
E... |
0e6fd5bef6ac6905608ef6b5413880854eed2759 | vidyesh95/pythonSimpleInterest | /main.py | 465 | 4.0625 | 4 | # Python program to find simple interest
def simple_interest(p, r, t):
print("The initial principal balance : ", p)
print("The annual interest rate : ", r)
print("The time(in years) : ", t)
si = (p * t * r) / 100
print("The simple interest : ", si)
return si
principal = input("Initial princi... |
42ea0a6fe036ea1fbb3059a715461680a0e13146 | saubhik/catalog | /src/catalog/tries/add-and-search-word-data-structure-design.py | 2,412 | 4.3125 | 4 | # Add and Search Word - Data structure design
#
# https://leetcode.com/problems/add-and-search-word-data-structure-design/
#
import unittest
from typing import Dict
class TrieNode:
def __init__(self):
self.children: Dict[str, TrieNode] = dict()
self.end: bool = False
class WordDictionary:
d... |
5f430095beafb871b34fa0119dbef6b24a457d90 | cladren123/study | /AlgorithmStudy/백준/19 해시맵/7785 회사에 있는 사람(10.22).py | 310 | 3.5625 | 4 |
import sys
input = sys.stdin.readline
n = int(input())
sdict = dict()
for _ in range(n) :
str1, str2 = input().strip().split()
sdict[str1] = str2
# 역순 정렬
sdict = dict(sorted(sdict.items(), reverse=True))
for key,value in sdict.items() :
if value == 'enter' :
print(key)
|
ea68ad28c6486c6d792c4cab73ab116f13343eaf | cladren123/study | /AlgorithmStudy/프로그래머스/8 깊이,너비 우선 탐색(DFS, BFS)/4 여행경로 다시 풀이.py | 1,242 | 3.59375 | 4 | import copy
from collections import deque
def solution(tickets) :
answer = []
n = len(tickets)
# print(n)
que = deque()
tickets.sort(key=lambda x:x[1])
# print(tickets)
start = 'ICN'
for i in range(n) :
if tickets[i][0] == start :
checklist = []
c... |
ff284bf1c119c1eab92fec5545d0d494ea00fe59 | cladren123/study | /AlgorithmStudy/프로그래머스/4 정렬/2 가장 큰 수.py | 1,634 | 3.5625 | 4 | from itertools import permutations
cont = ""
maxnum = 0
def solution(numbers):
# 시간 초과가 떠버렸다.. 다른 방법으로 해보자.
# n = len(numbers)
# list1 = list(permutations(numbers, n))
# maxnum = 0
# cont = ""
# for i in list1 :
# for j in range(n) :
# cont ... |
02297570312958a47876927c09dc93d5f0a9fd36 | cladren123/study | /AlgorithmStudy/백준/1 수학/곱셈2.py | 514 | 3.671875 | 4 | """
곱셈2
10 * 11 / 12
재귀함수
10^5 를 미리 구한다.
B가 짝수인 경우
10^10 -> (10^5)^2 -> (10^5) * (10^5)
B가 홀수인 경우
10^11 -> (10^5)^2 * 10 -> (10^5) * (10^5) * 10
B가 1이 되면 A%C를 리턴하자
"""
A, B, C = map(int, input().split())
def multi(A,B,C) :
if B == 1 :
return A % C
else :
temp = multi(A,B//2,C)
if B % 2 ... |
fd5d36e2949c6d3244619181a90ad35033e2c518 | cladren123/study | /AlgorithmStudy/백준/3 구현/6 영화감독 숌.py | 326 | 3.5 | 4 | """
문제 자체가 이해가 안감
????
아하...
제일 작은 종말의 숫자를 표시한다는거군..
1666 2666 3666 4666 5666 다음은 6666 이 아니라 6660 이다...
"""
n = int(input())
movie = 666
while n :
if '666' in str(movie) :
n -= 1
movie += 1
print(movie)
print(movie-1)
|
1b3a25d91d31244acf8f2b4443e88973cb34f507 | cladren123/study | /AlgorithmStudy/백준/무지성 랜덤풀이/10월/10.2/9935 문자열 폭발(시간초과).py | 395 | 3.578125 | 4 | """
문제유형 :
자료 구조
문자열
스택택
이중반복문을 쓰면 시간초과가 발생
"""
import sys
input = sys.stdin.readline;
# 입력단
string = input().strip();
bomb = input().strip();
while True :
if bomb not in string :
break;
else :
string = string.replace(bomb, "");
if len(string) == 0 :
print('FRULA');
else :
print... |
f79b7517ee609cbec049fe7a3288b07a2c44615a | cladren123/study | /AlgorithmStudy/DP, Dynamic Programming/포도주시식.py | 525 | 3.640625 | 4 |
# 연속해서 3잔을 마실 수 없다.
n = int(input())
drink = [0]
for i in range(n) :
podo = int(input())
drink.append(podo)
dp = [0]
dp.append(drink[1])
if n > 1 :
dp.append(drink[1] + drink[2])
for i in range(3, n+1) :
dp.append(max(dp[i-1], dp[i-3] + drink[i-1] + drink[i], dp[i-2] + drink[i]))
print(dp[n])
""... |
921c907297f46b2515ff1e51b00998fa425fcb6a | joshgarza/nutrition_coach | /Measurebot/macro_generator.py | 2,283 | 3.515625 | 4 | protein = 0
carbs = 0
fat = 0
total_calories = 0
bodyweight = 220
# fetch weekly_calories from calories_generator
# write function to allocate total calories into training and rest days
training_day = {
"protein_mult": .8,
"carb_mult": 1,
"fat_mult": .3,
"goal_calories": 1350,
"min_protein_mult": ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.