blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
65ba2658c6016cdcbecb5f5240e7b457f70b08b6
prasanna1695/python-code
/2-5.py
1,002
4.03125
4
#Given a circular linked list, implement an algorithm which returns node at the beginning of the loop. #DEFINITION #Circular linked list: A (corrupt) linked list in which a node's next pointer points to an earlier node, so as to make a loop in the linked list. #EXAMPLE #input: A -> B -> C -> D -> E -> C [the same C as ...
487b0fedc3b0d970786718cf9034254afbf0d8b4
prasanna1695/python-code
/4-1.py
2,695
4.40625
4
#Implement a function to check if a tree is balanced. For the purposes of this question, #a balanced tree is defined to be a tree such that no two leaf nodes differ in distance from the root by more than one class Tree(object): def __init__(self): self.left = None self.right = None self.data = None #not necess...
7b021d606fb3c8f33d3bb6f2738f531736c9e47e
mosheeven/PythonScripts
/BubbleSort/bubbleSort.py
403
3.828125
4
def sort(arr): while True: flag = False for num in range(0, len(arr)-1): if arr[num] > arr[num+1]: arr[num], arr[num+1] = arr[num+1], arr[num] flag = True if not flag: return arr # Best O(n) print(sort([1, 2, 3, 4, 6])) # Avarage O(n^...
f98cea48e5ef2da1ddd158c9cab3e2102f4a2fa0
johnsonl7597/CTI-110
/P2HW2_ListSets_JohnsonLilee.py
1,190
4.34375
4
#This program will demonstrate the students understanding of lists and sets. #CTI-110, P2HW2 - List and Sets #Lilee Johnson #05 Oct 2021 #----------------------------------------------------------------------------- #pesudocode #prompt user for 6 indivual numbers #store the numbers in a list called List6 #displ...
20946c853bf844f1c64023a01f482c0c797e2fbd
frances-ibe/hfycse160
/preProcessIRS.py
2,561
3.59375
4
""" The following code performs data preprocessing of the IRS dataset for the completion of our CSE 160 final project. All supporting code and preprocessed data will be made available. Authors: Frances Ingram-Bate, Parker Grosjean, Nathaniel Linden Updated: March 8th 2019 Abbreviations (We will use these throughout ...
bf237d8463bc47cc00013e20b568fdcd37f86e44
graphenessl/tensor-flow
/04.activation-functions/relu.py
208
3.53125
4
# It is used as an activation function only for the hidden layers # Problems: # It can result in a lot of dead neurons (which dont pass values anymore) def relu(x): if x < 0: x = 0 return x
0f502b7f2b10caf670060df58749d4aed4f8ac1f
LillianGab/SIP-2018-starter
/U2-Applications/U2.1-Data/data_vis_project_starter.py
2,261
3.71875
4
''' In this project, you will visualize the feelings and language used in a set of Tweets. This starter code loads the appropriate libraries and the Twitter data you'll need! ''' import json from textblob import TextBlob import matplotlib.pyplot as plt def avg(lst): return sum(lst)/len(lst) #Get the JSON data tw...
124651b1e5621e7b54ff62ce933226a778393798
hnhillol/PythonExercise
/HwAssignment7.py
1,903
4.125
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 7 02:34:40 2019 @author: hnhillol Homework Assignment #7: Dictionaries and Sets Details: Return to your first homework assignments, when you described your favorite song. Refactor that code so all the variables are held as dictionary keys and value. Then refactor your p...
b7df83f7481596122a194cafdd98dc00b96145a0
cassking/piton
/Problems/problem_7_new_years.py
273
4.03125
4
""" Start at 10 seconds and count down until 1 and then print "Happy New Year! 🎉" """ import time seconds_left = 20 while seconds_left > 0: print(seconds_left) seconds_left -= 1 time.sleep(1) if seconds_left == 0: print('Happy New Year! 🎉')
f2962e714e32fc1ce26a388eb416ccd20f72fa36
diegoarielsimonelli/variables_python
/ejercicios_profunidzacion/profundizacion_1.py
1,598
4.375
4
# Tipos de variables [Python] # Ejercicios de profundización # Autor: Inove Coding School # Version: 2.0 # NOTA: # Estos ejercicios son de mayor dificultad que los de clase y práctica. # Están pensados para aquellos con conocimientos previo o que dispongan # de mucho más tiempo para abordar estos temas por su cuenta...
f3c1d064b2e53290f969427f5429aa182665e693
teamerritt/Pythagorean-Theorem
/km2miles.py
63
3.546875
4
kilo=int(input("Number of kilometers")) print (kilo * 0.621371)
6776bc1506ad8b823ed8162d13a47cba27ec8f03
lym/real_world_oop
/suit.py
308
4
4
""" This class is an abstraction of a playing card suit """ class Suit: def __init__(self, name, symbol): self.name = name self.symbol = symbol # The four card suits, French Clubs = Suit('Club', '♣') Diamonds = Suit('Diamonds', '♦') Hearts = Suit('Hearts', '♥') Spades = Suit('Spades', '♠')
c019ec26e5a4ceaa0b5029549471a77d449733b9
hulaba/GeeksForGeeksPython
/Sorting/StableSelectionSort.py
1,104
3.625
4
class StableSelctionSort: def run(self, input_arr): length = len(input_arr) # Take hold of the input_arr length for i in range(0, length - 1): # iterate over the input_arr lowest_item_index = i # assume lowest index is current index for j in range(i, length): # iterate ...
05784dfb284c59c2ea2967e8f5aaff12c5100477
hulaba/GeeksForGeeksPython
/Greedy/MinNumberOfCoins.py
698
3.78125
4
class MinNumberOfCoins: def run(self, denominations_array, change_to_give): coins_used = [] for i in range(len(denominations_array) - 1, -1, -1): # we want to start from the highest denomination possible while change_to_give >= denominations_array[i] and change_to_give > 0: # we go fr...
4588b419b4735897bc4e5b24d0f545fd4fb701ea
ProtozoaMaster/LearningPython
/add100.py
74
3.53125
4
total = 0 for num in range(101): total = total + num print(total)
1ccc9715499668c4b22b62e294f6998c34df9e39
hkristof03/GoogleFooBar
/lvl2/Task2.2/solution.py
1,255
3.578125
4
from collections import Counter def numberToBase(n, b): """""" if n == 0: return [0] digits = [] while n: digits.append(str(int(n % b))) n //= b return digits[::-1] def assign_tasks(n, b): """""" k = len(n) x = sorted(n, reverse=True, key=int) x = ''.join...
7f3cf610dffccafa759a59ce287ffc73ee2a9639
SyriiAdvent/Intro-Python-I
/src/13_file_io.py
967
4.28125
4
""" Python makes performing file I/O simple. Take a look at how to read and write to files here: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files """ # Open up the "foo.txt" file (which already exists) for reading # Print all the contents of the file, then close the file # Note: pay close...
5cbbbf6016fddad73105dc85167ca54271e9f89b
marieamelie94/python
/firstPractice/encryption.py
3,083
4.25
4
import string # INPUT: text as a string and an integer for the shift value. # OUTPUT: The shifted text after being run through the Caeser cipher. # Create a normal plain alphabet # Create a shifted version of this alphabet # (Try slicing using the shift and then reconcatenating the two parts) # re...
96a8ebb55c6e3a49e6d90c3712b750784b2b6252
AN461/PYTHON-PRACTICE
/while python.py
96
3.59375
4
string=["anji","abhi","ram"] i=0 while i<len(string): print(string[i]) i=i+1
0d1f24a621dec8c19ea0f823af49911aa4dc0813
Kayrell/MAI-Classes
/ex1.py
422
3.78125
4
from math import sin x = float(input()) y = float(input()) # ToDo - a if x ** 2 + y ** 2 > 4 and y < x and x < 2: print("точка входит в область") else: print('точка не входит в область') # ToDo - б if y < sin(x) and y < 0.5 and y > 0: print('точка входит в область') else: print('точка ...
62ce4fc921767138ed3886021b6d1e3110e13043
ChianHuei/aws_scripts
/S3_CRUD/py_scripts/ListFiles.py
1,556
3.625
4
# -*- coding: utf-8 -*- """ ListFiles.py will have these command line arguments: user-name password For example: python ListFiles.py MtCat NiceCat For each user file stored, this Python script prints one line to the console: """ import boto3 import sys from UploadFile import authenticateUser import CreateUser BUCKE...
a302b1be63cbc9e949fff2c270ddf0c78da684d7
vdaemoni/django_piscine
/day01/ex05/all_in.py
1,378
3.8125
4
import sys def get_value_by_key(states, capital_cities, needed_key): if states.get(needed_key): return capital_cities[states[needed_key]] return None def get_key_by_value(dictionary, needed_value): for key, item in dictionary.items(): if item == needed_value: retu...
59e9ffccf0409530ee8c49dea1e1b7ff398b30b6
chenshuo666/pythonWell
/cs_data_structure_and_algorithms/tree/tree_category/AVL_tree.py
10,717
3.640625
4
#!/usr/bin/python # -*- coding:utf-8 -*- # Author:Sebastian Williams class Node: def __init__(self): self.left = None self.left_height = 0 self.right = None self.right_height = 0 self.data = None # 二叉树对象 class BalancedBinaryTree(object): def __init__(self): sel...
711bfa9c5b75dc2e5bcf3095c62d772347e299a7
chenshuo666/pythonWell
/Day4/socket_server.py
709
3.75
4
#!/usr/bin/python #-*- coding:utf-8 -*- # Author:Sebastian Williams import socket server = socket.socket() # 获得socket实例 server.bind(("localhost", 6969)) # 绑定ip port server.listen() # 开始监听 while True: # 第一层loop print("等待客户端的连接...") conn, addr = server.accept() # 接受并建立与客户端的连接,程序在此处开始阻塞,只到有客户端连接进来... ...
c1d202e6d9598dfec7e7469802a37fb9dd73f2f6
hongyixiong/PathFindingAndAlphaBetaPruning
/pathfinding/pathfinding_test.py
2,875
3.78125
4
import random def print_maze(maze): for m in maze: print(''.join(map(str, m))) print() def create_maze(m, n, blocked_probability): maze = [['X' for x in range(n)] for y in range(m)] start_x = random.randint(1, m - 2) start_y = random.randint(1, n - 2) goal_x = random.randint(1, m - ...
066d98ef889ca2e0056f07f03421c04d57d0017f
sandersFeigy/auto-complete
/utils.py
740
3.84375
4
def filter_chars(word): word = ' '.join(word.split()) # leaves no multiple ' ' # remove numeric, uppercase and special chars return ''.join([char.lower() for char in word if (char.isalnum() or char == ' ') and not char.isnumeric()]) def select_high_score(popular_words): highest = list(popular_words.v...
cd9488573ec9301349b1c69a3ab5d379d932daf2
jamesgray007/northwestern-predictive
/CIS435-Machine_Learning/Assignment 4/miller_on_training_and_test_in_python.py
4,162
3.84375
4
# ---------------------------------------------------- # Random forests plus snippets of code from chapter 8 # ---------------------------------------------------- import pandas as pd # DataFrame structure and operations import patsy # translate model specification into design matrices from sklearn.ensemble impo...
048a770e7674b3add9c5f924b1deaf09b9df03ef
AlexVashchenkov/Programming-10
/2021-10/2021.01.18_Lipetsk/I.py
684
3.546875
4
from math import * s = input() lst = s.split(' ') n = int(lst[0]) k = int(lst[1]) ''' def power(a, n): if n == 0: return 1 if n % 2 == 0: return power(a, n / 2) ** 2 else: return a * power(a, n - 1) ''' def power(a, n): return pow(a,n) def x_n(k): return power((n // 2), k...
48d2d40bb733d33b57da20111b607832579a9aee
cs-fullstack-2019-fall/python-loops-cw-rjrobins16
/classwork.py
1,507
4.5625
5
# ### Exercise 1: # Print -20 to and including 50. Use any loop you want. # for x in range(-20,51,1): print(x) # ### Exercise 2: # Create a loop that prints even numbers from 0 to and including 20. # Hint: You can find multiples of 2 with (whatever_number % 2 == 0) for x in range(0,21,2): if x % 2 == 0: ...
e855c021b4c90a50be034e174a24ddab16a7669a
SachinMathew253/SemResultAnalysis
/test.py
4,761
3.703125
4
# importing packages import pandas as pd import numpy as np import xlsxwriter #Reading data file data_file = pd.read_csv('201907MarchS6GradesAllColleges.csv') #Creating list of Different colleges under KTU unique_college = [] for x in data_file['College']: if x not in unique_college: unique_colleg...
45c42d758eb3f5bea5e93a8d54cfd58669f43f4a
alifakoor/quera_fundamental_python
/greatest common divisor.py
289
3.828125
4
n = int(input()) def gcd(a, b): if a > b: a, b = b, a while a > 0: b = b % a a, b = b, a return b def lcm(a, b): return int((a * b) / gcd(a, b)) result = 1 for i in range(1, n): if gcd(i, n) == 1: result = lcm(result, i) print(result)
e2e4e97a4a7897d0a9db10be523c468e073f81c2
alifakoor/quera_fundamental_python
/hanoi.py
356
3.96875
4
n = int(input()) def hanoi(az, to, help, n, move): if n == 1: move += 1 print(move, az, to) return move else: h = hanoi(az, help, to, n-1, move) move = h move += 1 print(move, az, to) h = hanoi(help, to, az, n-1, move) move = h ret...
ef0bed0a9656f53b03f80378532b179fd446d74d
lucaandradet/Data-Science-Visualizacao-de-dados-com-python
/Gráficos/grafico_em_barra.py
403
3.828125
4
#Visualização de dados em Python import matplotlib.pyplot as plt x1 = [1,2,3,4,5] y1 = [2,3,7,1,4] x2 = [2,4,6,8,10] y2 = [5,1,3,7,5] #Python titulo = "Gráfico em barra de comparação" eixox = "Eixo X" eixoy = "Eixo Y" #Legendas plt.title(titulo) plt.xlabel(eixox) plt.ylabel(eixoy) plt.bar(x1,y1,...
3451fb1d2a749660e53f2805c30c91580387ad21
VishrutJain24/SIT315-1
/Project/covid_input.py
2,254
3.765625
4
from fuzzywuzzy import fuzz from fuzzywuzzy import process # also pip install python-Levenshtein for faster fuzzy import json from covid_process import country_str def match_input(user_args): """Match a users country inputs For each country a user enters, this function uses fuzzywuzzy to match to an actual c...
10102901c98af6650f9bf17572878b7d689253f1
serenkoker/BBy162
/uygulama03.py
503
3.859375
4
# Günler listesi ve sözlüğü 06.03.2018 gunler= ["Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar"] print(gunler) gunler_dict = {"Pazartesi" :"İngilizce", "Salı": "Boş gün", "Çarşamba": "Programlama", "Perşembe": "Bilgi Erişim", "Cuma": "Bilgi Hizmetleri", "Cumartesi": "Ge...
79a554ae3a1cb3c0de55dae95f40d477eeccb296
Vaslo/CS412_ClassProj2
/ClassProj2.py
3,225
3.53125
4
import pprint target = open("reviews_sample.txt") myList = [] for line in target: tempList = line.split() myList.append(tempList) def find_unigrams(input_list): unigram_list = [] unigram_list = (set(input_list)) return unigram_list def find_bigrams(input_list): bigram_list = [] for i in ra...
0ed6019bb853fb88971c1808605a0190c2505269
monkut/enigma
/enigma.py
1,975
3.609375
4
""" implementation of 'enigma' """ from itertools import cycle import string UPPER_ALPHABET = string.ascii_uppercase class Rotor(object): def __init__(self, rotor_id, seq, turnover_positions=None): self.id = rotor_id # I, II, etc assert len(UPPER_ALPHABET) == len(seq) if turnover_posi...
66de896019e420463811bce48b7b193a800edd6b
Chia-vie/CodeRoemerland
/Abgaben/Tic_Tac_Toe/Tic_Tac_Toe_English.py
1,121
3.78125
4
Symbol = 'X' wait = 1 Spielfeld = ''' ___ ___ ___ |_0_|_1_|_2_| |_3_|_4_|_5_| |_6_|_7_|_8_| ''' Spielzüge = ['0','1','2','3','4','5','6','7','8'] print('Hello! Lets play tic-tac-toe!') print('Player 1, you are X') print('Player 2, you are O') print(f''' Here is your matchfield: {Spiel...
eafe06a04ef0b0852b8be3f6cbd37e265ab41b05
Chia-vie/CodeRoemerland
/Abgaben/Tic_Tac_Toe/Tic_Tac_Toe_Bernhard_Bot.py
2,394
3.546875
4
from random import random from random import seed from random import randint ''' author: Christine Ackerl date: 20.07.2021 Das ist ein unvollständiges Tic-Tac-Toe Spiel. Kannst du es vervollständigen? ''' Symbol = 'X' wait = 1 Spielfeld = ''' ___ ___ ___ |_0_|_1_|_2_| |_3_|_4_|_5_| |_6...
3325662f01c1766dc3c42943e6a1e12c56c354ef
jarvis-1805/Simple-Python-Projects
/theGuessingGame.py
900
4.15625
4
import random print("\t\t\tThe Guessing Game!") print("WARNING!!! Once you enter the game you have to guess the right number!!!\n") c = input("Still want to enter the game!!! ('y' or 'n'): ") print() while c == 'y': true_value = random.randint(1, 100) while True: chosed_value = int(inpu...
a89af8e3e25a369dbdd02fa1bf01dba30de7146e
salihadfid1/Intro-Python
/exercise3.py
585
3.671875
4
# Question 1 n_c2_3 = len(titanic[titanic['pclass'].isin([2,3])]) print("{:.1f}% of passengers were in 2nd and 3rd class.\n".format(n_c2_3/len(titanic)*100)) # Question 2 num_solo = len(titanic[(titanic['sibsp'] == 0)&(titanic['parch'] == 0)]) print(f"There are {num_solo} solo travelers in the dataset.\n") # Questi...
af3c626bfeb5bd90e2340cd620ef80d122eb84fd
kaizer1v/ds-algo
/datastructures/stack.py
2,133
3.875
4
''' Stack Uses the LIFO, Last In First Out concept NOTE: In the implenetation of using a stack using a linkedlist, remember that when the stack is initialised, it will be initialised only with a `head` pointer, which points to `None` Only after the 1st element is added, the `head` will point to the 1st element ''' c...
f1f869c390877cfc42bcd25dbec63137b46e3533
kaizer1v/ds-algo
/datastructures/matrix.py
1,797
4.125
4
class Matrix: ''' [[1, 2], [2, 1]] is a matrix ''' def __init__(self, arr): self.matrix = arr self.height = self.calc_height() self.width = self.calc_width() def calc_height(self): return len(self.matrix) def calc_width(self): if self._is_valid...
5dd783701c899fae07a094a2e2fce4094e370942
kaizer1v/ds-algo
/datastructures/priority_queue.py
1,388
4.40625
4
''' Priority Queue Prioritiy queue operates just like a queue, but when `pop`-ing out the first element that was added, it instead takes out the highest (max) element from the queue. Thus, the items in the priority queue should be comparable. When you add a new item into the queue, it will automatically remove the min...
3c75b2d9b900c099d51c916a8fa4b2035dfb1dfb
zlKevinlz/Primera-Previa
/Taller2.py
6,012
3.703125
4
#!/usr/bin/env python # coding: utf-8 # In[72]: #Kevin Alexander Rodriguez Bedoya #Computación Blanda # In[29]: # Se importa la librería numpy import numpy as np # APILAMIENTO # ----------- # Apilado # Las matrices se pueden apilar horizontalmente, en profundidad o # verticalmente. Podemos utilizar, para ese p...
acd3f5a7488cfaf4a3ee5df935eb200f85f3e98d
Hafidzmhmmd/PurwadhikaDataScience
/EXAM_MODUL_1_MUHAMMAD_HAFIDZ_JAKARTA.py
1,913
4.15625
4
# ---------------------------------------------<1>--------------------------------------------- kata = 'hello there how are you doing' def hastag(string): if string == '': output = 'False' else: word = string.split(' ') output = '#' for x in range(len(word)): ...
9bfbda2998738e3141901aacd0ca39e8a3181a70
WannaMinKhant/MissilePositonControl
/trafficServer.py
1,226
3.671875
4
import socket # Create a server socket serverSocket = socket.socket() print("Server socket created") # Associate the server socket with the IP and Port ip = "192.168.0.101" port = 5000 serverSocket.bind((ip, port)) print("Server socket bound with with ip {} port {}".format(ip, port)) # Make th...
b0f2acc2dcc4e208174b717edc067066769b18ef
alex-moffat/Python-Projects
/Demo_challenges.py
8,477
3.828125
4
# PYTHON: 3.8.2 # AUTHOR: Alex Moffat # PURPOSE: The Tech Academy Bootcamp - MISCELLANEOUS CHALLENGES #============================================================================= description = """ This program was written by Alex Moffat.\n This is a demonstration of programming based on requirements given from The Te...
7037f4717a933499345a69f09222e799bd612ab1
alex-moffat/Python-Projects
/Snippets/SQLITE_assignment.py
8,426
4.09375
4
# PYTHON: 3.8.2 # AUTHOR: Alex Moffat # PURPOSE: The Tech Academy Bootcamp - SQLITE ASSIGNMENT #============================================================================= """ TAGS: SQL, sqlite3.version, error handling, connect, cursor, execute, CREATE, INSERT, SELECT slice, upper, fetchall, executescript, 'with' s...
5a2f1300d6bfbb24251770a0df7e954eef443860
alex-moffat/Python-Projects
/Tkinter Phonebook/tkinter_phonebook.py
19,221
3.71875
4
# Python: 3.8.2 # Author: Alex Moffat # Purpose: Tkinter Demo Phonebook. Demonstrating OOP, Tkinter GUI module using Tkinter Parent and Child relationships. #============================================================= """TAGS: tkinter, Tk(), master, Frame, grid, row, column, label, entry, button, iconbitmap, title, ...
563ebe51e69ee649f6cd2a0f4de2b4198b014261
jnyangwe/Machine-Learning
/NeuralNetwork/neural_networks.py
6,300
4.03125
4
#import all the libraries import numpy as np import sys import matplotlib.pyplot as plt import pandas as pd from sklearn.preprocessing import normalize from mpl_toolkits.mplot3d import Axes3D ### PART 1: Training of a neural network with a simple architecture ###generates n random training inputs on the line y=3x+2 de...
20172fd2a83496c726185978bd85374570b0c0f0
mussaiina/PP2
/TSIS1/data_type/data1_7.py
303
3.90625
4
x = 5 print(type(x)) #int x = "Hello World" print(type(x)) #str x = 20.5 print(type(x)) #float x = ["apple", "banana", "cherry"] print(type(x)) #list x = ("apple", "banana", "cherry") print(type(x)) #tuple x = {"name" : "John", "age" : 36} print(type(x)) #dict x = True print(type(x)) #bool
b0aeffd236ea16f68cdfd7384dfe5bf82532443e
mussaiina/PP2
/TSIS4-6/TSIS6/9.py
247
4.09375
4
def IsPrime(n): if n == 0 or n == 1: return False elif n == 2 or n == 3: return True for i in range(2, int(n**0.5 + 1)): if n % i == 0: return False return True n = int(input()) print(IsPrime(n))
c6492bebb6ba1ec224eead5d14c08cf4efc5f221
mussaiina/PP2
/TSIS4-6/TSIS6/11.py
313
3.640625
4
def Divisors(n): divs = [] for i in range(1, n // 2 + 1): if n % i == 0: divs.append(i) return divs def Sum(*divs): x = 0 for i in divs: x += i return x n = int(input()) divs = Divisors(n) if n == Sum(*divs): print(n, "is perfect") else: print("no")
ac5f4ef237602bf3e0e62502780c72f51ee856ae
amourlee123/leetcode
/LC219_ContainsDuplicateII.py
450
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class Solution: # type nums: List[int] # type k: int # rtype: bool def containsNearbyDuplicate(self, nums, k): numDict = dict() for x in range(len(nums)): if numDict.get(nums[x]) != None: idx = numDict.get(nums[x...
af645751bda110d25b7447d11104b8e029999fee
BilalQadar/Toronto-Bike-Share
/bikes.py
12,845
3.6875
4
from typing import List, TextIO # A type to represent cleaned (see clean_data()) for multiple stations SystemData = List[List[object]] # A type to represent cleaned data for one station StationData = List[object] # A type to represent a list of stations StationList = List[int] #Constants # station information. ID = ...
57c3b1ee4f14c2751a90fb758fba4cdc1bb367ba
rohitdphutane/personalProgramming
/python/projectEuler/problem3.py
301
3.59375
4
from math import sqrt; from itertools import count, islice num = 600851475143 def isPrime(n): return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1))) factList = [] for i in range(1,int(sqrt(num)-1)): if num%i == 0 and isPrime(i): factList.append(i) print max(factList)
88da7ddacc60ffaa01b4832c9066addf353c10da
Valery780/lesson_2
/hellouser.py
64
3.5625
4
n = input('Please enter your name: ') print ('Hello,', n+'!')
7e5160d8f43bbeef9e6b4df35e27b10a387aaad3
aishiemaddimsetty/Hacker-Rank
/HackerRank Prac.py
73
3.765625
4
string = "hello" str = string.replace("e", "0") print(string) print(str)
d76a02c44e372abea4c331bb0694a8a102c56a75
redfernj-OSU/CS-362-In-Class-Activity-5-13-2021
/word_count.py
233
3.984375
4
def word_length(word): return len(word.split()) def main(): print("Enter a word: ", end="") word = input() print("The word '", word,"' is", word_length(word) , "words long.") if __name__ == '__main__': main()
25748e3aec7491f39c89e43df22e94b2e5550960
LRenascence/LeetCode
/Python/medium/300. Longest Increasing Subsequence.py
1,806
3.703125
4
""" Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Note: There may be more than one LIS combination, it is only necessary for you to re...
f2b2f12f4e62eb7a2cecd245f833bfca3490845c
LRenascence/LeetCode
/Python/hard/829. Consecutive Numbers Sum.py
615
3.71875
4
""" Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers? Example 1: Input: 5 Output: 2 Explanation: 5 = 5 = 2 + 3 Example 2: Input: 9 Output: 3 Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4 Example 3: Input: 15 Output: 4 Explanation: 15 = 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 +...
274d11e0039ca9c78f8abca692dd714ecb414e26
LRenascence/LeetCode
/Python/easy/349. Intersection of Two Arrays.py
1,116
4.03125
4
""" Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4] Note: Each element in the result must be unique. The result can be in any order. """ class Solution(object): def i...
df94bb1c640e3268c377fd5e62a151f080d92920
LRenascence/LeetCode
/Python/easy/387. First Unique Character in a String.py
790
3.953125
4
""" Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contain only lowercase letters. """ class Solution(object): def firstUniqChar(self, s): """...
596deac3755e94d510ceb2b43b491f8b09f501fd
LRenascence/LeetCode
/Python/medium/316. Remove Duplicate Letters.py
896
3.84375
4
""" Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/ Exa...
8c5cb6769935119a66f6e4864f5930d0aa425b3d
LRenascence/LeetCode
/Python/medium/215. Kth Largest Element in an Array.py
1,263
3.9375
4
""" Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 Note: You may assume k is always valid, 1 ≤ k ≤ array's leng...
1413c62cd87ae3eb72695f95636419cead678d19
LRenascence/LeetCode
/Python/easy/14. Longest Common Prefix.py
1,234
3.875
4
""" Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input st...
1e17886ceec97bc34d3e8d7969c4eeb4f79c6fc0
LRenascence/LeetCode
/Python/medium/86. Partition List.py
1,111
4
4
""" Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. Example: Input: head = 1->4->3->2->5->2, x = 3 Output: 1->2->2->4->3->5 """ # Definition for s...
50d2f84b507db7d240801ee58ec9de9bdda397ff
LRenascence/LeetCode
/Python/easy/653. Two Sum IV - Input is a BST.py
997
3.90625
4
""" Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: 5 / \ 3 6 / \ \ 2 4 7 Target = 9 Output: True Example 2: Input: 5 / \ 3 6 / \ \ 2 4 7 Target = 28 Output...
7a880aa9768cb931ca049d52a06728c10f529eb5
LRenascence/LeetCode
/Python/easy/169. Majority Element.py
718
3.921875
4
""" Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. Example 1: Input: [3,2,3] Output: 3 Example 2: Input: [2,2,1,1,1,2,2] Output: 2 """ class Solu...
e63b18f4baaa782935c54566693d773676553ed4
abhishekm2106/CP_CipherSchools
/ASSIGNMENT - 1 Searching and Sorting/SortarrayWith1&2.py
329
3.5625
4
def seperate(arr): start = 0 end = len(arr)-1 while(start<end): if arr[start]==1: start+=1 elif arr[end]==2: end-=1 else: arr[start],arr[end]=arr[end],arr[start] start+=1 end-=1 x=[2,2,2,1,2,1,2,2,1,1,1,1,2] seperate(x)...
50bfd6404c6444bab3285e07fb9f5b70a0acbb01
abhishekm2106/CP_CipherSchools
/ASSIGNMENT - 1 Searching and Sorting/SortarrayWith0,1&2.py
454
3.734375
4
def seperate(arr): first = 0 second = 0 third = len(arr)-1 while(second<=third): if arr[second]==0: arr[first],arr[second] = arr[second],arr[first] first+=1 second+=1 elif arr[second]==1: second+=1 else: arr[third],arr[s...
44d0ac5f284091f2e5731575bd81aeae0465b1d6
harmisbt/ia241
/lab2.py
405
3.671875
4
''' lab 2 ''' #3.1 my_name = "Tom" print (my_name) #3.2 my_id = 123 print(my_id) #3.3 _123=my_id my_id = your_id=123 print(my_id) print(your_id) #3.4 my_id_str ='123' print(my_id_str) # #3.5 # print(my_name +my_id) #3.6 print(my_name + my_id_str) #3.7 print(my_name*3) #3.8 print('hello, world. This is m...
21724748de611ddb86554583e08169d4e6a61f74
ReallyMonk/DSA-term-project
/rh690/dfsSolver.py
3,619
3.53125
4
import random class bfsSolver(): def __init__(self): # print('create solver') pass def update_info(self, head, tail, body, food, width): self.head = head self.tail = tail self.body = body self.food = food self.width = width self.walls = [] ...
57e05b770266c65f5d0861afe0ad48c5172dd8b3
voksus/OdooTestTask
/Task-2.py
1,767
3.546875
4
# ---------------------------------- # # Created by Volodymyr Burtsev # # on 03.07.2018 in 10:02 # # The project is < OdooTestTask > # # ---------------------------------- import random def createString(): print("Creating the string...") # ---- create list with 40k of each letter lst = list(letters * le...
09aa49ab010a3a00e71db544b0fde6ea5e26be05
cleitonkn/CursoemVideo
/Desafio041.py
871
4.09375
4
# a confederação nacional de natação precisa de um programa que leia o # ano de nascimento de um atleta e mostre sua categoria, de acordo com a # idade: # - Até 9 anos: MIRIM # - Até 14 anos: INFANTIL # - Até 19 anos: JUNIOR # - Até 25 anos: SENIOR # - Acima: Master from datetime import date atual = date.today().yea...
124622b6f67515efe0d569d7efcbd66868b69b38
cleitonkn/CursoemVideo
/Desafio046.py
310
3.65625
4
# Faça um programa que mostre na tela uma contagem regressiva para o estouro # de fogos de artificio, indo de 10 até 0, com uma pausa de 1 segundo entre # eles. import time print('\nCONTAGEM REGRESSIVA!\n') time.sleep(1) for c in range(10,0,-1): print(c) time.sleep(1) print('FELIZ ANO NOVO! FOGOS!')
c39e5b23629a1d9ffa303eeeaa06873997db821d
cleitonkn/CursoemVideo
/Desafio045.py
1,143
4
4
# crie um programa que faça o computador jogar Jokenpô com você. import random print('*'*40) print('Ecolha um das opções: ') print('*'*40) print('Pedra') print('Papel') print('Tesoura') print('*'*40) eu = str(input('Digite uma das opção: ')) lista = ['Pedra', 'Papel', 'Tesoura'] maq = random.choice(lista) print('*'*...
22648aa006234685bc71568ce59867a656291936
cleitonkn/CursoemVideo
/Desafio034.py
511
3.890625
4
# Escreva um programa que pergunte o # salário de um funcionário e calcule # o valor do seu aumento. # Para salários superiores a R$1250,00, # calcule um aumento de 10%. # Para os inferiores ou iguais, o aumento # é de 15% salario = float(input('Digite o seu salário atual: ')) if salario >= 1250: print('Seu novo s...
09c90c65e62450d8d38bf3d3dd2df062dcd7fafb
cleitonkn/CursoemVideo
/Aula06a.py
190
3.875
4
n1 = int(input('Digite o numero:')) n2 = int(input('Digite o mais um numero:')) s = int(n1+n2) #print('A soma entre',n1,'e',n2,'vale',s) print('A soma entre {} e {} vale {}'.format(n1,n2,s))
6583f1d6ace63695eb04c707761bca6c25704fac
cleitonkn/CursoemVideo
/Desafio022.py
412
3.875
4
nome = str(input('Digite o seu nome completo: ')).strip() nse = nome.split() length = len(nome) - (nome.count(' ')) print(nome.upper()) print(nome.lower()) print('seu nome completo tem {} letras'.format(length)) # print('seu nome completo tem {} letras'.format(len(nome) - nome.count(' '))) print('{} tem {} letras'.for...
37fe5223f2416277393f6ce1d29215d3986b0c43
WangShayne/python
/list.py
1,046
3.796875
4
#!usr/bin/env python3 # -*- coding:utf-8 -*- # ------------------------ list ------------------------ # 1. 如果一个产品,需要列出产品的用户,这时候就可以使用一个 list 来表示 users = ["老王", "老张", "老李"] print("1.用户以下这些") print(users) # 2.统计用户有多少人 print("\n2.用户有多少人") print(len(users)) # 3.具体的用户有谁 print("\n3.具体的是谁") print(users[0]+','+users[1]+","+...
e81368c2b31b4310559e950f61ba08256407da31
yaoyao0089/Selenium120
/dataDriverTest2.py
1,018
3.5
4
import csv import os #__file__双下划线开头,双下划线结尾的变量,是python内置变量,表示当前文件,这个变量写在哪个文件中, #就代表那个文件本身,这时候 path ==C:\Users\51Testing\PycharmProjects\Selenium120\ # path = os.path.dirname(__file__) # print(path) # final_path = path + "/data/member_info.csv" # print(final_path) #好处 保证项目在任意路经下都可以执行 #公用的代码应该封装成一个独立的方法 def readData(): ...
9735fd55ed92e1c647c303ce85b72a641549a2e8
abhishekg323/Durga-s-Python
/python_flowcontrol-1.py
4,871
4.03125
4
#break statement: #if break statement can not possible without for or while loop for i in range(10): if i==7: print('processing is enough, break loop execution') break print(i) print('out side of loop') cart =[10,20,30,600,40,50] for item in cart: if item>500: print('iteam is more t...
2e6b79f1ecea34e58bc83a42609d60e78f711a1c
rudysaniez/python-base
/conditions.py
458
4.0625
4
i, j, k = 8, 2, 6 one = i * j + k two = k * i + j three = j * k + i if(one > two): if(one > three): print("One is better") else: print("One is not the better") elif(two > one): if(two > three): print("Two is better") else: print("Two is not better") elif(three > one an...
9f51bcc1100bf2da76b5ec98df89b61ec189fa65
s10singh97/Python_Lab
/Sept27/1.py
1,210
3.78125
4
import random def odd_function(): s = random.randrange(0,30) if s % 2 == 0: odd_function() else: return int(s) def prime_number(): c = 0 s = int(random.randrange(0,30)) for i in range(1, int(s/2)): if s % i == 0: c += 1 if c == 1: return s el...
00d064aed275c8a00e0a0e9cce9347cece049873
s10singh97/Python_Lab
/Aug2/aa.py
235
3.65625
4
a = [1,2,3,4] i = 2; j = 4 if i and j in a: print('Present') else: print('Not Present') print(2+2) print(4^2) print(~4) print(4<<2) print(4>>2) print(2<3) print(2>4) print(2 == 2) print(2<=4) print(2 or 1) print(2 and 14)
86de12c4e8606d8ffdb9f8fed01c0d3e301551df
RameshThota87/python_intermediate_project
/q03_create_3d_array/build.py
171
3.796875
4
# Default Imports import numpy as np # Enter solution here def create_3d_array(): N = np.arange(27) N = N.reshape(3,3,3) return N #print (create_3d_array())
2bb0d07d18040aa3aabdabc51ab2d4f1ab86bded
NeilT-UK/python-utilities
/time_funcs.py
1,025
4.09375
4
import time import math version = '1.0.1 2016 Dec 31' """ utility functions for working with python time """ def seconds_to_round_time(start_time=None, secs=1): """ return the number of seconds to wait to get to the next even time, rounded up from the start secs = 10 for 10 seconds boundaries, = 7200 for...
3a3c4ea143aed07720ccbbaa1cc483048eafc327
Pypy233/python
/Fluent Python/namedtuple_demo.py
279
3.921875
4
from collections import namedtuple City = namedtuple('City', 'name country population coordinates ') tokyo = City(name = 'Tokyo', country = 'Japan', population = 36.933, coordinates = (1, 1)) print(tokyo.name) print(tokyo.country) print(tokyo.population) print(tokyo.coordinates)
92cb042787c3440b10ee2df4991af4de722b56fc
Pypy233/python
/Base/Combination.py
396
3.875
4
lst = list() arr = list() def Combination(n, r): arr = [1, 2, 3, 4, 5] lst = [1, 1, 1] if(n < r): return ; elif(n == 1): for i in lst: print(i, end = ' ') print() else: Combination(n - 1, r - 1) lst[r - 1] = arr[n - 1] Combination(n - 1, r) def main(): '''print('Enter the number n: ') n = input...
1a9221f0b931bac9c2a321280e337300b51c99a6
Pypy233/python
/base/myiterator.py
362
3.921875
4
class Reverse: """Iterator for looping over a sequence backwards""" def _init_(self, data): self.data = data self.index = len(data) def _iter_(self): return self def _next_(self): if self.index==0: raise StopIteration self.index-=1 return self.data[self.index] >>> rev = Reverse('spam') iter(r...
135792b96beaca673e3799c8c0fde6fbdd813833
Pypy233/python
/homework/static_end/1/problem.py
409
3.609375
4
class Solution(): def solve(self, A): return [i for i in A if self.prime(i)] #judge whether x is prime or not def prime(self, x): if x == 1 or x == 2 or x == 3: return True if x == 4: return False if x <= 0: return False for i in r...
1bc1721d4299022e66df4673f0730d4cf9bc2032
j6mes/py-dcs
/util/dateutils.py
518
3.625
4
from dateutil.parser import parse as dparse, parser _parser_p = parser() def is_date(string): try: dparse(string) components = 0 res, _ = _parser_p._parse(string) if hasattr(res, "day") and res.day is not None: components+=1 if hasattr(res, "month") and res.month...
b87baaa6882cc366e2668e1ef80593b67fefbc51
ongsuwannoo/PSIT-61
/Week 11/Median.py
351
3.703125
4
"""Median""" def main(): """find Med""" num = int(input()) lis = [] for _ in range(num): num1 = input() lis.append(int(num1)) lis.sort() if num%2 != 0: med = int((num+1)/2) print('%.1f'%(lis[med-1])) else: med = int((num+1)/2) print('%.1f'%((li...
93cf9b5f3cdd6c1f3f17f9869076684b7b8f0cf4
ongsuwannoo/PSIT-61
/Week 11/FibonacciRecursionV1.py
261
3.984375
4
""" FibonacciRecursionV1 """ def fibo(num): """ fibo recursive """ if num == 0 or num == 1: return num else: return fibo(num-1) + fibo(num-2) def main(): """ main function """ num = int(input()) print(fibo(num)) main()
0428c1815a9a3e3e4389ad7290a08441c85347b7
ongsuwannoo/PSIT-61
/Week 12/Amicable.py
621
3.515625
4
""" Amicable """ def amicable(num): """test""" count = 0 for i in range(2, int(num**0.5)+1): if num%i == 0: count += i + num//i if num**0.5 == int(num**0.5): count -= int(num**0.5) return count+1 def main(num): """ print """ first = [1]*(num + 1) count = 0 ...
4c12fc503caf2f6a921af072b90f7cde5d44f51d
ongsuwannoo/PSIT-61
/Week 12/Day2011.py
306
3.953125
4
"""Day2011""" def main(day, month): """Find Day""" days = ["Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"] total_month = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] return days[(day+total_month[month-1])%7] print(main(int(input()), int(input())))
2aba6cff5e9c7f7d17091286a7db130d7131dda5
ongsuwannoo/PSIT-61
/Week 12/CoinChangev1.py
251
3.828125
4
"""CoinChangev1""" def main(money): """Find Money""" coin = 0 coin += money//25 money = money%25 coin += money//10 money = money%10 coin += money//5 money = money%5 coin += money print(coin) main(int(input()))
db9d9289d7b646fdd2d452944427332174066b96
ongsuwannoo/PSIT-61
/Week 08 (MIDTERM)/Nearer.py
370
3.78125
4
''' Nearer ''' def main(): ''' dis ice ''' alice = int(input()) bob = int(input()) dis = int(input()) alice_1 = max(alice, dis) - min(alice, dis) bob_1 = max(bob, dis) - min(bob, dis) if alice_1 < bob_1: print('Alice', alice_1) elif alice_1 > bob_1: print('Bob', bob_1) ...