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
e7a33ffdd452989ea550cfb847115bf6197e7bf5
urvashi04/machine_learning-practice
/1st.py
384
3.921875
4
#!/usr/bin/python3 # first import numpy import numpy as np # Creating two arrays of rank 2 x = np.array([[1,2],[3,4]]) y = np.array([[5,6],[7,8]]) #creating two arrays of rank 1 v = np.array([9,10]) w = np.array([11,12]) # inner product of two vector print(np.dot(v,w),"\n") # matrix and vector product print(np...
9be5923a412b0d78f7a283c93f5acb80b52ac9b8
musicakc/NeuralNets
/Tutorial/threelayernn.py
1,701
4.15625
4
''' Neural Networks Tutorial 1: https://iamtrask.github.io/2015/07/12/basic-python-network/ 3 input nodes, 4 training examples ''' import numpy as np ''' Nonlinearity or sigmoid function used to map a value to a value between 0 and 1 ''' def nonlin(x,deriv=False): #ouput can be used to create derivative if(deriv ...
ebb71460c40f62662abe9ec92f4c93157cf9782c
GeorgeGalaxy/IT_PY_2021_05
/IT 15/IT 15.1.4.py
342
3.5
4
import math x = 1.0 y = 1.0 while (x <= 2.5) and (y <= 4): if (x + y) > 2: Func = math.fabs(math.log2(x + y)) print(f"If x = {x} and y = {y} then Func = {Func}") else: Func = math.pow(math.sin(x * math.exp(0.1 * y)), 1/3) print(f"If x = {x} and y = {y} then Func = {Func}") ...
49ab12ea83685d222175196159e1ee04af2c46d9
GeorgeGalaxy/IT_PY_2021_05
/IT 15/IT 15.1.3.py
295
3.890625
4
from math import * a = float(input('input a: ')) b = float(input('input b: ')) h = float(input('input h: ')) x = a value = 0 func = "value = cos(e*x)**3 + sin(fabs(x))" func1 = compile(func, "compiledfunc", 'exec') while x <= b: exec(func1) print(f'x = {x}, value = {value}') x += h
ec4b22358d7527c4efbddf28407eba7fbe1c95da
Nirav-1999/Small_Programs
/Python/Competitive/nine.py
1,470
3.59375
4
# No Nine is a counting game that you can try when you are bored. In this game, you are only allowed to say Fbers that are legal. A Fber is legal if and only if all of the following are true: # it is a natural Fber (i.e. in the set {1, 2, 3...}) # it does not contain the digit 9 anywhere in its base 10 rep...
0ca0f9346e7cdb867289bef75ce0c3b727b41fcb
Nirav-1999/Small_Programs
/Python/Competitive/game.py
1,375
3.984375
4
''' Read input from STDIN. Print your output to STDOUT ''' #Use input() to read input from STDIN and use print to write your output to STDOUT # A new fighting game has become popular. # There are N number of villains with each having some strength. # There are N players in the game with each having some energy. ...
d8ad647ac1752d104ad2f6c6ba6b777e0c6ad12b
Nirav-1999/Small_Programs
/Python/Competitive/BuildingPalindromes.py
1,443
3.921875
4
# Anna has a row of N blocks, each with exactly one letter from A to Z written on it. The blocks are numbered 1, 2, ..., N from left to right. # Today, she is learning about palindromes. A palindrome is a string that is the same written forwards and backwards. For example, ANNA, RACECAR, AAA and X are all palindrome...
40df1ca5cf6016152789984007c9c612faf9994b
Nirav-1999/Small_Programs
/Python/College/exception.py
475
3.71875
4
class MyException(Exception): def __init__(self,value): self.value = value def __str__(self): return "Don't add anything like " + repr(self.value) try: raise(MyException(2)) except MyException as e: print(e) def div(x,y): return x/y try: print(div(4,2)) raise(ValueErr...
faa922e0c4fe5667cf1f006038da0a38565ebf88
apiavis/Ashford-University-CST
/Ashford University-CPT200/CPT200_Wk4Assignment.py
10,456
4.03125
4
## Author: Alicia Piavis ## Title: Employee Management System Functionality 4 ## Course: CPT 200 Fundamentals of Programming Languages ## Instructor: Amjad Alkilani ## Date: 7/29/2018 ## function that prints initial Menu Options for Employee Management System def menu_options(): print('Menu Options:\n' '(1) Enter ...
e2677989fa979d9c116226d106d81d878634fefb
idwesar/minesweeper
/store.py
2,215
3.8125
4
class Store: def __init__(self): self.mines = [] self.counter = {} def numAdjacentMines(self, coord): #look up those coords and tell me how many adj mines if (coord) in self.counter: return self.counter[coord] return 0 def ...
39ddf7efc46b87396c64041dff218d992e8753df
Sokiryanskaya/learn_python
/week_5.py
224
3.625
4
print('Введите количество чисел: ') N = int(input()) for i in range(N): print('Введите число: ') n = int(input()) for i in range(n): kol=0 if i==0: kol+=1 print(kol)
d57a5fe2fac62f4b2fa96bad4f8019aa1144da2e
Sokiryanskaya/learn_python
/week5_9.py
373
3.875
4
# Для настольной игры используются # карточки с номерами от 1 до N. # Одна карточка потерялась. # Найдите ее, зная номера оставшихся карточек n = int(input()) card = [int(input()) for _ in range(n-1)] for i in range(1, n+1): if i not in card: print(i)
41ebe7ab424313e69fcc1e4203caa183385f0a89
blessed-sibanda/modern-python-recipes
/1-numbers-strings-tuples/currency_calculations.py
416
3.78125
4
from decimal import Decimal, ROUND_UP tax_rate = Decimal('7.25') / Decimal(100) purchase_amount = Decimal('2.95') print(tax_rate * purchase_amount) # to round to the nearest penny, create a penny object penny = Decimal('0.01') total_amount = purchase_amount + (tax_rate * purchase_amount) print(total_amount.quantize...
bcdf3c21fb9f2dbd2d3eeeb3de63224e7ab75927
blessed-sibanda/modern-python-recipes
/1-numbers-strings-tuples/regular_expressions.py
588
4.09375
4
import re """ Let's say that we want to decompose text from a recipe. Each line looks like this: ingredient = "Kumquat: 2 cups" We want to separate the ingredient from the measurements. """ ingredient = "Olive Oil: 200 mls" ingredient_pattern = re.compile( r'(?P<ingrd>[\w\s]+):\s+' # name of the ingredient up ...
ca5d631772a998607acba42ead0af35f7956b6ee
nonstoplearning/python_vik
/ex13.py
1,135
4.125
4
from sys import argv script, first, second, third = argv fourth = input("Enter your fourth variable: ") fifth = input("Enter your fifth variable: ") print ("Together, your first variable is %r, your second variable is %r, your third variable is %r, " "your fourth variable is %r, your fifth variable is %r" % (...
18320bcbcc843b91673e626d5d86a869e7db1d60
DoomBrownie/GettingStarted
/Exercise 1.py
461
3.90625
4
def prime_factors(n): i = 2 temp = [] while i <= n: if n % i == 0: print("i = ", i) print(i, " is divisor of ",n) print("----") temp.append(i) n = n / i else: i += 1 return temp res = prime...
94cc17f2a9ece1ef205a8c9c5bbd6a1f587c2dd8
r888800009/CTF-tool
/sql/mysql.py
113
3.8125
4
#!/usr/bin/env python def concat(str1): return 'concat({})'.format(','.join([hex(ord(x)) for x in list(str1)]))
10abd89359775aea1cdb979b7aa5c6b6735b3ec1
jacksarick/CS-DM
/CCC/Problem_2_Happy_Sad.py
1,153
3.53125
4
#Problem J2: Happy or Sad # I've included 3 different methods for counting and 2 methods for producing an answer (from simplest to most advanced) words = list(raw_input()) # Word Splice 1 (repetition) hcount, scount = 0, 0 for i in range(len(words) - 2): if (words[i] + words[i+1] + words[i+2]) == ":-)": hcount += 1...
e82220bb4b38b795cf576ec50ec128599fc3536e
cheokjw/Pytkinter-study
/tkinter/Codes/tk new window.py
1,269
4.0625
4
from tkinter import * from PIL import ImageTk, Image root = Tk() root.title("Base") #This function is for opening a new window showing the simpson image when the button from the main window is pressed def open(): #We have to global my_img because python would not show the image when its a local variable glob...
db7f21092dc6cba286f2c1270129f7c56b706d25
cheokjw/Pytkinter-study
/tkinter/Codes/tk button.py
849
4.3125
4
from tkinter import * # Initializing Tk class OOP(Object-Oriented Programming) root = Tk() # A function that shows the text "Look! I clicked a Button" def myClick(): myLabel = Label(root, text = "Look! I clicked a Button !") myLabel.pack() # Button(root, text) = having a button for user to click # state = DI...
e917b0be8a91c91d9eef917de1ef0cafacfb8896
kaslock/problem-solving
/Programmers/줄 서는 방법.py
509
3.5
4
fact = [0] * 21 def factorial(x): if x < 2: return 1 fact[x] = x * factorial(x - 1); return fact[x] def solution(n, k): answer = [] arr = [i for i in range(1, n + 1)] fact[1] = 1 factorial(20) for i in range(n, 0, -1): cur = fact[i] / i for j in range(...
d15db6c3067e54b2a87784def2a5e69b51d40738
tuhinroy111/Python_Playground
/Matplotlib.py
622
3.625
4
from matplotlib import pyplot as plt from matplotlib import style import numpy as np style.use('ggplot') #x=[2,4,6,8] #y=[7,3,8,3] #x2=[1,3,5,7] #y2=[1,3,9,3] #plt.scatter(x,y,'g',linewidth=3, label='Line 1') #plt.plot(x2,y2,'c',linewidth=5, label='Line 2') #plt.scatter(x,y,color='g') #plt.plot(x2,y2, color='k') ...
3a1062ace32487fb9f52df5a3be6e0b08f0c8bc5
tuhinroy111/Python_Playground
/Tkinter.py
1,681
3.640625
4
#from tkinter import * import tkinter as tk '''class Window(Frame) #inherits base class Frame;multiple inheritance is possible: def __init__(self,master=None): Frame.__init__(self,master) #Constructor initialization self.master=master self.init_window() def init_window(self):...
a91ff5d9e71b7a3d908f15b817c69143161761a4
tuhinroy111/Python_Playground
/Return+Global.py
109
3.5
4
x=6 print(x) def example(): globx=x print(globx) globx+=5 return globx x=example() print(x)
63fc3caf30b31542a88e0a92cc5f274c5c076a44
AARabee/nonlinear-optimization
/ex6.py
3,520
3.640625
4
# Exercise 6 - Gradient Descent Methods, Backtracking Line Search and Newton's method (unconstrained) # TOML-MIRI # Marcel Cases # 01-apr-2021 # # min(1) f(x) = 2*x^2 - 0.5, var x # min(2) f(x) = 2*x^4 - 4*x^2 + x - 0.5, var x #%% # Backtracking Line Search import numpy as np from numdifftools import ...
bceb8a1958a705bb73df7a50fe6f33d1c1f553ec
Yeming945/Learn-Python3-Practice
/example1-22/ex12.py
957
3.921875
4
""" 练习 12 提示用户 """ age = input("How odl are you?") height = input("How tall are you?") weight = input("How much do you weight?") print(f"So, you're {age} old, {height} tall and {weight} heavy.") """ 附加练习 1. 在 Terminal 里输入 pydoc input ,看看它会说什么。如果你用的是 Windows, 输 入 python3.6 -m pydoc input 。 2. 输入 q ,退出 pydoc 。 3. 到网上查...
55e55f2272fa45d762ee84b1b1823227c27b812d
lookinsharp/baseball-vendor
/items.py
534
3.90625
4
class Item: #food or drink isTossible = False price = -.1 popularity = 0.0 def __init__(self): #if item is x, y, or z, set item to b tossable? make new method for is it tossible self.isTossible = False self.price = -1 self.poularity = -1 def setToss(toss): if toss: isTossible = True else: is...
f92f29fbacfab72d4c32718212b5f657725ef8df
masonaviles/game_of_greed
/game_of_greed/game.py
3,389
3.515625
4
from game_of_greed.game_logic import GameLogic, Banker import sys class Game(): def __init__(self, num_of_rounds=20): self.banker = Banker() self.num_of_rounds = num_of_rounds self.round_num = 0 self.roller = None self.score = 0 def play(self, roller=None): sel...
cef4d40b146520f0527830e3ece9783daaf50c22
suddensummer/todo
/danbi_2d.py
1,368
3.984375
4
import turtle from math import * turtle.shape("turtle") """ R = input("공간의 가로 길이를 입력하세요.")/2 H = input("공간의 세로 길이를 입력하세요.") r = input("프로젝터의 가로길이를 입력하세요.")/2 x = input("프로젝터의 높이를 입력하세요.") y = input("프로젝터와 반사경 사이 거리를 입력하세요.") w = input("반사경의 반지름을 입력하세요.") h = input("반사경의 높이를 입력하세요.") """ R = 875/2 H = 260 r = 50/2 x =...
7795ee8380e7cab364152e84531b5cc92bd72c2e
Ibukun-Badmus/python-chapter-2
/Multiples.py
572
4.09375
4
# x = 4 # y = 3 # total = x + y # print('The total is', total) # print('type x is', type(x)) # total = 10.8 + 12.2 + 0.2 # print('total is', total) # triple_quoted_string = """This is a triple-quoted # ...:string that spans two lines""" # print(triple_quoted_string) # print("""This is a lengthy # multi...
b5990a97cc430bd1356b10c05b286ded513f9973
prashantkaulwar/Python-Practice
/python/Class/A2/Assignment2_1.py
336
3.890625
4
import Assignment2_1_module as a def main(): num1 = int(input("Enter First Number: ")) num2 = int(input("Enter Second Number: ")) print("Addition: ", a.Add(num1,num2)) print("Substraction: ", a.Sub(num2,num1)) print("Multiplication: ", a.Mult(num1,num2)) print("Division: ", a.Div(num1,num2)) if __name__ == "__m...
502152bb4c6b199daf17b538bc461ae1b82d9b9a
prashantkaulwar/Python-Practice
/python/Class/A8/Assignment8_5.py
667
3.625
4
import threading def func(name,lock): name(lock) def Thread1(lock): lock.acquire() for x in range(0,50): print("Thread1",x) lock.release() def Thread2(lock): lock.acquire() for x in range(50,0,-1): print("Thread2",x) lock.release() def main(): lock = threading.Lock() t1 = threading.Thread(target = fu...
1c94ca7ac1bc026b9a302bfcd47f4b2112bb317e
prashantkaulwar/Python-Practice
/python/Class/A4/Assignment4_1.py
204
3.921875
4
def testfunc(num): return lambda num : num * num def main(): number = int(input("Please Enter Number: ")) n = testfunc(number) print("Squre Number: ",n(number)) if __name__ == "__main__": main()
b546b97dffe94213d74da341aab6d61af3dc880c
prashantkaulwar/Python-Practice
/python/Class/A9/Assignment9_5.py
1,122
3.875
4
from sys import * import os.path def frequencyFileContent(filename1,keyword): exists1 = os.path.isfile(filename1) counter = 0 if(exists1): with open (filename1, 'rt') as myfile: # Open lorem.txt for reading text. for myline in myfile: findedKeyword = False findedKeywordlen = myline.split() for k...
6f98f2f353848f25c385f18b57737c8c5d3ee369
prashantkaulwar/Python-Practice
/python/Class/A4/Assignment4_5.py
564
3.625
4
import Assignment4_ListModule as a import functools def primeNumber(num): sum = 1; for x in range(2,int((num/2)+1)): if(num%x == 0): sum = sum + x return 0 if sum > 1 else num def eventNumberSqureUsingLambda(aList): return list(map(lambda x: x * 2, filter(lambda x : primeNumber(x),aList))) def main():...
29042288ddba2544a5d0fa17b440ca58a67f7ae5
prashantkaulwar/Python-Practice
/python/Class/A5/Assignment5_1.py
212
3.8125
4
import Assignment_Accept_String as a def stringReverse(string): return string[::-1] def main(): result = stringReverse(a.acceptString()) print("Reverse String: ", result) if __name__ == "__main__": main()
fdb87fcf446a3f42b572033a2af22279516bf5e5
gom7430/Basic-ML-algorithms
/kmeans_algo.py
932
4.34375
4
#--------------------------------------------------------------- #basic implementation of k-means clustering algorithm #--------------------------------------------------------------- import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans #prepare the data x = np.array([[5,3],[...
69a376ce63c1af57ab95d1b6c31991f08ddf7268
Levijom/Base_10_to_Binary
/Recursion.py
356
4.03125
4
#get number n = int(64) #print n """ print(n) """ #subtract 1 till 1 """ while n!=1: n = n-1 print (n) """ # subtract 1 till 1, show even or odd def minusOne(n): while n!=1: n = n-1 print(n) if n%2 == 0: print("even") else: ...
44d273386e3f37bcf231ff46304082fce385b1a5
savatabachhav/mca-sem2-practicals
/python/18_June_2021/Sum_of_List_Numbers.py
305
3.703125
4
""" Name.: Bachhav Savata B. Class.: MCA-I Roll No.: 03 Subject: Python Programming Program: WAP to calculate sum of all number in list """ total = 0 list1 = [20, 15, 10, 21, 9, 8.11] for ele in range(0, len(list1)): total = total + list1[ele] print("Sum of all elements in given list: ", total)
4bf8180c8d5be437a14f9866cf54187566b1bd30
cnoko/censor
/censor_dispenser.py
4,554
3.515625
4
# These are the emails you will be censoring. The open() function is opening the text file that the emails are contained in and the .read() method is allowing us to save their contexts to the following variables: email_one = open("email_one.txt", "r").read() email_two = open("email_two.txt", "r").read() email_three = o...
ac6b346fd9f0262cfd9381e374236955ee972a5e
bfakhri/deeplearning
/mini-1/bfakhri_fakhri/regressor.py
1,365
4.28125
4
""" Author: Bijan Fakhri Date: 2/3/17 CSE591 - Intro to Deep Learning This file implements the regressor class which performs a linear regression given some data """ import numpy as np class regressor(object): """ Class that implements a regressor. After training, it will have weights that can be exported. Ar...
d361a9f17f1238d9816d72c177302aee0c496204
zoey0820ivy/LearningPython
/GeneMutation.py
651
3.5
4
def SearchDiff(a, b): var = 0 i = 0 if len(a) == len(b): while (i < len(a)): if a[i] != b[i]: var += 1 i += 1 return var else: if len(a) > len(b): l = len(a) - len(b) while (i < len(b)): if a[i] ...
b7e4fcfd33d70efcb8f9f76dc5109ad8b4bd99a0
mishimingyue/hou
/algorithm/刷题/HJ13_句子逆序.py
401
3.703125
4
''' 将一个英文语句以单词为单位逆序排放。例如“I am a boy”,逆序排放后为“boy a am I” 所有单词之间用一个空格隔开,语句中除了英文字母外,不再包含其他字符 ''' import sys input_1 = sys.stdin.readline().strip().split(" ") input_1.reverse() print(input_1) # ************************************* str1 = ' ' k = str1.join(input_1) print(k)
7978a3063aa0e8e9bb11528dca1e07f4b1c91009
alperkaya0/HackerRank-IterTools-Combinations-W-Replacement
/Solution.py
471
3.71875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import combinations_with_replacement inp = input().split(" ") text = inp[0] num = int(inp[1]) liste = list(combinations_with_replacement(text,num)) newL = [] for x in liste: temp = [] for char in x: temp.append...
0677db01ce4e31f781092f00307b4d19c7d63051
h2oai/h2o-3
/h2o-r/scripts/build_dataset_from_parse_log.py
9,651
3.640625
4
#!/usr/bin/python import sys import os import re from random import random from random import randrange from random import uniform class RealColumn: """ One real number column in a dataset. May or may not be integer. """ def __init__(self, col_num, col_name, min_val, max_val, na_fraction, is_intege...
d3fce9cfd45c1078dd678fb3008a043e944779e4
vicky299/praktikum-8
/2.12.py
752
3.765625
4
buah = {'apel' : 5000, 'jeruk' : 8500, 'mangga' : 7800, 'duku' : 6500} while True: y = input('Nama buah yang dibeli:') x = input('Berapa Kg :') t =int(input('masukkan bilangan bulat:')) print('lagi (y/n)?:') print('Data buah:') print('- Apel (Harga Rp 5000') print('- Jeruk (Harga Rp 8500') ...
9d9f1e465c29fe9818d64b669df3e53a0e29af96
WHITSNAK/FoC_RiceU
/PoC/simple_dice.py
1,352
3.828125
4
""" Simple dice game Give out $10 to play the game 3 dice roll doubles gain $10 roll triple gain $200 others deal keeps the $10 Good game to play? """ # %% import random from .utils import gen_all_sequences # exhasutive search and counting method def search_all_expected_value(num_dice): DICE_OUTC...
603a6aca6150c160f2fce4c714bf0ba0022ab8e0
WHITSNAK/FoC_RiceU
/PoC/game_2048.py
5,617
3.609375
4
""" Clone of 2048 game. """ # %% import random INIT_TILES = 2 # Directions, DO NOT MODIFY UP = 1 DOWN = 2 LEFT = 3 RIGHT = 4 # Offsets for computing tile indices in each direction. # DO NOT MODIFY this dictionary. OFFSETS = {UP: (1, 0), DOWN: (-1, 0), LEFT: (0, 1), RIGHT: (0, -1)} d...
7a592ff5e48fa107727acdf19eaabbf900de3ee8
WHITSNAK/FoC_RiceU
/PoC/solitaire_mancala.py
4,637
4.21875
4
""" Student facing implement of solitaire version of Mancala - Tchoukaillon Goal: Move as many seeds from given houses into the store In GUI, you make ask computer AI to make move or click to attempt a legal move """ class SolitaireMancala: """ Simple class that implements Solitaire Mancala """ ...
03b31855a9f3d41cfe093d54a8b0d59036e75761
WHITSNAK/FoC_RiceU
/PoC/tic_tac_toe.py
4,091
3.859375
4
""" Monte Carlo Tic-Tac-Toe Machine Player that uses Monte Carlo method to sample the best move """ import random import poc_ttt_provided as provided # Constants for Monte Carlo simulator # You may change the values of these constants as desired, but # do not change their names. NTRIALS = 1000 # Number of ...
34d6599e36d46bde250a6aeea705f55d7ab41d74
WHITSNAK/FoC_RiceU
/PoC/simple_yahtzee.py
4,118
3.734375
4
""" Planner for Yahtzee Simplifications: only allow discard and roll, only score against upper level Upper level: ones, twos, threes, fours, fives, sixes """ def gen_all_sequences(outcomes, length): """ Iterative function that enumerates the set of all possible sequences of outcomes of given length. ...
bb1ccc440f2c6c9c59d8ca288ffeb17cf5d05fa1
reynolkb/python-bootcamp
/section_14/section_14.py
6,336
3.75
4
# ---------------------------------------- Collections Module ---------------------------------------- # from collections import Counter # mylist = [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,4] # print(Counter(mylist)) # sentence = "How many times does each word show up in this sentence with a word" # print(Counter(sentence.low...
c80fb14481b9cf600cdebb8d0c6b552a096606de
reynolkb/python-bootcamp
/section_13.py
1,407
4.03125
4
# def create_cubes(n): # result = [] # for x in range(n): # result.append(x**3) # return result # print(create_cubes(10)) # def create_cubes(n): # for x in range(n): # yield x**3 # for x in create_cubes(10): # print(x) # def genfibon(n): # """ # Generate a fibonn...
e87701879ad4f71a1baf9740a1237793409b6508
Ilis/checkio
/Alice/zigzag.py
1,134
3.703125
4
from typing import List def create_zigzag(rows: int, cols: int, start: int = 1) -> List[List[int]]: if rows == 0: return [] if cols == 0: return [[]] * rows flat = list(range(start, start + rows * cols)) data = [] reverse = False while flat: data.append(flat[0:cols] ...
b39882765da3e09f203bd282f21d8f03f245c46d
Ilis/checkio
/Watchtower/guessr.py
1,569
3.8125
4
from random import choice def checkio(attempts): all_numbers = set(range(1, 101)) all_divisors = set(range(2, 11)) # Filter numbers numbers = set(all_numbers) for r, d in attempts: valid_numbers = {n for n in all_numbers if n % d == r} numbers &= valid_numbers # Filter deviso...
51b3035b4f4147d82844f3de011dcb3ad8c7d22a
MirkoGarin/PruebasPython
/nombre.py
178
3.921875
4
nombre = raw_input("Digite su nombre: ") edad = int(raw_input("Digite su edad: ")) print("Mi nombre es: {}, su edad {}, y el doble de su edad es {}" .format(nombre,edad, edad*2))
03e8bff7745bcc43b68b2956f7d267d8a478beac
anandaraj24/pythonex
/project.py
1,329
3.859375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #Question 1: def print_N_nos(x): for i in range(1,x+1): if i%3==0: print("Fizz") else: print(i) # In[2]: #Question 2: list1=[1,2,3,5,8,4,7,9,1,4,12,5,6,5,2,1,0,8,1] i=len(list1)-1 while i>=0: result=li...
be3ac8aae3f2181b6b2c03e5fda3b39b97ea8e12
Srija-U/Data-structures
/stack.py
788
3.984375
4
def push(l,n): if(n==len(l)): print() print("STACK IS FULL!!") print() return l else: print("Enter the value to insert") x=int(input()) l.append(x) print("INSERTED!!") return l def pop(l,n): if(len(l)==0): print() ...
0c02f51880d3f6de8d20be1672bb08c504baa488
Srija-U/Data-structures
/reverse of list using stacks.py
645
3.96875
4
class st: def __init__(self): self.s1=[] self.s2=[] self.top=-1 def push(self,x): if(self.top==-1): self.top=0 self.s1.append(x) print("INSERTED ELEMENT: ",x) else: self.top+=1 self.s1.append(x) ...
40e8917bfabeb2899585705137292626801ba922
qrsforever/thinkstats
/fourth.py
736
3.578125
4
import survey table = survey.Pregnancies() table.ReadRecords() first_births = 0 first_birth_pregnancy_lengths = 0.0 later_births = 0 later_birth_pregnancy_lengths = 0.0 for record in table.records: if record.outcome != 1: continue if record.birthord == 1: first_births += 1 first_birth...
03abe2fde58318c6f0a252adb06607d0a9847c1b
harryDr/python-Data-Structures-and-Algorithms
/insert_sort.py
508
3.859375
4
#coding=utf-8 import random #插入排序(直接排序)算法 从数组的第一个数开始排序,数组右边的为待插入的数据 #插入时与前一个相比较形成有序序列 def insert_sort(listl): for i in range(1,len(listl)): key = listl[i] j = i-1 while j >= 0: if listl[j] > key: listl[j+1] = listl[j] listl[j] = key j -= 1 return listl if __name__ == '__main__': ...
6ce2de403aefad2789a9a0e07384d008dd53251b
lctsongas/MMNE
/Movement Control System/positioning_calc.py
3,794
3.671875
4
#Positioning Calculations ########## # #A x,y coordinate frame is attached to the robot. With the origin set to # the initial starting location facing the (+)x-axis. # #Units: 1 unit in the coordinate frame represents 1 meter #Heading: the direction the robot is pointing #Bearing: angle in degrees between destinati...
4bb2faecfe855d0b29270a3287e53cf6745fa588
Emily-Foreman/software-training
/ch_2_assign_emily_foreman.py
4,485
4.46875
4
teams = {} while True: command = input("""Type 'add' to add a team Type 'remove' to remove a team Type 'edit' to change a teams data Type 'search' to search for a team Type 'list all teams' to display all teams Type 'quit' to exit """) if command == "add": check = False ...
0ffedf0402804dc0f0dac22a0a9ae364021403ae
MishalKumar/Python_Assignments
/visited_placed.py
1,301
3.765625
4
# problem statement: ''' Given two lists such as list 1 contains name of the tourist places in Bihar and list 2 contains list of tourist places visited by you in last one year, write a program to find the places you have not visited yet. ''' def unvisited_places(places, visitedplaces): unvisited = ...
884efc528b5baf1110987cf903dc0388a84ff0a8
NewAwesome/Fundamental-algorithms
/Methodology/Recursive/example/lc2.py
672
3.5625
4
class ListNode: def __init__(self, val=0, next=None): self.next = next self.val = "val" class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: # Using a temp variable: _ , to save the sum of current two nodes _ = l1.val + l2.val digit, tenth = ...
424affb479e65f2a68e3bd8558df12b848d77427
NewAwesome/Fundamental-algorithms
/LeetCode/27. Remove Element/Solution.py
521
3.53125
4
from typing import List class Solution: # 解法灵感来自24题的双指针法 def removeElement(self, nums: List[int], val: int) -> int: if not nums: return slow = fast = 0 while fast < len(nums) - 1: if nums[fast] != val: nums[slow] = nums[fast] slow...
4c483c108073d56208c7d1e56497e2dca3e6588a
NewAwesome/Fundamental-algorithms
/LeetCode/21. Merge Two Sorted Lists/Solution.py
1,321
4.1875
4
from ListNode import ListNode class Solution: # Iteration def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: # create a var named 'head' node, used for point to head of the result LinkedList # create a var named 'cur' node, used for iteration point to the smaller node of l1 and ...
ae9fc276c755aac9325d24645d9706144dc93981
eyejayvee/thinkful_projects
/pirate_bartender.py
1,656
3.984375
4
import random questions = { "strong": "Do ye like yer drinks strong?", "salty": "Do ye like it with a salty tang?", "bitter": "Are ye a lubber who likes it bitter?", "sweet": "Would ye like a bit of sweetness with yer poison?", "fruity": "Are ye one for a fruity finish?" } ingredients = { "str...
bb42dc743a72d9de33698ee2f14c63d5265bff95
dullin/hololink-site
/content/INF1035/laboratoires/labo3/labo3.py
9,047
3.6875
4
import math def inverse_additif(nombre): """ L'inverse additif d'un nombre. Trouve la valeur du nombre multiplié par -1. Args: nombre (float): Le nombre à inverser. Returns: float: L'inverse du nombre. Exemple: :: >> inverse_additif(45) -45 ...
fbf208c17cebce245eef6abd0f5bf94d4894b891
jjunsheng/learningpython
/mosh python/quiz(if statement).py
347
3.703125
4
# price of house is $1M. if buyer has good credit, they need to put down 10% otherwise they need to put down 20% print the down payment has_good_credit = True price_of_house = 1000000 downpayment = 0 if has_good_credit: downpayment = price_of_house * 0.1 else: downpayment = price_of_house * 0.2 print(f"Down...
c19e61a53f4d4385faffd899370f7a460334955f
jjunsheng/learningpython
/mosh python/logical operators.py
721
3.90625
4
#if applicant has high income AND good credit then eligible for loan high_income = True good_credit = True if high_income and good_credit: print("Eligible for loan") else: print("Not eligible for loan") #if applicant has high income OR good credit then eligible for loan high_income = True good_credit = F...
84263c966b37e7e08a3772d6caf4e076d7be9f6f
jjunsheng/learningpython
/mosh python/comments.py
393
3.6875
4
# comments in python to add notes for program # example of bad comments : print sky is blue # comment get outdated if code change to : ocean is blue, very bad practise print("Sky is blue") # calculates and returns the square of the number def square (number): return number * number # ^ bad practise also comment...
5e8d193c0a21c3c3dfafcb0fb94419777359e9ca
jjunsheng/learningpython
/mosh python/quiz(comparison operators).py
438
4.46875
4
#if name is less than 3 characters long #name must be at least 3 characters #otherwise if it's more than 50 characters long #name can be a maximum of 50 chatacters #otherwise #name looks good name = input('Name : ') if len(name) < 3: print("Name must be a minumum of 3 characters. Please try again.") elif len(nam...
c3d39fa2d6734fe6f5e0d42c406146be3505037b
sdongchuanqi/py-parser
/test/test1.py
161
3.953125
4
import sys def factorial (num): if(num<20): return 21 else: return num*factorial(num-1) for index in range(10,25): print factorial(index) print "Hello"
39a1a1628607a2d07296f9f9a8dc1f48694e53f1
SteadBytes/study
/general-exercises/kata/codekata/02-karate-chop/chop.py
4,096
3.796875
4
from typing import List import pytest from hypothesis import given from hypothesis import strategies as st def chop_iterative(x: int, lst: List[int]): """ Classic iterative binary search implementation - no imagination here! No problems encountered due to familiarity with the algorithm, however from ...
a965cc023aefd586bc57dcfc92578a8f0993ae72
SteadBytes/study
/algorithms-data-structures-programs/exercises/01/13/binary_search.py
1,854
3.515625
4
import pytest from hypothesis import given from hypothesis import strategies as st, settings def binary_search(a, x): """ Implementation given in 1.17 """ i = 0 j = len(a) - 1 while True: k = (i + j) // 2 if x > a[k]: i = k + 1 else: j = k - 1 ...
ebe3ea1e655bfb55ed5d12804e63a26d2e09e224
SteadBytes/study
/the-pragmatic-programmer-20th/21/exercises/12/camel_finder.py
2,451
3.59375
4
#! /usr/bin/env python3 """ Scans source files for camelCase strings and reports on their locations. Yes I'm aware this can be achieved with a grep one-liner. """ import re import sys from pathlib import Path from typing import Generator, Iterable, List, NamedTuple # matches valid lower camelCase strings according t...
f0c0da9ab1391f5ec81f5b15fb5744b039ac4257
AerialRobotics/CarND-LaneLines-P1
/P1.py
12,988
3.546875
4
#################################################################### # # Andrew Baker # Self Driving Car Engineer # Project 1: Finding Lane Lines on the Road # # File Name: P1.py # Due Date: 12/06/16 # # Description: In this project you will develop code to identify # lane lines on the road. The pipeline will be ...
b370fabbd6626d7541ce0e9c9f12402845145d67
arpan-sharma/python_hackerearth_problems
/find_runnerup_score.py
417
3.625
4
if __name__ == '__main__': n = int(input()) arr = map(int, input().split(" ")) list_arrr = list(arr) max_in_list = max(list_arrr) pop_list_item = list_arrr.remove(max_in_list) while True: if max_in_list in list_arrr: pop_list_item = list_arrr.remove(max_in_list) el...
a7d60c02ab42c87c15fb9be614b1c68952e31bbf
arpan-sharma/python_hackerearth_problems
/nested_list.py
544
3.734375
4
if __name__ == '__main__': name_score = [] for_min = [] for _ in range(int(input())): name = input() score = float(input()) name_score.append([name,score]) for_min.append(score) for_min_score = min(for_min) for_min.remove(for_min_score) for i in for_min: if for_...
62c9779000c4abeac26299316cfd153f3f7d3eb4
YaliixxG/keep-doing-exercises
/344.reverse-string.python3.py
638
3.796875
4
# # [344] Reverse String # # https://leetcode-cn.com/problems/reverse-string/description/ # # algorithms # Easy (62.89%) # Total Accepted: 20.5K # Total Submissions: 32.7K # Testcase Example: '"hello"' # # 编写一个函数,其作用是将输入的字符串反转过来。 # # 示例 1: # # 输入: "hello" # 输出: "olleh" # # # 示例 2: # # 输入: "A man, a plan, a canal: P...
672dcd8d50b458ca0c572159e4690b34793f3364
YaliixxG/keep-doing-exercises
/349.intersection-of-two-arrays.python3.py
1,052
3.734375
4
# # [349] Intersection of Two Arrays # # https://leetcode-cn.com/problems/intersection-of-two-arrays/description/ # # algorithms # Easy (52.94%) # Total Accepted: 6.2K # Total Submissions: 11.5K # Testcase Example: '[1,2,2,1]\n[2,2]' # # 给定两个数组,编写一个函数来计算它们的交集。 # # 示例 1: # # 输入: nums1 = [1,2,2,1], nums2 = [2,2] # 输出...
ba2ce236426a14d35f10540770106ef7e14735a2
maheboob76/ML
/Basics/Perceptron_vs_Sigmoid.py
1,077
4.25
4
# -*- coding: utf-8 -*- """ http://neuralnetworksanddeeplearning.com/chap1.html#exercise_263792 Small example to show difference between a perceptron and sigmoid neuron For a Machine Learning model to learn we need a mechanism to adjust output of model by small adjustments in input. This example shows why a percpt...
c727154371c83cbe1540772e4ed24b7aa305d396
dymeks/CodingDojo
/multiples_sum_average.py
4,255
4.28125
4
# #Multiples part 1: # for number in range(1,1001): # if(number%2 == 1): # print number # #Print multiples of 5 from 5 to 1,000,000: # for number in range(5,1000001): # if(number%5 == 0): # print number # #SUM LIST: # sum1 = 0 # arr = [134,23,1,6,45,89] # for number in arr: # sum1 += number # print sum1 # #...
ef77ca61d55f559d00acfa8aa3dc027f283db965
andreufaner/python-sdk
/signaturit_sdk/resources/parser.py
4,006
4
4
class Parser: """ Parser: A class used to parse all the incoming data from user to a request-friendly format. The parser also validates that the info is correct and there aren't missing or wrong params. """ def __init__(self, all_params, mandatory_params): """ @all_params: All params...
ca2b7cf311bdbfb2c05d6f2fa521859a0d4d696d
neha07saxena/StockPricePredictor
/testrun.py
5,029
3.765625
4
# Price Predictor using Recurrent Neural Network # Part 1 - Data Preprocessing # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the training set dataset_train = pd.read_csv('Google_Stock_Price_Train.csv') training_set = dataset_train.iloc...
47eb5e298f7873968c76b28d5e9c40a3a4339860
bodacom/pythonforkids
/myletter.py
580
3.53125
4
пробіли = ' ' * 25 print() print('%s Задуплянский провулок, 12' % пробіли) print('%s Далека глушина' % пробіли) print('%s Село Західні Хропаки' % пробіли) print() print() print('Шановний пане,') print() print('Хочу повідомити вам, що з даху туалету надворі') print('злетіла черепиця.') print('Напевно, в усьому винен вчо...
91665952aa22e8423e29391da8057449c967fe10
amthompson42010/Python-Files
/Python_3/HuffmanCode/HuffEncode.py
3,491
3.671875
4
################################################ # # Project 4 April 14, 2014 # Huffman Codes # # Alexander M. Thompson # # File: HuffEncode.py # ################################################ from arrayheap import ArrayHeap def build_tree(heap): #Function to build the Huffman tree unique_ID = 200 #Number...
a1193668a74a6b0ee968c2e0229a47cb0c2c3ac8
bhawanaagarwal/Lebensmittel-Preisvergleich
/Interspar.py
1,512
3.5625
4
import time from selenium import webdriver from selenium.webdriver.support.ui import Select from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import csv import pandas as pd import numpy as np import matplotlib as mlt import matplotlib.pyplot as plt #launch the Browser and ente...
6280270a141b37affa1a35ca7990ac5042603786
SergioBarrera3/psp_repo2
/katas/captcha_inverso.py
359
3.53125
4
# 1. Captcha inverso # Sergio R. Barrera Flores print('Introduzca la secuencia: ') valorIntroducido = input() digitos = list(valorIntroducido) total = 0 x = 0 for i in digitos[:-1]: try: if digitos[x] == digitos[x+1]: total += int(i) except: pass x += 1 if digitos[x] == d...
4417f626faf8b2aec09e3ba604d59860f139ceb0
eibeom/UNIT_3_HOMEWORK_PYMEUPCHARLIE_BES
/U3PyBankBES/main.py
3,016
4.5625
5
# Unit 3 | Assignment - Py Me Up, Charlie # In this challenge, you are tasked with creating a Python script for analyzing the financial records of your company. # You will give a set of financial data called budget_data.csv. # The dataset is composed of two columns: Date and Profit/Losses. # (Thankfully, your compan...
5f85ea15b98b335c4c6b4f66c3d84d8ed8c988b9
joonasky/sanapelisolver
/src/sanapelisolver/solver.py
3,671
3.875
4
from abc import abstractmethod from typing import List, Tuple, NamedTuple from os import path from .cli import Game here = path.abspath(path.dirname(__file__)) DEFAULT_WORD_FILE = path.join(here, 'words', 'words.txt') class Word(NamedTuple): word: str path: List[Tuple[int, int]] class WordReader(object):...
3d31db7fa981a78bef44bc0359c6aa3d9489c5d3
dilsonm/CeV
/mundo3/Exercicios/ex094.py
2,592
3.96875
4
''' Crie um programa que leia nome, sexo e idade de varias pessoas, guardando os dados de cadas pessoa em um dicionario e todos os dicionarios em uma lista. No final, mostre: - Quantas pessias foram cadastradas - A média de idade do grupo - Uma lista com todas as mulheres -Uma lista com todos as pessoas com idade acima...
64db0f8c67bc7d1f426ca30857bed20ec64de5f0
dilsonm/CeV
/mundo2/ex070.py
1,065
4.0625
4
'''Crie um programa que leia o nome e o preco de varios produtos. O programa devera perguntar se o usuario vai continuar. No final mostre: a) Qual é o total gasto na compra b) Quantos produtos custam mais de R$1000. c) Qual é o nome do produto mais barato. ''' sair = 'N' compras = 0 prdcaro = 0 nomepr...
d331a468ba8e4fd972e3667b388c722d4bfd059f
dilsonm/CeV
/mundo2/ex071.py
750
4.09375
4
'''Crie um programa que simule o funcionamento de um caixa eletronico. No inicio, pergunte ao usuário qual será o valor a ser sacado (numero inteiro) e o programa vai informar quantas cedulas de cada valor serão entregues. OBS: Considere que o caixa possúi cédulas de R$50, R$20, R$10 e R$1. ''' n1 = 0 n2 = 0 n3 = 0 n4...
67eafce73c1fdde2ab1e128470ba91c6baf5eec7
dilsonm/CeV
/mundo2/ex042.py
886
4.09375
4
""" Refaço o exercicio 035 dos triangulos, acrescentando o recurso de mostrar que tipo de triangulo será formado: - Equilátero = os 3 lados iguais - Isósceles = 2 lados iguais - Escaleno = todos os lados diferentes """ r1 = float(input('Digite o comprimento da PRIMEIRA reta ')) r2 = float(input('Digite o comprimento da...
812e8260552be47b2508fc8a9c4b390ccf67f7f6
dilsonm/CeV
/mundo2/ex059.py
730
4.03125
4
''' Crie um programa que leia dois valores e mostre na tela: [1] somar [2] multiplicar [3] maior [4] novos numeros [5] sair do programa Seu programa deverá realizar a operação solicitada em cada caso. ''' n = 0 while n != 5: n1 = float(input('Digite o primeiro valor: ')) n2 = float(input('Digite o segundo valor...
0feaf36241b524d9dc47f5b980aa9219471e2a55
dilsonm/CeV
/mundo1/ex035.py
545
4.21875
4
""" Desenvolva um programa que leia o comprimento de três retas e diga ao usuário se elas podem ou não formar um triangulo. """ verde = '\033[0;32m' vermelho = '\033[0;31m' r1 = int(input('Digite o comprimento da PRIMEIRA reta ')) r2 = int(input('Digite o comprimento da SEGUNDA reta ')) r3 = int(input('Digite o comprim...
7f096383efde2b62b5dea0326140171aeb765d64
dilsonm/CeV
/mundo3/Exercicios/ex077.py
443
3.859375
4
'''Crie um programa que tenha uma tupla com varias palavras (não usar acentos). Depois disso, voce deve mostrar, para cada palavra, quais são as suas vogais.''' lista = ('Sao Paulo','Santos','Praia Grande','Peruibe','Cotia','Jundiai','Araraquara','Valinhos') vogais = ('a','e','i','o','u') for c in lista: print(f'\...
e7eaf16937c9c2d4083f5b84871c3b06483d478d
dilsonm/CeV
/mundo2/ex052.py
297
3.890625
4
# Faça um programa que leia um numero inteiro e diga se ele e ou nao um numero primo num = int(input('Digite um número: ')) t = 0 for c in range( 1, num + 1 ): if num % c == 0: t += 1 if t == 2: print("Este é um numero PRIMO") else: print('Este NÃO É um número PRIMO !')