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
d40e19b54f1b5134f7dc71e570ca22600c109ccc
yu1689485899/yumengmeng
/Monitor.py
1,900
3.734375
4
""" 监控代码:监控服务器的内存、cpu、网络、磁盘等。与租车系统部署到一起 """ from asyncio import sleep from datetime import datetime import psutil print(psutil.cpu_percent()) # 获取cpu的信息 print(psutil.virtual_memory()) # 虚拟的内存 print(psutil.virtual_memory().percent) # 虚拟内存的百分比 print(psutil.disk_usage("d:/")) # 租车系统所在的磁盘 print(psutil.disk_usage("d:/...
421f6253cf93d9eceb1f8193620607daaea8789f
sharmanikhil99/cs176project
/project.py
7,844
3.765625
4
""" RNA Alignment Assignment Implement each of the functions below using the algorithms covered in class. You can construct additional functions and data structures but you should not change the functions' APIs. You will be graded on the helper function implementations as well as the RNA alig...
6e68aacd4aec55f9a7d974ed3eeb021ec3b5fe78
MainakRepositor/Advanced-Programming-Practice
/Week 2/Q.4.py
2,960
3.9375
4
'''Develop an application called Quiz. Store 7 pairs of questions and answers in a dictionary. The task is to ask 5 questions. The user enters the answers. For every correct answer 1 mark is awarded. Finally, display the total score of the user.''' print("Welcome to APP Quiz! Good luck! :)\n") n = int(input("Please c...
f236b8b9866ac9eae15b53802cc2c01854c248f9
MainakRepositor/Advanced-Programming-Practice
/Week 3/Q.1.py
543
4.4375
4
'''1.Develop an Python code to display the following output using class and object (only one class and two objects)''' class Birdie: species = "bird" def __init__(self, name, age): self.name = name self.age = age blu = Birdie("Blu", 10) woo = Birdie("Woo", 15) print("Blu is a {}".format(b...
88667c491b10cfaee65996209c27103914d82a55
Naateri/ProgrammingLanguages
/Lab1/3.py
1,013
3.734375
4
def mat_mult(A, B): #filling with zeros C = [[0 for row in range(len(A))] for col in range(len(B[0]))] for i in range(len(A)): for j in range(len(B[0])): summ = 0 for k in range(len(A[0])): summ += A[i][k] * B[k][j] C[i][j] = summ retu...
63458826fb3151c4a1f02905ee5b73d4c51641b0
juanignaciolagos/python
/07-Ejercicios/ejercicio4.py
467
4.4375
4
""" Pedir dos numeros al usuario y hacer todas las operaciones basicas de una calculadora mostrarlo por pantalla """ numero1 = int(input("Introduce el numero 1: ")) numero2 = int(input("Introduce el numero 2: ")) print(f"La suma de los dos numeros es: {numero1+numero2}") print(f"La resta de los dos numeros es: {nume...
ce94909addce38a786e25be735616833dd8e55b9
juanignaciolagos/python
/07-Ejercicios/ejercicio10.py
530
3.921875
4
""" El programa tiene que pedir la nota de 15 alumnos y sacar por pantalla quienes han aprobado y quienes han suspendido """ contador = 1 aprobados = 0 suspendidos = 0 numero_de_alumnos = int(input("cuantos alumnos tienes: ")) while contador <= numero_de_alumnos: nota = int(input(f"que nota quieres ponerle a...
9958f3ae8ed45d535d2fab9444a43426100ede7f
juanignaciolagos/python
/08-Funciones/predefinidas.py
892
4.1875
4
nombre = "Juan Lagos" #funciones Generales print(nombre) print(type(nombre)) #detectar el tipado comprobar = isinstance(nombre,int) if comprobar: print("Esta variable es un string") else: print("no es un string") if not isinstance(nombre,float): print("la variable no es un numero decimal") #limpiar e...
379b9516400816ed7641602198bddc6cd690f555
juanignaciolagos/python
/07-Ejercicios/ejercicio7.py
391
4.125
4
""" entre dos numeros que el usuario ingrese mostrar solo los numeros impares """ numero1 = int(input("Introduce el numero 1: ")) numero2 = int(input("Introduce el numero 2: ")) if numero1 <= numero2: rango = range(numero1,numero2) for contador in rango: print( 2*contador ) else: rango = range(...
d72b7e613893a7f47fca63587c9ddd36531a4348
jdavcs/sergey.cs.uni.edu
/www/courses/cs1120/spring2018/code/code042618.py
1,838
3.671875
4
def hasVowels(word): for c in word: if c in "aeiouAEIOU": return true return false def isStrongPass(text): hasLower = false hasUpper = false hasDigit = false for c in text: if isLower(c): hasLower = true elif isUpper(c): hasUpper = true elif isDigit(c): hasDigit = t...
12b16dbd277eb214c3ccc2dc47d64dccfceb0d36
hari-bhandari/pythonAlgoExpert
/QuickAndBubbleSort.py
684
4.15625
4
def quickSort(array): length=len(array) if length<=1: return array else: pivot=array.pop() itemsGreater=[] itemsLower=[] for item in array: if(item>pivot): itemsGreater.append(item) else: itemsLower.append(item) return quickSort(items...
c1760dc17c8e8f4e43a32a026c4ddf01d32388db
Crazysniperr/Python
/user_login_attempt.py
1,741
4.0625
4
class User: #to create a class called user for user data entry def __init__(self,first_name,last_name,User_name,Email_ID):#all essential data about user self.first = first_name self.last = last_name self.uname = User_name self.mail = Email_ID self.login_attempts = 0 ...
357fbd822fa1d9e68afd1b880fc4c2f76988b384
jjen6894/PythonIntroduction
/Challenge/IfChallenge.py
593
4.21875
4
# Write a small program to ask for a name and an age. # When both values have been entered, check if the person # is the right age to gon on an 18-30 holiday must be over 18 # under 31 # if they are welcome them to the holiday otherwise print a polite message # refusing them entry name = input("What's your name? ") ag...
df7e232f57f2101611107b9eae0efa961f5aea0d
jjen6894/PythonIntroduction
/Challenge/Ranges_mini_challenge.py
438
3.734375
4
o = range(0, 100, 4) print(o) p = o[::5] # print all the values in the range that are multiples of 5 print(p) for i in p: print(i) range(1,10) # [1, 2, 3, 4, 5, 6, 7, 8, 9] a = range(1, 10) for i in a: print(i) print('='*50) for a in range(21, -1, -2): print(a) print(range(20, 0, -2)) # [20, 18, 16, 14,...
ee02007ed9b876035a22965127b7c85ee4fb608e
Santiago-j-s/Cuadernos-Jupyter
/Experimentos/functionpartida.py
521
3.65625
4
import numpy as np import matplotlib.pyplot as plt import plotly.plotly as py import plotly.tools as tls mpl_fig = plt.figure() ax = mpl_fig.add_subplot(111) names = ['-4T', '-3T', '-2T', '-T' ] values = [-4,-3,-2,-1] x = np.linspace(0, 10, 100) # lambda es una función anonima que retorna lo que sigue a : y = np.p...
a15e229bf8f22affdc2fc2d065e8bf14ffd17c5a
ahmad-abdellatif/pfla
/pfla/logger.py
808
3.75
4
import logging class Logger: """Logging functionality Parameters ---------- VERBOSE : boolean Value from the verbose argument """ def __init__(self, VERBOSE): self.verbose = VERBOSE def info(self, MSG, LEVEL): """Log message based on level Parameters ...
23cc71ffad0e35a2b1e3170cbe4178221a154734
rhuangab/projectEuler
/001-100/P003.py
693
3.5625
4
#Largest prime factor #Problem 3 #The prime factors of 13195 are 5, 7, 13 and 29. #What is the largest prime factor of the number 600851475143 ? # #Thought: #Use Fermat's algorithm find a^2 - b^2 = N, so (a+b)(a-b)= N. a+b and a-b are factors of N. #Begin from 2, find the largest factor of n, said m, then find the larg...
451e4c10cc9be75843283866cd07343b0a23bb6f
pulakanamnikitha/phython-program
/day.py
99
3.890625
4
string=raw_input() if(string=='sunday'or string=='monday'): print('yes') else: print('no')
49a053c483508ebe7a6bed95bafbe294b56239c1
gabmwendwa/PythonLearning
/3. Conditions/2-while.py
396
4.34375
4
# With the while loop we can execute a set of statements as long as a condition is true. i = 1 while i <= 10: print(i) i += 1 print("---------") # Break while loop i = 1 while i <= 10: print(i) if i == 5: break i += 1 print("---------") # With the continue statement we can stop the current iteration, and continu...
b5ab9138384b9079b73d6a64e922a307d500fe42
gabmwendwa/PythonLearning
/4. Functions/1-functions.py
2,308
4.71875
5
# In Python a function is defined using the def keyword: def myfunction(): print("Hello from function") # Call function myfunction() print("-------") # Information can be passed to functions as parameter. def namefunc(fname): print(fname + " Mutisya") namefunc("Mutua") namefunc("Kalui") namefunc("Mwendwa") print("-...
71b8b67c39bb8c55568ba0c8dcdbb0e3565c1972
gabmwendwa/PythonLearning
/2. Collections/4-dictionary.py
2,577
4.34375
4
# Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. # A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. mdic = { "brand" : "Ford", "model" : "Mustang", "year" : 19...
b12a8d8216927ad9dd5f2fe5975c80aba95f3d1b
gabmwendwa/PythonLearning
/7. OOP with Python/1-turtle-race.py
865
3.5625
4
import os from turtle import Turtle from random import randint # Ninja Turtles # Danotello Danotello = Turtle() Danotello.color('purple') Danotello.shape('turtle') Danotello.penup() Danotello.goto(-160, 100) Danotello.pendown() # Raphael Raphael = Turtle() Raphael.color('red') Raphael.shape('turtle') Raphael.pen...
6f07ebe7ecddb5faf02c9dff12ee00a91831ba65
mjafar1000/Mohammed_jafar_ecs_test
/python/medals.py
1,676
3.84375
4
medalResults = [ { "sport": "cycling", "podium": ["1.China", "2.Germany", "3.ROC"] }, { "sport": "fencing", "podium": ["1.ROC", "2.France", "3.Italy"] }, { "sport": "high jump", "podium": ["1.Italy", "1.Qatar", "3.Belarus"] }, { "sport"...
4247a2a8f68490a4b276eef52e14087d64637c42
dna001/advofcode2020
/10/10.py
1,716
3.6875
4
#!/usr/bin/env python3 """ AdventOfCode day 10. """ import argparse import logging import os import sys import json import fnmatch from datetime import datetime def get_args(): """Parse args from terminal.""" parser = argparse.ArgumentParser( description='AdventOfCode') parser.add_argument( ...
da99bd67d22ed15e9843eca265339b69cacdc25d
dna001/advofcode2020
/1/1.py
1,618
3.6875
4
#!/usr/bin/env python3 """ AdventOfCode day 1. """ import argparse import logging import os import sys import json import fnmatch from datetime import datetime def get_args(): """Parse args from terminal.""" parser = argparse.ArgumentParser( description='AdventOfCode') parser.add_argument( ...
c8a8efc2f5b1c1d2cc0cb9500bb9effddde59d6d
ASavageCabbage/PHYS203Project
/src/utils/phases/data.py
4,297
3.59375
4
from math import log # Helper functions def find_nearest_value(key, table): ''' Returns value corresponding to the nearest key in the table Assumes input key and keys in table are numeric ''' ordered_keys = list(table.keys()) if key in ordered_keys: return table[key] ordered_ke...
1a29bd815a14819b30f49333017029e350d12f7b
ASavageCabbage/PHYS203Project
/src/utils/subsystem.py
3,574
3.625
4
# class handling interplay between water, salt, and saltwater import logging import numpy as np from utils.phases import * from utils.absolute import gibbs class Subsystem: def __init__(self, water, salt): self.water = water self.salt = salt self.n_dissolved = 0 # number of moles of salt ...
8e5d1a886aec0188be1ad9e6f32434accc194873
jessemcastro/respostas_listas
/06.py
810
3.90625
4
#Faça um Programa que peça as quatro notas de 10 alunos, # calcule e armazene num vetor a média de cada aluno, # imprima o número de alunos com média maior ou igual a 7.0. notas = 0 soma = 0 media = 0 alunos = 0 cont= 1 aprovados = 0 lista_medias = [] for alunos in range(2): print("Inserindo notas do a...
fc2a0c271088609e9a18235a5eade9f9f9d1eac7
jessemcastro/respostas_listas
/04.py
768
3.859375
4
#Faça um Programa que leia um vetor de 10 caracteres, # e diga quantas consoantes foram lidas. # Imprima as consoantes. lista_letras = [] cont = 0 while cont < 10: atual = str(input("Digite uma letra")) lista_letras.append(atual) cont = cont + 1 print("Lista inicial: ",lista_letras) def remove...
97b303fff8717c225756a4b9d11b28a75fa4782f
ogdendavis/menus-project
/database_setup.py
2,547
3.921875
4
#!/usr/bin/env python # This module will create the database being used for the project. # Dependencies: SQLAlchemy, SQLite3 ### Configuration code: Setup and import of dependencies ### import os # Sys provides ability to manipulate runtime environment import sys # SQLAlchemy is an ORM that allows communication be...
1d02160f3f901d060999de9a72b38fd2fd187b55
koshelev-dmitry/Elements_of_codding_interviews_in_python
/chap_5_arrays/5.7_but_sell_twice.py
1,019
3.515625
4
def max_profit(A): # create two arrays # one in forward move: starting from first dat, -> # one in backward move: starting from last day, going backward <- min_val = A[0] max_profit = 0 forward_profit = [0]*len(A) for i in range(len(A)): min_val = min(min_val, A[i]) max_prof...
0b5a34b1470f58990325b8d446652c9d92ed9ec7
koshelev-dmitry/Elements_of_codding_interviews_in_python
/chap17_greedy/boot_camp.py
284
3.765625
4
def change_maker(number): CENTS = [100,50,25,10,5,1] coins = [] for coin in CENTS: number_of_coins = number//coin for _ in range(number_of_coins): number -= coin coins.append(coin) return coins print(change_maker(129))
b9fa2b80f6107ec4ddbc14ee83109709a38efd6a
bcchickadee/Recurrence-Relation-Calculation-Tools
/이항일반점화식_1.5.py
1,187
3.703125
4
def a(FirstSequence,MultipliedConstant,IndependentConstant,SequenceNumber): #a(n+1)=(MultipliedConstant)*a(n)+(IndependentConstant) if int(SequenceNumber)==1: return FirstSequence else: return float(MultipliedConstant)* a(float(FirstSequence),float(MultipliedConstant),float(IndependentConsta...
9abc470cc3792ccabac14ce9c42837736eeac176
buyuktas18/machine-learning
/hello.py
62
3.640625
4
i = str(input("Give your name: ")) print("hello {}".format(i))
a637118cb4b5f2a6b625a7324fbb91f1b3672645
exs-xgg/python-oop-scl2021
/main.py
5,975
3.921875
4
from student import Student from teacher import Teacher import pickle def start(): print("Welcome to the school database editor") def promptForInput(message): selection = "" while not (selection == "S" or selection == "T"): selection = input(message).upper() return selection def addNewStude...
3b8bbe4705ce4ba6ae2257e5b67687913a967e06
W3-Anjan/machinelearning
/LinearRegression.py
2,369
3.921875
4
# Importing libraries import numpy as np import pandas as pd from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt # Linear Regression class LinearRegression(): def __init__(self, learning_rate, iterations): self.learning_rate = learning_rate self.iterations =...
5b9ed85b89a20fb09ea94e7c218fcccd41ed2e96
ubccsss/open
/door.py
701
3.59375
4
import RPi.GPIO as GPIO class DoorSensor: """Manages door sensor IO.""" def __init__(self): # Set Broadcom mode so we can address GPIO pins by number. GPIO.setmode(GPIO.BCM) # This is the GPIO pin number we have one of the door sensor # wires attached to, the other should be a...
60886fb6e5aa61f1422551c9c9a7e888ae5360c5
44858/files
/displaying contents of a file.py
177
3.875
4
#Lewis Travers #13/02/2015 #displaying contents of a file with open("my_file.txt", mode="r", encoding="utf-8") as my_file: for line in my_file: print(line, end="")
293c467244c6513503cb45e70db9a565cbe7c31d
KrishnaKumarTiwari/xlearn
/aviso/number-name-problem/problem3.py
4,386
4.15625
4
#!/usr/bin/env python # coding: utf-8 # # Aviso Data Science Problem Solving Challenge # ## Problem #3 Coding logic Challenge # # ### Number name # Program should accept a number name less than 10000 and print the number # # Ex: One ---> 1 # Ten ----> 10 # twenty two ----> 22 # three hundred and seventy four ----...
e417879577e63567fcedd480df97b4482e11db10
Jed-77/reinforcement_learning_intro
/rl_deep/cartpole/q_learning.py
8,297
3.53125
4
import gym import os import sys import numpy as np import matplotlib.pyplot as plt from gym import wrappers from datetime import datetime from sklearn.pipeline import FeatureUnion from sklearn.preprocessing import StandardScaler from sklearn.kernel_approximation import RBFSampler class SGDRegressor: """ SGD Regre...
370dd08cd72cabb661a7b56d001fc73db60b35af
Jed-77/reinforcement_learning_intro
/rl_simple/Reinforcement Learning/linear_rl_trader.py
22,695
3.671875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt from datetime import datetime import itertools import re import os import pickle from sklearn.preprocessing import StandardScaler def get_data(): """ Retrieve stock data for AAPL (Apple), MSI (Motorola) and SBUX (Starbucks), be...
9d7ad393df5af9f5daada8b6daa17de0f5e10e76
johnwelter/portfolio
/NES_text_creator/AutoTextFormatter.py
5,026
3.53125
4
# # # # auto text formatter # # John Welter 2016 # # auto formats a txt file so it's text can be copy pasted into the Rocky NES Text Editor # witout having to manually put in all the line breaks and punctuation pauses. # # import sys pathName = sys.argv[1] #set path of txt to be read print (pathName) inFile = open(p...
42777cba8d7e167ce7779e33fe9f0d3b7b8b5e8d
raiamar/Python_basic_advance
/algebra_solution.py
203
3.53125
4
from algebra_module import sol1 try: a = float(input("Enter Value for a:")) b = float(input("Enter Value for b:")) print(sol1(a,b)) except ValueError as err: print("Use numbers, not alphabets")
ea9241fc86e69380dba96eef594a6b96698f6249
raiamar/Python_basic_advance
/per.py
686
4.0625
4
""" in1= int(input("marks obtained in maths:")) in2= int(input("marks obtained in english:")) in3= int(input("marks obtained in Nepali:")) Total = in1+in2+in3 per = (Total/ 300) * 100 print("Total Mark Obtain:", Total, "& Percent is", per) #conditional statements num = int(input("enter a number:")) if num < 0: p...
50540f4f2dcdce33600ad72abc09820cd0681c56
CPlusPlusNewb/python
/turtle/yearoneproject/Prestonscode.py
1,364
3.59375
4
import tkinter as tk import turtle import random import need import Ezekielscode as ec import Shanescode as sm menu_color = "" def menucol(col): try: global menu_color menu_color = col finally: turtle.Terminator() def get_mouse_click_coor(x, y):#this is da main try: mouseposx = x mouseposy = y cordprin...
441f0592abfa4da2f99cdd3e4ff1c0d5d6b63faa
CPlusPlusNewb/python
/edhesive/notneededgarbage/3.5LessonPractice/Question1-4.py
573
4
4
#num = int(input("Enter a number: ")) for i in range (0, 4):# num = 0 if (i == 0): num = 5 print("With a input of 5: ") elif (i == 1): num = 26 print("With a input of 26: ") elif (i == 2): num = 3 print("With a input of 3: ") elif (i == 3): num...
e184909d1fc15daaeb34b22bd9f570d55038acfa
CPlusPlusNewb/python
/edhesive/notneededgarbage/2.2 Lesson Practice/question7.py
271
4.28125
4
if (3 * (6 + 2) / 2) == int("19"): print("Its the 1st") elif ((3 * 6) + 2 / 2) == int("19"): print("Its the 2nd") elif ((3 * 6 + 2) / 2) == int("19"): print("Its the 3rd") elif (3 * (6 + 2 / 2)) == int("19"): print("Its the 4th") else: print("Something went wrong")
6fa15a907656386148ef50e5f74667a8386b89be
selmanakinci/ran_simulation
/src/simulation/counter.py
19,404
4
4
import math import numpy import scipy import scipy.stats from matplotlib import pyplot class Counter(object): """ Counter class is an abstract class, that counts values for statistics. Values are added to the internal array. The class is able to generate mean value, variance and standard deviation. ...
ba22f1df4df1934f1624e0783d1eb39de413acc8
blanks-hub/MyAdventOfCode2020
/day6.py
901
3.609375
4
with open('day6input') as f: groups = f.read().split("\n\n") # Part One sum = 0 for group in groups: l = list() group = group.replace('\n', '') count = len(set([c for c in group])) # by creating a set we eliminate all duplicates. The len of that is our count sum += count print(sum) # Part Two ...
252d6fb9fb6b77cfd70c38325fedc0b50e1d530d
alantanlc/what-is-torch-nn-really
/functions-as-objects-in-python.py
1,897
4.71875
5
# Functions can be passed as arguments # We define an 'apply' function which will take as input a list, _L_ and a function, _f_ and apply the function to each element of the list. def apply(L, f): """ Applies function given by f to each element in L Parameters ---------- L : list containing the op...
78c1296a009f6ff19884a46f48e67f6795e312f4
mariarozanska/python_exercises
/zad9.py
768
4.34375
4
'''Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. Extras: Keep the game going until the user types “exit” Keep track of how many guesses the user has taken, and when the game ends, print this ou...
121a31eea9076b7df62cbc4ce36a95a580c97e01
mariarozanska/python_exercises
/zad8.py
770
3.921875
4
'''Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game) Remember the rules: Rock beats scissors Scissors beats paper Paper beats rock''' game = 'y' while game == 'y'...
05c0c977d43ec72ab6ba22d23a7d35d5ffbf8329
mariarozanska/python_exercises
/zad21.py
1,149
3.953125
4
'''Take the code from the How To Decode A Website exercise and instead of printing the results to a screen, write the results to a txt file. In your code, just make up a name for the file you are saving to. Extras: Ask the user to specify the name of the output file that will be saved.''' import requests from bs4 i...
5074c98d7c5c156bc79b06b5e9371112d6e8b4d8
mariarozanska/python_exercises
/zad31.py
3,356
4.5625
5
'''This exercise is Part 2 of 3 of the Hangman exercise series. Let’s continue building Hangman. In the game of Hangman, a clue word is given by the program that the player has to guess, letter by letter. The player guesses one letter at a time until the entire word has been guessed. (In the actual game, the player ...
548e8cf83d22bb87c84992822e8cac5e62072938
LoopGlitch26/MLH-Open-Hacks-hackathon
/hash_utils.py
1,438
3.640625
4
import json import hashlib def hash_string_256(string): # print(hashlib.sha256(string).hexdigest()) return hashlib.sha256(string).hexdigest() def hash_block(block): """Hashing a block and returns a string reprensentation of it. Arguments: :block: The block that should be hashed. """ ...
65d941544384a58e32913665a86d069d9fb03981
tahjserieuxuag/cspp10
/unit2/tserieux_pluralizer.py
932
4
4
word = input("Enter a noun ") number = int(input("Enter a numberber ")) if word[-2:] == "fe" and (number > 1 or number == 0) : print("{} {}".format(number,word[:-2]+"ves")) elif word[-2:] == "fe" and (number == 1): print("{} {}".format(number,word)) elif word[-2:] == "ay" or word[-2:] == "ey" or word[-2:] == "...
52487e95666484bc0830db377fcefca6b3ae18b8
pbsugg/data_sci_lib
/charts/bar_charts.py
628
3.734375
4
from matplotlib import pyplot as bar_chart from collections import Counter grades = [55,75,90,91,33,47,83,77,22,55,33] # break into deciles using this lambda function decile = lambda grade: grade // 10 * 10 # Counter histogram = Counter(decile(grade) for grade in grades) # elements to plot the histogram bar_chart.bar...
d12df1f95f8c75f639b56a366fdb938f4a30eca6
pranav83/PythonTesting
/FirstDemo.py
178
3.796875
4
print("Hello") a = 3 print(a) Str = "Hello World" print(Str) b, c, d = 5, 6.4, "Great" print("{} {}".format("Value is", b)) print(type(b)) print(type(d)) print(type(c))
953db76bd81a736b76f767f0206302bdfd7df579
pranav83/PythonTesting
/PythonBasics/DemoFunction.py
430
3.953125
4
# In python function is method its a group of statments that perform task # Function declaration in python you dont need to function greetMe(): def greetMe(): print("GoodMorning") greetMe() # Lets have parameter function/Method def greetMe(name): print("Hi how r u "+name) greetMe("Neelraj") # Let add two ...
73af528d54e3d1a31827b0c0630b380a996ec29f
mafrasiabi/tf-examples
/mnist_logreg.py
2,911
3.6875
4
""" MNIST handwritten digit classification with logistic regression based on https://www.tensorflow.org/get_started/mnist/beginners """ import numpy as np import matplotlib.pyplot as plt import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # Load the data data = input_data.read_data...
b424c3190e40316502f8288e4dae5e79fdd91507
bekahbooGH/oo-practice-melons
/harvest.py
4,131
3.578125
4
############ # Part 1 # ############ class MelonType(object): """A species of melon at a melon farm.""" def __init__(self, code, first_harvest, color, is_seedless, is_bestseller, name): self.code = code self.first_harvest = first_harvest self.color = color ...
0888ee74bdadb896a37263c1f5b373d0ee48a11b
icarus1513/pythonAlgorithm
/Base/Counter 연습.py
340
3.578125
4
from collections import Counter ex = Counter("Hello world") ##{'l': 3, 'o': 2, 'H': 1, 'e': 1, ' ': 1, 'w': 1, 'r': 1, 'd': 1} ex.most_common() ##[('l',3)] ex.update("Hello world") ##{'l': 3, 'o': 2, 'H': 1, 'e': 1, ' ': 1, 'w': 1, 'r': 1, 'd': 1} * 2 ## subtract 각 요소들을 빼기 ## elements 카운터 숫자만큼 요소 반환
acd8149aa301405e6045818c487e7e2fdbc71e10
icarus1513/pythonAlgorithm
/Level2/쿼드압축 후 개수 세기.py
675
3.625
4
from itertools import chain def zip(arr): arr_len = len(arr) unit = arr_len // 2 arr_sum = sum(chain(*arr)) if arr_len == 1: return [arr[0][0]] elif arr_sum == arr_len * arr_len: return [1] elif arr_sum == 0: return [0] arr1, arr2, arr3, arr4 = ( [ar[0:unit...
ea14a87a924c0a3249a884a9881a68a48e641b88
icarus1513/pythonAlgorithm
/Level2/소수 찾기.py
471
3.609375
4
import itertools def is_prime_number(x): if(x<=1): return False for i in range(2, x): if x % i == 0: return False return True def solution(numbers): val_set = set() for i in range(len(numbers),0,-1): for val in list(map("".join, itertools.permutations(numbers,i))):...
b0b34e0e55d54f4fab172fef68be25344450b32b
lompolo/OhjelmoinninAlkeet
/pythagoras_paalaellaan.py
228
3.75
4
from math import sqrt def laske_sivun_pituus(hypotenuusa): return sqrt(1 / 2 * hypotenuusa ** 2) h = float(input("Anna tasakylkisen kolmion hypotenuusan pituus: ")) print("Kylkien pituus: " + str(laske_sivun_pituus(h)))
0501d807f5da9538067a267aa9ee81df405aa6b1
lompolo/OhjelmoinninAlkeet
/salakalassa.py
246
3.75
4
def kysy_salasana(): while True: merkkijono = input("Kirjoita salasana: ") if len(merkkijono) >= 8: return merkkijono print("Salasanan tulee olla vähintään 8 merkkiä pitkä") print(kysy_salasana())
99969c675016d5fb93cc27ee24b571555d847d98
AnastasiiaZhuk/Python_algorithms
/string_algorithms/common_prefix.py
464
3.6875
4
def common_prefix(str1, str2): if not str1 or not str2: return "" k = 0 while str1[k] == str2[k]: k += 1 if k >= len(str1) or k >= len(str2): return str1[0 : k] return str1[0 : k] def common_of_all_strs(strs): if not strs: return "" result = strs[0] ...
586a918680f552e5878ff90b882bc24320469d01
eranfuchs1/DI_Bootcamp
/Week4/Day5/exercise1/exercise3.py
261
3.53125
4
lowers, uppers = 0, 0 for i in map(lambda l: 1 if l.isupper() else 2 if l.islower() else 0, input()): if i == 1: uppers += 1 elif i == 2: lowers += 1 print(f'number of lowercase letters: {lowers}, number of uppercase letters: {uppers}')
9cb6cd4713c5ca34d02f618fa1935ac5230040ed
eranfuchs1/DI_Bootcamp
/Week4/Day2/exercise_xp_gold/exercise1/untitled.py
188
3.78125
4
def list_concat(a, b): answer = [] for item in a: answer.append(item) for item in b: answer.append(item) return answer print(list_concat([1,2,3], [4,5,6]))
789e14dfab77eb29cad9357cd199ec2bc020e6cc
eranfuchs1/DI_Bootcamp
/Week4/Day2/exercise_xp/exercise10/untitled.py
346
3.96875
4
toppings = set() while True: topping = input('enter a topping: ') if topping == 'quit': break else: toppings.add(topping) print(f'adding {topping} to pizza...') print('the toppings are: ', end = '') for topping in list(toppings): print(f'{topping}', end=', ') print(f'\nprice: {10...
994f361e9c8514157067bf8c66a3f00df9230d8c
eranfuchs1/DI_Bootcamp
/Week4/Day5/exercise1/exercise7.py
153
3.640625
4
list_count = lambda arr, item: (1 if arr[0] == item else 0) + list_count(arr[1:], item) if len(arr) > 0 else 0 print(list_count(['a','a','t','o'],'a'))
42da9e78fe4e8f045d59116d42c1f4b9462297c9
eranfuchs1/DI_Bootcamp
/Week4/Day1/exercises/exercise_xp_ninja/exercise5/untitled.py
261
4.0625
4
size = 0 sentence = '' while True: sentence = input('enter the longest sentence you can without the letter \'a\' or \'A\'') if 'a' in sentence.lower(): continue if len(sentence) > size: print('congrats') size = len(sentence)
b548c73dc5acdf026001c9ef1886e7c02f493806
eranfuchs1/DI_Bootcamp
/Week4/Day2/untitled.py
249
3.765625
4
num = int(input()) spacing = '\t' print(spacing, end = '') for j in range(num + 1): print(j, end = spacing) print() for i in range(num + 1): print(i, end = spacing) for j in range(num + 1): print(i*j, end=spacing) print()
5d6d3717c204cdf2a83246914f7284db84c09fc2
sebastianceloch/wd_io
/kolos1/zadanie7.py
955
3.625
4
""" Napisz funkcję, która przyjmuje listę wyrazów jako parametr wejściowy. Funkcja losuje jeden z wyrazów jako wyraz do odgadnięcia. Następnie losowana jest jedna litera tego wyrazu i na wyjściu wyświetlany jest ten niekompletny wyraz, np. wylosowany wyraz to piłka, wyświetlane jest _ _ ł _ _. Użytkownik wpisuje wyraz ...
19a50ed075b3ce0e8872bf9db1e4e74c898dc17d
sebastianceloch/wd_io
/kolos1/zadanie3.py
376
3.796875
4
""" Napisz funkcję, która przyjmuje listę plików jako argument wejściowy, i zapisuje ich zawartość do jednego pliku (dowolna nazwa pliku wyjściowego) """ def plik(lista): plik = open("plik.txt","w") for x in range(0,len(lista)): plik.write(str(lista[x])) plik.write("\n") plik.close() lista=[...
25f9411fe628a5bed07b396a8b3b4572c7822130
sebastianceloch/wd_io
/lab5/zadanie8.py
740
3.625
4
class Samogloski: def __init__(self, napis): if isinstance(napis, str): self.napis = napis self.index = 0 self.lista = ['a','ą','e','ę','i','o','ó','u','y','A','Ą','E','Ę','I','O','Ó','U','Y'] def __iter__(self): return self def __next__(self): i...
d7e13007c560e85278b99526af65e689d2c96e5e
sebastianceloch/wd_io
/lab5/zadanie11.py
136
3.6875
4
def fib(n): a=0 b=1 for _ in range(n): yield a temp = a+b a = b b = temp print(list(fib(5)))
cd9036b5e26a9da13b5ae64159ae209f12792ded
MykolaMorhunCR/Python_edu
/tasks/Trian.py
2,034
4.03125
4
import unittest class Triangle: def __init__(self, a, b, c): self.a = a self.b = b self.c = c ## Couldn't find way to test raised exceptions in constructor if not type(a) is int: raise TypeError("Only integers allowed") elif type(b) is not int: ...
694f6b46ead0120e14c6f65ed66e169d7a8cee9b
Kbusiness9/election_anlyis
/Python_pratice.py
6,370
3.75
4
print("Hello World!") print(type(3)) print(type("Kim")) ballots =1,341 print(type(ballots)) print(type(73.81)) print(type("")) isDog = True print(type(isDog)) num_candidates = 3 winning_percentage = 73.81 candidate = "Diane" won_election = True print(num_candidates) print(won_election) print(candidate) print("-------"...
8f14c85ca13f7d7b34dbd4d0454fe00abbb3d7b2
Tatsi94/smth
/task4.py
404
3.640625
4
n = 10 m = 2 s = 6 k = n - m def factorial(data): res = 1 for data in range(1, data + 1): res = data * (factorial(data - 1)) return res def probability(data): res = (factorial(n) / (factorial(m) * factorial(k))) * (((7 - s) / 6)**m) * (1 - ((7 - s) / 6))**k return res ...
8a459b534a5920f6947717a6997a8cb6a72355f2
Rivarrl/leetcode_python
/leetcode/601-900/897.py
4,473
3.8125
4
# -*- coding: utf-8 -*- # ====================================== # @File : 897.py # @Time : 2019/12/1 23:59 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [897. 递增顺序查找树](https://leetcode-cn.com/problems/increasing-order-search-tree/) ""...
31892853443e884664665adf8fa8a460e2b203d3
Rivarrl/leetcode_python
/leetcode/1-300/20.py
794
3.671875
4
# -*- coding: utf-8 -*- # ====================================== # @File : 20.py # @Time : 2020/8/8 23:20 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [20. 有效的括号](https://leetcode-cn.com/problems/valid-parentheses/) """ @timeit ...
674a6ca3842d4489dbce7f8652fde48aff558345
Rivarrl/leetcode_python
/leetcode/301-600/392.py
597
3.5
4
# -*- coding: utf-8 -*- # ====================================== # @File : 392.py # @Time : 2020/7/27 0:26 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: @timeit def isSubsequence(self, s: str, t: str) -> bool: if not s: return True ...
fd2a158c6db2e78540466fd64572a1a712e7279f
Rivarrl/leetcode_python
/leetcode/301-600/381.py
1,265
3.609375
4
# -*- coding: utf-8 -*- # ====================================== # @File : 381.py # @Time : 2020/7/28 3:20 下午 # @Author : Rivarrl # ====================================== from algorithm_utils import * import random from collections import defaultdict class RandomizedCollection: """ [381. O(1) 时间插入、删除和获取...
be6446e5b605222a772ff5dff617d039495bf5ac
Rivarrl/leetcode_python
/leetcode/LCP186+/5528.py
1,536
3.578125
4
# -*- coding: utf-8 -*- # ====================================== # @File : 5528.py # @Time : 2020/10/17 22:48 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [5528. 网络信号最好的坐标]() """ @timeit def bestCoordinate(self, towers: List[L...
8800b389957a6d4a07b49ac1d95be20170ad641e
Rivarrl/leetcode_python
/leetcode/leetcode_hr2.py
23,575
3.734375
4
from typing import List from algorithm_utils import * # leetcode困难题2 def numberToWords(num): """ 273. 整数转换英文表示 将非负整数转换为其对应的英文表示。可以保证给定输入小于 231 - 1 。 示例 1: 输入: 123 输出: "One Hundred Twenty Three" 示例 2: 输入: 12345 输出: "Twelve Thousand Three Hundred Forty Five" 示例 3: 输入: 123456...
4f3c018feb94740cb6429618e80974035f72bbd9
Rivarrl/leetcode_python
/leetcode/1501-1800/1599.py
1,030
3.546875
4
# -*- coding: utf-8 -*- # ====================================== # @File : 1599.py # @Time : 2020/10/1 12:14 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [1599. 经营摩天轮的最大利润](https://leetcode-cn.com/problems/maximum-profit-of-operating-a-ce...
f33aed1bd84a67b5adb2185d15a874b7f82a6a49
Rivarrl/leetcode_python
/leetcode/1-300/2.py
1,321
3.734375
4
# -*- coding: utf-8 -*- # ====================================== # @File : 5276.py # @Time : 2019/11/9 16:30 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: """ [2. 两数...
858ffb3ed171f478a4190b28408a5e3c69ff95b5
Rivarrl/leetcode_python
/leetcode/1-300/202.py
750
3.515625
4
# -*- coding: utf-8 -*- # ====================================== # @File : 202.py # @Time : 2020/4/30 14:00 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [202. 快乐数](https://leetcode-cn.com/problems/happy-number/) """ @timeit de...
f051ec7fbe8099906730789c40ac2e996ce061eb
Rivarrl/leetcode_python
/leetcode/LCP173+/5367.py
1,208
3.578125
4
# -*- coding: utf-8 -*- # ====================================== # @File : 5367.py # @Time : 2020/3/22 10:59 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [5367. 最长快乐前缀](https://leetcode-cn.com/problems/longest-happy-prefix/) """ @...
86e1ac5a6d94f53d35c570e490f48afe7d84e2c2
Rivarrl/leetcode_python
/leetcode/601-900/641.py
3,494
4.03125
4
# -*- coding: utf-8 -*- # ====================================== # @File : 641.py # @Time : 2020/12/21 10:00 上午 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Node: def __init__(self, val): self.val = val self.pre = None self.next = N...
94fb173f9dd7357f6467bdb383f6a16d1968df09
Rivarrl/leetcode_python
/leetcode/1-300/9.py
954
3.5625
4
# -*- coding: utf-8 -*- # ====================================== # @File : 9.py # @Time : 2019/11/10 21:28 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: @timeit def isPalindrome(self, x: int) -> bool: """ [9. 回文数](https://leetc...
b14005075f70c5543d9175e09bda0e1a35d3f765
Rivarrl/leetcode_python
/leetcode/LCP/5155.py
919
3.515625
4
# -*- coding: utf-8 -*- # ====================================== # @File : 5155.py # @Time : 1/25/20 10:31 PM # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [5155. 数组序号转换](https://leetcode-cn.com/problems/rank-transform-of-an-array/) ""...
8c937ab07cdc815b67027a34671635a7eb70e3ce
Rivarrl/leetcode_python
/leetcode/301-600/451.py
849
3.6875
4
# -*- coding: utf-8 -*- # ====================================== # @File : 451.py # @Time : 2020/7/30 11:49 上午 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [451. 根据字符出现频率排序](https://leetcode-cn.com/problems/sort-characters-by-frequency/) ...
6e32d839e8f10880d1f7817afd1db976ee7c6ae5
Rivarrl/leetcode_python
/leetcode/601-900/868.py
832
3.78125
4
# -*- coding: utf-8 -*- # ====================================== # @File : 868.py # @Time : 2019/11/15 0:38 # @Author : Rivarrl # ====================================== class Solution: """ [868. 二进制间距](https://leetcode-cn.com/problems/binary-gap/) """ def binaryGap(self, N: int) -> int: ...
b8d3493629c64534e65d670568a69203dacae015
Rivarrl/leetcode_python
/leetcode/LCP.py
2,237
3.953125
4
# -*- coding:utf-8 -*- # leetcode LCP题号的题 def game(guess, answer): """ LCP 1. 猜数字 小A 和 小B 在玩猜数字。小B 每次从 1, 2, 3 中随机选择一个,小A 每次也从 1, 2, 3 中选择一个猜。他们一共进行三次这个游戏,请返回 小A 猜对了几次? 输入的guess数组为 小A 每次的猜测,answer数组为 小B 每次的选择。guess和answer的长度都等于3。 示例 1: 输入:guess = [1,2,3], answer = [1,2,3] 输出:3 解释:小A 每次...
914bf490e08ff5cd453c610ddf42d00d55a91617
Rivarrl/leetcode_python
/leetcode/301-600/372.py
969
3.828125
4
# -*- coding: utf-8 -*- # ====================================== # @File : 372.py # @Time : 2020/4/21 19:53 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [372. 超级次方](https://leetcode-cn.com/problems/super-pow/) """ @timeit def ...
d007075810db4933f6f8e191bef6e8a336d398b1
Rivarrl/leetcode_python
/leetcode/LCP173+/5171.py
1,192
3.625
4
# -*- coding: utf-8 -*- # ====================================== # @File : 5171.py # @Time : 2020/2/23 11:18 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [5171. 最接近的因数](https://leetcode-cn.com/problems/closest-divisors/) """ @time...
d1dfd5656844f4782ef2d14df20774d6f8ee937b
Rivarrl/leetcode_python
/leetcode/LCP/5275.py
1,305
3.65625
4
# -*- coding: utf-8 -*- # ====================================== # @File : 5275.py # @Time : 2019/12/1 10:21 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ 5275. 找出井字棋的获胜者 """ @timeit def tictactoe(self, moves: List[List[int]])...
41de46ab06cc711c880b51cefdfee4a229ae748e
Rivarrl/leetcode_python
/leetcode/601-900/696.py
751
3.5
4
# -*- coding: utf-8 -*- # ====================================== # @File : 696.py # @Time : 2020/8/10 0:02 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [696. 计数二进制子串](https://leetcode-cn.com/problems/count-binary-substrings/) """ ...