blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
cdafa2433cad353cf58aa3eee49fe58ed38fc84d
Akash-Rokade/Python
/13-Jan/sub marks.py
192
3.859375
4
#Single line Comment '''Multiline comment''' a=int(input("Enter marks of 1 sub")) b=int(input("Enter marks of 2 sub")) c=int(input("Enter marks of 3 sub")) ans=(a+b+c)/3 print(ans)
3a59336b542ed4af262e0cbe508b0b3bba02e116
adityapatel329/python_works
/aditya-works-feature-python_programming (1)/aditya-works-feature-python_programming/26-Jul-2019/abstraction_examples/second_examples.py
281
3.9375
4
from abc import ABC,abstractmethod class Animal(ABC): @abstractmethod def eat(self): pass class Tiger(Animal): def eat(self): print("Eat non-veg") class Cow(Animal): def eat(self): print("Eat veg") t = Tiger() t.eat() c = Cow() c.eat()
78f04cf6f736ee814550e124ba23217308fc0c9e
tjkabambe/pythonBeginnerTutorial
/Graphs in Python.py
865
4.40625
4
# Import relevant modules import matplotlib.pyplot as plt # Plotting Graphs in Python # Basic plot # x = [2, 4, 7, 11, 16, 22] # plt.plot(x) # plt.show() # Shows the plot we are plotting # Plotting x and y against each other # y = [1, 3, 6, 10, 15, 21] # plt.plot(x, y) # plt.show() # Something nice # Line 1 - Points...
b21c15f75622931416011c55f6c102363b4b366b
Nikolov-A/SoftUni
/PythonBasics/Exam-Exercises/Exam Preparation/E_Football_souvenirs.py
1,967
3.84375
4
country = input() type_of_souvenirs = input() purchased_souvenirs = int(input()) price_for_souvenirs = 0 invalid_counter = False if country == "Argentina": if type_of_souvenirs == "flags": price_for_souvenirs = 3.25 elif type_of_souvenirs == "caps": price_for_souvenirs = 7.20 elif type_of...
6e17cbbf3606ee3163cbde84f2749cf01ea470d4
DamonZCR/PythonStu
/005/while学习2.py
529
4
4
print("---------第一个测试程序文件----------") temp = input("猜一下这个数字是几?") guess = int(temp) num = 3 # 输入 e 退出 三次比较 while guess != 8 and num != 1: temp = input("错误,猜一下这个数字是几?") guess = int(temp) if guess == 8: print("成功猜对,牛逼了!") print("猜对并没有什么奖励") else: if guess <8: print("小了"...
e5dc13fea9112f04f413a47733e614a6888a72c9
Luviriba/exercicios_python_11-17
/tarefa12.py
509
4
4
# 12. Faça um programa que leia a largura e a altura de uma parede em metros, calcule a sua área e a quantidade # de tinta necessária para pintá-la, sabendo que cada litro de tinta pinta uma área de 2 metros quadrados. largura = float(input("largura da parede: ")) altura = float(input("altura da parede: ")) area_...
d4d30885bedb870f7f1faa39382c5f9f1a7756aa
jb08/Dynamic_Programming
/6.1 Reading and weeping problem/reading_and_or.py
2,563
3.625
4
import numpy as np #given inputs m (array of free minutes by day) and t (array of minutes to read each section), #computes minimum unhappiness based on the formula in the given problem def min_unhappiness(m,t): D = len(m) n = len(t) memo = np.zeros((D+1,n+1)) m.insert(0,0) #insert 0 ...
3fbc1fb87d925a4c569c58f86cc65a98a34ab125
KehuM/TKH_Prework
/Assignment 1.py
159
3.625
4
AI = input("(AI) What is your name?") print("(User) My name is kehu " + AI) AI2 = input("(AI) shout out to you for always taking care of me") print(AI2)
636707da916fdee1ef6bda5efbe9f8d0414bc87b
error-hacker/Python-Games
/TicTacToe.py
4,241
3.765625
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 8 02:22:51 2019 @author: Sahilsarthak """ import random def drawBoard(board): print(board[7] + '|' + board[8] + '|' + board[9]) print('-+-+-') print(board[4] + '|' + board[5] + '|' + board[6]) print('-+-+-') print(board[1] + '|' + board[2] + '|...
e071d2bd3e5671b19b1f275d5219df1b76670f1f
caliuf/hacker_rank
/medium/encryption.py
1,047
3.6875
4
#!/bin/python3 # -*- coding: utf-8 -*- """ https://www.hackerrank.com/challenges/encryption/problem Time: 25m """ import math import os import random import re import sys # ===================================================================== # # Complete the encryption function below. def encryption(s): s = s.re...
0faaa6b28d685da417e3f1711f8bfef62592129f
bassmannate/py4e-old
/ex_11/ex_11_01.py
224
3.796875
4
import re fhand = open("../mbox.txt") count = 0 regex = input("Please enter a regular expression: ") for line in fhand: if re.search(regex, line): count += 1 print('mbox.txt had', count, 'lines that matched', regex)
02934761785fbced52879cb908df1da59219a435
Zahidsqldba07/CodingChalenges
/facebook/phone_screen/generate_parentles.py
739
3.75
4
# https://leetcode.com/problems/generate-parentheses/ def generate_parentheses(n): result = [] def generate(candidate, open, closed): if len(candidate) == n * 2: result.append(candidate) elif open == n: generate(candidate + ")", open, closed+1) elif open == closed...
25efe443cd46be579c0e4a22859f25970ad0f167
teacow2/Python_Crash_Course
/Chapter2_Strings.py3
842
4.21875
4
# Exercise 2-3 greetName = "Liza" print("Hi, " + greetName + "! Thanks for inviting me to the Python crash course!") # Exercise 2-4 myName = "niCk foRtuGno" print("Original Name: " + myName) print("In title case: " + myName.title()) print("In lower case: " + myName.lower()) print("In upper case: " + myName.upper()) ...
8890c110205542756071851bde9d98a793f20f2d
diegonavarrosanz1/1evaluacion
/ejercicio 2.py
276
3.796875
4
def cambiavocales(): texto= raw_input("dime una texto") for cont in range (0,len(texto),1): if texto[cont]=='a'or texto[cont]=='e'or texto[cont]=='i'or texto[cont]=='o': print 'u', else: print texto[cont], cambiavocales()
107b69b62fcc48e90857af01fcb18ac11c2a3160
isabella232/bootsteps
/bootsteps/steps.py
870
3.765625
4
"""Steps are objects which define how to run a step during initialization.""" import typing from collections import abc import attr @attr.s(auto_attribs=True, cmp=True) class Step(abc.Callable): """A step in the initialization process of the program.""" requires: typing.Set["Step"] = set() required_by: ...
77393262434aff02145bc3c630e5a80ffde8a44a
mgarcia86/python
/Zumbis/palindrome.py
219
3.96875
4
''' verificar se uma palavra é escrita da igual de traz pra frente ''' word = input('digite uma palavras: ') if word == word[::-1]: print('%s é palíndrome' %word) else: print('%s não é palíndrome' %word)
f1a909d9b221eba78be7b073d15ec065277ddabb
muskan123-sketch/python
/calculator.py
819
4.125
4
#design a calculator #add,substract,multiply,divide def Add(a,b): #to add two numbers c=a+b print(a,"+",b,"=",c) def Substract(a,b): #to substract two numbers c=a-b print(a,"-",b,"=",c) def Multiply(a,b): #to multiply numbers c=a*b print(a,"*",b,"=",c) def Divison(a,b):#...
aac2ec95a07e5508d18d8e5073cb2211173ed530
bhusalashish/DSA-1
/Data/Hashing/Find the triplet that sum to a given value/Sorting.py
647
4.09375
4
''' #### Name: Find the triplet that sum to a given value Link: [link]() #### Sub_question_name: Sorting Link: [link]() Sort and search **O(N^2) O(1)** ''' def find_triplets(nums, k): n = len(nums) nums.sort() numbers_set = set(nums) for i in range(n-2): left = i+1 right = n-1 ...
3c937f7d9da8a06d68bbe3f9de145fda40857199
thaismaiolino/HackerRank
/Mini-MaxSum.py
947
3.796875
4
# Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. # Input Format # A single line of five space-separated integers. # Const...
191120baa7539b82e201ba0d4a487a008401ed7d
SMKxx1/I.P.-Class-11
/Chapter 7/c 7.3.py
350
3.6875
4
List = [] while True: a = input("Enter a number or press 'q' to stop: ") if a != 'q' and a.isdigit(): List.append(eval(a)) elif a == 'q': break else: print("Invalid input") for i in List: if i > 10: List.insert(List.index(i),10) List.remove(i) else: ...
eca7f41f07ef2754369be197196f184b8dbc8a09
eugurlubaylar/Python
/33_PrimeSay.py
362
3.875
4
def isPrime(n): if n <= 1: return False else: for i in range(2, n): if n % i == 0: return False return True Say = 0 for i in range(1, 1000): if isPrime(i): print("{:>3}".format(str(i)), end= " ") Say += 1 if Say % 10 == 0: ...
f2488fefa7576f451864afcf55298fe8c2b79d99
chenyang929/grokking_algorithms
/02 选择排序/02_selection_sort.py
488
4.03125
4
def find_smallest(lst): smallest_index = 0 smallest_item = lst[0] for i in range(1, len(lst)): if smallest_item > lst[i]: smallest_item = lst[i] smallest_index = i return smallest_index def selection_sort(lst): new_lst = [] for i in range(len(lst)): smal...
574ab0746e71fd9ad6a6032cfd2d67f15e3fa6de
AdityanJo/Leetcode
/problem_0206_reverse_linked_list.py
528
3.9375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList(self, head: ListNode) -> ListNode: if head is None: return head prev = None curr = head nxt = head.ne...
4d91bcc2b4e634e32d6a5bc3a59b7c01b36268ea
Kindee99/BrunelCoursework
/Test1.py
1,066
4.28125
4
c = input("Enter today/'s date (dd/mm/yyyy)") if(c[2] =="/" and c[5]=="/"): c = c.split('/') day = int(c[0]) month = int(c[1]) year = int(c[2]) if(month >= 1 and month <= 13 and len(str(year)) == 4): if(month == 1): month = "Jan" elif(month == 2): mo...
642946cd448ffe6f42b51b11d6c7fb42c78b4b6f
incoging/python_study
/python/list_study.py
483
4.28125
4
# coding = utf-8 # lists = [[]] * 3 # print(lists) #[[], [], []] # lists[0].append(3) # print(lists) #[[3], [3], [3]] # array = [0, 0, 0] # matrix = [array] * 3 # matrix[0][1] = 1 # print(matrix) #[[0, 1, 0], [0, 1, 0], [0, 1, 0]] # #matrix = [array] * 3УֻǴ3ָarrayãһarrayı䣬matrix3listҲ֮ı䡣 lists = [[] for i in r...
874d6507c63a930d126172f80d55f1bff162227b
kartikarora1/python
/sortDictionary.py
291
4.15625
4
dict1 = {'gfg': [7, 6, 3], 'is': [2, 10, 3], 'best': [19, 4]} print("The original dictionary is : " + str(dict1)) res = dict1() for key in sorted(dict1): res[key] = sorted(dict1[key]) print("The sorted dictionary : " + str(res))
5738c4b7a679bdd0666d75c16740174f6f0c336e
enstulen/ITGK
/Øving 1/Oppgave 2.py
285
3.921875
4
__author__ = 'enstulen' import math radius = float(input("Hva er radiusen på kulen?")) overflaten = (4*radius*radius*math.pi) volumet = ((4*radius**3*math.pi)/3) print("Overflaten til kulen er", ("{:.2f}".format(overflaten))) print("Volumet til kulen er", ("{:.2f}".format(volumet)))
37d8e3543a98bd5015851b74122e3bde58a04678
mattjp/leetcode
/practice/medium/0039-Combination_Sum.py
568
3.546875
4
class Solution: def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: def search(nums: List[int], path: List[int]=[], cur: int=0): for i,num in enumerate(nums): if cur+num < target: search(nums[i:], path+[num], cur+num) # reduce search space so we don't look bac...
afad673a6d1c7af1b548caffecc3115e4c39dc79
azhartalha/Algorithms-and-Data-Structures
/codeVita/minDistance.py
570
3.5625
4
def mindistance(fileStream, firstWord, secondWord): fl, sl = len(firstWord), len(secondWord) for i in range(len(fileStream)-(fl+sl)+1): for j in range(len(fileStream)-i-(fl + sl)+1): if (fileStream[j:j+fl] == firstWord and fileStream[j + i + fl: j + i + fl + sl] == secondWord) or ( ...
fdce5959d2c73ddf0f348deea3297c460edfbdac
sandymnascimento/Curso-de-Python
/Aula 08/ex017.py
231
3.75
4
from math import hypot a = float(input('Digite o cateto oposto: ')) b = float(input('Digite o cateto adjacente: ')) print('Um triângulo com lados medindo {} e {} tem uma hipotenusa que vale é {:.2f}.' .format(a, b, hypot(a,b)))
ac8ffd7ac13572ae584c495f1a6b74cdff19e756
the0therguy/CSE365
/bfs.py
1,017
3.71875
4
from queue import Queue def bfs(graph, start, goal): visited = {} level = {} parent = {} bfs_traversal_output = [] queue = Queue() for node in graph.keys(): visited[node] = False parent[node] = None level[node] = -1 s = start visited[s] = True level[s] = 0...
1ca10c0e1a2e010dcd9d3bd2f96acb6dba99b3f9
chrysmur/Python-DS-and-Algorithms
/implementing_queues_with_stacks.py
1,174
4.0625
4
#Creating Queue using Stack #create a stack with lists #create a queue class Stack: def __init__(self): self.last = None self.first = None self.arrayStack = [] self.length = 0 def push(self, value): self.arrayStack.append(value) self.last = self.arrayStack[0] ...
8a2b85abee535aaf1857b1755d12ee28aa136881
aidansoffe/Python-Data-Structures-Practice
/33_sum_range/sum_range.py
157
3.578125
4
def sum_range(nums, start=0, end=None): if end is None: end = len(nums) return sum(nums[start:end + 1]) print(sum_range([1,2 ,3,4], end=2))
26c618e941487a75de398b6ce1b8da76ac385902
jasch-shah/python_codes
/oop_python.py
672
3.6875
4
class Vehicle: def __init__(self,number_of_wheels,type_of_tank,seating_capacity,max_velocity): self.number_of_wheels = number_of_wheels self.type_of_tank = type_of_tank self.seating_capacity = seating_capacity self.max_velocity = max_velocity @property def number_of_wheels(self): return self.number_of_w...
29470502ab482f3608d62dca1ff4e788ea102034
srinath2000/-python
/sum.py
116
3.640625
4
#sum of first n numbers: n=input("Enter the limit :") sum=0 for i in range(0,n+1,1): sum=sum+i print sum
3fd15d9849b2f572958a8e37d1c73a32aad3c009
souzajunior/URI
/uri - 1257.py
699
3.59375
4
lista_alfabeto = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] casos_testes = int(input()) for caso in range(casos_testes): qntd_linhas = int(input()) total = 0 for linha in range(qntd_linhas): entrada = ...
7160e3fff9972593fd64adf8699d9d767e0a13bd
ALMTC/Logica-de-programacao
/TD/17.py
166
3.703125
4
print 'Digite o valor de A' A1 = input() print 'Digite i=o valor de B' B1 = input() A = B1 B = A1 print 'Valor de A: ' + str(A) print 'Valor de B: ' + str(B)
9d11935cb86caa51085141079cc7699569599592
kloyt/pythonparser
/texter/termocolor.py
692
3.625
4
# -*- coding: cp1251 -*- colors = { 1: "\x1b[01;30m",#����� 2: "\x1b[01;31m",#���������� 3: "\x1b[01;32m",#������� "yellow": "\x1b[01;33m",#������ "blue": "\x1b[01;34m",#����� "magenta": "\x1b[01;35m", "cyan": "\x1b[01;36m", "white": "\x1b[01;37m",#����� "red": "\x1b[01;38...
cda21b5fb1bc788d0dcde16d546c6f11415ebe27
smswajan/mis-210
/Chapter-2-3-4/2.20-Calculate-Interest.py
169
3.875
4
balance, annualIntRate = eval(input("Enter balance and interest rate (e.g. 3 for 3%): ")) interest = balance *(annualIntRate/1200) print("The interest is", interest)
1a07ba3f6e5a721f7e3e9baca545be319ad8a939
andy1747369004/study
/tree.py
813
3.921875
4
from turtle import Turtle ,mainloop from time import clock import turtle def tree(plist,l,a,f): if l>3: lst=[] for p in plist: p.forward(l) q=p.clone() p.left(a) q.right(a) lst.append(p) lst.append(q) for x in tree(lst,...
4cc504de4af7cc1b178b1d1ded1b3e6e0afd1282
zeelib1/cs50
/pset6/readability/readability.py
1,402
3.9375
4
# Program that computes the approximate grade # level needed to comprehend some text # in accordance with the Coleman-Liau Index # translated from C version from cs50 import get_string import string def main(): # Prompting user for a text input text = input("Text: ") # Return values as variables pass...
ac6983aafe21e34e00cc486298c248434b8f4b1c
joetechem/python_tricks
/lambda/function_expressions.py
638
4.28125
4
# To see the output, run the following in the Interpreter # Lambdas ar Function Expressions: (lambda x, y: x + y)(5, 3) # returns 8 # In Python the lambda keyword acts a shortcut for declaring small # anonymous functions: add = lambda x, y: x + y add(5, 3) # check out the output on this one: print add # Now in func...
9550945a5cea602f0347c73444d7bb9bbc520bf8
alexandraback/datacollection
/solutions_5631989306621952_1/Python/CalTroll/A.py
278
3.734375
4
def solve(word): new_word = word[0] for char in word[1:]: if new_word[0] > char: new_word = new_word + char else: new_word = char + new_word return new_word T = input() for i in range(T): word = raw_input() print 'Case #' + str(i + 1) + ': ' + str(solve(word))
5a1d17f09066dd23a2d19624b7649488eb1a0719
webfanrc/Project1-Movie-Trailer-Website
/drawing.py
345
3.6875
4
import turtle def draw_square(): window = turtle.Screen() window.bgcolor("pink") brad = turtle.Turtle() #int brad.forwad(100) brad.right(90) brad.forwad(100) brad.right(90) brad.forwad(100) brad.right(90) brad.forwad(100) brad.right(90) window.exitonc...
c35f712d78e86557dba95c86c9241bf84ae05e85
pgriger/ID3sort
/ID3sort v0.2/example_window.py
2,252
3.84375
4
import tkinter as tk import tkinter.ttk as ttk class Example: def __init__(self): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' ...
c228e8fdb72b0294e3edcd9320736daa91afd01b
zeeshanhanif/ssuet-python
/23April2017/DemoObjects/Objects15.py
475
3.734375
4
class Human(): def __init__(self,name,age): self.name = name; self.age = age; def sleep(self): print("Human is sleeping") class Student(Human): def __init__(self): super().__init__("hello",45) print("Hello in student init") def study(self): print("Hel...
49ac5d64c8eca14be65b97b334d5cc15722e6d0a
KilianB95/Hello-You
/Textbased Game/Textbasedgame.py
24,468
4.09375
4
# Instructions Textbased game your choice will make the story. You have different choices in directions input() # First prologue a little story about the attack of Japan in Indonesia. # There will be choices made of how the game will start after the prologue. # You play as a person who works for the Sultan of Borneo(Ka...
81b8f7739a74200c11ec390ad01203c1b2eb2734
DaLiteralPanda/Python
/Rishov/Advanced_Python_Meetup/comprehensions.py
1,635
3.96875
4
# Comprehensions ## Clean and consise code ## Fast and Efficient Performance ## Applies to list, dicts, sets, and generators exprensions nums = [1, 2, 3] for i in nums: print(i) i def num_print(num_list): for i in num_list: print(i) # Restart now i #error # List comprehension ## What if we wanted...
57632c2a34616c41a683122cee51ed8dfac513e4
jakesjacob/FDM-Training-3
/Exercises/8_user_info.py
787
4.1875
4
# get full name # get dob # return users age # say users age on next birthday from datetime import datetime def getName(): firstName = input("Please type your first name: ") secondName = input("Please type your second name: ") firstNameCap = firstName.capitalize() secondNameCap = secondName.capitali...
dae629b36627883f84348bc6d51e315a77b3f264
we-are-peaky-blinders/Speech-Reco-Demo
/app.py
804
3.59375
4
import time import speech_recognition as sr # this is called from the background thread def callback(recognizer, audio): # received audio data, now we'll recognize it using Google Speech Recognition try: print("Google Speech Recognition thinks you said " + recognizer.recognize_google(audio)) exce...
ffc0d87316686b50dcbb5baa18bfc56c4b541e31
benfrisbie/python-puzzles
/sum-unique-pairs/sum-unique-pairs.py
1,019
3.984375
4
import unittest def sum_unique_pairs(nums, target): needed_nums = set() pairs = set() pair_count = 0 for n in nums: diff = target - n if n in needed_nums and n not in pairs: pair_count += 1 pairs.add(n) pairs.add(diff) needed_nums.a...
bff26c7b3aa14324fc0ddad1b5945513414adfb9
fransiscuscandra/Python
/OOP_Instance.py
781
4
4
class Employee: def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@company.com' def fullname(self): return '{} {}'.format(self.first, self.last ) emp_1 = Employee( 'Corey' , 'Schafer' , 50 ...
1e7d8d08fdd541fd3ff090337976b9f94ced0d55
saberly/qiyuezaixian
/收集参数.py
1,140
3.546875
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 27 20:34:42 2017 @author: ice-fire 收集参数有两种打包的方式:一种是以元组的形式打包,另一种则是以字典的形式打包 """ #============================================================================== # #以元组的形式打包 # def test(*params): # print("有 %d 个参数" %len(params)) # print("第二个参数是:",params[1]...
b760355c5fad839e3958045b3abdaeaad2cd5d0c
IlliaRodionov/MyProject
/hw/hw12.07/hwstadion.py
1,040
3.796875
4
class Stadium: def __init__(self, name, opening_date, country, city, central_part, left_side, right_side): self.name = name self.opening_date = opening_date self.country = country self.city = city self.left_side = left_side self.right_side = right_sid...
e1b1cb7a4d7383d0a24b3a39d9ef4e4dc44604f5
johanwahyudi/Cryptography
/Modern/RC4.py
724
3.546875
4
##!/usr/bin/env python """"Johan Wahyudi"""" def rc4(data, key,): x = 0 box = range(256) for i in range(256): x = (x + box[i] + ord(key[i % len(key)])) % 256 box[i], box[x] = box[x], box[i] x = y = 0 out = [] for char in data: x = (x + 1) % 256 y = (y + box[x]) %...
a6272babaaa3cc1d1a506c3a78f2688904533e8d
sandramkimball/Algorithms
/making_change/making_change.py
922
3.984375
4
#!/usr/bin/python import sys # Example: `making_change(10)` should return 4, since there are 4 ways to make # change for 10 cents using pennies, nickels, dimes, quarters, and half-dollars: # 1. We can make change for 10 cents using 10 pennies # 2. We can use 5 pennies and a nickel # 3. We can use 2 nickels # 4. W...
b5f057993b6015f673b752963d9d40d2b1412c12
chamon562/jupyter
/.ipynb_checkpoints/jupyter_reverse.py
314
4.4375
4
#!/usr/bin/env python # coding: utf-8 # In[8]: # Python offers several ways to reverse a String. This is a classic thing # that lots of people want to do. # In[9]: my_str = input('Enter a string: ') # In[10]: temp = '' # In[11]: for char in my_str: temp = char + temp print(temp) # In[ ]:
a35433fdfd706ac98f6aea5f8d1be1a01a2edba0
mike-jolliffe/Learning
/Checkio/days_between_dates.py
468
4.25
4
from datetime import date def days_diff(date1, date2): '''give two tuples in the form (yyyy, m, d) representing start and end dates, calculates total days between the two dates''' #unpack each tuple into an int and feed into date as arg d0 = date(date1[0], date1[1], date1[2]) d1 = date(date2[0]...
52c05728b1145947f1cd2cd18cfaf48221150663
AyushiSrivastava20/Python-Practice
/Dictionary1.py
387
3.734375
4
fname = raw_input("Enter file name: ") fh = open(fname) text= fh.read() words=text.split() counts=dict() for word in words: counts[word]=counts.get(word,0)+1 print counts.items() bigcount=None bigword=None for word,count in counts.items(): if bigcount is None or count>bigcount: bigword=word b...
cd1f647d632bde3e4c0076ea66b40669f066355c
KhudadadKhawari/sjjad-s-Homework
/c.py
171
3.65625
4
with open('file.txt') as file: data = file.read() names = data.split('\n') total_length = 0 for name in names: total_length += int(len(name)) print(total_length)
50aaf184bea637a61f6ff62ece3d13e555470505
himmat-singh/Python
/fib.py
284
3.84375
4
def fib(n): #define Fibonacci series upto n """Print a Fibonacci series upto n""" a,b=0,1 while a<n: '''if(b<n): print(a,end=', ') else: print(a,end=' ') ''' print(a) a,b=b,a+b #Now call the Fibonacci function defined above fib(1000)
b36a534f8069bc3c6615920a45040a18365dd393
Vonewman/introduction_to_algorithm
/quick_sort/quick_sort_python/quick_sort.py
279
3.53125
4
from sys import stdin def swap(A, i, j): A[i], A[j] = A[j], A[j] def partition(A, p, r): assert p < r def quick_sort(A, p, r): if p < r: q = partition(A, p, r): quick_sort(A, p, q-1) quick_sort(A, q+1, r) if __name__ == '__main__':
4bd3c235e96f10cb6e617caa93af24437815ec3a
KremenaVasileva/HackBG
/Week 1/Friday/goldbach.py
312
3.71875
4
def is_prime(n): divisors_sum = sum([x for x in range(1, n + 1) if n % x == 0]) return n + 1 == divisors_sum def goldbach(n): result = [] for i in range(1, n // 2 + 1): if is_prime(i) and is_prime(n - i): result.append((i, n - i), ) return result print (goldbach(100))
7cec97858af50cb1ba925244c23a26573284c90b
Dexterous-Devu/Find-distance-between-2-coordinates
/Distance.py
311
3.546875
4
__author__ : "@rockdevu" import numpy as np def distance_bet_2(A, B): result = np.sum([abs(a - b) for (a, b) in zip(A, B)]) return result if __name__ == "__main__": arr1 = [1, 2, 13, 5] arr2 = [1, 27, 3, 4] result = distance_bet_2(arr1, arr2) print("The distance between 2-coordinates is :", result)
73aa737a43ee7bc6c8f4f14efd5fb08e9ef4b846
Dmitry-White/CodeWars
/Python/7kyu/two_to_one.py
323
3.671875
4
""" Created on Sat Aug 05 23:58:21 2017 @author: Dmitry White """ # TODO: Take 2 strings s1 and s2 including only letters from a to z. # Return a new sorted string, the longest possible, containing distinct letters, # each taken only once - coming from s1 or s2. def longest(a1, a2): return "".join(sorted(set(a...
3af95328cb80cf479c8cc6de55ad3b5e4f9f3bdf
greenfox-zerda-lasers/h-attila
/week-03/day-3/search_palindrome.py
1,561
4
4
# output = search_palindromes('dog goat dad duck doodle never') # print(output) # it prints: ['og go', ' dad ', 'd d', 'dood', 'eve'] def search_palindromes(text): range = 1 akt_pos = 1 new_palindrome = '' palindrome = [] while akt_pos < len(text) - 1: found = True while found: ...
560cfacd8b70d5ebd65fdc7cff0471cd14b50259
Tokyo113/leetcode_python
/中级班/chapter02/code_04_numToString.py
1,312
3.734375
4
#coding:utf-8 ''' @Time: 2020/2/9 18:08 @author: Tokyo @file: code_04_numToString.py @desc: 将给定的数转换为字符串,原则如下:1对应 a,2对应b,…..26对应z,例如12258 可以转换为"abbeh", "aveh", "abyh", "lbeh" and "lyh",个数为5,编写一个函 数,给出可以转换的不同字符串的个数 ''' def convertString(str): if str == '' or str is None: return 0 return process(str, 0) ...
e4be0551587cabce2c8b49916ff4e01ae5c594a5
jim0409/PythonLearning-DataStructureLearning
/BasicLangLearning/package_tutorial/while_GCD/PythonWhile_EX.py
176
4.03125
4
print ('Enter two numbers...') m = int(input('Number 1: ')) n = int(input('Number 2: ')) while n != 0: r = m % n m = n n = r print ('GCD: {0}'.format(m))
36838a04e1d10b444378ad22821559bdc83655fe
furutuki/LeetCodeSolution
/0139. Word Break/Solution_dp.py
526
3.625
4
from typing import List class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: "f[i] means subarray(0, i) can represented by word of wordDict" f = [False for i in range(len(s) + 1)] f[0] = True for i in range(1, len(s) + 1): for j in range(i): ...
fb42bd16d5840354a8ce824779dfca7e3179f018
dubugun/big_data_web
/python/0131/0131_10_3.py
489
3.71875
4
score1 = int(input('숫자를 입력하세요.')) if score1 > 10 : if score1 % 2 == 0: print("입력한 숫자 %d 는 10보다 큰 짝수 입니다." % score1) else : print("입력한 숫자 %d 는 10보다 큰 홀수 입니다." % score1) else : if score1 % 2 == 0: print("입력한 숫자 %d 는 10보다 크지않은 짝수 입니다." % score1) else : print("입력한 숫자 %d 는 ...
8aeb1bcc84fcb4457f2a8805ba621bfbd6e9ae99
asuurkivi/Programmeerimine
/2013-11-28-01.py
313
3.53125
4
while True: t2ht = raw_input('Sisesta t2ht:') if len(t2ht) == 1: break print 'Palun sisesta ainult 1 t2ht' guessInLower = t2ht.lower() if "j" in t2ht: print "vasak" elif "k" in t2ht: print "all" elif "l" in t2ht: print "parem" elif "i" in t2ht: print "yleval" else: print "Tundmatu t2ht"
6a88efb4a656dfda208f49f561d287175734e755
erinnlebaron3/python
/FilesinPy.py/Create&WriteFile.py
1,659
4.625
5
# very common use case for working with the files system is to log values # gonna see how we can create a file, and then add it to it. # create a variable here where I'm going to open up a file. # I'm going to show you here in the console that if I type ls, you can see we do not have a file called logger. # functi...
d2caec73c703df6fef383adf59efeaf3d3788801
AidanMariglia/2XB3
/Lab_04/sorts.py
2,401
4.09375
4
#bottom up mergesort adapted from sedgewick wayne def mergesort_bottom(L): n = len(L) length = 1 while(length < n): low = 0 while(low < n - length): merge_bottom(L, low, low + length - 1, \ min(low + 2 * length - 1, n - 1)) low += 2*length length...
c302c2185819e853291dae507edd139120bc24de
Jaydeep386/python
/account_manage.py
1,812
3.859375
4
import datetime import pytz class Account: """ Simple account class with balance """ @staticmethod def _current_time(): utc_time = datetime.datetime.utcnow() return pytz.utc.localize(utc_time) def __init__(self, name, balance): self.name = name self.balance = balance ...
cb0450ba853f369c128f8859e24194d50cc21d96
earth418/PyGameEngine
/Math/vector.py
1,480
4.1875
4
from math import sqrt, sin, floor, atan class Vec2: X : float Y : float def __init__(self, x, y): ''' A 2-dimensional, cartesian representation of a Vector. ''' self.X = x self.Y = y def __mul__(self, value): if isinstance(value, Vec2): ...
3693d24e150a5f931abb2f1ea060a9ae10025e3e
PoulaAdel/python-crash-course-solutions
/ch8/8.1.py
274
3.796875
4
def display_message(learned_object): print("I've learned %s"%str(learned_object)) stop_flag = True while stop_flag: sub=input("What you've learned today?(enter 'q' to stop): ") if sub.lower()=='q': stop_flag=False else: display_message(sub)
8f64c97d6daec3eca9b20282c0507118dfe51e62
harsohailB/three-card-poker-judger
/game/player.py
4,051
3.875
4
from collections import Counter from hand import Hand class Player: """ A class to represent a player in the game Attributes ---------- id : int ID of a player cards : list[Card] Cards that the player holds hand : Hand Type of hand the player is holding (straight, f...
9975c10f49fa96f947b1676882e9209247e43da8
duy2001x1/nguyenquangduy-fundamentals-c4e14
/session4/homework/srs_ex4.py
263
4.125
4
initial_num = int(input("How many B bacterias are there? ")) time_mins = int(input("How much time in minutes will we wait? ")) total_num = initial_num * 2 ** (time_mins // 2) print("After {0} minutes, we would have {1} bacterias.".format(time_mins, total_num))
f0908b424887974375c89d28c9b20fadd10b0617
Akanksha-Verma31/Python-Programs
/Last char of string.py
223
4.3125
4
# to get the last letter of the string fruit = "banana" length = len(fruit) last = fruit[length-1] print("Last character: ",last) print(fruit[-1]) # yields last character print(fruit[-2]) # yields second last character
0e3ea8af5d0f77e25f2121eb8744dde669a6ae05
graphoarty/python-tutorial
/Chapters/8. GUI Programming.py
220
3.515625
4
''' https://www.tutorialspoint.com/python/python_gui_programming.htm The simplest GUI program in Python Event-driven programming Changing the layout Getting input from the user GUI Examples Designing a GUI '''
724e2c1fd82c70144b2185766431f8e52df70a4c
ullashjain004/StatscalUS
/Tests/test_Calculator.py
1,944
3.53125
4
import unittest from Calculator.Calculator import Calculator from CsvReader.CsvReader import CsvReader class MyTestCase(unittest.TestCase): def setUp(self) -> None: self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) ...
a0a2731553cbaf630e8bb50d19841be8bf1d1074
andrewgait/advent_of_code
/adventofcode2017/advent1/advent1.py
715
3.5625
4
# Advent of code, day 1 # open file input = open("advent1_input.txt", "r") #input = open("advent1_test_input1.txt", "r") #input = open("advent1_test_input2.txt", "r") #input = open("advent1_test_input3.txt", "r") #input = open("advent1_test_input4.txt", "r") # read string into array for line in input: data = line...
c481a2f03c177e9deb402ad7130f2914282c58ad
bluephlavio/basi-di-programmazione-2018
/square.py
353
3.90625
4
# Calcola il quadrato di un numero intero while True: try: n = int(input('Inserisci un numero intero: ')) break except ValueError: print('ERRORE: non sono riuscito ad interpretare il valore inserito come un numero intero.') continue print(f'Il quadrato di {n} è {n**2}.') input(...
0cfc28ec2a284eecf1c4aba1f1a2066c71d61f8a
jochigt87/PythonCrashCourse
/Chapter5/5-4.py
794
4.34375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Alien Colors #2: # Choose a color for an alien as you did in Exercise 5-3, and write an if-else # chain. # *If the alien's is green, print a statement that the player just earned 5 # points for shooting the alien. #*If the alien's color isn't green, print a statement t...
37ed9e181054353e59cf000897194dc497d70888
krsthg/python3
/COS PRO_2/6차시/문제 1.py
624
3.578125
4
def solution(temperature, A, B): answer = 0 #for i in range(0, len(temperature)): for i in range(A+1, B): #A부터 B사이의 수를 i에 하나씩 대입 if temperature[i] > temperature[A] and temperature[i] > temperature[B]: #i가 A보다 크고 i가 B보다 크면 answer += 1 return answer temper...
fafc299fb91ec0c6aed200fb838c9a48bca60baf
ElliotJH/adventofcode
/src/test_bathroom.py
1,462
4.5
4
# The document goes on to explain that each button to be pressed can # be found by starting on the previous button and moving to adjacent # buttons on the keypad: U moves up, D moves down, L moves left, and R # moves right. Each line of instructions corresponds to one button, # starting at the previous button (or, for ...
151380da95da9dce21a8a5f973530efba6e895b9
Crypto-Dimo/workbook_ex
/chapter_three/ex_82.py
212
4.21875
4
decimal = int(input('Enter the decimal number: ')) q = decimal result = '' while q != 0: r = q % 2 result = str(r) + result q = q // 2 print(f'The binary corresponding to {decimal} is: {result}.')
93f0ed6221bfe4276a1947d9db8cafe80bf59203
brettaking/Python
/ClassAverage.py
1,045
3.984375
4
#Class Average for Three Sample Students Lloyd = { "name":"Lloyd", "homework": [90,97,75,92], "quizzes": [ 88,40,94], "tests": [ 75,90] } Alice = { "name":"Alice", "homework": [100,92,98,100], "quizzes": [82,83,91], "tests": [89,97] } Tyler = { "name":"Tyler", "homework"...
7b14685ab9044a73a838c874ce08b67695ee0dd4
tpt5cu/python-tutorial
/language/python_27/class_/old_style_classes.py
2,921
3.65625
4
# https://realpython.com/python-metaclasses/ - class and type are different # https://stackoverflow.com/questions/4162578/python-terminology-class-vs-type - link to official PEP and great summary # https://www.python.org/download/releases/2.2.3/descrintro/ - the official PEP # https://stackoverflow.com/questions/54867/...
b76814421e025249d1015f088ccc0e9575ce157b
gdhaison/test_python_litextension
/algorythm/x_to_y.py
373
3.75
4
def x_to_y(x, y): count = 0 while x != y: ytemp = y while (x < ytemp): ytemp = ytemp / 2 if x < ytemp + 1: f_x = x x = x * 2 print(f"{f_x}*2 = {x}") else: f_x = x x = x - 1 print(f"{f_x}-1 = {x}")...
d694f876203e9af856350a9db1054ed82fd738c4
RogersEpstein/generatingmatrices
/matrices.py
5,437
3.765625
4
""" Computes random matrices of dimension n. Computes the least degree d of monomials needed to get n^2 linearly independent matrices if it exists. Computes the value of g(i) = dim V_i = dim V_{i-1} """ import numpy import random import math n = 3 # Returns a random nxn matrix def rand_generate(n, p = None): if ...
c995dfa15cabb7499e8c018e4c160f1505310dcf
nervaishere/DashTeam
/python/5th_session/6def_min-max.py
435
4
4
listA = [18, 19, 21, 22] print('The smallest number from listA is:',min(listA)) print('The largest number from listA is:',max(listA)) strA = 'AppDividend' print('The smallest character from strA is:', min(strA)) print('The largest character from strA is:', max(strA)) strA = 'AppDividend' strB = 'Facebook' strC = 'Ama...
c9872bd8ffc3bfd22676dca225344cfb363e4962
Jcannon4/Python_Samples
/ErrorHandling.py
1,197
4.03125
4
try: f = open('testfile','r') #change to 'w' to avoid error f.write('Write a test line') except TypeError: print('There was a type Error!') except OSError: print('Hey you have an OS Error') except: print('All other exceptions!') finally: print('I always run') def ask_for_int(): while Tru...
bdf4f576aceba31d7d274c2ec7efd61e1f4a337c
eric496/leetcode.py
/bfs/127.word_ladder.py
1,705
4.03125
4
""" Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that: Only one letter can be changed at a time. Each transformed word must exist in the word list. Note that beginWord is not a transformed word. Note: Return 0...
c66cffbf119d2e136d41402cc153847761ca5aea
nicolasgonzalez98/Ejercicios-Python-de-Informatica-UBA-
/TP 4/EJ4.py
219
3.96875
4
print("el texto debe ser hasta de 100 caracteres.") texto1=input("Ingrese un texto: ") while len(texto1)>100: print("Ingrese de nuevo.") texto1=input("Ingrese un texto: ") texto1=texto1.upper() print(texto1)
8987a97fcf45d00bd7feda52ea17fbb75da42008
PROFX8008/Python-for-Geeks
/Chapter06/comprehension/list1.py
155
3.96875
4
#list1.py list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] list2 = [x+1 for x in list1] print(list2) list3 = [] for x in list1: list3.append(x+1) print(list3)
49c688c0654460b271942b48c92c869fecb7e8d5
LiamSarwas/Advent-of-Code
/2021/day1.py
744
3.59375
4
import itertools import math from pathlib import Path FILE_DIR = Path(__file__).parent def part_one(input_data): last = input_data[0] increases = 0 for depth in input_data[1:]: if depth > last: increases += 1 last = depth return increases def part_two(input_data): inc...
7d5b356b9ed7f2ede1d05edf6ae7dcb262e91eb6
deepbsd/OST_Python
/ostPython2/floatsum.py
1,576
4.1875
4
#!/usr/bin/env python3 # # floatsum.py # # for OST: Lesson 7: Intro to GUIs # # by David Jackson on Feb 9 2015 # # Instructor: Pat Barton # # """ This program is a simple GUI with two Entry fields, a button, and a label. When the button is clicked, the value from each Entry field be converted i...
5e5f5644eeca83684b96b79a8bb9f75a707bcf3f
casparjespersen/adventofcode2020
/tasks/day9/part2.py
776
3.578125
4
import numpy as np from part1 import input_numbers, find_weaknesses def rolling_window(a, window): shape = a.shape[:-1] + (a.shape[-1] - window + 1, window) strides = a.strides + (a.strides[-1],) return np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides) def find_encryption_weakness(numbers...
7f0ee1c9e1b2bf50e9f08ab6f190eaaaf819e96a
PTZX/Functions
/Spot Check/Fn Spotcheck q3 - Cost of Fuel .py
759
4.21875
4
print("This Program:") print("Calculates the fuel cost of your next journey") #get values from user def getValues(): distance = input("Journey distance (in Miles): ") distance = float(distance) Mpg = input("Miles Per Gallon: ") Mpg = float(Mpg) p = input("Price of Petrol (In Pence): ") ...