blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
931067b62491676d51ab8815e89b865e4e5c4806
Example-A/python-discord-bot
/python discord bot/minesweeper.py
4,200
3.984375
4
import numpy as np import random #I made the board extra big to stop errors for counting the number of bombs around each square #X_input and Y_input #X_input = 5 #Y_input = 5 #Bombnum = 5 #startnumber = 0 #should have a 1 thick square of no bombs #"board" is the matrix #will returm a board with ...
20fa425e864f78108791f35351b0eb9a3c98fb44
nishu2498/Phi_DataEngg_Projects
/Python Bootcamp/queue_implementation.py
1,720
3.984375
4
import sys class Queue: def __init__(self,size): self.L = [None]*size self.capacity = size self.front = 0 self.rear = -1 self.count = 0 def DeQueue(self): if self.isEmpty(): print("Queue Underflow!! Terminating process..") ...
b02853b0e8f8f722e1560709c2740dca66539010
rafailislam/Deep-Learning
/Linear Classifer using Neural Network/Linear Classifer using Neural Network.py
5,828
3.78125
4
""" Author: Rafail Islam CSC790: Deep Learning Fall 2020, Assignment #2 """ import random import matplotlib.pyplot as plt import numpy as np import pandas as pd import csv def activate(sum): """ this function return either 1 or -1 based on the sign of sum """ return sum>0 and 1 or -1 d...
55f51403596f254c26f31a0a22cf6a994824aabc
gsrr/IFT_jerry
/tools/tree.py
2,056
3.6875
4
import sys import random class Node: def __init__(self, data): self.data = data self.left = None self.right = None class BST: def __init__(self, arr): self.tree = None self.arr = arr def _insert(self, tree, node): if node.data > tree.data: if...
9c0f2de7ceac3c7e755757ab1546e0775ee02d1c
LeakeyMokaya/Leakey_BootCamp_Day2
/Fizz_Buzz/fizz_buzz.py
767
4.5
4
#Create a function fizz_buzz to return 'Fizz', 'Buzz', 'FizzBuzz', or the argument it receives, #all depending on the argument of the function, a number that is divisible by, 3, 5, or both 3 and 5, respectively. #When the number is not divisible by 3 or 5, the number itself should be returned. def fizz_buzz(number)...
57d0669edab4e35691fabd21666e2759a9fe3538
anishthanaseelan/py-snippets
/draw_with_turtle.py
3,530
3.875
4
import turtle # Allows us to use turtles import random wn = turtle.Screen() # Creates a playground for turtles line = turtle.Turtle() # Create a turtle, assign to alex line.speed(10000) wn.bgcolor("black") line.pensize(3) line.color ("sky blue") def sq(scale=1, fill=False): if (fill ): ...
46fecfa0a97640c52d26da4896de60a5da073f9c
kevalpatel2106/bike-share-data-analysis
/practice/problem1.py
1,047
4.21875
4
import pandas as pd from practice import commons as cm filename = 'chicago.csv' def find_most_popular_start_hour(): """ Use pandas to load chicago.csv into a dataframe, and find the most frequent hour when people start traveling. There isn't an hour column in this dataset, but you can create one by extra...
bc189f1feba2a4a6a535a43219db5723970a555b
erinforman/markov-chains
/markov.py
3,010
4.15625
4
"""Generate Markov text from text files.""" import sys file_path = sys.argv[1] from random import choice def open_and_read_file(file_path): """Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. """...
69ddefb673d70a26e76dfc8eddd44f23263826f8
Rohan-Chaudhury/Natural-Language-Processing-Using-Python
/nlpstopwords.py
498
3.921875
4
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize example_sentence ="This is an example showing off stop word filtration" stop_words= set(stopwords.words("english")) #print(stop_words) words=word_tokenize(example_sentence) ##filtered_sentence= [] ## ##for w in words: ## if ...
da65167f905c124b4a4ed83250b46d5a0c8bb16e
bytedance/Hammer
/utils/image_utils.py
10,546
3.59375
4
# python3.7 """Contains utility functions for image processing. The module is primarily built on `cv2`. But, differently, we assume all colorful images are with `RGB` channel order by default. Also, we assume all gray-scale images to be with shape [height, width, 1]. """ import os import cv2 import numpy as np from ...
4a2d436b7e9f548e115a24b1600304abc7aae9e4
wildOsprey/nano-cv
/Introduction to Computer Vision/Lesson2/lesson2_19.py
2,064
3.515625
4
#Day and night classification based on brightness import cv2 import numpy as np from .tools import * from helpers import * # Image data directories image_dir_training = "day_night_images/training/" image_dir_test = "day_night_images/test/" # Using the load_dataset function in helpers.py # Load training data IMAGE_LI...
b8dd3b9721081e591bf17be021f11f23595488e1
shage001/interview-cake
/src/find-rotation-point/find_rotation_point.py
1,074
4.34375
4
def find_rotation_point( word_list ): """ ********************************************************************************************************************** I want to learn some big words so people think I'm smart. I opened up a dictionary to a page in the middle and started flipping through, looking for word...
c9ed63ed304762cfb45f3a96142df2a78a121f10
shage001/interview-cake
/src/merge-sorted-arrays/merge_sorted_arrays.py
507
4.09375
4
def merge_arrays( arr1, arr2 ): """ ********************************************************************************************************************** In order to win the prize for most cookies sold, my friend Alice and I are going to merge our Girl Scout Cookies orders and enter as one unit. Each order is re...
ef5d43d160b3882001531d5c47acf8b83bdb554a
shage001/interview-cake
/src/recursive-string-permutations/recursive_string_permutations.py
332
4.09375
4
def string_permutations( str ): """ ********************************************************************************************************************** Write a recursive function for generating all permutations of an input string. Return them as an array. Don't worry about duplicates—assume every character is un...
9b030ea113d2d1ee6dae82b2d660cd08d5532cca
ColinTing/Algorithms
/147.insertionSortList.py
1,552
4.125
4
class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next list = ListNode(-1, ListNode(5, ListNode(3, ListNode( 4, ListNode(0))))) class Solution: def insertionSortList(self, head): if head is None or head.next is None: retu...
0464843392b4c3866780002b054f545636aaa463
patriciotella/tella-juri-tella-so
/KernelSimulator/HardWare/Memory.py
709
3.640625
4
__author__ = 'Pato' class Memory: def __init__ (self): self.cells = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] self.next_cell = 0 def write_program(self, a_program): memory_position = self.next_cell for i in a_program.instructions: ...
dbdc6deb5ead539dda1873009cea59fa1bd6adc7
danrol/HW1Python
/venv/Lib/site-packages/pylablib/core/utils/iterator.py
1,055
3.765625
4
""" Class for building common iterators """ class AccessIterator(object): """ Simple sequential access iterator with customizable access function (by default it's 1D indexing). Determines end of iterations by :exc:`IndexError`. Args: obj: Container to be iterated over. access_...
ad80c971394b9bf710318406a17cc8cdbf0beb62
Nelinger91/Projects
/intro2cs/ex6/Good.py
1,394
3.546875
4
def is_balanced(s): counterstart=0 counterend=0 begining=[] end=[] check=0 for i in range(0,len(s)): if "("==s[i]: counterstart+=1 begining.append(i) elif ")"==s[i]: counterend+=1 end.append(i) if counterend!=counterstart: ...
1570693c0cfb00e8ad2148e5cd0d04851f18d832
Nelinger91/Projects
/intro2cs/ex10/WordExtractor.py
2,213
4.1875
4
#!/usr/bin/env python3 class WordExtractor(object): """ This class should be used to iterate over words contained in files. The class should maintain space complexity of O(1); i.e, regardless of the size of the iterated file, the memory requirements ofa class instance should be bounded ...
68d255a8838326be4bdc58b99f30efbe76813f86
smita-gupta83/Property_Assessment
/Gupta_Smita_Capstone_Project_Code.py
6,171
3.609375
4
""" Boston Property Assessment Python Script Copyright (c) 2019 Licensed Written by Smita Gupta """ def data_manipulation(data, column_name, manipulation_type, manipulation_value): """ This function has been created for data manipulation Parameters ----------- data: corresponds to dataframe on ...
932f842038022173208abdee109ef949784c6e92
samy1995/PYTHON_DEMO
/basics.py
6,866
4.03125
4
import math print("------------------------------------------------------------------------") print("## Emoji Converter ##") message = input("Please Enter Your Message: ") words = message.split(' ') emojis = { ":)": "😊", ":(": "😒", ";)": "😉" } output ="" for word in words: output += emojis.get(wor...
84360af2c3a540543653589fa9c7c10990914e22
DrewDaddio/Automate-Python
/regexpatterns.py
1,203
3.875
4
#Repetition in Regex Patterns import re print("?") batRegex = re.compile(r'Bat(wo)?man') adv = "The adventures of Batman" adv2 = "The adventures of Batwoman" print(adv) print(adv2) mo = batRegex.search(adv) print(mo.group()) mo2 = batRegex.search(adv2) print(mo2.group()) phoneRegex = re.compile(r'...
b98d0613e5f6abebc43ea3446e82c5fa146a89dc
DrewDaddio/Automate-Python
/KeywordArguments.py
470
4.375
4
print('Hello') print('World') # adding a keyword argument will get "Hello World" on the same line. print('Hello', end=' ') print('World') # the "end=' '" adds a single space character at the end of Hello starts the next print right next ot it print('cat', 'dog', 'mouse') #the above will have a single spac...
e003df5dfab0262310c3fcac0d38a05a8cf6168c
DrewDaddio/Automate-Python
/Logging.py
2,028
4.3125
4
# Logging # Logging is a good way to debug the program # Creates a trail of actions that we can define. #This is the setup code to setup loggin import logging logging.basicConfig(level=logging.DEBUG, format = '%(asctime)s - %(levelname)s) - %(message)s') logging.disable(logging.CRITICAL) print('There are 5 lev...
4a776c7f3f08f432a09f0d00b4bbc58e8bf3c43c
DrewDaddio/Automate-Python
/functions.py
440
4.46875
4
#def is used to create a new function. The function below will be hello() #hello() will now call whats executed into when calledS def hello(): print('Howdy') print('Howdy!!') print('Hello there!') hello() #this case adds a parameter "name" into the def function hello def hello(name): print...
20fbf45f1e114e0b9f951a295099415a5b78e2e8
Futrell/lmpy
/makeDistribMat.py
2,371
3.5625
4
#!/usr/bin/env python """ This program takes a list of target words and reads a dependency- parsed corpus to assemble vectors representing the contexts of each target word. The program: 1. Collects a list of contexts for each target word, 2. Converts the context list into a vector representation where columns represen...
5eef0b12c8126000837a72017907add9f8b83bdf
meghana153/M-R-Jeevan
/coding_solutions/Array Rotation.py
587
4.25
4
""" A program rotate an array by N positions """ array = [x for x in input('Enter array : ').split()] n = int(input('Enter Number of positions : ')) def move(array, n): """ n is < than len(array)""" return array[n::] + array[0:n:] def move2(array, n): """ n is > len(array)""" g = move(array, 1) ...
8f6600d979af940def258306d24ee53bdffa4718
meghana153/M-R-Jeevan
/coding_solutions/PRIME NUMBERS.py
489
3.859375
4
t ="FIND PRIME NUMBERS BETWEEN LOWER AND UPPER LIMIT." print(t.title()) prime =[] l_limit = int(input("lower limit: ")) if l_limit <= 1: l_limit = 2 u_limit = int(input("upper limit: ")) if l_limit > u_limit: raise Exception('Lower limit cannot be greater than upper limit.') flag = False for i in range(l_limit,...
6c7ec888faf223bd410d7387be2a572b02460970
sirisgupta/Caesar-Cipher-python-
/main.py
1,129
3.875
4
#code for caesar cipher encrypt def cce(au,sk): a=au.upper() l1=[] li="ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in a: ctr=0 if i==" ": l1.append(" ") for j in li: if i==j: l1.append(li[ctr+sk]) ctr+=...
a4169f8f2c1ebc9e81a8e831a997c58f0691ff7d
HarshaAsh/bid_allocation_model
/app.py
5,455
3.578125
4
import streamlit as st import time import numpy as np import pandas as pd from supplier_allocation import supplier_allocation from additional_functions import test_veracity_products, test_veracity_suppliers, test_veracity_bids st.set_page_config(page_title='Supplier Allocation') st.sidebar.markdown("## Constraints")...
a885f93e883fd7dacbd53b384559308d21a4ad67
asemfahad/python
/condition.py
724
4.03125
4
"""username = input('please enter your username: ') passwword = input('please enter your password: ') if username == 'asem' and passwword == '0000' or username == 'fahad' or username == 'haifa': print('welcome') else: print('error password or username') x = int(input("please Enter A Number : ")) if x == 100...
95df10ddc77fd6de7d323b5ec10d7b3fecaced28
bauefi/CS101
/Lecture_1_Input_Output_and_Flow_of_Control/AgeCalculator.py
432
4
4
year_now = input("Enter the current year then press RETURN.\n") age_now = input("Enter your current age in years.\n") another_year = input("Enter the year for which you wish to know your age.\n") another_age = int(another_year) - (int(year_now) - int(age_now)); if another_age >= 0: print("Your age in " + str(a...
f6c327b831cf0939cf35c34c924e3b0d06c75efe
abhay-raizada/p2pSystem
/main.py
638
3.5
4
import socket from threading import Thread import retrieveIP from client import Client from server import Server PORT=5020 #Specifying the port on which this chat client will operate NAME=raw_input("Enter Your Name\n") SOCK=socket.socket() choice=raw_input("1.JOIN AN EXISTING CHAT:\n2.HOST A CHAT\n") if(choice=='1')...
19704f8b473145eba0c6bc8d1968f94f9e6454e0
cid-aaron/testmachine
/testmachine/examples/floats.py
1,904
4.375
4
""" Find an example demonstrating that floating point addition is not associative Example output: t1 = 0.11945064104636571 t2 = t1 / t1 t3 = 0.16278913131835504 t4 = 0.6323432862008465 assert associative_add(t4, t3, t2) """ from testmachine import TestMachine from random import Random # This is t...
83ccfb86e81631e48ae8e86ad9d87b4f1ae616f4
cid-aaron/testmachine
/testmachine/examples/commutativeints.py
526
3.765625
4
""" This attempts to show that integer addition is not commutative. Since integer addition is commutative, it will not have much luck. Example output: Unable to find a failing program of length <= 200 after 500 iterations """ from testmachine import TestMachine from testmachine.common import ints, check machine ...
aa82a2cad66b8de2ff248962ec595908ee074d23
KayanSilva/ReservePython
/TestandoPython6/TestandoCodigo4.py
228
3.75
4
#Testando codigos com IF em Python bestanswer = 'yes'; answer = input('Would you like? ') if answer.upper() == bestanswer.upper(): print('That will be an extra $10') #print('That more $10') print('Have a good day')
148b0b8baa21251c2d58a265f4136e14393d616d
KayanSilva/ReservePython
/GamesInPython/src/gamesinpython.py
349
3.625
4
import diviner import gallows print("*******************************") print("Games in Python by Kayan Silva.") print("*******************************") game = int(input("Choice a game ---> (1) Gallows or (2) Diviner: ")) if(game == 1): print("Playing Gallows!") gallows.play() elif(game == 2): print("Pla...
dc12ca2047c9ecb2d2a5ed5ec93178f4c1b9ae49
KayanSilva/ReservePython
/ManipulandoString/antigo/aula01/main.py
506
3.578125
4
minhaIdade = 28 sobreMim = "Meu nome é Kayan e minha idade é 28" meuNome = "Kayan" print(meuNome) print(type(meuNome)) print(type(minhaIdade)) #.... substring = sobreMim[33:] print(substring) #.... url = "https://www.butebank.com.br/cambio?moedaorigem=real&moedadestino=dolar&valor=1500" argumento = "moedaorigem=real"...
a16ded0a84509531f1a34323ffd72dd097db1392
KayanSilva/ReservePython
/TestandoPython6/TestandoCodigo3.py
252
3.90625
4
#importando bibioteca para datas import datetime currentDate = datetime.date.today() userInput = input('Please birthday') birthday = datetime.datetime.strptime(userInput, '%d/m/%Y').date() print(userInput) days = birthday - currentDate print(days.days)
d7b841edcfeadb800d7ac4499cee35c9ef8d3ba9
olliematthews/multi-agent-rl-thesis
/Multi_Agent_Actor_Critic/environment.py
9,580
3.5
4
""" Created on Thu Oct 10 10:31:04 2019 @author: Ollie """ import numpy as np class Cyclist: def __init__(self, env_params, n_cyclists = 4, number = 0, velocity = 0, pose = 0, energy = 100): ''' Initialiser Parameters ---------- env_params : dict A dictionary w...
bec3375171ca517241835479a244d9cd8758ff58
nena6/Udacity-Introduction-to-Python-Programming
/html_tags.py
839
4.1875
4
#Write the html_list function. The function takes one argument, a list of strings, and returns a single string which is an HTML list. For example, if the function should produce the following string when provided the list ['first string', 'second string']. #define the html_list function def html_list(htmllist): m...
ef4aac3c8662c7956a7000577fb1609e925388d3
nena6/Udacity-Introduction-to-Python-Programming
/starbox.py
1,559
4.71875
5
#The starbox function in the quiz below prints a box made out of asterisks. The function takes two arguments, width and #height, that specify how many characters wide the box is and how many lines tall it is. The function isn't quite complete: it #prints boxes of the correct width, but the height argument is ignored. C...
54e006ce2c79e69b7d5ec4222a5401bf61824fd8
cliu0507/DL-ML-DM
/Template/Template_logistic_regression.py
6,145
4.0625
4
#Use Tensorflow to solve machine learning problem #Logistic Regression (Binary Classification) #Import tensorflow library import tensorflow as tf import numpy as np import math import random from sklearn.datasets import make_classification import matplotlib.pyplot as plt #---------------------------------------------...
61c28a65e3859d560348586390ce5acb17168d60
Solara570/demo-solara
/articles/inversion.py
111,041
3.640625
4
#coding=utf-8 ################################################################################################ # A 3-part series on circle inversion, Descartes' theorem along with its variants, and more! # # # # Part 1: A...
035343f554bfb7455e0643bdcb9a503475fd690d
lzr2006/PythonStudy
/Chapter5/Example25.py
271
3.921875
4
#Chapter5/Example25.py #!/usr/bin/python i=1 #用i表示行数 while i <=9 :#共有9行 j=1 #用i表示列数 while j<=i: #当列数小于等于行数 print("j","*","i","=",j*i) #打印 j=j+1 #令列数自增1 i=i+1 #令行数自增1
ec8fc4c2ba08df1c4312f45bce1e36e1a4367da6
lzr2006/PythonStudy
/Chapter3/Example18.py
255
4.0625
4
#Chapter3/Example18.py x1=int(input("请输入第一个数")) x2=int(input("请输入第二个数")) y=x1+x2 print("结果是",y) #改为小数 x1=float(input("请输入第一个数")) x2=float(input("请输入第二个数")) y=x1+x2 print("结果是",y)
4321fb467c37ec8f0f154a336972f76f6bb95c1e
lzr2006/PythonStudy
/Chapter5/Example29.py
200
3.84375
4
#Chapter5/Example29.py #!/usr/bin/python for i in range(1,10): #i表示行数 for j in range(1,i+1): #j表示列数 print("j","*","i","=",j*i,end=" ") #输出 print("\n") #换行
ed92d2ec45735ac6e4b189c992913d220d29958f
lzr2006/PythonStudy
/Chapter4/Example23.py
86
3.75
4
#Chapter4/Example23.py x=int(input("请输入数字")) y=x if x>=0 else -x print(y)
8b8f42513d505b5c8b6f1bd5ee48567c76c44440
endw0901/python_ml
/perceptron_simple.py
250
3.515625
4
# perceptron def AndGate(x1, x2): w1, w2, theta = 0.5, 0.5, 0.7 tmp = x1*w1 + x2*w2 if tmp <= theta: return 0 elif tmp > theta: return 1 print(AndGate(0,0)) print(AndGate(0,1)) print(AndGate(1,0)) print(AndGate(1,1))
359b647ce7d5b3b6949fe6cb5fd7b19905012cfb
Ultrasteve/Introduction-to-Algorithms
/Section1_chapter2/2.3-1.py
1,756
3.515625
4
""" 归并排序 输入数组【3,41,52,26,38,57,9,49】 """ # 方法一: # import math # def Merge(A, p, q, r): # C = [] # D = [] # result = [] # for i in range(q - p + 1): # C.append(A[p + i]) # for i in range(r - q): # D.append(A[q + 1 + i]) # C.append(999999) # D.append(999999) # c = 0 # d = 0 # while C[c] != 999999 and ...
1b130682ed37d7a1938c39ba9c22586fd404c182
irinanicoleta/Google-Atelierul-Digital-Python
/Homework-3/my_package/task_3.py
144
3.5625
4
def check_if_integer(): value = input('Enter value here: ') try: return int(value) except ValueError as e: return 0
909272ab3c353329e012bcc275735332aa033fc6
ns-m/netology_ad_py_Database_PostgreSQL
/main.py
3,628
3.609375
4
import psycopg2 as pg from datetime import datetime DATA = { 'dbname': 'learningdb', 'user': 'postgres', 'password': '', 'host': 'localhost', 'port': '5432' } def create_db(): with pg.connect(**DATA) as conn: with conn.cursor() as curs: curs.execute("""CREATE TABLE s...
f3e5268363f41fc55643820ed6cc0fa6c3ef7ad6
zimolzak/instruct-project-etrigger-sql
/advanced/whats_the_longest_line.py
273
3.765625
4
# python whats_the_longest_line.py LungOperational.sql import sys max_length = 0 the_line = '' with open(sys.argv[1]) as fh: for L in fh: if len(L) > max_length: max_length = len(L) the_line = L print(max_length) print(the_line, end='')
fe06938fca12f7d18acb9886c8fc5d28fe8d74e3
ICS3U-Programming-JonathanK/Unit2-03-Python
/circ_circle_tau.py
493
4.5625
5
#!/usr/bin/env python3 # Created by: Jonathan Kene # Created on: May 4, 2021 # This program asks the user for the radius of # a circle in m. It then calculates and displays # the circumference using tau. import constants def main(): # input radius = float(input("Enter the radius of the circle (m): ")) # ...
737b5a2c8718b9c6ce4f647c1dd768e195d1576c
gautamtarika/Programming_Basics
/Tkinter_Basic_Programs/labels_in_tkinter.py
189
3.828125
4
from tkinter import * window=Tk() #root window window.title("Label in Tkinter") L=Label(window,text="Getting started with tkinter").pack() #adding label to window window.mainloop()
f3c35eb80e7d6f325717b21a4d83c0a4cc2dff3d
gautamtarika/Programming_Basics
/Python_Basic/multiply_function.py
93
3.765625
4
def multiply(n1,n2): print(n1*n2) n1=int(input()) n2=int(input()) multiply(n1,n2)
d359810f0b14eb14acc973e4ea11ec70c711fb5c
gautamtarika/Programming_Basics
/Python_Basic/sqrt_function.py
208
4.03125
4
from math import sqrt a = sqrt(25) print(a) #here we have use math module available in python library. # we can use a different method to find square root also. import math a=math.sqrt(25) print(a)
85ccd8bad95c959a76f23fb12331e01c3393ad42
gautamtarika/Programming_Basics
/Python_Basic/second_greatest.py
150
3.8125
4
tc= int(input()) while(tc>0): num=[] for i in range(3): num.append(int(input())) num.sort() print(num[-2]) tc=tc-1
921328319e9a3953a2b99cc4f448d5bb6ac0ccaa
97mark749/Data-Visualization
/bar-graph-with-csv.py
1,750
3.625
4
from matplotlib import pyplot as plt import numpy as np import csv from collections import Counter import pandas as pd # print(plt.style.available) # execute the above to show a list of options for styles # Note some style have their own grid and color preferences # This is what to type in for styles plt.style.use('...
7d578ffa7a692468c0b994405f14e899c8fe4953
ableach/multi-paradigm-library
/libraryMVC/library2GUI.py
4,009
4.15625
4
class Book: # Note: self represents the instance of the class # e.g. used to access attributes and methods of a specific book def __init__(self, title, author): self.title = title self.author = author self.borrower = None def describe(self): print("Book Details")...
9aa966d1aa7702796ddf2312c97840f86470a027
PeterHolderrieth/Visualizing_backpropagation
/visualize_neural_nets.py
3,533
3.90625
4
import matplotlib.pyplot as plt import numpy as np from matplotlib.colors import Normalize from utils import give_ranks_of_array def visualize_neural_net(ax, left, right, bottom, top, layer_list,weight_list,cmap=None,ranks=False,threshold=None): ''' Function to visualize a multilayer perceptron (fully connec...
a48615ee5868fa52f9df96d89e9452609982bcbc
vjbaskar/cscipipe
/crispr/crisprCountTable.py
2,465
3.6875
4
#!/usr/bin/env python3 import os import argparse def getCounts(fileName): i=0 count_dict = dict() with open(fileName, mode = "r") as file: for line in file: line = line.strip() f = line.split(sep="\t") lastCol = len(f) - 1 grna_id = f[0] gene = f[1] sequence = f[2] libCount = f[3] exptCo...
e054be35905bab81f58eda44282e898c21856103
121910313014/pythonprograms
/L-3 ASSIGNMENT-1-ARRAY-CONCATENATION.py
639
4.125
4
# Program to concatenate arrays # J. Raghuramjee - 121910313004 # Taking inputs n = int(input("Enter the number of arrays you want to concatenate : ")) arr = [] for i in range(n): a = [] size = int(input("Enter the size of array " + str(i+1) + " : ")) print("Enter the elements of array", i+1, ":")...
05d13a83beacad32fa3d411aa6ad795afea1de00
121910313014/pythonprograms
/SWAPPING NUMBERS.py
570
4.21875
4
# Program to check whether a given number is Armstrong number or not and printing the sum of its digits # J. Raghuramjee - 121910313004 # Taking the numbers as input num1 = int(input("Enter the first number : ")) num2 = int(input("Enter the second number : ")) print('Before swapping, The first number is' , num...
5d074da5caef06a80f3506fe2ef3d321f756e935
121910313014/pythonprograms
/L-3 ALL-PROGRAMS-USING-FUCNTIONS.py
1,391
4.5
4
# ALL PROGRAMS USING FUNCTIONS IN L3 # J. Raghuramjee - 121910313004 # Function to copy elements form array def copy_array(arr): # Creating another array to store elements arr2 = [] # Logic to copy array elements using for loop for i in arr1: arr2.append(i) # Appending each element fro...
8d0cac05cb5c6cf78a2113daeef250222abc343b
121910313014/pythonprograms
/L-9 Stack User Choice.py
827
4.125
4
class Stack: def __init__(self): self.items = [] def push(self, data): self.items.append(data) def pop(self): if s.items!=[]: return self.items.pop() def printstack(self): print(self.items) s = Stack() print("Select a choice :") print("1. PUSH") print(...
8e5e02bc4304683c0102de80eca7873c34523efe
kaanozbudak/codeSignal
/arcade/makeArrayConsecutive2.py
762
3.859375
4
# Created by kaanozbudak at 2019-07-18 statues = [6, 2, 3, 8] # Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, # each statue having an non-negative integer size. Since he likes to make things perfect, # he wants to arrange them from smallest to largest so that each statue will...
cece027ae62d21e16b4aa2df02c2cdbd861859c0
edaveballard/CS_class_activities
/Python/Demos/StockMarketGame.py
6,343
4.15625
4
import random #Words used to make random company names COMPANY_NAME_WORDS = ("Food","Mine","Garden","Robot","Next","Tech","Sun","Electric","Forest","Road","Hat","Run","Play","Muscle","Cool","Fruit","Sea","Wire","Blue","Moon","Seven","Phone","Castle","Ship","Game","Loud","Cloud","Air","Punch","Pirate") #Total number o...
4357dbf10fb8a664ad544577dd1771425bdc3faf
porala/python
/UAT_scripts/testscript3.py
143
4.0625
4
#!/usr/bin/python3 your_age = input("Enter your age: ") last_year_age = int(your_age) - 1 print("Your last year age was: %s" % last_year_age)
5becdcb33379525e114e05e11eff367a2660291a
porala/python
/practice/46.py
313
3.90625
4
#Write a script that extracts letters from the 26 text files and put the letters in a list import glob letters = [] file_list = glob.glob("letters/*.txt") print(file_list) for filename in file_list: with open(filename, "r") as file: letters.append(file.read().strip("\n")) print(letters)
9d5ca9358dd6f6da98710fa6f294e5d506983522
porala/python
/practice/22.py
317
3.671875
4
#Create a dictionary of keys a, b, c where each key has as value a list from 1 to 10, 11 to 20, and 21 to 30 respectively and print out from pprint import pprint d = dict(a = list(range(1, 11)), b = list(range(11, 21)), c = list(range(21, 31))) pprint(d) #Video question so that user sees the pretty print
a402065ad6f6084a925d31da5fd2a1fa673b259a
porala/python
/UAT_scripts/remove_duplicates.py
253
3.859375
4
#!/usr/bin/python a = ["1", 1, "1", 2] a = list(set(a)) print(a) from collections import OrderedDict c = ["1", 1, "1", 2] c = list(OrderedDict.fromkeys(c)) print(c) d = ["1", 1, "1", 2] b = [] for i in d: if i not in b: b.append(i) print(b)
be53de0153562c8ca5913f724b75a0b5cecf73bb
porala/python
/UAT_scripts/advanced_password.py
311
3.765625
4
#!/usr/bin/python3 while True: username = input("Enter username: ") with open("users.txt", 'r') as file: users = file.readlines() users = [i.strip("\n") for i in users] if username in users: print("Username exists. Please try again") continue else: break
0e19c7966cc29cf11780e5586f49aed3b6d0a5df
Wanke15/ImageCaption-Keras
/extract_image_feature.py
985
3.625
4
import numpy as np from tensorflow.keras.preprocessing import image from tensorflow.python.keras.applications.inception_v3 import preprocess_input def image_preprocess(image_path): # Convert all the images to size 299x299 as expected by the inception v3 model img = image.load_img(image_path, target_size=(299...
5b27be6f420cb0631b9636ff74fa9c645c9a7c8f
NanaTake/dokugakuprogrammer
/dp2-13.py
527
4.0625
4
# オブジェクト指向での主要概念 # カプセル化...複数の変数とメソッドをまとめ、外から見えないようにする class Data: """__init__ 数値をlist型のコンテナnumsに格納している change_data 指定された順の数値を変更する """ def __init__(self): self.nums = [1, 2, 3, 4, 5] def change_data(self, index, n): self.nums[index] = n data_one = Data() print(data_one.n...
9b0c41706e6cfec56165722df38a1a031fecbc4e
NanaTake/dokugakuprogrammer
/dp1-5.py
6,905
4.375
4
# 文字列を変換するメソッド例 "Hello".upper() "hello".replace("o", "@") # リストは要素を指定順番通りに格納するコンテナ # 番号を指定してあげると中身の値を取り出せる fruit = list() fruit fruit = [] fruit fruit = ['apple', 'orange', 'pear'] fruit.append('banana') fruit fruit[0] fruit[2] = 'melon' fruit # 指定した位置の要素を削除し、値を取得: pop() fruit = ['apple', 'orange', 'pear'] basket ...
361fc81d034d7c85e433306a5c1b1afd8b4b3db2
3797kaushik/Hackerrank-Algorithm-Solutions
/2. Implementation/63. Happy LadyBugs.py
1,135
3.515625
4
#!/bin/python3 import math import os import random import re import sys # Complete the happyLadybugs function below. def count_chars(txt,ch): result = 0 for char in txt: if char.__eq__(ch): result += 1 # same as result = result + 1 return result def already(b,len2): len1=len(b)...
6ef19a6799ce8c1356eee2cd5e6eb1f2c8360dd6
pravinmaske/TorontoPython
/merge_List.py
726
3.75
4
def merge(L): merged=[] for i in range(0,len(L),3): merged.append(L[i]+L[i+1]+L[i+2]) return merged print(merge([1,2,3,4,5,6,7,8,9])) def mystery(s): matches = 0 for i in range(len(s)//2): if s[i] == s[len(s)-1-i]: matches+=1 print(matches) return matc...
04f699c78d66cc5f97b69dc5679653b4bd39bebc
pravinmaske/TorontoPython
/average.py
590
4.125
4
def averages1(grades): """ (list of list of number)-> List of float Return a new list in which each item is the average of the grades in the inner list at the corresponding position of grades. >>>averages([[70,75,80],[70,80,90,100],[80,100]]) [75.0, 85.0, 90.0] """ averages=[] for grades_list in grades: ...
a39af660c5f12b16c17b16a800d12aaaaa038d84
AlonzoRon/EEE-121
/Meeting_02/exercise1.py
396
3.5
4
def g(x, n): return (x ** 2 + 1) % n def gcd(m, n): if m < 0: m = -m if n < 0: n = -n if n == 0: return m return gcd(n, m % n) def maybe_prime(n): x, y, d = 2, 2, 1 while d == 1: x = g(x, n) y = g(g(y, n), n) d = gcd(x - y, n) return...
c7b9570e6d227e171217253469bc6ad0d167fcd4
christosg88/hackerrank
/Python/3_Strings/Find_a_string/main.py
265
3.921875
4
import re def count_substring(s, sub_s): return sum(1 for _ in re.finditer(r'(?=' + sub_s + r')', s)) if __name__ == '__main__': string = input().strip() sub_string = input().strip() count = count_substring(string, sub_string) print(count)
351477ae916c9a41a4af5e6c3772a09a704d7b6c
christosg88/hackerrank
/Regex/7-Applications/Utopian_Identification_Number/utopian-identification-number.py
223
3.6875
4
import re p = re.compile(r'[a-z]{0,3}\d{2,8}[A-Z]{3,}') N = int(input()) for i in range(N): s = input() result = p.match(s) if result: print('VALID') else: print('INVALID')
6a04fdf883f4504a65a91502e7d6f9ae0241ef18
christosg88/hackerrank
/Python/1_Introduction/Write_a_function/main.py
127
3.921875
4
def is_leap(year): return not ((year % 400) and (year % 4 or not (year % 100))) year = int(input()) print(is_leap(year))
d7440b55c339333a75a8a5054595ae912ddaa637
christosg88/hackerrank
/Python/2_Basic_Data_Types/Lists/main.py
598
3.75
4
if __name__ == '__main__': lst = [] for _ in range(int(input())): line = input().split() operation = line[0] if operation == 'print': print(lst) elif operation == 'sort': lst.sort() elif operation == 'pop': lst.pop() elif opera...
d517cf68f4cf090335a7f33adf9423e644b85c1b
Farhana-Afrin-Maysha/chor_police_game_python
/chor_police.py
1,490
3.828125
4
import random def find_thief(): y = int(input('Say the index no of thief. ')) if (y == mylist.index(00)): print('You are correct') else: print('You are not correct') def call_police(): print("Info: The index of Boss & Police is - ", mylist.index(100), mylist.index(80)) local = m...
c8220ad8bc6ae9c3e1378af4da2c064b54130999
WargLlih/LPP
/LPP_Listas/Lista_05/Questao_B.py
133
3.546875
4
cont = 0 for i in range(1, 10): if i != 3: for j in range(1, 7): print('oi') cont+=1 print(cont)
53a2d0b1cd3b996fe30062091425d4f4c55e4bd2
WargLlih/LPP
/LPP_Listas/Lista_01/Questao_009.py
156
3.546875
4
km = int(input("Quantidade de Km Percorrido: ")) dias = int(input("Quantidade de Dias: ")) #60 : dia #0.15 : km print("Preço a Pagar: ",km*0.15+dias*60)
a12cea4801c5cc389dc9cdbb73f1d718e3d152fe
WargLlih/LPP
/LPP_Listas/Lista_03/Questao_005.py
321
4.03125
4
print("***Algoritmo de Euclides***") numero_1 = int(input("Digite um numero: ")) numero_2 = int(input("DIgite o segundo numero:")) resto = 1#entrando no loop while resto != 0: resto = numero_1 % numero_2 mdc = numero_2 numero_1 = numero_2 numero_2 = resto print("MDC = {}".format(mdc))...
25f30552d96a9f7e9194c598a3d4a74085292979
WargLlih/LPP
/LPP_Listas/Lista_03/Questao_002.py
192
3.890625
4
user = input("Usuário: ") pasw = input("Senha: ") while user == pasw: print("Digite valores diferentes para usuario e senha!") user = input("Usuário: ") pasw = input("Senha: ")
d033a6b805539e070df5b80189114c0e98345932
Dukehang/store
/day04/任务4.py
300
3.71875
4
''' 请编程统计列表中的每个数字出现的次数(百度初级测试开发笔试题) List = [1,4,7,5,8,2,1,3,4,5,9,7,6,1,10] ''' List=[1,4,7,5,8,2,1,3,4,5,9,7,6,1,10] List1=list(set(List)) a = len(List1) b = 0 while b<a: print(List1[b],"出现",List.count(List1[b]),"次") b = b + 1
5744c6238d6f56ce850a661aee63d67736a5489b
Dukehang/store
/任务7.py
190
3.78125
4
''' 使用while编程实现求1~100以内的数的和! ''' CS=0 ZH=0 while CS<=100: CS = CS + 1 print("第几次",CS) CS=int(CS) ZH=ZH+CS print("数字总和为:",ZH)
05deaa51b3fbe85d9fc7d390612dcce35d85f08b
PurplePenguin4102/ark-thremar
/classes/Word.py
494
3.5
4
class = Word(object): """This will hold a bunch of variables that templates will read from to construct descriptions and that Creatures and Rooms will need to construct themselves""" def __init__(self, word, plural, wtype=None, subtype=None): self.word = word self.type = wtype #adjective, noun, mood, nationalit...
bcd95e13b939a3fdc94eb1625b51ce4595e2ef30
Chraut/tutObjectBasedProg
/tutObjectBasedProg/Special_MagicDunder_Methods.py
1,659
4.15625
4
''' Created on Mar 17, 2020 @author: marbe ''' class Employee: raise_amount = 1.04 # __ is called dunder you say: "dunder" init "dunder" ----!!!!! def __init__(self, first, last, pay): self.first = first self.last = last sel...
1400c36e6acdaddb25afc5bb5d8233f88cfcbc75
Legedith/Misc.
/ps6.py
715
3.765625
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 15 14:00:46 2018 @author: DSC """ balance = float(input("balance: ")) annualInterestRate = float(input("annualInterestRate: ")) monthlyInt = annualInterestRate/12 low = balance /12 high = (balance*(1+monthlyInt)**12)/12 guess = (low+high)/2 steps=0 temp = balance while ab...
e63ebcc4d258ef8ec7f42956bb522d3010f7403a
Mefoolyhi/Fillomino
/Fillomino1/generator.py
6,523
3.71875
4
"""Модуль генерирует поля заданного размера. Параметром задается число частей, на которое разбивается сторона равностороннего треугольного поля""" import random import classes import argparse import pickle import sys def generate_field(n): """Метод генерирует треугольное поле размера n*n и возвращает само по...
aa821764082fec92175a4074e3f9ba502fa05e30
Ananth-Adhikarla/Python-Programming
/permutation.py
1,732
4.5
4
""" Please submit the following in a file named `permutation.py`. 1. For a list of integers L of length n, write a function `isPermutation(L)` returns True if L is a re-ordering of the integers from 1 up to n and False otherwise. For example, if `L = [1,2,4,3,5]`, `isPermutation(L)` should return True, because since n...
5fc8de7bd4768929088c2f01efe00fd6ad7c1197
Ananth-Adhikarla/Python-Programming
/file_test3.py
353
3.78125
4
def createFile(fname): fd = open(fname , "w+") print("Enter some data to your file : ") while(True): line = input() if(line == 'exit'): break else: fd.write(line) fd.write("\n") fd.close() print("\n\n\n\n") print("Data stored on file : \n") with open(fname, "r+") as f: print(f.re...
9f5961aefaa906488c8a74439788becc301256ab
Ananth-Adhikarla/Python-Programming
/stack.py
1,590
4.15625
4
""" STACKS """ class Node: def __init__(self,initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self,newdata): self.data = newdata def setNext(self,newnext): self.next = newnext class Stack: def __init__(sel...
69d6276abbef0a397e71392a3cedaa028a1ca15c
JulieZhang0102/MIS3640
/session07/iteration.py
915
3.734375
4
# exercise 1 # result = 0 # for i in range (1, 11): # result +=i # # result = result + i # print(result) # result = 0 # for i in range(1, 1001, 2): # result += i # print(result) # sum of square of integers # result = 0 # for i in range(1, 5): # result += i*i # print(result) # name = "Greg" # enc...
d3af52029e5c048b1e802c5160c3cbc628f7cb9b
JulieZhang0102/MIS3640
/session04/exercise1.py
396
3.84375
4
import math def quadratic(a, b, c): y = b**2 - 4*a*c if y > 0: x1 = (((-b) + math.sqrt(y))/(2*a)) x2 = (((-b) - math.sqrt(y))/(2*a)) print('The answers are', x1, 'and', x2) elif y == 0: x = (-b) / 2*a print('The answer is', x) else: print('There is no answ...