blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3573a9ad7cdd845131d37e1f1a2253bdb3a54a7a
narinn-star/Python
/Review/Chapter03/3-26.py
126
3.75
4
lst = eval(input("Enter a list : ")) print("The first list element is ", lst[0]) print("The last list element is ", lst[-1])
87f451c31600d195fbea34a9eba57d1e229fc6d2
narinn-star/Python
/Review/Chapter05/5-18.py
190
3.53125
4
def four_letter(lst): res = [] for i in lst: if len(i) == 4: res.append(i) print(res) lst = ['dog', 'letter', 'stop', 'door', 'bus', 'dust'] four_letter(lst)
fdcf89544287268154073bee7f673d5e3a283c64
narinn-star/Python
/Review/Chapter03/3-30.py
284
4.21875
4
sum = 0 num1 = float(input("Enter first number : ")) sum += num1 num2 = float(input("Enter second number : ")) sum += num2 num3 = float(input("Enter third number : ")) sum += num3 average = sum / 3 num4 = float(input("Enter last number : ")) if average == num4: print("Equal")
376ed3af220a8c6ad666d2ffc9b76a2716872471
narinn-star/Python
/Review/Chapter03/3-01.py
156
3.890625
4
tem = int(input("Enter the temperature in degrees Fahrenheit : ")) ctem = float((5/9) * (tem - 32)) print("The temperature in degrees Celsius is ", ctem)
831283a67260c27e7178c9a7832526aa86c22633
narinn-star/Python
/Python 300/09. Function/220.py
228
3.546875
4
#functions _ 함수 정의 def print_max(a, b, c) : max_val = 0 if a > max_val : max_val = a if b > max_val : max_val = b if c > max_val : max_val = c print(max_val) print_max(1,2,3)
0bccc87f73329838b6e20efd654f31c88d3ce046
narinn-star/Python
/Python 300/08. Iteration Statement/135.py
210
3.859375
4
#for문 _ 코드 작성 #for i in ["A", "B", "C"]: # b = i.lower() # print("변환 : ", b) A = "A" B = "B" C = "C" print("변환 : ", A.lower()) print("변환 : ", B.lower()) print("변환 : ", C.lower())
1c72e2b35609fd466c715b261fa74a235b506141
narinn-star/Python
/Python 300/07. Control Statement/124.py
338
3.984375
4
#if문 _ 큰 수 찾기 number1 = input("number1 : ") number2 = input("number2 : ") number3 = input("number3 : ") number1 = int(number1) number2 = int(number2) number3 = int(number3) if number1 > number2 and number1 > number3: print(number1) elif number2 > number1 and number2 > number3: print(number2) else: print(...
822348c886c30f0ba4f03f45ef4b207c7c17f83d
narinn-star/Python
/Python 300/09. Function/223.py
147
3.78125
4
#functions _ 함수 정의 def print_even(lists): for i in lists: if i % 2 == 0: print(i) print_even([1,3,2,10,12,11,15])
2d142569ca692fd9a6eceb1eda777c543cfbe3ae
narinn-star/Python
/Review/Chapter03/3-23.py
480
3.546875
4
#3-23(a) for i in range(0,2): print(i) print("--------------------------------") #3-23(b) for i in range(0,1): print(i) print("--------------------------------") #3-23(c) for i in range(3,7): print(i) print("--------------------------------") #3-23(d) for i in range(1,2): print(i) print("--------...
823e287474d17b53254089ea65c7b731ad26c8a3
narinn-star/Python
/Python 300/07. Control Statement/123.py
177
3.703125
4
#if문 _ 환율 계산 n = {"달러": 1167, "엔": 1.096, "유로": 1268, "위안": 171 } user = input("입력 : ") num, name = user.split() print(float(num) * n[name], "원")
ff20dda2349167586e93dff31c4f126c839d0a45
narinn-star/Python
/Review/Chapter03/3-36.py
164
3.765625
4
#세자리 정수 def reverse_int(a): if a <= 0: return print(a%10, end = '') reverse_int(a//10) reverse_int(123) print() reverse_int(908)
46657a8f29c693902a094b4caaa8f4f1973f966b
narinn-star/Python
/Review/Chapter09/GUI_BASE/Label_outside.py
208
3.5625
4
from tkinter import * window = Tk() lb = Label(window) lb['text'] = "Hello GUI world!" lb['width'] = 20 lb['height'] = 2 lb['font'] = 'helvetica 14 italic' lb['relief'] = RAISED lb.pack() window.mainloop()
0676800031a280c975cd2d76f36e38873fea3c00
narinn-star/Python
/Nomad 2weeks/Day1/Lists.py
223
3.796875
4
days = ["Mon", "Tue", "Wed", "Thur", "Fri"] print(days, type(days)) print("Mon" in days) #Mon이 days 안에 있는가 ? => True/False print(days[2]) print(len(days)) days.append("Sat") #Mutable days.reverse() print(days)
217b2b1246e72bf3e1e090598e596c5139b93ab2
narinn-star/Python
/Python 300/09. Function/219.py
229
3.625
4
#functions _ 함수 정의 def print_arithmetic_operation(a,b): print(a, "+", b, "=", a + b) print(a, "-", b, "=", a - b) print(a, "*", b, "=", a * b) print(a, "/", b, "=", a / b) print_arithmetic_operation(3,4)
b0477856cb69463465d2e49ffb950e497123b778
narinn-star/Python
/Review/Chapter05/5-09.py
242
3.609375
4
def add2D(t, s): for i in range(len(t)): for j in range(len(t[i])): t[i][j] += s[i][j] print(t) t = [[4,7,2,5],[5,1,9,2],[8,3,6,6]] s = [[0,1,2,0],[0,1,1,1],[0,1,0,0]] add2D(t,s) for row in t: print(row)
08f4acede8bb7b63cc93e83bc2e7848412b8e9ff
narinn-star/Python
/Review/Chapter02/2-26.py
462
3.5625
4
import math x = 0 y = 0 r = 10 #2-26(a) x1 = 0 y1 = 0 if (math.sqrt((x-x1)**2 + (y-y1)**2) < r): print(True) else: print(False) #2-26(b) x1 = 10 y1 = 10 if (math.sqrt((x-x1)**2 + (y-y1)**2) < r): print(True) else: print(False) #2-26(c) x1 = 6 y1 = -6 if (math.sqrt((x-x1)**2 + (y-y1)**2) < r): pr...
04df2776af818bdaa9c7b8cabb1d06ca3f1e9a8a
narinn-star/Python
/Problems/Chap02/연습문제09.py
313
4.21875
4
a = dict() print(a) #다음 중 오류가 발생하는 경우? #1. a['name'] = 'python' #2. a[('a',)] = 'python' #3. a[[1]] = 'python' => 정답 : 리스트는 Key가 될 수 없다 #4. a[250] = 'python' # +) Key로는 변하는 값을 사용할 수 없다. # 문자열, 튜플, 숫자는 변하지 않는 값
bcf0a422e753ab61223f7585a99270ffab36f992
narinn-star/Python
/Review/Chapter09/Program/calc_form.py
374
3.59375
4
from tkinter import* top = Tk() top.title("Calculator") Entry(top, width= 30, bg='skyblue').grid(row=0, column=0, columnspan=5) lst=[['7','8','8','/','C'], ['4','5','6','*','('], ['1','2','3','-',')'], ['0','.','=','+',' ']] for r in range(1,5): for c in range(5): Button(top, text=lst[r-1...
4898600b986f81544e0e5adfcfd9d0fcbe5f66c0
narinn-star/Python
/Review/Chapter09/Program/stopwatch.py
932
3.640625
4
from tkinter import* top = Tk() top.title("스톱 워치") cnt = 0 def StopWatch(): if running: global cnt cnt += 1 lbl.config(text=str(cnt)) top.after(1000, StopWatch) #1000밀리초(1초) 후에 함수 StopWatch를 재호출하여 카운터를 1초마다 증가 def start(): global running # 전역변수로 True 설정, 카운터 구동 시작 runn...
e3053746ce8a786897160570e11c1b75ed12b4a1
narinn-star/Python
/Review/Chapter05/5-27.py
430
3.625
4
def letter2number(score): res = 0 if score[0] == 'A': res = 4 elif score[0] == 'B': res = 3 elif score[0] == 'C': res = 2 elif score[0] == 'D': res = 1 elif score[0] == 'F': res = 0 if '+' in score: res += 0.3 elif '-' in score: res...
a93016d14a2d148adf8a72ff83bf755119abda78
narinn-star/Python
/Review/Chapter09/GUI_BASE/Image02.py
388
3.65625
4
from tkinter import* top = Tk() logo = PhotoImage(file = "mini-logo.png") lb1 = Label(top, image = logo).pack(side = 'left') txt = '''A GUI is a type of user interface that allows users to interact with devices in a graphical way.''' #lb2 = Label(top, padx = 10, text = txt).pack(side='right') lb2 = Label(top, padx ...
6974be2b8993108e2a24064010b85081d881fd6a
narinn-star/Python
/Python 300/03. String/030.py
109
3.78125
4
#replace 메서드 _ replace string = 'abcd' a = string.replace('b', 'B') print(string) #abcd print(a) #aBcd
5c29a3eb0e54a3bb3d94bddc2c7484f77e594b65
MayWorldPeace/QTP
/Python基础课件/代码/ut/funcdemo/三角形判断.py
538
3.609375
4
class Sjx(): # 输入三条边,进行判断,是否等边、等腰、普通三角形,否则提示不能组成三角形,用函数来实现 def sjxpd(self,a,b,c): if a + b > c and a + c > b and b + c > a: if a == b and b == c: return 1 elif a == b or b == c or a == c: return 2 else: return 3 ...
29fd972c3d5b5be1a4ea77ae37689c0d634a47fe
MayWorldPeace/QTP
/Python基础课件/代码/第三天的代码/09-列表的定义.py
760
4.0625
4
# 定义一个字符串 my_str = "ab" # 想打印xiaoming -> 字符串的切片 比较麻烦 # 定义一个列表 # 格式: 列表名 = [元素1, 元素2, 元素3,....] # my_list = ["xiaoming", "xiaohong"] # # -> 支持下标索引 # # my_name = my_list[0] # print(my_name) # 定义一个列表 # my_list = [10, 3.14, "hello", True] # print(my_list) # 需求 我想打印hello (从左到右) 0, 1, 2,.... # 也可以从右到左 -1, -2, -3, .... # re...
3b2c0ded761bb97f069b3e021a5ffbc6a9a3c73f
MayWorldPeace/QTP
/Python基础课件/代码/第二天的代码/04-elif.py
806
4.03125
4
# elif == else if # 定义一个变量 记录分数 score = -100 # 通过判断分数 得到一个描述(优 良 中 差) # s >= 90 优 # s >= 80 and s < 90 良 # s >= 60 and s < 80 中 # s >= 0 and s < 60 差 # if score >= 90: # print("优") # elif score >= 80 and score < 90: # print("良") # elif score >= 60 and score < 80: # print("中") # elif score >= 0 and score ...
66866891e8d7c791896d2ff9a322b41cae8afdf7
MayWorldPeace/QTP
/Python基础课件/代码/第四天的代码/05-遍历.py
1,050
4.34375
4
# 可以遍历的 字符串 列表 元组 字典 -> for循环 # 自定义一个字符串 # my_name = "hello" # for c in my_name: # print(c) # 自定义一个列表 快速创建一个有规律的列表 # my_list = list("abcd") # for value in my_list: # print(value) # 自定义一个元组 # my_tuple = tuple("123456") # for value in my_tuple: # print(value) # 定义一个字典 # my_dict = {"name": "小红", "age": ...
6259bc85c9f6b43d53630d649db9755c5375376f
MayWorldPeace/QTP
/Python基础课件/代码/第五天的代码/12-交换变量的值.py
488
4.25
4
# 代码是从上往下执行 一行一行的读 # 第1种方式 # a = 4 # b = 5 # c = 0 # # c = a # c = 4 # a = b # a = 5 # b = c # b = 4 # # # 结果 # print(a) # print(b) # 第2种方式 # a = 4 # b = 5 # # a = a + b # a = 9 b = 5 # b = a - b # a = 9 b = 4 # a = a - b # a = 5 b = 4 # # print(a) # print(b) # 第3种方式 a, b = 4, 5 # a = 4 b = 5 # 在执行35行的时候 看的是第30行...
627364180d818a5ac12ce59cd060725965351f00
MayWorldPeace/QTP
/Python基础课件/代码/第六天的代码/03-应用:批量修改文件名.py
710
3.53125
4
import os # 准备工作 # 01 当前目录下创建一个文件夹 # os.mkdir("黑马文件夹") # 02 指定默认目录 # os.chdir("黑马文件夹") # print(os.getcwd()) # 03 在黑马文件夹下面创建10个文件 # for i in range(1, 11): # # 打开文件 # f =open("hm%d.txt" % i, "w") # # 关闭文件 # f.close() # 实际工作 # hmx.txt -> hmx[中国].txt # 01 指定默认目录 os.chdir("黑马文件夹") # 02 获取当前目录下的目录列表 my_...
b381544f012518a04257ab403b7da3890ca21e74
MayWorldPeace/QTP
/Python基础课件/代码/第六天的代码/14-子类重写父类的同名属性和方法.py
1,196
3.984375
4
# 自定义一个师傅类-(古法) class Master(object): # 构造方法 def __init__(self): self.kongfu = "古法煎饼果子配方" # 擅长做煎饼果子 def make_cake(self): print("按照<%s>制作煎饼果子" % self.kongfu) # 自定义一个新东方-(现代) class School(object): # 构造方法 def __init__(self): self.kongfu = "现代煎饼果子配方" # 擅长做煎饼果子 d...
7206576798ab203f45f0ed17bc9431b7459840e5
MayWorldPeace/QTP
/Python基础课件/代码/ut/Commonlib/Readcsv1.py
459
3.953125
4
#想要读取csv文件的内容需要导包 import csv #创建类 class readcsv(): def read_csv(self,filename): my_list =[] csv_context = csv.reader(open(filename,"r")) # print(csv_context) for csv_con in csv_context: my_list.append(csv_con) # print(my_list) my_lists=my_list[1:] ...
443a4b37f31fbe2b7756f20a6f4f82c39a81ed29
MayWorldPeace/QTP
/Python基础课件/代码/第四天的代码/09-名片管理器.py
756
3.984375
4
# 姓名:小明 年龄:22 姓名:小红 年龄:20 # 保存数据使用字典这个数据类型 # all_dict = {"小明": {"name": "小明", "age": 22}, "小红": {"name": "小红", "age": 20}} # # # 获取小明的数据 # print(all_dict["小明"]["name"]) # # # 获取小红名字 # print(all_dict["小红"]["name"]) # 准备一个空的字典 # all_dict = {} # # 添加名片 # all_dict["小明"] = {"name": "小明", "age": "22"} # print(all_dict) # 删...
3d9d9c57cc6b8fecf6cd5b97927220c8807c9f0f
MayWorldPeace/QTP
/Python基础课件/代码/第四天的代码/03-字典的常见操作1.py
1,063
4.3125
4
# 字典是无序的 可变的 # 定义一个字典 名字 年龄 学号 # my_dict = {"name": "小红", "age": 22, "no": "009"} # <1>修改元素 # 字典的每个元素中的数据是可以修改的,只要通过key找到,即可修改 # 通过key 获取对应key的value的值 # print(my_dict["age"]) # # 通过key 修该对应key的value的值 # my_dict["age"] = 220 # print(my_dict) # <2>添加元素 # title - "哈哈" # 格式: 字典名[key] = value # 如果使用上面的格式 如果这个key不存在 添加一组键...
c65899ed69d8c5755a5c3aed86318b64490afe2f
MayWorldPeace/QTP
/Python基础课件/代码/第一天的代码/14-常用的数据类型转换.py
622
4.3125
4
# python 面向对象语言 # python中万物皆对象 # 将x转换为一个整数 # 定义一个字符串 # my_str = "1234" # my_num = int(my_str) # print(type(my_num)) # print(my_num) # 将x转换为一个浮点数 # my_str = "3.14" # my_f = float(my_str) # print(type(my_f)) # print(my_f) # 将对象 x 转换为字符串 # num = 3.14 # my_str = str(num) # print(type(my_str)) # print(my_str) # 了解 # 用来计算...
4837c0ae8f8c0d639ff3902a2eae76b001db3ae6
joan1011/TwoNumberSum
/TwoNumberSum.py
484
3.9375
4
def twoNumberSum(array, targetSum): # Write your code here. array.sort() left = 0 right = len(array) - 1 while left < right: currentsum = array[left] + array[right] if currentsum == targetSum: return sorted([array[left],array[right]]) elif currentsum < targetSum: ...
fceddd14ca708d62fa94e6da69e08b03302b65d4
dshah98/Python_Pattern
/Alphabet Pattern/Pattern9.py
238
3.578125
4
''' A B C D E B C D E C D E D E E ''' n = int(input("Enter Number: ")) for i in range(1, n+1): print(" " * (i-1), end="") for j in range(i, n+1): print(chr(j + 64), end=" ") print("")
8e12ad206cbda711844db81a9fba2303c002c348
dshah98/Python_Pattern
/Number Pattern/Pattern29.py
227
3.796875
4
''' 5 5 5 5 5 5 4 4 4 4 5 4 3 3 3 5 4 3 2 2 5 4 3 2 1 ''' n = int(input("Enter Number: ")) for i in range(n, 0, -1): for j in range(n, 0, -1): print(i if i >= j else j, end="") print("")
991dbb2e63c8f4983ebfcbf7d58864a9d5da9e0c
dshah98/Python_Pattern
/Number Pattern/Pattern16.py
123
3.765625
4
''' -5 -4 -3 -2 -1 0 1 2 3 4 5 ''' n = int(input("Enter Number: ")) for i in range(-n, n+1): print(i, end=" ")
96efdeb5cd7a610cb97f24c28918b0a96e1e1abd
dshah98/Python_Pattern
/Alphabet Pattern/Pattern4.py
192
3.515625
4
''' A A B A B C A B C D A B C D E ''' n = int(input("Enter Number: ")) for i in range(1, n+1): for j in range(1, i+1): print(chr(j + 64), end="") print("")
a6d05fdd7d73bb6a58d8df89c3ea588f6917bdc0
dshah98/Python_Pattern
/Mix Pattern/Pattern7.py
314
3.921875
4
''' * 1 2 * * * 1 2 3 4 * * * * * 1 2 3 4 5 6 ''' n = int(input("Enter Number: ")) for i in range(1, n+1): print(" " * (n-i), end="") if i % 2 == 1: print("* " * i) else: for j in range(1, i+1): print(j, end=" ") print("")
270a988e9d12e5186e858c13ca8c7d1bf9208dd4
pranalinamdas934/Python-Practice
/Basic Programs/more_printing.py
597
4.1875
4
#!/bin/python print("Mary had a little lamb.") print("Its fleece was white as %s." % 'snow') print("And everywhere that Mary went.") print("." * 10) # what'd that do? end1 = "C" end2 = "h" end3 = "e" end4 = "e" end5 = "s" end6 = "e" end7 = "B" end8 = "u" end9 = "r" end10 = "g" end11 = "e" end12 = "r" # if we use com...
551287b3db846081c5d71c283c189fc1d0a1e96d
pranalinamdas934/Python-Practice
/Basic Programs/bmi.py
680
4.125
4
def gather_info(): height = float(input("enter height: ")) weight = float(input("enter weight")) unit = 'is the above metrics in metric or imperial'.lower().strip() return height, weight, unit def calculate_bmi(height, weight, unit='metric'): if unit == 'metric': bmi = (weight / (height **...
337893e71cfad96c2851b74155a6d81796a3261f
pranalinamdas934/Python-Practice
/SOLID Principles/ocp_exm.py
1,680
3.765625
4
# open/closed principle # open for extension and closed for modification class Animal: def __init__(self, name: str): self.name = name def get_name(self) -> str: pass def make_noise(self): pass # animals = [ # Animal('lion'), # Animal('mouse'), # Anim...
d667aa1e4f77a3a312d836e96c768bcb1d5b3757
daylight55/learn-program-contest
/3_Elementary_alignment/test.py
406
3.78125
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- import sys class Card: def __init__(self, suit, value): self.suit = suit self.value = value def printCard(C): out = [(c.suit + c.value) for c in C] print(' '.join(out)) C = [x for x in input().split()] cards = [Card(c[0], c[1]) for c in C] for card i...
1acf0ab67d4d7d496dac588695353252a6ae0bc8
jeffreykrodgers/jr_boggle_solver
/jr_boggler.py
2,287
3.796875
4
import sys class Trie: def __init__(self, parent, value): self.parent = parent self.children = [None] * 26 self.isWord = False if parent is not None: parent.children[ord(value) - 97] = self def make_trie(dictionary_file): dictionary = open(dictionary_file) root...
7b3d3ff3dbdc37542f9edf03a87157d9fbcd1420
GDGGranada/python_django_dic13
/examples/stringulado.py
586
4.1875
4
cadena="Hola amiwitos, gracias por venir" print cadena print cadena.upper() # Pasa el string a mayusculas print len(cadena) # Imprime la longitud de la cadena print cadena[1] # Imprime el caracter en la posicion 2 print cadena[:-8] # Imprime todos los caracteres excepto los 8 ultimos print cadena[8:-3] # Impr...
1fedd121342e0860ef431caff3a012f07d797904
PierreVieira/Python_Examples
/Combinando Filter e Map.py
519
3.71875
4
# Combinar filter() e map() nomes = ['Vanessa', 'Ana', 'Maria', 'Carol', 'Karine'] # Devemos criar uma lista contendo 'Sua instrutora é' + nome, desde que cada nome tenha mais de 5 caracteres instrutoras_selecionadas = list( filter(lambda nome: len(nome) > 5, nomes)) # Seleciona apenas os nomes cujo número de ...
cd3e4aa5e7262beab891460311b6ecb2581b1991
PierreVieira/Python_Examples
/Sort e Sorted.py
1,377
3.953125
4
earth_metals = ['Beryllium', 'Magnesium', 'Calcium', 'Strontium', 'Barium', 'Radium'] earth_metals.sort() print(earth_metals) earth_metals.sort(reverse=True) print(earth_metals) """ --> Isso aqui gera AttributeError conjunto = {1, 2, 3, 4, 5, 6} conjunto.sort() """ #Outro exemplo: """ format := (name, radiu...
5f7fd293ae31dc587422517d4a8970a843310dd4
PierreVieira/Python_Examples
/Map.py
396
3.859375
4
temps_celcius = [("Berlin", 29), ("Cairo", 36), ("Buenos Aires", 19), ("Los Angeles", 26), ("Tokyo", 27), ("New York", 28), ("London", 22), ("Beijing", 32)] temps_fahrenheit = list(map(lambda tupla_cidade: (tupla_cidade[0], (9/5)*tupla_cidade[1] + 32), temps_celcius)) #Aplica a operação da função lambda par...
26359ab0a96d03ecb80c26063b286ce82e7bcf8d
kevinard/labs_2oop
/exo2_5.py
589
3.984375
4
# 2.5 # # RECHERCHE D’UN ELEMENT DANS UNE LISTE (BIS) # # Ecrire une fonction récursive indiquant si un élément est présent ou non dans une liste. Cette fonction retournera # un booléen. On fera un test sur le premier élément, puis si besoin est l’appel récursif se fera sur la « fin » # de la liste. def recherche_rec...
7d165b8d13fa9bf826c574a2722578b782290f1c
johannaSommer/DeepL-MedicalImaging
/src/preprocessing/split/train_test_split.py
3,337
3.5625
4
import numpy as np import pandas as pd from sklearn.model_selection import GroupShuffleSplit from skmultilearn.model_selection import IterativeStratification def train_test_split(data, test_size=0.2, group='patient_id', labels=None, seed=None): # Author: Kristian & Tobias """ Split dataset into random tr...
f3a6b99a2de36a6631b5ca335105fc61cc2cd78e
hoefelb/Pemdas-Bot
/PemdasBot.py
1,729
3.5625
4
#A simple twitter bot that evaluates mathmatical expressions when it is mentioned in a tweet. #much thanks to pythonprogramming.net, where most of this code comes from #source: https://pythonprogramming.net/twitter-api-streaming-tweets-python-tutorial/ #thanks to Tweepy for interfacing the code with Twitter's APIs #sou...
af4282d2ead58cddd150b47b5068ce07be81d419
Vasallius/Python-Journey
/Automate the Boring Stuff With Python/Ch7-Pattern Matching and Regular Expressions/strong_password_detection.py
1,093
4.40625
4
# Strong Password Detection ''' Description: Write a function that uses regular expressions to make sure the password string it is passed is strong. A strong password is defined as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit. ''' import...
1856a4dc87cc5c9bf317eb9ea5273bae5b1f90ff
Vasallius/Python-Journey
/Data Structs and Algos/Chapter 1/Reinforcements/R1.6 and R1.7.py
348
4.40625
4
''' Write a short Python function that takes a positive integer n and returns the sum of the squares of all the odd positive integers smaller than n. ''' def sum_of_squares_of_odd_positive_integers(n): odd_positive = [x for x in range(1, n, 2)] return sum(x ** 2 for x in odd_positive) print(sum_of_squares_o...
0c13eca5e95c22e8ab49686c5ab7184796de7a29
Vasallius/Python-Journey
/Data Structs and Algos/Chapter 1/Creativity/C1.15.py
411
4.21875
4
''' Write a Python function that takes a sequence of numbers and determines if all the numbers are different from each other (that is, they are distinct). ''' def function(sequence): for number in sequence: count = sequence.count(number) if count > 1: print('There are duplicates') ...
ca497cf64770d3d1eb30274f501b3dede7b29088
Vasallius/Python-Journey
/Automate the Boring Stuff With Python/Ch12-Web Scraping/image_site_downloader.py
1,206
3.859375
4
# Image Site Downloader ''' Description: Write a program that goes to a photo-sharing site like Flickr or Imgur, searches for a category of photos, and then downloads all the resulting images. You could write a program that works with any photo site that has a search feature. ''' import requests import bs4 import o...
a3eef3011680c67ee0d2d23beaadee7bb1405c95
Vasallius/Python-Journey
/Automate the Boring Stuff With Python/Ch15-Working with PDF and Word Documents/brute_force_pdf_password_breaker.py
751
3.625
4
# Brute Force PDF Password Breaker import PyPDF2 # Open dictionary file dictionaryfile = open('dictionary.txt') word_list = [] filename = input('Enter filename of password protected pdf: ') # Add uppercase and lowercase version of the word to word_list for line in dictionaryfile.readlines(): uppercase = line.up...
e196a78247b162b689a52a69251cbd1cec870aff
Vasallius/Python-Journey
/Data Structs and Algos/Chapter 1/Projects/P1.30.py
421
4.25
4
''' Write a Python program that can take a positive integer greater than 2 as input and write out the number of times one must repeatedly divide this number by 2 before getting a value less than 2. ''' def function(number): number = int(number) counter = 0 while number > 2: number /= 2 cou...
50b4e9616a8dc7c346e6ffe888ddf5a66ce61adf
Vasallius/Python-Journey
/Automate the Boring Stuff With Python/Ch14-Working with Google Sheets/downloading_google_forms_data.py
781
3.71875
4
# Downloading Google Forms Data import ezsheets # Load the spreadsheet and the sheet # Replace with your spreadsheet id ss = ezsheets.Spreadsheet('1SZq-wSN_iWuOZENRrNfD_YcbK95p2mHCcw9WBeLSbmQ') sheet = ss[0] # Check for the column that has email address as its header for column in range(sheet.columnCount): colda...
3a59e7e79d7497d33b8a28e38cbbcac21282b7f1
ggonzales5/cs350lab_2
/River_Ecosystem_v6.py
14,551
4
4
#--------------------------------------------------# # Program: CS350 LAB 1 Bear and Fish Ecosystem # # Author: Michael Gonzales # # Date: 2-7-18 # # Compilation: python River_Ecosystem_v5.py | less # # # # ...
f57d58d6d967ee5f57b6a73e765e52c1d33cdc4a
Harrywekesa/python-games
/Matchmaker.py
3,459
3.828125
4
#How good is your memory? Test it in this fun game where you have to find pairs of #matching symbols. See how quickly you can find all 12 matching pairs! import random import tkinter from tkinter import Tk, Button, DISABLED #DISABLED stops a button from responding after its symbol has been matched. import time root = ...
a1f69836497f1fd74e220ba18db3d92409dcd639
venkateshvsn/patterns
/package/alphabets/capital_alphabets/D.py
678
4.09375
4
def for_D(): """printing capital 'D' using for loop""" for row in range(4): for col in range(4): if col==0 or row==0 and col!=3 or row==3 and col!=3 or col==3 and row in(1,2): print("*",end=" ") else: print(" ",end=" ") print() ...
d5480c24795cd5d510b140e4510b1f82ca4dc2f4
venkateshvsn/patterns
/package/numbers/four.py
627
4.03125
4
def for_FOUR(): """printing number 'FOUR' using for loop""" for row in range(5): for col in range(4): if col==2 or row==2 or col==1 and row==1: print("*",end=" ") else: print(" ",end=" ") print() def while_FOUR(): """pri...
38892d409479983a694347988bcadde791d762da
venkateshvsn/patterns
/package/alphabets/capital_alphabets/U.py
694
4.125
4
def for_U(): """printing capital 'U' using for loop""" for row in range(6): for col in range(5): if col==0 and row!=5 or col==4 and row!=5 or row==5 and col in(1,2,3): print("*",end=" ") else: print(" ",end=" ") print() def w...
ba931602940cb7955f50403e7510a89cb1f836f5
venkateshvsn/patterns
/package/symbols/pentagon.py
774
4.25
4
def for_PENTAGON(): """printing symbole 'PENTAGON' using for loop""" for row in range(7): for col in range(9): if col==4 or col in(3,5) and row!=0 or col in(2,6) and row not in(0,1) or row==4 or row in(3,5) and col not in(0,8): print("*",end=" ") else:...
636f9b695a069f2e6e403a0f0ed6b6d9a1c942a0
venkateshvsn/patterns
/package/alphabets/capital_alphabets/S.py
832
4.09375
4
def for_S(): """printing capital 'S' using for loop""" for row in range(9): for col in range(5): if col==0 and row not in(0,4,5,8) or col==4 and row not in(0,3,4,8) or row==0 and col in(1,2,3) or row==4 and col in(1,2,3) or row==8 and col in(1,2,3): print("*",end=" ") ...
ae3324420cbcda95bd6fdcce12de148869e24858
VB6Hobbyst7/Pre-release-Materials
/Oct-2020/PRM - AL/PRM - AS - P2/Task 1 - P2/Python/Task 1.py
10,131
4.15625
4
# TASK 1 – Algorithms, arrays and pseudocode # The following four 1D arrays can store different # pieces of data about Stock items in a shop: # Array identifier Data type # ItemCode STRING # ItemDescription STRING # Price REAL # NumberInStock INTEGER # import only system from os from os import syst...
044ee96b75493200f6e0c99e11e2dceae48e51a0
VB6Hobbyst7/Pre-release-Materials
/June-2021/OL/Variant 22/Python/main.py
12,544
3.6875
4
def task1(): # DECLARE leaveTickets : ARRAY[0:3] OF INTEGER # DECLARE returnTickets : ARRAY[0:3] OF INTEGER # DECLARE leavePassengers : ARRAY[0:3] OF INTEGER # DECLARE returnPassengers : ARRAY[0:3] OF INTEGER # DECLARE leaveTotal : ARRAY[0:3] OF INTEGER # DECLARE returnTotal : ARRAY[0:3] OF INTE...
bceea91a4e4ad810a39c1174db451b5248336713
ProgFuncionalReactivaoct19-feb20/clase02-royerjmasache
/ejercicio5.py
238
3.59375
4
""" Ejemplo 5: Uso de función lambda @royerjmasache """ datos = ( (100, 170), (200, 180), ) edades = lambda a: a[0] estatura = lambda a: a[1] funcion = lambda a: (edades(a)/12.0, estatura(a)/100) print(list(map(funcion, datos)))
32fa1b7cdca712e037751e4bbbbf704210dd01d1
aswinanil/advent-of-code-2020
/day_9.py
1,091
3.578125
4
import itertools PRE_AMBLE_LENGTH = 25 file_handle = open('input/input_day_9.txt') numbers = [int(line) for line in file_handle.read().splitlines()] def is_sum_of_two_numbers(preamble, number): sums = [] for (a, b) in list(itertools.combinations(preamble, 2)): sums.append(a + b) return number in l...
50a49cc653269b0a5210ac82a4ecfdf91a683878
blakeaa827/TalkPython_Jumpstart
/04_journal/program.py
1,175
3.65625
4
import journal def main(): jrn_file = 'test' jrn = journal.load(jrn_file) while True: cmd = get_cmd() if cmd == 'list': print_jrn(jrn) elif cmd == 'add': jrn.append(new_entry()) elif cmd == 'exit': journal.save_exit(jrn_file, jrn) ...
920ec4608c3012e6654d713fc5d300d0ad9c250f
teekay2020/python-training
/python/friendssqlite/friends.py
677
3.984375
4
import sqlite3 conn = sqlite3.connect("my_friends.db") # create cursor object c = conn.cursor() # execute some sql #c.execute("CREATE TABLE friends (first_name TEXT, last_name TEXT, closeness INTEGER);") #insert_query = '''INSERT INTO friends # VALUES ('Temi', 'Kazeem', 7)''' # BAD! DO NOT DO THIS! #form_first =...
d409a96cf0b1002156e75c722c30c730582f58c7
vfedetz/Black-Hat-Challenge
/isEnglish.py
1,808
3.90625
4
import urllib2 # INPUT : block of text /w no spaces # OUTPUT : fitness score # If score is under 500(?), not english. If over 500(?) its english. def isEnglish(text): #load dict of all words filename = "dictionary.txt" reader = file(filename,"r") all_eng_words = reader.read().split() score = 0 ...
31d5e9e65e0cecfa9edae04ce14a85c07dfadacc
barchuckie/metaheuristic
/l3/z2/trie.py
2,319
3.90625
4
"""Trie module This module implements trie (prefix tree) data structure to store words. """ import random from typing import Dict from word_matcher import fitness_function class Node: """Single tree node representation.""" def __init__(self): """Create new instance of node with empty children dict ...
f9d1b8cdf167c47cb33733ca326ad97e25e70832
barchuckie/metaheuristic
/l3/z2/genetic.py
3,898
3.8125
4
"""Genetic algorithm. Implementation of genetic algorithm for finding best matching word. """ import time import random CROSSOVER_PROB = 0.98 POPULATION_SIZE = 10 class GeneticAlgorithm: """Class implementation of genetic algorithm.""" def __init__(self, matcher, population_size=POPULATION_SIZE): ...
20c18538bcedac25abe0dce43460634cab527942
kevenLeandro/PBD_EntregaSemana3
/ex03.py
1,055
3.578125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression #Acidentes do trabalho por idade simplificado dataset = pd.read_csv ('dados_aci.csv',encoding = "ISO-8859-1") #dataset = pd.read_csv ('dados.csv...
4cb88772ceaf30d0e2c5b0295a33aafc6b88dedb
kaistullich/Codewars-Challenges-Answers
/disemvowel-trolls.py
691
3.984375
4
""" Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. Your task is to write a function that takes a string and return a new string with all vowels removed. For example, the string "This website is for...
7af5cc43735e64a7baea10ed9cb99b66174a3840
kaistullich/Codewars-Challenges-Answers
/most-digits.py
303
3.96875
4
def find_longest(arr): for num in arr: temp = num print(f'Temp: {temp}') print(f'Num: {num}') if num > temp: print('larger') def test_find_longest(): assert find_longest([1, 10, 100]) == 100 if __name__ == '__main__': find_longest([1, 10, 100])
dc49316b8c537ce7caca6e83237da6bcf5c58bac
HLdeMJ/bizhub_c266
/monthscalculation.py
1,990
3.53125
4
import datetime import calendar as c def calmonths(startdate, enddate): # 计算两个日期相隔月差 samemonthdate = None try: samemonthdate = datetime.date( enddate.year, enddate.month, startdate.day) except Exception as e: print(e) samemonthdate = datetime.date( endda...
c1fce5b9bb3094de15ea8356bb906ca3d1faed1a
khalid-hussain/python-workbook
/02-Decision-Making/059-next-day.py
982
4
4
from calendar import isleap theYear = int(input('Input year: ')) theMonth = int(input('Input month: ')) theDay = int(input('Input day: ')) print(f'Your date is: {theYear}-{theMonth}-{theDay}') nextDay = '' if theMonth == 12 and theDay == 31: theDay = 1 theMonth = 1 theYear += 1 elif theMonth in {1, 3, 5...
3b42633761d7eb99bcbbbff6dc4b3f52248f5de8
khalid-hussain/python-workbook
/04-Functions/085-compute-the-hypotenuse.py
422
4.15625
4
from math import sqrt # Calculate the hypotenuse given two sides # @param a first side of triangle # @param b second side of triangle # @return c size of hypotenuse def getHypotenuse(a, b): return sqrt(a**2 + b**2) def main(): a = int(input('Input value for a: ')) b = int(input('Input value for b: ')) ...
009bb13b7b7cfaa2adbb14e651bd20df37f029e8
khalid-hussain/python-workbook
/02-Decision-Making/047-season-from-month-and-day.py
369
4.15625
4
theMonth = input('Input Month: ') theDay = input('Input Day: ') if theDay == '21': if theMonth == 'June': season = 'summer' elif theMonth == 'December': season = 'winter' elif theDay == '20' and theMonth == 'March': season = 'spring' elif theDay == '22' and theMonth == 'September': seas...
1676350f9b1f47590a75a71d372e9912f57646fc
khalid-hussain/python-workbook
/01-Introduction-to-Programming/028-body-mass-index.py
164
4.0625
4
height = float(input('Input height (m): ')) weight = float(input('Input weight (kg): ')) bmi = weight / (height * height) print('The BMI is {:.2f}.'.format(bmi))
1111615cc097ada46f77f2df3ba22986b74ab459
khalid-hussain/python-workbook
/01-Introduction-to-Programming/032-sum-of-digits-integer.py
191
3.84375
4
x = input('Input integer: ') sumOfDigits = int(x[0]) \ + int(x[1]) \ + int(x[2]) \ + int(x[3]) print('The sum of the digits is {}.'.format(sumOfDigits))
9becd6be1d3174698ea4524f53308af557f09777
khalid-hussain/python-workbook
/05-Lists/120-formatting-a-list.py
690
4.09375
4
def formatListofWords(theWords: list) -> str: if len(theWords) == 1: return theWords[0] elif len(theWords) == 2: theWords.insert(1, ' and ') elif len(theWords) > 2: theWords.insert(len(theWords) - 1, ' and ') for i in range(len(theWords) - 3): theWords.insert(i + ...
b46fb12397e40a4a4045d69051f035cf771337cd
khalid-hussain/python-workbook
/04-Functions/088-median-of-three.py
386
3.75
4
def getMean(a, b, c): x = a - b y = b - c z = a - c if (x * y) > 0: return b if (x * z) > 0: return c return a def main(): a = int(input('Input first integer: ')) b = int(input('Input second integer: ')) c = int(input('Input third integer: ')) print(f'The median...
a569547d400654e56957f4e0bed748d916f33187
khalid-hussain/python-workbook
/05-Lists/118-word-by-word-palindromes.py
607
3.9375
4
from khalid_lib import getWordsFromString def isStringListPalindrome(theWords): for i in range(len(theWords)): theWords[i] = theWords[i].lower() # print(f'w: {theWords[i]}') theWordsReversed = list(reversed(theWords)) # print(theWordsReversed) if theWords == theWordsReversed: ...
bafe1bc3f270ef3a4f6a35c8245fed7df6183a91
khalid-hussain/python-workbook
/01-Introduction-to-Programming/003-area-of-a-room.py
149
4.09375
4
length = float(input("Input length: ")) width = float(input("Input width: ")) area = float(length * width) print("Area is", area, "square metres.")
a33092fc0f894c5a67b5f36aaddbc10f473ba5e5
khalid-hussain/python-workbook
/03-Repitition/72-fizz-buzz.py
227
3.59375
4
for x in range(1, 101): if x % 3 == 0: if x % 5 == 0: print(f'{x} Fizz Buzz') else: print(f'{x} Fizz') elif x % 5 == 0: print(f'{x} Buzz') else: print(f'{x}')
bc046e6ac7899545b577d50ea7dcb314e0273492
khalid-hussain/python-workbook
/01-Introduction-to-Programming/020-ideal-gas-law.py
259
3.5
4
R_GAS_CONSTANT = 8.314 P = int(input('Input pressure (pascals): ')) V = int(input('Input volume (liters): ')) T_K = int(input('Input temperature (C): ')) T = T_K + 273.15 n = (P * V) / (R_GAS_CONSTANT * T) print('Amount of gas is {0:.2f} moles'.format(n))
c7975adfd83264ab6327375d301a7f5de2e6a61f
khalid-hussain/python-workbook
/01-Introduction-to-Programming/019-free-fall.py
241
3.953125
4
from math import sqrt # m/s² FREE_FALL_ACCELERATION = 9.8 drop_height = int(input('Drop height (m): ')) final_speed = sqrt(2 * FREE_FALL_ACCELERATION * drop_height) print('The speed at touchdown will be {0:.2f}m/s'.format(final_speed))
191994ba4509f8fb86a2cacb63429ce8c3e33798
sophiemullerc/Sprint-Challenge--Python-1
/src/paddle.py
1,095
3.578125
4
from block import * from pygame.math import Vector2 class Paddle(KineticBlock): """ Defines the paddle at the bottom of the screen that is controlled by the player. """ def __init__(self, screenwidth, screenheight): self.screenwidth = screenwidth self.screenheight = screenheight ...
6b7bfcd7a0c8993aa1699c813e2a66bc3ec0f2ab
adamb70/google-foobar
/power_hungry.py
1,336
3.90625
4
from operator import mul def answer(xs): """ Takes list of ints. Returns max product of list as a string. """ positives = [] negatives = [] zero_found = False # Split values into positive and negative lists for val in xs: if val > 0: positives.append(val) elif val ...
874f3e723ccc37fe9dc774931fdfeedcb947d498
rasple/hrv-lab-gui
/timetools.py
305
4.03125
4
def convert_time_to_seconds(time): [minutes, seconds] = time.split(':') return int(minutes) * 60 + int(seconds) def convert_seconds_to_time(seconds): minutes = int(seconds / 60) remaining_seconds = max(int(seconds % 60), 0) return "{0:02d}:{1:02d}".format(minutes, remaining_seconds)
bc1720416ccc2b3dd1717aef62844b5b5dcc543d
mrci18/pythonBible
/packing.py
548
3.890625
4
numbers[1,2,3,4,5] print(*numbers) def add(*numbers) total = 0 for number in numbers total = total + number return(total) add(1,2,3) #numbers = (1,2,3) dictionary = {"name": "Charles", "age": 23 "likes": "wrestling"} def about(name,age,likes): sentence = "Meet {}! They are {} years old and ...
e1e528d6f9ee79d937c9f7b00f46f0027a678e16
spausanc/astr-119-hw-1
/operators.py
702
4.375
4
x = 9 y = 3 #integers #Arithmetic operators. functions that replace a complicated function definition #with a couple of chaeacters print(x+y) #adition print(x-y) #substraction print(x*y) #multiplication print(x/y) #division print(x%y) #remainder of division print(x**y) #exponentiation x = 9.191739203 print(x//y) #...
22cf408efbe9bedb4205e9d858c1e0dd355d4ba6
hanodims/hr-pro
/hr_pro.py
2,497
4.03125
4
from datetime import datetime class Employee: def __init__(self, name, age, salary,employment_year): self.name = name self.age = age self.salary = int(salary) self.employment_year = self.get_working_years(int(employment_year)) def get_working_years(self,employm...
a3caf9c55a918026eb69c37e4547030f2ffe0a10
PhilippSchuette/projecteuler
/py_src/problem025.py
1,100
4.0625
4
# Project Euler Problem 025 Solution # # The Fibonacci sequence is defined by the recurrence relation: # # Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. # Hence the first 12 terms will be: # # F1 = 1 # F2 = 1 # F3 = 2 # F4 = 3 # F5 = 5 # F6 = 8 # F7 = 13 # F8 = 21 # F9 = 34 # F10 = 55 # F11 = 89 # F12 = 144 # The 12th ter...
c5ba103e3502ab0df053b64dc0fc0749cd753949
defravin/StreamTweetsAnalysis
/SentimentAnalysis.py
3,814
3.6875
4
# Databricks notebook source #Python's library for processing textual data %pip install textblob # COMMAND ---------- ### IMPORT THE NECESSARY PACKAGES ### # We use pyspark, which is the Python API for Spark. Here, we use Spark Structured Streaming, which is a stream processing engine built on # the Spark SQL engine ...
2a42de120fcebd2bae8fc1cdd4103e3dbf89d687
adityachhajer/Hackerrank-Problem-Solving.
/QueueusingTwoStacks.py
209
3.53125
4
qu=[] q=int(input()) for i in range(0,q): l=list(map(int,input().split())) if(l[0]==1): qu.append(l[1]) elif(l[0]==2): qu.pop(0) elif(l[0]==3): print(qu[0])
921c05308532a592c667e2ddacf8e5b9ffd1e2ea
adityachhajer/Hackerrank-Problem-Solving.
/Problem Solving/IsThisaBinarySearchTree.py
950
4.03125
4
""" Node is defined as class node: def __init__(self, data): self.data = data self.left = None self.right = None """ def check_binary_search_tree_(root): if (root.left is None) and (root.right is None): return True elif(root.left is None) and (root.right is not None): ...