blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2d61581300cb377d16bc4f50cfbaa88471c7eadb
REGENTMONK97/Python-
/Functions/tuple segment print.py
227
3.859375
4
t = (1,2,3,4,5,6,7,8,9,10) def tuple_print(t): t = list(t) n = len(t) for i in range(int(n/2)): print(t[i],end=' ') print() for i in range(int(n/2),n,1): print(t[i],end=' ') tuple_print(t)
de887f86beedb1fda4ac673f35f936f151139d62
REGENTMONK97/Python-
/Functions/div by 7.py
139
3.625
4
import sys if len(sys.argv) == 2: n = int (sys.argv[1]) if n%7 == 0: print(n) else: print('not divisibe by 7')
badfcb27e7cb765782bf524de343300fca4cdfd2
REGENTMONK97/Python-
/Command_Line_Argument/List Based/Largest or smallest.py
216
4
4
from sys import argv s = [] print("Enter the number of elements") n = int(argv[1]) for i in range(2, n+2, 1): s.append(argv[i]) M = max(s) m = min(s) print("Largest number is ",M) print("Smallest number is ",m)
01309ebf6a9419c8a51879d7118414eb49fd2c8e
REGENTMONK97/Python-
/Control Statements/pattern3.py
182
3.71875
4
for i in range(0,8,1): for j in range(1,5-i,1): pass if j<=0: for k in range(0,8-i,1): pass print('* '*k) else: print('* '*j)
a348e5d76cdd5dafe144ad01ff6cfe2a6a5df105
REGENTMONK97/Python-
/Lists and Tuples/Tuples/Repeated item.py
427
3.828125
4
b = [] a = input("Enter all data separated by comma") a = a.lstrip() a1 = a.split(',') tuple(a1) #Finding repeated elements in tuple l = len(tuple(a1)) for i in range(0,int(l/2)+1,1): count = 1 for j in range(l-1-i,i,-1): #print(tuple(a1)[j],end=' ') if tuple(a1)[i] == tuple(a1)[j]: ...
684b2dc423d82e7d39bcb539c37831c46b396d22
azamsharp/learning-python-week-two
/day1_assignment/grocery_app.py
3,339
4.25
4
# Grocery App from classes import Store, Grocery def greeting(): print("\nWelcome to our Grocery List App.\nPlease review the upcoming options carefully:\n") def farewell(): print("\nThanks for using our App!\nGoodbye!") def view_stores(): print("\nBelow are your stores:") print("--------------------...
06b46c5a381dd01c440748251d38d3c59fd3fa82
nicolasportela/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-append_write.py
272
4.21875
4
#!/usr/bin/python3 """this module contains a function to append a string at the end of a text file""" def append_write(filename="", text=""): """function to append at the end""" with open(filename, "a", encoding="UTF8") as file: return file.write(text)
7568f09273c1be7bffb0b5785d2357fe200017cb
nicolasportela/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
869
4.375
4
#!/usr/bin/python3 """ This module contains a function which prints a text with 2 new lines after any of these characters: ., ? and : """ def text_indentation(text): """The function takes a string and prints it, replacing each period (.), double colon (:) and question mark (?) for two empty lines. Args: ...
8326e3df51574193cf4b9d64f7f3e20c380ff58a
nicolasportela/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/tests/6-max_integer_test.py
1,233
3.921875
4
#!/usr/bin/python3 """Unittest for max_integer([..]) """ import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): """List of tests""" def test_ints(self): """test with a list of ints""" self.assertEqual(max_integer([1, 2, 8, 4]), 8) de...
4532e7bec842968a34ed7c5f1f12e517dec4adf2
nicolasportela/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
213
3.703125
4
#!/usr/bin/python3 """checks if an object is exactly an instance of the specified class""" def is_same_class(obj, a_class): """True if it is an instance, False otherwise""" return type(obj) == a_class
a050e1861b52c6dc44ab2ad1aba836e6517b51ef
nicolasportela/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
303
4.09375
4
#!/usr/bin/python3 """Class MyList that inherits from list""" class MyList(list): """Public instance method that prints the list sorted (ascending)""" def print_sorted(self): """all elements will be type int""" if issubclass(MyList, list): print(sorted(self))
5edef08e2759a35e9d3aa4729c6c7bf2b0b32cdb
ereynolds123/introToProgramming
/bitcoin_converter.py
462
4.125
4
# Convert Bitcoin to Dollars # prinn conversion statemtn print("As of 1/15/2021 at 5:26 AM, Bitcoin is currently trading at $38, 508.73.") #user inputs amount of bitcoin bitcoinAmount = (int(input("How much Bitcoin do you own? Enter a number: "))) #value of bitcoin calculated bitcoinValue = (bitcoinAmount * 38508.72) ...
3a5c019be9f204b73e7794d9e90e5ad784c3a46b
ereynolds123/introToProgramming
/celciusconverter.py
935
3.84375
4
#Imports graphics library from graphics import * def createConverter(): win= GraphWin("Celsius Converter", 400, 300) win.setCoords(0.0, 0.0, 3.0, 4.0) #Draw the interface Text(Point(1,3), "Celsius Temperature:" ).draw(win) Text(Point(1, 1), "Fahrenheit Temperature:" ).draw(win) inputText=...
497638a5f983d6c4ff3788a05b7d22de51ea2f82
ereynolds123/introToProgramming
/golfClub.py
1,194
4.09375
4
# A program to determine the club for golfing #Print opening statements print("Welcome to the Golf Club Helper!") print("Tell me your situation, and I'll recommend a club.") #Get input from user on if they are on the green and how far from the hole they are onGreen = input("Did you hit the ball on the green (y/n)? ")...
cabd288f8a3779b8b441e1c4919af1d9fc670a88
ereynolds123/introToProgramming
/harrypotterfinal.py
9,988
3.984375
4
#An adventure text based game #Import necessary dependencies import random #Create class enemies class Enemy(): def __init__(self, nameEnemy, probOfWin): self.nameEnemy= nameEnemy self.probOfWin= probOfWin def getEnemyName(self): return self.nameEnemy def getProb(self...
3dadbed299ace690289242b034fcc6f141cc478f
ereynolds123/introToProgramming
/password.py
400
4.25
4
while True: password = input("Enter your new password: ") while True: if len(password) >=7: break print("Your password must be at least 7 characters.") password= input("Enter your new password: ") secondPassword = input("Enter your password again: ") if secondPas...
c841741255a48320def1ae4eb03b36f6bf8598d8
ereynolds123/introToProgramming
/ecount.py
580
4.03125
4
#numberOfWords =int(input("How many words will you enter: ")) countOfEs = 0 totalWords= 1 sentinel="quit" #for index in range(numberOfWords): #inputWord =input("Enter word {0}: ".format(index +1)) #countOfEs =countOfEs + inputWord.count("e") #totalLengthOfInput = totalLengthOfInput +len(inputWord) #anot...
a853812c747e8cc9739036a56eb8984618efb2f1
ereynolds123/introToProgramming
/sum.py
485
4.21875
4
#function call print("Hello World!") #print is the function name. Takes information and prints to the console # the "Hello world" in parantheses is an argument #calls the print value, evaluates the arugments #expression print(3+4) # 3+4 is an expression #3 and 4 are literals. they are the values # + is an operator #a...
20c21ef167937a2d49113efb08d59364114b96db
gpspelle/learning-python
/ML/poly_regression.py
947
3.8125
4
import matplotlib.pyplot as plt import numpy as np # Olympic's data from 100 metres freestyle over the years # Notes: 1900, 1904, 1916, 1940 and 1944 aren't on the set of years years = [1896, 1908, 1912, 1920, 1924, 1928, 1932, 1936, 1948, 1952, 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, ...
db8806c1d2ec4b5c6296db76d3efe2422646c3bd
gpspelle/learning-python
/Python/exercises/eliminate_duplicates.py
263
3.78125
4
def remove_duplicates(lis): new_lis = [] for i in range(0, len(lis)-1): if lis[i] not in new_lis: new_lis.append(lis[i]) lis[i] = -1 return new_lis lis = [1, 1, 2, 2, 3, 3] new_lis = remove_duplicates(lis) print new_lis
f1d785ff3ef7a6221fb6ce4124b9c818914de93e
gpspelle/learning-python
/Python/exercises/odd_even.py
263
4.25
4
print("Enter a integer") number = int(input()) if number % 4 == 0: print("The number " + str(number) + " is multiple of 4") elif number % 2 == 0: print("The number " + str(number) + " is odd!") else: print("The number " + str(number) + " is even!")
ff0982cdf4a6cccd6a730ef466dade14a76b3ace
hulyacetin/Algoritma-Analizi-Dersi-2017
/4.hafta_odev/n_kare_insertion_sort.py
860
3.8125
4
import numpy as np import matplotlib.pyplot as plt import random import time import math def insertionSort(alist): for index in range(1,len(alist)): currentvalue = alist[index] position = index while position>0 and alist[position-1]>currentvalue: alist[position]=alist[position-1] ...
e7874638262aab63ba11d4ca8681098a90be6edc
yevgenikuznetsov/Tic_Tac_Toe
/Open_Windows.py
1,400
3.75
4
from tkinter import * from WindowsHandler import * ONE_PLAYER_MODE = 1 TWO_PLAYERS_MODE = 2 NUMBER_OF_OPEN_WINDOWS = 1 mainWindow = Tk() mainWindow.title("Tic Tac Toe") mainWindow.geometry("470x300+300+100") mainWindow.wm_attributes("-topmost", 1) window_text = "" mainWindowLabel = Label(mainWindow, font=" none 30 b...
a418840c11cb7bda08efce553884f5bb791cf25b
AntonSlivaev/GeekBrains_Python
/3.py
229
3.6875
4
def my_function(x, y, z): list = [x, y, z] total= [] max_1 = max(list) total.append(max_1) list.remove(max_1) max_2 = max(list) total.append(max_2) print(sum(total)) my_function(1, 3, 5)
e965a14ab90fe6d2b42dfd6d23999ff2db99a0ca
MatiasDuhalde/contenidos
/semana-04/ejercicios_propuestos/04-Generadores.py
477
3.578125
4
def es_primo(nr): if nr > 1: for i in range(2, nr): if not (nr % i): return False return True return False def iterador_primos(): # Completar utlizando yield, recuerda que debe ser un generador i = 2 while True: if es_primo(i): yield i...
75346a232adc2ecdfa3c7f6f992f473493b36d80
MatiasDuhalde/contenidos
/semana-12-13/Ejemplos/server.py
3,772
3.8125
4
import socket import threading class Server: def __init__(self, port, host): print("Inicializando servidor...") self.host = host self.port = port self.socket_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.bind_and_listen() self.accept_connections()...
a97e7f92c34e3cb8045625a58f9661a48db55df4
MatiasDuhalde/contenidos
/semana-04/ejercicios_propuestos/03-Reduce_y_Map.py
714
3.640625
4
import random from functools import reduce numeros = [random.randint(0, 15) for _ in range(100)] def factorial(n): # Completa la función haciendo uso de reduce. # Recuerda que factorial de 0 es 1. (Puedes implementar ese caso especifico sin reduce) if n <= 0: return 0 else: return red...
7e0c69f0cf125028c5eaa6013c4831fab4c7d56d
MatiasDuhalde/contenidos
/semana-09/ejercicios_propuestos/04-Arbol_binario.py
2,199
3.546875
4
# textwrap tiene varias funciones convenientes para el manejo de strings from textwrap import indent from collections import deque class ArbolBinario: def __init__(self, id_nodo, valor=None, padre=None): self.id_nodo = id_nodo self.padre = padre self.valor = valor self.hijo_izquierd...
b19df5a8cb589ef20c221a416d2dab4a45cff8c6
19h61a0519/vamshi-krishna
/even_or_odd.py
220
4.3125
4
#wap to check whether the given number is even or odd a=int(input("Enter a number to check if a number is even or odd...\n")) if a%2==0: print(str(a)+" is an Even Number") else: print(str(a)+" is an Odd Number ")
6839cfa4e54ad4c6722cce97a344efa7cc920b61
MuSaCN/PythonLearning
/Learning_Basic/老男孩Python学习代码/day2-基本数据结构/test.py
602
3.546875
4
# Author:Zhang Yuan import copy #浅copy本质上是引用,只能第一层不治,列表中的列表只复制指针 var1=['name',['a',100]] #引用的三种方式 p1=copy.copy(var1)#string会新建立内存,但是列表只复制指针 p2=var1[:] #string会新建立内存,但是列表只复制指针 p3=list(var1) #string会新建立内存,但是列表只复制指针 print(p1,p2,p3) p4=p1 #若直接用=,则建立指针 p1[0]='abc' #只修改p1,不影响p2,p3 p2[0]='def' #只修改p2,不影响p1,p3 p3...
2cc9e5a222c2ceb368451eee383d59d97b34828d
MuSaCN/PythonLearning
/Learning_Basic/Python基础教程学习代码/chapter02---List And Tuple/test2.py
203
3.5
4
# Author:Zhang Yuan database=[ ["a1","1234"],["a2","2345"],["a3","3456"],["a4","4567"] ] name=input("name:") code=input("code:") if [name,code] in database: print("OK") else: print("wrong")
628baed0dcdaa9ff7430fb16af6acb376fa4496a
MuSaCN/PythonLearning
/Learning_Quant/python金融大数据挖掘与分析全流程详解/第1章源代码汇总/1.3.1 if条件语句介绍.py
594
3.75
4
# ============================================================================= # 1.3.1 if语句 by 华能信托-王宇韬 # ============================================================================= score = 100 year = 2018 if (score < 0) and (year == 2018): print('录入数据库') else: print('不录入数据库') score = 85 if score >= 60: ...
78a60f813957ab66dce7836e4f198f3895700eeb
MuSaCN/PythonLearning
/Learning_Basic/Python基础教程学习代码/chapter06---抽象/6.1Fibonacci函数.py
331
3.859375
4
# Author:Zhang Yuan def Fibs(num): "Calculate Fibonacci Series" base=[0,1] if num==0 or num==1:return None if num==1 :return [0] for i in range(num-2): base.append(base[i]+base[i+1]) #更简单 #base.append(base[-1]+base[-2]) return base print(Fibs(9)) print(Fibs.__doc__) help...
ec796ba1a898027c095172ffccb22f77e62f31a5
MuSaCN/PythonLearning
/Learning_Basic/Python基础教程学习代码/chapter03---String/字符串方法.py
1,248
4
4
# Author:Zhang Yuan text="what is your name" print(text.center(27,"*")) a=["a","b","c","d","e"] b="ABC" print(b.join(a),b) #f字符串 year = 2016 event = 'Referendum' print(f'Results of the {year} {event}') #字典传递到字符串 table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678} print('Jack: {0}; Sjoerd: {1}; ' 'Dcab: {2}...
35c6a18efbe7fdec81ffd30b87e4f1d9d3988317
MuSaCN/PythonLearning
/Learning_Basic/老男孩Python学习代码/day2-基本数据结构/3level_menus.py
1,264
3.75
4
# Author:Zhang Yuan data={ "AnHui":{ "HeFei":{ "FeiXi":"肥西", "FeiDong":"肥东" }, "LuAn":{ "YuAn":"裕安", "JinAn":"金安" } }, "ShangHai":{ "PuDong":{ "LuJiaZui":"陆家嘴" }, "XuHui":{ "XuJiaH...
a3d7d0acebf64615eb0b13b73481326a931e4b2a
MuSaCN/PythonLearning
/__文档自学与总结/1.数据结构.py
5,915
3.921875
4
# Author:Zhang Yuan #PS:列表List与List[:]值相同,但不是一个对象 words = ['cat', 'window', 'defenestrate'] for w in words: print(w, len(w)) #如果写成 for w in words:,这个示例就会创建无限长的列表,一次又一次重复地插入 defenestrate。 for w in words[:]: # words与words[:]不是一个对象,值相同而已 if len(w) > 6: words.insert(0, w) print(words,words == words[:],word...
136cccc171906503662c93da9838eb630d14eea0
MuSaCN/PythonLearning
/Learning_Basic/老男孩Python学习代码/day1-介绍与循环/guess.py
559
3.84375
4
# Author:Zhang Yuan #study age_of_oldboy=57 count=0 while count<3: guess_age = int(input("guess age:")) if guess_age==age_of_oldboy: print("yes") break elif guess_age > age_of_oldboy: print("big") else: print("small") count+=1 else: print("you are tried too many...
ab5660a77ffab364d1adf0bc7ef94a16db3d8f67
MuSaCN/PythonLearning
/Learning_Basic/Python核心编程学习代码/Chapter4---多线程/4.4锁Lock()与可重复锁RLock().py
2,036
3.703125
4
# Author:Zhang Yuan #锁能够防止多个线程同时进入公共临界区 import threading,time num = 0 #创建lock对象,这句必须要有,指向一个锁。且只能acquire()一次------------------------------------ lock = threading.Lock() def run(n): #如果不加入锁,print的内容会混乱 lock.acquire() #获得锁,锁住状态。每次只能有一个线程访问 global num print("first",n,num) num +=1 print("second",n,nu...
668a42ef9912a1711608635d99125f8c04cec41a
MuSaCN/PythonLearning
/__文档自学与总结/3.异常和类.py
3,413
3.53125
4
# Author:Zhang Yuan class B(Exception):pass class C(B):pass class D(C):pass class E:pass #如果发生的异常和 except 子句中的类是同一个类或者是它的基类,则异常和except子句中的类是兼容的 for cls in [B, C, D]: try: raise cls() #引发异常时执行 except B: print("B") except D: print("D") except C: print("C") #不引发异常时执...
c69d72cc7511ae6c9530404e2892088a82e2f3c4
MuSaCN/PythonLearning
/Learning_Basic/Python基础教程学习代码/chapter05---条件循环及其他语句/迭代时获取索引.py
143
3.75
4
# Author:Zhang Yuan name=["a","b","c","a","e","f","a"] #枚举化序列,可以自动获取索引 for i,j in enumerate(name): print(i,j)
c21896394e516e12e2f8ece9e5993ea154b39916
bengranett/minimask
/minimask/sphere.py
5,008
3.625
4
"""spherical geometry utilities""" import numpy as np import utils # degrees to radian conversions c = np.pi/180 ic = 180/np.pi def distance(ra1,dec1,ra2,dec2): """ compute distance between two points on the sphere using the haversine formula Inputs ------ ra1 dec1 ra2 dec2 Outputs ------- distance (deg...
664296dd3396d79178a1988885b1c563fc719ec4
jrpotter/fifth
/src/cam.py
3,439
3.53125
4
""" Top level module representing a Cellular Automata Machine. The CAM consists of a number of cell planes that allow for increasingly complex cellular automata. This is the top-level module that should be used by anyone wanting to work with fifth, and provides all methods needed (i.e. supported) to interact/configure...
9366e8001d4ef83618b94a0880757ea53ea108ef
marisapug/PigLatin
/Python.py
569
4.03125
4
vowels = ["a", "e", "i", "o", "u"] def piglatin(str): if str[0] in vowels: return str + "ay" elif str[0] not in vowels and str[1] not in vowels: return str[2:] + str[0] + str[1] + "ay" elif str[0] not in vowels: return str[1:] + str[0] + "ay" def translate(text): words = text.s...
74a1e827044dd1136a638425039c0e6a5b671993
Trumbu/ph464-fall2018
/students/one_MichaelTrumbull/fitDiamond.py
1,930
3.6875
4
import numpy as np import matplotlib.pyplot as plt """ This file loads/plots 2-column-data from /data/data.txt then finds two polyfits x in [3,10] """ def mindata(file): ### Load data ### data = np.loadtxt(file) print (data) x = data[:,0] y = data[:,1] ### Plot data ### plt.plot(x,y,"o",l...
d02472a20ea1c8f21049eebe08322a0a904ac318
tejanogenard/cs-module-project-algorithms
/moving_zeroes/moving_zeroes.py
887
4.34375
4
''' Input: a List of integers Returns: a List of integers Write a function that takes an array of integers and moves each non-zero integer to the left side of the array, then returns the altered array. The order of the non-zero integers does not matter in the mutated array. ''' def moving_zeroes(arr): # iterate thr...
15ca0e8471a963c1ec8cfb13d5b63d53698b9273
kchipp/RPSLSversion2
/Players.py
812
3.75
4
class Players: def __init__(self, player): self.player = player self.playerChoice = None def chooseShot(): playerChoice = input("Player-Make your Choice: ") playerChoice = playerChoice.lower() aValidChoice = self.validChoice(playerChoice) ...
3712197102105d8913a0e2494f9dbe38d20a3778
TannerLow/Project-Euler-Solutions
/Python/Problem34/Problem 34.py
485
3.578125
4
total_sum = 0 def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) factorials = [1, factorial(1), factorial(2), factorial(3), factorial(4), factorial(5), factorial(6), factorial(7), factorial(8), factorial(9)] for i in range(144,factorial(9)*7): sum = 0 number = i while number > 0: ...
c17f04ed12bef65a5602d12add49c7ecff38e604
alphatsai/BPIXColdBox
/elcomandanteGUI/example/genTemperature/tempCosine.py
337
3.765625
4
#!/usr/bin/env python import sys, math if len(sys.argv) < 3: print '>> [INFO] Please input maximum temperature and angle' print '>> Ex. ./cosine [max T] [angle]' sys.exit() maxTemp = sys.argv[1] angle = sys.argv[2] graidian = 5 temperature = float(maxTemp)*math.cos(int(angle)*graidian*math.pi/180) print '%...
94ccadb02a4e1d3ae6f2fcecb8895f1ae560ed1a
nyccowgirl/generator_log
/generator_practice.py
352
3.96875
4
# Within range of 0 up to and including stop value def halves(stop, step): start = 0 while start <= stop: yield float(start) start += step print(list(halves(10, 0.5))) # Infinite range from 0 def halves(step): start = 0 while True: yield float(start) start += step for...
bafae8927cb80a6c29170d7c286074c99358f1c8
Krathinavada15/krathinavada
/ASSIGNMENT_PYTHON/M1/Q7.py
291
4.0625
4
"""7.Write a program to accept a number from the user and determine the sum of digits of that number. Repeat the operation until the sum gets to be a single digit number.""" n = int(input("enter n ")) sum = 0 while n!=0: sum+=n%10 n=n//10 print(f"sum of digits is {sum}")
45ca66840561d044e14546ead7bee56198162fa6
soultreemk/Coding-Test
/4. array.py
1,832
3.71875
4
#code test #정렬 ## 1. K번째 수 ### 1 def solution10(array, commands): answer = [] for a in commands: i, j, k = a[0], a[1], a[2] se = array[i-1:j] #slice 함수 사용(잘라낼 때) se.sort() #정렬 answer.append(se[k-1]) #답에 붙여넣기(인덱싱) return a...
1b1ead68eced50ff80b01dd5f95fe9b5f8487e14
Lesley9589/areaofcircle
/Hello.py
318
4.125
4
print("Hello Guys! How are you?") print("Learning Python is Fun with Life Choices") print(5+9) ''' firstname=input("What is your name?") print("My name is ", firstname) ''' #============================================= radius=int(input("please enter radius")) pi=3.14 area=pi * radius*radius print(round(area, 2))
3e521cacc212f7ea433654ab53b7ecd46f790911
chg0421/Assignment2
/command_line.py
991
3.53125
4
import sys class CommandLine: # renee @staticmethod def greeting(): try: print(sys.argv[1]) except NameError as e: print(e) except IndexError as e: print("Index Error :", e) # Jono @staticmethod def set_name(): ...
7f947e4dab3998140db9dba8689342eb6910fb8e
FrankSpinachi/testrepo
/randomgame.py
293
3.671875
4
import sys from random import randint start = int(sys.argv[1]) stop = int(sys.argv[2]) lol = int(sys.argv[3]) x = randint(start,stop) print(f'guess the number in range from {start}, to {stop}') if lol==x: print('Good job u guessed rigt') else: print(f'try again it was {x}')
10682c453f409ef4a0b3d790ab11e99d2c56e68e
Luis-Felipe-N/curso-em-video-python
/modulo-1/exercicios/022-upper,lower,len.py
544
4.25
4
# Ler um nome completo de uma pessoa e mostrar: nome = input('Digite seu nome completo: ') # Separar o nome nome_split = nome.split() # O nome com todas letras maiúsculas print(f'Seu nome em maiúsculo fica {nome.upper()}.') # O nome com todas letras minúsculas print(f'Seu nome em minúsculo fica {nome.lower()}.') # ...
a19bb5ddf76851fa4f4b7c69286278c5b0db95db
Luis-Felipe-N/curso-em-video-python
/modulo-3/exercicios/092-carteira.py
1,432
3.875
4
from datetime import date # FAZER UM PROGAMA QUE LEIA O NOME, ANO DE NASCIMETO, E A CARTEIRA DE TRABALHO DE UMA PESSOA # CADASTRE A IDADE DA PESSOA # SE O CTPS FOR != DE 0, O DICIONÁRIO RECEBERÁ TAMBÉM O ANO DE CONTRATAÇÃO E O SALÁRIO # CALCULE E ACRESCENTE, ALÉM DA IDADE, COM QUANTOS ANOS A PESSOA VAI SE APOSENTAR #...
1f9a8f672f85b65faecaec81c45205fb54389e73
Luis-Felipe-N/curso-em-video-python
/modulo-2/exercicios/068-par_impar.py
1,392
3.875
4
from random import randint# IMPORTANDO FUNÇÃO DO MÓDULO RANDOM == ALEÁTORIo venceu = 0# CONTADOR VAI MOSTRAR QUANTAS VEZES O USUÁRIO GANHOU print('-' * 30) print('VAMOS JOGAR IMPAR OU PAR!') while True:# CRIANDO LOOP INFINITO print('-' * 30) num_usuario = int(input('Escolha um número: ')) num_computador = r...
9e270cffd3b6abf4d172616fc3dce57205de5008
Luis-Felipe-N/curso-em-video-python
/modulo-3/exercicios/094-cadastrar_pessoas.py
1,755
3.84375
4
# FAZER UM PROGAMA QUE LEI NOME, SEXO E IDADE DE VÁRIAS PESSAOS E GUARDAR OS DADOS EM UMA LISTA # NO FINAL MOSTRAR: pessoas = [] dados = {} idade = [] while True: print('-' * 30) dados['nome'] = str(input('Nome: ')) dados['idade'] = int(input('Idade: ')) dados['sexo'] = str(input('Sexo [M/F]: ')).s...
94ec09625f81f98e213573c8deb55fc600968557
Luis-Felipe-N/curso-em-video-python
/modulo-3/exercicios/099-maior_menor_semax.py
799
3.765625
4
from time import sleep def maior(lis): for e, n in enumerate(lis): if e == 0 : maiorNumero = n elif n > maiorNumero: maiorNumero = n print(maiorNumero) lista_de_numeros_maoir = [] quant_num = int(input('Quantos números quer analisar: ')) if quant_num == 0: print('...
b372a6186ad24adb579bf57e03c8ca6f07703333
Luis-Felipe-N/curso-em-video-python
/modulo-2/exercicios/040-media.py
609
3.84375
4
# Fazer um progama que leia duas notas e mostre: # Média abaixo de 5.0 - REPROVADO # Média entre 5.0 de 6.9 - RECUPERAÇÃO # Média 7.0 ou superior - APROVADO # Pedindo as notas nota1 = float(input('Primeira nota:')) nota2 = float(input('Segunda nota:')) media = (nota1 + nota2) / 2 if media < 5: print('Sua média é...
2270c9e06a525521450340aff916eb949221cc81
Luis-Felipe-N/curso-em-video-python
/modulo-1/exercicios/031-custo_da_viagem.py
400
3.890625
4
# Fazer uma progama que pergunte a distânsia de uma viagem em km. # Sendo o preço da passagem, 0,50$ por km e 0,45$ para viagens acima de 200km # Pedi adistância da viagem distancia = float(input('Digite em km a distância da viagem: ')) # Mostre o valor da viagem if distancia <= 200: print(f'Sua viagem ficou {dis...
d0c0a52512dea40f01c4c3a49735107e1f5679f7
Luis-Felipe-N/curso-em-video-python
/modulo-2/exercicios/059-calculadora.py
1,075
4.09375
4
from time import sleep # FAZER UM PROGAMA QUE LEIA DOIS VALORES E MOSTRE UM MENU DE OPÇÕES NA TELA ''' [ 1 ] - SOMAR [ 2 ] - MULTIPLICAR [ 3 ] - MAIOR [ 4 ] - NOVOS NÚMEROS [ 5 ] - SAIR DO PROGAMA ''' n = 1 n1 = float(input('Digite o primero número: ')) n2 = float(input('Digite o segundo número: ')) while n == 1: ...
f9bdbf5a4fb63784c5493f2ec021ce6ccb90717d
Luis-Felipe-N/curso-em-video-python
/modulo-1/exercicios/026-primeira _ultima_ocorrencia.py
428
4.0625
4
# Pedi para o usuário digitar uma frase e mostrar: frase = str(input('Digite uma frase: ')).strip() frase = frase.lower() # Quantas vezes aparece o A print(f'A na frase tem {frase.count("a")} as.') # Em que posição o A aparece na primeira vez print(f'O primeiro A aparece na posição {frase.find("a") + 1}.') # Em que ...
be039ab3bb2f17617e8b183776efd9f138e44968
Luis-Felipe-N/curso-em-video-python
/modulo-1/exercicios/035-analisando_triangulo_1.py
551
4.09375
4
# Fazer um progama que leia três retas e mostre se é possível a existencia de um triangulo # Ler as três retas reta_a = float(input('Qual o comprimento da reta A em cm: ')) reta_b = float(input('Qual o comprimento da reta B em cm: ')) reta_c = float(input('Qual o comprimento da reta C em cm: ')) # Mostrar se é possív...
07bf67d6534dd92906580317e481e6e2307d1d62
Luis-Felipe-N/curso-em-video-python
/modulo-3/exercicios/075-analisando-dados_tupla.py
770
4.125
4
# FAZER UM PROGAMA QUE LEIA QUATRO VALORES E GUARDE EM UMA TUPLA E MOSTRE # QUANTAS VEZES CADA QUE O 9 APARECEU # EM QUE POSIÇÃO O 3 APARECE # QUANTOS VALORES PARES FORAM MODIFICADO # !MODIFIQUEI A SINTAXE COM BASE NA RESOLUÇÃO! # SIM, PODEMOS FAZER UMA TUPLA COM VARIOS INPUT n = (int(input("Digite um número: ")), ...
bb6def17b0e071363babca0180f8456d0f71b120
Luis-Felipe-N/curso-em-video-python
/modulo-2/exercicios/055-maior_e_menor_de_sequencia.py
320
4.09375
4
# FAZER UM PROGAMA QUE LEIA O PESO DE PESSOAS E MOSTRE O MAIOR E MENOR PESO lista_peso = [] for x in range(1, 6): peso = float(input(f'Digite o peso da {x}ª pessoa: ')) lista_peso.append(peso) print('O menor peso lido foi {}.'.format(min(lista_peso))) print('O maior peso lido foi {}.'.format(max(lista_peso)))
722dd6980b413e388ef48fd104c69c83552ab708
Luis-Felipe-N/curso-em-video-python
/modulo-3/aulas/tratamento_de_erro.py
1,638
4.21875
4
# NÃO TEM MUITO O QUE FALAR, NOSSO CÓDIGO SEMPRE TEM ALGUMAS EXEÇÕES # EXEMPLO: ESTAMOS ESPERANDO UM NÚMERO INTEIRO E O USUÁRIO INSIRE UM NÚMERO REAL, ISSO É UMA EXEÇÃO, POIS NO NOSSO CÓDIGO NÃO TEM NENHUM ERRO # a = int(input('digite um número inteiro: '))# SE O USUÁRIO COLOCAR QUALQUER COISA QUE NÃO SEJA UM NÚMERO I...
c1d4ca5bb28532722c8195bdac4e8a9bdf4e02d9
Luis-Felipe-N/curso-em-video-python
/modulo-1/aulas/math.py
531
3.578125
4
import math # O MATH É UM MÓDULO QUE JÁ VEM NO PYTHON E QUE ADICIONA MAIS ALGUMAS OPERAÇÃO MATEMÁTICA # PARA IMPORTA O MATH ULTILIZAMOS O IMPORT NO COMEÇO DO PROGAMA # O MATH TEM ALGUMAS FUÇÕES COMO raiz = math.sqrt(7) # QUE CALCULA A RAIZ QUADRADA COM isqrt() ELE RETORNA A RAIZ INTEIRA math.sin(60) # RETORNA O SENO ...
cef78e16409245bb29ce3a4350ef74ac18e21253
CoitThomas/Milestone_5
/test_convert.py
554
4.375
4
"""Verify if function convert() capitalizes all the letters in the second part of a string when the first part of the string is a positive odd integer. """ from convert_odd_input import convert def test_convert(): """Assert the correct output for various positive integers given to the function convert(). "...
ce056e2d20ce71eeb712d63524dea62121554a2a
turion/enigmake
/examples.py
2,973
3.59375
4
#! /usr/bin/python # -*- coding: utf-8 -*- """enigmake.examples""" import enigmake target1 = enigmake.Parameter(3.0, title = "target1") # The basis to build the dependent targets upon print target1() target2 = target1**4 # Operators are implemented for targets and numbers. Use numbers instead of targets if you are...
65456f2d0fa4994f6cc924d5605e9286011e09f6
AhsanUrRehmanSiddiqui/Classification
/Classification/k-NN.py
2,150
3.53125
4
import pandas as pd import csv from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.datasets import load_iris from sklearn import neighbors from sklearn import datasets iris_data = datasets.load_iris() print ('Keys:', iris_data.keys()) print ('-' * 20) p...
befad2653cf1d77617f8d476da3cd275b1d8f521
prachi3731/Python
/Py_assignment3.py
1,852
3.84375
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 20 13:17:42 2021 @author: Anand Yargole """ # 1: Create a list of 10 elements of four different data types. l = [10,20,2+4j,30,"good job",6.5,34 ] #2: Create a list of size 5 and execute the slicing structure. l = [30, 24, "mine", "yours", 3.14] print(l[0:5:...
0454b5a9a1bd13467345ca3d17fcf1da960a21e3
xaoch/SpeechZoom
/utils.py
4,675
3.59375
4
import re import datetime import os import json def preprocess_dialogue(text): """Preprocess a dialogue text to make it ready for the keywords extraction functions. Remove square brackets and add ellipses at the end of incomplete sentences. Parameters ---------- text : str Text to be preprocessed. Return...
edc6e71adda24c9b18c9b229c098d41709ef3d5c
skakunur/codefights
/triangleExistence.py
134
3.96875
4
def triangleExistence(sides): sides = sorted(sides) if sides[0] + sides[2] > sides[1]: return True return False
3e901414f645e82925ba8327fd8304b906d947e9
skakunur/codefights
/sumUpDigits.py
217
3.625
4
def sumUpDigits(inputString): answer = 0 for i in range(len(inputString)): if '1' <= inputString[i] and inputString[i] <= '9': answer += ord(inputString[i]) - ord('1') return answer
fa42029104417c59a9c03874041e370720032e82
skakunur/codefights
/digitDistanceNumber.py
144
3.53125
4
def digitDistanceNumber(n): s=str(n) r=[] for i in range(1,len(s)): r.append(str(abs(int(s[i])-int(s[i-1])))) return int("".join(r))
6d8d2d51be0a01857db39c74e7303c72a3c072c3
purveshbhele/SINGLE-SAMPLE-Z-TESTS
/data.py
1,817
3.578125
4
import statistics import pandas as pd import csv import plotly.figure_factory as ff import random df=pd.read_csv("medium_data.csv") data=df["claps"].tolist() mean=statistics.mean(data) std_dev=statistics.stdev(data) """print("Mean is",str(mean)) print("Std_dev is",str(std_dev)) fig=ff.create_distplot...
248e79fa6095df225ba6e8b46e1a27722dedc214
MathAdventurer/Data_Mining
/week10/2-nltk_stem.py
571
3.515625
4
#coding=utf8 """ Created on Sun Nov 17 12:29:00 2019 @author: Neal LONG """ import nltk porter = nltk.stem.PorterStemmer() lancaster = nltk.stem.LancasterStemmer() snow = nltk.stem.SnowballStemmer('english') word_list = ["playing", 'plays', 'played', "friendships", "friends","destabilize","is","ate","foo...
9b64621786d04583603b4eb26df714c7b744c743
MathAdventurer/Data_Mining
/quiz_1/solution/Q3-loss_function.py
3,443
3.703125
4
#coding=utf8 """ Created on Thu Mar 12 17:48:23 2020 @author: Neal LONG Hint max() is a built-in function in Python """ import pickle import math def linear_func(W,X): """ General form of a 2-d linear function with w0 as intercept W = [w0,w1,w2], X = [x1,x2] f_x = w0 + w1 * x1 + w2 * ...
aa448b229e91bb8303b6f9c7594e333829e0f96a
paulsatish/IGCSECS
/15Nov-Task2-MaxandMin.py
515
4
4
# find the maximum and minimum numbers # Task 2 # replace count<4 with "count<18" max=-999 min=999 count=1 while count<4: a=int(input("enter the temperature")) if a>max: max=a print(max) if a<min: min=a print(min) count=count+1 difference=ma...
e6082bf0cf2bb3914ebacb378f6ed87ed0bc6836
eddyhuyhp/ThreeCat
/exercises/ex35_3.py
346
4
4
#!/usr/bin/env python3 def solve(N): '''Creates a list which contains N first even integers. ``[2, 4 ...]`` Must: use list comprehension Tips: list comprehension always create new list ''' result = [i*2 for i in range(1,N+1)] return result def main(): print(solve(6)) if __name__ ...
68af3b83ac43f4f55069703eb246a41396dd92c7
chenchao0504/chenchaocentos
/string_format.py
750
3.578125
4
#!user/bin/python3.6 # -*- coding=utf-8 -*- # this is test # 欢迎来到乾颐堂 Department1 = 'Security' Department2 = 'Python' Manager1 = 'cq_bomb' Manager2 = 'qinke' COURSE_FEES1 = 25000 COURSE_FEES2 = 30000 # line1 = 'Department1 name:%-15s Manager:%-15s COUSE FFES:%-10d The End!' % (Department1,Manager1,COURSE_FEES1) # l...
19a1869217990fae3b94f23178095cfe2550fee6
Shrulk/Kosmo
/hero.py
2,081
3.671875
4
""" Это модуль нашего основоного героя """ import pygame, const, main from math import pi, sin, cos from main import display class Hero: def __init__(self): self.x_last = 0 self.y_last = 0 self.x = const.start_pos_x self.y = const.start_pos_y self.speed = 4 self.x_d...
e3b5dd5ec1889e8d54d4821c425b1302be727cf7
almoratalla/mimo-python-projects
/functions/morse_encoder.py
553
3.875
4
def convert_to_morse(code): code - code.replace("1", ".----") code - code.replace("2", "..---") code - code.replace("3", "...--") code - code.replace("4", "....-") code - code.replace("5", ".....") code - code.replace("6", "-....") code - code.replace("7", "--...") code - code.replace("...
2fe272b5cacdc547b681a70e888a4e476f43cf1f
almoratalla/mimo-python-projects
/list_comprehensions/activity_prioritiser.py
716
3.796875
4
hobbies = ["Archery", "Bowling", "Canoeing", "Dance", "Embroidery", "Flute", "Gymnastics"] while hobbies[-1] != "Dance": del hobbies[-1] number = str(len(hobbies)) print("These are your " + number + " Favourite hobbies:") print(hobbies) extras = ["Gym", "Cinema", "Restaurants", "Jewellery", "Coffee", "Netflix", ...
6c10474c5f84eb50a51547392e5baab13941853f
almoratalla/mimo-python-projects
/object-oriented_programming/vending_machine_code.py
422
3.59375
4
class Soda_Machine: paid = False balance = 0 def eject_soda(self): if self.paid == False: print('Please insert money') else: print('Enjoy the soda!') def pay(self, amount): self.balance += amount def select_soda(self): if self.balance >= 1: ...
9b7caee4c47061df723ac6ae560bfb4a8d9d95ef
DukeJefferson/python
/oddoreven.py
108
3.859375
4
c=int(input()) if c > 0: if(c%2==0): print('even') else: print('even') else: print('invalid')
238364ce0ca99b22a35ff915510c1bfd9745f883
danielbrianjohnson/CS265
/assn4/assn4.py
11,405
3.671875
4
#!/usr/bin/env python import sys def getPurchaseChange(change_needed): oneBills = 0 fiveBills = 0 tenBills = 0 twentyBills = 0 while change_needed >= 20: change_needed = change_needed - 20 twentyBills += 1 while change_needed >= 10 and change_needed < 20: change_needed =...
46dc2e13bfb11879e15c854bba919d92ace26a72
beingsoso/crazy
/climbing_stairs2.py
877
3.765625
4
class Solution(object): ''' A*(x1,x2) = (x1,x2)*(l1,l2) ''' def matrix_mul(self,x,y): y0 = x[0][0] * y[0][0] + x[0][1] * y[1][0] y1 = x[0][0] * y[0][1] + x[0][1] * y[1][1] y2 = x[1][0] * y[0][0] + x[1][1] * y[1][0] y3 = x[1][0] * y[0][1] + x[1][1] * y[1][1] r...
73cac956064c301339f8460cd22c0e90c9c400af
beingsoso/crazy
/single_numberII.py
477
3.53125
4
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ dict={} for i in range(len(nums)): if dict.has_key(nums[i])==False: dict[nums[i]]=1 else: dict[nums[i]]+=1 f...
ac143c8715d3b9d6797979c0dd06caad0f64a161
SaiMohithAmbekar/Sorting_Algorithms
/insertion_sort.py
289
3.671875
4
# Insertion Sort a=[9,3,5,2,6,4,0] for i in range(1,len(a)): value=a[i] idx=i while(idx>0 and a[idx-1]>value): a[idx]=a[idx-1] idx-=1 a[idx]=value #print(a) print(a) # Time Complexity : # Avg & Worst Case ==> O(n^2) # Best Case ==> O(n)
2c98ac956f96d11547c63a5b420bef69e37e08e9
keenajiao/Python
/since/bubble_sort.py
849
4.1875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @File : bubble_sort.py @Time : 2020/1/2119:25 @Author : crisimple @Github : https://juejin.im/user/5890963661ff4b006bebc3a5/posts @Contact : crisimple@foxmail.com @License : (C)Copyright 2017-2019, Micro-Circle @Desc : a = [1, 3, 10, 9, 21, 35...
5cbacb0a3211309b47fb9fbe32318addcdf89278
micheldavalos/intro_python_20B
/main6.py
127
3.703125
4
''' for e in range(0, 100, 2): print(e) ''' lista = [1, 2, "michel", [0, -1, -2]] print(lista) for e in lista: print(e)
62ffece81b22196403ea6b5701308ca5f8df5b7e
jirojo2/tuenti2014
/src/ch8.py
3,767
3.640625
4
#!/usr/bin/env python import fileinput import math import sys class Table: def __init__(self): self.moves = 0 self.buffer = [None] * 9 def idx(self, x, y): return (x + y*3) def get(self, x, y): return self.buffer[self.idx(x, y)] def set(self, x, y, val): self.bu...
35dc4ea541e3b70e6b1b92f0089135f24f2e536d
TapasDash/BABLU-The-Smart-Calculator-Assistant
/index.py
1,019
3.84375
4
import sys sys.path.append('/modules/') import modules from modules.BABLU import * print() print(responses[0]) print() name = input('BABLU : Please type in your name here so that I can refer you = ').upper() print() print(f'''BABLU : {name},that is a very nice name of yours! BTW {responses[1]} I would love to...
072c03f226bb257c2bf7164490edde1c4f618cd8
mtony75/isprime
/isprime.py
2,678
4.15625
4
''' Function used to accept input from user ''' def getPrime(): aNumber = input("Please enter a number: ") loopLogic = True while loopLogic == True: try: properNumber = int(aNumber) loopLogic = False except ValueError: print(f"The value entered is not an i...
244c9ab15dfcd5018faea5bc97500bcb951bb0bd
BerryHN/DJH-Python
/libs/csv/csvTest.py
2,231
3.59375
4
# coding:utf-8 import csv def testReader(file): with open(file, 'r') as csvfile: spamreader = csv.reader(csvfile, delimiter=',') for row in spamreader: print(', '.join(row)) def testWriter(file): with open(file, 'w') as csvfile: spamwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv....
b118360ef067e1ec9f19baa75d3306c04ee5e9eb
Light-Y007/MachineLearning
/2. Regression/3. Polynomial Regression/polynomial_regression.py
2,508
3.5
4
#Polynomial Regression #importing Libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd #IMPORTING THE DATASET dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:, 1:2].values y = dataset.iloc[:, 2].values '''#Taking care of missing data #from sklearn.impute ...
2cc9b3a32033622f82ae2c7fc6214d50c01083c7
magnus-jcu-persson/CP1404-practicals
/prac9/file_sorter.py
562
3.734375
4
import os import shutil def main(): os.chdir('FilesToSort') directories = {} for filename in os.listdir('.'): ext_list = filename.split('.') ext = ext_list[-1].lower() if ext not in directories: directory = input("What category would you like to sort {} files into?".fo...
68ef5ff4ea2a4131a76399e0ef3885f703c4e7e4
magnus-jcu-persson/CP1404-practicals
/prac3/password_entry.py
436
3.890625
4
""" Magnus Persson """ def main(): valid = False while not valid: password = get_password() valid = check_password(password) def get_password(): user_password = input('Password') return user_password def check_password(password): MIN_LENGTH = 7 if len(password) >= MIN_LENG...