blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5b447e06d1bd2595518c0b2dbaed58d2270a67e6
philipzhou2009/coding
/python/01xx/0124/solution01.py
949
3.875
4
# https://leetcode.com/problems/binary-tree-maximum-path-sum/ from typing import List logger = print if False else lambda *arg: None # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right ...
5a77753620b796d0b7d2e24535b166eaae9aa6f2
philipzhou2009/coding
/python/02xx/0204/solution01.py
801
3.9375
4
# https://leetcode.com/problems/count-primes/ from typing import List logger = print if True else lambda *arg: None class Solution: def countPrimes(self, n: int) -> int: if n < 2: return 0 primeList = [] result = 1 for i in range(3, n, 2): bTmp = isPrime...
47a4b05a7d9c8c1a8b7b798cd3adff5f821ae66a
philipzhou2009/coding
/python/01xx/0166/solution01.py
1,423
3.71875
4
# https://leetcode.com/problems/fraction-to-recurring-decimal/ from typing import List logger = print if True else lambda *arg: None class Solution: def fractionToDecimal(self, numerator: int, denominator: int) -> str: f1 = numerator / denominator logger("f1=", f1) s1 = str(f1) ...
d112f5bf00bebaeea1c841d7d1de6987831cfeac
picard2409/optimization_competion
/FIND.py
245
3.5625
4
#ๅฏปๆ‰พไธ‹ไธ€ไธชๆœๅŠก็‚น def node(truck,route,remain,la,iteration): M=2 if truck.type==1: #ไธๅŒ็ฑปๅž‹่ฝฆ็š„่ฝฝ้‡้‡ๅ’Œไฝ“็งฏ Q=2 V=12 else: Q=2.5 V=16 if iteration<M: return route,remian,
be2c0ccb11df283ac3722cecd3153ca8e5b3bc6d
odanielb/Mascota
/turtle_user_input.py
14,206
4.25
4
#------------------------------------------------------------------------------- # Name: turtle_user_input.py # Purpose: This module handles all the keystroke listening for listening for user # input on the Turtle screen. It handles only the basic letters (Upper and # lower) as well as numbers. It also ena...
fb4ad069bc46e86c35e2ef76773f1be3f6ddc2c0
HenrryHernandez/Python-Projects
/DataStructuresUdacity/List-Based Collections/linkedList.py
2,070
3.984375
4
class Element: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self, head=None): self.head = head def printAllList(self): current = self.head if self.head: print(current.value) while current.next...
47574a7c69b9fd6bc5415215e7f57ec682663310
HenrryHernandez/Python-Projects
/DataStructuresUdacity/Searching and Sorting/binarySearch.py
922
3.5625
4
from math import log2, ceil arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] def binary_search1(input_array, value): low = 0 high = len(input_array) - 1 loop = ceil(log2(high)) if isinstance(loop, int): loop += 1 for...
28cb113f382a036ae44fa37a27ccdcfce7fe896c
HenrryHernandez/Python-Projects
/DataStructuresUdacity/Searching and Sorting/bubbleSort.py
310
4.09375
4
arr = [7, 9, 4, 13, 13, 5, 9, 8, 12, 11, 2, 1, 13, 10] def bubbleSort(array): n = len(array) - 1 for i in range(n): for j in range(n - i): if array[j] > array[j + 1]: array[j], array[j + 1] = array[j + 1], array[j] print(array) bubbleSort(arr)
7b442ec6d4f2e1bc423658a934646c6c19c465be
HanJeongSeol/crawler_practice
/์Šคํฌ๋ ˆ์ดํ•‘_test.py
533
3.5
4
from bs4 import BeautifulSoup html = """ <html><body id = "main"> <h1 class = "str"> ์Šคํฌ๋ ˆ์ดํ•‘์ด๋ž€?</h1> <p1>์›น ํŽ˜์ด์ง€๋ฅผ ์ถ”์ถœํ•˜๋Š” ๊ฒƒ</p1> <p2>์›ํ•˜๋Š” ๋ถ€๋ถ„์„ ์ถ”์ถœํ•˜๋Š” ๊ฒƒ</p2> </body></html> """ soup = BeautifulSoup(html, 'html.parser') # h1 = soup.html.body.h1 # p1 = soup.html.body.p1 # p2 = soup.html.body.p2 h1 = soup.select_one("...
fad6f5e8ac3503b2fc042f2c9dab64e89969e1a7
SebGeek/Kenobi
/assistant/led_button.py
1,162
3.5
4
#!/usr/bin/python # -*- coding: utf-8 -*- import RPi.GPIO as GPIO import time GPIO_BLUE_BUTTON = 20 GPIO_RED_BUTTON = 21 GPIO_LED = 26 led_state = False def change_led_state(_): global led_state led_state = not led_state GPIO.output(GPIO_LED, led_state) def power_off_led(_): global led_state l...
968c3a2fd452579d7eef1b31e1dec49c3741d7d4
twairball/nn_from_scratch
/nn.py
2,508
3.65625
4
""" Neural Network from scratch. License MIT, all rights reserved jerry liu @twairball """ import numpy as np # input and outputs X = np.array([[0,0,1],[0,1,1],[1,0,1],[1,1,1]]) # shape: (4, 3) Y = np.array([[0,1,1,0]]).T # shape: (4,1) # regularization term, or learning rate lr = 0.0001 # number of training iterat...
d4bd234e8efca2fceea42991cdc12abfc7a3fa3c
codesigned4/Data-Analysis-with-Python
/Sea-level-predictor/sea_level_predictor.py
1,008
3.765625
4
import pandas as pd import matplotlib.pyplot as plt from scipy.stats import linregress import numpy as np def draw_plot(): # Read data from file df=pd.read_csv("epa-sea-level.csv") df.plot.scatter(x='Year', y="CSIRO Adjusted Sea Level",alpha=0.5,label="original data") years = np.arange(1880, 2050) # Fi...
7472b6028d6f266b47ebacc9abcfdac03542fd33
Crytoma/Java_Summer
/snail.py
441
4.40625
4
reachedTopOfPole = False currentHeight = 0 currentDay = 1 h = 10 a = 3 b = 2 #While we have not reached the top. while reachedTopOfPole != True: if currentHeight + a >= h: print("Ladies and gentlemen. The snail has reached the summit.") reachedTopOfPole = True else: cu...
f61e0fe2a15fa0b10ccf2f3f7ece56b67f4ef8c9
EbinJacob/HacckerRank
/ElectronicsShop.py
1,046
3.8125
4
#!/bin/python3 import os import sys # # Complete the getMoneySpent function below. # def getMoneySpent(keyboards, drives, b): # Write your code here. n=len(keyboards) m=len(drives) elem=[] flag=0 temp=0 for i in range(0,n): for j in range(0,m): temp=keyboards[i]+drives[...
a4105f9eac6e3162a88c44e3af8d87f5a27e0ac8
tlaudahl/Intro-Python-I
/src/rps.py
1,725
4.34375
4
# Create a rock paper scissors game in Python # Player should be able to type r, p, or s # Computer will pick r, p, or s # Game will print out the results and keep track of wins, losses, and ties # Type q to quit def eval_moves(player_move, cpu_move): winning_moves = {'r': 's', 's': 'p', 'p': 'r'} if play...
8b26cdf408a7672b2fbe0f9ea2558848f0687594
RizkiAsmoro/python
/Create_function.py
1,385
4.15625
4
''' How to Create Function ''' #define function def function(): print("Have a nice day") #call function function() print(20*"=","perimeter of square fuction") #define dunction and create formula def perimeter_square(a): p = a * 4 print("perimeter of a square is :",p) function() # call the function inside ...
4f5d9dd456ea5afb62078eee5e26c81a2821275e
RizkiAsmoro/python
/While_loop.py
1,026
4.0625
4
''' While Loop as long the condition TRUE, the proccess will continue ''' #While with condition a = 1 while a < 5: print("number ",a) a +=1 print("end of WHILE") print(20*"=") #While using variable boolean a = True b = 1 while a: print("number :",b) if b is 5: a = False print("number fo...
805798021b7907c774bd0023bf431f67ceb2a77c
RizkiAsmoro/python
/Variable_class.py
1,276
3.78125
4
''' Variable Class ''' #sample 1 print("================sample 1==============") class employees(): department = "Finance" #public variable owned by class def __init__(self,input_name,input_id): #all who use self. then it belongs to instances/object self.name = input_name #public self.id =...
03fa138e873a2c33897a2d0abaf2fd6f7a2c757a
RizkiAsmoro/python
/For_loop.py
657
3.953125
4
''' FOR LOOP ''' #iterable list fruits = ["mango","durian","pineapple","apple"] for x in fruits: # x is new varibale and will access each component of fruits print(x) print(len(x)) # length each of list print(20*"=") #string as iterable fruits = ["mango","durian","pineapple","apple"] durian = "durian" for i ...
aa86b666df3cef24e53dadb2774dc06befa61ed4
AlreadyAsleep/AdventOfCode_2017
/SolutionDay6.py
1,133
3.515625
4
from math import * s = input() #read input arr = s.split("\t") #split into a list arr = [int(i) for i in arr] #cast to an int list snapshot = [str(arr)] #push a snapshot of the list into another list index = 0 count = 0 seen_again = "" #used to store the first repeat we find seen...
425c9ca09c13d3202bb7ff49548f7e7d7d6984d5
guyrux/udacity_statistics
/funcoes.py
211
3.71875
4
def somatorio(lista): total = 0 for item in lista: total += float(item) return total def produtorio(lista): total = 1 for item in lista: total *= float(item) return total
c5abe47f6b2a472d2bc4e261d142bd4f6f9602f9
Potokar1/Python_Review
/sorting_algorithms/bubble_sort.py
835
3.921875
4
# Parameter a is a list def bubble_sort(a): for i in range(len(a) - 1): for j in range(len(a) - 1 - i): if a[j] > a[j+1]: a[j], a[j+1] = a[j+1], a[j] return a def bubble_sort_better(a): unsorted = True decreasing_length = len(a) - 1 while unsorted: unsor...
d3569b6f121da84d89458976b83536297cf3fa59
Potokar1/Python_Review
/sorting_algorithms/selection_sort.py
929
4.15625
4
# O(n^2) # Parameter a is a list def selection_sort(a): # Iterate over the start of the list to the second last part of the list for i in range(0, len(a)-1): # This is how we keep track of the minimum value of the unsorted part of the list min_index = i # Iterate over the entire unsort...
cf98ab88e64ea68398b8a80744f38f901857d85f
omerbyzt/python
/developments/yt-ders/d3.py
121
3.75
4
""" ders 3 """ A = 5.0 B = 10 print(A + B) A = 22 B = 15 print(A / B) a = 5 b = 3 c = 10 d = 2 print((a + b) * d + c)
c1da38efc47b1cb8faaa6c31663ac643b3b6d0b0
kinshukjuneja/Information-Retrieval
/Assignment 3/UseIndex.py
2,370
3.546875
4
import re class UseIndex: def getTermID(self, term): """ param: term return: the corresponding TermID """ term = str(term) file = open("IndexFolder/TermIDFile.csv", "r") for line in file.readlines(): line = line.split(',') if line[0]...
a64e1e56337f92b43141b973c0efeb61acec763b
MichaelYadidya/Python-Begginer-Projects
/String Reverser.py
171
3.984375
4
user_input = input('Enter the text: ') def String_rev(user_input): return user_input[::-1] def main(): print('The Reversed text is: ',user_input[::-1]) return; main()
82e9befb55cd7429d5028111deacc99bf024546c
fabio-jaremciuc/real-estate-project
/real-estate-table.py
6,490
3.515625
4
import pandas as pd import numpy as np # it is necessary to change the file path df = pd.read_csv('/home/jaremciuc/data_analysis_test/assignment_data.csv') def remove_nan(): '''Removes the NaN elements from the dataset''' #replaces NaN elements by 0 df['plot_area'].fillna(0.0, inplace=True) df['total_...
e1865a6b55f674c63407ba1b30dbff0cc11bb328
BoyeDat/NEA-with-json
/SQL_handler.py
3,721
3.78125
4
from tkinter import * from tkinter import filedialog import sqlite3 import csv # key press functions #EXECUTE key press def execute(): entered_text = entry.get('1.0', 'end-1c') # collect text from the text entry box entry.delete('1.0', 'end-1c') # and clear the entry box! try: displa...
cca33f072bd7729bc0ea53d8fb9997e1eb2b650f
safaranees/set5
/lexicographical_order.py
58
3.5625
4
x=str(input()) y=sorted(x) for i in y: print(i,end="")
7622225365ce7fa566e5fcbb419123969ee23346
akashhnag/flask-restful-app
/database_connectivity/user.py
1,886
4.0625
4
import sqlite3 class User(): def __init__(self,_id,username,password): self._id=_id self.username=username self.password=password def get_user_by_username(username): print('fetch by username',username) connection=sqlite3.connect('data.db') cursor=connection.curso...
8eeb655cb003bef4db4ea81525e03d8227499dd5
denizgenc/encryption-fun
/rotemake.py
2,083
3.6875
4
# -*- coding: utf-8 -*- # rotemake.py # Makes a ROT file, using a plaintext (or any?) source file as input, and # running it through mod 26. # Usage: # python rotemake.py [-n|-a] inputfile outputfile # -n means output comma seperated integers (default) # -a means output a string of characters instead # inputfile and o...
566b03e7abe66332a29a671d95795abc197ef480
alyshareinard/Advent-of-Code-2020
/day10.py
4,230
3.515625
4
def read_data(): with open("day10.txt") as f: adaptors_db = f.read().split('\n') adaptors_db = adaptors_db[:-1] adaptors_db = [int(x) for x in adaptors_db] return adaptors_db def adaptor_combs(adaptors): adaptors.append(0) adaptors.append(max(adaptors)+3) adaptors.sort() diffs ...
e094041cc181d82ee9e5d37d5f16dc1045d58db4
alyshareinard/Advent-of-Code-2020
/day13.py
5,459
3.734375
4
import numpy as np import math def read_data(): with open("day13.txt") as f: notes = f.read().split('\n') notes = notes[:-1] ourtime = int(notes[0]) busses = notes[1].replace('x', '-1').split(',') busses = [int(x) for x in busses] return(ourtime, busses) def part1(ourtime, busses): ...
39c18680af99f06216fe06c5531e2bfef9e3dc69
zhangqqqqqq/python
/str2float.py
426
3.703125
4
# -*- coding: utf-8 -*- from functools import reduce def str2float(s): s1,s2=s.split('.') digital={'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9} def fn(x,y): return 10*x+y def char2num(s): return digital[s] return reduce(fn,map(char2num,s1))+reduce(fn,map(char2num,s2))/(pow(10,len(s2))) print(s...
3eb9c469f3627ae62795920b2d475f0233badd6e
GumpDev/PythonTutorial
/pessoas.py
1,518
4.0625
4
import sys class Pessoa: lista = [] dinheiro = 5 def __init__(self, nome, dataNascimento): self.nome = nome self.dataNascimento = dataNascimento Pessoa.lista.append(self) def info(): opcao = -1 while opcao < 1 or opcao > 4: print("Bem-vindo ao banco, escolha uma opรงรฃo:") print("1 - Novo...
30869fddb46d1971915e4a54fd19d2bfa5b8fd4b
ryan-lewin/laddergram
/word_ladder.py
5,224
4
4
#!/usr/bin/env python import re import os def match_letters(start_word, target): """ Searches for matching letters between the search word and target. Returns a list with indexes of the matching letters. """ matches = [] for(start_word_i, target_i) in zip(start_word, target): if start_word...
114a9bddc52fb444a656bded35c9b677cd0c64a3
poopingPepe/CSE5P-Intro_to_Python
/HW1_2.py
311
4.25
4
r = float(input("Enter the radius of a circle (in inches): ")) r_feet = r * 0.0833 pi = 3.1415 print("The diameter of the circle is: ","%.4f" % (r_feet*2),"feet") print("The perimeter of the circle is: ",round(r_feet*2*pi,4),"feet") print("The area of the circle is: ",round((pow(r_feet,2))*pi,4),"square feet")
b6b4a539090ebb3f8ba6c3cabd24ebbc87d12160
jespel2013/Python-Programs
/rhymes-oo.py
3,644
3.859375
4
#Name: Jesse Pelletier #Purpose: This program finds words that rhyme with a given word. #FileName: rhymes-oo.py '''An instance of this class represents a word''' class Word: def __init__(self, word, pronunciation): self._word = word self._pronunciations = [pronunciation] def getWord(se...
34e26dbc9d58f24c00485c4a92b0c1df9f2e36a4
jespel2013/Python-Programs
/battleship.py
7,728
4.21875
4
# Name: Jesse Pelletier # Purpose: This program is a model of half of the board game Battleship. It models Player 1's ship # placements and Player 2's guesses. # FileName: battleship.py # This class represents an object that represents a position on the grid. class GridPos: def __init__(self, x, y): #...
d4fa7b4539f9498969fbe6fb6efbaeb78191bbf5
JagtapAnkita/373JagtapAnkita
/Ass1_C.py
228
3.984375
4
N1=int(input("Enter the first number: ")) N2=int(input("Enter the second number: ")) print("1st Number=",N1) print("2nd Number=",N2) Add=N1+N2 Diff=N1-N2 Mul=N1*N2 print("Sum: ",Add) print("Diff: ",Diff) print("Product: ",Mul)
0e26cff9f7191668b4fb4c33d622cfd69852075d
SasikalaGV/MPP-Shop
/Python_oop/python_oop.py
17,539
4.0625
4
""" SHOP Assignment Functionality The shop CSV should hold the initial cash value for the shop. Read in customer orders from a CSV file. โ€“ That file should include all the products they wish to buy and in what quantity. โ€“ It should also include their name and their budget. The shop must be able to process the orders...
6e0676efca49591a58e9be827b336dee01aa2079
MoCuishle28/deep-learning-practice
/nn-learn/keras/boston_housing.py
3,385
3.5
4
from tensorflow.keras.datasets import boston_housing from tensorflow.keras import models from tensorflow.keras import layers from tensorflow.keras.utils import to_categorical import numpy as np import matplotlib.pyplot as plt # ๅ„ไธชๆ•ฐๆฎ้‡็บฒไธๅŒ๏ผˆๆœ‰็š„ 0~1, ๆœ‰็š„ 0~100, ้œ€่ฆๅฝ’ไธ€ๅŒ–๏ผ‰ (train_data, train_targets), (test_data, test_targets) =...
0ffe24deeaef4ad7ab9de3c92db5ca2a08aa22a2
MoCuishle28/deep-learning-practice
/numpy-learn/broadcast.py
376
3.5625
4
import numpy as np a = np.array([[1,2,3], [2,3,4], [12,31,22], [2,2,2]]) b = np.array([1,2,3]) # ๆƒณๅฎž็Žฐๆฏไธ€่กŒๅŠ ไธŠb for i in range(4): a[i,:] += b print(a) print('-------------') a = np.array([[1,2,3], [2,3,4], [12,31,22], [2,2,2]]) print(a + np.tile(b, (4,1))) print('-------------') # ๅนฟๆ’ญๅฎž็Žฐๆฏ”่พƒ้ซ˜ๆ•ˆ # ๅฏไปฅ็›ดๆŽฅ็›ธๅŠ  ...
5378c772f37f35a16b3620580777b229219b007f
MoCuishle28/deep-learning-practice
/tensorflow-learn/base.py
3,188
3.625
4
import tensorflow as tf # ๅฎšไน‰ไธ€ไธช้šๆœบๆ•ฐ๏ผˆๆ ‡้‡๏ผ‰ random_float = tf.random.uniform(shape=()) print(random_float) # ๅฎšไน‰ไธ€ไธชๆœ‰2ไธชๅ…ƒ็ด ็š„้›ถๅ‘้‡ zero_vector = tf.zeros(shape=(2)) print(zero_vector) # ๅฎšไน‰ไธคไธช2ร—2็š„ๅธธ้‡็Ÿฉ้˜ต A = tf.constant([[1., 2.], [3., 4.]]) B = tf.constant([[5., 6.], [7., 8.]]) # ๆŸฅ็œ‹็Ÿฉ้˜ตA็š„ๅฝข็Šถใ€็ฑปๅž‹ๅ’Œๅ€ผ print(A.shape) # ่พ“ๅ‡บ(2, 2)๏ผŒๅณ็Ÿฉ้˜ต็š„้•ฟๅ’Œๅฎฝ...
568706d82b2e945ec11d118be07909b69c4b048f
MoCuishle28/deep-learning-practice
/nn-learn/keras/deep-learning-best-practices/three-output-model.py
2,340
3.625
4
from tensorflow.keras import layers from tensorflow.keras import Input from tensorflow.keras.models import Model # 1ไธช่พ“ๅ…ฅ 3ไธช่พ“ๅ‡บ vocabulary_size = 50000 num_income_groups = 10 posts_input = Input(shape=(None,), dtype='int32', name='posts') embedded_posts = layers.Embedding(256, vocabulary_size)(posts_input) x = layers.C...
7c24bd8b335173eea7c8d28e6894d2085b33d317
MoCuishle28/deep-learning-practice
/PyTorch-learn/batch-train.py
919
3.5625
4
import torch import torch.utils.data as Data # ่ฟ›่กŒๅฐๆ‰นๆฌก่ฎญ็ปƒ็š„ๆจกๅ— BATCH_SIZE = 5 # ๆฏๆ‰น5ไธชๆ•ฐๆฎ # BATCH_SIZE = 8 # ่‹ฅๆฒกๆ‰นๆ˜ฏ8 ๅˆ™ๅ‰ฉไธ‹้‚ฃๆฌกไธ่ถณ็š„ๆŠŠ็”จๅ‰ฉไธ‹็š„ๅ…จ็”จไธŠ x = torch.linspace(1, 10, 10) # 1~10 ็š„ 10 ไธช็‚น y = torch.linspace(10, 1, 10) # 10~1 ็š„ 10 ไธช็‚น # ๅฎšไน‰ไธ€ไธชๆ•ฐๆฎ้›†, ่ฎญ็ปƒๆ•ฐๆฎ็š„ๆ˜ฏ ็ฌฌไธ€ไธชๅ‚ๆ•ฐ, ่ฎก็ฎ—่ฏฏๅทฎ็”จ็ฌฌไบŒไธชๅ‚ๆ•ฐๆœ‰ ? torch_dataset = Data.TensorDataset(x, y) loader = Data.Data...
c2eb93cf513a0ffafa14758aeb16b1c2f8006c08
MoCuishle28/deep-learning-practice
/numpy-learn/array.py
721
3.65625
4
import numpy as np a = np.array([1,2,3]) print(a, type(a)) # ๆ˜Ž็กฎ็กฎๅฎšๅ‘้‡ๆ˜ฏ่กŒๅ‘้‡่ฟ˜ๆ˜ฏๅˆ—ๅ‘้‡ (่กŒ, ๅˆ—) # 1 ่กจ็คบๆ•ดไธชๆ•ฐ็ป„ๅชๆœ‰1่กŒ, -1ๆ˜ฏๅ ไฝ็ฌฆ print(a.shape) a = a.reshape((1, -1)) print(a.shape) print("-------------------") a = np.array([1,2,3,4,5,6]) print(a, a.shape) a = a.reshape((2, -1)) print(a.shape) print(a) a = a.reshape((-1, 2)) print(a) ...
5fb604ac0512a22e819651316ddeaa338f1b6db7
gavinfish/Awesome-Python
/beginning-python/file/read_diff.py
189
3.546875
4
f = open('hello.txt') print(f.read()) print('---------') f.seek(0) for line in f.readlines(): print((line,'&&\n')) f.seek(0) for i in range(4): print(str(i)+":"+f.readline()) f.close()
24af7f26766be99289afd712608a42886dbd7d09
ma291265298/helloword
/nowcoder/1001.py
206
3.71875
4
num = int(input()) for i in range(num): a, b, c = input().split() if int(a) + int(b) > int(c): print('Case #' + str(i+1) + ': true') else: print('Case #' + str(i+1) + ': false')
34cf69909e835c992d0d23590241a91068a48904
ISFP1021/Lecture7inclass
/L7E2.py
217
4.28125
4
def isnumberdiv3(n): if n%3==0: return True return False num=int(input("Give me a number")) if isnumberdiv3(num): print("Number is divisible by 3") else: print("Number is not divisible by 3")
11ccb094261c389c59452ca4dd7c63d782e184fc
ISFP1021/Lecture7inclass
/L7E5.py
183
3.734375
4
def takeargs(n1='',n2='',n3=''): alist=[n1,n2,n3] print(alist) first=input("First thing?") second=input("Second thing") third=input("Third thing") takeargs(first,second,third)
ccd47f21883e5ad767b04826e45bd0ced0bb130a
AnttiStalnacke/CatRepo
/Lab/Test.py
438
4
4
__author__ = 'Antti' import time print time.time() print 'This is the testfile!!!' A = 5 B = 3 C = A + B print 'A + B is', C print 'this has nothing to do with time, yet' D = A*B print 'But it does multiplication. A times B is', D print 'And we step this as well' def fib(n): # write Fibonacci series up to n ...
53f8e38cb054b24a18c8e141961f3a64f48e7f50
albertogurpegui/Python1
/venv/Ejercicio1.py
597
3.765625
4
import random from pip._vendor.distlib.compat \ import raw_input def funcionBuscar(numeroAleatorio): valor = False while not valor: print("Introduzca un numero:") print(numeroAleatorio) numero = int(raw_input()) if numero == numeroAleatorio: print("Has acertado") ...
8cd164345050b05f777d11c15b7dc5a22421c025
alanrgo/code_challenges
/Basic/pair_with_sorted_array/pair_with_sorted_array.py
1,570
3.734375
4
# https://practice.geeksforgeeks.org/problems/pair-with-given-sum-in-a-sorted-array/0 # You are given an array A of size N. You need to find all pairs in the array that sum to a number K. # If no such pair exists then output will be -1. The elements of the array are distinct and are in sorted order. # Note: (a,b) and ...
6f41ab09a6f687243b91d30191188fc93bd9f7f3
rohanlekamge/Histogram-for-Exam-Marks
/Part D - Vertical Histogram/Part 1.D - Vertical Histogram (extension) (Optional).py
3,498
4.25
4
#Part D: Vertical Histogram (Extension) count = 0 #this count is used to print the total number of students who had written the exam. total = 0 #this is used to find the average marks of these students target = 0 #i have used this count to print number of students who got marks above 40 histogram = 0 count1 = 0 ...
17d30d2c27e79bbeb3df3a86932c7a33b1d349a4
fenekku/code-samples
/sudoku.py
1,864
3.640625
4
def square_elements(row, col, puzzle): t = (row / 3) * 3 l = (col / 3) * 3 return set([e for r in puzzle[t:t+3] for e in r[l:l+3]]) def col_elements(col, puzzle): return set([row[col] for row in puzzle]) def row_elements(row, puzzle): return set(puzzle[row]) def choices(row, col, puzzle): p...
5b10a4f809c958c49b874c8854b02df1ca13e3b6
Maram-Ankir/madlib-cli
/madlib_cli/madlib_cli.py
1,359
3.828125
4
import re print(""" Welcome to Madlib Game MadLibs game is key words replaced with blanks. ... One player asks the other players, in turn, to contribute a word of the specified type for each blank, but without revealing the context for that word. """) input_list=['Adjective','Adjective','A First Nam...
9857f36b4b963baa2517eba459c2f2a5cbce6275
KnightsTiger/pluralsightUnderstandingMachineLearningwithPython
/3Molding.py
1,262
3.96875
4
#loading data import pandas as pd # pandas is a dataframe library import matplotlib.pyplot as plt #Reading data from CSV #This will read the entire file. df = pd.read_csv("pima-data.csv") #---------------------------------------------------------------------------------------------- # Converting e...
cb3296df7d1ecedc8dee10d8742b4491ad18db15
NazarTTW/Vstup-Lab-1-2-3-4-5
/ะ›ะฐะฑะฐ 3.py
80
3.75
4
world = str(input("Enter world:")) text = ''.join(reversed(world)) print(text)
4486e69123039fd7dc6a727b4751d19c7c33f9f0
Carloslee96/Indoor-Localization
/Data_Processing/calculate_loc_final.py
2,709
3.65625
4
''' By Zhenghang(Klaus) Zhong With data structure of samples X time_steps X features, and the time steps are created by sliding Window, which means there are a lot of repeating data in input as well as output, the data sample is like (if with one feature): [1 2 3 4 5 6 2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9] The o...
7b9d505309d75f278d642f50313f78dbfc26f231
papicheng/hash_c
/python/hashset.py
1,732
3.65625
4
from enum import Enum import config class hashset: def __init__(self): # TODO: create initial hash table self.verbose = config.verbose self.mode = config.mode self.size = config.init_size # Helper functions for finding prime numbers def isPrime(self, n): ...
ea3985b21d95898911e5035e7dea124867e98a63
dzhelek/Antony-Yoan
/Dungeons and Pythons/test_treasure.py
980
3.578125
4
import unittest from treasure import Treasure, Weapon, Spell # class TestTreasure(unittest.TestCase): # def test_init_treasure(self): # t = Treasure.get_random_treasure() # self.assertIsInstance(t, Treasure) class TestWeapon(unittest.TestCase): def test_init_weapon(self): name = "Th...
f65ee274990eb6bad4d6fa442b09eb51dd785f00
JOliveira-Py/assessment
/mail_25Sep19/headNtail.py
212
3.671875
4
def headNtail(aux): for i in range(len(aux)): if aux[i] != aux[0-i-1]: return False return True print("Please enter the sequence of characters: ") seq = input() print(headNtail(seq))
8dc3df34138c623e8a331c16ddaa3fd252ca4607
Jcarlos0828/py4eCourses-excercisesCode-solved
/Using Python to access Web Data/Week 5/ExtractXML_Assignment.py
1,140
4.15625
4
#Code Author: Josรฉ Carlos del Castillo Estrada #Excercise solved from the book "Python for Everybody" by Dr. Charles R. Severance #Following the Coursera program "Using Python to access Web Data" by the University of Michigan ''' Following the given URL (XML), extract from the tag <count>, to sum the numbers inside ...
f68ed779007b574c45e5921a424456dbb9720365
Jcarlos0828/py4eCourses-excercisesCode-solved
/Python Data Structures/Week 5/GroupInDicts_A9.2.py
850
4.03125
4
#Code Author: Josรฉ Carlos del Castillo Estrada #Excercise solved from the book "Python for Everybody" by Dr. Charles R. Severance #Following the Coursera program "Python Data Structures" by the University of Michigan ''' Program to find all sentences that starts with "From " to obtain the emails and store them in a d...
d4ebe64eb68d1f9778b4d5f78285202cc305457a
fxweidinger/codingquestions
/dailycodingproblem_23052019.py
544
3.796875
4
#Given a list of numbers and a number k, return whether any two numbers from the list add up to k. #For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. #Bonus: Can you do this in one pass? listA=[10,15,3,7,5,90,15,8,9] def findSolution(lst,k): for x in range(0,len(lst)): ...
b150676a8b9fc6e524f442413e95c9699f50a103
bridgecrew-perf7/sphinx-documenter-deploy
/src/sphinx_documenter_deploy/core.py
390
3.578125
4
# -*- coding: utf-8 -*- __all__ = ["my_cool_function"] import numpy as np def my_cool_function(a: np.ndarray, b: np.ndarray) -> np.ndarray: """This is a clever function that adds two numpy arrays Args: a (np.ndarray): The first array b (np.ndarray): The second array (shocker!!) Returns...
2ee9251c81671622b5f2b7bcc2690993218a5170
lucassilva-dev/codigo_Python
/ex043.py
762
3.78125
4
peso = float(input('Qual รฉ o seu peso? KG: ')) altura = float(input('Qual a sua altura? M: ')) imc = peso / (altura**2) if imc < 18.5: print(' IMC Abaixo de 18,5.Vocรช esta com imc abaixo do seu peso seu imc รฉ {:.1f}'.format(imc)) elif imc >= 18.5 and imc <= 25: print('IMC entre 18,5 e 25.Vocรช esta no peso...
4bb724c74c4509a8944bb2fb938f39cb25adbce6
lucassilva-dev/codigo_Python
/ex070.py
867
3.578125
4
print('=' * 40) print('{:^40}'.format('LOJA DO LUCรƒO')) print('=' * 40) total = mil = nome = menor = 0 while True: produto = str(input('Nome do produto: ')).strip() preco = float(input('Preรงo: R$ ')) total += preco if preco > 1000: mil += 1 if menor == 0: menor = preco ...
ca5e2983f5b03aa76a6994174b5679d4b1554349
lucassilva-dev/codigo_Python
/ex039.py
691
3.984375
4
from datetime import date sexo = int(input('''Qual o seu sexo? tecle [1] para masculino tecle [2] para feminino opรงรฃo: ''')) ano = int(input('Qual o seu ano de nascimento? ')) anoatual = date.today() idade = anoatual.year - ano if sexo == 1 and idade < 18: print('Ainda falta {} ano(s) para vocรช se alistar ...
5ffc0ccc8021ea871e0df8ebd5ecd2dfd1c430c8
lucassilva-dev/codigo_Python
/ex016.py
152
3.90625
4
import math n1 = float(input('Digite um valor de um nรบmero real: ')) real = math.trunc(n1) print('O valor inteiro de {} รฉ {}'.format(n1, real))
69cb26ac6953f08968eefaf775f21917e965a041
lucassilva-dev/codigo_Python
/ex037.py
621
4.03125
4
numero = int(input('Qual o valor do nรบmero ? ')) print('Entendi, legal vocรช escolheu o nรบmero {}'.format(numero)) conversao = int(input('Digite 1 para binรกrio, 2 para octal ou 3 para hexadecimal, qual conversรฃo vocรช quer? ')) if conversao == 1: print('Ok o seu nรบmero convertido para binรกrio fica {}.'.format(bin...
b42c52262c21ef1281ae2f62653099abbd5aa98e
lucassilva-dev/codigo_Python
/ex014.py
170
3.921875
4
n1 = float(input('Me informe quantos Graus celsius vocรช deseja converter para farenheit C: ')) print('{}ยฐC convertido em farenheit fica {}Fยฐ'.format(n1, (n1*9/5)+32))
d9eb429c0582a5ba04684edcf02c5c19371850ec
lucassilva-dev/codigo_Python
/ex026.py
291
3.984375
4
frase = str(input('Digite uma frase qualquer:')).strip().upper() print('Na sua frase aparece a letra "A" {} vezes'.format(frase.count('A'))) print('A primeira posiรงรฃo do A aparece em {}'.format(frase.find('A'))) print('A รบltima posiรงรฃo do A aparece em {}'.format(frase.rfind('A')))
36c517b38c944476b0142492d6b824ca2867a75b
lucassilva-dev/codigo_Python
/ex038.py
365
3.953125
4
n1 = int(input('Qual o valor do primeiro nรบmero ? ')) n2 = int(input('Qual o valor do segundo nรบmero ? ')) if n1 > n2: print(' o primeiro valor {} รฉ maior que {}'.format(n1, n2)) elif n2 > n1: print(' o segundo valor {} รฉ maior que {}'.format(n2, n1)) else: print('Nรฃo existe valor maior, o valor {} e...
6cb38fa2e931f2faf6ac59f53002e89616abfae2
lucassilva-dev/codigo_Python
/ex083.py
268
3.875
4
pilha = 0 expr = str(input('Digite a expressรฃo: ')) for cont in expr: if cont == '(': pilha += 1 elif cont == ')': pilha -= 1 if pilha == 0: print('Sua expressรฃo esta correta') else: print('Sua expressรฃo esta errada')
966c581ef2cebf37da137b9c359536d80b73b9f7
lucassilva-dev/codigo_Python
/ex032.py
176
3.9375
4
ano = int(input('Digite um ano qualquer que vou dizer se ele รฉ bissexto ou nรฃo ')) if ano%4==0: print('ร‰ um ano bissexto') else: print('Nรฃo รฉ um ano bissexto')
4595aaa16d4c662abf15371977918a2aae039699
AlexeyNigin/csprag-w19-rpn
/rpn.py
1,717
3.96875
4
#!/usr/bin/env python3 class CalculatorError(Exception): pass def add(stack): if len(stack) < 2: raise CalculatorError("stack underflow during addition") b = stack.pop() a = stack.pop() stack.append(a + b) def subtract(stack): if len(stack) < 2: raise CalculatorError("stack underflow during subtraction")...
9232ecc61d428763aa171b44e32fb9503e44a1ec
cghiaus/PyCloze
/PyClz02.py
8,073
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 28 11:57:20 2021 @author: cghiaus Creates PyClz02.xml file for the following problem in which the input data is between * * the embedded answers are between { }: ------------------------------------------------------------------------------- Evalua...
f66cbfc2c4dea7e6f9ede539da311f1567c31930
kingjhay/workshop4
/2.py
1,798
3.84375
4
# ex 1 string_upper_list = [] string_list = ["jae", "zeus", "jaem", "marc", "ryu"] for string in string_list: # string jae string_upper_list.append(string.upper()) #string JAE print("string_upper_list", string_upper_list) string_list = ["jae", "zeus", "jaem", "marc", "ryu"] string_upper_list = [string.upper(...
932ec3d080b97d7047e41b7c32d8b20bf9ab17f0
Mikelmx/Salary-increase
/p7.py
577
3.96875
4
''' Michael Mcmanimon project 7 ''' #read the input starting salary salary = float(input("Enter starting salary: ")); #read the input percentage increase increase_percent = float(input("Enter percentage increase: ")); #read the input number of years increase years = int(input("Enter number of years in the schedul...
779bd1bfd67d42c6b4a5c2cee3b019d3fbae455a
ahrav/Coding_Dojo_Assignments
/python_fundamentals/comparing_arrays.py
152
4.15625
4
list_one = [1,2,5,6,2] list_two = [1,2,5,6,3] if list_one == list_two: print "they are the same list" else: print "they are not the same list"
0d3968777ecbf578ae4ff7eac0120d73f4c4fb75
ahrav/Coding_Dojo_Assignments
/python_fundamentals/filter_by_type.py
472
3.65625
4
import types vars = 45 isinstance(vars, (int)) if vars >= 100: print "thats a big number" else: print "that's a small number" strings = "experience is simply the name we give to our mistakesssssssssss" isinstance(strings, (str)) if strings >= 100: print "thats a long string" else: print "thats a short ...
89db1e78889154f55fe9d0f38850b48a333bb77d
ahrav/Coding_Dojo_Assignments
/Python_OOP/MathDojo.py
691
3.703125
4
class MathDojo(object): def __init__(self): self.number = 0 def add(self, *nums): for num in nums: if type(num) == list or type(num) == tuple: for val in num: self.number += val else: self.number += num return s...
dcfdcda8964d9a0de47c6126fff195624aa45b41
marquesarthur/programming_problems
/interviewbit/interviewbit/btree/is_identical.py
1,091
3.828125
4
class Btree(object): def __init__(self, value): self.value = value self.right = None self.left = None def add(self, value): if value < self.value: if not self.left: self.left = Btree(value) else: self.left.add(value) ...
7f4e0cd3e2f3e0c86d5ef24532148160b32d57a6
marquesarthur/programming_problems
/leetcode/arrays/majority_element.py
363
3.71875
4
class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int """ nums = sorted(nums) return nums[len(nums) / 2] # Input: nums = [3,2,3] # Output: 3 print(Solution().majorityElement(nums)) # Input: nums = [2,2,1,1,1,2,2] # Output...
cb2c8ce597598d8818f2cdf08fbc03cdae9c3f70
marquesarthur/programming_problems
/interviewbit/interviewbit/arrays/largest_number.py
567
3.65625
4
def compare(x, y): v = long(str(x) + str(y)) w = long(str(y) + str(x)) if v > w: return 1 elif v < w: return -1 else: return 0 class Solution: def sort_values(self, values): return sorted(values, cmp=compare, reverse=True) # @param A : tuple of integers ...
c45440edd038b0b59737d75aa641157f799e8486
marquesarthur/programming_problems
/leetcode/amazon/2020/k_largest_element.py
767
3.671875
4
class Solution(object): def __insert_in_stack(self, num, k, stack): if len(stack) >= k: _min = stack[0] if num < _min: return else: stack.pop(0) stack.append(num) stack.sort() return def k_largest(self,...
ce7ac6a0aded7ebce24208be50b697bcba9f72cb
marquesarthur/programming_problems
/leetcode/amazon/2020/connect_ropes.py
1,473
4.25
4
""" Given n ropes of different lengths, we need to connect these ropes into one rope. We can connect only 2 ropes at a time. The cost required to connect 2 ropes is equal to sum of their lengths. The length of this connected rope is also equal to the sum of their lengths. This process is repeated until n ropes are conn...
33e4a8bb17ed28e7c50b4e55fb73779d2ca7a9b3
marquesarthur/programming_problems
/interviewbit/test/test_find_duplicate.py
667
3.59375
4
import unittest from interviewbit.arrays import find_duplicate class TestPlusOne(unittest.TestCase): def test_one_duplicate(self): s = find_duplicate.Solution() A = [1, 2, 3, 2] B = 2 result = s.repeatedNumber(A) self.assertEqual(result, B) def test_two_duplicates(sel...
934433148038ddb73f1b3b5049570cb279af84c1
marquesarthur/programming_problems
/interviewbit/interviewbit/math/grid_unique_paths.py
421
3.546875
4
class Solution: fact = {} def factorial(self, n): x = 1 for i in range(1, n + 1): x *= i return x # @param A : integer # @param B : integer # @return an integer def uniquePaths(self, A, B): x = A + B - 2 right = A - 1 down = B - 1 ...
12b561c9caf2df324211bbcf684984ce841461ea
marquesarthur/programming_problems
/data_structures/graph.py
935
3.78125
4
class Edge(object): def __init__(self, to, weight): self.to = to self.weight = weight class Vertex(object): def __init__(self, value, edges=[]): self.value = value self.edges = edges class Graph(object): def __init__(self, vertexes): self.vertexes = vertexes a, ...
f49fd80a7f12bff77e9a8df8bf1f68ce552d525b
marquesarthur/programming_problems
/leetcode/twitter/pigeon.py
733
3.78125
4
def knapsack(n, values, weights, W): K = [[0 for x in range(W + 1)] for y in range(n + 1)] for i in range(n + 1): for w in range(W + 1): if i == 0 or w == 0: K[i][w] = 0 elif weights[i - 1] <= w: K[i][w] = max( values[i - 1] + ...
d404b2b4adf540eab538fafd10ced08b01e4b161
marquesarthur/programming_problems
/leetcode/arrays/rotate_array.py
656
3.515625
4
class Solution(object): def rotate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: None Do not return anything, modify nums in-place instead. """ if k == 1: return nums if k > len(nums): k = k % len(nums) # a = ...
50cd28790084f78b8a0e46c5b92c5a77eea0ff84
marquesarthur/programming_problems
/interviewbit/interviewbit/tall/find_word_brute.py
1,249
3.78125
4
# Brute force approach! def findWord(rules): precedence_map = {} letters = set() for r in rules: left, right = r.split(">")[0], r.split(">")[1] precedence_map[left] = right if right not in precedence_map: precedence_map[right] = precedence_map[left] letters.add(...
5f6cc5a546bed4ef63aa0ce7acd39502bfb80a88
marquesarthur/programming_problems
/interviewbit/interviewbit/math/fizz_buzz.py
458
3.546875
4
class Solution: # @param A : integer # @return a list of strings def fizzBuzz(self, A): result = [] for i in len(range(A)): if A[i] % 5 == 0 and A[i] % 3 == 0: result.append("FizzBuzz") elif A[i] % 5 == 0: result.append("Buzz") ...
0e7025b26ebefbd54c2622c5f78f9da8d747c0c4
marquesarthur/programming_problems
/leetcode/amazon/2020/flatten_tree_to_double_linked_list.py
2,084
3.921875
4
class Tree(object): def __init__(self, value): self.val = value self.left = None self.right = None def insert(self, node): if node < self.val: if self.left: self.left.insert(node) else: self.left = Tree(node) elif...
b41e6a230f2ac3f5b3fb687a6315733375558bab
marquesarthur/programming_problems
/interviewbit/interviewbit/bsearch/matrix_median.py
1,600
3.921875
4
from bisect import bisect_right as upper_bound # First we find the minimum and maximum elements in the matrix. # Minimum element can be easily found by comparing the first element of each row, # and similarly the maximum element can be found by comparing the last element of each row. # Then we use binary search on o...
0bd8b0103416f93876dd44633877dcddea542979
marquesarthur/programming_problems
/interviewbit_old/arrays/bucketing_or_sorting/largest_num.py
767
3.515625
4
from fractions import Fraction class Solution: # @param A : tuple of integers # @return a strings def customSort(self, a, b): value1 = int(a + b) value2 = int(b + a) return value1 - value2 def largestNumber(self, A): result = "" aux = map(str, A) ...
395a404212a2dafeecf601ffef74cf20e112026b
marquesarthur/programming_problems
/interviewbit/interviewbit/math/palindrome_integer.py
296
3.515625
4
class Solution: # @param A : integer # @return an integer def isPalindrome(self, A): a = str(A) i = 0 j = len(a) - 1 while i < j: if a[i] is not a[j]: return False i += 1 j -= 1 return True