blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c6737f4dc808f5c08e951b56de84a5f165f96584
Chinna2002/Python-Lab
/L5-Binary search with test cases.py
1,376
3.84375
4
""" #Test Case-1(Array of characters) Enter the size of array: 4 enter element:a enter element:b enter element:c enter element:d ['a', 'b', 'c', 'd'] Enter the target to be searched:c Element c found at 2 """ """ #Test Case -2(With repetation of elements) Enter the size of array: 4 enter element:1 enter ...
08b50141596ce0f5b47adf82c2f138504f1b4eff
Chinna2002/Python-Lab
/L2-Twin.py
480
3.953125
4
print("121910313006","Kadiyala Rohit Bharadwaj") #Printing Twin Primes up to specified range def prime(n):#Fuction1 isprime=True for i in range(2,n): if(n%i==0): isprime = False break return isprime def twin(a,b):#function2 for k in range(a,b+1): j=k+2 ...
799d5efe28140e54821c7c679ae77b64d250f45f
Chinna2002/Python-Lab
/L2-(LCM and GCD).py
398
3.90625
4
#GCD and LCM of two numbers print("121910313006","Kadiyala Rohit Bharadwaj") a=int(input("Enter a value:")) b=int(input("Enter b value:")) #logic for GCD if(a<b): small=a else: small=b for i in range(1,small+1): if(a%i==0 and b%i==0): gcf=i #logic for LCM lcm=(a*b)/gcf #Displayin...
6fde2414bff47226f5896dd31552593fe94edc86
Chinna2002/Python-Lab
/L8-Inserting node at desired postion in double linked list.py
1,677
4.1875
4
print("121910313006","Kadiyala Rohit Bharadwaj") # Defining the Node class class Node: def __init__(self, data): # Constructor for Node class self.data = data self.prev = None self.next = None # Definind the Doubly Linked List Class class DoublyLinkedList: def __init__(self...
f2b67df436780fcdecb6969039bc148fc52a3817
Chinna2002/Python-Lab
/L12 Selection with Recursion.py
489
3.8125
4
import sys print("121910313006","Kadiyala Rohit Bharadwaj") print("SELECTION SORT WITH RECURSION") def Selection(arr,i,n): min_idx = i for j in range(i + 1, len(A)): if arr[min_idx] > arr[j]: min_idx = j arr[i], arr[min_idx] = arr[min_idx], arr[i] if i + 1 < n: Selection(arr...
99f619e0326870b4da14b72895e14a78d1326934
Chinna2002/Python-Lab
/L8-deleting a node in doubly linked list.py
1,755
4.15625
4
#Deleting the nodes in Double linked list print("121910313006","Kadiyala Rohit Bharadwaj") # Defining the Node class class Node: def __init__(self,data): # Constructor for Node class self.data = data self.prev = None self.next = None # Definind the Doubly Linked List Class class D...
77fa1e03c1aac2d2608d3798ec983b1474833aa1
shahzaibk23/Frog-Problem-Python
/frogProblem.py
1,040
3.75
4
# Operations class FrogProblem: def __init__(self, state, lst): self.lst = lst self.states = state def moveRight(self,i): self.states += 1 self.lst[i],self.lst[i+1] = self.lst[i+1],self.lst[i] print(self.lst) def jumpRight(self,i): self.states += 1 ...
00d9bd3e3b4d0ab4217a779f63504ddc5b7681d5
Quantumgame/quantum-ml
/Nanowire Model/potential_profile.py
1,949
3.59375
4
# potential_profile.py # This script contains the definition of the gate model used to create the # potential profile. The script should not be changed when being used for # development since the data generation scripts might be dependent on this. # Use the "Test Notebooks" folder instead. # Last Updated : 14th Novem...
37a5617d3f6410f5669061cf2fbfea8c4fdaddda
dwallace-web/python_with_excel_notes
/viewing_data.py
768
3.828125
4
import pandas as pd from openpyxl.workbook import workbook df = pd.read_csv('Names.csv', header=None) # access data df.columns = ['first', 'last', 'address', 'city', 'State', 'Area Code', 'unknown'] # get data by columns print(df.columns) # show data from one column print(df['last']) # show data from...
939222b1f317ba003d7f6aee3e0e8ed7a36eb61f
samyakmshah/ml-implementations
/k_nearest_neighbours.py
1,785
3.796875
4
import numpy as np import matplotlib.pyplot as plt class kNN(): def __init__(self, k = 5): self.k = k def predict(self, x, X_train, y_train): if len(x.shape) == 1: x = x[np.newaxis, :] '''Classify a new point according to KNN ---------- Inputs x_new: new datapoint to classify X_train: dataset of lab...
e4fafd336931627588a360f611cdd5f8862e765a
davidebuglione/esercizi-in-classe
/esercizio 2.py
803
4.0625
4
candidato1=input("inserire il nome del primo candidato").upper() candidato2=input("inserire il nome del secopndo candidato").upper() voticandidato1=int(input("quanti voti ha ricevuto il candidato 1?")) voticandidato2=int(input("quanti voti ha ricevuto il candidato 2?")) if candidato1>candidato2: print("L'ordine alf...
8c1ebdbbd62559322f94820d0796ab36c9ab9403
davidebuglione/esercizi-in-classe
/esercizio 3.py
338
3.8125
4
totale_stipendi=0 numero_stipendi=0 while True: stipendio=input("inserire il valore di uno stipendio") if stipendio=="-1": break else: stipendio=int(stipendio) totale_stipendi+=stipendio numero_stipendi+=1 media=int(totale_stipendi/numero_stipendi) print("la media degli stipe...
a7ddc217beabee6da9857a63d7fee548960d5d0e
manuelz120/hackvent-2019
/12/crack.py
252
3.5
4
#!/usr/bin/python3 encrypted_flag = "6klzic<=bPBtdvff'yFI~on//N" decrypted_flag = "HV19{" for i in range(len(encrypted_flag)): char = chr(ord(encrypted_flag[i]) ^ (6 + i)) decrypted_flag += char decrypted_flag += '}' print(decrypted_flag)
0fa62f5b8cae7d59ba28983986e08c1768250064
martalais/URI
/Python/1060numeros_positivos.py
135
3.75
4
# coding: utf-8 count = 0 for i in range(6): num = float(raw_input()) if num > 0: count += 1 print "%d valores positivos" % count
2766542cdca73c53a016cf4c3101a3517344a0f3
lenapy/HW
/painting_square.py
2,070
4.125
4
def check_input(func): def wrapper(*args): allowed_numbers = ['1', '2', '3', '4'] if args[1] not in allowed_numbers: raise Exception('Invalid input!') res = func(*args) return res return wrapper class Square: def __init__(self, side_len): self.side_len =...
93c4c50b5168bc3de00b2997e3cd51ba1aec7b79
Benjir1/Elemi-programozasi-tetelek
/ept/tetel1.py
835
3.734375
4
print("Az összegzés tétele\n") sve = input("Szóközzel szeretnéd elválasztani a tagjaidat, vagy egyesével szeretnéd beírni? (S = Space, E = egyesével): ").lower() def osszeadas(tomb, elemekmennyisege): eredmeny = 0 for i in range(0, elemekmennyisege): eredmeny += tomb[i] return f"Az eredmény: {...
01143b503d89d95f78410cb7ecf76eba3858a9bf
SandraMarcelaHerreraArriaga/LedgerImplementation
/my-ledger.py
1,025
3.875
4
import sys import re from Commands import register def main(): arguments = sys.argv[1::] inputCommand = sys.argv[1] checkIfValidCommands(inputCommand,arguments) def checkIfValidCommands(command,arguments): validCommands = ["bal","balance","register","reg","print","--price-db","--file","-...
3cceee339d472cb1da44914370e9d3467abb897d
client95/s.p.algorithm
/week_2/04_delete_node_linked_list.py
2,614
3.984375
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self, value): self.head = Node(value) def append(self, value): cur = self.head while cur.next is not None: cur = cur.next cur.next = Node(valu...
50714dc120318b05e424f20c8be44a1211286ea4
jaeseo-park/JS_AlgorithmStudy
/단어변환.py
1,101
3.515625
4
#프로그래머스 #https://programmers.co.kr/learn/courses/30/lessons/43163 import copy def dfs(checklist, now_word): global g_target global min_count if now_word == g_target: min_count = min(min_count, sum(checklist)) return for i in range(len(checklist)): now_checklist = copy.deepcopy...
e7683013957b04267bd18541c5cccd1b962c4830
vladimirjukic/advent_of_code_2017
/day2/day2.py
804
3.640625
4
def calculateSpreadsheetPartOne(data): result = 0 for row in data: numbers = map(int, row.split()) result += max(numbers) - min(numbers) print "Sum of spreadsheet part 1: ", result def calculateSpreadsheetPartTwo(data): result = 0 for row in data: numbers = sorted(map(int, ...
f7dd45ea2eb02b3de9c3dafd32ed4e8f9506f23e
augustinkrug/hackinscience
/exercises/328/solution.py
245
3.78125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 22 13:33:07 2015 @author: A.KRUG """ def mul(l): # if len(l) == 1: # return l[0] result = 1 for i in l: result = result * i return result """ print(mul([2])) """
9550df9ad490ecbb3f3c58d64578dbebdd5ef2d6
mmosc/pyph
/2/2-2.py
224
3.546875
4
"""kleine Einmaleins. """ import numpy as np # Define the array a of shape (9,1) a = np.arange(1,10).reshape(9,1) # Define the array b of shape (1,9) b = np.arange(1, 10).reshape(1,9) produkt = a * b print(produkt)
3dfc05faf6bb8aa055f6200b2a4339891e56f417
Zoe99-code/python-conditional-exercises
/main.py
390
4.1875
4
grade = float(input("Enter your grade")) if grade >= 90: print("Your grade is A") else: if grade >= 80: print("Your grade is B") else: if grade >= 70: print("Your grade is C") else: if grade >= 60: print("Your grade is D") else: ...
3a441747728a1494126b8c9a7eabbe803214e22b
muremwa/Simple-Python-Exercises
/exercise_5B_files.py
499
4.09375
4
# Q5b) Print sum of all numbers (assume only positive integer numbers) from a file containing arbitrary string import re def main(): # open file and copy all text with open('files/f2.txt', 'r') as f: text = f.read() # search for number sequences in the text using regular expressions nums = re...
e5ad40c48428c8132de6360f10205b5d55991d27
muremwa/Simple-Python-Exercises
/exercise_4B_lists.py
906
4.34375
4
# Q4b) Write a function that returns nth lowest number of a list (or iterable in general). # Return the lowest if second argument not specified # Note that if a list contains duplicates, they should be handled before determining nth lowest def nth_lowest(list_1, nth=1): # remove duplicates and sort list_1 = l...
459741a3fd5a966f929ffd1dbbb6d849cfeaa650
sebastiendamaye/picoCTF_2018
/cryptography/250-rsa-madlibs/files/rsa.py
1,339
3.703125
4
#!/usr/bin/env python from Crypto.Util.number import inverse # pycryptodome pip package print("=== QUESTION #1 ===") print("Possible: YES") q = input("q: "); q = int(q) p = input("p: "); p = int(p) print("n =", p*q) print("=== QUESTION #2 ===") print("Possible: YES") p = input("p: "); p = int(p) n = input("n: "); n =...
bdcdeb71bdcf9837e4f13ab9e1eadb396544bba6
BigPlayLab/VolleyballSoftware
/scoreboard.py
3,007
3.875
4
import matplotlib.pyplot as plt import matplotlib.ticker as ticker import numpy as np class scoreboard(): """ Keeps a record of the score for the game. Types: self.set_counter : int --> max number of sets in a game is 3 self.point_counter : list --> keeps record of order in which points are scored...
57bfcec31889ced05861f4bd4a159df7e448a82b
smart-town/MyNotes
/02Backstage/Python/00Test/Basic/ObjectMore.py
705
3.921875
4
class Person(object): def __init__(self,name,age): self._name = name self._age = age @property def name(self): return self._name @property def age(self): print("You will get age ") return self._age @age.setter def age(self,age): print...
757ad4709d1caf7562601ff163b84333ba647cf1
projeto-de-algoritmos/Greed_CineMania
/funcoesGreed.py
5,462
3.671875
4
import re def exibir_menu_principal(): print('Bem vindo ao Cinemania') print('1 - Cadastrar filme') print('2 - Ver filmes cadastrados') print('3 - Visualizar número de salas necessárias para exibição') print('4 - Número máximo de filmes que uma pessoa consegue assistir por dia') print('0 - Sair...
9eb978e0161028188368db765c1777cd6376e83f
PeterLW/NLTK-Training
/test1_tokenizer.py
375
3.59375
4
#separate words or sentences import nltk from nltk.tokenize import sent_tokenize, word_tokenize #nltk.download(); example_text = "Hello Mr. Smith, how are you doing today? The weather is great and python is awesome. The sky is blue." print(sent_tokenize(example_text)); print(word_tokenize(example_text)); ...
27135905d8d602794e012d49456615246b90b517
wilmaRodz/cs-module-project-iterative-sorting
/src/iterative_sorting/iterative_sorting.py
2,065
4.15625
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n-1 elements # For each element in the array for i in range(0, len(arr)): #print(f"i: {i}") # Save the current_index of this element cur_index = i # Set smallest_index as current_...
984f88b812822b1c2e0ccff990ed0ebaee5c9102
NafunNebula/NafunTkinter
/NafunCalculator/Calculator.py
2,871
3.765625
4
import math from tkinter import * root = Tk() root.title("Nafun Calculator") e = Entry(root, width=50, borderwidth=5) e.grid(row=0, column=0, columnspan=4, padx=15, pady=15) def addEntryValue(number): current = e.get() e.delete(0, END) e.insert(0, str(current) + str(number)) def clearEntryValue(): e...
81c61dfb8126c589bef7eb7eaeb8608d910d8f96
napatpiya/bootcamp
/python_stack/python/fundamentals/insertion_sort.py
323
4.0625
4
def insertion_sort(someList): for i in range(0, len(someList)-1, 1): for j in range(i+1, 0, -1): if someList[j] < someList[j-1]: someList[j-1], someList[j] = someList[j], someList[j-1] return someList print(insertion_sort([4,3,5,1,2])) print(insertion_sort([6,5,3,1,8,7,2,4]...
e60ce9929d0dc545db7bc1a6982526fa01a8a62b
napatpiya/bootcamp
/python_stack/python/fundamentals/validation.py
1,986
4
4
def braceValid1(string): parens = 0 brace = 0 bracket = 0 arr = [] for i in range(len(string)): if string[i] == "(": parens += 1 arr.append(string[i]) if string[i] == ")": parens -= 1 if arr[len(arr)-1] == "(": arr.pop()...
bbc12400e1694e2fbb8b3f11c9b1039c7ccd1d0f
napatpiya/bootcamp
/python_stack/python/fundamentals/sequences.py
857
4.0625
4
my_list = [99,4,2,5,-3,120] my_tuple = (99,4,2,5,-3) my_str = "sequoia" print(my_list[:]) # output: [99,4,2,5,-3] print(my_tuple[1:]) # output: (4,2,5,-3) print(my_str[:3]) # output: "seq" print(my_tuple[2:4]) # output: (2,5) print(my_list, my_tuple, my_str) # output: [99,4,2,5,-3] (99,4,2,5,-3) 'sequoia' -- note the o...
08858714a779f79fb955e8ec6aeb5cdad76791c1
venky97/Basics
/linear_regression.py
445
3.625
4
import numpy as np import matplotlib.pyplot as plt x = np.array([0,1,2,3,4,5,6,7,8,9]) y = np.array([1,3,2,5,7,8,8,9,10,12]) p0 = np.array([1,1]) n = np.size(x) # Least squares technique m_x = np.mean(x) m_y = np.mean(y) ss_xy = np.sum(x*y-n*m_x*m_y) ss_xx = np.sum(x*x - n*m_x*m_x) p0[0] = ss_xy/ss_xx plt.scatter(x,y,...
84e3ce8361f7f38b3be22078a1e8a753cd150e9e
sambapython/batch58
/except.py
1,016
3.546875
4
import logging logging.basicConfig(level=logging.WARN, filename="log.txt", format=("%(asctime)s==>%(levelname)s-->%(message)s-->%(name)s") ) logging.info("program strted") try: print("welcome") logging.info("program strted") a=input("Enter a vlaue:") logging.debug("a value enterd:%s"%a) ...
7e2f04d06ff2bf40185435958f633ac7f3c63f75
ragvri/python-snippets
/matplotlib/scatter_plots_and_bar_graphs.py
494
3.90625
4
import matplotlib.pyplot as plt from matplotlib.pyplot import style style.use('ggplot') x = [1, 2, 3, 4] y = [7, 3, 8, 3] x2 = [5, 6, 7, 8] y2 = [2, 3, 4, 5] # for scatter plot use scatter instead of plot plt.scatter(x, y, label='line 1', color='green') plt.scatter(x2, y2, label='line two', color='yellow') # giving ...
9f224234c912b0f3890d520d85eaee36c3544424
ragvri/python-snippets
/intermediate_python_stuff/urllib_module.py
1,523
3.90625
4
import urllib.request import urllib.parse # x = urllib.request.urlopen('https://www.google.com') # sends a get request to the url and returns the source code # print(x) ''' Variables in link the first variable will have a ? in front of it and the subsequent variables will have an & in front of them ''' # if we want...
d2698c3e0b2d53bf29ee72f486158d4eb1624b5c
ragvri/python-snippets
/tkinter_snippets/sixth.py
417
3.90625
4
#simple example from tkinter import * root=Tk() def leftclick(event): print("left clicked") def middleclick(event): print("middle clicked") def rightclick(event): print("right clicked") frame=Frame(root,width=300 , height=250) # can specify width and height frame.bind("<Button-1>", leftclick) frame.bi...
b0481784be66fe774691c060de789fccf31f31a1
ragvri/python-snippets
/tkinter_snippets/second.py
887
4.5625
5
#creating buttons from tkinter import * root=Tk() #frame-> invisible rectangle that we can put things in topframe=Frame(root) topframe.pack() # no need to specifty side=Top here as bottom already occupied bottomframe=Frame(root) bottomframe.pack(side=BOTTOM) #tells us that we want to put the frame...
900967027c581ccbcc5b8b9cca0030ae607638cd
ragvri/python-snippets
/intermediate_python_stuff/argparser.py
1,154
4.375
4
# how to use argparser for command line interface import sys import argparse def main(): parser = argparse.ArgumentParser() # from the case of ArgumentParser it is a class., so parser is a class parser.add_argument('--x', type=float, default=1.0, help='What is the first number') parser.add_argument('--y...
c5514a3342d3fec0b81a8ef23f8f8e7911ebafa8
plummaster/ChatClient
/chat-transmitter.py
1,483
4.28125
4
# Here is a basic program file to get us started. # I think this module may be very helpful for us # Documentation is here: https://docs.python.org/3/library/socket.html import socket # Initialize the socket host = 'localhost' # localhost just means "this computer" port = 54321 # port can be pretty much any n...
7ee64cc2091d024bd70cadcd35b0f394b4fc4f61
lsh3163/Sliding-puzzle
/makeyour's/mc_eg.py
3,626
3.640625
4
import numpy as np from puzzle import Puzzle import pickle import matplotlib.pyplot as plt # Constants gamma = 0.95 moves = ('L', 'U', 'R', 'D') oob = 1 game_ends = 1 #Epsilon greedy for Monte Carlo # Probability of a is really 1 - eps + eps / |A| def random_move(a, eps=0.1): p = np.random.random() if p < 1 - eps...
530b604ba57142c037c4c7593d5ae2ec1731b865
h-dyeon/Algorithm
/Leetcode/Leetcode547.py
705
3.625
4
from collections import deque # def checkConnected(start,check): # visited[start]=check # dq=deque([start]) # while dq: # t=dq.popleft() # for i in range(nodesize): # if visited[i]==0 and t!=i and isConnected[t][i]==1: # visited[i]=check # dq.appe...
eda680a70bdd57ba4ac9bf50c3c9b0d855c0b21d
stephroxas/FTW-DS-Bootcamp
/Exercise3.py
121
3.546875
4
def tripleprint(string): for i in range(1,4): print(string, end="") return x = "hello" tripleprint(x)
08bd3ce5238de2c65d975a8b2fed8f14f11f9f4b
Tyler-Z/algorithm006-class02
/Week_01/G20200343030496/LeetCode_26_496.py
871
3.609375
4
#已经排好序,重点信息 class Solution: #method 1 哈哈好简单 def removeDuplicates1(self, nums: [int]) -> int: if not nums: return 0 k = 1 for i in range(1, len(nums)): if nums[i] != nums[i - 1]: nums[k] = nums[i] k += 1 print(1,nums) return k ...
c0f94372e00fdd313d2c439ecb9f9c5a8c812907
Tyler-Z/algorithm006-class02
/Week_02/G20200343030586/02_02_n_ary_tree_preorder_traversal.py
863
3.703125
4
# 589. N叉树的前序遍历 # 根左右 # 递归 """ class Solution(object): def preorder(self, root): # terminator if not root: return [] ans=[] # current lvl def preTreversal(node): if not node: return ans.append(node.val) #先将当前节点的值写入...
4f033af52abdb134c515ffcec9450d833940f064
Tyler-Z/algorithm006-class02
/Week_01/G20200343030550/LeetCode_88_550.py
840
4.09375
4
# -*- encoding: utf8 -*- def merge(nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: None Do not return anything, modify nums1 in-place instead. """ # 冒泡 # nums = nums1[:m] + nums2[:n] # swapped = True # while swapped: ...
95d8a8a2cd0fa00508b95753fbcb29094f26e083
Tyler-Z/algorithm006-class02
/Week_01/G20200343030556/21.合并两个有序链表.py
1,014
3.96875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def mergeTwoLists(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ # 1....
eb675d6cd1f0f6805b1f5b33d1614dbf7dc3fbd8
hemanth1011/coding-dump
/leapyear.py
146
4.125
4
year = int(input("Enter year")) if(year%400 == 0 or ( year%4 == 0 and year%100 != 0)): print("Leap year") else: print("Non-Leap year")
2093abf4a7c38d55d528cb4290161b6eb288b586
hemanth1011/coding-dump
/SecondBiggestNum.py
414
3.796875
4
a = int(input()) b = int(input()) c = int(input()) if(a>b): if(a>c): if(b>c): print(b,"is Second Biggest") else: print(c,"is Second Biggest") if(b>c): if(a>c): print(a,"is Second Biggest") else: print(c,"is Second Biggest") else: if(...
0099a17b3d889215f6691b3cf3cf8b91a101bab1
hemanth1011/coding-dump
/CalUsingifelse.py
612
4.21875
4
# Note : there is no switch case in python. so, here im using if and if-else statements. #--------------------------------------------------------------------------------------- a = input("Enter first number") b = input("Enter second number") op = input("Enter opertion from below \n+\n-\n*\n/\n") if(op=="+"): ...
6ca09ce09d67b2a4947497ee9485325752de6508
Abdirahman136896/python
/dateandtime.py
114
3.640625
4
#Write a Python program to display the current date and time. import datetime print(datetime.datetime.now())
286e3152c7b4cf0b188f52f79acabd0c4cc19566
Abdirahman136896/python
/strings.py
632
3.90625
4
phrase = "Giraffe Academy" print("Giraffe\n\"Academy\"") print(phrase + " is cool") print(phrase.lower()) print(phrase.upper()) print(phrase.islower()) print(phrase.isupper()) print(phrase.upper().isupper()) print(phrase.lower().islower()) print(len(phrase)) print(phrase[0]+phrase[1]+phrase[2]+phrase[3]+phras...
7175c6a35d808d0b24cf2a5a760bab1fd413de03
Abdirahman136896/python
/buildingabasiccalculator.py
146
3.90625
4
my_num1 = input("Enter the first number:") my_num2 = input("Enter the second number:") my_sum = float(my_num1) + float(my_num2) print(my_sum)
337ff2072336a7d1b15ca99f8aff30e5a897e3c3
Abdirahman136896/python
/ifstatementsandcomparisons.py
282
3.96875
4
def max_num(num1,num2,num3): if num1 >= num2 and num1 >= num3: return num1 if num2 >= num1 and num2 >= num3: return num2 if num3 >= num1 and num3 >= num3: return num3 print(max_num(2,40,3)) print(max_num(20,4,3)) print(max_num(2,4,30))
a94c06b3914fadb258b7d9d6843d21a4dc493dc7
ahyman3/scriptingDS
/Labs/Lab 3/computePay.py
1,464
3.921875
4
''' File Name: computePay.py Created on: 31 Jul 2018 Created By: Alex Hyman Purpose: To calculate the pay given the hours and a rate. This will be defined in a function called computePay and will include overtime ''' #Defining the function def computePay(hours, rate): #if statement to see if we need to implement o...
b513485cbf40ce18655092164dc66847bd3f44be
himrasmussen/PyCipher
/homophonic_cipher.py
3,719
3.71875
4
# a homophonic cipher # needs to have a homophoinic letter substitution table import copy from tkinter import Tk from tkinter.filedialog import askopenfilename from cryptobase import CryptoBase from homophonic_table_creator import TableCreator from letter_distribution import LangData class HomophonicCipher(CryptoBas...
6d6448519b7b013d22cb65939f5adb57c7e45bea
Almaz97/hackerrank
/basic_data_type/find_runner_up_score.py
345
3.671875
4
if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) arr = list(arr) # arr = [2, 3, 6, 6, 5] arr.sort() maxScore = -2 ** 32 runnerUpScore = -2 ** 32 for score in arr: if score > maxScore: runnerUpScore = maxScore maxScore = score ...
8446e4342453c8e1eba78bd55047155f6df878ef
jasonkeung/general-linear-subgroup-gen
/subgroupGen.py
2,568
3.640625
4
# matrix mult function def matMult(m1, m2, mod): tl = m1[0] * m2[0] + m1[1] * m2[2] tr = m1[0] * m2[1] + m1[1] * m2[3] bl = m1[2] * m2[0] + m1[3] * m2[2] br = m1[2] * m2[1] + m1[3] * m2[3] return (tl % mod, tr % mod, bl % mod, br % mod) # inverse function mod p def invMod(num, mod): for i in r...
c8180e3280407276008b089b878d1b402eabc773
alexendrios/maratona_data_science
/python/script_python/pintando_paredes.py
457
4.03125
4
#entrada largura = float(input('Informe a largura da parede em metros: ')) altura = float(input('Informe a altura da Parede em metros: ')) #processamento area = largura * altura qtd_tinta = area / 2 #saída print('\n\t\t\tPintado Parede') print('-' * 65) print('A dimensão é {} X {} equivalente a {:.2f}m2\n' 'par...
bc92b5c4ed61e4ebc84b6b5e9f15200a92ee746f
rlowrance/mlpack
/module_softmax.py
1,588
3.515625
4
'''softmax FUNCTIONS output(values) --> probs gradient(probs) --> vector ARGS probs : np.array 1d size s values: np.array 1d size s vector: np.array 1d size s ''' import numpy as np import unittest import pdb def softmax(): '''softmax_k = exp(input_k) / sum_k exp(input_k)''' def output(input): # gu...
b463a0f17d11c1a343017a48830d706c0cfb066b
ericjohnlucas/samplecode
/primes.py
1,350
4.28125
4
#This method will print the sum of all primes up to the integer n provided def primeSum(n): #We initially set the sum of primes to 0, and initialize an empty list to store the primes as we find them sum=0; primelist=[] #We iterate from 2 up to n and add each prime number found to the sum for ...
f25d2e8ea2788f5504affefea82a8a17bf3205d8
diogoaj/cryptopals
/set2/challenge10/solve.py
2,971
4
4
""" Implement CBC mode - https://cryptopals.com/sets/2/challenges/10 CBC mode is a block cipher mode that allows us to encrypt irregularly-sized messages, despite the fact that a block cipher natively only transforms individual blocks. In CBC mode, each ciphertext block is added to the next plaintext block before the...
6792cb05fdeb40f1060152b0b82fb3887682e67c
davidLM20/fp-utpl-18-evaluaciones
/eval-parcial-primer-bimestre/ejercicio1.py
327
3.734375
4
# se pide los valores para las variables de longitud y ancho ancho=float(input("Ingrese la longitud\n")) longitud=float(input("Ingrese el ancho\n")) if ancho > 0 and longitud >0 : superficie=(longitud * ancho) #se presenta el resultado print("La superficie de la habitacion es de: {0} metros cuadrados".format(superf...
0363872818be912cb386a805366d7656ee1c4638
jeneferjene/guvi_set1
/vowel.py
352
4.125
4
while(True): ch = input("") if((ch >= 'a' and ch <= 'z') or (ch >= 'A' and ch <= 'Z')): if((ch == 'a') or (ch == 'e') or (ch == 'i') or (ch == 'o') or (ch == 'u')): print("Vowel") else: print("Consonant") elif(ch >= '0' and ch <= '9'): print("invalid") ...
fd266cd6a88a8d620cea0f997e31ba6764e0beb2
badlydrawnrob/python-playground
/doing-math-with-python/lesson_03.py
520
4.03125
4
from fractions import Fraction f = Fraction(3, 4) i = 1 fi = f + i print(f) print(fi) # Using Fraction for negative exponent smallDeal = 1 / 10 ** 3 print(smallDeal) # You need to use a float to return properly fractionDeal = Fraction(1, 10) ** 3.0 print(fractionDeal) # # Complex numbers # a = 2 + 3j type(a) # R...
ded00d7d87f5c80342d9164effc118f827a07022
badlydrawnrob/python-playground
/anki/unused/purify.py
514
3.53125
4
''' Purify | Practice makes perfect.12 ''' # def purify(args): # args = list(args) # for i, n in enumerate(args): # if n % 2 == 0: # remove = args.pop(i) # print('{} removed'.format(remove)) # return args # print(purify([1, 2, 3, 4, 6, 7])) def purify(args): new_l...
842fa7ad81b7e8748cfcfa5bbe70c2c043c98d3e
badlydrawnrob/python-playground
/doing-math-with-python/lesson_08.py
547
4.15625
4
''' Converting units of measurement | pg. 88 ''' def inches(a): print( '{0} inches equals roughly {1:.2f} cm'.format(a, (a * 2.54) / 100) ) def km(a): print( '{} miles is exactly {} kilometers'.format(a, (a * 1.609)) ) inches(25.5) km(650) def celsius(a): print( 'The ...
18ad8629f7767cf8b710eac64ca8a57ed1490122
badlydrawnrob/python-playground
/python-bootcamp/milestone_one_solution.py
3,349
4.0625
4
''' Tic Tac Toe game ''' from random import randint board = [0,0,0,0,0,0,0,0,0] game_state = True announce = '' def reset_board(): global board, game_state board = [0] * 9 game_state = True def horizontal_board(board): board = [board[i:i + 3] for i in range(0, len(board), 3)] return board d...
1a9fbdde19fb109e191c15f87eaeb791bac6fb42
badlydrawnrob/python-playground
/anki/added/sorted.py
802
4.1875
4
''' Median sorted() | Practice makes perfect.15 ''' def median(args): new_list = sorted(args) print('{} converted to {}'.format(args, new_list)) length_of_list = len(new_list) # Using floor gives a whole number, # as well as rounding down, so 7 / 2 = 3.5 becomes '3' # - This gives us the midd...
9783877b43588ac4862a55fd5bd1644fa4cbbb13
badlydrawnrob/python-playground
/anki/added/reverse.py
770
4.1875
4
''' Reverse | Practice Makes Perfect.7 ''' def reverse(text): current = 0 reverse = [] for c in text: reverse.insert(current, c) current = reverse.index(c) return ''.join(reverse) print(reverse('this@2!')) def reverse_slowly(text): reversed_text = '' slicing = len(text) ...
d81f7bdea707d3aa6f888ba2bf9bc5b4529299e2
oldacre/Who-The-Hill
/image.py
2,236
3.53125
4
import requests from io import BytesIO from face import Face class Image: """ A class to store an image and its facial recognition information in a non-json-dependent form """ def __init__(self, image_url='', image_file=None): self.image_url = image_url self.image_file = image_fil...
70837404fb1f29748079be8a39b2a51ec8264abf
CognitiveComputationLab/cogmods
/propositional/student_projects/Kaltenbrunn2020/models/Baseline/giessl/data_structures.py
7,365
4.03125
4
from enum import Enum class ChoiceClasses(Enum): logic = 1 if_to_iff = 2 or_to_and = 3 iff_to_if = 4 nothing = 5 negative_literal_premise = 6 atmospheric = 7 ignore_not = 8 anti_atmospheric = 9 not_classified = 10 class PremiseTree: """ Class representing premises a...
c77cc638c95cd1f92f2a6dff9e493cb105cb20e5
CognitiveComputationLab/cogmods
/relational/student_projects/2020_karkkainen/models/cognitive/prism/spatialreasoner/model_builder.py
9,300
3.84375
4
#------------------------------------------------------------------------------- # Name: Spatial Reasoning Model Builder # Purpose: Module of functions which create new models and add # items to existing models. # # Author: Ashwath Sampath # Based on: http://mentalmodels.princeton.edu/progr...
ac82183d9cc9d3806f73a0250886e4b2021a1bc5
vicky-xiaoli/html
/python1/py095.py
649
3.875
4
#输入两个整数,放入到a与b变量中去,如果a>=b就将a与b中的值进行交换,否则就不交换。目的就是要让a中放的值总是小于或等于b中的数,输出 # a= int(input("输入整数:")) # b= int(input("输入整数:")) # if a >= b: # a,b =b,a #/ # # print(a,b) #结束始终都会执行此操作,故不用跟else,直接结束语句:print顶格 # #else不是必须跟if一起的 # 方法二 # a= int(input("输入整数:")) # b= int(input("输入整数:")) # if a >= b: # ...
ad81d6ae2abb5e72a71985bce990dfa81d5ce32f
vicky-xiaoli/html
/python1/乘法表10114.py
307
3.671875
4
#打印九九乘法表。 # for i in range(1,10): # for j in range(1,i+1): #第二次循环是列,跟第一次循环的次数有关 # print("%d*%d=%d" %(j,i,i*j),end = '\t') #打印乘法格式并且循环结束后不换行。。\t 是自动对齐 # print() #循环一次结束后换行
5036fdffd0420e9ea1963e5c76fa66ce0732cbbc
vicky-xiaoli/html
/python1/py091.py
715
4.1875
4
#从键盘接收一个输入,输入成绩,当输入的成绩在60以下时,打印不及格,60-79打印及格,80及以上打印优秀 degree = int(input("请输入成绩:")) #必须转换成整型,字符型是一个一个比较,不合适此处。→数字比较都要转换成数字 # if degree >= 80: #if语句的运用 # print("优秀") # elif degree >= 60: # print("及格") # else: # print("不及格") ##2根据上题循环输入成绩 # while True: #判断真假,死循环的运用 # degree = int(input("请输入成绩:"...
07ece7c38ee303e4c2c7b54e0a2a349db5aa717b
liyi54/python-refresher
/loops.py
206
3.640625
4
friend_list = ['Zoe', 'Saldana', 'Kunle', 'Bada', 'Tolu', 'Gafar', 'Tobi', 'Asa', 'Jackson', 'Leyla'] for f in friend_list: invite = "Hi " + f + "," + "\nYou are invited to my party." print(invite)
2812364f02b291b0e3c4e2116c1d87ad2fd79c1f
liyi54/python-refresher
/linked_lists.py
1,157
3.953125
4
class Node: def __init__(self, cargo=None, next=None): self.cargo = cargo self.next = next def __str__(self): return str(self.cargo) def print_list(self): while self is not None: print(self.cargo, end=' ') self.cargo = self.next print() ...
d9808227b81f32036e8700e41a217b060c9bec15
liyi54/python-refresher
/Exercises.py
2,166
3.859375
4
# for i in range(1000): #Basic for loop # print("We like Python's turtles!") # xs = [12, 10, 32, 3, 66, 17, 42, 99, 20] #for loop with square # for i in xs: # square = i ** 2 # print(str(i), str(square)) # total = 0 # Rolling sum # for i in xs: # total += i # i += 1 # print(str(total)) # p...
8c37c2a25f301c6fe61b82b126dd1a0786ccc346
liyi54/python-refresher
/dicts.py
913
3.65625
4
import unit_tester as ut alreadyknown = {0: 0, 1: 1} def fib(n): if n not in alreadyknown: new_value = fib(n-1) + fib(n-2) alreadyknown[n] = new_value return alreadyknown[n] print(fib(100)) letter_counts = {} word = "ThiS is String with Upper and lower case Letters" p_word = "".join(word.sp...
b8a1a24f5500b5042480d03a5a6b3321cba621d4
KamphuisAlex/whatsappwordcount
/process_iphone.py
2,181
3.609375
4
# open chat file f = open('chat.txt', 'r') # place to store all lists msgs = [] # list of all messages afzs = [] # list of all senders # function definitions def avgLength(afz, output=True): """Calculate the average length of all messages by one sender in number of characters""" count = 0 length = 0 ...
efad2ffb0707fb7f7315de2e0ab7733a4a244d00
quynhvi98/teky-course
/level2/lesson4/homework/IsoscelesTriangle.py
1,439
3.828125
4
import turtle screen = turtle.Screen() screen.bgcolor("pink") # simple equilateral triangle simpleEquilateralTriangle = turtle.Turtle() simpleEquilateralTriangle.forward(100) # draw base simpleEquilateralTriangle.left(120) simpleEquilateralTriangle.forward(100) simpleEquilateralTriangle.left(120) simpleEquilatera...
d2922bf20c2fb33aeb697efbd768a70b9791fc97
quynhvi98/teky-course
/level1/lesson4/content/example_2.py
118
3.703125
4
count = 1 print("Ban hay nhap vao 1 so nguyen") number = input() while (count >= 0): print(count) count += 1
55ae5d5b3b1e6fc9f3683eb91fe71e4b7b6b0ab9
quynhvi98/teky-course
/level1/lesson4/hw/hw_6.py
185
3.953125
4
x = 1; s = 0 while (x < 10): s = s + x x = x + 1 if (x == 5): break else: print('The sum of first 9 integers : ', s) print('The sum of ', x, ' numbers is :', s)
0ee42d2d0852aeb92cfd0b183512fb57dfb7d6ad
quynhvi98/teky-course
/level2/lesson5/AttendanceTool.py
2,368
3.828125
4
from turtle import * sc = Screen() pen = Turtle() pen.ht() border = Turtle() border.ht() border.speed(0) # mot so ham ho tro def make_square(pen, x, y, width, color="white", text=""): pen.penup() pen.color('black') pen.setpos(x, y) pen.pendown() # pen.begin_fill() pen.setpos(x + width, y) ...
3f3bddbbef5539546931760af85c8428e0f87dc5
quynhvi98/teky-course
/level1/lesson6/practice/__init__.py
424
3.546875
4
""" Yêu cầu: Viết chương trình Python thực công việc sau: - Nhập vào số nguyên n - In ra các số """ # Nhập số nguyên n n = int(input("Nhập n=")) i = 0 tong = 0 while i: if i % 3 == 0 or i % 5 == 0: tong += i print(i) i += 1 # Tổng print("Tổng các số chia hết cho 3 hoặc 5:", ton...
4744c4bfe7221380ede40a7616765527374ace44
quynhvi98/teky-course
/level1/lesson2/cast_type.py
367
3.53125
4
age = 22; #ép sang float floatAge = float(age) print(type(floatAge)) #ép sang integer intAge = int(age) print(type(intAge)) #ép sang chuỗi strAge = str(age) print(type(strAge)) """ Học viên Teky: - Lập trình và phát triển ứng dụng - Robot và điện tử tự động - Công nghệ 3D và phương tiện truyền t...
363b45bdf16cc476f5f3ff56be70ae7b24c43dcc
tantp/test
/testhundred.py
555
3.859375
4
#!/usr/bin/env python2.7 number=int(input('Enter an integer:')) if number<=100: print('You number is less than or eaual to 100') else: print("Your number is greater than 100") w=20 while w>1: print('w={}'.format(w)) w-=1 amount=float(input("Enter amount: ")) #shurushue inrate=float(input("Enter inrate rate:...
a45f720e8c71295819370fdcdfadfee44ff5ca5c
asnydernfv/html-python-course
/Python/10_functions/10_functions.py
362
3.921875
4
def capitalize(word): new_word = word[:1].upper() + word[1:] return new_word print(capitalize('hello')) def count(number): if hasattr(number, '__round__') and not hasattr(number, 'is_integer'): i = 1 while i <= number: print(i) i+=1 else: raise TypeErro...
713b202a49af01936e624310748d45fe0c335ac0
tusharsadhwani/leetcode
/subsets_alt.py
752
3.5625
4
from typing import Callable, Optional class Solution: def subsets(self, nums: list[int]) -> list[list[int]]: subsets: list[list[int]] = [[]] for num in nums: subsets_with_num = [subset + [num] for subset in subsets] subsets += subsets_with_num return subsets tes...
03c9c55c7caeb93d8a128985daed772a4c126e8a
tusharsadhwani/leetcode
/rotate_array.py
650
3.546875
4
from typing import Callable class Solution: def rotate(self, nums: list[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ for _ in range(k): nums.insert(0, nums.pop()) tests = [ ( ([1, 2, 3, 4, 5, 6, 7], 3), [5, 6...
314b22a170affc37f14fa069224d51829a6216c7
tusharsadhwani/leetcode
/odd_even_linked_list.py
2,286
3.96875
4
from typing import Callable, Optional class ListNode: def __init__(self, val: int) -> None: self.val = val self.next: Optional[ListNode] = None def __repr__(self) -> str: return f'{type(self).__name__}({self.val})' def create_node_list(values: list[int]) -> ListNode: """Creates ...
711c34ed3776cd55449342023c14805fa0c1aa83
tusharsadhwani/leetcode
/edit_distance.py
2,760
3.71875
4
# # Solution 1 - Recursion # class Solution: # def minDistance( # self, # word1: str, # word2: str, # index1: int = 0, # index2: int = 0, # ) -> int: # # Base cases: if one word is empty, the answer is the length of the other word # if ...
28320f431ad160a7d27fb55e90d3d5f45ef54155
tusharsadhwani/leetcode
/best_time_to_buy_and_sell_stock.py
618
3.609375
4
class Solution: def maxProfit(self, prices: list[int]) -> int: # Approach: keep track of the highest price in the future, # and iterate backwards to find the largest difference. max_price = prices[-1] max_profit = 0 for price in reversed(prices): if price > max_pr...
c7fb1650bfa564f967851bcb95b02a266f34b2e1
tusharsadhwani/leetcode
/merge_sorted_array.py
1,289
3.59375
4
from typing import Callable class Solution: def merge(self, nums1: list[int], m: int, nums2: list[int], n: int) -> None: """Do not return anything, modify nums1 in-place instead.""" pos1 = m - 1 pos2 = n - 1 endpos = len(nums1) - 1 while pos1 >= 0 and pos2 >= 0: ...
cec2448f66ff03c32b647550c0c888b5327e6aa7
tusharsadhwani/leetcode
/coin_change_alt.py
3,233
3.625
4
from collections import defaultdict import sys # # Method 1 - Recursive: Stack Overflow # def coin_change(coins: list[int], amount: int, index: int = 0) -> int: # if index >= len(coins): # return sys.maxsize # # coin = coins[index] # # # Base cases: # if amount < 0: # return sys.maxsize...
03225ca20792578e87e42810fe1d97e7390a98aa
tusharsadhwani/leetcode
/merge_intervals.py
1,161
3.75
4
class Solution: def merge(self, intervals: list[list[int]]) -> list[list[int]]: intervals.sort() new_intervals: list[list[int]] = [] prev_interval = intervals[0] for index in range(1, len(intervals)): interval = intervals[index] # If the intervals are in asc...