blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
624b61cfac66a83ca8f5989b0f1806df330c7cab
delonxd/Calculate2.0
/src/Freq.py
1,464
3.84375
4
class Freq: """ 频率 """ def __init__(self, value=0.0): self.value = value def change_freq(self): new = self.value if self.value == 1700: new = 2300 elif self.value == 2000: new = 2600 elif self.value == 2300: new = 1700...
8c5cf3b851e9e73a31b36418acb8c58e69bb29a5
folkol/c3
/funcs.py
1,750
3.921875
4
def chunkify(lst, n): """Given a list of a number n, yield consecutive chunks of size n.""" for pos in range(0, len(lst), n): yield lst[pos:pos + n] def hex_to_ints(hex_string): """Converts the hex string to a list of ints by converting chunks of 2 chars to int.""" return [int(chars, 16) for c...
593c576dd4cd4cb4063ca8b9778d25119c08ff97
Nevilli/unit_three
/d4_unit_three_warmups.py
270
3.859375
4
def area_of_rectangle(length, width): """ This function calculate the area of a rectangle :param length: length of long side of rectangle :param width: length of small side of rectangle :return: area """ area = length * width return area
d0d02f1607c97e6c7284f3f14d9366e79dc359fd
tylerweng/test-tensor
/examples/variable_example.py
1,293
3.734375
4
import tensorflow as tf W = tf.Variable([.3], dtype=tf.float32) b = tf.Variable([-.3], dtype=tf.float32) x = tf.placeholder(tf.float32) linear_model = W*x + b """ Constants are initialized when you call tf.constant, and their value can never change. By contrast, variables are not initialized when you call tf.Variable...
12c7f58887bfc154c09569a13de79d6eb83caa59
Leo7890/Tarea-04
/VentadeSoftware.py
1,244
3.9375
4
#encode: UTF-8 #Autor: Leonardo Castillejos Vite #Descripción: Da el precio total del software comprado def main(): paquetesComprados = int(input("Teclea el número de softwares comprados: ")) if paquetesComprados > 0: descuento = calcularDescuento(paquetesComprados) totalPagar = calcula...
a68707c994be958a06e2a0cc5480cf78d488f3ad
BalaKumaran1998/Python
/Armstrong Number.py
243
3.921875
4
n=int(input()) def arms(n): sum = 0 temp = n while temp > 0: digit=temp % 10 sum+=digit ** 3 temp //= 10 if (n == sum): print(n,"is Armstrong number") else: print(n,"is not Armstrong number") arms(n)
238001c5397879d0a6d632a2d2de48dccffa2ddc
irfankhan309/DS-AL
/Py_Codes/my_practice/python_series/dictionary.py
278
3.796875
4
rec={} n=(int(input('enter no of students:'))) i=1 while i<=n: name=input('enter the student name:') marks=input('enter the %of the student') rec[name]=marks i=i+1 print('name of student','\t','% of marks') for x in rec: print('\t',x,'\t\t',rec[x])
c6c9e57135b1c1ef08112b65ec310b6c333e414b
irfankhan309/DS-AL
/Py_Codes/my_practice/python_series/functions_1.py
1,024
3.921875
4
def sum_dec(func): def inner(a,b): return a+b return inner def sub_dec(func): def inner(a,b): c=a+b c1=c*2 return c1 return inner @sub_dec @sum_dec def add(a,b): print('the values of sum:',a+b) add(2,4) #------------------------- def wish_dec(fun...
fbf736938161e98b8c03b83620597aed3a28d5a5
irfankhan309/DS-AL
/Py_Codes/my_practice/python_series/y.py
747
3.609375
4
class supermarket: def __init__(self,cnumber,item,cost,qty): self.cnumber=cnumber self.item=item self.cost=cost self.qty=qty def total(self): print('*'*30) print('cnumber items cost qty') print('*'*30) print('number is:',self.cnumber) pri...
5498480aa47f089ec6dbdde9b94057e3bd774cb7
irfankhan309/DS-AL
/Py_Codes/my_practice/python_series/NOTHING.PY
242
3.65625
4
class student: def __init__(self,sno,sname): self.sno=sno self.sname=sname def sinfo(self): print("the student number is:",self.sno) print("the student name is:", self.sname) s1=student('08DN1A0526', 'irfankhan') s1.sinfo()
472e517a45ca9635b512f268bc0ed6f5acd31dda
mohamed-elghayesh/PyHackerRank
/count_substring/door_mat.py
246
3.96875
4
rows = input() cols = int(rows) * 3 for i in range(int(rows)//2): print((".|."*(2*i+1)).center(int(cols),"-")) print("WELCOME".center(int(cols),"-")) for i in reversed(range(int(rows)//2)): print((".|."*(2*i+1)).center(int(cols),"-"))
d78f2a4ea0aca46bea573ee1f0c695e273b706e3
Riqzz/master_course
/numerical analysis/misc/eu.py
307
3.53125
4
def fun(x): return (2*x+1)**0.5 def dfun(x): return 1/(2*x+1)**0.5 def dy(x, y): return y - 2*x/y xn = 0 yn = fun(xn) h = 0.1 xn1 = xn + h yn1 = yn + h * dy(xn, yn) print('yn+1\'', yn1) for i in range(20): yn1 = yn + h * dy(xn1, yn1) print('yn+1', yn1) print('y(xn+1)', fun(xn1))
0d7f4bc775f87d78a2324b5540cc3db0215db945
rahuladream/Speech-Recogniser
/Speech Recogniser.py
1,924
3.734375
4
#Python Speech Recogniser #Please do check your mic before beginning.. import speech_recognition as sr from time import ctime import time import os import sys from gtts import gTTS def speak(audioString): print(audioString) tts = gTTS(text=audioString, lang='en') def recordAudio(): #...
3a0e0613e6800fb782f195d6587e6060c7274f47
mxpablo/Batch17Roja
/15 ejListas.py
491
3.75
4
lista = [] for i in range(0,100): lista.append(i+1) print(lista) numero = int(input("Escribe un número \n")) lista2 = [] for i in range(1,11): lista2.append (numero*i) print(lista2) lista3=[4,76,3,12,65,3] lista4=[234,222,523,65] lista5 = [] lista5.extend(lista3) lista5.extend(lista4) print(lista5) suma = 0 for i...
c20fb0daa9ad8f5124511a54a8cdbf9fd7e7a91a
mxpablo/Batch17Roja
/16 dict.py
1,319
3.953125
4
diccionario = { 'nombre':'Carlos', 'edad':'22', 'cursos':['Python','Flask'] } print(diccionario) print(diccionario['nombre']) print(diccionario['edad']) print(diccionario['cursos']) print(diccionario['cursos'][0]) print(diccionario['cursos'][1]) dic = dict(nombre='Juan',apellido='Juarez',edad=22) print(dic['nombre']) ...
638b3f1058b6f91699bb21598044d1f99ae29449
jerryjsebastian/leetcode
/1431_KidsAndCandies/KidsAndCandies.py
207
3.5
4
def kidsWithCandies(candies, extraCandies): sol = [] for c in candies: if c+extraCandies>=max(candies): sol.append(True) else: sol.append(False) return sol
288765118face2829ac1a203b78b5767eab41327
Angihyo/Angihyo
/GiHyo/servo_angle_calcul.py
347
3.53125
4
import math def Servo_angle_calcul(vanishingpoint): height = 360 - vanishingpoint[1] width = vanishingpoint[0] - 240 angle = 180*(width/height) / math.pi print(angle) if angle > 30: return 1 #turn right maximum elif angle < -30: return -1 #turn left maximum else:...
09b34c8e145b7f56157dfac0bab96585321fb618
AarthiAnanth/SampleProject
/MarsExplotion.py
520
3.859375
4
import sys def marsExploration(s): # Complete this function length=len(s) multiple=len(s)//3 p=0 q=3 count=0 for i in range(multiple): new_sub_string=s[p:q] if new_sub_string[0]!='S': count+=1 if new_sub_string[1]!='O': count+=1 i...
fcb92b490e1c70b46762fdbff6f8e2fec51e2d30
himmu-git/MyDesktopAssistant
/MyAssitant.py
2,415
3.609375
4
import pyttsx3 import datetime import speech_recognition as sr import webbrowser import wikipedia as wiki import tkinter as tk engine =pyttsx3.init('sapi5') voices= engine.getProperty('voices') engine.setProperty('voice',voices[0].id) def speak(audio): engine.say(audio) engine.runAndWait() def myWindow()...
a784e7502fd9150977a1b0279b83dc23ccfcf8e2
tehspyke/Example-Programs
/Py4J Program/Account.py
1,517
3.828125
4
#Mike Rozier class Account: 'Class to hold accounts' def __init__(self, acc): 'Initializer for Account class' self.accountNumber = acc self.transactionList = [] self.balance = 0.0 def __str__(self): 'String representation for an instance of Account' return '{0:<20} {1:<20} \n{2:<20} ${3:<20....
c26c3fa52692454bd47cfab92253715ed461f4f2
DiegoRmsR/holbertonschool-higher_level_programming
/0x03-python-data_structures/3-print_reversed_list_integer.py
223
4.28125
4
#!/usr/bin/python3 def print_reversed_list_integer(my_list=[]): if not my_list: pass else: for list_reverse in reversed(my_list): str = "{:d}" print(str.format(list_reverse))
df51784a57ea894f61e560f04413337a2e299c92
DiegoRmsR/holbertonschool-higher_level_programming
/0x0A-python-inheritance/4-inherits_from.py
353
3.75
4
#!/usr/bin/python3 def inherits_from(obj, a_class): """ function that verifies if is an instance of a class that inherited (directly or indirectly) Return True if is an instance of a class Return False otherwise """ if isinstance(obj, a_class) and type(obj) is a_class: return(False...
93c28615161ad665f97e89b09222deb2b306f097
DiegoRmsR/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/2-print_alphabet.py
96
3.515625
4
#!/usr/bin/python3 import binascii for alp in range(97, 123): print(end="{:c}".format(alp))
2f6e9e49c2e16eb0367a99ea29bd2ded11a20da3
narinee1403/workshop2..0
/if-else/if_else.py
246
3.734375
4
point = int(input("Enter you score : ")) grade = ["A", "B+", "B", "C+", "C", "D+", "D", "F"] score = [80, 75, 70, 65, 60, 55, 50, 0] z = 0 for y in grade: if point >= score[z]: print("Grade : " + grade[z]) break z = z + 1
f64e6f348f76f3b3ca4d3b87ac1ff4f004ee87d5
Starfunk/neural-network-library
/train_network.py
1,843
3.6875
4
"""Using this network setup, I have achieved a maximum accuracy of 98.06% on the MNIST dataset.""" import numpy as np import network_library import mnist_loader # load the MNIST dataset using the mnist_loader file---the returned # data structure is a list containing the training data, the validation # data, and t...
cde46fdfc48a87498f1150a034bd82926467bb64
PPavlidis7/Peg-Solitaire
/Peg_Solitaire/pegsol.py
18,550
3.890625
4
# This program solves the Peg Solitaire problem using two algorithms: # - BFS - Best First Search (argument = best) # - DFS - Depth First Search (argument = depth) # Game board is read from an given input file and the solution is written to a given output ile # This program is written by Pavlidis Pavlos for...
64c38b12e17bcb0a43e450543252adeea2010817
chebread/findText
/Terminal/exec.py
811
3.828125
4
# 파일에서 문자열 찾기 (terminal) import os.path import sys def Isfile(file): # 파일이 존재하는가 ? if os.path.isfile(file): return 1 # 있어요 else: return -1 # 없어요 def Find(file, text): isfile = Isfile(file) if isfile == -1: return -1 load = open(file, "rb") _read_ = load.read() load.cl...
056309b99eb0f20cb9ef3ab0fc211602718f3f1f
muvekat/nummethods
/lab2tsk1newthon.py
531
3.84375
4
import copy, math, cmath def Newton(f, dfdx, x, eps): f_value = f(x) it = 0 while True: prev_x = x x = x - float(f_value)/dfdx(x) f_value = f(x) it += 1 if abs(x - prev_x) < eps: return x, it def f(x): return x**3 + x**2 - x - 0.5 def dfdx(x): return 3*x**2 + 2*x - 1 ...
8f15111bdab7c53803b54f1a36289f2f468c6348
Jacobb200/ComputerScience3
/Phone_Number.py
1,636
3.578125
4
"""Assignment 02 - 09 Jacob B,""" class phoneNumber: # Class Constants DEFAULT_NUMBER = "0000000000" def __init__(self, phone_num=DEFAULT_NUMBER): # Initializes the instance variables self._phone_num = phone_num # Sanity checks for the phone_number try: self.p...
31157a1f3b21b680b86c67ece8fe22898b3f8580
Jacobb200/ComputerScience3
/Phone_Number_client.py
347
3.953125
4
from Phone_Number import phoneNumber phone_num1 = phoneNumber("***650--688--0850***#") print(f"Phone number for phone_num1 is {phone_num1}") phone_num2 = phoneNumber("***650--688--0850**#") print(f"Phone number for phone_num1 is {phone_num2}") """" Phone number for phone_num1 is (000) 000-0000 Phone number for phone...
4f8f36ec20bd137cc2423bc1330763257128aef5
luizamboni/python-type-study
/2-struct.py
147
3.75
4
from typing import Dict, List, Set # structs f: Dict[str, str] f = { 'a': 'b' } g: List[int] g = [1,2,3] h: Set[int] h= set() print(f,g,h)
3edee7525b3c87debd1525df3dde6ccd470acbea
jindulys/Leetcode
/90-subsets.py
689
3.59375
4
import copy from sets import Set class Solution: # @param S, a list of integer # @return a list of lists of integer def subsets(self, S): n = len(S) result = self.getSubsets(S,n) return result def getSubsets(self,S,n): result = [] if n == 0: ...
a79f1c2fc6391d0032cceafe73e3530784105c14
jindulys/Leetcode
/minStack.py
1,531
3.703125
4
class MinStack: # @param x, an integer # @return an integer def __init__(self): self.myList = [] self.topIndex = -1 self.minIndex = [] self.minTop = -1 def push(self, x): self.myList.append(x) self.topIndex = self.topIndex+1 ...
b6757bb87853eb6476f6b445827df2a660bd8e98
jindulys/Leetcode
/sortList.py
1,319
3.9375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @return a ListNode def sortList(self, head): if head == None or head.next == None: return head ...
0254ed479c00b3f5140df3546c06612dca233557
Andriy63/-
/lesson 4-4.py
686
4.15625
4
''' Представлен список чисел. Определить элементы списка, не имеющие повторений. Сформировать итоговый массив чисел, соответствующих требованию. Элементы вывести в порядке их следования в исходном списке. Для выполнения задания обязательно использовать генератор.''' from itertools import permutations from itertools im...
4b8f690cb618bb443380333e392b745c2437b9d7
Andriy63/-
/lesson 2.py
3,582
3.65625
4
# 1 mylist = ['boy', 12, [], {}, 'year'] print(list(map(type, mylist))) # 2 l = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10] for i in range(0, len(l), 2): old = l[i] l[i] = l[i + 1] l[i + 1] = old print(l) # 3 year = {1: 'january', 2: 'february', 3: ' march', 4: 'april', 5: 'may', 6: 'june', 7: 'july', 8: 'augus...
a7f1790524dd1d056f6b29c0b2d389afaac889b0
laialanza/P1-Laia
/rgb_yuv.py
621
3.546875
4
def YUVfromRGB(R, G, B): Y = 0.257 * R + 0.504 * G + 0.098 * B + 16 U = -0.148 * R - 0.291 * G + 0.439 * B + 128 V = 0.439 * R - 0.368 * G - 0.071 * B + 128 return Y,U,V def RGBfromYUV(Y, U, V): Y -=16 U-=128 V -=128 R = 1.164 * Y + 1.596 * V G = 1.164 * Y - 0.392 * U - 0.813 * V B = 1.164 * Y + ...
1a6a7bdd7150e0e08557a728cdb62f87d653aa0e
augustosch/mi_primer_programa
/combate_pokemon.py
1,142
3.984375
4
pokemon_elegido = input("¿Contra qué Pokemos quieres combatir? (Squirtle / Charmander / Bullbasaur): ") vida_pikachu = 100 if pokemon_elegido == "Squirtle": vida_enemigo = 90 nombre_pokemon = "Squirtle" ataque_pokemon = 8 elif pokemon_elegido == "Charmander": vida_enemigo = 80 ataque_pokemon = 7...
3dde05cf95b6f3dd8d930e090a3fda960e8f5d42
vinitkantrod/HackerRank
/Algorithm/DFS_proability_of_reach.py
1,431
3.5625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import sys # globals input_list = [] ptr = 0 def path_exists(s,d,graph,visited): if s == d: return True visited.append(s) adj=graph[s] for i in adj: if i not in visited and path_exists(i,d,graph,visited): ...
9933a3b31cd139f4bfb736a5ae45d6c56f7760a3
vinitkantrod/HackerRank
/alternating-characters.py
431
3.53125
4
def alternative(stri,de): l = len(s) for j in range(l): if(stri[j]=='a'): if(((j+1)>l) and (stri[j+1]=='a')): de = de + 1 if(stri[j]=='b'): if(((j+1)>l) and (stri[j+1]=='b')): de = de + 1 return de no = raw_input() no = int(no) v = [...
21455fe40cb7f7adcc7a69bc559ed363e3cad386
mohitciet/CorePython
/LearnPython/PythonBasics/OOPS_Inheritance_Polymorphism.py
638
3.890625
4
class Person(object): def __init__(self,name): self.name=name def getName(self): return self.name def isEmployee(self): return False p1= Person("Harry") print(p1.getName()) print(p1.isEmployee()) print("================") class ChildClass(Person): def isEmployee(self): ...
440fb62ef8a3a4144b3082ca38c478fc78357c6b
mohitciet/CorePython
/LearnPython/PythonBasics/Dictionary.py
2,077
4.3125
4
"""DICTIONARY""" dictionary={'key1' : 'india','key2' : 'USA'} #Access Elements from Dictionary print(dictionary['key1']) print("===================") #Adding Elements from Dictionary dictionary={'key1' : 'india','key2' : 'USA'} dictionary['key3']='Pakistan' print(dictionary) print("===================") #Modify E...
d8646f6f1e0173693fd08bb76bd1491603456b74
mohitciet/CorePython
/LearnPython/PythonBasics/IfElseConcept.py
157
4.0625
4
a=10 if(a<0): print("a is a negative number") elif(a>0): print("a is a postive number") else: print("a is a zero") print("number is : "+str(a))
1506a8ea3f9f4e7e05c2a16541d5ae8c0af91047
kylegalloway/CS403
/Project/prettyPrinter.py
11,136
3.703125
4
from parser import Parser def main(filename): p = Parser(filename) parse_tree = p.parse() prettyPrint(parse_tree) print() def prettyPrint(tree): if(tree != None): # printf(tree.ltype + " ", end="") if(tree.ltype == "PARSE"): printPARSE(tree) elif(tree.ltype == "...
e9bf4f58421ccd1a104729718f1f76608f15aa47
jonnrauber/first-follow
/first_follow.py
7,954
3.625
4
from Estado import * ###GLOBAL VARIABLES### i_line = 1 Estados = [] has_changed = True pos_estado = None pos_estado_atual = None all_have_eps = True ###################### ################### PRINT FUNCTIONS ####################### #Print the first sets def imprime_first(): global Estados print("CONJUNTOS FIRST") ...
599e389fd6a37b9119e663c23bb75c67e686d90e
lukelu389/programming-class
/python_demo_programs/2020/example_20201127.py
2,582
4.03125
4
# practice # Below are the two lists convert it into the dictionary # keys = ['Ten', 'Twenty', 'Thirty', 'Hello'] # values = [10, 20, 30, 'Hi'] # expected output: {'Ten': 10, 'Twenty': 20, 'Thirty': 30, 'Hello': 'Hi'} # create a dictionary from two lists, one list has all keys, one list has all values def build_dictio...
8ba63fdd070ef490570285c17d8669b8d8ffb5b0
lukelu389/programming-class
/python_demo_programs/2020/prime_number.py
273
4.375
4
# write a python program to check if a number is prime or not number = int(input('enter a number:')) n = 1 counter = 0 while n <= number: if number % n == 0: counter += 1 n += 1 if counter > 2: print('not prime number') else: print('prime number')
3404c6cc7af2350bf12592921226a9f4a87da618
lukelu389/programming-class
/python_demo_programs/2021/example_20210319.py
1,529
4.1875
4
# s = 'abcdefgh' # print(s[0:2]) # print(s[:2]) # implicitly start at 0 # print(s[3:]) # implicitly end at the end # # # slice from index 4 to the end # print(s[4:]) # to achieve the conditional, need to use if keyword # a = 6 # b = 5 # if b > a: # print('inside if statement') # print('b is bigger than a') # ...
1d4bac21899ddd993ad41cdf80a0c2ad350b8104
lukelu389/programming-class
/python_demo_programs/2021/example_20210815.py
1,644
4.1875
4
# class Person: # def __init__(self, name): # self.name = name # def method1(self): # return 'hello' # p1 = Person('jerry') # print(p1.name) # Person.method1() # class = variables + methods # variable: static variable vs instance variable # method: static method vs instance method # class is...
2ad3a01fc1c2ef2e1e45304656cd37e027a1b85d
lukelu389/programming-class
/python_demo_programs/2021/example_20210207.py
403
3.65625
4
# list = [0, 1, 2, 3] # [1, 3, 5, 7] # [i*2+1 for i in list] list = [3, 8, 9, 5] # res = [] # for i in list: # if i % 3 == 0: # res.append(True) # else: # res.append(False) res = [True if i % 3 == 0 else False for i in list] list = ['apple', 'orange', 'pear'] res = [] for i in list: res.ap...
92c67fbb46180ca6d3abc13cdbf9fb24d005cefb
lukelu389/programming-class
/python_demo_programs/2021/example_20210126.py
2,619
3.78125
4
# questions = ['name', 'quest', 'favorite color'] # answers = ['lancelot', 'the holy grail', 'blue'] # l = (1, 2) # # for i in questions: # # print(i) # # for i in answers: # # print(i) # # # print(zip(questions, answers)) # # zip(questions, answers) -> [('name', 'lancelot'), ('quest', 'the holy grail'), ('favo...
6d7f89a6f38bcb3765ff3e6f5a954bfed6b27f3c
lukelu389/programming-class
/python_demo_programs/2020/factorial.py
231
4.15625
4
# use a loop to calculate n*(n-1)*(n-2)*(n-3)*...2*1, # and return the result def factorial(n): result = 1 while n > 0: result = result * n n -= 1 return result print(factorial(5)) print(factorial(3))
899a93327d5bce8e523b1622bf8b859a5c1b7c30
lukelu389/programming-class
/python_demo_programs/2020/string_index.py
353
3.90625
4
s = 'abcd' # print(s[0]) # print(s[1]) # print(s[2]) # print(s[3]) # print(s[0:2]) # print(s[0:2] == "ab") # s = 'Arthur' # # print(s[3:6]) # # print(s[1:4]) # # print(s) # print(s[:2]) # print(s[::-1]) # a = 7 # b = 7 # # if a > b: # print('a is bigger than b') # elif a < b: # print('a is less than b') # el...
62499768bba965433aadc0831f82058a25027723
lukelu389/programming-class
/python_demo_programs/2020/example_20201113.py
1,442
4.09375
4
# # dictionary pairs have int key, string value # sample = {0: "Yan", 1: "Gary", 2: "Gilbert", 3: "Hangbing", 4: "Justin", 5: "Nick", 6: "Yijun Zhu"} # print(sample[5]) # # add a new key-value pair # sample[7] = "new student" # print(sample[7]) # # sample[7] = "new teacher" # print(sample[7]) # # sample2 = {"key": "va...
ea53f0ecbeee4c3c1a35d5a2d2569b8a70cf4ea2
lukelu389/programming-class
/python_demo_programs/2020/example_20201018.py
1,389
4.125
4
# homework # write a python function takes two lists as input, check if one list contains another list # [1, 2, 3] [1, 2] -> true # [1] [1, 2, 3] -> true # [1, 2] [1, 3] -> false def contain(list1, list2): # loop through list1 check if each element in list1 is also in list2 list2_contains_list1 = True for...
2a483c17bbe52a294c1a45c98e46a07039610f86
lukelu389/programming-class
/python_demo_programs/2021/example_20210403.py
333
3.96875
4
class MyClass: num = 12345 # <- class variable # construct method receives the passed in value when creating object def __init__(self, name, age): self.name = name # <- instance variable self.age = age # class method def greet(self): return "hello" a = MyClass("Tom", 1) p...
9e63c534debc5b8bb2adcfd7493ce18e8acd1bf7
lukelu389/programming-class
/python_demo_programs/2020/example_20201025.py
1,532
4.25
4
# # write a python function that takes a list and a int, check if list contains any two values that diff of the two values # # is the input int # # [1, 2, 3] 1 -> true # # [1, 2, 3] 4 -> false # # def find_diff(list, target): # for i in list: # for j in list: # if j - i == target: # ...
12720f4c953a952aaebf3737a248c5e61c947773
lukelu389/programming-class
/python_demo_programs/2020/nested_conditionals.py
1,370
4.15625
4
# a = 3 # b = 20 # c = 90 # # # method 1 # if a > b: # # compare a and c # if a > c: # print('a is the biggest') # else: # print('c is the biggest') # else: # # a is smaller than b, compare b and c # if b > c: # print('b is the biggest') # else: # print('c is the ...
e7858de37139b8012d40948dba3830c1726e9422
lukelu389/programming-class
/python_demo_programs/2020/break_continue.py
356
3.71875
4
# a = range(3) # print(list(a)) # range(10) -> [0, 1, 2, ..., 9] # for i in range(10): # if i == 5: # break # print(i, "hello") # # print('finish') # for i in range(10): # if i == 6: # continue # print(i) # n = 1 # while n < 10: # if n == 6: # break # print(n) # n...
e98b2c293445fb59504836725d5a9642b6ecdc58
vijaykanth1729/Python-Programs-Interview-Purpose
/element_search.py
559
4.09375
4
''' Write a function that takes an ordered list of numbers (a list where the elements are in order from smallest to largest) and another number. The function decides whether or not the given number is inside the list and returns (then prints) an appropriate boolean. ''' def element_search(ordered_list, number): if ...
82fd4d0ada2e7508236c2b5ffaa9ad4f3a7a2345
vijaykanth1729/Python-Programs-Interview-Purpose
/input_to_year.py
250
4.03125
4
from datetime import datetime year=datetime.now().year name = input("Enter Your Name: ") print(f"Hello Mr.{name}") age = int(input("How old are you: ")) new_data = str((year-age)+100) print(f"{name} you will be 100 years old in the year {new_data}")
ebdba2efa6a80d17470217c55478dcfb9e3250e2
vijaykanth1729/Python-Programs-Interview-Purpose
/diamond_problem.py
605
3.625
4
''' A B C D ''' ''' MRO (method resolution order) rule tells that if a method is not available in class d, then it verifies the method in class B, if not available then it checks in class C. in this case, class B method is executed.. ''' class A: def method(self): print("This is method from...
8a4df0a858c7823dc4f4b614ae81ff658abf6675
vijaykanth1729/Python-Programs-Interview-Purpose
/Ab-inbev/unzip_file.py
315
3.78125
4
from zipfile import ZipFile, ZIP_STORED f = ZipFile('files7.zip', 'r', ZIP_STORED) # for performing unzip operation.. names = f.namelist() print(names) print('') for name in names: print('FileName: ',name) print('The content of this file: ') f1 = open(name, 'r') print(f1.read()) print('*'*10)
a0b7bbca5f8d4cbd1638a54e0e7c5d78302139f8
vijaykanth1729/Python-Programs-Interview-Purpose
/list_remove_duplicates.py
776
4.3125
4
''' Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates. Extras: Write two different functions to do this - one using a loop and constructing a list, and another using sets. Go back and do Exercise 5 using sets, and write the so...
b91da36a1584fdc853640416324ba7470a51eb2c
tasos-bouas/tic-tac-toe
/tic-tac-toe.py
4,177
3.875
4
def DisplayBoard(board): row = 0 for i in range(1,14): if i == 1 or i == 5 or i == 9 or i == 13: print("+-------+-------+-------+") elif i == 2 or i == 4 or i == 6 or i == 8 or i == 10 or i == 12: print("|", "|", "|", "|",sep=" ") else: for...
c43de8857ff0fe4041ef73387297793d9030c59a
Rojas-Andres/Desarrollo-de-problamas-usando-python-flask-y-mongo
/Punto 2/Cifrado cesar/cifrado.py
5,186
4.0625
4
#Comence por A:1 porque en el documento enviado lo desarrollaron asi para el ejemplo, tambien se tomo la letra Ñ porque #Somos latinos dic={ "A":1, "B":2, "C":3, "D":4, "E":5, "F":6, "G":7, "H":8, "I":9, "J":10, "K":11, "L":12, "M":13, "N":14, "Ñ":15, "O...
4e9833cf7f21845f6c64cee80c347d82a37a02b3
abdullahnoble/Intro-to-Webd
/hacker_rank 2.py
277
3.734375
4
from collections import OrderedDict d = OrderedDict() for _ in range(int(input())): item, space , quantity = input().rpartition(' ') if item not in d: d[item] = int(quantity) else: d[item] += int(quantity) for i, q in d.items(): print(i, q)
e27f13f5d021969e253aa6d5157180bc30a7dc47
stevehaigh/python-exercises
/rna.py
339
3.609375
4
# Convert a DNA sequence to corresponding RNA sequence. # import sys if len(sys.argv) < 2 or not sys.argv[1]: print "Please specify file containing a DNA sequence" sys.exit() DNAseq = open(sys.argv[1], "r").read() RNAseq = DNAseq.replace('T', 'U') with open("rna.txt", "w") as RNAfile: RNAfile.write(RNAs...
f71a8b917462f1f7fea0cd2c79cc1c8bfa426a50
balwantrawat777/assignment-15
/assignment 15.py
773
3.65625
4
#QUESTION 1 import re email="zuck26@facebook.com" "page33@google.com" "jeff42@amazon.com" output=re.findall("(\w+)@([A-Z0-9]+)\.([A-Z]{2,3})",email,flags=re.IGNORECASE) print(output) #QUESTION 2 import re text = "Betty bought a bit of butter, But the butter was so bitter, So she bought some better butter, To make th...
54398f9ffb92228b89e18e91f4d765d2bcd1bbe3
zilunzhang/puzzles
/puzzles-BFS-DFS/puzzle_tools.py
5,106
3.921875
4
""" Some functions for working with puzzles """ from puzzle import Puzzle # set higher recursion limit # which is needed in PuzzleNode.__str__ # uncomment the next two lines on a unix platform, say CDF # import resource # resource.setrlimit(resource.RLIMIT_STACK, (2**29, -1)) import sys sys.setrecursionlimit(10**6) d...
19f7f545bfd4eff755300906a7336fa5692757d1
zinh/advent-of-code-2018
/day15/game.py
2,364
3.90625
4
from board import Board import pdb class Game: def __init__(self, lines, attack_point = 3): self.board = Board(lines) self.attack_point = attack_point self.elf_win = True def run(self): turn_count = 0 while not self.turn(): turn_count += 1 return tur...
dd22a8411a9d8848bfa25f34e3e58ef71ca4b09a
zinh/advent-of-code-2018
/day15/cell.py
861
3.5
4
class Cell: def __init__(self, position, cell_type): self.position = position self.type = cell_type self.hit_point = 200 def is_unit(self): return self.type == 'E' or self.type == 'G' def is_opponent_of(self, other): return (self.type == 'E' and other.type == 'G') o...
bb3c2b979426ab217b7cf3bbdadb12d4c8aa2e05
ThtGuyBro/Python-sample
/Dict.py
307
4.125
4
words = {"favorite dessert": "apple pie","never eat": "scallop","always have" : "parachute","don't have" :"accident","do this" : "fare","bug" : "flea"} print(words['bug']) words['parachute']= 'water' words['oar']= 'girrafe' del words['never eat'] for key, value in words.items(): print(key)
0fd872f83272cd79893013134f174cdc153a333b
sdnnet3/python
/10_OOP_02of03.py
263
3.796875
4
""" Let's Learn Python #11 - Overriding & File Mng. - OOP 2 of 3 """ class BaseClass(object): def test(self): print ('ham') class InClass(BaseClass): def test(self): print ("Hammer Time") i = InClass() i.test() b = BaseClass() b.test()
5ecba5e1ff3c45fc0b074e483a95260f7dcb48c0
sdnnet3/python
/type_class.py
442
3.859375
4
class MyClass(object): def __init__(self): self.x = 5 """ Example: TypeClass = type("TypeClass", (), {"x":5}) TypeClass TypeClass - these should be the same (object,) - comma defaults to a tuple (object, BaseClass, etc) ...
dc48605f4aec1a64d4190f6363fd9d02050c927a
felipemlrt/begginer-python-exercises
/08_classesI/Example.py
195
3.59375
4
class basic_math: def sum(x, y): return x + y def subtract(x,y): return x - y def multiply(x, y): return x * y if __name__ == "__main"": bm = basic_math() print(bm.sum(5,5))
a5c89600f1343b8059680634e0ca7caed0bcebe9
felipemlrt/begginer-python-exercises
/06_FuntionsI/Exercise.py
1,923
4.3125
4
#!/usr/bin/env python3 #1) #Create a function that receives a operator ( + - * or / ), values X and Y, calculates the result and prints it. #Crie uma função que receva um oprador ( + - * or / ), valores X e Y, e calcule o resultando apresentando este ao usuário. #2) #Create a function that tell if a number is odd or...
cd12a5192994e593a3eec07aad7ef181954d194c
eryl/windpower
/scripts/merge_csvs.py
583
3.65625
4
import argparse import pandas as pd from pathlib import Path parser = argparse.ArgumentParser("Merge the input csv files") parser.add_argument('csv_files', help="files to merge", type=Path, nargs='+') parser.add_argument('--output-file', help="Where to write output, to standard out if not given", type=Path) args = par...
fc7fe301cf229ffec3e2ba02c4f452042e340173
jinyesong/Python
/base/practice4/4.1_list.py
121
3.734375
4
num = 12345 list_num = list(str(num)) print(list_num) sum = 0 for i in list_num: sum += int(i) print(sum)
47b2b9d03b9c39190f6a5bbc3aaed01b58706815
dlimla/Data-Structures
/heap/max_heap.py
5,140
4.125
4
class Heap: def __init__(self): self.storage = [] def insert(self, value): # pass self.storage.append(value) value_index = len(self.storage) - 1 self._bubble_up(value_index) def delete(self): # pass # so first we have to see if the tree has any values in it if not self.storage: ...
b321b25ea686aa1330dc45942cca8305c77b6bbe
jakerjohnson94/molecules_ICPC
/find_intersections.py
773
4.09375
4
# """ # Write a function that will find the intersection with the widest # angle between the strings (that is, lowest index pairs) # that will maximize the potential interior area. # """ def find_intersections(w1, w2): """ # Return a sorted list of tuples that represent intersection points. # The sorting orde...
7013c110a2e2f976b23da251ba9f42b59657311e
CodecoolBP20161/python-pair-programming-exercises-2nd-tw-szilvi_mark
/passwordgen/passwordgen_module.py
857
3.9375
4
import random import string strong_or_weak = input("Strong or weak password would you like to choose?") def passwordgen(): global strong_or_weak for_weak_password = ['hahika', 'hihike', 'ilovecheese'] if strong_or_weak == "strong": list_password = [] random_lenght = random.randint(8, 14) ...
068980cb4b9170e148c723ef1b5c0f395a9f02ac
telboon/Project-Euler
/oddEven.py
170
4.25
4
#!/usr/bin/python3 oddEven=50 if oddEven%2==1: print(str(oddEven)+" is odd!") elif oddEven%2==0: print(str(oddEven)+" is even!") else: print("This shouldn't run!")
2a4ed91c06d6c216a527dfed4522e356df88f858
Bahrom21/python_lessons
/12.07.2021/12.07.2021.py
521
3.703125
4
""" def fun(num): yig = 0 for i in str(num): yig+=int(i) print(yig) fun(n) Oʏʙᴇᴋ Nᴀʀᴢᴜʟʟᴀʏᴇᴠ, [12.07.21 11:47] [Переслано от Oʏʙᴇᴋ Nᴀʀᴢᴜʟʟᴀʏᴇᴠ] # 4 - masala. n = int(input("n = ")) """ # def xona_yigindi(a): # yigindi = 0 # for i in range(len(str(a))): # yigindi += a // (10 ** i) % ...
5167eaf105aa7f58b823c69bf773b84947875abb
Bahrom21/python_lessons
/Funksiyalar/15_07_datetime.py
625
3.5625
4
""" vaqt=dt.datetime.now() print(vaqt.year) print(vaqt.month) print(vaqt.day) print(vaqt.hour) print(vaqt.minute) print(vaqt.second) def vaqt(t) print(f"soat:{t.hour}:{t.minute} bo`ldi") vaqt(t) """ """ x=dt.datetime(2021, 7, 15) print(dt)""" """ import datetime x = datetime.datetime(2021,7,15) print(x) """ """ i...
d36f2a6c38ed2a89b03f9efeaa7960171361f300
Bahrom21/python_lessons
/21-31.06.2021/29.06.py
79
3.859375
4
n = 3 for i in range(1,n+1): for j in range(1,n+1): print(i,'x', j,'=', i*j)
907939bff91f3602da522c7de0c0b1da537c85e3
Bahrom21/python_lessons
/21-31.06.2021/4-masala 25.06.py
143
3.59375
4
import math a=int(input("a=")) x=int(input("x=")) y=int(input("y=")) G=(math.cos(2*abs(y+x)-(x+y))**(4*x*x))/(math.atan(x+a)**4*x**5) print(G)
b996f8a64ba54db420f34ca501851f241b672787
Bahrom21/python_lessons
/05.07.2021/4-masala 05.07.2021.py
362
3.96875
4
"""#matrix = [[1, 1, 1], [2, 2, 2], [3, 3, 3]] B = [[], [], [], [], [], [], [], [], []] for i in range(3): for j in range(3): B[i][j] = int(input(f"[{i}][{j}]=")) print(B)#""" # 3x3 matrisa xar elementi alohida qatorga chiqsin numberlist = [1,2,3] numberlist1 = [5,6,7] numberlist2 = [8,9,10] print(numberli...
409de30ab1bc103b081f5dbc4675a3a17d9a1c8d
Bahrom21/python_lessons
/21-31.06.2021/3-masala 25.06.py
107
3.609375
4
import math y=int(input("y=")) h=int(input("h=")) A=(math.tan(y**3-h**4)+h**2)/(math.sin(h)**2+y) print(A)
0b829978bc66ee64f7cd1123a800124119d1169d
Bahrom21/python_lessons
/21-31.06.2021/1-masala 29.06.py
191
3.609375
4
qidirilayotgan_son=int(input("qidirilayotgan raqamingizni kiriting")) for i in range(1,11): if qidirilayotgan_son == i: print("bor") break else: print("yo`q")
2ec734f5bcc997c81263a4fabd67efc3a51df4d8
Bahrom21/python_lessons
/13.07.2021/13.07 dars.py
591
3.515625
4
# REKURSIYA. #masala. 1 dan n gacha bo'lgan natural sonlarni ekranga chiqarish dasturi. """ def birdanNgacha(n): if n==1: print(n) else: print(n) birdanNgacha(n-1) birdanNgacha(10)""" """ def birdanNgacha(k, n): if n==k: print(k) else: print(k) birdanNga...
dbb99274b99980f61fad44d019c6055e8b7ff8c8
arifkhan1990/hackerrank-solution
/Python3/Python3 language/Lists.py
648
3.71875
4
# Name : Arif Khan # Judge: HACKERRANK # University: Primeasia University # problem: Lists # Difficulty: Medium # Problem Link: https://www.hackerrank.com/challenges/python-lists/problem # if _...
72107b37729b1d33683462e27ddc32993e149e7a
arifkhan1990/hackerrank-solution
/Python3/Python3 language/Mutations.py
573
3.75
4
# Name : Arif Khan # Judge: HACKERRANK # University: Primeasia University # problem: Mutations # Difficulty: Easy # Problem Link: https://www.hackerrank.com/challenges/python-mutations/problem #...
8320e270cc0ef7f8767336dfcb0dcf7ffe538e01
tocodeil/webinar-live-demos
/20200326-clojure/patterns/04_recursion.py
658
4.15625
4
""" Iteration (looping) in functional languages is usually accomplished via recursion. Recursive functions invoke themselves, letting an operation be repeated until it reaches the base case. """ import os.path # Iterative code def find_available_filename_iter(base): i = 0 while os.path.exists(f"{base}_{i}"):...
8045ee48406d08ba6bad22b7549ea55d191ffd56
elizabethendri/Batch-Gradient-Stochastic-Gradient-Descent
/HW-02.py
1,076
3.78125
4
# Elizabeth Endri # CSC 481 - Artificial Intelligence # HW 02 # This program implements batch gradient descent and stochastic descent algorithms # to find the linear regression equation # Initial Weights w0=.25 w1= .25 α = 0.0001 or 1/t # Repeat until convergence # how fast our model lea...
43d5ef9aa2cb9bb9e0ccff7721c27cb81607a065
soft9000/Python1000
/Python1100/Study/MyBannerSet.py
315
3.75
4
#!/usr/bin/env python3 prefix = set() prefix.add("Pig") prefix.add("Cat") prefix.add("Pig") prefix.add("Dog") for dat in prefix: print(dat) prefix2 = set(("pig", "Mouse", "Pig", "Dog")) print(prefix2.intersection(prefix)) print(prefix2.union(prefix)) prefix = frozenset() prefix.add("Pig")
fb5f69f7dd0a77dfdfcce1df40f7be08a3644a89
soft9000/Python1000
/Python1100/Study/MyListDelete.py
375
3.59375
4
# File: MyListDelete.py # OKAY! Rational item removal zList = ["This", "is", "a", "Test"] zPop = zList.pop(0) print("Popped:", zPop) print("Result:", zList) # ERROR! Irrational removal zList = ['Mary', 'had', 'a', 'little', 'lamb!'] zList.pop(-100) # IndexError: pop index out of range zList.pop(99) # Ind...
140f987ff550f9f0b83cd93ef7bcd6de4f295310
soft9000/Python1000
/Python1100/Study/SimpleInputLoop.py
219
3.953125
4
zOpts = ("Loop", "Break") while True: for ss, opt in enumerate(zOpts, 1): print(ss, ".)", opt) zChoice = input("What number? ") if zChoice is "2": break print("Looping ...")
fc0d283efec47c1f9a4b19eeeff42ba58db258c7
EdmondTongyou/Rock-Paper-Scissors
/main.py
2,479
4.3125
4
# -*- coding: utf-8 -*- """ Edmond Tongyou CPSC 223P-01 Tues March 9 14:47:33 2021 tongyouedmond@fullerton.edu """ # Importing random for randint() import random computerScore = 0 ties = 0 userScore = 0 computerChoice = "" userChoice = "" # Loops until the exit condition (Q) is met otherwise keeps asking for # on...
84ae781762294928dbcdf26133b537c39a2ee7ad
rshamsy/lpthw-exs
/lphw/ex7.py
341
3.71875
4
tryString = "x {}" for i in range(1,10): print(tryString.format(i)) tryString_2 = "x"*5 print("\nx*5: " + tryString_2, end=' ') # ", end=' '" causes the next print statement to coninue on the same line after a space, and not on next line print("a b c d") print("\nwith end='':") print("\nx*5: " + tryString_2, end=...