blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
fd1ee1971b9e2e59f8a2e76575fe4c3599286898
Thammarat-b1992/CP3-Thammarat-Punyaponvittaya
/Lecture 104_Thammarat_P.py
600
3.9375
4
class Customer: name = "" lastName = "" age = 0 def addCart(self): print(self.name,self.lastName,self.age) customer1 = Customer() customer1.name = "admin" customer1.lastName = "admin" customer1.age = 21 customer1.addCart() customer2 = Customer() customer2.name = "admin" customer2.lastName = ...
7aacb27082e21c1a3a419515a8fb5834d5f91da8
shuyuqing/-
/keras/keras_rnn.py
3,378
3.90625
4
# please note, all tutorial code are running under python3.5. # If you use the version like python2.7, please modify the code accordingly # 8 - RNN Classifier example # to try tensorflow, un-comment following two lines # import os # os.environ['KERAS_BACKEND']='tensorflow' import os import numpy as np np....
ad553dd78d2f06b1e14a3c4d1d2eeb1cb10f219f
shuyuqing/-
/ceshi/if.py
141
3.796875
4
a = 0.5 if a == 0.5: print('a') elif a == 0.5: print('b') elif a == 0.9: print('c') else: print('i')
5f4c1b8564202614438a96b0224a12f639c1eaea
atif93/hackerrank
/staircase.py
199
3.84375
4
#!/bin/python import sys n = int(raw_input().strip()) for i in range(n): row = "" for j in range(n - i - 1): row += " " for k in range(i + 1): row += "#" print row
c4153790d1ca4577013e196c076242b4a23cc862
wind05408/Python3Base
/flow/skill.py
2,483
3.890625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/5/15 18:31 # @Author : dk05408 # @Site : # @File : skill.py # @Software: PyCharm #原地交换两个数字 import math x,y = 10,20 print(x,y) x,y = y,x print(x,y) #链状比较操作符 n = 10 result = 1<n<20 print(result) result = 1>n<=9 print(result) def small(a, b, c)...
cc4bcb04d29e0113c5b8b264e7b045a6f58dd539
viplod/brain-games
/brain_games/games/gcd.py
366
3.8125
4
import random DESCRIPTION = 'Find the greatest common divisor of given numbers.' def divisor(a, b): while b != 0: a, b = b, a % b return a def generate_round(): number1 = random.randint(1, 99) number2 = random.randint(1, 99) question = f'{number1}, {number2}' answer = divisor(numbe...
937e26236029e0a98d8f721df37467e069da98de
gitHirsi/PythonNotes
/001基础/006列表/03判断是否存在.py
351
4.09375
4
""" @author:Hirsi @time:2020/5/25 21:11 """ """ """ nameList = ['Hirsi', 'Tom', 'Bill'] print('Hirsi' in nameList) print('Hirsis' not in nameList) print('------------------') """ 案列 """ name = input('请输入账户名:') if name in nameList: print('用户已经存在!') else: print(f'你输入的是{name},可以注册!')
2f77dcc4cc55709761d94f6ba76e5502446b8d49
gitHirsi/PythonNotes
/001基础/StudentManagerSystem/拓展__dict__.py
199
3.75
4
""" @Author:Hirsi @Time:2020/6/15 """ class A(object): a=0 def __init__(self): self.b='hirsi' self.c='男' self.d=3356 aa=A() print(A.__dict__) print(aa.__dict__)
4d92ab64c3b696d5161e00a9d8f2193b6ac18446
gitHirsi/PythonNotes
/001基础/018面向对象/04魔法方法str.py
360
3.515625
4
""" @Author:Hirsi @Time:2020/6/11 21:47 """ """ _str_() :定义_str_方法后,打印对象时,就会打印容这个方法中return的数据 """ class Washer(): def __init__(self, width, height): self.width = width self.height = height def __str__(self): return '冰箱说明书' haier = Washer(450, 500) print(haier)
de42f03696ffc38941cac91cd7663e82f4891ef5
gitHirsi/PythonNotes
/001基础/006列表/07删除数据.py
588
3.5625
4
""" @author:Hirsi @time:2020/5/25 21:34 """ nameList = ['Hirsi', 'Tom', 'Bill', 'aa', 'bb', 'cc'] """ 1.del """ # del nameList #删除整个列表 # del nameList[2] #删除指定下标位置数据 # print(nameList) # print('-------------------') """ 2.pop() 按下标删除,不指定下标,删除最后一个 """ # popName1 = nameList.pop() # print(popName1) # popName...
f827f2a2a2f34903b2b9dfc738b603573f69aac4
gitHirsi/PythonNotes
/001基础/018面向对象/07搬家具.py
1,154
4.15625
4
""" @Author:Hirsi @Time:2020/6/11 22:32 """ # 定义家具类 两个属性:名字和占地面积 class Furniture(): def __init__(self, name, area): self.name = name self.area = area # 定义房屋类 4个属性:地理位置,房屋面积,剩余面积,家具列表 class House(): def __init__(self, address, area): self.address = address self.area = area ...
8ca25288b0885fed4aca271c6fa554f8ff61ee19
gitHirsi/PythonNotes
/001基础/StudentManagerSystem/student.py
308
3.640625
4
""" @Author:Hirsi @Time:2020/6/15 """ class Student(object): def __init__(self, name, gander, tel): self.name = name self.gander = gander self.tel = tel def __str__(self): return f'{self.name},{self.gander},{self.tel}' # hh=Student('hh','男','123456') # print(hh)
76c2bacefc0f6f33dfaf37682b8be84303754cdb
gitHirsi/PythonNotes
/001基础/019面向对象_继承/08私有属性和方法.py
1,609
4.1875
4
""" @Author:Hirsi @Time:2020/6/12 22:10 """ """ 1.定义私有属性和方法 2.获取和修改私有属性值 """ # 师傅类 class Master(object): def __init__(self): self.kongfu = '《师傅煎饼果子大法》' def make_cake(self): print(f'运用{self.kongfu}制作煎饼果子') # 学校类 class School(object): def __init__(self): self.kongfu = '《学校煎饼果子大法》' ...
d8f86789984bbdb7e4e140b3b800edd8ba423975
gitHirsi/PythonNotes
/001基础/002if语法/02if多重判断.py
237
3.796875
4
""" @author:Hirsi @time:2020/5/21 20:47 """ age = 30 # if (age >= 16) and (age <= 60): if 18 <= age <= 60: #化简 print('可以上班!') elif age >= 60: print('已经退休了!') else: print("未成年不能上班!")
bebc9219c14378585d716dc35d6ce01b9eb5fb55
gitHirsi/PythonNotes
/001基础/001变量和输出输入/09数据类型转换函数.py
281
3.546875
4
""" @author:Hirsi @time:2020/5/20 20:53 """ # eval() --计算在字符串中的有效python表达式,并返回一个对象 str1='1' str2='1.1' str3='(10,20,30)' str4='[100,200,300]' print(type(eval(str1))) print(type(eval(str2))) print(type(eval(str3))) print(type(eval(str4)))
1eaba137311948a4042e1c25a0238d79db17f27b
SouriCat/pygame
/7_Intermédiaire __ La portee des variables et utilisation dans les fonctions.py
1,500
4.25
4
## Fonctionnement normal d'une fonction et des variables ##--> la variable locale est Dispo dans tous le documents, mais les fonctions doivent l'avoir en parametre pour l'utiliser var1 = "parametre1" var2 = "parametre2" def fonction(parametre1, parametre2): print (parametre1, "a bien été passé dans la fonc...
a32adf43016c39fa5c413703b48ff5628cc6f0cf
SouriCat/pygame
/8_Intermédiaire __ Manipulation de chaines de caractères.py
1,726
4.3125
4
##### Manipulation des chaines de caractères str1 = 'Bonjour' # unicode str2 = "Bonjour" # utf8 ##---> L'echappement permet d'afficher des signes utilisés pour coder #\' \" ##---> Retour chariot, a mettre a la fin de la ligne #\n\ ## retour chariot facile : # str3 = """ texte sur # plusieurs ligne...
d6a73549971f600108d261b51199c765656ea76e
RitaJain/Python-Programs
/storeConditions.py
285
3.5
4
#storing conditions in name called all a,b,c=1,2,3 all= a==1 and b==2 and c==3 #test variables if (all) : print("all conditions are true") else : print("all conditions are not true") #using condition all again if all: print("condtion is fullfilled again")
67ef1b27449b3dd39629b8cc675e519ac462663e
RitaJain/Python-Programs
/greater2.py
226
4.25
4
# find greatest of two numbers using if else statment a=int(input("enter a ?")) b=int(input("enter b ?")) if (a>b): print("a is greater than b", a) else: print("b is greater than a",b)
1c1b6f7379b46515bab0e2bcddf0ed78bf527cc4
vipulm124/Python-Basics
/LearningPython/LearningPython/StringLists.py
355
4.40625
4
string = input("Enter a string ") #Method 1 reverse = '' for i in range(len(string)): reverse += string[len(string)-1-i] if reverse==string: print("String is a pallindrome. ") else: print("Not a pallindrome. ") #Method 2 rvs = string[::-1] if rvs == string: print("String is a pallindrome. ") else...
4cf17bef5702acd48de369fcdbf1ae595e0bc2ad
ATLS1300/pc02-graffiti-12-hannah-imhoff
/PC02_Graffiti_Imhoff.py
1,213
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Sep 4 11:45:47 2020 @author: hannahimhoff """ #!/usr/bin/env python # coding: utf-8 ''' Turtle starter code ATLS 1300 Author: Dr. Z Author: YOUR NAME May 29, 2020 ''' from turtle import * #import the library of commands that you'd like to use color...
8e5615f63e3c80f1ed4af7d669ce12d29ea23227
tuzhucheng/project-euler
/p10/p10.py
414
3.8125
4
from math import sqrt, ceil def isPrime(n): if n <= 1: return False elif n == 2: return True else: for d in range(2, ceil(sqrt(n))+1): if n % d == 0: return False return True sumOfPrimes = 0 for i in range(1, 2000000): print(i) if isPrime...
bd17263b5e1af3fc2ec8ea1929959c1844ffecbc
arias365/juego-python
/3ra.py
2,731
4.1875
4
nombre = input("digite su nombre: ") print("hola ", nombre, " bienvenido") #tema de la clases 7 n1 = int(input('introduce n1: ')) n2 = int(input('introduce n2: ')) print(type(n1)) print('la suma de los numeros es: ', n1 + n2) print('la suma de los numeros es: {}'.format(n1+n2)) print('la suma de ', n1, ' y ', n2, 'es',...
f3519cffe8474f5f473252b1f82e276952ba8459
ShriramShagri/fabric-fault-detection
/src/preprocessing/utils/exceptions.py
1,128
3.65625
4
class Error(Exception): """Base Exception Class Attributes: message -- explanation of the error """ def __init__(self, message="Custom Error"): self.message = message super().__init__(self.message) class ImageFileNotFoundError(Error): def __init__(self, message = "Image No...
5c40d587eb5bea2adab8c6a6ae27c461ec45ed74
bhattaraiprabhat/Core_CS_Concepts_Using_Python
/hash_maps/day_to_daynum_hash_map.py
995
4.40625
4
""" Built in python dictionary is used for hash_map problems """ def map_day_to_daynum(): """ In this problem each day is mapped with a day number. Sunday is considered as a first day. """ day_dayNum = {"Sunday":1, "Monday":2, "Tuesday":3, "Wednesday":4, "Thursday":5, "Friday":...
3dc10b40ad44521c1b628324e38b976f88cca26d
bhattaraiprabhat/Core_CS_Concepts_Using_Python
/recursion/fibonacci_series.py
580
4.25
4
""" This module calculates Fibonacce series for a given number input: an integer return : Fibonacce series """ def main(): number = input("Enter an integer : ") for i in range (int(number)): print ( fibonacci(i), end= ", " ) print () def fibonacci(n): """ Calculates the...
1e6eb33a7057383f2ae698c219830b5408ba7ab5
lilamcodes/creditcardvalidator
/ClassMaterials/parking lot/review.py
1,563
4.34375
4
# 1. Dictionary has copy(). What is it? # DEEP dict1 = {"apple": 4} dict2 = dict1.copy() dict1["apple"] = 3 # print("dict1", dict1) # print("dict2", dict2) # SHALLOW dict1 = {"apple": [1,2,3]} dict2 = dict1.copy() copy = dict1 dict1["apple"].append(5) # print("dict1", dict1) # print("dict2", dict2) # print("...
4e27ca77f0bc276dac99e0623ef459ed1915006f
lilamcodes/creditcardvalidator
/ClassMaterials/DayOne/greeting.py
117
3.78125
4
def greeting() user_input = input ("What is your name?") if user_input =="" print("Hi"+user_input+) greeting()
f9ca56364b52e6da5cb52c00396872294c04e5eb
lilamcodes/creditcardvalidator
/ClassMaterials/day7/beginner_exercises.py
1,701
4.59375
5
# Beginner Exercises # ### 1. Create these classes with the following attributes # #### Dog # - Two attributes: # - name # - age # #### Person # - Three Attributes: # - name # - age # - birthday (as a datetime object) # ### 2. For the Dog object, create a method that prints to the terminal the name...
4dc342eff7bd44bc37256fd79259149e5ec51cde
verzinoc/cs362hw4
/full_name.py
175
3.84375
4
def generate_name(first_name, last_name): if first_name == "": return last_name if last_name == "": return first_name return first_name + " " + last_name
889afeaaefeeb82a160f199251ce0d305fc8461f
vallampalli/PracticePython
/Exercise3.1-ListLessThanUserInput.py
223
3.859375
4
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] input = int(input("Please Enter a Number: ")) LowerThanUserEnteredNum = [] for i in a: if i < input: LowerThanUserEnteredNum.append(i) print(LowerThanUserEnteredNum)
f4ad4407a962845915ab5f54baf5f60bfc014b0b
nishantsinha15/Minimax-GA-MA-and-CSP-Aritficial-Intelligence
/Minimax.py
3,159
3.765625
4
import copy import time def isWinner(ch, board): if (board[0][0] == ch and board[0][1] == ch and board[0][2] == ch) \ or (board[1][0] == ch and board[1][1] == ch and board[1][2] == ch) \ or (board[2][0] == ch and board[2][1] == ch and board[2][2] == ch): return True if (board[...
a75e30b9ffc5f268a1c0be2868a81362796e5bc1
Pragad/LearnPython
/Algos_Python/FindCollinearPoints.py
5,088
3.5625
4
#! /usr/bin/env/python # Author: Pragad Thirumurthi import csv import math # https://www.quora.com/Given-N-points-on-the-plane-what-is-an-efficient-algorithm-to-find-all-the-sets-of-3-or-more-collinear-points # https://stackoverflow.com/questions/4557840/find-all-collinear-points-in-a-given-set # https://www.geeksforg...
66aca6194b69230265531409611b526a387611e1
sarari0318/basic-data-structures
/DataStructures/linked_list.py
2,528
3.953125
4
class Node(): def __init__(self,data): self.data = data self.next = None class LinkedList(): def __init__(self): self.head = None self.tail = None def append(self,data): new_node = Node(data) if self.head == None: self.head = new_node ...
ed11b5b03f8775df2175b27831c7528ba8f34a09
konstant-in/Objects
/m0.py
1,625
4.0625
4
class MyClass: x = 0 def show(self): # через пераметр "self" реализуется доступ к объекту "экзумпляр класса" (название может быть любым) print("экземплярная:", self.x, self, self.__class__) @classmethod # этот декаратор говорит, что первый параметр это ссылка на объект-класс def show_c(c...
c02f93620bc0c3fb7f134990dd5595ced3b82de2
SACHSTech/ics2o-cpt-AndrewChan22
/main.py
15,751
3.859375
4
''' ------------------------------------------------------------------------- Name: main.py Purpose: Escape room game Author: Chan. A Created: date in 1/27/2021 ------------------------------------------------------------------------- ''' import random import time # Create counter variable for the amount of times...
e2f218f372f314115ef751fb58e3bab596b08136
stonesteel1023/python_study
/test1/about_tuple.py
804
3.796875
4
# 자료형2 - 리스트, 튜플 # tuple ## 1. 순서 있음 ## 2. 중복 가능 ## 3. 수정 안됨 - 변경안되야하는 값에 적용 - 함수 적음 ## 4. 삭제 안됨 - 예) 통장잔고 저장 자료구조 # 배열 선언 ()로 묶음 a = () b = (1,) c = (1, 2, 3, 4) d = (10, 100, ('a', 'b', 'c')) # del c print(c[0]) print(d[2][1]) # indexing & slicing print(d[2:]) print(d[2][0:2]) # 확장 print(c + d) print(c * 3) ...
9070738966b4441c6a660c11f7fafe2f30e704c0
mkao006/dl_udacity
/artificial_intelligence_nanodegree/1_foundation_of_ai/solving_sudoku/sudoku.py
4,172
3.890625
4
from utils import * rows = 'ABCDEFGHI' cols = '123456789' def cross(a, b): ''' Function to create a cross-grid indexes Args: a: The index of rows b: The index of columns Returns: The concatenated index. ''' return [ele_a + ele_b for ele_a in a for ele_b in b] def grid_va...
bd8cab740890c73454f7fc27c28c9ee41db707b5
YarDK/lesson2
/comparison.py
1,323
4.59375
5
''' Сравнение строк Написать функцию, которая принимает на вход две строки Проверить, является ли то, что передано функции, строками. Если нет - вернуть 0 Если строки одинаковые, вернуть 1 Если строки разные и первая длиннее, вернуть 2 Если строки разные и вторая строка 'learn', возвращает 3 Вызвать функцию несколько р...
1b82d057d603672ef90d083bbc59dd34de075736
saurabh-ironman/Python
/sorting/QuickSort/quicksort.py
1,419
4.15625
4
def partition(array, low, high): #[3, 2, 1] # [1, 2, 3] # choose the rightmost element as pivot pivot = array[high] # pointer for greater element i = low - 1 # traverse through all elements # compare each element with pivot for j in range(low, high): if array[j] <= pivot: ...
b6a6115d59a708f61f30b577246230d621a8da86
jcksnparsons/python-multiple-inheritance
/jakesFlowerShop/arrangements/mothersDayArrangement.py
323
3.625
4
from .arrangement import Arrangement class MothersDayArrangement(Arrangement): def __init__(self): super().__init__() def addFlower(self, flower): if flower.isOrganic == True: self.flowers.append(flower) else: print(f'{flower} cannot be added to this arrangement...
b35f5ae57efce6624f0be056e561925410139ede
jcksnparsons/python-multiple-inheritance
/diggersAndFliers/animals/ant.py
309
3.609375
4
from movements import Walking from .animal import Animal class Ant(Animal, Walking): def __init__(self, name): Animal.__init__(self, name) Walking.__init__(self) def __str__(self): return f'{self.name} the Ant' def walk(self): print(f'{self.name} the ant walks')
88e586b13ad79ced855c14c76970b52f85515772
AnaNava1996/ejercicios-de-algoritmia
/ejercicios/Data structures/tree2.py
422
3.765625
4
class Node: def __init__(self,data): self.data=data self.left=None self.right=None class Tree: def __init__(self,data): self.root=Node(data) def insert(self,node,data): newNode=Node(data) if(data<node.data): if(node.left==None): node.left=newNode return self.insert(node.left,data) else...
f9bea1e0894d064c1c1c5eb836bc15ea7777e4c1
AnaNava1996/ejercicios-de-algoritmia
/ejercicios/Data structures/queue.py
1,153
4.09375
4
class Node: def __init__(self,data): self.data=data self.next=None class Queue: def __init__(self): self.head=None self.top=None def push(self,data): newNode=Node(data) if(self.head is None): self.head=newNode self.top=self.head else: self.top.next=newNode self.top=self.top.next def...
88e9955673482095a9b0496d2a655ebd162c30e3
AnaNava1996/ejercicios-de-algoritmia
/ejercicios/interview practice/staircase.py
282
3.859375
4
''' its about n steps and how many ways can i walk through a staircase... the only steps i can take are in x ''' x=[1,2] def function(n): cont = 0 for i in x: if(n-i==0): cont+=1 elif(n-i>0): cont=cont+function(n-i) return cont #x.remove(0) print(function(4))
15800f3e31a401fa6eaf88a46ced8ff1906e71ca
franklynr92/intro_to_python
/tuple_lab.py
693
4.09375
4
gpas = (3.14, 3.45, 3.98, 2.55, 3.24, 2.27) #gpas[1] = 2.25 x = 0 total = 0 for g in gpas: total = total + gpas[x] x += 1 average = total/len(gpas) print("The average GPA is: ", average) studentGpas = {"Bob" : 3.14, "Mark" : 3.45, "Melissa" : 3.98, "Travis" : 2.55,...
ad97d31b075650eca5f62ec3db56d8e94a131710
franklynr92/intro_to_python
/simple_func.py
296
3.53125
4
#Function definition def greetingEnglish(): #this function greets user in Enlgish language. print("Greetings and Salutations") return def greetingSpanish(): #this function greets user in Spanish language). print("Buenos Dias") return greetingEnglish() greetingSpanish()
97b880571e2820c708466832d0a43582f6ea45e3
franklynr92/intro_to_python
/strings2.py
316
3.78125
4
message = "welcome to Python! Thanks for taking my class!" message2 = "Franklyn" message3 = '4508409535834590' print(message.find('for')) print(message.find('xx')) if message.find('xx') == -1: print("Not found in message") print(message.isalpha()) print(message2.isalpha()) print(message3.isdigit())
44a828f3cce4c2f809f66b373793aeb080b51f73
franklynr92/intro_to_python
/dates.py
441
3.953125
4
import time import datetime now = time.time() print("Now it is", time.asctime(time.localtime(now))) print("Tomorrow it will be", time.asctime(time.localtime(now + (60*60*24)))) print("A year ago it was", time.asctime(time.localtime(now + (60*60*24*365)))) print("In 100 hours it will be", time.asctime(time.localtime(now...
d8b218b2131f6d6269ef16a56039dfadd218bb0a
Vish9454/nptel
/OOPS/duck_typing_polymorphism/duck_typing_3.py
625
4
4
class duck: def talk(self): print("Duck class quack quack") class Horse: def talk(self): print("Horse class huaahhh huaaahh ") class Dog: def talk(self): print("Dog class bark bark") class All: def code(self,param): param.talk() # duck typing,do do not care ...
b6db78649dd85004dc31e1b77cf5513bed96686e
Vish9454/nptel
/nptel_py/rough.py
2,157
3.9375
4
x=1 def f(): x=2 return x print(x) print(f()) print(x) print("##########################################################################") a=1 def f1(): try: y=a a=2 return a+y except UnboundLocalError as e: print("Variable not declared") print(a) print(f1()) print(a) pri...
4300c652faa0481d920e81edb1a6b207939e2e99
Vish9454/nptel
/DataSciNPTEL-master/DataSciNPTEL-master/control_structure2ndpart.py
476
3.546875
4
import pandas as pd data=pd.read_csv("F:\Testwel_new.csv",index_col=0) data.insert(5,'km_per_month',"");data.insert(6,'Age_converted',"") #print(data) def function_convert(val1,val2): Age_year=val1/12 km_per_month=val2/val1 return [Age_year,km_per_month] data["Age_converted"],data["km_per_month"]= \ f...
233cf457bae17e581e6bf7e1ea2e6d06e9b0e828
Vish9454/nptel
/nptel_py/creating_list.py
468
3.8125
4
class Node: def __init__(self,initval=None): self.value=initval self.next=None def isempty(self): return self.value==None def append_i(self,v): if self.isempty(): self.value=v elif self.next==None: newnode=Node(v) self.next=newnode ...
b88ea78a86970452c0de4de456533498997d332d
kiniamogh/trading-algos
/tradingAlgo.py
419
3.53125
4
from abc import ABC class tradingAlgo(ABC): """ Abstract base class defining trading algorithm methods """ def __init__(self): """ Initialize algorithms by specifying hyperparameters """ pass def handle_data(self, data): """ Called every tim...
0bf0a482c5d64ae06431708fdded98b5091278a3
sunchengxuanivy/ccccccccccb
/SpeechCutSrc/accuracy_lib.py
4,805
3.53125
4
""" This module stores functions writen to facilitate comparing transcripts. """ import pandas as pd import difflib as diff import os import re # the Differ function. After comparing string A and B, yield 3 types of output. # -char: belongs to A - B # +char: belongto B - A # char: belong to A intersection B d = di...
d4315d06f2d3ab94665f4744633b8f0c8e7d6714
vitalelele/string-to-morse-converter
/morse-to-code.py
1,425
3.875
4
morse_code_alphabet = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."] normal_alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "...
6d61ba1374fccf86d26bdd3a697ddfd0a05e6bb0
SayantanD99/Python_Programs
/ctoflist.py
209
3.984375
4
temperatures=[10,-20,-289,100] def c_to_f(c): if c< -273.15: return "That temperature doesn't make sense!" else: f=c*9/5+32 return f for t in temperatures: print(c_to_f(t))
50871d61b08cbf0d40167fd9ae1d19243005621a
skyfather/MMUST-Shortest-Path
/algorithms/dij1.py
2,082
3.609375
4
def shortest_dist_node(dist): best_node = 'undefined' best_value = 1000000 for v in dist: if dist[v] < best_value: (best_node, best_value) = (v, dist[v]) return best_node def dijkstra(G, v): dist_so_far = {} dist_so_far[v] = 0 final_dist = {} while len(...
0ec4c6190ca93526c6ccb7fb0852b67d27fa7ada
yocalebo/scripts
/python/ftp_upload.py
922
3.65625
4
#!/usr/bin/env python3 # Quick and dirty python script # to upload files to an ftp server from ftplib import FTP import sys USERNAME = 'change_me' PASSWORD = 'change_me' FTP_SITE = 'change_me' def usage(): print("usage: ./ftp_upload.py [file1 file2..]") if len(sys.argv) < 2: usage() sys.exit(2) try: ...
15ce6b105ff6c1651962b0c421ae8f1c6daf2843
MarloneA/Inter-Prep
/test_adventure.py
858
3.5
4
import unittest from unittest.mock import patch class Testguess(unittest.TestCase): def test_input(self): result = guesswork(3) self.assertEqual(result, "What's your guess?" ) @patch(guesswork(1).get_input, return_value=1) def test_run(self): self.assertEqual(return_value=1,msg = "You got it") @...
4c1638375c2ab1fdd82e1d0b8563e60f22886839
mjkelly/experiments
/random-phrase.py
3,711
3.765625
4
#!/usr/bin/env python3 # # This program generates random phrases using words from the system dictionary. # In the interest of typeability, we only pick words over 3 characters in # length, which contain no non-ascii characters, and don't end in "'s". # # Based on the dictionary size, and other parameters, the program p...
541562214c4dd092316fce84e04f2abf20e966c1
JulianConneely/Programming-and-Scripting-Project--Spring-2018
/IrisMean.py
878
4.03125
4
# Julian Conneely 27/04/18 # Section A - Using numpy Calculate the mean of each column import numpy #read data file into array data = numpy.genfromtxt('data/iris.csv', delimiter=',') firstcol = (data[:,0]) # select all of the values in the first column of the numpy array meanfirstcol = numpy.mean(data[:,0]...
82a2a4b4ed2c356be8dd20e21bf38aa752e4d2d8
ikollipara/Customized-Python
/struct.py
1,158
3.546875
4
# customized-python/struct.py # Ian Kollipara # 2020.03.03 # Rust-like Struct implementation in Python # # Usage # from struct import Struct # Imports from interface import Interface from typing import Dict, Any class Struct: """ Implement a Rust-like Struct implementation. Use as a wrapper around a di...
ba3a7142338e1af83dc6018a55176a5adcbf1428
calebbelmont/class-examples
/04 - db/db.py
5,442
3.546875
4
import sqlite3 from flask import g from application import app import os ##### Database Utilities ######################################## DATABASE = 'test-db.sqlite' # Connect to the database. def connect_db(db_path): if db_path is None: db_path = os.path.join(os.getcwd(), DATABASE) if not os.path....
f0c0a2fdac1e972d4f75796214b733c94850c6e9
vratchaudhary/camera-trap-classifier-publication-code
/tools/subjects.py
16,125
3.84375
4
""" Classes to implement SubjectSets, Subjects and Images - A SubjectSet is a collection of Subjects which typically are either the full subject set of a project, a training-, test- or validation set. - A Subject is defined by a unique identifier, by a label and by a set of images. - An Image belongs to a Subject, ...
92464d2b149f2e146441915f04ab27f8855ff9c2
sori-kim/sparta-7th
/3week/python/hello.py
259
3.984375
4
# 주석달기 a = [] a.append(10) b = {} b["sparta"] = 10 for i in range(10): # print(i) # # range()는 임의의 범위를 만들어주는 것 if a > 10: print(a) elif b > 10: print(b) else: print(c) def test(a): print(a)
605bb344aa621b396b68669c8ebcab48be26ac3c
JoSungHun/Algorithm
/programmers/lv1/42748.py
395
3.75
4
def solution(array, commands): answer = [] temp = [] for x in range(0, len(commands)): i = commands[x][0] j = commands[x][1] k = commands[x][2] temp = array[i-1:j] temp.sort() answer.append(temp[k-1]) return answer array = [1, 5, 2, 6, 3, 7, 4] commands =...
cbbee3221bdd6ac354e1a303a91534d23d3ddc14
kat007/PythonNumpyBasicConcepts
/numpybasics.py
236
3.6875
4
import numpy # 1D array n = numpy.arange(27) print(n) print(type(n)) # two dimensional array twon = n.reshape(3, 9) print(twon) # three dimensional array threen = n.reshape(3, 3, 3) print(threen) print(type(threen))
ee08af7be0b9a7616b540fb2d29883b2b1c584ab
matheusferro/Python
/teste2.py
167
3.984375
4
i = 1 l = [] while i != 0: i = int(input('Digite um número: ')) if i != 0: l.append(i) for x in l[::-1]: print(x)
d1be99119541912f782269c4e43f9d57589580cd
matheusferro/Python
/maior_primo.py
386
3.5625
4
def primo(x): div = 1 contador = 0 while div <= x: if (x % div == 0): contador += 1 div += 1 else: div += 1 if(contador == 2): return True else: return False def maior_primo(nu): while primo(nu) == False: ...
189aa213e88f8b82ad0ada7fd599b10d82047323
matheusferro/Python
/desafio-indicadores-passagem.py
304
4.03125
4
num = int(input('Digite um número')) indicador = False while num != 0 and not indicador: n = num % 10 num = num // 10 n2 = num % 10 if n == n2: indicador = True if indicador: print('tem números adjascentes') else: print(' não tem números adjascentes')
cc74e2f5c6ef1e2c6fb095da6b2a890b67cab721
matheusferro/Python
/vogais.py
234
3.84375
4
def vogal(a): if(a == 'a' or a == 'e' or a == 'i' or a == 'o' or a == 'u' or a == 'A' or a == 'E' or a == 'I' or a == 'O' or a == 'U'): return True else: return False a = input('digita') print(vogal(a))
6bdcb1cf38be5366f9ca5e6dd7406319f5ef92ee
friketrike/ML-AI-proj-2016
/tf/othello.py
1,744
3.75
4
# COMP 6321 Machine Learning, Fall 2016 # Federico O'Reilly Regueiro - 40012304 # Final project - othello with neural nets import random import board as b BLACK = b.BLACK WHITE = b.WHITE class game(): def __init__(self, board=None, turn=None, pass_moves=None): self.board = board if board else b.Board() ...
a639d16801e42f98db541ffed75da583d430cd89
shekhar84/python-basics
/HelloWorld/interpolation.py
243
3.84375
4
age =24 print("My age is %d years" % age) major ="years" minor="months" print("My age is %d %s, %d %s" % (age, major, 6, minor)) print() days = "Mon,Tue,Wed,Thu,Fri,Sat,Sun" print(days[:]) print() print(days[::4]) print() print(days[::5])
2a0d8db51db1c26a89a75f5dccfd4d2c53cf88d5
shekhar84/python-basics
/HelloWorld/escapechar.py
340
3.578125
4
splitString = " This string has been \nsplit over\nseveral\nlines" print(splitString) tabbedString= "1\t2\t3\t4" print(tabbedString) print('The pet shop owner said "no, no, \'e\'s uh,...he\'s resting".') print("""The pet owner said "no, no 'e's uh, ..he's resting".""") print("""The pet owner said "no, no 'e's uh, .....
d0ee23f919b1f262be4995b567eaf818234d2c58
mayralisiak/UCD_Projects_Summer_2021.1
/Data Science DataCamp/W06/W06.E02.py
492
4.03125
4
import inspect def build_tooltip(function): """Create a tooltip for any function that shows the function's docstring. Args: function (callable): The function we want a tooltip for. Returns: str """ # Get the docstring for the "function" argument by using inspect docstring = inspect.getdoc(funct...
2f1c1717f73b14238532853407f95dc6f5cc067b
shmalex/galvanize
/tasks/ngcm_pandas_2017/notebooks/solutions/matrix_creation.py
99
3.578125
4
import numpy as np X = np.arange(1, 16).reshape(5, 3, order='F') print(X) Y = X[[1, 3]] print(Y)
75f189402c8d31071341d41cba75358f8e3ce6a2
japawka/coffe_machine
/Coffee Machine/task/machine/coffee_machine.py
11,239
4.25
4
# number = int(input('Write how many cups of coffee you will need:')) # print('For', number, 'cups of coffee you will need:') # print(number * 200, 'ml of water') # print(number * 50, 'ml of milk') # print(number * 15, 'g of coffee beans') # amount of water, milk and beans required for one cup # waterReq = 200 # # #...
ae744f9577e7d77aea82a4b7d8e7c166039dbdff
ryotakano77/atcoder
/ABC/218/C.py
1,325
3.5
4
N = int(input()) S = [] T = [] for _ in range(N): S.append(list(input().split())) for _ in range(N): T.append(list(input().split())) # .しかない行,列は削除 def push(graph: list) -> list: r, c = 0, 0 while True: r_i = graph[r] if r_i == ["." * N]: r += 1 else: bre...
3666748a823f210c5f7320f253ba43d248b8f74a
ryotakano77/atcoder
/4/3_cheat_WA_TLE.py
902
3.640625
4
from collections import deque N = int(input()) roads = [[] for _ in range(N)] for _ in range(N-1): A, B = (int(e) - 1 for e in input().split()) roads[A].append(B) roads[B].append(A) def dfs(city_num: int) -> list: path_length = [1 if i in roads[city_num] else 0 for i in range(N)] # まずはcity_...
97ccfa048133005feb0906676b95103fa08c9128
ryotakano77/atcoder
/ABC/217/b.py
115
3.59375
4
s = set(["ABC", "ARC", "AGC", "AHC"]) for _ in range(3): i = input() s.discard(i) for e in s: print(e)
696f8074ced6e5da399c418b21d4dbc5f7be02e4
alinered/LeetCode
/7.py
1,267
3.9375
4
# -*- coding: utf-8 -*- #7 #算法 #给定一个 32 位有符号整数,将整数中的数字进行反转。 #示例 1: #输入: 123 #输出: 321 #示例 2: #输入: -123 #输出: -321 #示例 3: #输入: 120 #输出: 21 #注意: #假设我们的环境只能存储 32 位有符号整数,其数值范围是 [−2^31, 2^31 − 1]。根据这个假设,如果反转后的整数溢出,则返回 0。 class Solution: def reverse(self, x): """ :type x: int ...
dcc6ddf44656b8308a0be15723b80968ae66fd0d
cwgit97/Game
/main.py
2,519
3.71875
4
import pygame import random import Sprite pygame.init() # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) KEY_A = 97 KEY_B = 98 KEY_DOWN = 274 KEY_UP = 273 # Open a new window size = (700, 500) screen = pygame.display.set_mode(size) pygame.display.set_ca...
345f0e23434bf1067e94f8b9c78b3813a09a9187
BrenBlaze/WebScraping
/HW9/HW9.py
1,756
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ################################################################ # In Python, use json module to convert JSON objects to # Python dictionaries #Brendan Blais ################################################################ import requests import json # use requests.get...
7ecc2719978b8e862953321530d063d0fe67ec64
n9grigoriants/python
/Lesson_3/mymodules/vsearch.py
697
3.65625
4
def search4vowels(phrase: str) -> set: """ Выводит гласные, найденные в веденном слове """ vowels = set('aeiuo') return vowels.intersection(set(phrase)) def search4letters(phrase: str, letters: str = 'aeoui') -> set: """Возвращает множество букв из 'letters', найденных в указанной фразе"""...
57cb8daab27142956246f0a849924a1a4103cd21
n9grigoriants/python
/removing.py
374
4.125
4
nums = [1, 2, 3, 4, 5, 6, 7, 8] print(nums) nums.remove(3) #используем , если заранее известно значение объекта для удаления print(nums) #nums.remove(5) возникнет ошибка nums.pop() print(nums) res = nums.pop(2) print(nums) print("Был удален элемент со значением " + str(res))
b97b07a993abf307f3319db7f29720bb5bd947e8
n9grigoriants/python
/Lesson_3/func/func_with_return.py
387
3.578125
4
def search4vowels(word:str) -> set: """ Выводит гласные, найденные в веденном слове """ vowels = set('aeiuo') return vowels.intersection(set(word)) #return bool(found)#булево #return found res = search4vowels("wwww") # {} print(res) l = list() print(l) l = [1,2,3,] print(l) d = dict() prin...
653eb83d866926de9a13589957fed2ad853d0934
alokojjwal/FLAMES
/Flames.py
1,144
3.703125
4
def remove_match(m1,m2): for i in range(len(m1)): for j in range(len(m2)): if m1[i]==m2[j]: c=m1[i] m1.remove(c) m2.remove(c) m=m1+['*']+m2 return [m,True] m=m1+['*']+m2 return [m,False] name...
04987c752a830bfe563cdf407ff12fc1e8e08c2a
harsh-m-kumar/CancerPrediction
/Data_Ingestion/DbOperation.py
18,710
3.515625
4
import shutil import sqlite3 from Application_Logger.logger import App_Logger import csv import os class Db_operation: """ This class shall be used for handling all the SQL operations. Written By: Harsh Kumar Version: 1.0 Revisions: Nonse ...
0ef09a962036e71630916cbfab0d35d79dde2f87
Nevin-Edwin/training_question_week1
/week_3.py
4,313
3.640625
4
import random class Pet: Boredom_thresh = 5 Hunger_thresh = 5 boredom_decrement = 2 hunger_decrement = 2 def __init__(self, names, Sounds, Boredom=random.randint(0, Boredom_thresh), Hunger=random.randint(0, Hunger_thresh)): self.Sounds = Sounds self.Boredom = Boredom ...
1dded4ae8185d865fcd503fd187cd8ee166b8556
becerra2906/python_practice_ex
/funciones.py
601
4
4
# part of platzi´s python basic course # def imprimir_mensaje(): # print("Mensaje Especial: ") # print("Estoy aprendiendo a usar funciones!") # imprimir_mensaje() def conversacion(mensaje): print('Hola ') print('Como estás? ') print(mensaje) print('Adiós') opcion = int(input("Elige una opci...
d1b73eb42b846b3f46519c98f6884897d36575d5
BartolomeoD/UchebaPython
/laba1/task1.py
164
3.75
4
import math katet1 = int(input("katet1 = ")) katet2 = int(input("katet2 = ")) gipotenuza = math.sqrt(math.pow(katet1, 2) + math.pow(katet2, 2)) print(gipotenuza)
848e0b7c09f38374356acfcfd91cb026875231e1
BartolomeoD/UchebaPython
/laba1/task4.py
127
3.90625
4
number1 = int(input("number = ")) number2 = int(input("number = ")) count = number1 // number2 print("count = " + str(count))
886e4f89b7df6b55190abe4dc251e964e5856a67
Alex-CheromK/Rocket_dynamic_simulator
/Main_script.py
4,945
3.578125
4
### Main script descript: # This file simulates the full flight trajectory of a liquid propellant rocket. # The code is written in the Python programming language. # The software has been created by Dr. Ali C. Kheirabadi for the purpose of... # simulating and validating the range of motion of the University of British ...
f8b0f58a2610b6495286b321940deabb0d7866cf
Chelsi-create/PythonProjects
/tkinter/slider.py
596
3.953125
4
from tkinter import * import tkinter.messagebox as tmsg root = Tk() root.geometry("455x233") root.title("Slider Tutorial") def getdollar(): print(f"We have credited {myslider2.get()} dollars to your bank account") tmsg.showinfo("Amount Credited!", f"We have credited {myslider2.get()} dollars to your bank acco...
cfc9640c7a255fc71adcf7b6e700eba4cc4eeec3
Chelsi-create/PythonProjects
/tkinter/radiobutton.py
1,033
3.578125
4
from tkinter import * import tkinter.messagebox as tmsg root = Tk() root.geometry("455x233") root.title("Radiobutton Tutorial") def order(): tmsg.showinfo("Amount Received", f"We have received your order for {var.get()}. Thanks for ordering") #var = IntVar() var = StringVar() var.set("Radio") #var.set(1) Label(r...
dd1e1bd24402b0257685f40caba55ba3713f36bc
rociohernandez2000/PythonChallenge
/PyPoll/main.py
2,301
3.515625
4
import os import csv csvpath = os.path.join('election_data.csv') file_output=os.path.join('output_file.txt') total_voters=0 candidates = [] candidate_votes = {} winning_candidate = "" winning_count = 0 with open(csvpath,newline='') as csvfile: csvreader=csv.reader(csvfile,delimiter=',') csv_header=next(csvre...
c4e898d2acad5d29efd4b24a1609f56f1c3fca12
JayWelborn/HackerRank-problems
/python/data structures/stacks/maximum element.py
363
3.75
4
stack = [] elements = int(input()) for _ in range(elements): operation = [int(x) for x in input().split(' ')] if operation[0] == 1 and stack: stack.append(max(stack[-1], operation[1])) elif operation[0] == 1 and not stack: stack.append(operation[1]) elif operation[0] == 2: stack...
8b14a5d3b6700ecefc75e3a4ed06cfc6075161c6
JayWelborn/HackerRank-problems
/python/30_days_code/day20.py
526
3.546875
4
#!/bin/python3 n = int(input().strip()) a = list(map(int, input().strip().split(' '))) # Write Your Code Here total_swaps = 0 while True: num_swaps = 0 for i in range(1, len(a)): if a[i-1] > a [i]: b = a[i-1] a[i-1] = a[i] a[i] = b num_swaps += 1 ...
ffc17a58e989094e5a31092826b501a6b22f2652
JayWelborn/HackerRank-problems
/python/30_days_code/day24.py
417
4.125
4
def is_prime(x): if x <=1: return False elif x <= 3: return True elif x%2==0 or x%3==0: return False for i in range(5, round(x**(1/2)) + 1): if x%i==0: return False return True cases = int(input()) for _ in range(cases): case ...