blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
67c56866ae607159c5d91fa33153b58dee44440b
wcphkust/sling
/python/tree_traversal_inorder.py
894
3.6875
4
import random import pprint class node: def __init__(self, key = 0, left = None, right = None): self.key = key self.left = left self.right = right def inorder(x, n): if x is None: return n else: n1 = inorder(x.left, n) x.key = n1 n2 = n1 + 1 n3 = inroder(x.right,...
77ba68fad7d5e790611d61f47a570b6fa98fb2c2
wcphkust/sling
/python/sorted_insert_iter.py
978
3.65625
4
import random import pprint def ret_heap(m): for c in m: ret_cell(c) def ret_cell(c): while c is not None: print hex(id(c)) + ' ' + pprint.pformat(vars(c)) c = c.next class node: def __init__(self, key = None, next = None): self.key = key self.next = next def insert_iter(x, k)...
530075ed989fcf34df154720d0477c4044e034a0
wcphkust/sling
/python/circular_insert_back.py
997
3.59375
4
import random import pprint def ret_heap(m): for c in m: ret_cell(c) def ret_cell(c): while c is not None: print hex(id(c)) + ' ' + pprint.pformat(vars(c)) c = c.next class node: def __init__(self, key = 0, next = None): self.key = key self.next = next def create_list(size): h...
070231f820697975cab6adee16b75ca72f87d500
shandamonke/Project-Euler-Solutions
/problem9.py
320
3.671875
4
import math for a in range(1,1001): for b in range(1, 1001): if a + b + math.sqrt(a ** 2 + b ** 2) == 1000: print('a = ' + str(a) + 'b = ' + str(b)) c = math.sqrt(a ** 2 + b ** 2) print(math.sqrt(a ** 2 + b ** 2)) print('answer = ' + str(a * b * c))
8e880e707ce62c8f0a8c1d90f2b3dc2c67730565
lukasrieger-dev/CADCostCalculator
/calculator/dxfutils.py
7,329
3.671875
4
import math import ezdxf import logging __author__ = 'lukas' # dxf constants DXF_TYPE_LWPOLYLINE = 'LWPOLYLINE' DXF_TYPE_CIRCLE = 'CIRCLE' DXF_TYPE_TEXT = 'TEXT' DXF_TYPE_MTEXT = 'MTEXT' DXF_TYPE_LINE = 'LINE' DXF_TYPE_ARC = 'ARC' DXF_TYPE_INSERT = 'INSERT' def distance_2d(p1, p2): x1, y1 = p1 x2, y2 = p2 ...
6784d650612574c41665f81d47fff4598bf3b7aa
Revel109/Uri-Problems-Solution-10-20-
/prob-15.py
202
3.609375
4
import math a=input().split(" ") b=input().split(" ") x1,y1=a x2,y2=b z=math.sqrt(((float(x2) - float(x1))*(float(x2) - float(x1))) + ((float(y2)-float(y1)) *(float(y2)-float(y1)))) print('%.4lf'%z)
d14cfcde4dadc3e4e509fa8a57ec6d2822eb4fb4
ashutoshkrjha/Daily_Code_Challenge
/Karumanchi_Algos/Ch2/bitnstrings.py
465
3.953125
4
def bitstring(num_bits, global_arr): if (num_bits == 0): print(global_arr) else: global_arr[num_bits - 1] = 0 bitstring(num_bits - 1, global_arr) global_arr[num_bits - 1] = 1 bitstring(num_bits - 1, global_arr) def main(): num_bits = input("Give me the number of bit...
a17e198eeaac4a06b472845f6dffdd2bcf1f74c3
damsonli/mitx6.00.1x
/Mid_Term/problem7.py
2,190
4.4375
4
''' Write a function called score that meets the specifications below. def score(word, f): """ word, a string of length > 1 of alphabetical characters (upper and lowercase) f, a function that takes in two int arguments and returns an int Returns the score of word as defined by t...
622b10cab635fa09528ffdeab353bfd42e69bdc7
damsonli/mitx6.00.1x
/Final Exam/problem7.py
2,105
4.46875
4
""" Implement the class myDict with the methods below, which will represent a dictionary without using a dictionary object. The methods you implement below should have the same behavior as a dict object, including raising appropriate exceptions. Your code does not have to be efficient. Any code that uses a Python di...
de17bb8bd8f94f087845cd59e2ad83f7b43f8ebd
Nicolanz/holbertonschool-web_back_end
/0x00-python_variable_annotations/3-to_str.py
269
4.21875
4
#!/usr/bin/env python3 """Module to return str repr of floats""" def to_str(n: float) -> str: """Function to get the string representation of floats Args: n (float): [float number] Returns: str: [str repr of n] """ return str(n)
180368ef6cef54de3e94387eddd54ff39a41e4c4
Nicolanz/holbertonschool-web_back_end
/0x04-pagination/0-simple_helper_function.py
460
3.890625
4
#!/usr/bin/env python3 """Module containing index_range function""" from typing import Tuple def index_range(page: int, page_size: int) -> Tuple[int, int]: """Index range function Args: page (int): [Number of page] page_size (int): [Number of page size] Returns: Tuple[int, int]...
a124cd5fc15e3058c03414c35fb9a9df61ff98f6
Nicolanz/holbertonschool-web_back_end
/0x01-python_async_function/2-measure_runtime.py
559
3.640625
4
#!/usr/bin/env python3 """Module to create a measure_time function with integers n and max_delay""" import time import asyncio wait_n = __import__('1-concurrent_coroutines').wait_n def measure_time(n: int, max_delay: int) -> float: """Function o measure time Args: n (int): [number of items] ...
94c63cf09da1e944b67ca243ee40f67ad3550cf5
Nicolanz/holbertonschool-web_back_end
/0x00-python_variable_annotations/9-element_length.py
435
4.28125
4
#!/usr/bin/env python3 """Module with correct annotation""" from typing import Iterable, Sequence, List, Tuple def element_length(lst: Iterable[Sequence]) -> List[Tuple[Sequence, int]]: """Calculates the length of the tuples inside a list Args: lst (Sequence[Iterable]): [List] Returns: ...
522c24738fc362ea620859d392eab2a3bd63dcc3
Feldron21/Flappy-Bird-Bot
/learning.py
4,299
3.5
4
import json from json import JSONDecodeError import random class Learning: def __init__(self): # Initialize the agent self.previous_state = "0_0_0_0" self.previous_action = 0 self.discount_factor = 0.9 self.learning_rate = 0.8 self.reward = {0: -1, 1: -100} ...
aedfe44fe94a31da053f830a56ad5842c77b4610
jesseklein406/data-structures
/simple_graph.py
2,747
4.28125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """A data structure for a simple graph using the model from Martin BroadHurst http://www.martinbroadhurst.com/graph-data-structures.html """ class Node(object): """A Node class for use in a simple graph""" def __init__(self, name, value): """Make a new nod...
b90c20842ac3410291253377a8f2026c1330e9f2
jesseklein406/data-structures
/merge.py
4,506
4.28125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals def merge_sort(lst): """ Sort a list of values using merge sort. Return the sorted version of the list """ if len(lst) <= 1: return lst middle = len(lst) // 2 left = lst[:middle] right = lst...
ca00f0b24983a61a3691a80acf8017e63290dc1b
lsommerer/number-guessing-game
/main.py
1,315
4.09375
4
import time import random def main(): """ A simple number guessing game framework. """ lowerLimit = 1 upperLimit = 20 correctGuess = random.randint(lowerLimit, upperLimit) currentGuess = 'wrong-number' maxTries = 5 currentTry = 0 pauseTime = 1 print('I am thinking of a numb...
71c4de24e31e2f6dddf916debd083071d6ec9a0f
upsmancsr/Algorithms
/making_change/making_change.py
1,518
4.03125
4
#!/usr/bin/python import sys def making_change(amount, denominations): # --- method 1 start --- # if amount == 0: # return 1 # if amount < 0: # return 0 # if len(denominations) == 0: # return 0 # return making_change(amount - denominations[-1], denominations) + making_change(amount, deno...
d15f0e09c36d24cb1685e9e14ca94de6eeee5826
7ty/Programming1Repository
/HYShapes- Edited by TH/Pyramid.py
525
3.671875
4
class Pyramid: def __init__(self,pyramidL,pyramidW,pyramidH): self.pyramidL = int(pyramidL) self.pyramidW = int(pyramidW) self.pyramidH = int(pyramidH) def calcVol(self,pyramidL,pyramidW,pyramidH): print("The volume is: " + str((pyramidL*pyramidW*pyramidH)/3)) def ...
34aa3059b0bd6a2b100280fd3e6580b551fe71c9
FathimaRz/python-assignment1-2-day4
/ASSIGNMENT1DAY4RAZ.py
324
3.90625
4
#!/usr/bin/env python # coding: utf-8 # In[2]: str1= "what we think we become; we are python programmers" str1.count ("we") # In[3]: str1.count ("we",0,15) # In[4]: str1[0:15].count("we") # In[5]: str1.find("we") # In[6]: str1[5] # In[7]: str1.rfind("we") # In[8]: str1.index("we") # In[ ]: ...
56ca126bba997578083504a366e2afaeeaf9d046
prabhakarjoshi/face-recognition-based-attendance-system
/GUI/Get_The_Password_UI.py
954
3.71875
4
from DB.Get_Password_db import Get_Password_db_fun from tkinter import * import tkinter.messagebox def Get_The_Password_fun(): def Get_Password_db_fun_helper(): str=Get_Password_db_fun(entry_1.get(),entry_2.get()) root3.destroy() tkinter.messagebox.showinfo("Password","Your Password is '"...
f6a3c26889b4837b0e6a80cbcea3b6f9b4ae75eb
ryansdowning/aoc-2020
/aoc_2020/day22.py
1,329
3.515625
4
def game_score(deck): return sum(i * card for i, card in enumerate(deck[::-1], 1)) def solve1(deck_a, deck_b): while deck_a and deck_b: a, b = deck_a.pop(0), deck_b.pop(0) if a > b: deck_a += [a, b] else: deck_b += [b, a] return game_score(deck_a if deck_a e...
4bc7aa00dc066c938517d221940333af32335ec9
memiles47/PythonWithMosh
/HelloWorld/app.py
138
3.625
4
birthYear = input('Birth Year: ') # print(type(birthYear)) age = 2019 - int(birthYear) print(type(birthYear)) print(type(age)) print(age)
70b72d5cae0908be4f08976911f0e5eb3082c800
CaioHenriqueMachado/Algoritmo-A-estrela
/AEstrela.py
4,905
3.640625
4
class Aresta: def __init__(self, alvo,custo): self.custo=custo self.alvo=alvo def getCusto(self): return self.custo def getAlvo(self): return self.alvo class No: def __init__(self, nome, funcaoH): self.nome=nome self.funcaoH=funcaoH self.funcaoF=0 self.adjacente=None def ge...
3ba8d38d218d435affea8e4a9bfa6644568fd4f4
Vlad-Shcherbina/PegJumping
/render.py
6,444
3.5
4
from __future__ import division from math import sqrt, erf, log, exp import io import collections class Distribution(object): def __init__(self): self.n = 0 self.sum = 0 self.sum2 = 0 self.max = float('-inf') self.min = float('+inf') def add_value(self, x): sel...
51428801feafb425b87e8ece7f93416e7e64c69b
yuvaltimen/LanguageModel
/language_model.py
16,346
3.625
4
import sys from math import log10 import numpy as np import matplotlib.pyplot as plt from random import choice as rand_choice """ Yuval Timen N-Gram statistical language model generalized for all n-gram orders >= 1 Main method will train a unigram and bigram model, will generate 50 sentences from each of these models,...
630ca37331b91d15e5c808cb77e658ea38a591bf
pooja-pichad/list
/substract ilist.py
509
3.5625
4
l1 = [10, 20, 30, 40, 50, 60] l2 = [60, 50, 40, 30, 20, 10] a= [] # i=0 for i in range(len(l1)): if l1[i] > l2[i]: a.append(l1[i] - l2[i]) else: a.append(l1[i]) print("Original list are :") print(l1) print(l2) print("\nOutput list is") print(a) # while i<len(l1): # if l1[i...
eb8b61a458f25d4b4c2e047aac42eb619688abcc
pooja-pichad/list
/code sum.py
208
4
4
# Write a program to find the sum of all elements of a list. # a=[1,2,3,4,5,6,7,8,9] # i=0 # sum=0 # while i<len(a): # b=a[i] # sum=sum+b # i=i+1 # print(sum) # # i=i+1 a=[1,2,3,4,5,6,7]
db9f20c4fe4300a16f19f7c582d0d4c2986b17da
pooja-pichad/list
/largest smallest.py
164
3.921875
4
# Find largest and smallest elements of a list. a=[1,3,4,7,8,9,11,12] i=0 large=a[i] while i<len(a): if a[i]>large: large=a[i] i=i+1 print(large)
45c2833deed1c43476f35496cce681a2fba7d17e
pooja-pichad/list
/1 se 10 lis.py
225
3.546875
4
# output=[1,1,1,1,1,1,1,1,1] a=[1,2,3,4,5,6,7,8,9,10] # i=0 # b=[] # while i<len(a): # t=a[i] # b.append(t*5) # i=i+1 # print(b) i=1 b=[] while i<len(a): t=a[0] b.append(t*1) i=i+1 print(b)
b33d4b18f0e3dedb594d79c68a5512b29ec21ab9
amanchauhan98/shoes-bill
/shoes_program.py
2,394
3.9375
4
import time pair = 0 cost = 0 print("|---------------------|") print(" AMAN SHOES STORE ") print("|---------------------|") name = str(input("Enter your name here\n")) phone = (input("Enter your mobile number here\n")) adress = str(input("Enter your address\n")) time.sleep(0.5) print("THANK YOU!") print("f...
d496e4a15bff3c8f728128e5e16b82dcd4f12f21
zadair005/Introduction-to-Data-Science
/Functions.py
3,048
3.75
4
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> #Below is the function >>> def hello(): print ("hello") return 1234 #And here is the function being used print hello() SyntaxError: invalid syntax ...
a7413dc1858d6a48a49692f302cd88be66a6925d
Sanria2309/caramel-ice-cream
/Hangman Game.py
6,785
3.703125
4
import time import random def intro() : print("It is adviced to play with uppercase characters.") time.sleep(2) print("Just remember, if you are ever stuck and need help, hit the 'h'(not 'H') button.\n") print("Best of luck for the game !!") time.sleep(2) pr("Let's begin the game...") print(...
097a3e342b6f3d947ea81924e8b89a1563b425bc
ElAouane/Python-Basics
/104_List.py
1,195
4.5625
5
#LIST #Defining a list #The syntax of a list is [] crazy_landlords = [] #print(type(crazy_landlords)) # We can dynamically define a list crazy_landlords = ['My. Richards', 'Raj', 'Mr. Shirik', 'Ms Zem'] #Access a item in a list. #List are organized based on the index crazy_landlords = ['My. Richards', 'Raj', 'Mr. S...
985677d77e2d0dcda0eca81d4924075e1c8b2e77
ElAouane/Python-Basics
/110_Python_WhileLoops.py
359
3.953125
4
#Syntax #While <condition>: # block of code num = 0 # while 10 > num: # print(num) # num += 1 #2nd Syntax and pattern for while loops #While True: # block of code # control flow # if <condition> # #break for val in 'String': print(val) if val == 'i': print('going out of the loo...
7e0db0417467e7948835dcde1c67985b76a2dce6
skdmajee/Coding
/unscramble.py
1,815
3.6875
4
from collections import defaultdict scramble = 'ehllotehotwolrd' wordset = {'the','hello','world','to'} def calchash(s, kv, ll): hk = 0 for c in s: hk += ord(c) hk *= (kv+ll) return hk def builddict(wordset): # #Creates a dictionary of words. Each entry has the string and the unique value #t...
dfc818c931c516d40f82d5d2b16c18bd2b2ff20d
vibhor3081/GL_OD_Tracker
/lib.py
2,986
4.1875
4
import pandas as pd def queryTable(conn, tablename, colname, value, *colnames): """ This function queries a table using `colname = value` as a filter. All columns in colnames are returned. If no colnames are specified, `select *` is performed :param conn: the connection with the database to be used t...
80ef822d5d085af5e216fb57c6b15c2067836f46
yasmineElnadi/python-introductory-course
/Assignment 3/3.1.py
164
3.65625
4
#3.1 def getPentagonalNumber(n): pentagonalnumber=int((n*(3*n - 1))/2) return pentagonalnumber for i in range(1, 101): print(getPentagonalNumber(i))
e617e0788ff6129a6717d7cc26bb2a9fe2e7f12b
yasmineElnadi/python-introductory-course
/Assignment 2/2.9.py
330
4.1875
4
#wind speed ta=float(input("Enter the Temperature in Fahrenheit between -58 and 41:")) v=eval(input("Enter wind speed in miles per hour:")) if v < 2: print("wind speed should be above or equal 2 mph") else: print("the wind chill index is ", format(35.74 + (0.6215*ta) - (35.75* v**0.16) + (0.4275 * ta * v**0.16)...
1b6d2d0843efad0980c4fa09aa7388c3b1eb609c
birkirkarl/assignment5
/Forritun/Æfingardæmi/Hlutapróf 1/practice2.py
241
4.28125
4
#. Create a program that takes two integers as input and prints their sum. inte1= int(input('Input the first integer:')) inte2= int(input('Input the second integer:')) summan= int(inte1+inte2) print('The sum of two integers is:',+summan)
3729b7247c1d1aa07ebe9b59c8b642b6740e3c6c
birkirkarl/assignment5
/Forritun/Heimadæmi/TileTraveller/filetraveller.py
290
3.609375
4
out1=False out2=False while out1==False: bref=input('Enter number of shares: ') brefin(bref) while out2==False: price=input('Enter price (dollars, numerator, denominator): ') theprice(price) while out3==False: afram=input("Continue: ") if afram=='y': else:
557aeb343b71809953779d58c5f357ab5ad6a074
birkirkarl/assignment5
/Forritun/Heimadæmi/Cards/Cards.py
5,120
4.15625
4
import random class Card(object): """ A card with rank and suit """ def __set_rank(self,rank): ''' Sets the rank of the card. The rank parameter can either be a character or an integer corresponding to the rank. Internally, the rank is an integer. ''' # rank is ...
3c5a435952dd3ad37df854caa705ce4c77c048d8
birkirkarl/assignment5
/Forritun/Midterm2/Analyze.list.py
1,542
3.859375
4
def is_prime(n): '''Returns True if the given positive number is prime and False otherwise''' if n == 1: return False if n == 2: return True for i in range(2,n): if n%i == 0: return False else: return True def get_numbers(get): nytt_inntak=[] nyt...
b1841b923e2e6878e14b4846d4c59328a6e351f2
birkirkarl/assignment5
/Forritun/Assignment 15 - Sets/CommonLetters.py
1,018
3.984375
4
def get_input(): a_list=input('Input a list of integers separated with a comma: ').split(',') b_list=input('Input a list of integers separated with a comma: ').split(',') a_list=[int(i) for i in a_list] b_list=[int(i) for i in b_list] return a_list, b_list def set_lists(a_list,b_list): a_set=se...
bda620609ee67d3c75d75fd92ec42d7a005bddc5
birkirkarl/assignment5
/Forritun/Heimadæmi/english scramble/test.py
4,442
4.0625
4
def nyrleikur(): current_tile = 1.1 s = 'You can travel: ' coin = 0 while current_tile != 3.1: if current_tile == 1.1: print(s + '(N)orth.') direction = '' while direction != 'N': direction = str(input("Direction: ")).upper() if...
c326ce32719b4f47e4c5257e54d1b2c093c3e7cd
birkirkarl/assignment5
/Forritun/Assignment 7 - Functions /Fibonacci.py
323
3.90625
4
def fibo(x): array=[1,1] if x!=1: for i in range(2,x): tala=(array[i-2])+(array[i-1]) array.append(tala) for n in range(0, len(array)): print(array[n], end=' ') else: print(x) n = int(input("Input the length of Fibonacci sequence (n>=1): ")) fibo...
18ad8bcf6e920438f101c955b30c4e4d11f72e4b
birkirkarl/assignment5
/Forritun/Assignment 10 - lists/PascalTriangle.py
422
4.15625
4
def make_new_row(row): new_row = [] for i in range(0,len(row)+1): if i == 0 or i == len(row): new_row.append(1) else: new_row.append(row[i]+row[i-1]) return new_row # Main program starts here - DO NOT CHANGE height = int(input("Height of Pascal's triangle (...
8ea021e0d21620c3bdd2a4f48fccc60d0465efe8
birkirkarl/assignment5
/Forritun/Frá Brynjari/Fs%3a_Python/sk.py
1,495
3.921875
4
import re from fractions import Fraction def skalli(u, s): if u.isdigit() or ('/') in u: if '/' in u and ' ' in u: u = u.split(' ') a = Fraction(u[0]) + Fraction(u[1]) a *= Fraction(s) b = Fraction(a) if int(b) != 0: rest = b - int...
ec624856087f5952ad3b3e440dd7879478b291ef
birkirkarl/assignment5
/Forritun/Æfingardæmi/Heimadæmi gerð aftur/klassarúrfyrraprofi.py
1,709
3.796875
4
class OrderLine(object): def __init__(self, name, price, number, discount): self.name=name self.price = price self.number = number self.discount = discount def __str__(self): return "{0:<10}{1:<9}{2:<11}{3:<12}{4:<5}".format(self.name, self.price, self.number, self.d...
f8d320c1892c3458552bc3eb5d66a9f092a00ebc
birkirkarl/assignment5
/Forritun/Heimadæmi/PriceOfStock/priceOfStock.py
1,331
3.59375
4
#hef int i öllu til að checka hvort þetta séu tölur def brefin(): global out1 global bref while out1==False: bref=input('Enter number of shares: ') try: bref = int(bref) out1=True return except ValueError or SyntaxError or NameError: p...
6d1d4e00410eba10b7396a5f41ec2775c634d424
birkirkarl/assignment5
/Forritun/Æfingardæmi/Heimadæmi gerð aftur/midterm2.py
1,963
4
4
# def filereader(x): # try: # file_name=open(x,'r') # return file_name # except: # return False # def word_tool(the_file): # file_list=[] # longest=0 # for i in the_file: # file_list.append(i.strip()) # for i in range(len(file_list)): # if len(file_list[i...
77627ea28d92565289b6cd6c76778f0c98bf8c18
birkirkarl/assignment5
/BKS Önn/age.py
225
4.03125
4
age_float=float(input("Enter your age: ")) if 0 <= age_float < 34: print("Young") elif 35 <= age_float < 50: print("Mature") elif 51 <= age_float < 69: print("Middle-aged") elif 70 <= age_float: print("Old")
b09764f40c136fe3c93a97976e545f8ba67db081
phil-nye/MontyHallSimulation
/MontyHall.py
4,120
4
4
import random as rnd class GameShow: win_count = 0 lose_count = 0 total = 0 def __init__(self): self.doors = ['reward', 'nothing a', 'nothing b'] self.reward = 0 self.wrong = 0 self.host = '' self.player = '' self.set_door() def set_door(self): ...
5cac525605095e2923c91749bed70eace20e5912
Seal-Li/statistics-learning-method
/knn.py
2,026
3.6875
4
# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt import sys sys.path.append(r"C:\Users\dell\Desktop\code\knn") import get_data def EuclideanDistances(x): """ Parameters ---------- x : ndarray matrix of instances. norm : float, optional p-nor...
c3b2939dd88a1e38aad72ef09982eda2d1390511
LucianoUACH/IP2021-2
/PYTHON/ClasePractica11/funcion_angulo_triangulo.py
488
3.9375
4
import math def calcular_angulo_triangulo(a,b): if a <= 0 or b <= 0: print("Error, los valores deben ser positivos") return 0 else: c = math.sqrt(a**2+b**2) angulo = math.asin(a/c) return angulo if __name__ == "__main__": print("Ingrese el valor de a: ") a = fl...
5ac52919724b8b658c1a2586b4a6b4a7e371af0d
LucianoUACH/IP2021-2
/PYTHON/X_1/x_1.py
103
3.875
4
print("Ingrese un número") x = int(input()) x_1 = 1 / x print("El resultado es: ", end="") print(x_1)
35b5bcedc003939f44bef58326dd49e725717da4
LucianoUACH/IP2021-2
/PYTHON/Funcion1/funcion1.py
219
4.25
4
print("Ingrese el valor de X:") x = float(input()) #f = ((x+1)*(x+1)) + ((2*x)*(2*x)) f = (x+1)**2 + (2*x)**2 # el operador ** la potencia print("El resultado es: " + str(f)) # str() tranforma un número a una palabra
ac10acfb84da478b5b3cc4b192510ade116ac675
LucianoUACH/IP2021-2
/PYTHON/Clase9/clase_9.py
1,433
4.03125
4
#Ejercicio 1 def mayor(a, b): if a > b: print(str(a) + " es mayor!!!") return a elif a < b: print(str(b) + " es mayor!!!") return b else: print(str(a) + " y " + str(b) + " Son iguales") return a #Ejercicio 2 def menor(a, b): if a < b: print(str(a)...
af2dcfa2dc824abad123b6c829c134e6a3d515b9
abulka/Pythonista
/Examples/Plotting/Motion Plot.py
957
3.71875
4
'''This script records your device's orientation (accelerometer data) for 5 seconds, and then renders a simple plot of the gravity vector, using matplotlib.''' import motion import matplotlib.pyplot as plt from time import sleep import console def main(): console.alert('Motion Plot', 'When you tap Continue, acceler...
68645766659dbcf46d206fdde71462ede7adbaed
chengxxi/SWEA
/D4/1486.py
1,542
3.53125
4
# 1486. 장훈이의 높은 선반 def dfs(s, h): # staff / height of tower if h >= shelf: towers.append(h) if s == staff: # len(heights) if h >= shelf: towers.append(h) return dfs(s+1, h + heights[s]) dfs(s+1, h) for test_case in range(1, int(input())+1): staff, shelf = map(...
e0708591fa989e92ab07f8f9370b206551f49f1a
ViktorKarpilov/Study_reposytory_with_structure
/Small-stydy-things_and-tasks-from-amis/seven_task.py
372
3.78125
4
def translation(): input_minutes = int(input("Enter pleas minutes: ")) hours = input_minutes//60 result_hours = hours - (hours//24)*24 result_minutes = input_minutes - hours*60 result = str(result_hours) +"Hours and "+str(result_minutes) +"Minutes" print(result) try: translation() except: ...
128f9d2c0776b35758e20d750e577d8ac7227ef3
eunchanity/davids_repo
/scripts/list_function_solution.py
379
4.09375
4
def find_first_names(students_input): """ input: list of a class roster return: sorted list of first names in roster """ first_name = [] for name in students_input: first_name.append(name.split()[0].capitalize()) return sorted(first_name) print( find_first_names([ 'nich...
c5927a700a348468464f200631e9e2dbdf872322
dhurataK/python
/insertionSort.py
506
3.921875
4
import random, datetime def insertionSort(array): for i in range(1, len(array)): key = array[i] j = i-1 while j>=0 and array[j] > key: array[j+1] = array[j] j = j-1 array[j+1] = key return array arr = [] for i in range(0 , 100): ran...
b74ac298e5cba51c032cee6114decf658a67f494
dhurataK/python
/score_and_grades.py
804
4.1875
4
def getGrade(): print "Scores and Grades" for i in range(0,9): ip = input() if(ip < 60): print "You failed the exam. Your score is: "+str(ip)+" Good luck next time!" elif (ip >= 60 and ip <= 69): print "Score: "+str(ip)+"; Your grade is D" elif (ip >= 70 a...
739202147eac8f44a40e213cbd6bafdcc26dcea1
17leungkaim/programming-portfolio
/grading.py
426
4.1875
4
# program to figure out grades score = int(raw_input("Enter your test score")) if score >= 93: print "A" elif score >= 90: print "-A" elif score >= 87: print "B+" elif score >=83: print "B" elif score >=80: print "-B" elif score >=77: print "+C" elif score >=73: print "C" elif score >=70: print "-C" elif sco...
495dffd2bb07f45cc5bb355a1a00d113c2cd6288
cadyherron/mitcourse
/ps1/ps1a.py
981
4.46875
4
# Problem #1, "Paying the Minimum" calculator balance = float(raw_input("Enter the outstanding balance on your credit card:")) interest_rate = float(raw_input("Enter the annual credit card interest rate as a decimal:")) min_payment_rate = float(raw_input("Enter the minimum monthly payment rate as a decimal:")) monthl...
49f3df82601d5ec49d18f2e76971080100b6927a
cadyherron/mitcourse
/ps3/filter.py
732
3.9375
4
""" filter input: list input: function that returns a boolean if True keep element in list if False remove element returns: a new list with only the elements that meet a certain condition """ list = [5, 6, 7] def function(x): if x == 6: return True else: return False def filter_fun...
f3fb695d70656cd48495be8fc89af09dd3cee40a
learning-triad/hackerrank-challenges
/gary/python/2_if_else/if_else.py
838
4.40625
4
#!/bin/python3 # # https://www.hackerrank.com/challenges/py-if-else/problem # Given a positive integer n where 1 <= n <= 100 # If n is even and in the inclusive range of 6 to 20, print "Weird" # If n is even and greater than 20, print "Not Weird" def check_weirdness(n): """ if n is less than 1 or greater than...
3f43cee2f9a74cf64526522defccd2f1af8d6d9e
korynewton/Algorithms
/eating_cookies/eating_cookies.py
1,337
4
4
#!/usr/bin/python import sys # The cache parameter is here for if you want to implement # a solution that is more efficient than the naive # recursive solution def eating_cookies(n, cache=None): if n < 0: return 0 elif n == 0: return 1 else: return eating_cookies(n-1) + eating_co...
b80f01747733f676db5bce5dd0a16c278f505e33
JohnAsare/TicTacToe
/tictactoe.py
4,380
4.1875
4
# John Asare # Jun 25 2020 14:07 """Tic Tac Toe Milestone Project game! """ import random # Prints 100 spaces to behave like a clear screen def clear_screen(): print('\n' * 100) # A function to print out the Tic Tac Toe board def display_board(board): # print('\n'*100) print(board[7] + '|' + board[8] ...
09a3ab3cde4354f311071092cc20d004e9a3f572
TahaKaawan/AOC
/dcf.py
1,297
3.671875
4
# import numpy as np #import pandas as pd #import matplotlib.pyplot as plt def growth_value(FCF_t0,g,r,n): r = r/100 g = g/100 value=0 t=0 for k in range(n): tk = ((FCF_t0*((1+g)**(k))))/((1+r)**(k)) t += tk value =t global terminal_FCF,g1,r1,n1 terminal_FCF = tk ...
9554fcb0cf04be3c94f11d58e329a3bfcf4f74b1
imaadfakier/cheap-flight-club
/flight_data.py
2,046
3.515625
4
# This class is responsible for structuring the flight data. class FlightData: """Responsible for structuring the flight data.""" # class attributes # ... def __init__(self): self.all_flight_data_per_destination_city = [] self.specific_flight_data_per_destination_city = [] def st...
838bfbfabfb5e341aa341bc9042d49107c5234ce
Madhav-Somanath/LeetCode-AugustChallenge
/PancakeSorting-August29.py
992
4
4
""" Given an array of integers A, We need to sort the array performing a series of pancake flips. In one pancake flip we do the following steps: Choose an integer k where 0 <= k < A.length. Reverse the sub-array A[0...k]. For example, if A = [3,2,1,4] and we performed a pancake flip choosing k = 2, we revers...
d74a203fb83246ada7d0777b94667dc6d243cbef
Madhav-Somanath/LeetCode-AugustChallenge
/AddandSearchWord-August5.py
1,245
3.9375
4
""" Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or . A . means it can represent any one letter. """] from collections import defaultdict class WordDictionary...
fc1816b5c55421855a87b4fab9fef655bf70fb1b
Madhav-Somanath/LeetCode-AugustChallenge
/IteratorforCombinations-August13.py
1,795
3.890625
4
""" Design an Iterator class, which has: A constructor that takes a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments. A function next() that returns the next combination of length combinationLength in lexicographical order. A function hasNext() that...
704471e605b3ea2f00faf7f79477698681fc7eec
MaloMn/SudokuSolver
/f_solcan.py
468
3.703125
4
# -*- coding: utf-8 -*- """ Sole candidate technique. If there is only one possibility in a cell, because of the constraints of the other numbers, then it can only be this number. """ from copy import deepcopy def sole_candidate(s, poss): sudoku = deepcopy(s) for i in range(9): for j in range(9): ...
ff93536c0021d334658ef14d60eb3bf30f328f84
chillinc/angel
/lib/devops/settings_helpers.py
1,374
3.65625
4
import sys def key_value_string_to_dict(data_string, key_value_separator='='): ''' Given a string like: key=value\nkey2=value2 Return a dict with data[key] = values. - Ignores all lines that start with # or are empty. - Returns None on any parse errors. - Strips leading...
1bfa2d483b59b2cdadc6498bb3ec5d85bd9fa658
gaoyang836/python_text
/learning_test/循环.py
740
3.625
4
''' names = ['gaoyang', 'xinxin', 'guanglin'] for ceshi in names: print(ceshi)''' '''sum = 0 for x in [1,2,3,4,5,6,7,8,9,10]: sum = sum + x print(sum)''' '''sum = 0 for x in range(101): sum = sum + x print(sum)''' '''sum = 0 n = 99 while n>0: sum=sum+n n=n-2 print(sum)''' '''sum ...
3f9b52057465aa6657f677e2ebf65ea5e3e9ede9
gaoyang836/python_text
/test_tool/my_sort.py
311
3.90625
4
def mysort(inList,dir): newList=[] while len(inList)>0: if dir: minData = max(inList) else: minData =min(inList) newList.append(minData) inList.remove(minData) return newList alist=[0,8,5,1,2] print(mysort(alist)) print(mysort(alist),True)
38ab9b100cd65fa8f507932ce3824bcfde62099e
gaoyang836/python_text
/test_tool/Decorator_certification.py
1,664
3.859375
4
# -*-coding:utf-8 -*- # author:gaoyang time:2020-03-04 #用装饰器加认证功能(token) #token:令牌,是服务端生成的一串字符串,作为客户端进行请求的一个标识, # 当用户第一次登录后,服务器生成一个token并将token返回给客户端, # 以后客户端登录会判断token,有token不用登录,没有token需要登陆 #按理说此处应该连接数据库表,此处用字典代替 user_dict={ #用户名密码 'user1':'123', 'user2':'123' } token="" #定义一个装饰器 def auth(func): def ...
3e9f5cb439f461d32d83823f63379b7b72a8c259
ahmadzaidan99/Codewars
/Write_Number_In_Expanded_Form.py
274
3.75
4
def expanded_form(num): result = [] divider = 10 while divider < num: temp = num%divider if temp != 0: result.insert(0, str(temp)) num -= temp divider *= 10 result.insert(0, str(num)) return ' + '.join(result)
835fc048225330f1334708fc2a0ede731d1be94b
demptdmf/python_lesson_3
/homework_3.py
7,393
4.09375
4
f = open('text.txt') text = f.read() print('1) Методами строк очистить текст от знаков препинания:') text = text.replace(',', '') text = text.replace('.', '') text = text.replace('?', '') text = text.replace('!', '') text = text.replace('«', '') text = text.replace('»', '') text = text.replace(':', '') text = text.repl...
d13d318c78f4f902ef6b1a1474a832c70db6b9f2
demptdmf/python_lesson_3
/range.py
2,788
4.21875
4
# Когда использовать RANGE # позволяет создать последовательность целых чисел numbers = range(10) print(numbers) print(type(numbers), '— это диапазон') print(list(range(1, 20, 2))) # Напечатать список от 1 до 20 с шагом "2" — 1+2, 3+2, 5+2 и так далее for number in range(1, 20, 2): # Просто ...
7fb1cb548a817550635159efe45fb90df7441f18
Kederly84/pythonProject
/Unit 3.py
1,486
3.921875
4
# ИГРА "УГАДАЙ ЧИСЛО" # №1 Программа загадывает число import random number = random.randint(1, 100) # №2 и №3 ввод числа пользователя и реализация цикла проверки чисел user_answer = None counter = 0 levels = {1: 10, 2: 5, 3: 3} level = int(input('Выберите уровень сложности от 1 до 3')) max_count = levels[level] us...
e5730e25a2d2a5272616443ba26f8fa912278127
Kederly84/pythonProject
/Lesson 7.py
1,616
3.75
4
# cities = ['Las Vegas', 'Paris', 'Moscow', 'Paris', 'Moscow'] # print(cities) # print(type(cities)) # # cities = set(cities) # # print(cities) # print(type(cities)) # # cities ={'Las Vegas', 'Paris', 'Moscow'} # cities.add('Birma') # добавление элемента в множество # cities.add('Moscow') # повторяющийся элемент не доб...
d2cfcecd211e2b6ff7047c4d3239311c430d6f8f
kushal200/python
/Basic/Function/OddEvenFunction.py
206
4.09375
4
def oddeven(a): if a%2==0: print( a,"is Even Number") else: print(a,"is Odd Number") def main(): num=int(input("Enter any number:")) oddeven(num) main()
16356775ed7d047aa0146ced654ac2bf8a45d112
kushal200/python
/Basic/Function/MultiplicationFunctino.py
189
4
4
def multiplication_table(a): for i in range(1,11): print("%d * %d = %d" %(a,i,a*i)) def main(): num=int(input("Enter the number")) multiplication_table(num) main()
24de5abad8325fa762558ccd6ba5e733691c4f3e
kushal200/python
/Basic/ClassAndObject/areaOfCircle.py
398
3.703125
4
# class dog: # def __init__(self, name, age): # self.name=name # self.age=age # print(name,age) # buddy=dog("buddy", 9) # miles=dog("miles", 4) # print(buddy.name) # # print(buddy.name) # # print(buddy.age) class circle: def __init__(self, radious): self.radious=radious def...
cb04fdd6c7777b683649f3bb1b889092280146b4
kushal200/python
/Basic/Function/examQues.py
2,876
3.609375
4
def check(m_u, income): if m_u == 'Y': if annual <= 450000: a = annual * 0.01 total = a tax = 1 elif 450000 < annual <= 550000: a = 450000 * 0.01 b = (annual - 450000) * 0.1 tax = (1 + 10) total = a + b elif ...
748885bd08afb97b4a16c100814f6a99d26923e4
kushal200/python
/Basic/ListOfpython/vowel.py
392
3.953125
4
userinput=input("Enter the Sentence:") print(userinput) vowel=0 for i in userinput: if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'): vowel+= 1 print(vowel) if vowel%i==0: print("The given number is a prime number.") else: print("The num...
acdbae328d4470d480c2369c62c05a4c12514331
kushal200/python
/Basic/ListOfpython/greatestNumber.py
268
4.03125
4
a=int(input("Enter the First Number:")) b=int(input("Enter the Second Number:")) c=int(input("Enter the Third Number:")) if a>b>c: print("%d is a Greatest Number" %a) elif b>a>c: print("%d is a Greatest Number" %b) else: print("%d is a Greatest Number" %c)
3469b3d2e746ed029a42d652fea839ede1def1fd
VivekKumar4387/tathastu_week_of_code
/day1/prog4.py
252
3.90625
4
CP = float(input("enter cost price of product:")) SP = float(input("enter selling price of product:")) profit = SP-CP newsp = 1.05*profit + CP print("profit from product=",profit) print("to increase profit 5% more new selling price should be =",newsp)
98b8612d26bf010ae68ea139a0811c3627846881
cegodwin/BIOL5153HW
/parseGFF_2.py
1,391
3.796875
4
#! /usr/bin/env python3 #import modules import csv import argparse #create and argument parse object parser = argparse.ArgumentParser(description = 'This script will take a .gff file, pull out the gene names from the list, and store them in a alphabatized list. Then it will take that list and use it to pull out the ...
b1baeef01b90b0ecae1b840759d619a71a8e1a29
Hovhanes/Webs
/Basic/script.py
1,428
3.703125
4
#name = "hovlo" #age = 25.555 #print(f"hello,{name},qo tariqna {age}") #print('%d is ok' % (age)) #print ('%s is %d years old' % ('Joe', 42)) #str_lower = 'abcdefjhy' #str_uper = 'ABCDEFJS' #print(str_lower.upper()) #print(str_uper.lower()) #string = "geeks for geeks geeks geeks geeks" # Prints the string by...
d5e440eed002560547bf69c31a88bd5584a2bb53
snlucas/Poke_Trader
/test_trade_calculator.py
3,380
3.5
4
from pokemon import Pokemon from player import Player from trade_calculator import TradeCalculator import unittest class TestTradeCalculator(unittest.TestCase): def test_player_total_base_experience_passing_wrong_type(self): """Teste passando argumento diferente de Player >>> _total_base...
3eb3915dfca95ace11f03d4eb2ae162c0428e4cf
ConnorWood/Prac03
/namePrint.py
94
3.859375
4
name = str(input("What is your name? ")) for i in range(0, len(name), 2): print(name[i])
4f5d0feece8584349ad40d9da35afc37ec8cadce
st084331/InaccurateInput
/main.py
1,683
3.765625
4
def Z_func_with_discrepancy(str): I = 0 r = 0 j = 0 Z = [0] * (len(str)) Z[0] = len(str) for i in range(1, len(str)): j = i discrepancy = 0 if i <= r: Z[i] = min(r - i + 1, Z[i - I]) while j + Z[i] < len(str) and (str[Z[i]] == str[j + Z[i]] or (i > str...
7e02ef06abb2d2ab0566c999decf610d54c232ee
florenciano/estudos-Python
/_first.py
599
3.921875
4
# -*- coding: utf-8 -*- # comentário de várias linhas """ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis, labore, autem nihil ratione ipsum itaque sapiente, et eveniet error obcaecati a provident veniam nam consequuntur quod enim natus. Tempore aliquid maxime laboriosam sunt. Vero repellat animi ...
612e27abc6ddf0c70b01aecc4b98b05f9d146857
florenciano/estudos-Python
/livro-introducao-a-programacao-em-python/cap9/arquivo_exercicio1.py
393
3.5
4
# -*- coding: utf-8 -*- # abrindo os arquivos pares.txt e impares.txt pares = open("pares.txt", "r") impares = open("impares.txt", "r") lista = [] # lendo os arquivos pares.txt e impares.txt for x in pares.readlines(): lista.append(int(x)) pares.close() for x in impares.readlines(): lista.append(int(x)) impares...
c6f81be710ff83f95f7b3ed87711cdcc40251903
florenciano/estudos-Python
/livro-introducao-a-programacao-em-python/cap10/classe-objeto-all.py
2,004
4.125
4
# -*- coding: utf-8 -*- #abrindo conta no banco Tatú class Cliente(object): def __init__(self, nome, telefone): self.nome = nome self.telefone = telefone #movimentando a conta """ Uma conta para representar uma conta do banco com seus clientes e seu saldo """ class Conta(object): def __init__(self, clientes, nu...