blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f22beaf7e83ebd005ef175266dec05dd3e942aca
priyaVora/pythonProjects
/SimpleProjects/SimpleCalculator.py
1,316
4.15625
4
operations = {1: "Add", 2: "Subtract", 3: "Multiply", 4: "Divide"} loop = True user_selection = "" while loop == True: try: for key, values in operations.items(): print(str(key) + ". " + values) user_input = input("Please enter one of the operation types from above: ") size = l...
f9af27555e1cf1a158d257a98d290fbdadf31861
Laurensvaldez/PythonCrashCourse
/CH3: Introducing Lists/lists.py
2,113
4.71875
5
# a list is made with square brackets -> [] # for example: names = ['Laurens', 'Elba', 'Jonathan', 'Vanessa', 'Domingo'] # if you want to access an item from the list you can use the index number print (names[:2] ) # in this case you print the first two items given # because in Python the first item in a dat...
ec8d02ebef9984e314adb2aa451dd261f3b24f10
SkyfengBiuBiu/Introduction-to-Audio-Processing
/sgn2017/ex0/exercise0.py
2,155
3.546875
4
# coding: utf-8 # import Python modules import sys import numpy as np import matplotlib.pyplot as plt import scipy from scipy.io import wavfile from scipy import signal # Read the wavefile: sound of plucking a guitar string #This is my own audio file #fs,x = wavfile.read('hall.wav') fs,x = wavfile.read('gtr55.wav')...
c0e632ae148d4bc7346a81f0883e0018f6e5ec88
jordan-dinwiddy/python-play
/basics/function1.py
421
4.09375
4
#!/usr/bin/python def fib(n): # write Fibonacci series up to n """Print a Fibonacci series up to n.""" # The above line is called the docstring a, b = 0, 1 while a < n: print a, a, b = b, a+b fib(2000); f = fib f(100); # Some might say that fib is really a procedure not a function # because it doesn't ...
f2a642e7119e197b3bb4a5ce824c6890be8dee0e
freebz/Python-Cookbook
/ch05/ex5-4.py
953
3.59375
4
# 5.4 바이너리 데이터 읽고 쓰기 # 파일 전체를 하나의 바이트 문자열로 읽기 with open('somefile.bin', 'rb') as f: data = f.read() # 바이너리 데이터 파일에 쓰기 with open('somefile.bin', 'wb') as f: f.write(b'Hello World') # 토론 # 텍스트 문자열 t = 'Hello World' t[0] # 'H' for c in t: print(c) # H # e # l # l # o # ... # 바이트 문자열 b = b'Hello World' b[...
69ddea33daae9524818d3eab1972776568f25f2e
SharminAkter93/Linear_project
/Queue_implementation.py
2,304
4.15625
4
# Initialize a queue queue_exm = [] # Adding elements to the queue queue_exm.append('x') queue_exm.append('y') queue_exm.append('z') print("Queue before any operations") print(queue_exm) # Removing elements from the queue print("\nDequeuing items") print(queue_exm.pop(0)) print(queue_exm.pop(0)) print(queue...
9b727d5e6536cce2fc0b734783b755cfdf6be352
titohayward/Engr-216-Lab-Group-B-Code
/finite diff functions.py
1,617
3.765625
4
# Juan Hayward # ### this is a general finite difference function import numpy as np time = np.array([0,2,4,6,8,10,12,14,16]) pos = np.array([0,0.7,1.8,3.4,5.1,6.3,7.3,8.0,8.4]) def velocity(pos_array,time_array): print("pos length:", len(pos_array), "time length:", len(time_array)) if len(pos_array) != len(...
7801dce80fd2a586745f1e0155cbc6b7079cd849
dolooo/JS-Projekt-Saper
/Interface.py
10,801
3.640625
4
from tkinter import * import time class MainWindow: """główne okienko gry""" def __init__(self, controller): """ustawienia parametrów głównego okienka gry""" self._window = Tk() self._controller = controller self._window.title("Saper") self._window.iconbitmap("images/ic...
c8339212ca119a46b22abbae4b0a36a8f1038c28
HenriqueHideaki/100DaysOfAlgo
/Day 75/LCS.py
1,400
4.09375
4
''' Problem statement : Given an array of integers, find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order Algorithm: Create an empty hash. Insert all array elements to hash. Do following for every element arr[i] Check ...
a875ab86b2b7bdb42675b5a9b4004994a9791a62
mczekajski/15game
/main.py
2,571
3.515625
4
from random import randint, choice from tkinter import * class Game(): base_grid = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0] ] grid = base_grid def get_position(self, num): row = 0 for x in self.grid: if num in x: ...
420902bcaf92c3b054d4819bd1bfa50df4e12977
marinnaricke/CMSC201
/Homeworks/hw4/hw4_part3.py
696
4.3125
4
#File: hw4_part3.py #Author: Marinna Ricketts-Uy #Date: 9/30/15 #Lab Section: 17 #UMBC Email: pd12778@umbc.edu #Description: This program asks the user for input to determine whether a # subject can be studied or not. def main(): #initialize variable size = 10 subjects_list...
0f4fb1a54e06d235c4216627a71fc892f9baa42c
rrang004/Backup-Renamer
/backup renamer 2000 v1.py
1,061
3.578125
4
#This script was created to aid me in renaming instrument stem files by removing the backup date and time #Wanna delete 25 characters, from ( to ) import os #os.listdir(os.curdir) print("backup renamer 2000 v1") for filename in os.listdir("."): print(filename) curName = filename print("curName = "...
d9711cbd3d92a6d1ad6b330c9648813942fb5004
NickBryson/My_Projects
/Shipping_Cost.py
1,519
4.03125
4
def cost_of_ground_shipping(weight): cost = 0 if (weight <= 2): cost = (weight * 1.50) + 20.00 elif (weight > 2) and (weight <= 6): cost = (weight * 3.00) + 20.00 elif (weight > 6) and (weight <= 10): cost = (weight * 4.00) + 20.00 else: cost = (weight * 4.75) + 20.00 return cost ...
3621c1e421286c7a64134cd72d4432868fa8b5d3
anantkaushik/Competitive_Programming
/Python/GeeksforGeeks/search-in-a-rotated-array.py
1,428
4.09375
4
""" Problem Link: https://practice.geeksforgeeks.org/problems/search-in-a-rotated-array4618/1 Given a sorted and rotated array A of N distinct elements which is rotated at some point, and given an element key. The task is to find the index of the given element key in the array A. Example 1: Input: N = 9 A[] = {5, 6,...
4c469013f10bd6093eaf6a907a2039cb3ebc4b7d
dabaicai233/Base-Prooject
/机试题.py
4,881
3.625
4
#第一题:1.设计一个函数,传入两个代表日期的字符串, # 如“2018-2-26”、“2017-12-12”,计算两个日期相差多少天 def main(str1,str2): import datetime str1 = "2018-2-26" str2 = "2017-12-12" str1 = str1.split("-") str2 = str2.split("-") days =abs(datetime.datetime(int(str2[0]), int(str2[1]), int(str2[2])) - datetime.datetime(int(str1[0]), in...
d20c355670f14a4cddd8c618dc76eb666056c250
alonso121198/Videogame_FunctionWar
/Ejemplos_arcade/Mecanicas/FunctionWar.py
5,560
3.8125
4
import random import arcade SPRITE_SCALING_PLAYER = 0.5 SPRITE_SCALING_COIN = 0.2 SPRITE_SCALING_LASER = 0.8 COIN_COUNT = 50 SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 BULLET_SPEED_X = 5 BULLET_SPEED_Y = 5 class MyGame(arcade.Window): """ Main application class. """ def __init__(self): """ Initializer...
02af04a2cb8d5de1c50241685b200525739e16a8
Lolirofle/Toabot
/bin/external_commands/wikipedia
1,806
3.796875
4
#!/usr/bin/python import sys import codecs import wikipedia import sqlite3 # Database tools. Mainly used for caching the results from data fetching def dbLookupEntry(db,title): returnValue = None try: db.execute('SELECT content FROM wiki_entries WHERE title=?',(title,)) returnValue = db.fetchone() if returnV...
c82fef6a9c65f5515aabc02cf02ddcabbf51c9fb
Terry9022/learn_Python
/python_practice/py_14 score.py
520
3.609375
4
n=eval(input()) if 90<=n<=100: print("4.3") print("A+") elif 85<=n<=89: print("4.0") print("A") elif 80<=n<=84: print("3.7") print("A-") elif 77<=n<=79: print("3.3") print("B+") elif 73<=n<=76: print("3.0") print("B") elif 70<=n<=72: print("2.7") print("...
4ed2ffe29bf382b30e6de976d906dfcd359031c8
daum913/python_project
/assignments/loop-1/loop1-8.py
810
3.90625
4
# 문제 8.(for) # 두 개의 정수를 입력받아 두 정수 사이(두 정수를 포함)에 3의 배수이거나 5의 배수인 수들의 합과 평균을 출력하는 프로그램을 작성하시오. # 평균은 반올림하여 소수 첫째자리까지 출력한다. # 입력 예: 10 15 # 출력 예: sum : 37 avg : 12.3 num_1 = int(input("첫 번째 정수를 입력하세요 : ")) num_2 = int(input("두 번째 정수를 입력하세요 : ")) list = [] sum = 0 if num_1 > num_2 : for i in range(num_2, num_1+1) : ...
15fd098e391bac7d24b6dfa775f3f0a28b86f956
yasuki666/UAV-mission-planning-homework
/作业2/linklist.py
2,925
3.765625
4
class Node: def __init__(self, key): self.key = key self.next = None class LinkList: def __init__(self, node=None): # 使用一个默认参数,在传入头结点时则接收,在没有传入时,就默认头结点为空 self.head = node def isEmpty(self): if self.head == None: return True else: return Fa...
1df571b0ac6512bdff3b2e3845f1ef2f44ee39a4
assuran54/UFABC-PI
/Calculadora.py
860
4.0625
4
pedido = input() operaçao = pedido.split(' ') # .split() no parenteses está o símbolo que representa o local de divisão, split funçao = operaçao[0] x = float(operaçao[1]) #LEMBRE QUE PRA COMPARAÇÃO É O == if len(operaçao) == 3: y = float(operaçao[2]) #Exatamente dois decimais -> '{:.2f}'.format() #...
863c71a85c66235fc56adba44e2f5ab53e2da28d
PyRPy/Py4fun
/PythonEdu/game_snow.py
1,414
3.984375
4
# how to simulate a snow # http://programarcadegames.com/index.php?chapter=example_code import pygame import random # initialize pygame.init() BLACK = [0, 0, 0] WHITE = [255, 255, 255] # set screen size SIZE = [400, 400] screen = pygame.display.set_mode(SIZE) pygame.display.set_caption("Snow animation") ...
f5a75f2cc8d75d0e7d6cd141a0286e6486323237
zhu535/Python_Study
/Neuedu_20200202/day08_propert的使用.py
856
3.6875
4
# -*- coding: utf-8 -*- # @Time : 2020/2/6 16:33 # @Author : zhu # @FileName: day08_propert的使用.py # @Software: PyCharm """ class Girl: def __init__(self, weight): self.__weight = weight def get_weight(self): print("我的体重是%s" % self.__weight) def set_weight(self, weight): self.__we...
f30e1b6ab7bb6e7c8329bb19e10f3fd95800e760
dimaswahabp/Testing
/task6.py
818
3.765625
4
#sebuah function dengan 1 parameter #function => menentukan value parameter ganjil genap ''' def gangen(x): if (x % 2) == 0: print (f"{x} adalah bilangan genap") else : print(f"{x} adalah bilangan ganjil") gangen(11) ''' ''' #Sebuah function calc def calc(): x = float(input('Masukan Angka 1...
003228d5f54f7f532609ef0a49adfe456c92d28a
rakesh-chan/Python
/DailyCode/HelloWorld/2.0_Print_Interactive.py
941
4.1875
4
#print with raw input print("Press 1: To print") print("Press 2: To combine two strings") print("Press 3: To print in sperate lines") print("Press 4: To print your entered string and digit") print("Press 5: To print multiple times") x = int(input()) if (x==1): print(input("Enter the string to combine : ")) elif...
0eedaf83efc4c1729352fd2f71be26ca2314657c
Rochan2001/data-science
/programs/ex2.py
495
4.125
4
""" Read the "churn.csv" data set and perform the following tasks 1.what is the average monthly charge paid by a customer for the services he/she has signed up for? 2.The data type of the variable tenure from the churn dataframe is expected output: average: 62.4734817814 tenure Data type: object """ import numpy as np ...
76378368317572e2a67f2dec0d2942ace7e9e839
raxxar1024/code_snippet
/leetcode 151-200/188. Best Time to Buy and Sell Stock IV.py
1,350
3.75
4
""" Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most k transactions. Note: You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). Credits: Special ...
8f9064f1d89314c2fa8689f68f2517194a5574fd
toxicthunder69/Assignment
/Basic exercises/MultProgram.py
143
4
4
number1=int(input("Enter no. 1: ")) number2=int(input("Enter no. 2: ")) print("The sum of ",number1,"x",number2," is:") print(number1*number2)
ac87b51260f0ddafb1a4bae952eb71db8e453ddd
harip/google-ml-course
/intro_to_pandas_1.py
746
3.828125
4
"""Google ML crash course learning exercises""" import pandas as pd import numpy as np CITY_NAMES = pd.Series(['San Francisco', 'San Jose', 'Sacramento']) POPULATION = pd.Series([852469, 1015785, 485199]) CITIES = pd.DataFrame({'City Name':CITY_NAMES, 'Population':POPULATION}) CITIES['Area square miles'] = pd.Series(...
f29663068e65691d68e2b368f061765a99914a3f
venkateshpitta/python-exercism
/acronym/acronym.py
109
3.578125
4
def abbreviate(given: str) -> str: return ''.join(w[0].upper() for w in given.replace('-', ' ').split())
be0e223930e4d8d244358b65cc5f2eb1aa0709af
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/344_Reverse_String.py
1,453
4.09375
4
""" Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. You may assume all the characters consist of printable ascii characters. Example 1: I...
0c034fbda4e1bd8afd099fcdd71c694d7960be3b
katel85/Labs-pands
/labsweek03/Lab3.2.1/convert.py
669
4
4
# program takes in a float amount in dollars and outputs abs amount in cent # Author Catherine Leddy # ref https://learnandlearn.com/python-programming/python-reference/python-abs-function # ref https://www.w3schools.com/python/python_datatypes.asp number = float(input("Enter a number:")) absoluteValue = abs(int(num...
1d3ce470259821bf35869c694651829ffdfd58b5
timm/duo
/etc/old/duo2/col.py
3,061
3.53125
4
#!/usr/bin/env python3 # vim: ts=2 sw=2 sts=2 et tw=81 fdm=indent: """ col.py : summarize streams of data (c) 2021, Tim Menzies, MIT license. https://choosealicense.com/licenses/mit/ USAGE ./col.py [OPTIONS] -t S run demo functions matching S -T run all demo functions -L list all demo...
cec0af2a9ad239e667fd0c83f27e925d6f8f774a
kali786516/PluralsightCourse1
/webapp/student.py
438
3.84375
4
students=[] '''self is like this in java''' class Student: school_name = "Springfield Elementary" def __init__(self,name, student_id=332): self.name=name self.student_id=student_id students.append(self) def __str__(self): return "Student " + self.name def get_name_...
0251f8827a3ba22b3d130526079a3a88c21732fa
kljoshi/Python
/Exercise/Chapter5/List_to_dictonary_function.py
1,508
4.03125
4
# function to add items into dictionary if it doesnt exist else increment the counter value # if the item exists. def addToInventory(inventory, addedItems): # loop through items in the dragonLoot, which is a list for item in addedItems: # condition to check if item in the dragonLoost already exists ...
e92f4611329f311a5f42666c084cad617386f336
tiedye93/Python--COT4930
/lab01/tbourque2012_lab01.py
285
4.0625
4
# COT 4930 Python Programming # Tyler Bourque # tbourque2012 # Lab : 01 def convertMiles( miles ): kilo = miles * 1.609 print( miles, "Miles is", kilo, "in Kilometers." ) userInput = eval( input( "type in a number to convert Miles to Kilometers: " ) ) convertMiles( userInput )
a6a1b4a058f141da2d7780e2213fe03bd3f668bf
tiggers1985/python-learning
/oop_advance/use_super.py
5,445
4.34375
4
#!/usr/local/bin python3 # -*- coding: utf-8 -*- '''super() method usage samples https://realpython.com/python-super/ ''' #------------------------------------------------------------------------------------------------------------------------- #super() returns a delegate object to a parent class, so you call th...
3969c8a0714a259558e48badac630213e4323b55
YesterdayxD/interesting_idea
/leetcode/257_binary_tree_paths.py
683
4.03125
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def previous(node): print(node.val) if node.left != None: previous(node.left) if node.right != None: previous(node.right) class ...
363ee29780ffa05bcb1051b9126960acafef02d7
msaqib/DBRO
/PostgreSQL Code/tweet_length.py
2,244
3.5
4
import psycopg2 import csv import math #from math import filename='/home/faban/Downloads/TestJava/tweets.csv' with open (filename,'rU') as csvfile: csv_data=csv.reader(csvfile) csv_data2=csv.reader(csvfile) #csv_data = csv.reader(file('/home/faban/Python-Postgresql/Crime.csv')) # database = psycopg2.connect (host=...
ca2fe1e09d07428093ba36fd91c40ad3c3275744
merry-hyelyn/Programmers_weekly_challenge
/Week4/answer.py
982
3.65625
4
def make_language_preference_table(languages, preference): table = {} for i in range(len(languages)): table[languages[i]] = preference[i] return table def solution(table, languages, preference): answer = '' languages_preference = make_language_preference_table(languages, preference) '''...
423c902a4d481c40d11eacf7c06e0b976f260a30
aryandosaj/ScienceCanvasProjects
/Project-4/Straightline.py
733
3.59375
4
import matplotlib.pyplot as plt x = [1,2,3,4,5,6,7,8] y = [53807,55217,55209,55415,63100,63206,63761,65766] c = 50000 m = 100 n = float(len(x)) alpha1 = 0.0001 alpha2 = 0.0001 def update(): der_c = 0 der_m = 0 global c,m,alpha,n for (i,j) in zip(x,y): der_m =der_m + i*(m*i + c - j) der_...
74d3ba1f53b07993c228c9b5c27df6ee4589fe7b
simonxu14/LeetCode_Simon
/257.Binary Tree Paths/Solution.py
966
3.828125
4
__author__ = 'Simon' # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def binaryTreePaths(self, root): """ :type root: TreeNode :rtype: List[str] ...
5078992d6df9125828dec5c78e8557765f7f8162
daniel-reich/ubiquitous-fiesta
/YA5sLYuTzQpWLF8xP_3.py
142
3.59375
4
def clean_up_list(lst): even = [i for i in map(int, lst) if i%2 == 0] odd = [i for i in map(int, lst) if i%2 == 1] return [even, odd]
2f38acd2c899f6a0cd7d840b75b18abb88f0136a
bryanyaggi/Coursera-Algorithms
/course2/pa1.py
5,022
3.859375
4
#!/usr/bin/env python3 import sys import threading import time # Hitting limits if the following are not modified sys.setrecursionlimit(800000) threading.stack_size(67108864) ''' Programming Assignment 1 Download the following text file: SCC.txt The file contains the edges of a directed graph. Vertices are labeled...
5852cb7f842079eecce9403c5d09f2ba09bdab3d
ectom/Coding-Dojo-Python-Stack
/1 - python_fundamentals/hello_world.py
363
3.65625
4
words = "It's thanksgiving day. It's my birthday,too!" x = [2,54,-2,7,12,98] y = ["hello",2,54,-2,7,12,98,"world"] z = [19,2,54,-2,7,12,98,32,10,-3,6] print words.find('day') print words.replace('day','month') print min(x) print max(x) print y[0] print y[len(y)-1] a = [y[0], y[len(y)-1]] print a z.sort() b = len(z)/2 ...
e4c59b39baefb1052f6bd7d848e1d37ab92fe2bb
alikslee/Python-itheima-2019
/01-Python核心编程/代码/04-数据序列/04-字典/hm_08_字典的遍历之键值对.py
97
3.84375
4
dict1 = {'name': 'TOM', 'age': 20, 'gender': '男'} for item in dict1.items(): print(item)
9bb5edb135c6ba83995bd29369d70dad615e76ad
Saiden125/demo_py
/age_matome.py
361
3.75
4
text = input('年齢入力') if text.isdigit(): age = int(text) if age < 20: if 0 <= age < 6: print('未成年(幼児)') elif age >= 6 and age <= 15: print('未成年(義務教育期間)') else: print('未成年') elif age < 65: print('成人') else: print('高齢者')
a6687917f41c88d7a0bbbad272878f497be77caf
richherr/richherr.github.io
/data8/_build/jupyter_execute/chapters/05/1/Arrays.py
6,106
3.84375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: from datascience import * path_data = '../../../assets/data/' # # Arrays # # While there are many kinds of collections in Python, we will work primarily with arrays in this class. We've already seen that the `make_array` function can be used to create arrays of numbe...
ca92f3ebe4bfc73271d75dcf004b0d8a881e12c8
CalebBorwick/CS-1026
/Textbook/Chapter 6/6.2 List Operations.py
1,189
4.34375
4
#adding elements to a list family = [] family.append('Hayden') family.append('Nicole') family.append('Bruce') family.append('Lauren') family.append('Sparky') print(family[4]) #adding in a specific loction family.insert(5,'Merlin') print(family[5]) #Finding an element if 'Nicole' in family : print('She is my mothe...
7de765f684317a31ec1dafac117b353cbc6f9577
FordTang/ICS32_ProgrammingSoftwareLibraries
/Project4/Project4.py
7,803
3.84375
4
# Ford Tang / 46564602 # Project #4: The Width of a Circle (Part 1) # Project4.py # This is the main file for Project 4 that will create an othello game on the console. import Othello import othello_ai def play_game() -> None: """ This function runs the othello game on the console. :rtype : None "...
1c502406600a191106569a8945ea6ca3bbe2133d
Geeksten/guessing-game
/guessing_game.py
1,247
4.03125
4
import random prior_guesses = [] #use snakecase for python guess_found = 0 guesses_taken = 0 number = random.randint(1, 100) username = raw_input("Hi there! What is your name? ") print "%s I'm thinking of a number from 1-100. Try to guess my number!" % username while guess_found < 1: guess = raw_input('Please tak...
89f340cac84f6037a5b75393940de0d12ac258bc
emblu3/Sorter
/sorter/Sorter.py
3,945
3.984375
4
# How many items to rank def inputNumber(message): while True: try: user_input = int(input(message)) if user_input < 2: print('Please enter 2 or more.') continue except ValueError: print("Please enter a whole number.") continue else: return ...
ec7f43bb91161ec2dbf875cd92d0e262bf907185
HongyuS/Vegetable-Market
/CSC1001/Assignment_2/q3.py
1,092
4
4
# Return true if the card number is valid def isValid(number): _sum = sumOfDoubleEvenPlace(number) + sumOfOddPlace(number) if _sum % 10 == 0: return True else: return False # Get the result from Step 2 def sumOfDoubleEvenPlace(number): _sum = 0 for i in range(2, len(number)+1, 2): ...
99f806453e8894fd7060761c947371e984a967e5
Xnaivety/pat
/pat(advanced)python/1022(advanced)need_to_fix.py
2,343
3.609375
4
class book(): def __init__(self, seven_digit_id_number, book_title, author, key_words, publisher, published_year): self.seven_digit_id_number = seven_digit_id_number self.book_title = book_title self.author = author self.key_words = key_words self.publisher = publisher ...
7bc9162ba10295da568377e2328a2bd0313539c4
PansulBhatt/NeuralNetworks
/exercise_3.py
4,041
4.15625
4
# Keras uses the Sequential model for linear stacking of layers. # That is, creating a neural network is as easy as (later) # defining the layers! from tensorflow.keras.models import Sequential # Everything we've talked about in class so far is referred to in # Keras as a "dense" connection between layers, where every ...
c95ebc785e5e95fa790ed88e19b06686fbdde881
DimpleOrg/PythonRepository
/Python Crash Course/vAnil/Chapter-5/5-5.py
1,028
3.796875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 4 18:20:08 2021 @author: ANIL """ alien_color = 'green' if alien_color == 'green': print('The player just earned 5 points for shooting the alien.') elif alien_color == 'yellow': print('The player just earned 10 points.') elif alien_color == 'red': ...
bf7208591a93625b1b39989a3dda03e839a85567
Vincebye/CTF-Tools
/Decrypt-Caesar.py
496
4.0625
4
def encrypt(): pass def decrypt(key,str): decrypt_str='' for i in str: decrypt_words=ord(i)+key if decrypt_words>ord('Z'): decrypt_words=decrypt_words-26 decrypt_str=decrypt_str+chr(decrypt_words) return decrypt_str if __name__=="__main__": decrypt_list=[] s...
3f18980af9c0018b88966f07a81dcc2503160116
sunanth123/Genetic-Algorithm
/ga.py
4,143
4.03125
4
import random from Queue import PriorityQueue ##Sunanth Sakthivel ##CS541 Program 2 ##this program is a genetic algorithim that will find the solution to the knapsack problem. Note that the ##optimality of the solution will depend on the number of iterations and population size of the sample. MaxWeight = 100 ##max...
f811b9393ae59c9cd34d20aebb4c7f4ea367ea22
jbnicolai/code-eval
/240/main.py
190
3.703125
4
#!/usr/bin/env python3 import fileinput primes = [ 3, 7, 31, 127, 2047 ] for line in fileinput.input(): n = int(line) print(', '.join(str(prime) for prime in primes if prime < n))
5277434b6d85a5db1eef2bee0136ecdf9dac421b
ankitkundra/PythonGettingStarted
/if.py
275
4.0625
4
num1 = input("Enter first number") num2 = input("Enter second number") if num1 > num2: print("First number is greater than second number") elif num2 > num1: print("Second number is greater than first number") else: print("Both numbers are equal")
4208309dfccbc8af936e370140ded48d467638be
jocelinoFG017/IntroducaoAoPython
/01-Cursos/GeekUniversity/Seção06-Estruturas_Repetição/Exs_1_ao_21/S06_Ex17.py
271
4.0625
4
""" .17.Faça um programa que leia um número inteiro positivo N e calcule a soma dos N primeiros números naturais. """ n = int(input('Informe um numero: ')) soma = 0 for i in range(0, n+1): print(i) soma = soma + i print(f'soma de todos os Nº pares = {soma}')
ee4f6d83ea9242846e641e3a4de954dffccd6553
lukasbystricky/ISC-3313
/lectures/chapter6/code/Fraction.py
1,632
3.625
4
from gcd import gcd class Fraction: def __init__(self, numerator = 1, denominator = 1): if denominator == 0: self._top = 0 self._bottom = 0 else: factor = gcd(abs(numerator), abs(denominator)) if denominator < 0: ...
823fdd45a182f150332def0624a36e73d341505b
lemonzoe/python_origin
/d1/class2.py
810
4.46875
4
movies=[ "the holy grail",1975,"terry jones&terry gilliam",91, ["graham chapman", ["michael palin","john cleese","terry gilliam","eric idle","terry jones"]]] print(movies[4][1][3]) print(movies) for each_item in movies: print(each_item) # 显示嵌套列表 for each_item in movies: if isinstance(...
5e34b40d139e3ff6a730b1f33002792527401c41
ramit29/Algorithms-Rosalind
/bfs.py
356
3.84375
4
#!/usr/bin/env python3 #requires graph represented as an adjacency list def bfs(adlist,start): visited=[] queue=[start] while queue: vertex=queue.pop(0) if vertex not in visited: visited.append(vertex) edges=adlist[vertex] for i in edges: ...
8c1e38086ced083b43e3d4f3a9f16585ebd7d566
Nibroo/PythonBootcamp
/whileColt/functions.py
3,379
4.03125
4
def product(a,b): return a*b print(product(5,6)) #*------------------------------------------- days = ['None','Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] def return_day(num): if 1 <= num <= 7: return days[num] return None print(return_day(5)) print(return_day(10...
5c18ce38e2c5cbe6e3ef0de775a3ecdc95cde468
99ashr/PyCode
/Infytq/Ass22.py
678
4.3125
4
#!/use/bin/python3 def find_leap_years(given_year): """A python Program to find a list of next 15 leap years""" list_of_leap_years=[] while len(list_of_leap_years)<15: if given_year%4==0: if given_year%100==0: if given_year%400==0: list_of_leap_years....
32f3c552360bb86f5a3217e376f107c31b5e60b3
BadrChoujai/hacker-rank-solutions
/Python/04_Sets/Symmetric Difference.py
355
3.65625
4
# Problem Link: https://www.hackerrank.com/challenges/symmetric-difference/problem # -------------------------------------------------------------------------------- a = int(input()) m = set(map(int, input().split())) b = int(input()) n = set(map(int, input().split())) c = m.difference(n) d = n.difference(m) e = c.u...
89d59517290c85e07289d8d2173b9e4e0cf1f3d7
ddot159/Python_Hw
/calculator.py
1,486
4.4375
4
def calculator(number1, number2, operator): """ Calculator uses the following operators on numbers 1 and 2: addition (+), subtraction(-), multiplication(*) division(/), integer division (//) power(**) operation If the operator is invalid, the program exits """ outp...
126cbccf3efd4bd0f969aae2539a383154d5b7be
hoybyte/python
/ZeroToMastery/catseverywhere.py
562
4.3125
4
class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age def get_oldest_cat(*args): return max(args) Cat1 = Cat('Cat1', 2) Cat2 = Cat('Cat2', 3) Cat3 = Cat('Cujo', 4) print(Cat1) print(Cat2) print(Cat3) print(f"The oldest cat is {get_oldest_cat(Cat1.a...
e9be765e21c3437eb561b09c4403079b78892c04
daniel-vv/ops
/S12/day1/string_format.py
374
3.59375
4
#!/usr/bin/env python # coding:utf-8 name = input("name:") age = input("age:") job = input("job:") #print("Information of []: \nName:["+ name +"]\nAge:["+ age +"]\nJob:["+ job +"]") #print("Information of []: \nName:[%s] \nAge:[%s] \nJob:[%s]" %(name,age,job)) msg = ''' Information of: Name:[%s] A...
16f23dd4c52d9c484c5f7688c2ca783ee87eb2bf
arovit/Coding-practise
/practise/dropbox.py
583
4.09375
4
#!/usr/bin/python # binary search def binary(startindex, endindex, elements, target): if startindex > endindex: return False middleindex = (endindex + startindex)/2 if elements[middle] > target: return binary(middleindex, endindex, elements, target) elif elements[middle] < target: ...
25873344a59a020a20271546ceb8840d862e29a7
zhanghaipeng-alt/demo-python
/ck01/Demo/元组列表.py
3,268
3.515625
4
# 元组:值不能改变。 # 定义方式 a = (1,2,3) # t = (2, 5, 6, 2, 8, 0, 54, 32, 'a', 8.9, '中国') # # 分片 # print(t[2:12:1]) # # # 倒序 # print(t[::-1]) # # # 索引 # print(t.index('中国')) # # # 计数 元素出现的次数 # print(t.count(2)) data = ((1,'张三',4500.00),(2,'李四',7800.00),(3,'小黑',3599.00)) #循环打印所有员工信息 # for i in data: # for j in i: # p...
9286b7aee24767905921149295773769ed7e6643
hakosaj/PygameAI
/snake/snek.py
3,172
3.71875
4
import sys import os import random import time import pygame import math from constants import * from pygame.locals import * from grid import * class Snek: def __init__(self, x, y, gr): """Initialize the snake Args: x (int): start position y (int): start position y ...
28385b5c373d0d8fa55a2bbf4138db807b508457
Janis90/snlp
/Project/implementation/Word.py
7,213
4.03125
4
import numpy as np class Word(): """The Word class represents simple words consisting of a prefix, a stem and a suffix """ def __init__(self, prefix, stem, suffix): """Creates a Word object out of the given parameters. To split up a string into prefix, stem and suffix, use a splitting alg...
8dabcfc69f0676da9dd1828d99c19c69c79c4cd7
hellicott/hangman
/word.py
1,184
3.84375
4
import random from alphabet import Alphabet class Word(object): possible_words = ['quack', 'aardvark', 'rhythm'] def __init__(self, alphabet: Alphabet): self.word_to_guess = self.pick_word() self.alphabet = alphabet def pick_word(self): return random.choice(self.p...
12348f3f5d28eae3709395ed29d90be217e4ea6d
DilLip-Chowdary-Codes/100DaysOfCode
/Python/Loops/print_Chars_in_a_Word.py
190
3.65625
4
#25 """ __author__ = DilLip_Chowdary ❤️ Rayapati """ a = input() counter = 0 length_of_a = len(a) while counter < (length_of_a): print(a[counter]) counter = (counter + 1)
41be49e4cdd1c99d77e0d9cdcf54f47f42a16130
RossMcKay1975/Python_Day2
/generators.py
234
3.8125
4
# numbers = range(11) # # for number in numbers: # print(number) def generate_evens(n): i = 0 while i < n: if i % 2 == 0: yield i i += 1 for number in generate_evens(10): print(number)
ed46b1526ec191f1f9dfb88efbeb2f4e58773d98
Aasthaengg/IBMdataset
/Python_codes/p02722/s439672872.py
394
3.5
4
import numpy as np N = int(input()) def divisor(N): x = np.arange(1, int(N**(1/2))+1, dtype=np.int64) div = set(x[N % x == 0]) return div | set(N // x for x in div) cand = divisor(N) | divisor(N - 1) def test(N, K): if K == 1: return False while N % K == 0: N //= K ...
4ed10deca016d883ce5d1c86bb9bdbdeb6801267
SACHSTech/ics2o1-livehack-2-keira-h
/problem1.py
880
4.40625
4
""" ---------------------------------------------------------- Name: problem1.py Purpose: Write a program that tells the user whether they are over or under the given speed limit. If they are over the speed limit, they will be given a fine. Author: Hosey.K Created: date in 23/02/2021 -----------------------------...
4d35019f85a173fba6e120586a4d1779a4638ed2
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/allergies/25c039a0d30246abbf53c79ea832b51a.py
472
3.75
4
class Allergies(object): def __init__(self, score): self.score = score self.check_allergies() def check_allergies(self): self.list = [] possible = "eggs peanuts shellfish strawberries tomatoes chocolate pollen cats".split() results = bin(self.score)[:1:-1].ljust(8,'0') for i in range(len(possible)):...
052051d8aefac964409a0547d5e6bc521f003fa0
IlshatVEVO/Data-Analys-Labs
/LAB5/6.py
317
3.78125
4
#Дана случайная матрица. Вычтите среднее значение для каждой строки матрицы. import numpy as np a = np.random.randint(10, size=(5,5)) print(a) sum = int(0) for i in range(len(a)): for j in range(len(a)): sum +=a[i][j] print(sum/len(a))
9a5ba184f874c11a9aa8305aed961603b96a2afc
gurvkm/placement
/make_matrix_zero.py
963
3.640625
4
import numpy as np #define the array arr arr=np.array([[0,4,1,0], [3,2,1,5], [1,0,7,2]]) row,col=np.shape(arr) #create flags for row and column first_row=bool(0) first_col=bool(0) #step1: if 0 present in any col or row make entire col or row 0 for i in range(row): if arr[i...
9f5dd915ab9cf7dacb8f93be4262ad1702afaa6a
simonsben/intent_detection
/utilities/pre_processing/process.py
2,562
3.5
4
from multiprocessing import Pool from pandas import DataFrame, read_csv from functools import partial from config import n_threads def apply_process(packed_data, processes, get_content, save_content): """ Applies the pre-processing filters to a document :param packed_data: a tuple of document ind...
d44dbf980fe2867be0269a0b94113da186c8ccc4
arpitiiitv/PythoN-From-P-to-N
/AH_set.py
294
3.609375
4
s=set() print(type(s)) s1=set([1,3,4,5,6]) print(s1) s2=set([12,1,3,44,10]) print(s2) s1.add(312) print(s1) ################## x=s1.union(s2) print('Union ',x) y=s1.intersection(s2) print("intersection ",y) print("is disjoint ",s1.isdisjoint(s2)) #length of set print(len(y))
6ebf6b111608ce472bcd90e95544beca4aecbe8a
korneyrodionov/pythonbook
/тест эрудит.py
2,139
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def check_guess(guess, answer): global score still_guessing = True attempt = 0 while still_guessing and attempt < 2: if guess.lower() == answer.lower(): print('Ответ верный') score = score + 2 - attempt still_gue...
39a1ef67fbb24e72dde348950eeb09c63a5fd4f1
3-clique/Elements-of-Programming-Interviews-Problems
/6.1.py
1,739
3.84375
4
def swap(A, dest, src): temp = A[dest] A[dest] = A[src] A[src] = temp return def dutch_flag_partition (A, pivotIndex): """ Given an array of ints and a pivot index, partition A such that - all elements of A < A[pivot_index] are at the begining - all elements of A < A[pivot_index] a...
7d1ba2aa5c36f221c7592888192ea15ca6fd6a17
KotRom/pythonProject1
/New folder/023_flask/003_http_methods.py
1,097
3.71875
4
from flask import Flask, redirect, url_for, render_template, request # request is used to get information from forms app = Flask(__name__) ''' Files needed: base2.html home2.html login.html ''' # First let's check what is GET and POST # Run app, try refreshing, look in command line # 127.0.0.1 - - [05/M...
700eb0990b3bca024730b9d825f3e1377f05d8c0
petitefille/Python
/innlevering/Cubic_Poly4.py
1,987
3.890625
4
class Line: def __init__(self, c0, c1): self.c0 = c0 self.c1 = c1 def __call__(self, x): y_Line = self.c0+ self.c1*x print 'Line: %.3f' % (y_Line) return self.c0+ self.c1*x def table(self, L, R, n): """Return a table with n points for L ...
0f2fd29c8c52ee79a3eb1d635f241e0a6b33ff85
mc0e/morphio-Australian_Election_Dates
/scraper.py
1,172
3.609375
4
# Closely based on a template for a Python scraper from morph.io (https://morph.io) import scraperwiki import lxml.html # # Read in page data html = scraperwiki.scrape("http://www.aec.gov.au/Elections/Australian_Electoral_History/Federal_State_and_Territory_elections_dates_1946_Present.htm") # # # Find something on th...
7cbe8b80f4162ce202585375500a2c1624a4970f
grickoff/GeekBrains_5HW
/1.py
555
4.21875
4
# Создать программно файл в текстовом формате, записать в него построчно # данные, вводимые пользователем.Об окончании ввода данных свидетельствует пустая строка. f = open('HW1.txt', 'w') write = [] while write != (''): write = input('Вводите построчно данные или оставьте поле ввода пустым для завершения: ') f...
aee865f308adb873b32abfe59a307e996cc357d4
Rodelph/VideoManager
/depth.py
1,440
3.671875
4
import numpy as np """ To identify outliers in the disparity map, we first find the median using np.median which takes an array as an argument. If the array is of an odd length, median returns the value that would lie i nthe middle of the array if the array were sorted. If the arrray is of an even length, median retur...
f20bf01193c7e4bc7478bd196b3a41a1576dfbc5
tanishq-dubey/Tobias
/TobiasPyFiles/enemies.py
1,156
3.765625
4
class Enemy(object): def __init__(self, name, description, hp, ap, damage): self.name = name self.description = description self.hp = hp self.ap = ap self.damage = damage def __str__(self): return "{}:\n{}\nHealth: {}\t Armor: {}\n".format(self.name, self.descrip...
3e1f29c50d71853d0aa41b435a1e8e8506d5447f
douzujun/LeetCode
/py74_290_wordPattern.py
515
3.5625
4
# -*- coding: utf-8 -*- class Solution: def wordPattern(self, pattern: str, str1: str) -> bool: pli = list(pattern) sli = str1.split() plen = len(pli) slen = len(sli) if plen != slen: return False for i in range(slen): if pli.index(...
b1c863166fcc509a61ec6e7df70babc7d5e2e3e4
kiryeong/python_basic_study
/Quiz2.py
2,377
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 9 22:23:53 2020 @author: SAMSUNG """ sentence = '나는 소년입니다' print(sentence) sentence2 = "파이썬은 쉬워요" print(sentence2) sentence3 = """ 나는 소년이고, 파이썬은 쉬워요 """ print(sentence3) jumin = "990120-1234567" print("성별: " + jumin[7]) print("연: " + jumin[0:2])...
9f8c069d48276bc36604e24dca5557f3945e1e1b
VictorCavichioli/Julius
/2) Backend/Conversor.py
807
3.609375
4
from currency_converter import CurrencyConverter from config import sai_som def Conversor_Moedas(): c = CurrencyConverter() sai_som(''' Para realizar a conversão, use os seguintes códigos: ''') print(''' 'EUR' - para Euros; 'CAD' - para dólar Canadense; ...
b61fb26a16d1e8af91a97d2c15eb0d1194062738
ayushchauhan09/Mini
/Projects/Guessing_Game.py
533
3.75
4
import random winning_number=random.randint(1,100) guess=1 guessed_number=int(input()) game_over=False while not game_over: if winning_number==guessed_number: print(f"\U0001F973 Congrats! You Won! And You Guessed This Number In {guess} Attempts!!!") game_over=True else: if winn...
70ff0d816f6ac74fee122e8f48559a66b87e7e9d
oliverschwartz/leet
/ctci/bit_string.py
123
3.5625
4
def bitString(n): s = '' for i in range(31, -1, -1): s += '1' if ((1 << i) & n) != 0 else '0' return s
be23afe8dfce2cbe87833da8cdacc9632e8b2409
syurskyi/Python_Topics
/115_testing/examples/Github/_Level_1/UnitTesting-master/Proj4/ListsAndTuples/listAndTuples.py
2,223
4.03125
4
import sys import timeit # https://www.youtube.com/watch?v=NI26dqhs2Rk # Tuple is a smaller faster alternative to a list # List contains a sequence of data surrounded by brackets # Tuple contains a squence of data surrounded by parenthesis """ Lists can have data added, removed, or changed Tuples cannot change. Tu...
ec5b83e634b38c0b62c7d4ade8382bfdc5559775
rayjustinhuang/CS175
/isSigmaAlgebra (Final).py
2,591
3.90625
4
# CS 175: Topics in Computational Science - Probability and Stochastics # Assignment: Program to check if a set of sets is a sigma-algebra (of some given universal set) def is_sigma_algebra(space, sets): """ This function checks if a given set of sets is a sigma-algebra of a given sample space ("universal se...
89e4fc713e5f324269f58e4b4ec13ccfdd772174
yaominzh/CodeLrn2019
/boboleetcode/Play-Leetcode-master/0064-Minimum-Path-Sum/py-0064/Solution3.py
860
3.5625
4
# Source : https://leetcode.com/problems/minimum-path-sum/ # Author : penpenps # Time : 2019-07-10 from typing import List # Use single list to keep accumulate dp result # Time Complexity: O(n*m) # Space Complexity: O(n) class Solution: def minPathSum(self, grid: List[List[int]]) -> int: if not grid or ...