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
9ed58555f4bea81ea61d8fa95d83f249c4a8b999
koshikka/assingment1
/a1_t1_8.py
154
3.671875
4
def k_to_f(k): f = (k - 273.15) * 9/5 + 32 return f k = 283.0 f = k_to_f(k) print("kelvin of" + str(k) + "is" + str(f) + "in kelvin")
979041ca3296b986f0a96d6c617b7fa037a4c534
janellesh08/Python_assignments
/hello.py
185
3.9375
4
FirstName = input("Please, enter your first name.") LastName = input ("Please enter your last name.") message = f"First Name: {FirstName}, Last Name: {LastName}" print(message)
442c078137b023a26a7ec76b6b8bcac64d0ca358
michaelobi99/snake-game
/app.py
12,657
3.8125
4
# using tkinter to simulate a snake game #import the tkinter library from tkinter import * import tkinter.messagebox import tkinter.simpledialog from random import randint class Snake: def __init__(self): self.window = Tk() self.window.title("Snake game") self.window.resizable(False, False) ...
69f6b96d636c231b12fafb4905ba9a6aca8f351a
levuhachi/levuhachi-lab-c4e23
/lab1/homework/study1_get_current_time.py
223
4.0625
4
# Exercise 1: # Learn how to get the current hour of your computer # Hint: Google “python 3 get current hour” from datetime import datetime now = datetime.now() print (now.day, now.month, now.year, now.hour, now.minute)
706d716e3b00300ef10f1e459d3dc3abdb8ed3a0
levuhachi/levuhachi-lab-c4e23
/lab3/calc1.py
436
4.03125
4
a = float(input("a= ")) b = float(input("b= ")) #Warm Up 1: c = a + b print("a + b = ",c) #Warm Up 2: operation = input("Operation(+,-,*,/: ") print ("*" * 20) if operation == "+": print("a + b =",a+b) elif operation == "-": print("a - b =",a-b) elif operation == "*": print("a * b =",a*b) elif operation == ...
411cc86ab0f69cdc89dd4de6565c5e0b6755f2a4
AtilioA/Python-20191
/lista3jordana/Ex033.py
1,273
3.8125
4
# 6) Faça um programa que lê as duas notas parciais obtidas por um aluno numa disciplina # ao longo de um semestre e calcule a sua média. A atribuição de conceitos obedece à # tabela abaixo. O algoritmo deve mostrar na tela as notas, a média, o conceito # correspondente e a mensagem “APROVADO” se o conceito for A,B ou ...
cb872587b807a4fa720448e1b4be38e462d9d562
AtilioA/Python-20191
/lista8jordana/Ex051.py
542
3.625
4
# Dada uma lista de duplas formadas por nomes de alunos e suas respectivas médias de # notas obtidas ao longo do curso, obter uma nova lista de duplas, ordenadas em ordem # decrescente dessas médias. def permuta(lista, i1, i2): aux = lista[i1] lista[i1] = lista[i2] lista[i2] = aux return lista def bol...
cb84dfe7c8b97399758c6924c273f354bd09e5bd
AtilioA/Python-20191
/Project Euler/euler2.py
524
3.765625
4
# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. def somafibonacciPar(): somaTermos = 0 anterior = 0 atual = 1 limite = 4000000 while (atual <= limite): if (atual % 2 == 0): somaTermos += atual ...
c7f03f51f21780f89384f0a41bd4af27c0efd48e
AtilioA/Python-20191
/lista6jordana/Ex035.py
212
3.671875
4
# 1) Dada uma lista, determine o seu maior elemento. from functools import * def minN(n1, n2): if n1 < n2: return n1 else: return n2 def minLista(lista): return reduce(minN, lista)
89786e3d23a48edae281b38edcc1df05db998b13
AtilioA/Python-20191
/lista7jordana/Ex062.py
744
4.15625
4
# 12. Faça uma função que receba uma lista de números armazenados de forma crescente , e # dois valores ( limite inferior e limite superior), e exiba a sublista cujos elementos são maiores # ou iguais ao limite inferior e menores ou iguais ao limite superior def intervalo(listaOrdenada, limInferior, limSuperior): ...
0c93c3ff29fde537181cb2c57621090c5805d874
AtilioA/Python-20191
/lista1jordana/Ex006.py
404
3.78125
4
import math def pertenceIntervalo(x, a, b): if a > b: aux = a a = b b = aux if x >= a and x <= b: return True else: return False # print(pertenceIntervalo(1, 2, 3)) # print(pertenceIntervalo(50, 3, 99)) # print(pertenceIntervalo(50, 99, 3)) # print(pertenceInterval...
aac41be4b9974afcfe7d26921298ed28e41bb971
AtilioA/Python-20191
/lista5jordana/Ex024.py
1,541
3.59375
4
# 3.1. A expressão que calcula o volume da figura. Faça o modelo de avaliação da expressão. import math as jordana def vCilindro(r, h): v = jordana.pi * r ** 2 * h return v def vSemiCilindro(r, h): v = vCilindro(r, h) / 2 return v def volumeFigura(rMenor, rMaior, alturaEmPe, alturaDeitada, larguraCil...
b1841284102e88bb8c6e78ea5540579668ce9b44
AtilioA/Python-20191
/Slides e testes/Ex046.py
238
3.671875
4
def menorLista(lista): if len(lista) == 1: return lista[0] elif lista[0] < menorLista(lista[1:]): return lista[0] else: return menorLista(lista[1:]) lista = [55,78,2,8,0,2,8] print(menorLista(lista))
b72668b16b525c51d08c424030f8a536a7129b91
AtilioA/Python-20191
/Slides e testes/Ex004.py
4,258
4
4
# 6) Dada a idade de uma pessoa em segundos e um planeta do sistema solar, calcule # qual seria a idade relativa dessa pessoa no planeta informado, sabendo que o # Período Orbital é o intervalo de tempo que o planeta leva para executar uma # órbita em torno do Sol (o que é denominado de ano, que na Terra tem # aproxima...
75db23491fd660c007860b03e4ed99cca64a9025
zengh100/PythonForKids
/lesson02/07_keyboard_number.py
316
4.15625
4
# keyboard # we can use keyboard as an input to get informations or data (such as number or string) from users x1 = input("please give your first number? ") #print('x1=', x1) x2 = input("please give your second number? ") #print('x2=', x2) sum = x1 + x2 #sum = int(x1) + int(x2) print('the sum is {}'.format(sum))
4871826ada05278e48da0bc9f2a6fb9cb117108c
thoffart/otimizacao_monovariavel
/Packages/Busca_Dicotomica.py
733
3.671875
4
class metodo(): def __init__(self, fx, delta, a, b, epsilon): self.fx = fx self.delta = delta self.a = a self.b = b self.epsilon = epsilon def calcula(self): while(abs(self.b - self.a) > self.epsilon): xaux = (self.a + self.b)/2 x = xaux ...
019535772cf6e719e7e6fd9fb30ad63d4ccee054
davendiy/matan_2course
/lab6/lab6.py
3,443
3.625
4
#!/usr/bin/env python3 # -*-encoding: utf-8-*- # by David Zashkol # 2 course, comp math # Taras Shevchenko National University of Kyiv # email: davendiy@gmail.com import numpy as np eps = 10e-9 def compacting_split(a: float, b: float, n: int) -> np.ndarray: """ розбиття, яке ущільнюється :param a: поча...
ac078c137248d768b9456e6581a6c47a9043c7c5
davendiy/matan_2course
/lab1/lab1_integral.py
5,103
3.515625
4
#!/usr/bin/env python3 # -*-encoding: utf-8-*- # by David Zashkolny # 2 course, comp math # Taras Shevchenko National University of Kyiv # email: davendiy@gmail.com """ модуль з функціями, які реалізують обчислення визначеного інтегралу різними методами """ import math import random # -----------------------------...
89b312bd10e84811f57046607c8d2881d9a67420
yiz202/leetcode
/nine_chapter/three sum closest.py
920
3.765625
4
class Solution: """ @param numbers: Give an array numbers of n integer @param target : An integer @return : return the sum of the three integers, the sum closest target. """ def threeSumClosest(self, numbers, target): # write your code here numbers.sort() small = 99999 ...
a2e4edc247f33feedb49dc0f200cccb1ed89c9aa
yiz202/leetcode
/235(2)recursion.py
1,606
3.890625
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def lowestCommonAncestor(self, root, p, q): """ :type root: TreeNode :type p: TreeNode :type q: Tre...
174e7efdd801dc1c8d007c3f08949eab4eac0a93
yiz202/leetcode
/241.py
825
3.640625
4
class Solution(object): def diffWaysToCompute(self, input): """ :type input: str :rtype: List[int] """ def helper(leftnum, rightnum, op): if op == '*': return leftnum * rightnum if op == '+': return leftnum + rightnum else:...
ca523cd3e8c6c5cd4c8df6c01f0a08c2b0c97200
yiz202/leetcode
/24 swap node in pairs.py
656
3.703125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None 1234 class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ dummy = ListNode(0) dum...
d0619fde603c9ef21ccfaf5ad80a9a021c44d9f2
yiz202/leetcode
/40.py
675
3.59375
4
class Solution(object): def combinationSum2(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ def search(nums,target,res,possible): for i,e in enumerate(nums): if e < target: ...
c401b647f10e5802ecb5cac55f5cc843fe827f86
yiz202/leetcode
/jacob's hw/remove repeat.py
255
3.609375
4
def removeRepeat(s,letter): return ''.join([s[i] for i in xrange(1, len(s)) if s[i] != letter or s[i-1] != letter]) # li = [] # for i in s: # if i == letter # li.append(i) # print removeRepeat('xkclueeeexejfenlneeeix', 'e')
cd374e3e6885f1db69425f2f007080470bb3b963
jonesmat/codechallenge
/model/puzzle.py
1,811
3.515625
4
from problem import Problem class Puzzle(object): def __init__(self, data_mgr): self.data_mgr = data_mgr self.problems = [] self.puzzle_id = '' self.name = '' self.instructions = '' self.app_path = '' self.state = PuzzleState.NEW def load(self, puzzle_data): ''' Check how the DataManager loads...
ef117ed4d90041050eed954b22aa5b0a6b2f2e72
julio-nf/cracking-coding-interview-solutions
/chapter-01/03-urlify.py
607
3.6875
4
# O(n²) since string slicing is O(n) def urlify(string: str) -> str: def replace_slice_url(string: str, i: int, j: int) -> str: return string[:i] + "%20" + string[j:] string = string.strip() i = len(string) - 1 j = i while i != 0: if string[i] == ' ': while string[j] == ...
6abefccce5a10189e9ee2d149a78658c05348fc9
julio-nf/cracking-coding-interview-solutions
/chapter-03/03-stack-of-plates.py
1,039
3.609375
4
class StackOfPlates(): def __init__(self, max: int) -> None: self.stacks = {} self.max = max self.total_len = 0 def _get_last_stack(self) -> list[int]: if len(self.stacks) == 0: return None return self.stacks[len(self.stacks) - 1] def push(self, value: ...
bd310f0c1498688707ca250b93d81f2fbe99f2d0
julio-nf/cracking-coding-interview-solutions
/tree.py
1,258
4.03125
4
class Node(): def __init__(self, value): self.value = value self.left = None self.right = None class Tree(): # O(log n) where n is number of nodes def insert_node(self, node: Node, value): if node is None: return Node(value) if value == node.value: ...
cc4c2cf52cf831974663400ef430df788058bd5c
W0n9/Data_Structure_Python
/queue.py
2,096
4.03125
4
from typing import Union class Node(object): def __init__(self, elem, next=None) -> None: self.elem = elem self.next = next class Queue(object): def __init__(self) -> None: self.head = None self.rear = None def is_empty(self) -> bool: return self.head is None ...
0c9fdcfa231b64e1e3a2af64caf377680988fae1
cristinabac/Artificial-Intelligence
/Lab5/aco4.py
14,982
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 1 19:46:30 2020 @author: Bacotiu-Denisa Cristina - group 921/1 """ from itertools import permutations from copy import deepcopy from random import random, choice import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import statistics class A...
7ac66dc258dbd6ab3d183eb328938f73fde09243
muhamadziaurrehman/Python
/Finding the Greatest number from list.py
204
3.9375
4
List = [1,2,3,4,5,6,7,8,9] Len = len(List) ###Length of List Greatest_Num = List[0] for x in range(0,Len): if Greatest_Num > List[x]: continue else: Greatest_Num = List[x] print(Greatest_Num)
ab38aaac210610d8b6b26ef0cab0d918d58f81b7
muhamadziaurrehman/Python
/Finding and printing odd numbers from list.py
283
4.34375
4
List = (1,2,3,4,5,6,7,8,9) ###This function is printing odd position numbers according to programmers who starts counting from 0 minor changes occur to start it from 1 i-e change x to x+1 only in if statement for x in range(0,9): if (x)%2 == 0: print() else: print(List[x])
2a0261cf30afaf35e66f90020a6331f95f83e305
TheLabbingProject/django_analyses
/tests/interfaces.py
1,302
3.5625
4
import numpy as np class Addition: def __init__(self, x: float, y: float): self.x = x self.y = y def calculate(self) -> dict: return {"result": self.x + self.y} class Power: def __init__(self, base: float, exponent: float): self.base = base self.exponent = expone...
c75d693b5f9e6fbf51573a8e2ede8070b52ec4cb
kasataku777/PY4E
/chap8-list/ex8-5.py
1,126
4.125
4
# Exercise 5: Write a program to read through the mail box data and # when you find line that starts with “From”, you will split the line into # words using the split function. We are interested in who sent the # message, which is the second word on the From line. # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:1...
a895e10b36a30794206a2130998d21fab8cd6784
chenshun12580/helloGithub
/knn_minist_number.py
6,984
3.96875
4
""" K-近邻算法实现手写数据集识别系统(手写数据集Minist) """ # 加载库 import numpy as np import pandas as pd import operator # 获取数据集 def get_digit(): print('test_images...') test_images = pd.read_csv("E:\\PYTHONproject\\BAG\\机器学习数据\\Minist_test_data.csv") print('test_labels...') test_labels = pd.read_csv("E:\\PYTHONproject\\BA...
34be6c02e3e34d4ccc9652581237e0ff92d5c87d
drahul401/pythonscripts
/print('RD').py
97
3.515625
4
print('RD') print('d') a=1,2,3 print(a) b=4,5,6,7 c=a+b print(c) d=b+a print(d)
21e087371351ed3eb82ab866674f93acfd52f2ff
drahul401/pythonscripts
/Test.py
198
3.828125
4
print('HI') x = input ("enter name:") print("hi", x) x = input ("hrs:") y=input("rate:") a = float(x) b = float(y) z = a * b print(z) if a>20: print("ot") else: print("normal")
9e14205ff95f2ebebf26bd8aeddd15194a36d399
ShubhanYenuganti/TicTacToePython
/TicTacToe.py
3,062
4.03125
4
def start(): print("Welcome to Tic Tac Toe") res = "result" compl = False while(compl != True): res = input("Please pick a marker X or O: ") if (res == 'X' or res == 'O'): compl = True return res def display_board(board): print(board[1] + " | " + board[2] + " | " + board[3]) print(board...
bc204746027f72a2c68e230e9be6a4a3fc8bce26
sneceesay77/python_projects
/python_basics/classes.py
933
4.125
4
class Tutorial: """Modelling a Tutorial class""" #a docstring, mainly printed in documentation #constructor def __init__(self, module_name, max_students): self.module_name = module_name self.max_students = max_students def display_max_stud(self): print(f"Maximum number...
b0e10d7961966bc713d8e9931468db173310e453
sneceesay77/python_projects
/python_basics/restaurant.py
1,680
3.671875
4
class Restaurant: def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print(f"Name of restaurant {self.restaurant_name} Cuisine type {self.cuisine_type}") def open_res...
4b11cd3e357f769570e9383c13cab6623d424676
MarcPartensky/Pygame-Geometry
/pygame_geometry/physics.py
3,401
4.03125
4
from .motion import Motion from .material import Material class Physics(Material): #,Rotational? """Create a physical object that can have multiples motions for describing the way the objects move in any space. Because a physical object is also a material object it makes it easy to use in practice.""" ...
fa728c0a7611861209dd2c99f823621c2bb061be
MarcPartensky/Pygame-Geometry
/pygame_geometry/triangle.py
540
3.90625
4
from .abstract import Form class Triangle(Form): """Representation of triangle.""" @classmethod def random(cls, **kwargs): return super().random(n=3, **kwargs) def __init__(self, points, **kwargs): if len(points)!=3: raise Exception("There must be 3 points in a triangle not...
1a3637e35b9f0bb83155ee4ffc9c412eed210616
MarcPartensky/Pygame-Geometry
/pygame_geometry/group.py
4,823
3.96875
4
from copy import deepcopy class Group(list): def __init__(self, *elements): """Create a group using the unpacked elements.""" super().__init__(elements) def __str__(self, name=None): """Give a str representation of the group.""" if name is None: name = type(self)._...
6e7d258b3760926db70a0849320b4ebb9855092d
Nao-Y1996/LearningPython
/ICPC/2018/ansA.py
226
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- n = int(input()) a_list = list(map(int, input().split(' '))) ave = sum(a_list)/int(n) ans_list = [] for i in a_list: if ave >= i: ans_list.append(i) print(len(ans_list))
f7c3307aef504629b414de53dcf59ac622beb906
Nao-Y1996/LearningPython
/func_visualization.py
873
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -* import numpy as np import matplotlib.pyplot as plt # 近傍順位関数 # lは学習が進むにつれて小さくすることで学習後半は近接するノードのみ更新することができる def nearest_neighbor(k, l): return np.exp(-1*k/l) # 収束速度の制御関数 # 近接順位関数における l を変化せさる関数 # l は t(学習回数)が大きくなるほど小さくしたいので initial < finalとする def convergence_speed(t, m...
fc82ccb116710e46a6240703d1316b78f5ef9fe0
Nao-Y1996/LearningPython
/ICPC/2014/ansB.py
2,062
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as np ans_list = [] while (True): h = int(input()) # 終了条件の時,答えを出力して終了 if h == 0: for answer in ans_list: print(answer) break # 終了条件でないとき else: ans = 0 stones = [] for row in range(h): ...
9dbe57bc0c7a2f9dbf8da6c55387e8749d6ecda1
CatsMeow492/practice-projects
/miles-to-kilometers/main.py
63
3.515625
4
miles = input() kilometers = miles * 1.609344 print(kilometers)
b045ff13c4bf858b433528616d3bf02efcbcae56
CatsMeow492/practice-projects
/sololearn-labs/dictionarys.py
288
3.84375
4
nums = { 1: "one", 2: "two", 3: "three", } print(1 in nums) print("three" in nums) print(4 not in nums) pairs = { 1: "apple", "orange": [2,3,4], True: False, 12:"True", } print(pairs.get("orange")) print(pairs.get(7,42)) print(pairs.get(12345, "not found"))
01f57965e48f1e625fee1da98c00ff138b1f0fea
mmacdonnacha/Adven-of-Code-2019-python
/day06/day06.py
2,474
3.515625
4
def part1(list_of_orbits): orbits_dict = {} orbits_count = {'COM' : 0} orbits_dict = planet_orbit_dictionary(list_of_orbits) count = 0 planet_list = list(orbits_dict.keys()) while len(planet_list) > 0: for planet in planet_list: prev_planet = orbits_dict[planet] ...
f5199dab7a0115fd931bae9d38e55cfe1a697005
PerlinWarp/AdventOfCode2018
/day2/p1/1.py
452
3.65625
4
#Day 2 - Problem 1 twos = 0 threes = 0 path = "input.txt" file = open(path, "r") for line in file: dico = {} s = set(line) three = False two = False for char in s: dico[char] = 0 for char in line: dico[char] += 1 for key in dico: if(two and three): break if(dico[key] == 2 and two == False): two...
c84cd9885dd85e22ed42e4aedbe0a377155fdd89
hwamoc/algorithm-study
/rlaclgh/lv3_타일 장식물.py
191
3.546875
4
def solution(N): length = [1,1] area = [4,6] for i in range(N-2): length.append(length[-1]+length[-2]) area.append(area[-1]+length[-1]*2) return area[-1]
19f2779870026ff84f9f8981c848f9629fbfb21f
FatemehRezapoor/Matlab_Linux
/PythonExercise/Ex3.py
533
4.03125
4
# June 10, 2018 # Take a list and write a program that prints out all the elements of the list that are less than input number. number = int(input('Number:\t')) a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [] for i in range(0, len(a)): if a[i] < number: b.append(a[i]) else: pass print(b) # ...
65c0f048ec6fb7e8ea9adc7f6f1064dc774c4812
ivaylospasov/programming-101
/week0/magic_square.py
1,050
3.875
4
#!/usr/bin/env python3 def magic_square(matrix): matrix_sums_set = set() matrix_dimentions_digits = [] first_diagonal = [] second_diagonal = [] transposed_matrix = [[row[i] for row in matrix] for i in range(len(matrix))] for idx, row in enumerate(matrix): matri...
eb45891ee654fdf5838183d21b840700a46137ca
ivaylospasov/programming-101
/week0/reduce_file_path.py
754
3.8125
4
#!/usr/bin/env python3 def reduce_file_path(path): path_parts = [] path = path.split('/') for index, part in enumerate(path): if not (path[index] == "" or path[index] == "."): path_parts.append(path[index]) for index, part in enumerate(path_parts): if path_parts[index] == '...
b07ad656cf7d622f2c7038320567a50e4ac31e5c
ivaylospasov/programming-101
/week0/contains_digit.py
233
3.65625
4
#!/usr/bin/env python3 def contains_digit(number, digit): if str(digit) in str(number): return True else: return False def main(): print(contains_digit(1234, 4)) if __name__ == '__main__': main()
2c9a301385c3f3a3864f2ff8a53d5a67835199db
ivaylospasov/programming-101
/week0/nan_expand.py
189
3.53125
4
#!/usr/bin/env python3 def nan_expand(times): not_a = "Not a " * times return "{0}NaN".format(not_a) def main(): print(nan_expand(3)) if __name__ == '__main__': main()
5d8601802cb13b42bacf51308463429aa5054735
ivaylospasov/programming-101
/week0/sevens_in_a_row.py
239
3.828125
4
#!/usr/bin/env python3 def sevens_in_a_row(arr, n): sevens = [x for x in arr if x == 7] if n > 0 and len(sevens) >= n: return True else: return False print(sevens_in_a_row([10, 8, 7, 6, 7, 7, 7, 20, -7], 3))
6194db2615e2819ffb8437cbbc8a2f511a093854
ivaylospasov/programming-101
/week0/prime_number_of_divisors.py
329
4.125
4
#!/usr/bin/env python3 from is_prime import is_prime def prime_number_of_divisors(n): divisors = [x for x in range(1, n+1) if n % x == 0] if is_prime(len(divisors)) is True: return True else: return False def main(): print(prime_number_of_divisors(45)) if __name__ == '__main__': ...
cf398f1e943501c351dd1822b65aff62c07ce8c0
afrigon/blitz-2020-clicksvp
/bot.py
19,518
3.5
4
from collections import Counter from functools import partial from pprint import pprint from collections import deque from typing import Dict, List from game_message import * from bot_message import * import random TAIL_THRESHOLD = 15 TAIL_INCREMENT = 2 OPPONENT_THRESHOLD = 7 def manhattan_distance(p1, p2): retu...
48b2af86561b5d42ae2bd1972948ddc58b891974
piyushpisu/Snake-Water-and-Gun-Game
/My Game 1 Code.py
1,968
4.0625
4
""" My First Project/Game #Snake Water and Gun Game!!!!""" import random def GameWon(computer,human): if computer==human: return None elif computer=="s" and human=="w": return computer elif computer=='w' and human=='s': return human elif computer=='g' and human=='w': return human elif computer...
b2b86d9596d514196662e4df6e62edcd3558f1b2
Jacob-jiangbo/jacob-studio
/exercise-py/random_example.py
506
3.75
4
# !/usr/bin/python import random # create random float from 0<=n<1.0 print random.random() # create random float from a<=n<=b print random.uniform(10, 20) # create random int from a<=n<=b print random.randint(10,20) # create random int from a<=n<=b stepped by c print random.randrange(10, 100, 2) # create random ...
6d4f60c611b15fc39f04939f7ada0610d07b31a7
MayankVerma105/Python_Programs
/trianglestars.py
937
3.90625
4
''' def triangle(n,nRows): k = n- 1 nSpaces = 0 nStars = 2 * nRows - 1 for i in range(0,n): print(' '* nSpaces + '*' * nStars) nStars -= 2 nSpaces += 1 for j in range(0,k): print(end =' ') k = k- 1 for j in range(0, i+ 1): ...
920c812f7e53c6bbd429ad043768723fe3f1ead7
MayankVerma105/Python_Programs
/insertionSort.py
395
3.921875
4
def insertionSort(lst): for i in range(0, len(lst)): temp = lst[i] j = i - 1 while j >= 0 and lst[j] > temp: lst[j + 1] = lst[j] j = j - 1 lst[j + 1] = temp def main(): lst = eval(input('Enter the list: ')) print('Sorted List') ins...
a3387722a6d8ac4ecf061ed08de7887fa38c7e59
MayankVerma105/Python_Programs
/max3.py
530
4.125
4
def max3(n1,n2,n3): maxNumber = 0 if n1 > n2: if n2 > n3: maxNumber = n1 else: maxNumber = n3 elif n2 > n3: maxNumber = n2 else: maxNumber = n3 return maxNumber def main(): n1=int(input('Enter first number :...
a0c345ef1bff86d36895d35a6291383a06ef8def
MayankVerma105/Python_Programs
/multiplication.py
305
4.125
4
def printTable(num, nMultiples = 10): for multiple in range(1, nMultiples + 1): product = num * multiple print(num,'*','%2d'% multiple, '=' , '%5d'% product) def main(): num = int(input('Enter the Number : ')) printTable(num) if __name__ == '__main__': main()
7adba4f2b11da7f619a33f455d37725a7f9650d0
martingamban/BSIT302-Activity2
/salary.py
570
3.71875
4
employees = [] class Employee: def __init__(salf, name, department, position, rate): self.name = name self.department = department self.position = position self.rate = rate def getSalary(self, hourly): return self.rate * hourly employee.append(Employee("Charles...
5981728a1e7b0bf5260f0d04432939a2f778c4e8
15077693d/BodyStation
/body_station/tool/position_seacrh.py
5,895
3.65625
4
import os,sys import matplotlib.pyplot as plt import cv2 from matplotlib.widgets import RectangleSelector import numpy as np import json def overlay_transparent(background_img, img_to_overlay_t, x, y, overlay_size=None): """ @brief Overlays a transparant PNG onto another image using CV2 @param backgroun...
1ee82eb006562f08f7b0e7c188b10a1a35e504ed
natiiix/Assistant
/action_define.py
1,760
3.84375
4
"""This module contains functions used for defining word meaning.""" import synthesizer as synth import requests import bs4 DEFINE_EXPRESSIONS = ( "define", "what is", "who is" ) WIKIPEDIA_URL_BASE = "https://en.wikipedia.org/w/index.php?search=" def findwiki(expression): """This function finds the...
4d9a439a7e2c3eea5d6413139db67b685fb38e7a
Burrisravan/python-fundamentals.
/LIST/lists.py
1,013
4.1875
4
lst1=[1, 'sravan', 10.9] lst2 =[90,20,50,100,8,0] lst3 =[5,89,3,99,23,7] print(lst1) print(lst1[2]) print(lst1+lst2) print(lst1*5) print(max(lst2)) print(min(lst2)) print(len(lst2)) print(lst2[:]) # prints all in the list print(lst2[1:3]) print(lst2[-1]) # pri...
2e925f659f66530009d4559681d348d5d21581fb
taniey/go-slides
/reboot/lesson01/scripts/guessnum.py
879
3.859375
4
# -*- coding: utf-8 -*- '''guess the num''' # from random import randint import random def main(): '''the guess function''' can_retry_count = 6 thenum = random.randint(0, 100) # thenum = random.randrange(0, 101) # print(type(thenum)) while can_retry_count > 0: print("you have", can_r...
3ecc132007c95e7d84efb6b8054cfa19c6580661
benpulido21/python_prueba_isep
/triangle.py
575
3.984375
4
#declaramos la clase triangulo con el constructor y sus atributos privados class Triangulo(object): def __init__(self): self.__a = 6 self.__b = 10 self.__c = 6 #metodo para calcular la altura y area de un triangulo e imprimirlo def CalcularArea(self): a = self.__a...
87cf969513834e654f7f62398be4f18240b0622e
naix5526/genese-final_python
/assignment-4c.py
1,385
4.0625
4
'''Implement question number 1, 2 and 6 from Session 3 Exercise as different functions in a single(.py) file''' '''1. Write a program to display all prime numbers from 1 to 100''' def prime(): print("Prime numbers are: ") for i in range(1,101): c = 0 for j in range(1,101): if i % j...
b58a3cca7cc65000663f1c6174e1d98a43b118f2
nickmcadden/Kaggle
/NCAA/2016-17/code/massey_ratings.py
1,123
3.546875
4
import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) # Input data files are available in the "../input/" directory. # For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory data_dir = '../input/' df_massey = ...
7d975d1479545d2a8f030b29fa537dec5d814d25
nickmcadden/Kaggle
/Homedepot/code/test.py
354
3.625
4
#loop through the ngrams, key_pos will be the number of ngrams or else the one before the first that contains 'with' from nltk.util import ngrams title = ['the','cat', 'sat','on', 'the','mat','with','the','dog'] key_pos = 0 for t_ngram in ngrams(title, 2): print(t_ngram) key_pos += 1 if t_ngram[-1] == "with": ke...
8969228734bda8998b943e4a2a3b9c3e56d4b135
Tawn/Compiler-Scanner
/tokenizer.py
4,097
3.671875
4
# Lexical process: removing white lines and comments token = [] user_variables = [] digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] reserved_words = ["int", "void", "if", "while", "return", "continue", "break", "scan", "printf", "main", "write", "read", "else"] symbols = ["(", ")", "{", "}...
a8bca500397fe617774a655065a8b4f2898d7b21
Ergash04/phyton-darslari
/dars-16.py
362
3.640625
4
print('do`stlaringizni yoshini saqlaymiz') dostlar = {} ishora = True while ishora: ism = input('do`stingizni ismini kiriting:') yosh = input(f"{ism.title()} ning yoshini kiriting:") dostlar[ism] = int(yosh) javob = input('yana ism qo`shasizmi? (ha/yo`q)') if javob == "yo`q": ishor...
6dc29726f1ff7647eac0fb8ba6c4a4c4491594e5
enthusiasticgeek/common_coding_ideas
/python/dynamic_typing.py
157
3.5625
4
#!/usr/bin/env python3 # Dynamic typing in Python message = "Hello, World!" print(message) message = 42 print(message) message = [1, 2, 3] print(message)
4ad7d619d47c08500341a4e860b95a11301f233f
enthusiasticgeek/common_coding_ideas
/python/exception.py
553
4.21875
4
#!/usr/bin/env python3 def divide_numbers(a, b): try: result = a / b print("Result:", result) except ZeroDivisionError: print("Error: Division by zero!") except TypeError: print("Error: Invalid operand type!") except Exception as e: print("An unexpected error occu...
3982d495e405bef4db0ae8a3787540f03ad38f01
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/Searching/count_element.py
1,682
4.15625
4
from typing import List def find_min_index(A: List[int], x: int) -> int: """ Finds the max index of the element being searched :param A: Input Array :param x: Element to search in the array :return: Min Index of the element being searched """ min_index = -1 start = 0 end = len(A)-1...
16cc6706d31469e30bb278d68016b04f41ed3537
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/hackerrank/ReverseArrayInplace.py
145
3.65625
4
def reverse_array(a): i = 0 j = len(a) - 1 while i <= j: a[i], a[j] = a[j], a[i] i += 1 j -= 1 return a
1668578a1b7cac4d5fe98a40855691737c787289
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/datastructures/graph/dfs_traversal.py
1,032
3.734375
4
from datastructures.graph.Graph import Graph def dfs_traversal(graph, source): """ Time Complexity: O(V + E) """ result = [] visited = set() # Add the source vertex to the stack stack = [source] while len(stack) > 0: vertex = stack.pop() result.append(vertex) ...
e81faee5b80e46b9efa87794c8293d22638a20b1
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/Sorting/insertion_sort.py
427
4.125
4
''' Insertion Sort Time Complexity : O(n^2) Best Case : O(n) Average Case : O(n^2) Worst Case : O(n^2) Space Complexity : O(1) ''' def insertion_sort(A): n = len(A) for i in range(1, n): value = A[i] hole = i while hole > 0 and A[hole - 1] > value: A[hole] = A[hole - 1] ...
436944fd0810939bb2b5d9eba2fafc07bc541a60
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/datastructures/tree/BinarySearchTree.py
9,091
4.3125
4
import sys from queue import Queue class Node: def __init__(self, data): ''' Creates a new node with left and right pointers pointing to None :param data: data of the new node ''' self.data = data self.left = None self.right = None class BinarySearchTree: ...
94c3716860b97d1e577c2b0b9f7eea0483df2501
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/leetcode/find_minimum.py
264
4.0625
4
import math def find_minimum(arr): """ Time Complexity: O(n) Space Complexity: O(1) """ min_value = math.inf for x in arr: if x < min_value: min_value = x return min_value print(find_minimum([10, 2, 5, 6, 8]))
bbe4ea6780e4b3aa8bb98bd82fb38a9ea0bc678a
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/datastructures/stack/Stack.py
1,282
4.15625
4
class Stack: def __init__(self): self.stack = [] self.top = -1 def push(self, x): ''' Push an element x into the stack :param x: input element ''' self.top += 1 self.stack.append(x) def pop(self): ''' Removes the topmost eleme...
274ba9400492f7a1ac39283a2419e19921c2d2f5
mohanakrishnavh/Data-Structures-and-Algorithms-in-Python
/leetcode/product_except_self.py
771
3.734375
4
def product_except_self(arr): """ Time Complexity: O(n^2) Space Complexity: O(1) """ result = [] for i, x in enumerate(arr): product = 1 for j, y in enumerate(arr): if i != j: product *= y result.append(product) return result def product...
0f22054647eabd674ab0c8c0af5540e0af2ab9ae
pawelkalinowski/project-python
/Fibonacci n-th number (iterative).py
1,735
3.84375
4
""" The MIT License (MIT) Copyright (c) 2013 Pawel Kalinowski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, me...
9b7e9c82023a3c54ecfd2a804310684fccf9dd23
RadoslawP/slowniki
/turtle_fraktal.py
618
3.578125
4
import turtle def ustawienia(pisak): pisak.color('blue') pisak.penup() pisak.goto(-200, 100) pisak.pendown() def koch(pisak, rozmiar, skala): if skala == 0: pisak.forward(rozmiar) else: for kat in [60, -120, 60, 0]: koch(pisak, rozmiar/3, skala-1) pisak....
dce4c2074cad3dbbe1c750d33e83145b25d22287
albee56/What-day
/calendar.py
1,053
4.09375
4
year = int(input('Year: ')) month = int(input('Month: ')) day = int(input('Day: ')) # lst is the list contains all years lst = list() x = 1900 while x < year: lst.append(x) x = x + 1 # count is the total days before the enter year count = 0 for ye in lst: if ye % 400 == 0 or (ye % 4 == 0 and ye % 100 != 0...
e68bad4e94224ea33f7723472429141f005f2c3f
zingesCodingDojo/PythonAlgorithms
/_PythonAlgorithms/LL_Flatten.py
5,574
4.1875
4
class Node: def __init__(self, data=None): self.data = data self.next = None self.prev = None self.child = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def add_child(self, child): current_child = Node() de...
79ee615b411c88a8a04ddc4cfc52ea7504a7178e
ogozuacik/turkce-haber-derlemi
/haberlerde_kesif_cizici.py
1,549
3.671875
4
import pandas as pd import matplotlib.pyplot as plt # veri okuma data=pd.read_csv('derlemler/filtrelenmis_temizlenmis_derlem.csv.gz') # grafik çizimi için yardımcı metot def window_average(x,N): low_index = 0 high_index = low_index + N w_avg = [] while(high_index<len(x)): temp = sum(x[low_inde...
8b629dbfc892b3a462f3a9d1d3efc9e332b1f3ed
santiago-miguel-5023/Final-Project-CS-162
/game_of_life.py
11,028
4.6875
5
#! /usr/bin/env python3 """ Conway's Game of Life The square class is what we use to set up the grid for the program. The grid class is what we use to set up the rules and manipulate the squares. The app class is what we use to set up the program with TKinter. Mico Santiago """ import tkinter as tk import random ...
b4d7d43174d9813addb997338bbbef97d6b76c48
iAshutosh-joshi/knc-402-python-lab
/lab8.py
330
3.84375
4
print("Lab 8 by Ashutosh Joshi") def linear_Search(list1, n, key): for i in range(0, n): if (list1[i] == key): return i return -1 list1 = [5, 4, 7, 9,5,3,33] key = 9 n = len(list1) res = linear_Search(list1, n, key) if(res == -1): print("Element not found") else: print("Element found...
55845d436c03941d09bc7240b1f61b7d0af91f66
iAshutosh-joshi/knc-402-python-lab
/lab16.py
171
3.71875
4
print("Lab 16 by Ashutosh Joshi") c='A' temp=5 for i in range(5): s="" for j in range(temp): s=s+c c=chr(ord(c) + 1) print(s) temp=temp-1 c='A'
962724f3e413addc00a37c82e2c1c9bea82e94c3
qu1616/website-builder
/project/html_builder.py
3,222
3.859375
4
""" CSC1-141 description: project 1 author: Quincy Myles Jr. """ import sys import build import build_site def user_input(): """ Prompts the user for inputs :return: website data structure """ website_title = input("What is the title of your website? ") print("Background Colo...
6e269d6d53c1325a8f2d974a30e94a7e34d2c7ba
jmlon/Estructuras-Algoritmos
/1-ADT/punto2D/point2DPolar.py
1,269
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #----------------------------------------------------------------------- # Point2DPolar.py # An implementation of the Point2D using the polar representation # # Author: Jorge Londoño #----------------------------------------------------------------------- import math fro...
cb267175bc590bbe0abc1d0c631a6f21ebbd3cdf
RuarkReynolds/Learning-Python
/question2.2.py
1,247
4
4
noun = input("Provide a noun: ") adjective = input("Provide an adjective: ") noun_two = input("provide another noun: ") verb = input("Provide a verb: ") objects = input("Provide an object: ") print("{} ran {}, so {} {} {}.".format(noun, adjective, noun_two, verb, objects)) import random import time no...
03c7da215924c0a83e28503c868455c6936a0839
smmsadrnezh/numerical_methods_python
/numerical-differentiation.py
549
3.984375
4
"""numerical_differentiation.py: Calculate second numerical differentiation of a function using numerical methods.""" from math import sqrt __author__ = "Masoud Sadrnezhaad" # Read the input x = float(input("Point: ")) function = input("Enter the function: ") error = float(input("Error: ")) func_x = eval(function)...
53e76716c520046f434162136b466854e81a2298
Jeffzfeng/uda_intro_SDC
/U2_matrices/matrix.py
6,981
4
4
import math from math import sqrt import numbers def zeroes(height, width): """ Creates a matrix of zeroes. """ g = [[0.0 for _ in range(width)] for __ in range(height)] return Matrix(g) def identity(n): """ Creates a n x n identity matrix. """ I...
371f392c7a448ac36e0948f5b0eb5ee0fc2c425c
danielpsf/python-coding-dojo
/src/case_converter.py
635
4.0625
4
def convert_from_snake_to_camel_case(snake_case: str) -> str: words_list = snake_case.split("_") return words_list[0] + "".join([word.capitalize() for word in words_list[1:]]) def convert_from_snake_to_kebab_case(snake_case: str) -> str: words_list = snake_case.split("_") return "-".join([word for wor...