blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
46815e5d35c59dd5e2cecec5290e2d134d0f21a0 | eli1234561/EliProgram | /main.py | 424 | 3.78125 | 4 |
from tkinter import *
window=Tk()
# add widgets here
lbl=Label(window, text="The Mental Health Quiz", fg='Black', font=("Serif", 21))
lbl.place(x=110, y=50)
btn=Button(window, text="Press To Continue", fg='Blue')
btn.place(x=210, y=280)
window.title('The Mental Health Quiz 2021')
window.geometry("600x500+10+20")
# ... |
ec157c5613693aeb0dcca09c0272b5f62b7edf31 | dsteven12/python-bootcamp | /LoopingInPython/while_exer.py | 737 | 4.09375 | 4 | def userNum():
"""Takes USER input to be used to display ith number of smileys"""
nums = int(input("Please give an integer: "))
if((nums == 1) or (nums ==0)):
nums = int(input("Please give an integer that isn't 0 or 1: "))
nums += 1
return nums
def smileyPrint(userInput):
"""Takes int g... |
2f2cfd7ef46dc8de6800c4d41c1c075199851576 | Jhonyoficial-zz/Codigos_em_Python | /inserirNaLista/escolherNaLista.py | 131 | 3.71875 | 4 | import random
lista = []
for c in range(5):
a = str(input('digite o nome: '))
lista.append(a)
print(random.choice(lista)) |
4c8c846b5243e14f1f4278911ef13edee535e572 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/logic_a24.py | 911 | 4.125 | 4 | # Boolean Algebra kas ir pamatā visiem datoriem (un elektronikai)
is_sunny = True
print(is_sunny)
is_sunny = not is_sunny # we reverse the logic
print(is_sunny)
is_sunny = not is_sunny # we reverse the logic
print(is_sunny)
is_sunny = not is_sunny # we reverse the logic
print(is_sunny)
print(not True, not False) # nega... |
fbb1019297170b1605c6461e5b7e7d9b22890580 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/variable_types.py | 5,288 | 4.78125 | 5 | my_name = "Valdis" # string data type
# # in Python we need to specifiers for variables
# # DRY - Do not repeat yourself
print(my_name)
print(f"Why hello there {my_name}!") # formatted string from Python 3.6+
print("How are you", my_name, "?")
print(type(my_name))
print("my_name", my_name)
my_other_name = 'Voldemārs'
p... |
90d647233e54bd071c4bf893aa6ec90844137645 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/conditionals.py | 3,034 | 4.09375 | 4 | # # a = 215
# a = int(input("Input a"))
a = 9000
a = 3
# if True:
# print("This always runs because if statement is True")
# print("Still working")
# # after we go back to our normal indentation the if block is ended
#
if a > 10: # in Python when you see : next line will be indented
# runs only w... |
42a0b32a30c564d2aa9c3db74110d0f92b7ce116 | komunikator1984/Python_RTU_08_20 | /Diena_6_lists/list_comprehension.py | 917 | 3.71875 | 4 | # my_nums = list(range(20))
my_nums = list(range(5,26,3))
print(my_nums)
# mylist = [1,2,3,10,20,3022.44324,342.11]
# new_list = [n+100 for n in mylist] # this will create a copy of mylist
# # same as
# new_list_2 = []
# for n in mylist:
# new_list_2.append(n)
# print(mylist)
# print(new_list)
# print(ne... |
7a283975dbc0f27e7eaed5530b8429242e4412b2 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/d4_a26_u2.py | 160 | 3.78125 | 4 | height = 5
for i in range(height,-1, -1):
print(' ' * (height - i) + '*' * (2*i + 1))
print(list(range(height)))
print(list(range(height,-1, -1))) |
df43637671a65a2fcbee222ab5107d8e7fda2c14 | komunikator1984/Python_RTU_08_20 | /Diena_6_lists/d6_g2_u3.py | 369 | 4.0625 | 4 | # # 3. uzdevums
# txt = input("Input text: ")
# rev_txt = ' '.join(txt[::-1].split()[::-1]).capitalize()
# print(f"{txt} -> {rev_txt}")
#3.uzdevums
sentence = input("Ieraksti teikumu! : ")
words = sentence.split(" ")
reverse_words = [word[::-1] for word in words]
reverse_sentence = " ".join(reverse_words).capitalize()... |
5d7133017871a944949241ce878046fb90e9943c | komunikator1984/Python_RTU_08_20 | /Diena_10_Classes_Objects/d10_g2_u1.py | 1,817 | 3.828125 | 4 | class Song:
def __init__(self, author, title , album, lyrics = ()):
self.author = author
self.title = title
self.album = album
self.lyrics = lyrics
self.print_header()
def print_header(self):
if self.title == "":
self.title = 'Unknown'
if s... |
50bdf9a5e58a07ee8360ca4f16f58ecc86962fd9 | komunikator1984/Python_RTU_08_20 | /Diena_5_strings/d5_g1_u3.py | 243 | 3.84375 | 4 | text = input("Please enter some text: ")
nav = text.find("nav")
slikts = text.rfind("slikts") # rfind is from right side
if nav >= 0 and slikts >= 0 and nav < slikts:
newText = text[:nav] + "ir labs " + text[slikts+6:]
print(newText) |
c2d6b8693f6ee64530752fe034e828c2535e8ca4 | komunikator1984/Python_RTU_08_20 | /Diena_8_dictionaries/d8_g2_u1.py | 801 | 4.125 | 4 | # text=input("Input text: ")
# def get_char_count(text):
# count={str(n):text.count(n) for n in text}
# return count
# from collections import Counter
# def get_char_count(text):
# # text = input("Please enter any text: ")
# count = Counter(text)
# print(count)
# return count
def get_char_c... |
69b58d254678162c94275fda7c2af4a9d7e7d86f | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/input2.py | 1,088 | 4.21875 | 4 | my_name = input("What is your name? ")
my_name = my_name.title()
# whatever we write before pressing enter will be saved as string
# and my_name will have reference to our text
print(f"Cool name {my_name}") # formatted string
print("Cool name " + my_name + " indeed") # not that fun
print("Cool name", my_name, "somethin... |
e6f5a4922eaa1311d9870ccb9023fa3a2c92033e | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/d2_f1_u3.py | 180 | 4.1875 | 4 | #task 3
celsium = float(input("What is the temperature outside?" ))
farenheit = 32+celsium*(9/5) # farenheit will be float automatically
print(f"It is {farenheit} degrees outside") |
3f8c49c0a9d0c12d6d6960d6a55e9acb1707c428 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/d2_u1_d10.py | 594 | 4.0625 | 4 | # # 1 uzdevums
name = input("Enter your name: ")
age = int(input(name + ", how old are you?"))
import datetime
currentYear = datetime.datetime.now().year
print("You will be 100 in", 100-age, "years and that will be year", currentYear+(100-age))
# name = input("What is your name?")
# age = input (f"What is your age {n... |
caff565fb2ef2bca2eca95ce32bb079d859d5a5e | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/d3_g3_u3.py | 498 | 4.03125 | 4 | #Task 3:
x = int(input("Please enter first number: "))
y = int(input("Please enter second number: "))
z = int(input("Please enter third number: "))
# if x <= y <= z:
# print(x, y, z)
# elif x <= z <= y:
# print(x, z, y)
# elif y <= x <= z:
# print(y, x, z)
# elif y <= z <= x:
# print(y, z, x) ... |
367735d2ba7e880fd1d81c4b84aec26cf66bd657 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/hello_world.py | 403 | 3.96875 | 4 | for x in range(5):
print("Valdis")
print("alus "*5)
# print("Valdis")
# print("Valdis")
# print("Valdis")
# print("Valdis")
# print("Hello World!")
# print("Computer do something....")
# print(2+2)
# print(2*3)
print(10/5) # regular division
# print(10//5)
# print(9//4) # dividing without reminder just the whole
#... |
133acc305c0077d07bf71af9a94e4a0b78402742 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/d3_g2_u3.py | 712 | 4.09375 | 4 | # 3. uzdevums
# a = float(input("a"))
# b = float(input("b"))
# c = float(input("c"))
# if a >= b >= c:
# print(f"{a},{b},{c}")
# elif a >= c >= b:
# print(f"{a},{c},{b}")
# elif b >= a >= c:
# print(f"{b},{a},{c}")
# elif b >= c >= a:
# print(f"{b},{c},{a}")
# elif c >= a >= b:
# print(f"{c},{a},{b... |
08bdde93b6942af8e04ca9bbb42f16526652c9ca | komunikator1984/Python_RTU_08_20 | /Diena_8_dictionaries/d8_f1_u2.py | 908 | 3.78125 | 4 | def replace_dict_value(d, bad_val, good_val):
"""
IN PLACE replacement of bad_val to good_val ues
"""
for key, val in d.items():
if bad_val == val:
d[key] = good_val
print(d)
return d
replace_dict_value({'a':5,'b':6,'c':5}, 5, 10)
replace_dict_value({'a':5,'b':6,'c':5, ... |
c9a8e1c5334e90224ae565d180c6661c5403c3f3 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/comparison.py | 2,047 | 4.3125 | 4 | print(2*2 == 4) # so == compares values returns Boolean
print(2*2 == 5)
a = 2
b = 3
c = 3
result = 4
d = 5
unused_var = 6
is_equal = a*a == result # I can save results evaluation is from the right side
print(a,a*a, result, a*a == result, is_equal)
print(a, b, a+b, result, a+b == result)
# # #
# # # # we can also do gr... |
c700e74ecdfcddec781f0496b09a76269f7ae654 | komunikator1984/Python_RTU_08_20 | /Diena_5_strings/d5_g1_u2.py | 1,259 | 3.953125 | 4 | #Player 1 input:
text_to_guess = input("Player 1, please input the text to guess! ")
guessed_so_far = ""
for i in text_to_guess:
if i != " ":
# guessed_so_far = guessed_so_far + "*"
guessed_so_far += "*"
else:
guessed_so_far += " "
print(f"Text to guess: {guessed_so_far}") #
done = False... |
77b1cc683b27b179fd777de91dcc0b748f9aba24 | komunikator1984/Python_RTU_08_20 | /Diena_7_functions/d7_g1_u1.py | 392 | 3.6875 | 4 | # Lielais rezultāts
def add_mult(a,b,c):
my_list=[a,b,c]
list_sort = (sorted(my_list))
# print (list_sort)
result = (list_sort[0]+list_sort[1])*list_sort[2]
print(f"({list_sort[0]}+{list_sort[1]})*{list_sort[2]}={result}")
return result
a = int(input("Ievadi 1. skaitli: "))
b = int(input("Ievadi... |
2be63eb555fbd413f46f5dd1139ca19a45bba79a | komunikator1984/Python_RTU_08_20 | /Diena_10_Classes_Objects/d10_g1_u2.py | 1,786 | 3.796875 | 4 | class Song:
def __init__(self, title="", author="", lyrics=()):
self.title = title
self.author = author
self.lyrics = lyrics
print(f"New song by {self.title} by {self.author} made!")
def sing(self, max_lines = -1):
if(max_lines < 0):
max_lines = len(self.lyr... |
dece0e7bec69c544120bd347f0d7e03865e31de3 | komunikator1984/Python_RTU_08_20 | /Diena_1_4_thonny/d3_aug24_u3.py | 485 | 4.09375 | 4 | a, b, c = int(input("Ievadiet skaitli ")), int(input("Ievadiet otru skaitli ")), int(input("Ievadiet trešo skaitli "))
print(a,b,c)
if a <= b <= c:
print(a, b, c)
elif b <= c <= a:
print(b,c,a)
elif c <= a <= b:
print(c,a,b)
elif a <= c <= b:
print(a, c, b)
elif b <= a <= c:
print(b, a, c)
elif c <=... |
e77caaf3717d6b93a12fbce12faf7055478be355 | benutte/exercicios-de-python | /Lista de Exercicios 1/zumbi 10.py | 229 | 3.6875 | 4 | # -*- coding: utf-8 -*-
quantidades = int(input(" Quantos cigarros são fumados por dia: "))
anos = int(input("Quantos anos já fumou: "))
total = anos * 365 * quantidades
dias = total / 144
print "Voce perdeu %.2f dias" % dias
|
31b4dd36b2d4a739b421359f4614d8dc1c6d91e5 | benutte/exercicios-de-python | /Lista de Exercicios 2/zumbi 06.py | 474 | 3.734375 | 4 | # -*- coding: utf-8 -*-
valor = float(input(" Digite quanto você ganha por hora: "))
hora = float(input(" Digite o número de horas trabalhadas no mês: "))
total = valor * hora
ir = 0.11 * total
inss = 0.08 * total
sindicato = 0.05 * total
liquido = total - ir - inss - sindicato
print " + Salário Bruto é: R$ %.2f" %tota... |
39a70866e8d7c173f66a3734225c3cac884f397f | benutte/exercicios-de-python | /Lista de Exercicios 2/zumbi 02.py | 263 | 3.921875 | 4 | # -*- coding: utf-8 -*-
ano = int(input(" Digite o ano, para saber se ele é bissexto: "))
if (ano % 4 == 0 and ano % 100 != 0):
print (" O ano é bissexto")
elif (ano % 400 == 0):
print (" O ano é bissexto")
else:
print (" O ano não é bissexto")
|
298c5ee2354d66fb48e0ba278cb1c1aab3f951d1 | benutte/exercicios-de-python | /Lista de Exercicios 3/zumbi desafio 04.py | 154 | 4.25 | 4 | # -*- coding: utf-8 -*-
num = int(input(" Digite um número:"))
for a in range(2, num):
while num % a == 0:
print (a)
num /= a
|
7ba588d081a53485cbf542da76639fb863f9332a | sxz1537/PATtest | /1011 A+B 和 C (15 分).py | 364 | 3.609375 | 4 | def isTrue(x,y,z):
if x+y>z:
return True
return False
N=int(input())
for i in range(1,N+1):
x,y,z=map(int,input().split())
t=isTrue(x,y,z)
if t:
print ("Case #",end="")
print (i,end="")
print (': true')
else:
print ("Case #",end="")
... |
0800ae8be9927799c1d80906c694b3b247c0615e | FressiaWang/DailyLeetcode | /Interview145/Remove Nth Node From End of List.py | 861 | 3.921875 | 4 | """
Given a linked list, remove the n-th node from the end of list and return its head.
Example:
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will always be valid.
Follow up:
Could you do this in one pass?
"""
def remov... |
7bb1679e13cba8ca6a373653f3d5316b9f8b8f1e | FressiaWang/DailyLeetcode | /Interview145/105. Construct Binary Tree from Preorder and Inorder Traversal.py | 1,622 | 4.03125 | 4 | """
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
For example, given
preorder = [3,9,20,15,7]
inorder = [9,3,15,20,7]
Return the following binary tree:
3
/ \
9 20
/ \
15 7
"""
# Definition for a binary tr... |
bd84aab9da105484d74b8901374916e1fb8bfc85 | FressiaWang/DailyLeetcode | /Interview145/55. Jump Game.py | 2,257 | 4.1875 | 4 | """
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine if you are able to reach the last index.
Example 1:
Input: [2,3,1,1,4]
Output: true
Explanation: Jump 1 step from index... |
7552994ce50155d032414bc90317837f2aac29ae | FressiaWang/DailyLeetcode | /Interview145/309. Best Time to Buy and Sell Stock with Cooldown.py | 1,950 | 3.765625 | 4 | """
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as many transactions as you like
(ie, buy one and sell one share of the stock multiple times) with the following restrictions:
You may not engage in multiple tr... |
cfc49d0eb0e149a6db7670b273b37b097841e54e | FressiaWang/DailyLeetcode | /Interview145/14. Longest Common Prefix.py | 2,081 | 4.09375 | 4 | """
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".
Example 1:
Input: ["flower","flow","flight"]
Output: "fl"
Example 2:
Input: ["dog","racecar","car"]
Output: ""
Explanation: There is no common prefix among the input st... |
bb5dbc247592f4d28c0fdd47995217f448b159da | FressiaWang/DailyLeetcode | /Interview145/230. Kth Smallest Element in a BST.py | 1,330 | 3.890625 | 4 | """
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
Example 1:
Input: root = [3,1,4,null,2], k = 1
3
/ \
1 4
\
2
Output: 1
Time complexity : \mathcal{O}(H + k)O(H+k), where HH is a tree height. This complexity is defined by the stack,
which contains at... |
7cd84ef34542aa74596aebd598c073df3956aa13 | FressiaWang/DailyLeetcode | /Interview145/33.Search in Rotated Sorted Array.py | 3,475 | 4.1875 | 4 | """
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
You are given a target value to search. If found in the array return its index, otherwise return -1.
You may assume no duplicate exists in the array.
Your algorith... |
65065d7131e4d89a6d5e6dce42c32e2868359e21 | FressiaWang/DailyLeetcode | /Interview145/62. Unique Paths.py | 883 | 4.09375 | 4 | """
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner
of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
**... |
cc0f853ef8a48b4ee77a51cfc9f98084eb4801e4 | kimuracl/diplomado | /IntroProg/ejercicio1.py | 816 | 3.59375 | 4 | #raizX1: num num num -> float
#Calcula la raiz resultante x1 de una ecuacion de segundo grado
#Ejemplo : raizX1(1, 3, -4) debe producir 1.0
def raizx1(a, b, c):
factor2 = 4 * (a * c)
raiz = (b ** 2 - factor2) ** 0.5
numerador = -b + raiz
denominador = 2 * a
resultado = numerador / denominador
re... |
14edda28c3d8f3dd8cd2667a54de4bb262bef8b9 | jeanbenoitdaille/Createaclasswhichheritesother | /main.py | 698 | 3.5 | 4 | class Voiture(object):
def __init__(self):
self.couleur = "noire"
self.vitesse_max = 200
self.prix = 25000
@property
def prix_reduit(self):
return self.prix * 0.75
def __repr__(self):
return "Je suis une voiture ... |
7547b6f7bda0a49f44ea80cd990a002c4ae6485f | hockeykozo/python_practice | /input.py | 111 | 3.953125 | 4 | name = input("What is your name : ")
age = input("How old are you : ")
print("Hello, Mr %s. (%s)" %(name,age))
|
e09c9ece957069583208a244389723b4af1f50dd | simonchapman1986/ripe | /src/apps/bi/floyd_warshall.py | 2,309 | 4.625 | 5 | """
Example of Floyd-Warshall Algorithm
@author: Simon Chapman
Introduction:
Floyd-Warshall is a very simple, but inefficient shortest path algorithm that has O(V3) time complexity. Based on the
two dimensional matrix of the distances between nodes, this algorithm finds out the shortest distance between each and
ever... |
594ead3a0ef0f8642a1870e6d9a6cf00d5598503 | simonchapman1986/ripe | /src/apps/bi/eratosthenes.py | 520 | 3.875 | 4 | __author__ = 'simon'
def eratosthenes(n):
"""
>>> n = 10
>>> primes = eratosthenes(n)
>>> print 'primes:', primes
primes: [2, 3, 5, 7]
"""
r = [i for i in range(2, n+1)]
# steps for eratosthenes
two = [t for t in r if (t % 2) >= 1 or t == 2]
three = [t for t in two if (t % 3) ... |
afe7f296ec11b54885799e8a6aaa06124b9403af | sopasolari/Python_Projects | /calcavg.py | 285 | 3.96875 | 4 | averg = []
userinp = int(input("How values you want to add:"))
for x in range(userinp):
averg.append(float(input("Enter the %d value for avarage:" % (x+1))))
print (averg)
print("The average grades of yours student is:", sum(averg) / len(averg))
print("The max it is:",max(averg)) |
0fe47a48cbfe60b5330f77384e3acdbd883bfe55 | CodecoolGlobal/seti-python-gyurma12 | /seti.py | 856 | 3.859375 | 4 | def decimal_to_binary(decimal_number):
"""Returns the array of digits in binary representation of a decimal number"""
pass
def binary_to_decimal(binary_digits):
"""Returns the decimal (number) representation of a binary number represented by an array of 0/1 digits"""
pass
def decimal_to_base(decimal... |
9e4a893b080ad02d803c312d747206f2544dacdf | xzxiong-1/deep-learning | /DeepLearning-B站课程/DeepLearning/第16课-受限玻尔兹曼机RBM(代码)/RBM识别数字.py | 1,316 | 3.515625 | 4 |
# coding: utf-8
# In[1]:
#51CTO课程频道:http://edu.51cto.com/lecturer/index/user_id-12330098.html
#优酷频道:http://i.youku.com/sdxxqbf
#微信公众号:深度学习与神经网络
#Github:https://github.com/Qinbf
# In[2]:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn import me... |
3c34202f0c8697f2ddf9efe390e75289670e36d9 | borko81/python_scripts | /book/find_duplicate.py | 778 | 3.71875 | 4 | from collections import Counter
a = [1, 7, 2, 9, 7, 11]
def find_fuplicates_in_list(items):
found_items = set()
for item in items:
if item not in found_items:
yield item
found_items.add(item)
# print(list(find_fuplicates_in_list(a)))
# Found most looked element
# First usin... |
7e1fbafda7994986ffa486a4f886bcf5d73fbf25 | borko81/python_scripts | /anycode/filtering.py | 326 | 3.953125 | 4 | mylist = [1, 4, -5, 10, -7, 2, 3, -1]
values = ['1', '2', '-3', '-', '4', 'N/A', '5']
result = (n for n in mylist if n > 0)
print([i for i in result])
def is_int(val):
try:
x = int(val)
return True
except ValueError:
return False
int_values = filter(is_int, values)
print(list(int_va... |
33b1f74804febc4781f447daf946f143a5a5b982 | borko81/python_scripts | /OOP/ended_states_save_or_not.py | 616 | 3.5625 | 4 | class Connection:
error = "Connection close"
def __init__(self):
self.state = 'CLOSED'
def check_is_status_open(self):
if self.state != 'OPEN':
raise RuntimeError(Connection.error)
def read(self):
self.check_is_status_open()
print('Now reading')
def w... |
826b7ea0ddc843b201836a23dfb2a2f6811896cd | borko81/python_scripts | /File_Test/Words Count/solve05.py | 1,281 | 3.6875 | 4 | import os
import re
from typing import List
FILE_TO_READ = 'words.txt'
FILE_TO_CHECK = 'text.txt'
def get_searched_word(file: str) -> List[str]:
''' Return list with word who search '''
result = []
with open(file, 'r') as f:
for line in f.readlines():
result.extend(line.split())
... |
4998e33f6b154d3334230b008157b6164a34c2ca | borko81/python_scripts | /OOP/try_to_implement_subscriber.py | 1,320 | 3.796875 | 4 | class Person:
def __init__(self, name) -> None:
self.name = name
def update(self, message, channel):
print(f"Hello {self.name} this is a new message: {message} in channel {channel}")
class Channel:
def __init__(self, name) -> None:
self.name = name
self.__subscriber = []
... |
1505c9cbb8c100b72924b874b311a07ba52ef3ce | borko81/python_scripts | /some_with_excell/index.py | 151 | 3.5 | 4 | import pandas as pd
file = 'january.xlsx'
data = []
df = pd.read_excel(file, skiprows=1, usecols='A')
data.append(df)
d = pd.concat(data)
print(d)
|
08d450b6f4e9482ee5b3460cc79b3b62abfd02c6 | borko81/python_scripts | /decorators_ex/example_one.py | 432 | 3.59375 | 4 | # High order function
def sum(n, func):
total = 0
for number in range(n + 1):
total += (func(number))
return total
def square(n):
return n * n
result = sum(10, square)
# Nested function
from random import choice
def greet(person):
def get_mood():
mood_result = choice(['One'... |
baf3532dc735addb668d728487bb6489aeb309b3 | borko81/python_scripts | /anycode/work_with_csv/file_one.py | 1,214 | 3.640625 | 4 | import csv
from collections import namedtuple
from pprint import pprint
import json
FILE = 'sample.csv'
FILE_TO_WRITE = 'sample.csv'
headers = ['Symbol', 'Price', 'Date', 'Time', 'Change', 'Volume']
rows = [('AA', 39.48, '6/11/2007', '9:36am', -0.18, 181800),
('AIG', 71.38, '6/11/2007', '9:36am', -0.15, 195500... |
74d31d75723b09d033cb379f0662cc06270a2c1d | borko81/python_scripts | /small_problem/one_line_code.py | 689 | 3.578125 | 4 | def is_palindrome(str):
return str == str[::-1]
nums = [1, 2]
mylist = ['a', 'b', 'c', 'd']
dictionary1 = {"name": "Jack1", "age": 25}
dictionary2 = {"name": "Jack2", "city": "Texas"}
mylist = [1, 5, 8, 'b', 5, 9, 6, 9, 5, 6, 9, 6,
5, 4, "a", "a", "b", "b", "a", "b", "b"]
print(dict(enumerate(mylist)))... |
0e0f89cb458cee3c95ff6856acd750654b17c29d | alexaverill/SenseHat | /Example2.py | 717 | 3.75 | 4 | # Show Message Example
#This program will let you display a scrolling message on the LED matrix of the SenseHat
#import senseHat library
from sense_hat import SenseHat
# a library is a set of code that can be referenced in a program. It has books (functions) that can be opened to help with tasks.
#we have to declar... |
33f417bb92d7ba07119d2cdd93fbc875cae6a881 | Frankie-Tu/Codewars | /Python/SumOfPair.py | 2,097 | 4.03125 | 4 | """
Challenge created by AlejandorLazaro:
Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum.
sum_of_pairs([11, 3, 7, 5], 10)
# ^--^ 3 + 7 = 10
== [3, 7]
sum_of_pairs([4, 3, 2, 3, 4], ... |
d5d7cfb1445e418573f2df314a1203e6af79aed4 | Envoy-Beta/Python | /hello_you.py | 532 | 4.40625 | 4 | # Ask user for name
name = input("What is your name?: ")
print(name)
#Ask user for age
age = input("What is your age?: ")
print(age)
#Ask user for city
city = input("What city do you live in?: ")
print(city)
#Ask user what they enjoy doing
hobby = input("What do you enjoy doing?: ")
print(hobby)
#Create outp... |
8ba9a6aeb4e1c0346eb258311a89a5a5b314857d | AndersonTeala/Project-Andre-Iacono-Python | /numbers.py | 200 | 3.921875 | 4 | # COM VARIAVEIS
num1 = 5
num2 = 10
print (num1 + num2)
# COM VARIAVEIS
num1 = 77
num2 = 10
print (str(num1) + ' e o meu numero da sorte.')
# FUNCAO PARA NUMEROS
num1 = 77
num2 = 10
print(pow(2, 3)) |
beec02f4c47f9a9257e4222d4034255903e14af4 | vickymmcd/Complexity_IPD | /prisoner_classes/vicky_prisoner.py | 1,310 | 3.8125 | 4 | from base_class import Prisoner
class VickyPrisoner(Prisoner):
def __init__(self):
Prisoner.__init__(self)
self.history = []
self.name = 'VickyPrisoner'
def getHistory(self):
return self.history
def addToHistory(self, decision):
self.history.append(decision)
... |
2e40f288f212cc87759d1493643b6a06efd71479 | MachunMC/python_learning | /python_learning/04_数字.py | 731 | 3.84375 | 4 | # -*- coding: utf-8 -*-
# @Project : python_learning
# @File : 004_数字.py
# @Author : Machun Michael
# @Time : 2020/5/17 18:00
# @Software: PyCharm
'''
0. python中使用"+"、"-"、"*"、"/"来进行数字的运算,**表示几次方
1. 浮点数:python中进行浮点数运算时,运算结果中的小数点位数可能是不确定的
如:0.2 + 0.1,运算结果为0.30000000000000004
'''
# 1. 整数
sum ... |
f53152d66c35503b3a8082507d33d470c45a34b2 | MachunMC/python_learning | /python_review/20_字典和列表的嵌套.py | 1,023 | 3.578125 | 4 | # -*- coding: utf-8 -*-
# @Project : python_learning
# @File : 20_字典和列表的嵌套.py
# @Author : Machun Michael
# @Time : 2021/3/26 21:25
# @Software: PyCharm
# 有时候,需要将一系列字典存储到列表中,或者将列表中的值存储到字典中,这种称为嵌套
# 1.字典列表(字典类似于结构体,列表类似于数组,字典列表就类似于结构体数组)
dog_tom = {'name' : 'tom', 'age' : '2'}
dog_jack = {'name' : 'jack', 'ag... |
92e7af3d168d9b59b6ef971cfdf4d0293faca916 | MachunMC/python_learning | /python_learning/17_函数.py | 4,175 | 3.625 | 4 | # -*- coding: utf-8 -*-
# @Project : python_learning
# @File : 017_函数.py
# @Author : Machun Michael
# @Time : 2020/6/16 19:31
# @Software: PyCharm
'''
0. 函数定义
(0) 格式:def func_name(param0, param1...):
function body
1. 参数默认值
(0) 在定义函数时,可以指定参数默认值。在调用函数时,如果传递了实参,则使用实参值;如果没有传递实参... |
a21e700d4119399d54940b6d99056182695c1d15 | MachunMC/python_learning | /python_learning/19_类.py | 2,668 | 3.78125 | 4 | # -*- coding: utf-8 -*-
# @Project : python_learning
# @File : 019_类.py
# @Author : Machun Michael
# @Time : 2020/6/21 23:16
# @Software: PyCharm
'''
1. 类和实例
(1) 类表示某些事物所共有的属性,比如Dog类
(2) 实例是根据类所创建的对象
2. 定义类
(1) 格式:class Class_name():
def __init__(self, param0, para... |
ec2e958ca313994d73d4c090d06b8f6f39eb2c75 | MachunMC/python_learning | /python_review/29_传递任意数量的实参.py | 2,105 | 4.1875 | 4 | # -*- coding: utf-8 -*-
# @Project : python_learning
# @File : 29_传递任意数量的实参.py
# @Author : Machun Michael
# @Time : 2021/4/3 15:04
# @Software: PyCharm
# 有时提前无法预知函数需要接受多少个参数,所以python支持传递任意数量的实参
# 该函数只有一个形参 *toppings,表示可以接受任意多个实参,接受的实参,将统一保存到一个元组中
# 实际上,形参*toppings,表示定义一个名为toppings的空元组,函数调用传递的实参都保存到这个元组中
def mak... |
cd2cced9508b05065fd2fce6527df9fbcd83ebd1 | estraviz/codewars | /8_kyu/Heads and Legs/animals.py | 270 | 3.734375 | 4 | """
Heads and Legs
"""
def animals(heads, legs):
return (2 * heads - legs / 2,
legs / 2 - heads) if is_valid(2 * heads - legs / 2) and is_valid(
legs / 2 - heads) else "No solutions"
def is_valid(x):
return x >= 0 and x == int(x)
|
9fdaa698957c363832d3d8e1845690d03fe5c732 | estraviz/codewars | /8_kyu/Localize The Barycenter of a Triangle/bar_triang.py | 282 | 3.625 | 4 | """Localize The Barycenter of a Triangle
"""
def bar_triang(pointA, pointB, pointC):
# Assuming points A, B and C will never be aligned
xO = round((pointA[0] + pointB[0] + pointC[0]) / 3., 4)
yO = round((pointA[1] + pointB[1] + pointC[1]) / 3., 4)
return [xO, yO]
|
20d04c8d137ffe230bd9296e223d67940e923a28 | estraviz/codewars | /6_kyu/Validate Credit Card Number/python/solution.py | 389 | 3.78125 | 4 | """Validate Credit Card Number"""
def validate(n):
numbers = list(int(digit) for digit in str(n))
double_every_other = []
for i, num in enumerate(numbers):
if len(numbers) % 2 == i % 2:
num *= 2
if num > 9:
num = sum(int(x) for x in str(num))
double_... |
b23a0053783c63ee0980b47338ea69368c264ee5 | estraviz/codewars | /6_kyu/Calculate String Rotation/python/solution.py | 140 | 3.828125 | 4 | """Calculate String Rotation"""
def shifted_diff(first, second):
return -1 if len(first) != len(second) else (second * 2).find(first)
|
e722d1a9ecf8ef2ffdc2827277eeab59faa63ba8 | estraviz/codewars | /7_kyu/Sum of Array Averages/sum_average.py | 150 | 3.609375 | 4 | """
Sum of Array Averages
"""
from statistics import mean
from math import floor
def sum_average(arr):
return floor(sum(mean(x) for x in arr))
|
a97315e81ecdd478644b381cf2d003a8e1257f3c | estraviz/codewars | /7_kyu/[Geometry A-2]: Length of a vector/python/solution.py | 221 | 3.71875 | 4 | """[Geometry A-2]: Length of a vector"""
import math
def vector_length(vector):
v1x, v1y = vector[0][0], vector[0][1]
v2x, v2y = vector[1][0], vector[1][1]
return math.sqrt((v2x - v1x)**2 + (v2y - v1y)**2)
|
482298fa5a12b00a6a9aa5cec346451a416cd822 | estraviz/codewars | /8_kyu/Check same case/python/solution.py | 216 | 3.640625 | 4 | # Check same case
def same_case(a, b):
if a.isalpha() and b.isalpha():
if a.islower() and b.islower() or a.isupper() and b.isupper():
return 1
else:
return 0
return -1
|
cf1bfb1b8260b65b4beae70a200762932f2b8d4d | estraviz/codewars | /7_kyu/Sorted Union/python/solution.py | 230 | 3.9375 | 4 | """Sorted Union"""
def unite_unique(*lists):
output_list = []
for list in lists:
for element in list:
if element not in output_list:
output_list.append(element)
return output_list
|
14c0374dc94474a7040f956bd6d7254f0f004da2 | estraviz/codewars | /6_kyu/Collatz/collatz.py | 216 | 3.734375 | 4 | """Collatz
"""
def collatz(n):
if n == 1:
return '1'
else:
if n % 2 == 0:
result = n//2
else:
result = 3*n + 1
return '{}->{}'.format(n, collatz(result))
|
a7498f743b16497e982d09552cbdfbc4a2326df4 | estraviz/codewars | /5_kyu/Going to zero or to infinity/going.py | 175 | 3.6875 | 4 | """Going to zero or to infinity?
"""
def going(n):
sum, fact = 0, 1
for i in range(1, n+1):
fact *= i
sum += fact
return int((sum/fact)*1e6)/1e6
|
9ad26786e5600477f917abe58dadd0cce2d61fef | estraviz/codewars | /6_kyu/Number Zoo Patrol/python/solution.py | 128 | 3.578125 | 4 | """Number Zoo Patrol"""
def find_missing_number(numbers):
return next(iter(set(numbers) ^ set(range(1, len(numbers)+2))))
|
476091810b43defbd855a20b720f43d58614fbff | estraviz/codewars | /7_kyu/number with 3 roots./python/solution.py | 119 | 3.546875 | 4 | """number with 3 roots."""
from math import sqrt
def perfect_roots(n):
return sqrt(sqrt(sqrt(n))).is_integer()
|
2ea2bef9479fd0abc6fd921ebbadd973a0ab87ea | estraviz/codewars | /6_kyu/longest_palindrome/python/solution.py | 416 | 3.828125 | 4 | """longest_palindrome"""
def longest_palindrome(s):
max_len = 0
for i in range(len(s)):
for j in range(len(s), i, -1):
if max_len >= j - i:
break
else:
sub_s = s[i:j]
if is_palindrome(sub_s):
max_len = len(sub_... |
73ba0fbc53035091d7662b99e7e7158a04024c6f | estraviz/codewars | /7_kyu/Sum of squares less than some number/get_number_of_squares.py | 245 | 3.953125 | 4 | """
Sum of squares less than some number
"""
def get_number_of_squares(n):
sum_, count = 0, 0
for num in range(1, n):
sum_ += num**2
if sum_ >= n:
break
else:
count += 1
return count
|
d9c522249e1a64c9f080568c8ecdf8ef528ff79e | estraviz/codewars | /6_kyu/Count the smiley faces/count_smileys.py | 318 | 4 | 4 | """
Count the smiley faces!
"""
def count_smileys(arr):
return sum(1 for s in arr if is_a_smiley(s))
def is_a_smiley(s):
eyes, noses, mouths = (':', ';'), ('-', '~', ''), (')', 'D')
eye, nose, mouth = s[0], s[1:-1], s[-1]
return True if eye in eyes and nose in noses and mouth in mouths else False
|
000fd11c972961222698155f5d35c05a5e894711 | estraviz/codewars | /7_kyu/Powers of 3/largest_power.py | 125 | 4 | 4 | """
Powers of 3
"""
from math import log
def largest_power(N):
k = int(log(N, 3))
return k if 3**k < N else k - 1
|
d5c3804bfde555369535d44e101d72cf3defe45b | estraviz/codewars | /5_kyu/Simple Pig Latin/pig_it.py | 175 | 3.640625 | 4 | """Simple Pig Latin
"""
def pig_it(txt):
return " ".join(word if not word.isalpha() else
"".join([word[1:], word[0], 'ay']) for word in txt.split())
|
db2b089606929b096fd5aa218d10ee966dfdcf43 | estraviz/codewars | /7_kyu/Exclamation marks series #3: Remove all exclamation marks from sentence except at the end/python/solution.py | 360 | 3.921875 | 4 | # Exclamation marks series #3: Remove all exclamation marks from sentence except at the end
from collections import Counter
def remove(s):
num_excl_tot = Counter(s)['!']
num_excl_end = 0
for c in s[::-1]:
if c == '!':
num_excl_end += 1
else:
break
return s.repla... |
96523b03a0eba9882e7eff50e76e97b04050ffb5 | estraviz/codewars | /7_kyu/Get the integers between two numbers/python/solution.py | 118 | 3.5625 | 4 | # Get the integers between two numbers
def function(start_num, end_num):
return list(range(start_num+1, end_num))
|
eef811b3ab71a158b5f8cb3261d048b114a36be4 | estraviz/codewars | /7_kyu/Fix string case/python/solution.py | 296 | 3.890625 | 4 | """Fix string case"""
from string import ascii_lowercase as asc_low, ascii_uppercase as asc_upp
def solve(s):
lower, upper = sum_case(s, asc_low), sum_case(s, asc_upp)
return s.lower() if lower >= upper else s.upper()
def sum_case(s, case):
return sum(1 for x in s if x in case)
|
0473ab731b8a88302ff2bac22f2ad2b019d09232 | estraviz/codewars | /8_kyu/Return the day/test_whatday.py | 520 | 4.09375 | 4 | from whatday import whatday
def test_return_weekday():
assert whatday(1) == 'Sunday'
assert whatday(2) == 'Monday'
assert whatday(3) == 'Tuesday'
assert whatday(4) == 'Wednesday'
assert whatday(5) == 'Thursday'
assert whatday(6) == 'Friday'
assert whatday(7) == 'Saturday'
assert whatda... |
9f786edefc48fb0a3738c6727383bfe4ccba01e5 | estraviz/codewars | /6_kyu/String Letter Counting/python/solution.py | 304 | 3.75 | 4 | """String Letter Counting"""
from collections import Counter
from collections import OrderedDict
def string_letter_count(s):
counts = Counter(filter(str.isalpha, s.lower()))
ordered_counts = OrderedDict(sorted(counts.items()))
return "".join(str(v) + k for k, v in ordered_counts.items())
|
197da6bf0d27dd2242e46e72357b274d8557c1ed | estraviz/codewars | /6_kyu/Format words into a sentence/python/solution.py | 274 | 3.9375 | 4 | """Format words into a sentence"""
def format_words(words):
if not words or not (words := [word for word in words if word]):
return ""
if len(words) == 1:
return words[0]
return " and ".join([", ".join(word for word in words[:-1]), words[-1]])
|
a1ec69a315468f2aab80627022aefd44095cda72 | estraviz/codewars | /7_kyu/Random case/random_case.py | 131 | 3.546875 | 4 | """
Random case
"""
from random import choice
def random_case(x):
return "".join(choice([c.lower(), c.upper()]) for c in x)
|
7e783fbd14bbe856b742e66aad16c965b0ce73e6 | estraviz/codewars | /7_kyu/Mirror, mirror, on the wall.../solution.py | 139 | 3.515625 | 4 | """Mirror, mirror, on the wall...
"""
def mirror(data: list) -> list:
arr = sorted(data, reverse=False)
return arr + arr[-2::-1]
|
d267276151ae7cd7c255bb521ada062b2784626d | estraviz/codewars | /7_kyu/Diagonals sum/test_sum_diagonals.py | 596 | 3.515625 | 4 | from sum_diagonals import sum_diagonals
def test_0x0():
matrix = []
assert sum_diagonals(matrix) == 0
def test_1x1():
matrix = [[4]]
assert sum_diagonals(matrix) == 8
def test_2x2():
matrix = [[1, 2], [3, 4]]
assert sum_diagonals(matrix) == 1 + 2 + 3 + 4
def test_3x3():
assert sum_di... |
f65b17af4241da3013f9c69520ba0e173f25a444 | estraviz/codewars | /6_kyu/Playing with digits/dig_pow.py | 213 | 3.859375 | 4 | """Playing with digits
"""
def dig_pow(n, p):
sum_of_powers = 0
for digit in str(n):
sum_of_powers += int(digit)**p
p += 1
return sum_of_powers // n if sum_of_powers % n == 0 else -1
|
b534c9de2a6a90c1df469c8dd8732a767eae9399 | estraviz/codewars | /7_kyu/Sub-array elements sum/elements_sum.py | 256 | 3.5 | 4 | """
Sub-array elements sum
"""
def elements_sum(arr, d=0):
add, ind = 0, 1
for elem in arr:
try:
add += elem[len(arr) - ind]
except IndexError:
add += d
finally:
ind += 1
return add
|
8d7b10967ec36abc7615249ed582af64e9b4bef3 | estraviz/codewars | /8_kyu/How much water do I need?/how_much_water.py | 200 | 3.859375 | 4 | """How much water do I need?
"""
def how_much_water(W, L, C):
if C > 2*L:
return 'Too much clothes'
if C < L:
return 'Not enough clothes'
return round(W*(1.1)**(C-L), 2)
|
72ac94ce04d671d1de0786053d26ce7c93ad443d | estraviz/codewars | /7_kyu/Swap the head and the tail/swap_head_tail.py | 264 | 4.0625 | 4 | """
Swap the head and the tail
"""
def swap_head_tail(arr):
if len(arr) % 2 == 0:
return arr[len(arr)//2:len(arr)] + arr[0:len(arr)//2]
else:
return arr[len(arr)//2 + 1:len(arr)] + [arr[len(arr)//2]] + \
arr[0:len(arr)//2]
|
c6c1bc942915185ef940032a4423f8b4c6a87ac1 | estraviz/codewars | /8_kyu/Geometry Basics: Distance between points in 2D/test_distance_between_points.py | 818 | 3.78125 | 4 | from distance_between_points import distance_between_points
from random import random
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def test_distance_between_points_simple():
a = Point(3, 3)
b = Point(3, 3)
assert distance_between_points(a, b) == 0
a = Point(1, 6)... |
d68ccd24394df9742be117ea664a0b3a0e7c36f1 | estraviz/codewars | /7_kyu/The Poet And The Pendulum/pendulum.py | 271 | 3.5625 | 4 | from collections import deque
def pendulum(values):
output = deque(maxlen=len(values))
for i, value in enumerate(sorted(values)):
if i % 2 == 0:
output.appendleft(value)
else:
output.append(value)
return list(output)
|
aeb9c81afe351384651922b78fe562e976a1f65c | estraviz/codewars | /7_kyu/Coding Meetup #5 - Higher-Order Functions Series - Prepare the count of languages/python/solution.py | 312 | 3.75 | 4 | # Coding Meetup #5 - Higher-Order Functions Series - Prepare the count of languages
from collections import defaultdict
def count_languages(lst):
result = defaultdict(int)
for obj in lst:
for k, v in obj.items():
if k == 'language':
result[v] += 1
return result
|
254499831e93bed31ae2a0269ec6404af00a26e6 | estraviz/codewars | /7_kyu/Return the first M multiples of N/multiples.py | 109 | 3.9375 | 4 | """
Return the first M multiples of N
"""
def multiples(m, n):
return [k * n for k in range(1, m + 1)]
|
2f6f4c7cd89ff9beadcbad34c9d32aabcc6f2397 | estraviz/codewars | /7_kyu/Sum even numbers/python/solution.py | 97 | 3.640625 | 4 | """Sum even numbers"""
def sum_even_numbers(seq):
return sum(x for x in seq if x % 2 == 0)
|
3c7cb65ff461feeb701411670437bd6eeb4358eb | estraviz/codewars | /8_kyu/Job Matching #1/test_match.py | 507 | 3.5 | 4 | from match import match
candidate1 = {'min_salary': 120000}
candidate2 = {'min_salary': 190000}
job1 = {'max_salary': 130000}
job2 = {'max_salary': 80000}
job3 = {'max_salary': 171000}
def test_valid_matches():
assert match(candidate1, job1) is True
assert match(candidate1, job3) is True
assert match(c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.