blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e7fdcf614a86f86f6507daed6e55518a2d45b56c
bplank/BA-scriptie
/exercise/logistic_regression_sentiment.py
2,855
4.0625
4
__author__ = "bplank" """ Exercise: sentiment classification with logistic regression 1) Examine the code. What are the features used? 2) What is the distribution of labels in the data? 3) Add code to train and evaluate the classifier. What accuracy do you get? What is weird? 4) How could you improve the representatio...
dcdc80a0e64f547a07e224a1a4de7d61e9daa764
nyxgear/TIS-diversity-algorithms
/diversity/neighborhood.py
1,724
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from copy import copy import random from .default_diversity_functions import diversity_element_element def neighborhood(elements, ngb_range, diversity_element_element=diversity_element_element): """ elements: input array, the initial set of el...
577b91f8defdad9a264821b12a66a32ee592d916
scttohara/python_card_game
/main.py
3,900
3.921875
4
""" Entry point for card game """ import read_and_write_to_file_functions import functions_that_affect_the_deck from time import time import functions_that_print_to_the_screen import score_and_round_results_handling def main(): """ entry point of program. Just calls functions no real logic handled here ...
8bf32f0f4428739480da8aded54191edbf227f0c
anipmehta/InterviewCake
/arrays_and_strings/test_grid.py
2,678
3.671875
4
''' Linearly interpolate down a path of points by a ratio of the path's length. ''' import math def interp(points, ratio): # do stuff here previous_x = points[0][0] previous_y = points[0][1] total_distance = 0 distances = [] for i in range(1, len(points)): current_x = points[i...
07c0f47c47c913fff2aea34c9f84413d24ffddd2
AlexSelby1/Snake
/main.py
1,310
3.890625
4
from turtle import Screen, Turtle from snake import Snake from food import Food from scoreboard import Scoreboard import time # Create suitable screen for game screen = Screen() screen.setup(width=600, height=600) screen.bgcolor("black") screen.title("Snake") screen.tracer(0) # Creating classes snake = Snake() food =...
822b57a3f9cba6d6a4b6578d929d2bde09828283
microgenios/cod
/03/xx/07-sklearn/02-classification/0a-classification/label_encoder.py
830
3.71875
4
#!/usr/bin/python import numpy as np from sklearn import preprocessing input_labels = ["red", "black", "red", "green", "black", "yellow", "white"] # Sample input labels encoder = preprocessing.LabelEncoder() # Create label encoder and fit the labels encoder.fit(input_labels) print("\nLabel mapping:") # Print the ma...
800193657e45645d2625a1b4e52b6b61aa74b047
microgenios/cod
/03/xx/07-sklearn/c-ipython/2015/2015lab4/Lab4-stats_original.py
32,926
3.546875
4
#!/usr/bin/env python # coding: utf-8 # # CS-109: Fall 2015 -- Lab 4 # # # Regression in Python # # *** # This is a very quick run-through of some basic statistical concepts # # * Regression Models # * Linear, Logistic # * Prediction using linear regression # * Some re-sampling methods # * Train-Test s...
f7f586bf1e0a8e0da6a6330d6fe66146ad2d2e1a
microgenios/cod
/03/xx/07-sklearn/16-deep-learning/11-deep-learning/deep_neural_network.py
1,412
4
4
#!/usr/bin/python import neurolab as nl import numpy as np import matplotlib.pyplot as plt min_value = -12 # Generate training data max_value = 12 num_datapoints = 90 x = np.linspace(min_value, max_value, num_datapoints) y = 2 * np.square(x) + 7 y /= np.linalg.norm(y) data = x.reshape(num_datapoints, 1) labels = y.re...
82e34bc5cf9d0c85825adc98f8564e7a62eb37f8
microgenios/cod
/03/xx/07-sklearn/b-python/fuzzypy.py
3,006
3.640625
4
# Fuzzy Logic experiment (WIP) # Objects are not always in one of two states (true or false), but rather in several states at one time. # By the Tutorial Doctor # --------------------------------------------------------------------------- # (val-min)/(max-min) # ---------------------------------------------------------...
2ad7b8cd403bc0af2ef6dc05742d57e27944fb00
jack-skerrett-bluefruit/InterviewCalculatorInPython
/maths_tests.py
3,048
3.625
4
import maths def test_fresh_calculator_has_current_number_as_zero_by_default(): test_class = maths.Math() assert test_class.current_number == "0" def test_fresh_calculator_has_stored_number_as_nothing_by_default(): test_class = maths.Math() assert test_class.stored_number == "" def test_fresh_calcula...
b0050528e419a1e1b813bfcf066a254f4f0f3e50
Iliakra/Python-HW-1
/task_1.py
612
4.34375
4
""" Красильников Илья 1. Поработайте с переменными, создайте несколько, выведите на экран, запросите у пользователя несколько чисел и строк и сохраните в переменные, выведите на экран. """ a = 10 b = 'Привет!' c = 15 name = input("Введите ваше имя ") age = int(input("Введите ваш возраст ")) week_day = input("Какой с...
ed94e2ce732a1af59fcd78c22963771594b723c6
znchnk/UniversityTasks
/kendall tied ranks.py
1,769
3.625
4
import tkinter import tkinter.ttk import numpy as np print('Введите кол-во экспертов') exp=int(input()) print('Введите кол-во факторов') fac=int(input()) def kend(ocenki): data=[[znach[i][j].get() for j in range(len(znach[0]))] for i in range(len(znach)) ] #print(data) znam = exp**2*(f...
2c9542f4faaf10c1d52afac854ebd976675d93dd
DanoBuck/PythonLabs
/Factorial.py
278
3.75
4
def factorialRecursive(number): if number < 1: return 1 return number * factorialRecursive(number-1) # BE SURE TO CAST TO A LIST TO ENABLE PRINTING CONTENTS listOfDigets = [1,2,3,4,5,6,7,8,9] newList = list(map(factorialRecursive, listOfDigets)) print(newList)
36a578ed1392db5d561256300834b968f7ed5275
DanoBuck/PythonLabs
/CA3_X00109141.py
2,604
3.796875
4
# CA 3 # Daniel Buckley # X00109141 from functools import reduce def convertEurosToOther(ammount, currency): euro_to_us_dollars = 1.09105 euro_to_pounds = 0.844123 euro_to_candian = 1.49805 if str.upper(currency) == "CANADIAN": return round(ammount * euro_to_candian, 2) elif str.upper(curr...
42cfacc54b0faf986b2825549e277841f92e39b5
aidardarmesh/hackerrank
/Problems/Min Heap.py
2,382
3.59375
4
class MinHeap: items = [] size = 0 def get_left_child_index(self, parent_index): return 2*parent_index+1 def get_right_child_index(self, parent_index): return 2*parent_index+2 def get_parent_index(self, child_index): return (child_index-1) // 2 def has_left_ch...
d51654a28343c241f6013d89824150559504aa9b
ronaldvilchez98/Santotomas_estructuras_programacion
/python_3/guia4/Ejercicio_1.py
660
4.125
4
''' :::::::::::::::::::::::::::::::::::::::::::::: :: @github: adrian273 :: :: @email: adrianverdugo273@gmail.com :: :::::::::::::::::::::::::::::::::::::::::::::: 1@ Lea el Radio de una circunferencia y calcule: a. Diámetro = 2 * Radio. b. Perímetro = 2 * Radio *...
284489884cd23e359c82aed095280971f136756b
ronaldvilchez98/Santotomas_estructuras_programacion
/python_3/guia5/Ejercicio_6.py
917
4.1875
4
''' @ Leer el tiempo que se demoraron las personas en correr una maratón (Los tiempos son ingresados sin orden), dejara de leer cuando se ingrese cero. Calcular: a. Número de personas que llegaron a la meta. b. Tiempo promedio de la maratón. c. El tiempo menor. d. El tiempo m...
2352b0a78441a48b5f614a2b8fe212a91cd019bf
ronaldvilchez98/Santotomas_estructuras_programacion
/python_3/guia5/Ejercicio_1.py
526
3.8125
4
''' :::::::::::::::::::::::::::::::::::::::::::::: :: @github: adrian273 :: :: @email: adrianverdugo273@gmail.com :: :::::::::::::::::::::::::::::::::::::::::::::: 1@ Leer un numero y generar los impares siguientes hasta el 100 ''' number = int(input('Ingrese numero \n')...
785bbe9dd340392255a4c38ad66290424175e782
ronaldvilchez98/Santotomas_estructuras_programacion
/python_3/guia4/Ejercicio_4.py
640
4.0625
4
''' :::::::::::::::::::::::::::::::::::::::::::::: :: @github: adrian273 :: :: @email: adrianverdugo273@gmail.com :: :::::::::::::::::::::::::::::::::::::::::::::: 4@ Lea un número y determine si un número es par o impar.Considere que un número par, al ser dividido por d...
906ab9e6446e35910a0418c6007f3b5d5a613a61
ronaldvilchez98/Santotomas_estructuras_programacion
/python_3/guia_python_section_2/ejercicio_15.py
5,350
3.625
4
"""ejercicio_15.py @description: Que gestiona las notas de una clase de 20 alumnos de los cuales sabemos el nombre y la nota. El programa debe ser capaz de: @Buscar un alumno. {ok} @Modificar su nota. {ok} @Realizar la media de todas las notas. {ok} @Realizar la ...
0b40509ae71bc4fcb2c1cd3ab24beed2274a7b99
Pritons/Python-
/Firststeps/list.py
208
3.765625
4
import random def randintlist(len, ceiling): list1 = list() for x in range (len): number = random.randint(1, ceiling) list1.append(number) return list1 print(randintlist(5, 10))
475173738f2afd0613aad3598dd09696eb1421d9
Sachin-D-N/Python
/Python-Fundamentals/06.Functions.py
14,783
4.5
4
"*****Functions******" #by default return more than one value it comes with tuple #function is a block of code it runs only when we called #return can store and we can use it def cylinder_volume(height, radius): pi = 3.14159 return height * pi * radius ** 2 cylinder_volume(1,2) #This is called Func...
027b43cecba46fbffdac4b5c60fb95f25dc12d1d
Sachin-D-N/Python
/Python-Fundamentals/08.Modules.py
4,865
4.5
4
#https://docs.python.org/3/py-modindex.html "Modules" #A file containing a set of functions you want to include in your application. #packages are collection of modules """We can define our most used functions in a module and import it, instead of copying their definitions into different programs.""" import ...
7c7bad650d055c896e36b274c30abc7aa5dce93e
misladkova/python_exercises
/pyramida.py
295
3.609375
4
n = int(input()) k = (2*n//2)-1 m = 1 j = (2*n//2)-1 for r in range(0, n): for c in range(0, k): print('.', end = '') k = k-1 for c in range(0, m): print('*', end = '') m = m+2 for c in range(0, j): print('.', end = '') j = j-1 print()
6ae0cc2878cee603447cc9360e97b108b215c1cc
Xiraj/LessonPython
/3-the generosity of the steam.py
677
3.53125
4
member = input("Apakah member? ") time = int(input("Lama member (tahun)? ")) month = input("Bulan lahir? ") year = int(input("Tahun game? ")) multi = input("Apakah multiplayer? ") skema1 = 0 skema2 = 0 if member in ("Ya", "ya", "YA"): skema1 += 5 if time <= 10 and time >= 5 : skema1 += 20 else : skema1 += ...
2d99da3659f1e3629e1e0418b1ab88e1b854404a
adithyanarayanan/News-Scope
/file_read.py
245
3.984375
4
## Reads a text file and outputs it as a single string for the analyzer in main.py to read def create_string(file): filename = open(file, 'r') str = "" for line in filename: # print(line) str += line return str
0afcab97614678dd6da9741c1bf6cebce8cce9b5
ryanofarrell/ncaa-basketball
/code/dbLoad/generatePredateSeasonTeamCsv.py
2,437
3.578125
4
""" This module makes CSV files with seasonteams data for each team on each date in a given season. CSVs are dumped into /Users/Ryan/Documents/projects/ncaa-basketball/data/predate_games/ One CSV for each season, with a record for each team on each date of that season. The CSVs can be used to replicate what data was av...
b9d32a3c26e509739d49de89450f12a6aabebef2
bittu99nic/Rock_Paper_Scissors
/rps_game.py
1,741
4.125
4
import random total_game_time = 0 high_score = 0 print("LET'S PLAY ROCK PAPER SCISSORS\n") user_game_choice = 'no' while user_game_choice[0] == 'n' or user_game_choice[0] == 'N': # getting user input total_game_time = 1 + total_game_time user_choice = input("ENTER ROCK//PAPER//SCISSORS ") # gam...
290ff1d1bc0bdba28457fe36d48aeeaed1ec6211
IvyHole/c
/python/1183.py
91
3.8125
4
def res(n): m=list(n) m.reverse() for p in m:print(p,end='') n=input() res(n)
27be5bb530540c937f204d931a8cb75a325242fb
IvyHole/c
/python/1172.py
74
3.59375
4
n=int(input()) i=1 sum=1 while i<n: sum=(sum+1)*2 i+=1 print(sum)
48c35f90d8e790ec25dca6cb8ee5c6347b958946
IvyHole/c
/python/1148.py
121
3.53125
4
li = input().split() while len(li): print(['last', 'first'][min([int(x) for x in li]) % 2]) li = input().split()
ca95fcd9b9b62e0bcd9c33953bf60e5985e4bf88
IvyHole/c
/python/1127.py
131
3.71875
4
while 1==1: x=int(input()) if 0<=x<=14: print("%.2f"%(x*6)) elif 15<=x<=500: print("%.2f"%(x*(6-0.1)))
4756747b60219eaecb57896c416cbf92f47c2594
hansewetz/gitrep2
/src/python/algorithms/subsets/subsets.py
574
3.875
4
#!/usr/bin/env python import sys # generate subsets # v - vector # bv - bol vector, true of element part of subset, false otherwise # k - current position # n #of elements in v def subsetsAux(v,bv,k,n): # check if we should print elements if k==n: for i in range(0,n): if bv[i]: sys.stdout.write("{0} ".f...
d528f0bca80992d311cf722b6e284e3265390492
mavridiSS/Programming101-3
/week5/1-Dungeons-and-Pythons/Tests/test_dungeon.py
3,077
3.59375
4
import unittest from dungeon import Dungeon from hero import Hero """ S.##.....T #.##.S###. #.###E###E #E....###. ###T#####G """ class TestDungeon(unittest.TestCase): def setUp(self): self.dungeon = Dungeon('test_map.txt') self.hero = Hero(name="Bron", title="Dragonslayer...
86e14a9d5dbe4bcc68c2110a5a4686269226d67e
mavridiSS/Programming101-3
/week7/1-Scan-Bg-Web/histogram.py
357
3.546875
4
class Histogram: def __init__(self): self.histogram = {} def add(self, key): if key not in self.histogram: self.histogram[key] = 1 else: self.histogram[key] += 1 def count(self, key): if key in self.histogram: return self.histogram[key] ...
403372c2c7bbeb5b4c024a1732e74aeeb2fad32a
zakidem/DataCamp
/Course/01-Intermediate Python for Data Science/Chapter 1 Matplotlib/Line plot(3).py
219
3.640625
4
# Print the last item of gdp_cap and life_exp print(gdp_cap,life_exp) # Make a line plot, gdp_cap on the x-axis, life_exp on the y-axis x = gdp_cap y = life_exp plt.plot(gdp_cap,life_exp) # Display the plot plt.show()
eb3798fe34ce29e3440cfb6e8fb61512150e4aa3
IndiraM/ProjectEuler
/Problem34.py
463
3.765625
4
def Curious_number(n): res = 0 for curious in str(n): sum = 1 for i in range(1,int(curious)+1): sum=sum*i res = res+sum #print n,res return res if __name__ == '__main__': for number in range(3,1000000): out = Curious_number(number) #p...
da6e992420fb4f2847283e8e08e3026eb22e0181
IndiraM/ProjectEuler
/Problem22.py
1,031
3.9375
4
'''Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For exampl...
5dcba888e08d45d12bf48aa9b7932cfd21f29102
msiebert1/UCSC_spectral_pipeline
/spectral_reduction/tmath/wombat/womrelvel.py
665
3.5625
4
def womrelvel(hop): """relativistic velocity calculation""" from tmath.wombat.inputter import inputter light_speed=2.99792458e5 print('Relativistic velocity calculation\n') lambda1=inputter('Observed wavelength ','float',False) print(' ') lambda0=inputter('Rest wavelength ','float',Fals...
ad0cc2c7eee4ed76a0022b06a5eb39d6a87c88a2
msiebert1/UCSC_spectral_pipeline
/spectral_reduction/tmath/wombat/womhertz.py
608
3.609375
4
def womhertz(hop): """converts wavelength to hertz for f_nu spectrum""" import numpy as np print('NOTE: The routine expects an f_nu spectrum') print(' I will try to guess if the spectrum') print(" has been scaled by 1E26 (it shouldn't be)") print(' ') print(' Check this be...
756467e464e5433920f39de43047f3160c3e488e
msiebert1/UCSC_spectral_pipeline
/spectral_reduction/tmath/wombat/womscalemany.py
2,935
3.53125
4
def womscalemany(hop): """scale many hoppers to one""" import matplotlib.pyplot as plt import numpy as np import logging from tmath.wombat.inputter import inputter from tmath.wombat.womwaverange import womwaverange from tmath.wombat.womget_element import womget_element from tmath.wombat ...
b0d262a6c9551f72b69c8836c304654f55e0350e
SolutionsDigital/Yr10_Activities
/Activity03/Act03_proj3.py
376
3.984375
4
""" File : Act03_proj3.py Name : Michael Mathews Date : 25/01/2020 # Program Purpose : printing Prime Number status up to 20 """ for n in range(1, 20): for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) break else: # loop fell through wit...
22f45c55c5186a48db58dbf10e2ce64a5a78198f
SolutionsDigital/Yr10_Activities
/Activity05/Act05_proj1.py
603
4.28125
4
""" File : Act05_proj1.py Name : Michael Mathews Date : 02/02/2020 Program Purpose :Display List and using the index value display the first and second last list values """ # List sample for output myList=[1,2,3,4,5,6] #shows list elements inside the square brackets print(myList) #shows list elements in single colum...
82922eef8c48e4bc5c01c06ac65b119e8b06f297
SolutionsDigital/Yr10_Activities
/Activity04/Act04_proj6C.py
1,689
4.4375
4
""" Volume solver - Collection of methods for calculating various volume formulas using floats or decimals yet """ import math def volume_of_cube(): side =float( input("side ? ")) answer = side * side * side print(f"Volume_of_cube with side {side} is {answer} cubic units") def volume_of_box(): width =...
ef7a5c2abc34ff632892ad06171a2afb2e28c0b4
SolutionsDigital/Yr10_Activities
/Activity05/Act05_proj4.py
648
3.953125
4
""" File : Act05_proj4.py Name : Michael Mathews Date : 02/02/2020 Program Purpose: : Investigate common factors for user defined integers and upper limit """ # upper boundary defined by user upper = int(input("what is the upper boundary :")) # create list = l ready for data list=[] # prompt user for fist factor...
d4659ea4c213a454d4b8f5080312da4fe85f8d9b
swanyriver/leetcode
/lru.py
2,771
3.609375
4
class node(object): def __init__(self,key): self.key = key self.prev = None self.next = None class LRUCache(object): def __init__(self, capacity): """ :type capacity: int """ self.capacity = capacity self.cache = {} self.sentinal = node(N...
f5454dc9c3841fbf801e9847587cd8969d422050
StockLin/Data_Analysis_practice_projects
/CNN_dog_cat_classification_20181010/cnn_dogs_cats_classification.py
3,619
3.609375
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 10 16:15:39 2018 @author: Stock """ from keras.models import Sequential from keras.layers import Convolution2D from keras.layers import MaxPool2D from keras.layers import Flatten from keras.layers import Dense # ==========================================================...
eed9881dc1a8b35df1b0576cff497b2b34899b10
MartinH97/Ejercicio1
/clase_3/3_recorrer_string.py
136
3.859375
4
palabra= input("Ingrese una palabra: ") for i in palabra: caracter_transformado= i.upper() print(caracter_transformado)
1d2353c6863bed81cd2eb687420894745da8b7d9
hpellis/datacamp_data_scientist_with_python
/7_cleaning_data_in_python/3_combining_data_for_analysis.py
6,881
4.34375
4
###Combining rows of data #The dataset you'll be working with here relates to NYC Uber data. The original dataset has all the originating Uber pickup locations by time and latitude and longitude. #For didactic purposes, you'll be working with a very small portion of the actual data. #Three DataFrames have been pre-loa...
7bbdc002844f1b93a8b24f752a59b42bc6678637
hpellis/datacamp_data_scientist_with_python
/8_pandas_foundations/4_case_study_sunlight_in_austin.py
15,052
4.40625
4
###Reading in a data file #Now that you have identified the method to use to read the data, let's try to read one file. #The problem with real data such as this is that the files are almost never formatted in a convenient way. #In this exercise, there are several problems to overcome in reading the file. First, there i...
e5e21b34b76f309d0e9af4465f1b20a18af07e3d
rimys/book1
/1.py
311
3.96875
4
alien_color = '' while alien_color != 'exit': alien_color = input('Enter visible alien color: ') if alien_color == 'green': print('You earned 5 points!') if alien_color == 'yellow': print('You earned 10 points!') if alien_color == 'red': print('You earned 20 points!')
d4784bdb4eda47e026870ccd03763ad1451b5bae
the-last-question/CodeTask-BrunaAndrade
/Q04.py
288
4.09375
4
def __isPalindrome(string): return string == string[::-1] def __main__(): inputString = input("Palavra:") if(__isPalindrome(inputString)): print(inputString + " É um palíndromo.") else: print(inputString + " Não é um palíndromo") __main__()
0ed53f7a27b369b43637e1e189a26ff2c08f4f57
GaryRevell/AdventOfCoffee
/grevell/day_04.py
1,089
4
4
""" --- Day 4: High-Entropy Passphrases --- A new system policy has been put in place that requires all accounts to use a passphrase instead of simply a password. A passphrase consists of a series of words (lowercase letters) separated by spaces. To ensure security, a valid passphrase must contain no duplicate words. ...
35738f75e5d839bf04b1c4238c37c37e969862bc
delaanthonio/hackerrank
/data_structure/stack/poisonous_plants/solution.py
1,270
4.25
4
#!/usr/bin/env pypy3 """ Poisonous Plants :author: Dela Anthonio :hackerrank: https://hackerrank.com/delaanthonio :problem: https://www.hackerrank.com/challenges/poisonous-plants """ import itertools import sys from collections import namedtuple from typing import List Plant = namedtuple('Plant', 'pesticide days_ali...
c2742d98f2182f071a0abcec8fbcabe05a185e39
delaanthonio/hackerrank
/algorithm/bit_manipulation/xor_queries/solution.py
779
3.65625
4
#!/usr/bin/env python3 """ Xor Queries :author: Dela Anthonio :hackerrank: https://hackerrank.com/delaanthonio :problem: https://www.hackerrank.com/contests/codeagon/challenges/xor-queries """ import sys def solve(x: int, l: int, r: int) -> int: complement = ~x mask = 1 while mask < r: mask *= 2...
1e3d99bdc12ee5d7d92ba95124d1cbba1c87f340
delaanthonio/hackerrank
/algorithm/search/hackerland_radio_transmitters/solution.py
1,403
3.8125
4
#!/usr/bin/env pypy3 """ Hackerland Radio Transmitters :author: Dela Anthonio :hackerrank: https://hackerrank.com/delaanthonio :problem: https://www.hackerrank.com/challenges/hackerland-radio-transmitters """ from typing import List import bisect import sys def min_radios(houses: List[int], range: int) -> int: ...
9a3687440350da65670de0747f232a5a6c304e88
jtschei/py-sudoku
/sudoku/__init__.py
5,467
3.8125
4
import logging import random import itertools from copy import deepcopy class Puzzle: def __init__(self, board=None): logging.debug("creating puzzle") if (board is None): self.reset_board() else: self._board = deepcopy(board) def reset_board(self): logg...
e4ddad1f6e4c08d549af3a51d34dcc3b1f42fa98
CraftyClark/pythonprojects
/arcadegames/Chapter9/Chapter9_Lab2.py
896
4.125
4
import random def create_list(list_size): """ Parameter: list size. returns: a list of random values 1-6 list should be of length, list_size """ newList = [""] * list_size for i in range(len(newList)): newList[i] = random.randint(1, 6) return newList def count_list(list, number): """ Parameters: Takes in a li...
8b6c36fd232a318264afa7019c5007c5d8d4ff58
sushmithanat/player_guvi
/play_42.py
162
3.5625
4
def play_42(): s=input('Enter string :') ss=input('Enter substring :') for i in range(len(s)): if ss==s[i:len(ss)+i]: return "yes" return "no" play_42()
a6dc8f4884571e508da02653dadc94070f13287e
sholatransforma/hello-transforma
/sh hw.py
193
3.59375
4
a = input('what is your name? \n') b = int(input('how old are you? \n')) c = int(input('what is the current year? \n')) x = ('will turn 100 in year \n' + str(c + 100 - b) + '\n') print(x)
0ff22db30c427ab029037c4baf842aca22137e02
RuningBird/pythonL
/day01/wordgame.py
174
3.828125
4
print("-------------------") temp = input("心中数字:") guess = int(temp) if guess == 8: print("right") else: print("wrong") print("game over") # print(type(temp))
986b2aeb21ea7951989026d788fbafa938c0840f
mjmolina/Project-67_years_of_LEGO_python
/colors.py
441
3.5625
4
# Import modules import pandas as pd import matplotlib.pyplot as plt # To read colors from the database colors = pd.read_csv('datasets/colors.csv') # To print the first few rows colors.head() # How many differents colors are available in lEGO? num_colors = colors.shape[0] print(num_colors) # colors_summary:Colors...
1456f6ff6f88505a897e46651b042d78ed773385
lkfken/python_assignments
/assn-2-3.py
110
3.671875
4
hrs = raw_input("Enter Hours: ") rate = raw_input("Enter Rate: ") salary = int(hrs) * float(rate) print salary
4afa43d8843907f6749ffaadf6452a570c926068
lkfken/python_assignments
/extra1.py
150
3.734375
4
__author__ = 'kleung' sentence = 'This is my first Python script.' print("{}\nThe above sentence has {} characters.".format(sentence, len(sentence)))
d43a31197530683c1fbbd54441b8509d94a8ee18
ibrahimr-024/Water-Jumper
/Main_Menu_function.py
1,261
3.53125
4
import pygame pygame.init() size = (800, 600) screen = pygame.display.set_mode(size) # ------------------ Defining Variables --------------- # Define some colors BLACK = (0, 0, 0) # Set background image for scene background_image = pygame.image.load("Main Menu Backdrop.png") # Define fonts for te...
a72b7ba7cf012bbbd4bf33e44aae884f9fef946c
aerava/python-tuto
/classes_example.py
2,332
4.0625
4
#!/usr/bin/env python class FirstClass: # Define a class object def setdata(self, value): # Define class's methods self.data = value # self is the instance def display(self): print(self.data) # self.data: per instance x = FirstClass() # Make two instances y = FirstClass() # Each is a new name...
78f73e9d1d3d43bc168da2251ca67eeb6c59a22a
danilo-bc/uri-online-judge-studies
/2203_tempestade_de_corvos/tempestade.py
311
3.5625
4
from math import sqrt while(True): try: xf, yf, xi, yi, vi, r1, r2 = map(int, input().split()) dist_i = sqrt((xf - xi)**2 + (yf - yi)**2) dist_f = dist_i + vi * 1.5 if dist_f <= r1 + r2: print("Y") else: print("N") except: break
c32c463ad1b1a512bf1ab9f565b77a08f8913d3c
danilo-bc/uri-online-judge-studies
/1011_sphere/sphere.py
103
3.71875
4
pi = 3.14159 def solve(r): print(f"VOLUME = {4.0/3 * pi * r**3:.3f}") r = float(input()) solve(r)
f98fbb5b0a35e4c459ae6c32b40aa2ecd3a48bfe
IntroMind/Annual-Salary-Calculator
/annualsalary.py
246
4.03125
4
hourly_pay = input('What is your hourly pay? ') hours_week = input('How many hours do you work a week? ') weekly_pay = float(hourly_pay) * float(hours_week) annual_salary = float(weekly_pay) * 52.0 print('You make', annual_salary, 'a year.')
82e74ca3918989a03685d967d03c00386dc0957b
WantHp/python
/study/Pandas/Pandas_Part01_01_dataframe基本概念.py
4,049
3.828125
4
import numpy as np import pandas as pd # Dataframe 数据结构 # Dataframe是一个表格型的数据结构,“带有标签的二维数组”。 # Dataframe带有index(行标签)和columns(列标签) data = {'name':['Jack','Tom','Mary'], 'age':[18,19,20], 'gender':['m','m','w']} frame = pd.DataFrame(data) print(frame) print(type(frame)) print(frame.index,'\n该数据类型为:',type(...
c45d47df92bbeb8cf5766ac4a9b8e435f27876c6
sean-attewell/Hash-Tables
/basic_hashtable/b_hashtables.py
2,885
4.03125
4
# ''' # Basic hash table key/value pair # ''' class Pair: def __init__(self, key, value): self.key = key self.value = value # pointer to next pair # ''' # Basic hash table # Fill this in. All storage values should be initialized to None # ''' class BasicHashTable: def __init__(self,...
1ea8c4a4efaa451b87009f195c31c2b7d971b55f
sudhanshu-jha/python
/python3/Python-algorithm/Hashing/hashtable.py
2,655
4.0625
4
# Implementing a hashtable from scratch. # The implementation uses the multiplication method # (https://www.cs.auckland.ac.nz/software/AlgAnim/hash_func.html) to # create a hash function. Collisions are resolved using chaining. # Assumption is that keys are natural numbers {1,2,...,N}. For # character strings, we repr...
198ca950afd887156aad8c6775fbb72a53b4db6c
sudhanshu-jha/python
/python3/Python-algorithm/DynamicProgramming/shortestPathKEdges/shortestPathKEdges.py
1,427
3.609375
4
# Given a directed, weighted graph, and a source vertex 'u' and # target vertex 'v', find the shortest path between u and v with # exactly k edges. def shortestPathKEdges(graph, u, v, k): V = len(graph) # let memo[i][j][k] denote the shortest path length from # i to j of length exactly k memo = [[[0 ...
5cda7b93ac1c80c83e616e3d94f82adfab4e3a76
sudhanshu-jha/python
/python3/Python-algorithm/Lists/findBeginning/findBeginning.py
855
3.921875
4
# Given a circular linked list, return a node at the beginning of the # loop # Have a slow runner and a fast runner = 2x speed of slow. # If they meet each other somewhere, then there is a loop. # When they meet, both will be 'k' units from start of loop # where 'k' is length of non-loop portion of the list. # So, set...
50eb979be4c4f8a3a021d1c59fd16058feef16c7
sudhanshu-jha/python
/python3/Python-algorithm/ArraysAndStrings/IsUnique/IsUnique.py
802
4.28125
4
# Accepts a string and returns true if all chars in the string are # unique. Returns false otherwise. Assumes strings made up of # lowercase letters 'a' through 'z' def isUniqueChars(str): checker = 0 for c in str: value = ord(c) - ord("a") if (checker & (1 << value)) > 0: return F...
a8916e732d34d7758e47e158d8a62c7a384e1d9a
sudhanshu-jha/python
/python3/Python-algorithm/ArraysAndStrings/palindromicSubstrings/palindromicSubstrings.py
1,471
3.828125
4
# Given a string of ASCII characters, find all palindromic substrings. def palindromeSubStr(string): hashmap = {} n = len(string) # table for storing results (2 rows for even and odd-length palindromes) memo = [[0 for i in range(n+1)],[0 for i in range(n+1)]] # Find all substring palindromes from...
f290f22c75869efd0256c0c8c57721505050f3de
sudhanshu-jha/python
/python3/Python-algorithm/DynamicProgramming/isSubsetSum/isSubsetSum.py
1,176
3.8125
4
# Given a set of non negative integers, and a value sum, determine if # there is a subset of the given set with sum equal to given sum. # Example: set = [3, 34, 4, 12, 5, 2] ,sum = 9 # Output: True ,There is a subset (4, 5) with sum 9. # isSubsetSum(set,n,sum) = isSubsetSum(set,n-1,sum-set[n-1]) || isSubsetSum(set,n...
3255d9e83c02afbe0aef5dc3d11b903874170414
sudhanshu-jha/python
/python3/Python-algorithm/Moderate/countZeroes/countZeroes.py
532
4.1875
4
# Count the number of trailing zeroes in n! # The main idea is that zeroes are introduced by multipying 2 and # 5 or multiples of 2 and multiples of 5. Since, there would # be more multiples of 2 than 5, we can just count the multiples of # 5. Two count multiples of 5 - # Say the number is n. Then there are n/5 multip...
0749d76c5ffaca8efb25ef8de025edfeeaf05dfa
sudhanshu-jha/python
/python3/Python-algorithm/Lists/findIntersection/findIntersection.py
1,446
3.9375
4
# Given two singly linked lists, return the intersecting node or null # if they don't intersect. Intersection is based on reference and not # value. # Returns the length and last node of a linked list. def get_tail_and_length(head): cur = head length = 0 while cur.get_next() is not None: cur = cur....
520b11596a45589e83c246b589ce115fb01c7205
sudhanshu-jha/python
/python3/Python-algorithm/TreesAndGraphs/DiameterOfTree/diameterOfTree.py
706
4.15625
4
# Diameter of binary tree is defined as number of nodes on the longest path # between two leaves of a tree. # Diameter of tree is largest of following quantities: # 1. Diameter of T's left subtree # 2. Diameter of T's right subtree # 3. The longest path between leaves that goes through the root of T. def diameter(ro...
e30661a859b9ae3d3fa234812d406033a816009d
sudhanshu-jha/python
/python3/Python-algorithm/Lists/kthToLast/kthToLast_test.py
714
3.546875
4
from LinkedList import LinkedList from kthToLast import kthToLast import pytest def test_kthToLast(): lst = LinkedList() lst.insert("Batman") lst.insert("Superman") lst.insert("Flash") lst.insert("Green Lantern") lst.insert("Wonder Woman") lst.insert("Hawkgirl") # Hawkgirl -> Wonder Wo...
afd6354aa3cd37326c55e9319b9d27bf4e56bcfd
sudhanshu-jha/python
/python3/Python-algorithm/TreesAndGraphs/isBalanced/isBalanced.py
886
4.09375
4
# Implement a function to check if a binary tree is balanced. # Heights of the two subtrees at any node never differ by more than 1. def getHeight(node): if node is None: return 0 return max(getHeight(node.left), getHeight(node.right)) + 1 def isBalanced(node): if node is None: return Tr...
7383dd0e88de85add4a350406d75a890bb0d1572
sudhanshu-jha/python
/python3/Python-algorithm/Hard/majority/majority.py
733
3.859375
4
# Given an array of positive integers, return a "majority" element # which takes more than half the space in the array. Return -1 # if no majority element found. You should do this in O(n) time and # O(1) extra space. def findMajorityElement(arr): candidate = getCandidate(arr) return candidate if validate(arr...
36119040e177f4207761e50d5f86ea5eb070a1d2
sudhanshu-jha/python
/python3/Python-algorithm/Hard/add/add.py
603
4.5
4
# Write a function to add two numbers. You should not use + or # any arithmetic operators. # 1. If we add two binary numbers together, but forget to carry, # the ith bit in the sum will be 0 only if a and b have the same # ith bit. This is essentially XOR # 2. If I add two numbers together but only carry, I will have ...
a07fa1f19c8ff1817217cd65b497fdc79253f60b
sudhanshu-jha/python
/python3/Python-algorithm/ArraysAndStrings/IsPermutation/IsPermutation.py
596
3.9375
4
# Accepts two strings and returns true if one is a permutaiton of the # other. Assumes ASCII strings def sort(str): return "".join(sorted(str)) def IsPermutationWithSort(source, target): if len(source) != len(target): return False return sort(source) == sort(target) def IsPermutationWithLetter...
06fd8822fcd000c41bd9b81bb4e0fa56be99980d
truecapehorn/RPI_Temperatura
/input_data_all.py
630
3.71875
4
# -*- coding: utf-8 -*- # !/usr/bin/python3 def wejscia(): print('\nPodaj warunki wejsciowe: \n') while True: try: temp_zad = float(input("\nPodaj temperaturę maksymalną: ")) except ValueError as error: print('\n Wystapil blad ', error) continue bre...
f0d419e1a2e1a99119780e81c65dba9cd390689e
decocereus/google-code-sample
/python/src/video_playlist.py
2,108
4.34375
4
"""A video playlist class.""" class Playlist: """A class used to represent a Playlist.""" def __init__(self): self._user_playlist = {} """Creates the key value pair in the dictionary """ def create_internal_playlist(self, user_input): self._user_playlist[user_input] = [] """Che...
37021ce7e016f4882f5140bcbdee497da6a51683
rvf0068/pycliques
/src/pycliques/dominated.py
11,732
3.640625
4
"""A vertex :math:`v` of a graph :math:`G` is *dominated* if there is another vertex :math:`u\ne v` such that :math:`N_{G}[v]\subseteq N_{G}[u]`. A graph is called *dismantlable* if by removing dominated vertices we end up with the one-vertex graph. A vertex is called *s-dismantlable* if its open neighborhood is disman...
2db984585867f4f0d1fb0e0049fa64f92ee02766
blueducttape/PythonPY1002
/Занятие3/Практические_задания/task3_1/main.py
467
4.0625
4
def remove_whitespace(str_): word_list = str_.split(" ") words_list_without_empty_string = [] for word in word_list: if word: words_list_without_empty_string.append(word) print(words_list_without_empty_string) return " ".join(words_list_without_empty_string) if __name__ == "_...
da8777bd537e38e940fe73aaf987d1dc4aa9450f
blueducttape/PythonPY1002
/Занятие3/Лабораторные_задания/task1_3/main.py
366
3.96875
4
def prime_numbers(n): i = 2 prime_list = [] while i * i <= n: while n % i == 0: prime_list.append(i) n = n / i i = i + 1 if n > 1: prime_list.append(n) return prime_list if __name__ == "__main__": print("Введите число: ") n = int(input()) ...
99f8dcf631aefa9cd33ca8edc65ece87b8cec111
blueducttape/PythonPY1002
/Занятие2/Лабораторные_задания/task1_3/main.py
198
4.0625
4
a = int(input()) b = int(input()) if a**2 + b**2 > (a+b)**2: print("Сумма квадратов больше") elif a**2 + b**2 < (a+b)**2: print("Квадрат суммы больше")
70fe8d63e0784e1ba3485282f04cfc9160132a4c
jaqlai/python_turtle_art
/starburst.py
327
3.671875
4
import turtle, random t = turtle.Turtle() ran = random.randint turtle.colormode(255) t.home() turtle.bgcolor("black") t.speed("fastest") for x in range (0, 180): r = ran(0, 255) g = ran(0, 255) b = ran(0, 255) t.color(r, g, b) length = ran(10,350) t.forward(length) t.backward(length) t.l...
fa3b32cd01818fec12f28f0c7439bb34476ccdeb
anoopvk/project-euler
/vs/pe12.py
466
3.5625
4
import math def trianglenumber(num): return (num*(num+1))//2 def factors(num): count=0 for i in range(1,math.floor(math.sqrt(num+1))): if num%i==0: count+=1 return count*2 flag=1 i=1 maxcount=0 while(flag): trnum=trianglenumber(i) count=factors(trnum) if count>maxcou...
a000dfacc49363c283973f84d74d403d23973bbd
ma7modsidky/data_structures_python
/Linked List/linkedList.py
3,461
4.0625
4
class Node: def __init__(self, data=None, next=None): self.data = data self.next = next class LinkedList: def __init__(self): self.head = None def print(self): if self.head is None: print("Linked list is empty") return itr = self.head ...
0aa9fd5080dd8721f4adbbe6a16f2e083d1ce612
gautam-cloud/Nexwave
/file_ops.py
2,415
3.75
4
#Writing to file f1=open('out1.txt','w') #In w mode if file is not available it will make one and if existing file is there with data it will erase that x=10 s='python\n' x=str(x)+'\n' #The function with which we want to write data takes only string value f1.write(x) f1.write(s) #data get copied from buffer to fi...
dcdfb8b1d97ad4255888bfe73b6e3bc5ecd644b1
gautam-cloud/Nexwave
/classes_ex.py.py
5,149
4.625
5
#!/usr/bin/env python # coding: utf-8 # In[23]: #multiple objects can be created in a class as compared to functions #inheritance #operator overloading #just to differentiate between functions inside and outside the class; they are known as methods(inside) and function(outside) #types of variables: local, enclosed, ...
d11f47408ffc0fd8160136b11328738e96c44ddd
gautam-cloud/Nexwave
/mainprogram.py
1,881
3.71875
4
import addmodule #once this is imported it will execute every line #Its giving an error #WE HAVE TWO WAYS TO DO THAT 1)ENV VARIABLE IE TO SET PYTHON PATH SO THAT IT CAN READ IT FROM LIB 2)Programaticaaly #This import will Search for file execute it and set an object print(addmodule.msg) print(addmodule.add(10,20))...
eb57f9eb8a9f25e0b83b312b6c98c5d7d29e6310
gautam-cloud/Nexwave
/tuple_ex.py
290
3.75
4
#tuple class t1=tuple([10,20,30]) t2=(10,12.56,'python',['a','b'],(10,20)) print(t2) print(t2[1]) print(t2[-4:4:2]) i=t2.index('python') c=t2.count(12.56) print(i,c) #tuple to list t=(10,20) l=list(t) print('l=',l) #list to tuple l=[30,40] t=tuple(l) print('t=',t)
f961c66f086efff6e99601639c5d47ff6fee1c05
hbin99/Algorithm
/baekjoon/15921.py
206
3.640625
4
cnt = int(input()) if cnt == 0: print("divide by zero") else: list = list(map(int, input().split())) av1 = sum(list)/cnt av2 = sum(list)/cnt result = av1 / av2 print("%.2f" % result)
222c1d0d32d597461d195035c01530f4b5e2c32f
eunchae2000/codeup
/.vscode/1640.py
391
3.578125
4
n = int(input()) s = [input() for _ in range(n)] a = 'xocure' b = '\t' result = 0 for i in range(0, n): if (len(s[i]) <= 3) or ("tap" in s[i]) or ("xocure" in s[i]): result += 1 print(s[i]) else: result += 0 if (result >= 0 and result <= 3): print("safe") elif (result >= 4 and res...