blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b3732c55bf3cc794fda7811b88558f7e6672b6f8
anthonyndunguwanja/Anthony-Ndungu-bootcamp-17
/Day 2/Data_Types_Lab .py
396
3.984375
4
def data_type(x): if type(x) is int: if x < 100: print('less than 100') elif x == 100: print('equal to 100') else: print('more than 100') elif type(x) is None: print('no value') elif type(x) is bool: print(bool(x)) elif type(x) is str: print(len(x)) elif type(x)...
5a60dade00c99a357b0f5982e3d8703abd349b11
Colin0523/Ruby
/Ruby/ExamStatistics.py
909
4
4
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for grade in grades: print grade print_grades(grades) grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] o = [6,5] def grades_sum(scores): total = sum(scores) return total print grades_sum(...
8226c9d6879b166b22974e187a931bc2014df449
MCVitzz/AED
/Deque.py
415
3.5
4
class Deque: def __init__(self): self.items = [] def add_front(self, item): self.items.insert(0, item) def add_rear(self, item): self.items.append(item) def pop_front(self): return self.items.pop(0) def pop_rear(self): return self.items.pop() def is_e...
9b3b287203c988e80248808faa68a0cdcc41f67d
Sandeep-Ravula/code-22April2021-SandeepRavula
/BMI_analysis.py
4,307
4.40625
4
## This is a Python code to give analysis results of BMI on the given JSON sample data-sets from pprint import pprint import json #Below is the function to calculate and return the BMI of the sample based on the given height, weight along with the BMI category and Health-Risks def bmi(gender,height,weight): """ ...
19569f831e6fa6486f4df73d025801433cabfcba
anirudhpillai16/Python-Excercises
/Challenges/Excercise12.py
352
4.21875
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. a = [1,2,6,7,1,4,3,1,8,2,8] b = [] def remdup(a,b): for i in a: if i not in b: b.append(i) print "List after removing duplicate value...
62343b696e9aef4f8f92f57fb7bb3c096dca2292
liudahuan0218/train-code
/6.py
307
3.53125
4
class A: def __init__(self,a,b): self.__a=a self.__b=b print('init') def mydefault(self,*args): print('default:',str(args[0])) def __getattr__(self,name): print('other fn:',name) return self.mydefault a=A(10,20) a.fn1(33) a.fn2('hello') a.fn3(10)
156f877d6a54962cf50b4c9a09b59da628210901
WenhaoChen0907/Python_Demo
/01_hellopython/hn_25_tuple02.py
307
3.875
4
# 格式字符串,格式化字符串后面的 () 本质上就是一个元组 info_tuple = ("小明", 18, 1.75) print("%s 的年龄是 %d 身高是 %.2f" % info_tuple) # 拓展:格式字符串可以拼接生成新的字符串 info_str = "%s 的年龄是 %d 身高是 %.2f" % info_tuple print(info_str)
2e8e9ede3967144e86b94da0a50bc5ff2c7a12eb
JCGilPose/Intro_Computing_David_Joyner
/exam_practice_6.py
1,784
4.25
4
#Write a function called are_anagrams. The function should #have two parameters, a pair of strings. The function should #return True if the strings are anagrams of one another, #False if they are not. # #Two strings are considered anagrams if they have only the #same letters, as well as the same count of each let...
cae8cecb66010b90e237f87c1721061f0954e7c2
Romario12c/COMP3608-2020
/assignments/assignment1/solution.py
1,775
3.546875
4
import json def check_valid(current_pairs): taken_men = set() for _, m in current_pairs: if m in taken_men: return False taken_men.add(m) return True def solve_helper(preferences, current_pairs, current_index, num_women): # see if we can progress (i.e. not at a deadend...
792d13f5516577c8974a93fd856b45d2d6c4d0d2
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4351/codes/1596_2049.py
270
3.90625
4
#colocamos a variavel dos numeros inteiros x=int(input("valor de x")) y=int(input("valor de y")) #agora colocamos a variavel do que e pedido dividendo=x divisor=y quociente=x//y resto=x%y #basta imprimir tudo print(dividendo) print(divisor) print(quociente) print(resto)
1e90804e6b31310b1f4154201f05a827bcda6d85
jearnest88/python
/multiply.py
128
3.53125
4
def multiply(a): x = a * 5 return x y = [2,4,10,16] g = 0 while g < 4: b = y[g] result = multiply(b) print result g +=1
0c60fb2bc9325f01df7e6dbacaf081e8b0d413c9
ntc-Felix/toolbox
/coding/writing_functions/dry.py
1,467
3.78125
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.decomposition import PCA from sklearn.model_selection import train_test_split # Dont Repeat Yourself (DRY) # At the first moment we have a function like this: def load_and_plot(path): """ Load a data set and plot the first tw...
05f86c2229bdfec330de2e07b63502587aeea88d
dhk1349/Algorithm
/Algorithm Practice/leetcode_59.py
1,490
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sat May 8 23:33:06 2021 @author: dhk1349 """ class Solution: def generateMatrix(self, n: int) -> List[List[int]]: condition=["right", "down", "left", "up"]# or left up down mode=0 out=[] cursor=[0, 0] # r, c # though ineffici...
8b77d7564ecaf44693439b8958b57f193ceb6203
tejasree0328/assignment5
/qu1.py
267
3.734375
4
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> import math r=float(input("enter radius:")) area=math.pi*r*r print("area of circle:",area)
787c196f86c764025fbeec81d9656ef82ba3ef85
bobrayEden/python-katas
/fizzbuzz.py
830
4.03125
4
""" TIY-fizzbuzz 7 kyu fizzbuzz """ # Ma solution def tiy_fizz_buzz(string): result = '' vowels = {'a', 'e', 'i', 'o', 'u'} for c in string: if (not c.isalpha() or (c not in vowels and not c.isupper()) ): result += c elif c.lower() in vowels and c...
d003f81f050b60be5fdd4543821aa7453c5a61d3
ygorvieira/exerciciosPython
/ex013.py
138
3.6875
4
#Cálculo de acréscimo (15%) s = float(input('Informe o salário: R$')) print('O salário com aumento é R${:.2f}'.format(s + (s*0.15)))
2da37a3b82e945f06b77121618e264c12493430c
crocodile033/content
/labs/lab8/anagrams.py
695
4.03125
4
from mrjob.job import MRJob class MRAnagram(MRJob): def mapper(self, _, line): # Convert word into a list of characters, sort them, and convert # back to a string. letters = list(line) letters.sort() # Key is the sorted word, value is the regular word. yield letter...
e1ed53516c721d388ef69b09477552d6a92ea22e
rdsteed/RasWik
/Python/Examples/02Receive.py
1,285
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Wireless Inventors Kit Python Example 02Receive.py Copyright (c) 2013 Ciseco Ltd. This basic Python example just open a serial port and send one LLAP message and receive a reply and prints it to the console Author: Matt Lloyd This...
9cfec44bedba0aeabc70bd7a873a565a9b3fa403
kolleshirisha/alarm-clock
/myminiproject-alarm.py
1,033
3.546875
4
from tkinter import * import datetime from tkinter import messagebox from tkinter.ttk import * import winsound obj=Tk() def alarm(): if(c1.get()=="AM"): x=int(e1.get()) y=int(e2.get()) if(c1.get()=="PM"): x=int(e1.get())+12 y=int(e2.get()) messagebox.showinfo("no...
3cc25068551ef4d261783dc462b248b8492341f7
andriitugai/10_python_apps_udemy
/Other/hello.py
160
3.78125
4
print("Hello!") import os dir = os.listdir() print(dir) a = ['a', 'b', 'c'] b = [1, 2, 3] for i,j in zip(a,b): print("%s is %s" % (i, j))
c6e62ee8ba73a87d375a2aa80c03a5b8655ae222
pa20abhay/Swaping
/swap2.py
48
3.578125
4
x=5 y=6 print(x,y) x=x*y y=x/y x=x/y print(x,y)
f4aab33db74d16614b93051e06a2536230ab1b65
UWPCE-PythonCert/Py100-2017q1
/jingdai/stringformat.py
300
3.53125
4
# # Write a format string that will take: # # ( 2, 123.4567, 10000) # # and produce: # # 'file_002 : 123.46, 1.00e+04' print("file_{:0>3d}: {:.2f}, {:.2e}".format(2, 123.4567, 10000)) t=(1,2,3) print("the 3 numbers are: {:d}, {:d}, {:d}".format(*t))
41ad546fa8e24fba19c5fefc437ad9972e7be39b
sanderheieren/in1000
/oblig6/dato.py
1,408
3.859375
4
# Program om datoer # 1, 2, 3 class Dato: def __init__(self, nyDag, nyMaanded, nyttAar): self._nyDag = nyDag self._nyMaanded = nyMaanded self._nyttAar = nyttAar def hentAar(self): return self._nyttAar def printDato(self): return f"{self._nyDag}/{self._nyMaanded}/{s...
0ee4deaac8683cf7c85338813f2827dd034ef750
ibianco91/curso_em_video
/exercicios/desafio 5.py
171
4.03125
4
v = int(input('Digite um valor')) print('o numero antecessor é {} e o numero sucessor é {}'.format((v-1),(v+1))) print('o numero somado a 10 é igual a {}'.format(v+10))
bf321e3fbfb736597146195c98833e8fb13d36f8
SterlingJosh/sat-sudoku
/display_solution.py
710
3.578125
4
#!/usr/bin/env python3 # encoding: UTF-8 """A pretty-printer to display the solution.""" __author__ = "David Oniani" __email__ = "onianidavid@gmail.com" __license__ = "GPLv3" def main() -> None: def p(x, y, z): return (((x - 1) * 9) + (y - 1)) * 9 + z line = input() if line.strip() == "SAT": ...
1c690ea62fa138507183ba1c65ae6888f0336c19
rajchauhan28/learn_with_raj
/tic_tac_toe_ex.py
1,886
3.859375
4
board=[0,1,2,3,4,5,6,7,8] x=[1,3,5,9] y=[2,4,6,8] print("Enter name of user playing as 'x' player") usrx = input() print("Enter name of user playing as 'y' player") usry = input() def boards(): print(board[0]," l ",board[1]," l ",board[2]) print("-------------------") print(board[3]," l ",board[4]," l ",board[...
45cc5c2855dda5563feccb699f78ceb7ea5e501f
yyHaker/PythonStudy
/algorithms/常见面试编程题(剑指offer&leetcode)/双指针&快慢指针&滑动窗口/8.无重复字符的最长子串.py
1,863
3.578125
4
#!/usr/bin/python # coding:utf-8 """ @author: yyhaker @contact: 572176750@qq.com @file: 10.无重复字符的最长子串.py @time: 2019/7/25 10:13 """ """ leetcode3: 无重复字符的最长子串 思路:滑动窗口 """ class Solution1(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ # 思路:滑动窗...
84cafbe66bb746b876bd011a6f9552e33396a61a
mstgrant/Interview_Prep
/Selection_sort.py
446
3.75
4
#Time Complexity O(n^2) #Space Complextiy O(1) def selection_sort(list_a): index_a = range(0,len(list_a)-1) for i in index_a: min_value = i for j in range(i+1,len(list_a)): if list_a[j] < list_a[min_value]: min_value = j if min_value != i: list...
f9b6ccdc394c40c55e894c5449411f52c6a8d7c2
GodMadoka/LeetCode
/array/566. Reshape the Matrix/R1.py
684
3.609375
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ def matrixReshape(nums, r, c): """ :type nums: List[List[int]] :type r: int :type c: int :rtype: List[List[int]] """ if len(nums)*len(nums[0]) != r*c: return nums ...
f11a12484eb394803ae46f4fee9cbaf03ee845fd
Derin-Wilson/Numerical-Methods
/poly_reg.py
3,221
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 15 18:48:45 2020 @author: esha """ import matplotlib.pyplot as plt import numpy as np import sympy as sym """This is a program to perform polynomial interpolation""" #Enter the data x=np.array([0,1,2,3,4,5]) y=np.array([2.1,7.7,13.6,27.2,40.9,61...
48db56f8f8182bc630790959eeeabf484e534405
teohongwei898/python
/divisbleby10.py
225
3.90625
4
#Write your function here def divisible_by_ten(nums): x = 0 for y in nums: if (y % 10 == 0): x += 1 return x #Uncomment the line below when your function is done print(divisible_by_ten([20, 25, 30, 35, 40]))
833f01cbb75a4275754c1b4b932ede4d7213d9b6
takecian/ProgrammingStudyLog
/hackerrank/30-days-of-code/day29.py
643
3.515625
4
# https://www.hackerrank.com/challenges/30-bitwise-and/problem #!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': t = int(input()) for t_itr in range(t): nk = input().split() n = int(nk[0]) k = int(nk[1]) a = k - 1 # 答えの候補...
8cb75263cee39e95232dd5dca4d4c7d46867c4c1
Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021
/answers/justshivam/Day 27/question2.py
129
3.890625
4
string, num = input(), int(input()) while len(string) < num: string += string string = string[:num] print(string.count('a'))
899d5c0dfeccdb3146e2480474aefd8b723334cc
anoirtrabelsi/Path-Finder
/Main.py
4,583
3.828125
4
from collections import deque import pygame import Graph as graph import math #This class represents the GUI #Select start then end vertex then draw obstacles with the mouse #Hit the Enter key pygame.init() class grid(object): def __init__(self, w, h, rows): self.w = w self.h = h self.ro...
a6b64b703d685bcb8885b96dae69c382193f0a70
qcq/WeChatCopyer
/src/listener/mouselistener.py
220
3.53125
4
# -*- coding:utf-8 -*- #!/usr/bin/env python3 from pynput import mouse mouseController = mouse.Controller() def on_scroll(x, y, dx, dy): print(x, y, dx, dy) listener = mouse.Listener( on_scroll=on_scroll )
5c75f93b0b896566e451949a375a3999537708c2
mfarzamalam/Snake_Charmer
/numpy/one_dimension/user_input.py
492
3.609375
4
from numpy import * ### Using For loop # user = int(input("How many user do you have?\n:")) # rollno = zeros(user, dtype=int) # print("Enter their Roll Number's\n") # for i in range(user): # ids = int(input(":")) # rollno[i] = ids # print(rollno) ### Using While Loop user = int(input("How many user do you...
2c9c1ea44c545e4d0cdb74f6234012bc604142e2
amitdshetty/PycharmProjects
/PracticePythonOrg/Solutions/23_File_Overlap.py
1,717
4.1875
4
""" Problem Statement: Given two .txt files that have lists of numbers in them, find the numbers that are overlapping. One .txt file has a list of all prime numbers under 1000, and the other .txt file has a list of happy numbers up to 1000. (If you forgot, prime numbers are numbers that can’t be divided by any other n...
e9bfd9657352b3f8aff32cd943d82663d08d2566
ricarcon/programming_exercises
/2021/implementQueueWithStack.py
1,588
4.25
4
class Queue: def __init__(self): self.s1 = [] self.s2 = [] self.flag = True #when we move elements from one stack to the other, the new stack will now have the last element at the top vs the bottom, so we can just pop from the top if even def enQueue(self, val): s...
97e7251535e3656d9dad93c48ca3fb9e3c15b1eb
jereneal20/Basic_Python_Study
/week4/gugudan.py
182
3.78125
4
number = 0 while number < 10: number2 = 0 number = number + 1 while number2 < 10: number2 = number2 + 1 print(number,"단!! ",number2," * ",number," = ", number * number2)
815ff83f3e238d6a603163152ef6239b0587007b
southpawgeek/perlweeklychallenge-club
/challenge-188/vamsi-meenavilli/python/ch-1.py
1,103
4.15625
4
#!/usr/bin/env python3 ''' Week 188: https://theweeklychallenge.org/blog/perl-weekly-challenge-188 Task #1: Divisible Pairs You are given list of integers @list of size $n and divisor $k. Write a script to find out count of pairs in the given list that satisfies the following rules. The pair (i,...
a2eff41cb79724f0b86f6cbc6a63b9053dc7fe12
AyaElAshry/Mancala_Game
/Mancala_Project.py
5,580
3.6875
4
import time import sys from pytimedinput import timedInput def print_board(board): print("| |" , board[12], "|" , board[11], "|" , board[10], "|" , board[9], "|" , board[8], "|" , board[7], "| |" ) # print("-----------------------------") print("|{}| \t\t\t\t\t |{}|" .format(board[13], board[6])) #...
58e5e631c2c7471a86087fc88a14436846e8106a
django-group/python-itvdn
/домашка/starter/lesson 7/Dmytro Marianchenko/t_2.py
769
4.09375
4
def fib(max): """ Функция выводит число Фибоначчи, согласно порядковому номеру списка. для работы функции, передайте число равное порядковому номеру чила Фибонначи """ num1 = 0 num2 = num1 + 1 numbers.append(num1) numbers.append(num2) for i in range(max): numbers.append(numbe...
40044c7ebb51620e5cfb338d4a7393965e4b5675
rdhakal098/RichterScale
/proj01.py
289
3.828125
4
print("How many Richters are you converting") richter = float(input()) print("Richter scale Value:", richter) def Conversions(): joules = 10**((1.5*richter)+4.8) print("Amount of Joules:", joules) tnt = joules / (4.184*10**9) print("Amount of TNT:", tnt) Conversions()
7d30529d3e4db547e23297db14f8b8d786e2e005
Allaman/pckt
/pckt/db.py
1,222
3.5
4
# -*- coding: utf-8 -*- """ db implements functionality to create a local sqlite3 database containing Pocket items from the fetch module """ import os import sqlite3 from sqlite3 import Error from fetch import get_tags def create_db_con(path): """Returns a sqlite3 connection object Args: path (str):...
0c9307e508116e65603363c1a355ef46c0a38812
branko-malaver-vojvodic/Python
/values_dict.py
177
3.828125
4
#Function that prints the assigned value of a key animals_count = {'Lion':1, 'Tiger':2, 'Shark':3, 'Dog':4, 'Cat':5} print (animals_count['Tiger']) print (animals_count['Dog'])
b604953bc6662432589bf9d32c7090f2b383c243
CodeHemP/CAREER-TRACK-Data-Scientist-with-Python
/19_Writing Functions in Python/04_More On Decorators/06_Run_n_times().py
1,564
4.28125
4
''' 06 - Run_n_times() In the video exercise, I showed you an example of a decorator that takes an argument: run_n_times(). The code for that decorator is repeated below to remind you how it works. Practice different ways of applying the decorator to the function print_sum(). Then I'll show you a funny prank...
c218f564293dc03f627eba8e79c4f7072f5f7d05
dombroks/Daily-Coding-Problems
/Google_Problems/Google_Problem_38.py
903
3.859375
4
""" This problem was asked by Google. Given the root of a binary search tree, and a target K, return two nodes in the tree whose sum equals K. For example, given the following tree and K of 20 10 / \ 5 15 / \ 11 15 Return the nodes 5 and 15. """ class Node: def __init__(self, va...
bca3c67594e37453908f1d0f417c2ec438740e69
gutovesco/Introduction-to-Python-
/funcoes.py
342
4.15625
4
# -*- coding: utf-8 -*- def divisao(x, y): return x/y divisao = divisao(10, 2) def quadrado(m, n): return m**n quadrado = quadrado(3, 3) print("O valor da divisao é:") print(divisao) print("\nO valor do quadrado é:") print(quadrado) print("\nO valor do quadrado menos o da divisão é:") print(quadrad...
74f4ba52c88c312f1a51774fb300e08106ec683b
atriekak/LeetCode
/solutions/78. Subsets.py
2,181
3.703125
4
class Solution: #Solution 1 def subsets(self, nums: List[int]) -> List[List[int]]: #Approach: Recursion with backtracking #Time Complexity: O(n * 2^n) #Space Complexity: O(n) #where, n is the length of nums self.result = [] self.backtracking(nums, 0, []) ...
2599a61dc1699469e6988fc07012e25fbe63cd28
nickhuber327/budget
/actualPercents.py
1,860
3.734375
4
#actualPercents import csv def calcPercents(filename): """Calculates the actual percentages of the 5 category budget at any income""" budget = {"Housing" : 0, "Transportation" : 0, "Food" : 0, "Personal" : 0, "Savings" : 0, "Debt" : 0, ...
ee16920bdad9f99f3937bb7433dd7a9acb0fc254
Patryck1999/Curso_em_Video
/PythonExercicios/Mundo_2/ex038.py
495
3.84375
4
""" Escreva um programa que leia dois números inteiros e compare-os mostrando na tela uma mensagem: - O primeiro valor é maior - O segundo valor é maior - Não existe valor maior, os dois são iguais """ valor_1 = int(input("Digite o primeiro valor: ")) valor_2 = int(input("Digite o segundo valor: ")) if valor_1 > valo...
6920a63d717d5b2a6501b6aae644163254f53873
MartaSzuran/Python-for-the-Absolute-Beginner-M.Dawson
/Chapter 5/who_is_your_father_1.py
1,974
3.8125
4
# program kto jest twoim ojcem # dodanie imienia i nazwiska osoby z przyporzadkowaniem imienia i nazwiska ojca #słownik fathers przedstawia wartość imienia i nazwiska ojca w stosunku do klucza syna fathers = {"Miś Puchatek" : "Miś Grizzly", "Rycerz Bez Piątej Klepki" : "Rycerz Bez Czwartej Klepki", "Brad Pitt" : "Bóg...
878a941728a4108abc810a42bbb11a768b641e66
KXJiao/ResearchTime
/dicClassifier.py
676
3.546875
4
text = open("subInfo.txt").read() def findCount(sub): count = 0 terms = open(sub).readlines() terms = [t.strip().lower() for t in terms] for t in terms: if t in text: count += 1 return count subArr = [] subArr.append((findCount("biology_terms.txt"), "biology_ter...
40e8fafcfe717d7385cf12cecbea27db08903c17
wchung94/Rosalind
/Bioinformatics/lia.py
2,171
3.65625
4
#!/usr/bin/env python3 """ Author: WYC Given: Two positive integers k (k≤7) and N (N≤2k). In this problem, we begin with Tom, who in the 0th generation has genotype Aa Bb. Tom has two children in the 1st generation, each of whom has two children, and so on. Each organism always mates with an organism having genotype Aa...
b2ddad622beb6df04adc0aa686268814ba7bbd14
funtion/praise
/praise/tests/helper.py
317
3.609375
4
def caption_check(word, word_list): if not word.isalpha(): return True return word.isupper() and word.lower() in word_list def first_letter_caption_check(word, word_list): if not word.isalpha(): return True return word[0].isupper and word[1:].islower() and word.lower() in word_list
55c9a653b14824324053aebcffb89f4babcaeedc
kaphleyy/Backup
/DSA/Dictionary.py
734
4.0625
4
# constructors of dictionary myDict = dict([('Name', 'Amrit'), ('age', 24)]) d1 = {'one': 1, 'two': 2, 'three': 3} d2 = dict(one=1, two=2, three=3) print(myDict) print(d1) print(d2) print() # add and update element in a list d2['four'] = 4 d2['three'] = 33 print(d2) # delete an element, all elements or whole list del...
fda9caf4c95d4bb6757be94be161f098c21c8c82
Florence-TC/Hangman
/Topics/Loop control statements/Party time/main.py
166
3.625
4
guest_list = [] while True: name = input() if name != ".": guest_list.append(name) else: break print(guest_list) print(len(guest_list))
2ec705a9b3df2d3f6df6306fa5b5ee0215a4d152
aabhishek-chaurasia-au17/MyCoding_Challenge
/coding-challenges/week10/day04/Q.2.py
1,826
3.78125
4
""" Q-2 )Baseball Game: (5 marks) https://leetcode.com/problems/baseball-game/ (Easy) You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds' scores. At the beginning of the game, you start with an empty record. You are...
fbf32a5c02df9e2bc817e27a1b092e5d5ce84dd7
meliyahu/python-tut-101
/functions.py
438
3.8125
4
def power(value): return value**2 def how_long(value=None): if (value != None): return len(value) else: return "No length" def converter(origin_unit, units="m", coefficient=0.348): result = (origin_unit * coefficient) return f"{result} {units}" def cels_to_fah(celsius): retur...
2b2c3a907f2fc960eb8457b8313ffb5972afa9b2
nandyorama/PyPractise
/enumerate.py
600
4.75
5
# Accessing items using enumerate() cars = ["Aston" , "Audi", "McLaren "] for i, x in enumerate(cars): print (x) print (list(enumerate(cars))) for x in enumerate(cars): print (x[0],x[1]) #Enumerate takes parameter start which is default set to zero. We can change this parameter to any value we like...
0ebf6e438ccfaa6c55dd3505c2e23c36493145f8
3bdifatah/lab5
/ui.py
376
3.703125
4
def get_name(): name=input('name: ') return name def get_country_and_record(): country = input('country: ') record = int(input('number of chainsaws caught: ')) return country, record def get_new_record(): new_record = int(input('number of chainsaws caught: ')) return new_record def error...
4b3c1f377671eb60dae11f071320bd32ed775bc6
ABoxOfPringles/Math-Formulas
/rectangle.py
252
4.0625
4
# Calculating the area of a square l = input("What is the length? ") w = input("What is the width? ") area = float(l) * float(w) if l == w: print("That is a square, you fucking idiot.") else: print("The area of the rectangle is " + str(area))
3003c6e7c0ab8d1153d1c3cdb348f574c4ceffc8
auchappy/MA305
/cw7/cw7.py
965
4.03125
4
#!/usr/bin/env python3 import numpy as np from matplotlib import pyplot as plt """ ======================================================================== MA305 - cw 7: Chapman, Piers - 15NOV18 Purpose: Use a function to plot some stuff. Yeah. ======================================================================== ...
2da2c9395a7b99fd75bb40ba50bf75a2ebf9108c
kolchinSI/friendly
/django-exemples/mysite/mysite/1.py
589
3.578125
4
def bread(func): def wrapper(): print("Булочка") func() print("<\Булочка/>") return wrapper def ingredients(func): def wrapper(): print("#помидоры#") func() print("~салат~") return wrapper def sandwich(food="--ветчина--"): print(food) @bread @i...
19b05950db913c9b3834eabadb79285669d877c9
Ashish-012/Competitive-Coding
/recursion/arraySum.py
139
3.671875
4
def arraysum(arr): if len(arr) == 0: return 0 num = arr[0] return num + arraysum(arr[1:]) arr = [15, 12, 13, 10] print(arraysum(arr))
1389d79fb934db1cbc34aad384f4280fe29ae7c0
GaryXiongxiong/python
/ex11.py
565
4.125
4
#coding:utf-8 ################# # 习题11:提问 ################# # 前言 # # 这里主要理解:接收用户的输入 # print "How old are you?", # 接收控制台的输入信息 age = raw_input() # 在python3.x 中,raw_input 被 input代替(待深究) print "How tall are you?", height = raw_input() print "How much do you weight?", weight = raw_input() print "So,you're %s old, %s tall ...
f2b8ed6767160d50615feb1bd3d948f221f4cb07
vadim-job-hg/checkio.org
/py.checkio.org/Elementary/Popular Words.py
683
3.84375
4
def popular_words(text, words): # your code here return {word:text.replace(","," ").replace("\n"," ").replace("."," ").lower().split().count(word) for word in words} if __name__ == '__main__': print("Example:") print(popular_words(''' When I was One, I had just begun. When I was Two, I was nearly new....
2ce1b15417384cabe857bdb1d21428f8aeaccd36
furuhama/sicp
/sicp_in_python/src/my_package/account.py
1,286
4.0625
4
""" every Account instance has its holder & balance """ class Account(object): interest = 0.02 # class attribute @classmethod def show_inheritance(cls): print([c.__name__ for c in cls.mro()]) """ instance methods """ def __init__(self, account_holder): self.balance = 0 ...
37c322b9bac05e9935c36054c9530a344558f702
jagtapshubham/Python
/Strings/VowelConsonentCount.py
757
4.0625
4
#!/usr/bin/python3 def vowel_consonent_count(string): cvowel=0 cconsonent=0 cdigit=0 cspchar=0 for i in string: if i>='a' and i<='z' or i>='A' and i<='Z': i=i.lower() if i=='a' or i=='e' or i=='i' or i=='o' or i=='u': cvowel+=1 else: ...
4b7936c69a301824659cec82561b076dcbd6c522
Artem-Vorobiov/Tic-Tac-Toe
/ttt_2.py
1,602
3.921875
4
import os import time import random # Define the board board = [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '] def print_the_header(): print('\n\n\t\t\t\t_______ TIC--TAC--TOE _______\n\n\n') def print_board(): print(' | | ') print(' '+board[1]+' | '+board[2]+' | '+board[3]+' ') print(' | | ') pri...
eddf150b5ecf4a3fa057cdad5c63e315ba112b3e
Arality/Dice-Roller
/roller.py
428
3.9375
4
import random class Dice: pass def __init__(self): self = self pass def roll(self, dice) return random.randint(1,dice) TotalDice = int(input("Home many Dice would you like to roll:")) TotalSides = int(input("How many sides on the Dice:")) Sum = 0 x = 0 while x != TotalDice: ...
dd7d81e59769e5711bb9d84f8fadee014cbe325f
Astlight/blockChain
/PoW.py
174
3.78125
4
# -*- coding:utf-8 -*- from hashlib import sha256 x = 5 y = 0 # y未知 while sha256(f'{x*y}'.encode()).hexdigest()[-1] != "": y += 1 print(f'The solution is y = {y}')
82d5190ff1a94b03aa42b8bb4f50ad0b4856ec03
qinyanjuidavid/Hands-On-Python
/Dictionaries.py
783
4.09375
4
#Dictionaries are simply a collection of words matched with their definations. #Dict are usually made up of key and values spanish=dict() spanish['hello']='hola' spanish['yes']='si' print(spanish,type(spanish),sep="|") #Trial two name=dict() name['David']=23 name["Jane"]=32 name['John']=42 print(name,type(name),sep="|...
a78f42c95ebb8d9931ce54c84cfed7f2b98ac288
JohnSalazarTec/Portafolio1
/NumeroPar.py
469
4
4
""" Nombre:numeroPar Entradas: n: Entero positivo mayor o igual a cero salidas: Entero mayor a cero donde el numero sea elegido verdadero si es par o sea elegido falso si es impar. Restricciones: Entero positivo mayor o igual a cero """ def numeroPar(num): if(isinstance(num,int)and nu...
d64ddd4d9e2e435d71c156022079b0fd3d0d2eb2
harshhx/codeforces-practice
/Candies and Two Sisters.py
131
3.640625
4
t = int(input()) for _ in range(t): n = int(input()) if n<3: print(0) elif n%2 != 0: print(n//2) else: print(n//2 - 1)
57ef8955ae34d0751981f264d5add1a79440a0d9
mundopacheco/lindenmayer
/src/tortuga.py
1,640
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Aug 16 09:28:39 2019 @author: mundo """ import matplotlib.pyplot as plt from math import cos, sin, pi from stack import Stack class Tortuga: # Tortuga constructor def __init__(self,d,delta,x=0,y=0,angle=0,color='c'): self.x = x ...
229e1ec67c523bc9805606ea3d9c7ddb1c1d634b
licosty/learning_python
/chapter_3/exercise_2.py
1,190
3.984375
4
''' Страница упражнения - 55 ''' # 3-4 print() party = ['Hoba', 'Boba', 'Ad'] print('Hey ' + party[0] + ', go to my party') print('Hey ' + party[1] + ', go to my party') print('Hey ' + party[2] + ', go to my party') # 3-5 print() print(party[2]) party[2] = 'Kevin' print('Hey ' + party[0] + ', go to my party') print('...
f6e29c889e4912abaf7fe471933533673b46b66e
sumsted/python_class
/lesson11-moreclasses/exercise.py
1,451
4.0625
4
class Animal: def __init__(self, classification): # add a parameter called classification to __init__() # store the classification parameter in an instance variable self.classification = classification def __eq__(self, other): return self.classification == other.classification...
b7832ade8eccf3d99d47c40564c98f52a5fcb9dd
deppwater/-
/singleListNode.py
3,541
3.9375
4
""" 链表的题主要考察的coding能力是尽量缩小辅助空间 """ class Node(object): def __init__(self, elem): self.elem = elem self.next = None class SingleLinkList(object): def __init__(self, elem): head_node = Node(elem) self.head = head_node def isEmpty(self): return self...
340551b9307b26a3eef0ab2fef371800e10bc64c
aditya-doshatti/Leetcode
/random_point_in_non_overlapping_rectangles_497.py
1,595
3.65625
4
''' 497. Random Point in Non-overlapping Rectangles Medium Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space covered by the rectangles. Note: An integer point is a point that has integer coordinates. A point on the ...
c768c150fd6c410fe2b3c9ba8329f1ed6308bc78
cshintov/python
/anand-python/chapter2/ex38invertdict.py
831
4.0625
4
import sys #Returns the key,value tuple list sorted based on the key def v(_dict): key_val=_dict.items() key_val.sort(key=key_fn) sort_val=[] for tup in key_val: sort_val.append(tup[1]) print sort_val return key_val #Interchanges each of the (key, value) pair def invertdict(_dict): new_dict={} for ...
9502832482ee6f0941407f202864b8f1fa252c38
brimmann/python-exercises
/book2/chap3/general.py
149
3.625
4
class Chair(object): """This class represents chairs.""" def __init__(self, name, legs=4): self.name = name self.legs = legs
89bb8c382cf6fecbe542b18725a5565af1b061cc
learninglegion/PCC
/old_exercises/chap10exercises.py
5,040
3.984375
4
#10.1 # with open('learning_python.txt') as file_object: # contents = file_object.read() # print(contents.rstrip()) # filename = 'learning_python.txt' # with open(filename) as file_object: # for line in file_object: # print(line.strip()) # with open(filename) as file_object: # lines = file_object....
e20655ac6937f781722b4130a0834e0189df566f
xCUDx/PycharmPythona-z
/hello/assignment5.py
1,088
4.4375
4
# Define a first_three_characters function that accepts a string argument. # The function should return the first 3 characters of the string. # # EXAMPLES: # first_three_characters("dynasty") => "dyn" # first_three_characters("empire") => "emp" def first_three_characters(word): return word[0:3] print(first_th...
0c00d69ef7c315571ffd54603be8bbc4f6c058ac
j-mai/BreakOut
/Ball.py
1,131
3.890625
4
#Ball class for Breakout game #Jasmine Mai from cs1lib import * class Ball: def __init__(self, x, y, radius, r, g, b, velocity_x, velocity_y): self.x = x self.y = y self.radius = radius self.r = r self.g = g self.b = b self.velocity_x = velocity_x se...
d41c4eeba9751d660428f9d69ccd94dcecedb85f
dogbyt3/Data-Science-Projects
/Neural Networks/Steepest Descent/experiment3.py
2,108
3.53125
4
import numpy as np import matplotlib.pyplot as plt import random import nnlib def main(): # number of samples to create n = 20 # number of repititions to run NN for nReps = 200 # data set percentages train_pct = 0.60 test_pct = 0.20 valid_pct = 0.20 # create some random independe...
4873b1523737be173f42e3ee000d0e52cd9e47a5
alqamahjsr/InterviewBit-1
/07_DynamicProgramming/ways_to_color_a_3xN_board.py
1,019
3.59375
4
# Ways to color a 3xN Board # https://www.interviewbit.com/problems/ways-to-color-a-3xn-board/ # # Given a 3Xn board, find the number of ways to color it using at most 4 colors such that no two adjacent boxes have same color. Diagonal neighbors are not treated as adjacent boxes. # Output the ways%1000000007 as the answ...
05a8b827dac2bc41fe3849cf1aaed04cf3e5d55f
JaydeepKachare/Python-Classwork
/Session4/functions /Functions.py
936
3.9375
4
# Functions.py # 1 : function accept nothing and return nothing def fun() : print("function fun") # 2 : function accept parameter and return nothing def gun(no) : print("function gun with paramter : " ,no) # 3 : function accept paramter and return value def sun(no): print("function sun with param...
ce3f80e4614504a971c2a170d643fe098c67207c
dansoh/python-intro
/python-crash-course/exercises/chapter-6/6-10-favorite-numbers.py
252
3.671875
4
favorite_numbers = { 'daniel' : [28, 69], 'anthony' : [4, 14, 25], 'alex' : [9, 24, 35], } for name, numbers in favorite_numbers.items(): print("\n" + name.title() + "'s favorite number is:") for number in numbers: print("\t" + str(number))
e05a8770ace02f25048ea1f02550d2d575b3416d
cgdaker/si475
/final/state.py
4,855
3.53125
4
class State: # takes in a position and a disctionary of balloon locations def __init__(self, position, balloons, goal, parent=None, priority=1000): self.position = position self.balloons = balloons self.goal = goal self.parent = parent self.visited = False self.g...
27b4b5c852d38f427ff5cb18f837c4971fd9718a
theindianczar/VirtEnvProj
/ageINput.py
161
3.953125
4
name= input("hello what is your name") print("hello",name) print('so',name,'how old are you') age = input() age = int(age) print('next year you would be ',age+1)
ac157d48861cc0863114adffa3aae0a00ad3f691
sachin-rajput/ctci-v6-solutions
/ch1_Arrays_Strings/q1.2.py
1,051
3.921875
4
# Question: # Given two strings, write a method to decide if one is a permutation of the other. # Runtime: O(n * log n) def isPermutation1(str1, str2): if len(str1) != len(str2): return False # Runtime for sorted here is O(n log n) if(''.join(sorted(str1)) != ''.join(sorted(str2))): re...
bc53b4178d8f954149112b8694b5c5987328a39c
SamMorton123/26.2-app
/src/components/trackrankings.py
1,706
3.734375
4
''' Streamlit "component" for rendering track rankings. Sam Morton, TwentySix.Two January 26, 2020 ''' import pandas as pd import plotly.graph_objects as go import streamlit as st # constants CURR_YEAR = 2020 TABLE_WIDTH = 1350 TABLE_HEIGHT = 700 def TrackRankings(selected_event): ''' Render most recen...
4c436cea3e57a5a0a05e8518efa5b7f9a3ef3867
pony6666/100--master
/untitled0.py
155
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 9 08:58:56 2019 @author: malin """ def f(x): x=x+1 print('inf(x):x=',x) return x x=3 z=f(x)
dbd150d851ffa03cdcb4a2b65714f573a9e1658a
SabithaSubair/Luminar_PythonDjangoProjects_May
/collections/list/divisbleby8_listcomprhnsion.py
227
3.609375
4
# ls=[i for i in range(1,1000) if i%8==0] # print("Even number between 1 to 1000 is:",ls,"\n","count is:",len(ls)) ls=[i for i in range(1,1000) if i%5==0] print("Even number between 1 to 1000 is:",ls,"\n","count is:",len(ls))
1047408bf92a17308f8257b05f648ac1663b9bce
ksrntheja/08-Python-Core
/venv/oops/102HierarchicalInheritance.py
789
3.75
4
class P: def p01(self): print('Parent p01 method') class C1(P): def c1m01(self): print('Child c1m01 method') class C2(P): def c2m01(self): print('Child c2m01 method') print('C1') c1 = C1() c1.p01() c1.c1m01() # c1.c2m01() # Traceback (most recent call last): # File "/Code/ven...
4a2c0ee05278589197b0e8333c1781d335a9445b
AndersonHJB/Student_homework
/xiaokai/课堂代码/01-函数的定义/def_fun02.py
419
3.796875
4
# -*- coding: utf-8 -*- # @Time : 2021/6/9 9:18 上午 # @Author : AI悦创 # @FileName: def_fun02.py.py # @Software: PyCharm # @Blog :http://www.aiyc.top # @公众号 :AI悦创 def HelloUser(username=None, age=None): result = "hello {}, age: {}".format(username, age) # print(result) return result a = HelloUser(age=18, use...
bb3ff06321788546a36d9b07219581dec9d473d4
anivicks/nanotech
/MyPython/timetable.py
343
3.796875
4
table = [1, 2, 3, 4, 5] for x in range(1, 11): multitable = [] for y in table: pro = x * y multitable.append(pro) print(multitable) for x in range(1, 11): multitable = [] multitable.append(x) for y in range(4): x += multitable[0] multitable.append(x)...
37a7da81f3bf35aec7a4600333721b1cb4e1aeda
Malvyn/DL
/DL2(Teacher-Fang)/p40_24points.py
2,355
3.59375
4
import numpy as np def get_random_numbers(num, minimum, maximum): return np.random.randint(minimum, maximum, [num]) def get_values(numbers): """ :param numbers: a list of the numbers which is great than zero :return: a list of the tuples of (value, exp) that the numbers can compose with addition(+)...
dec458417c5e072b512c2771974bbad951d6dd55
Mikhail-Khanaev/Tic-tac-toe
/tic-tac-toe.py
3,862
3.609375
4
# Внешний вид игрового поля field = [ [' ', '0', '1', '2'], ['0', '-', '-', '-'], ['1', '-', '-', '-'], ['2', '-', '-', '-']] move = "O" # Переменная, которая отвечает за то, чей сейчас ход, первые всегда ходят крестики Flag = False # Флаг, который будет меняться после выполнения условий в бесконечном ци...