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
97c3e135a02fc6bdb2e72e7df56e8e5d20e886a0
Macsito-prog/python_test
/main.py
2,419
3.6875
4
import random print("Bienvenido") print("Seleccione una opción") print("1.- Dados") print("2.- ATM") print("3.- Salir") opcInicio = input("") opc = int(opcInicio) ## funciones def func_ATM(usuario): print("Bienvenido "+usuario) print("Seleccione qué quiere hacer") print("1.- Cargar...
0b32e6ada7958f6eafcc5dd7035747aab90eeb43
xellmann/geography_quiz
/main.py
475
3.84375
4
from functions import * capitals = load_capitals() capitals_items = capitals.items() answer_list = game_data(capital_data=capitals) randomcity = answer_list[0] correct_capital = answer_list[1] while True: print("What is the capital of {0}?".format(str(list(list(capitals_items)[randomcity])[0]))) answer = in...
7da4fa2f89f95532f15bf6e442d8d83af17f3bb4
XanderEagle/unit6
/unit6.py
1,349
4.3125
4
# by Xander Eagle # November 6, 2019 # this program displays the Birthday Paradox showing the percent of people that have the sme birthday based on the # amount of simulations import random def are_duplicates(nums): """finds the duplicates :return: true if there is a duplicate false if no duplica...
c907b22818cfa855268f1dc565dc688dd77dcf60
Trietptm-on-Coding-Algorithms/arm_simulator
/pipeline.py
1,142
3.5
4
# This class is as good as a list data structure with some restrictions. # A pipeline must be instanciated at the start of each simulation. # Pipeline holds the instruction found in the text section sequentially # The program control can fetch required instruction by translating the # memory address in PC reg using t...
fe6dec85422036b090efd20e8cfe454aa523e414
saumil-jain/hackerearth-python
/hackerearth/com/hackerearth/basicprogramming/inputoutput/FindProduct.py
356
3.8125
4
# https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/find-product/ size = int(input()) input_array = input() input_array = input_array.split(' ', maxsplit=size) input_array = [int(i) for i in input_array] ans = 1 for i in input_array: ans = (a...
098816a9a74846cc3dde4d7c5537cf98907eb8ed
AKDavis96/Data22python
/Classes/Class.py
544
3.703125
4
class Dog: animal_kind = "Dolphin" # class variable def bark(self): # method (a function in a class) return "woof" # print(Dog().animal_kind) # print(Dog().bark()) with brackets you have instantiated it # print(Dog()) # print(Dog.bark) prints memory location Myles = Dog() Osc...
bfd6e98f6142eb53b9adae85fd34469c2c3b2cb4
AKDavis96/Data22python
/dictionary/forloop.py
190
3.84375
4
list_data = [1, 2, 3, 4, 5] for num in list_data: print(num*2) embedded_list = [[1,2,3], [4,5,6]] for data in embedded_list: print(data*2) for num in data: print(num*2)
a4d87e18be3ba024055d3d0a5a646a64e8240244
AKDavis96/Data22python
/variables/concat.py
562
3.953125
4
a = 2 b = 5.4 c = "How old are you? " print(c + "I am " + str(a) + str(b)) #converting to strings int_string = "6" print(type(int_string)) #converting to int print(type(int(int_string))) name = "dog" years = 7 height_cm = 60.2 print(f"{name} is {years} years old and {height_cm}cm tall") #f string pi = 3.141592653...
0655b98e3883961e58e18259bafd2686171a0e52
AKDavis96/Data22python
/libraries/car class.py
1,264
4.0625
4
# brake # acceleration, seconds # max_speed # bhp # deccelleration class Car: def __init__(self, max_speed): self.speed = 0 self.max_speed = max_speed self.car_started = "off" def car_start(self, on_or_off): self.car_started = on_or_off if self.car_started == "off": ...
3a119099113d1c26986b7a025cd2617d930d026f
AKDavis96/Data22python
/Advent of code/eulerQ7.py
458
3.953125
4
import math prime_numbers = [2] not_prime = [1] y = 3 def is_prime(x): for n in range(2, math.floor(x ** 0.5) + 1): if x % n == 0: return False return True def nth_prime(p): y = 3 while len(prime_numbers) < p: if is_prime(y) is True: prime_numbers.append(y) ...
32987ed32590490213e03942681a381295999e80
weesiau/numberbases
/decoct.py
249
3.984375
4
def decimal_octal(dec): num = int(dec) octal = [] while (num > 0): rem = num % 8 octal.append(str(rem)) num = num // 8 octal.reverse() return(''.join(octal)) # main print(decimal_octal(95))
0e9274b008500de0a92e9560bc7b35692b9120ff
uefall/my_lc
/smallest-string-starting-from-leaf/smallest-string-starting-from-leaf.py
1,900
3.875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def update_path(self,root,cur_path): if not root: return # print('root',root.val...
eaf673e6c74cd6dd4d4aa7af3102bb307b555f83
anupshrestha11/python-training
/lists.py
362
3.984375
4
numbers = [2, 5, 1, 3, 8, 7, 10, 9, 4, 6] print(numbers) print(len(numbers)) print(numbers[1]) print(numbers.index(5)) numbers.sort() print(numbers) numbers.reverse() print(numbers) numbers.remove(5) print(numbers) numbers.append(5) print(numbers) numbers.pop() print(numbers) numbers.insert(1, 0) print(numbers) ...
ccc6812fc4dd9da0d9de02799765b53ccfd5116e
fooelliot/python
/python-base/03circulation/Dmeo1.py
590
3.734375
4
import copy class Person(): def __init__(self): self.__num = 12 self.__age = 23 def setNum(self, num): print("setNum---") self.__num = num def getNum(self): print("getNum---") return self.__num num = property(getNum, setNum) @property def age...
b21676782ba6dd1e3985da09dd78932cfbb45b1d
fooelliot/python
/python-base/03circulation/Demo3.py
1,233
3.546875
4
import time import timeit start_time = time.time() # // time = 185 # for a in range(0 ,1001): # for b in range(0 ,1001): # for c in range(0 ,1001): # if a + b + c == 1000 and a**2 + b**2 == c**2: # print("a,b,c:%d,%d,%d"%(a,b,c)) # end_time = time.time() # print("time:%d"%(end...
a9dcbc12e34e5a042c22ea486b0e5b18954ababc
shilpavijay/Pandas-and-Data-Analytics
/Intro.py
951
3.640625
4
import pandas as pd import matplotlib.pyplot as plt from matplotlib import style import numpy as np style.use('ggplot') stats = {'Day':[1,2,3,4,5,6], 'Visitors':[43,34,65,56,29,76], 'Bounce Rate':[65,67,78,65,45,52]} ######## Creating a Data Frame ########## df = pd.DataFrame(stats) ##...
0b3ba6aff99bee7ec5adfb7eb03fb494d128b6c5
xanxys/tools3d
/affine.py
7,010
3.546875
4
# coding=utf-8 """ affine: provides 2d and 3d rotation and translation library """ from __future__ import division import math import numpy as np class SE2(object): """ Lie Group SE(2): translation and rotation in plane T(x)=R(self.z)x+self.d """ def __init__(self, d, z): """ You should us...
bfd83c9b6c55427eaf814d9fa6456ee30c00a9bd
OnlyMason/Frog-Wars
/fireball.py
1,124
3.921875
4
import pygame """ The fireball sprite that will be drawn when the player shoots Attributes: x, y (int): the position of the fireball player (int): the player that shot the fireball """ class Fireball(pygame.sprite.Sprite): def __init__(self, player, x, y): """ :param player: the player tha...
2865d43f5210b945eadc07481a14436f34b3ad23
Mike7P/python-projects
/Guessing_game/guessing_game.py
1,147
4.125
4
print("Welcome to Kelly's Number Guessing Game!") print("I'm thinking of a number between 1 and 100.") attempts = 0 difficulty_choosing = False random_num = randint(1, 100) # print(f"Pssst, the correct answer is {random_num}") def guessing_func(guess, random_num): global attempts attempts -= 1 if guess == rando...
425c5d037bef2e1f3d1f9f05463778eba2646194
Mike7P/python-projects
/Pong-Python/main.py
1,138
3.734375
4
from turtle import Screen, Turtle from paddle import Paddle from ball import Ball from scoreboard import Scoreboard import time # player = input("Welcome to Pong! What's your name?: ") screen = Screen() screen.bgcolor("black") screen.setup(width=800, height=600) screen.title("Pong!") screen.tracer(0) paddleR = Paddle...
d7dd96224064d98e702d82a4b781989d265e0fcb
nathanhwyoung/code_wars_python
/find_the_parity_outlier.py
910
4.4375
4
# https://www.codewars.com/kata/5526fc09a1bbd946250002dc # You are given an array (which will have a length of at least 3, but could be very large) containing integers. # The array is either entirely comprised of odd integers or entirely comprised of even integers except for a # single integer N. Write a method that ...
35cd73c64bcef045c3fafb7f4e3966d37d315b9d
aditi411/fibonacci-numbers
/list.py
297
3.828125
4
l=[] n=int(input('enter how many list items : ')) if n<=0: print('Enter a valid number') else: for i in range(1,n+1): print('enter no ', i , ': ') x=int(input()) l.append(x) print(l) for i in l: if i>0: print(i)
3db71560286dc19cd4b1337ba78983485d56f057
Chopsaru/CS325-programs
/HW3_knapsack/knapsack.py
1,229
3.734375
4
import math values_list = [25, 20, 15, 40, 50] weights_list = [3, 2, 1, 4, 5] def knapsack(values, weights): n = len(weights) W = 15 #weight capacity opsubset = [] result = [[0 for w in range(W + 1)] for i in range(n)] # blank table for i in range(1, n): for w in range(1, W + 1): ...
e3a2a4b957a1db6d7c415b60c94d9441207e555a
pavankumarNama/PythonLearnig
/Ex_Files_Adv_Python/Exercise Files/04 Collections/deque_start.py
656
4.0625
4
# deque objects are like double-ended queues import collections import string def main(): # TODO: initialize a deque with lowercase letters alpha = collections.deque(string.ascii_lowercase) # TODO: deques support the len() function print(len(alpha)) # TODO: deques can be iterated over for a ...
74ad4278b47c70c03ec4f9439fcbc358708303bb
pavankumarNama/PythonLearnig
/Checkio/Home/SortArrayByElementFrequency.py
1,135
3.828125
4
from collections import Counter def frequency_sort(items): # your code here # Simple sort method in list # print(sorted(items, key=items.count, reverse=True)) items = sorted(items, key=lambda i: items.index(i)) # sorted(items, key=lambda x : items.count(x), reverse=True) print(items) # ...
78f52eed0d2426d52462b9467f6224ead214b4fb
pavankumarNama/PythonLearnig
/Ex_Files_Python_Standard_Library_EssT/Exercise Files/Chapter 5/05_01/datetime_start.py
810
4.34375
4
# Basics of dates and times from datetime import date, time, datetime # TODO: create a new date object tdate = date.today() print(tdate) # TODO: create a new time object t = time(15, 20, 20) print(t) # TODO: create a new datetime object dt = datetime.now() dt1 = datetime.today() print(dt) print(dt1) # TODO: access...
9d3e5efeed4958670366ec4b6c94bc3415ffc77b
pavankumarNama/PythonLearnig
/Ex_Files_Python_Standard_Library_EssT/Exercise Files/Chapter 3/03_02/tempfiles_start.py
1,281
3.640625
4
# Working with temporary files import os import tempfile # TODO: get information about the temp data environment # print('tempfile DIR: ', tempfile.gettempdir()) # print('tempfile prefix: ', tempfile.gettempprefix()) # TODO: create a temporary file using mkstemp() # (temposhandler, tempfp) = tempfile.mkstemp('.tmp',...
8f14328ebcd0f973846d5727f1824f1a95793ac3
F7Villani/Python-Fundamentos
/Aula08_3-Lambda.py
387
3.78125
4
# Aula 08 Lambda contador_letras = lambda lista: [len(x) for x in lista] lista = ['cachorro', 'gato', 'elefante'] print(contador_letras(lista)) soma = lambda a,b: a+b print(soma(5,10)) calculadora = { 'soma': lambda a,b: a+b, 'subtracao': lambda a,b: a-b, 'multiplicacao': lambda a,b: a*b, 'divisa...
cb40054ebfc4d76a3e13bafdb9420c88531da284
sidtiwari98/Fibonacci-no.-algo-and-time-complexity-graph
/q1_graph.py
468
3.640625
4
import math import numpy as np import matplotlib.pyplot as plt import time list_time = [] a = np.arange(1,30,1) def time1(n): start = time.time() y = F1(n) end = time.time() temp = end-start list_time.append(temp) def F1(n): if (n <= 2): return 1 else: return (F1(n-1) + ...
da07296f30030b450f9b1a3d754c4e777138a946
cannibalcheeseburger/PyShitCodes
/LEETSPEAK/AdvancedLeet.py
579
4.125
4
dic = {"a":"4","b":"|3","c":"(","d":"|)","e":"3","f":"|=", "g":"9","h":"|-|","i":"!","j":"_|","k":"|<","l":"|_", "m":"/\\/\\","n":"|\\|","o":"0","p":"|D","q":"q", "r":"|2","s":"5","t":"7","u":"(_)","v":"\\/","w":"\\/\\/","x":"><", "y":"`/","z":"2"} inpoot = input("Enter String to conver...
717d00181d4ace298abed539757dc23b90d7193d
canberkeh/Python-SQL
/py_sql_operations.py
10,197
3.59375
4
''' You may need to change your localhost, root, databases''' from getpass import getpass import mysql.connector class Database(): '''Making some database operations.''' database_choice = { "1": "crypto", "2": "schooldb", "3": "mydatabase", "4": "sys" } def choices(self...
50cdca4c4255d11994cebc13554da9bb9ff631e6
Jecosine/python-couse
/grammar/function.py
206
3.921875
4
def calc(x): if x > 1: return 3 * x - 5 elif x < -1: return 5 * x + 3 else: return x + 2 if __name__ == "__main__": x = float(input("Input x:")) print(calc(x))
f660c604fabe4f59985b7c87f6104a9c9916dadc
Jecosine/python-couse
/cs8/cs8.py
3,466
3.6875
4
def display_board(b): print("\t{0}|{1}|{2}".format(b[0],b[1],b[2])) print("\t_|_|_") print("\t{0}|{1}|{2}".format(b[3],b[4],b[5])) print("\t_|_|_") print("\t{0}|{1}|{2}".format(b[6],b[7],b[8])) def legal_moves(board): moves = [] for i in range (9): if board[i] in list("012345678"): ...
7b1ff64ddc49479c7768267115f6f5a6f7f62bf5
Jecosine/python-couse
/mymodule.py
254
3.578125
4
# filename:mymodel.py def calc(numbers): sum = 0 for n in numbers: sum = sum + n * n return sum def myprint(mydata): for i in mydata: print(i) def factorial(n): if n == 1: return 1 return n*factorial(n-1)
6c506a5b929738c7bfe76797f93923041020f061
okeonwuka/PycharmProjects
/ProblemSolvingWithAlgorithmsAndDataStructures/Chapter_1_Introduction/pg29_selfcheck_practice.py
2,996
4.15625
4
import random # create alphabet characters including 'space' character alphabet_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' '] # create empty list to house character matches from target s...
389a05c08df9ec5693f272aa70ac40f3e67e28bb
okeonwuka/PycharmProjects
/ThinkPython/swampy-2.1.5/docStringTest.py
905
4.03125
4
# Doc string for Polygon, arc and circle from math import * from TurtleWorld import * # For some reason we need to initialise TurtleWorld() otherwise # error world = TurtleWorld() bob = Turtle() # Speed things up by reducing delay bob.delay = 0.1 def polygon(thing, lengthOfSide, numberOfSides): """ This f...
61862704038bbc482c3bfda8cdadd060301d3f7b
okeonwuka/PycharmProjects
/ProblemSolvingWithAlgorithmsAndDataStructures/Chapter_1_Introduction/pythonClassesPractice.py
588
4.03125
4
# Define class class Fraction: def __init__(self, top, bottom): self.num = top self.den = bottom def __str__(self): return str(self.num) + '/' + str(self.den) def __add__(self, other_fraction): new_num = self.num*other_fraction.den + other_fraction.num*self.den ne...
8c40de2b5d9cfbb59af3428537caac07ed102c99
okeonwuka/PycharmProjects
/Horizons/pythonPracticeNumpyArrays.py
1,687
4.40625
4
# The numpy module gives users access to numpy arrays and several computation tools. # Numpy arrays are list-like objects intended for computational use. from pprint import pprint import numpy as np my_array = np.array([1, 2, 3]) pprint(my_array) # Operations on a numpy array are made element by element (unlike fo...
1cc9d4e42948a5894720e5351f78e61a82e58c72
okeonwuka/PycharmProjects
/ProblemSolvingWithAlgorithmsAndDataStructures/Chapter_3_BasicDataStructures/LinkedList.py
545
3.53125
4
class Speed(object): def __init__(self, d, t): self.distance = d self.time = t return d * t # def getspeedInHours(self): # return # # tesla = Speed(300,100) class Node(object): def __init__(self, d, n=None): self.data = d self.next_node = n...
f81bacd959b0819966a3540f07837fc3ed164a1d
okeonwuka/PycharmProjects
/ThinkPython/swampy-2.1.5/alphabet.py
5,951
3.765625
4
# Exercise 4.4 # Standardize all letters to be drawn LEFT to RIGHT import math try: # see if Swampy is installed as a package from swampy.TurtleWorld import * except ImportError: # otherwise see if the modules are on the PYTHONPATH from TurtleWorld import * # Instantiate turtle world and turtle wo...
6883fc7502bd68bd86718c900c3c4ae2e8fbc8f9
asd3258/yzu_python_20210411
/day05/8_字典串列dict.py
432
3.984375
4
# John = key 50000 = value 數組 salary = {'John': 50000, 'Mary': 60000} print(salary) print('John的薪資:', salary['John']) for key in salary: print("%s 的薪資 %d" % (key, salary[key])) salary.setdefault('Bob', 70000) # 新增元素 print(salary) # 求薪資總和 print(type(salary['John'])) print(salary['John'] + salary['Mary'] + sala...
f58876d314b8e78ea7e0c548aca6a7a758c8b8a2
jahirmedinacs/cnn-project2
/project-container/cnn.py
3,633
3.640625
4
import matplotlib.pyplot as plt import keras from keras.models import Sequential from keras.layers import Dense, Conv2D, MaxPooling2D, Dropout, Flatten from keras.datasets import cifar10 ### Pseudo Macros PLOT = False VERBOSE = 0 NUM_OF_CLASS = 10 # CIFAR - 10 #### # The data, split between train and test sets:...
92e285b4a2ff1828a0cfec85280594e55c8ad52f
wp-lai/xpython
/code/threesum.py
1,029
3.9375
4
""" Task: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. >>> three_sum([-1, 0, 1, 2, -1, -4]) [[-1, -1, 2], [-1, 0, 1]] """ def three_sum(nums): result = [] nums = sorted(nums) for i ...
fa7839e158a42655a6bbdab05620c5fa0d1e7aa7
wp-lai/xpython
/code/kthlargest.py
922
4.21875
4
""" Task: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. >>> find_kth_largest([3, 2, 1, 5, 6, 4], 2) 5 """ from random import randint def find_kth_largest(nums, k): # find a random pivot length = len(nums) ...
d9b9b16d104861c8a11e487f108e0271178cdd39
wp-lai/xpython
/code/twosum.py
1,176
4.03125
4
""" Task: Given an array of integers, return indices of the two numbers such that they add up to a specific target. >>> two_sum([3, 2, 4], 6) [1, 2] >>> two_sum([2, 7, 11, 15], 9) [0, 1] >>> two_sum([0, 2, 3, 0], 0) [0, 3] """ # Solution 1: double loop def two_sum(nums, target): for i in range(len(nums))...
7d17cbaddef7f2dad0a85adad69a2d838c7f2936
wp-lai/xpython
/code/int2binary.py
1,431
4.1875
4
""" Task: Converting decimal numbers to binary numbers >>> convert_to_binary(25) '0b11001' >>> convert_to_binary(233) '0b11101001' >>> convert_to_binary(42) '0b101010' >>> convert_to_binary(0) '0b0' >>> convert_to_binary(1) '0b1' """ # Solution 1: # keep dividing by 2, store the remainder in a stack # read in re...
b6c98e606fc6437cfd748c5d42ebf2d8c4391807
wp-lai/xpython
/code/covering_segments.py
927
3.953125
4
""" Task: Given a set of n segments {[a0,b0],[a1,b1]....[an-1,bn-1]} with integer coordinates on a line, find the minimum number 'm' of points such that each segment contains at least one point .That is, find a set of integers X of the minimum size such that for any segment [ai,bi] there is a point...
8f9dcd1efbd0af630617a98328201e6402c6116a
XueningHe/Rosalind_Hidden_information_in_DNA
/HammingDistance.py
267
3.71875
4
def HammingDistance(x,y): distance=0 for i in range(len(x)): if x[i]!=y[i]: distance+=1 return distance f=open('dataset_9_3.txt','r') gene1=f.readline() gene2=f.readline() print(gene1) print(gene2) print(HammingDistance(gene1,gene2))
d49d2e9bee7312caa0d20b2e0b636e744c8cbbcd
gnrfan/python-ica-2014
/2014-02-23/bucles/simular_repeat_until.py
161
3.578125
4
# Simular un do-while # # i := 1; # repeat # print i; # i = i + 1 # until i>100; # i = 1 while True: print i i += 1 if i > 100: break
1f4801bc3e5d784839dca6f136ef9f69b5a65793
harpiechoise/Python-Database-Engine
/Utils/LinkedLists.py
6,930
3.765625
4
# Mi vision de como deberia ser la estructura básica # Del motor de Base de Datos # Estructura a conseguir # DB.locdb # Basado en JSON # [ # <nombre_tabla>: { # { # <id>: { # <campos>:<valores> # } # } # } # ] NODE_TYPE_ERROR = TypeError("The linked list only admits Node types objects") NODE_ASSERT_ERROR =...
b8a4990a2c343505fa0f89db71d75a9ae7affd60
MinecraftDawn/AE402
/class6/class6-2.py
605
3.625
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 18 14:05:51 2020 @author: eric """ class Animal: def __init__(self, HP): self.HP = HP def hurt(self, damage): self.HP -= damage print("剩下血量:" + str(self.HP)) class Dog(Animal): def __init__(self, HP): sup...
1169dfd4a0974b2cf83d112b13675179b171ea98
Sajjadakedavra/pythonFlaskClientApp
/hash.py
267
3.5
4
def adler32(text_in_string: str) -> int: ADLER_MOD = 65521 a = 1 b = 0 for char in text_in_string: a = (a + ord(char)) % ADLER_MOD b = (b + a) % ADLER_MOD #print(a) #print(b) return (b << 16) | a #print(adler32("hello"))
43f6a3c3a86ed57b37335121c515fc602f79d2d2
MohanPrakash32/beginer
/test 8.py
164
4.0625
4
Num = int(input("Please Enter any Num: ")) Count = 0 while(Num> 0): Num = Num // 10 Count = Count + 1 print("\n Num of Digits in a Given Num = %d" %Count)
60c80bedab546831f1f46a311df0b2cee377844a
Thiago7SPY/EstudosPython
/Maior3Numeros.py
365
4
4
a = int(input('Digite o primeiro número: ')) b = int(input('Digite o segundo número: ')) c = int(input('Digite o terceiro número: ')) if a > b and a > c: print ('O número %d é maior' %a) if b > a and b > c: print ('O número %d é maior' %b) if c > a and c > b: print ('O número %d é maior' %c) else: print...
30a1d1f8fa03962350e56b505a7100d322bccb88
Thiago7SPY/EstudosPython
/FatorialDe10.py
107
3.875
4
#Calcula o fatorial do número 10 fat = 1 n = 1 while n <= 10: fat = fat * n n = n + 1 print (fat)
7758caa3013cf04c124083a0b4db9e954f2c1a74
shaheerkhan199/python_assignment
/Assignment6/Question5.py
707
3.890625
4
class Car(): def __init__(self,car_name,car_model,car_color,car_speed,car_price): self.car_name = car_name self.car_model = car_model self.car_color = car_color self.car_speed = car_speed self.car_price = car_price def start(self): print("Car is now start") de...
30d5904478efa8ad1c368a130afd82cfb87423cb
lucaspassa/programacion-imperativa
/PythonIntroduction/lesson3/task7/len_function.py
240
3.546875
4
#CONTADOR de Caracteres de un String + substring + caracter de multiple linea phrase = """ It is a really long string triple-quoted strings are used to define multi-line strings """ first_half = phrase[0:(len(phrase)/2)] print(first_half)
8431ac931d7d55a8dec4a95c610150e5a30403d2
mijara/alma-buckets
/src/buckets.py
5,887
3.5
4
class Bucket(object): """ A Bucket is an object that collects alarms, and potentially displays useful information to STDOUT for Jenkins to parse. For each alarm that the searcher collects, this object cherry_pick method gets called with that alarm. """ # Guard format for bars. GUARD_FO...
88c31c64ae17dadcdaad02656b97dc9a92e89bc7
mehul29/abc_proteins
/Pattern_Search (3).py
3,652
3.578125
4
import sys import regex as re import os f= open("input.txt",'rw+') f1=open(output.txt,'a') number=raw_input("How many pattern: ") number=int(number) new_char = [] miss=[] check="" desc_next="" input_dist1=[] input_dist2=[] prod=1 """-----------------Taking-Input-Parameters-and-Patterns--------------""" for j in range(0...
ea7f35d103f3523a8d0b5417eeb9b3c21cfbafb4
sweeya99/Autumn-of-Automation
/umic training/python files/3.py
4,711
3.796875
4
from math import sqrt class Complex(object): def __init__(self, real, imag=0.0): self.real = real self.imag = imag def add (self, other): return Complex(self.real + other.real, self.imag + other.imag) def subtract (self, other): return Complex(self...
990a71081ed5164c5097cdcad390fc42068ea579
handsomeboy/CS446-3
/mp2/mp2/train_eval_model.py
4,159
3.734375
4
""" Train model and eval model helpers. """ from __future__ import print_function import sys import numpy as np from models.linear_regression import LinearRegression def train_model(processed_dataset, model, learning_rate=0.001, batch_size=64, num_steps=1000, shuffle=True): """Implements the train...
1a9ac35fdb9701912d49774e808c4af41703e2b2
benmazur/File_IO_Python_Database_program
/program2.2.py
6,616
4
4
# Stephen Buchanan, Benjamin Mazur, Section 20L, 10/12/13 # Program 2 # Program 6-13 #imporing libraries from cisc106_32 import* import random #Cosntants CHART = 'c' DELETE = 'd' FIND = 'f' INSERT = 'i' PRINT = 'p' READMERGE = 'r' QUERY = 'q' EXIT = 'e' FIRSTNAME = 0 LASTNAME = 1 SECTION = 2 GRADE = 3 MERGEDLIST = [...
840b85ac58a714eedb4d77e687441aba5933749c
spencerlheureux/riball
/riball_objects.py
1,392
3.953125
4
import math from random import randint from environment import Environment, EnvironmentItem class RiEnvironment(Environment): """ Ri Environment An example environment built specific to this example. """ class Ball(EnvironmentItem): """ Ball Represents a ball moving through the Environment. ...
b62fca9fe165e17ac30acac06b3d462973cd519d
lkora/IKEA-stock-checker
/bin/mailer.py
1,826
3.53125
4
import smtplib, ssl, getpass from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart def send_mail(sender, recipient, content): r"""Sends an E-Mail (sends content from sender to recipient). :param: `sender`: :pair:(:str:e-mail, :str:password) for the sender of the email. :par...
c65b02fc056b996dacd941e299fe558d47785d6d
erinnlebaron3/python
/partitionstr.py
2,573
4.78125
5
# partition function works in Python is it's going to look inside the string for whatever you pass in as the argument. # once it finds that it then partitions the entire string and separates it into three elements and so it is going to take python and it is going to be the first element. # whenever you call partiti...
dd552daf2cf44e1a08733c54e31204750afc4f43
erinnlebaron3/python
/List.py
2,563
4.875
5
# like an array. It is a collection of values and that collection can be added to. You can remove items. You can query elements inside of it. # Every time that you want a new database query what it's going to do is it's going to look at its set of data structures and it's going to go and it's going to put them in that....
5a8410116af9cd906f35761cfe66281605423b47
erinnlebaron3/python
/lineComments.py
701
3.625
4
# single line comments, inline comments, and multiline comments. # comments—a way to add additional context and documentation into your programs # I'm a single line comments # Single Line: # I'm a single line comment name = 'Kristine Hudgens' # TODO: Split into two variables print(name) """ Multi Line: Aenean...
9673ae62285d1caf5117a936bb1e05b7699a76a6
erinnlebaron3/python
/PackageProject.py
2,385
4.4375
4
# will help you on the entire course capstone project # Technically you have learned everything that you need to know in order to build out this project. # helps to be familiar with some of the libraries that can make your life a little bit easier and # make your code more straightforward to implement # web scrape...
077bbfec6567508594cadabda71238de6829b41c
erinnlebaron3/python
/NegativeIndexStr.py
777
4.15625
4
# In review the first value here is zero. The next one is one and it counts all the way up in successive values. # However if you want to get to the very back and you actually want to work backwards then we can work with negative index sentence = 'The quick brown fox jumped over the lazy dog' print(sentence[-1]) a...
3476001e15c24a54fa379573e8b315c00f571d14
erinnlebaron3/python
/python_import/libs/helper.py
592
3.5
4
# just function with new file made in terminal # all in python terminal without print def greeting(first, last): return f'Hi {first} {last}' # >>> import helper # >>> helper.greeting('Erinn', 'LeBaron') # 'Hi Erinn LeBaron' # >>> # # also works with just putting print # def greeting(first, last): # return ...
ad51a4b6182415c29a404f0457b9d168f2ced94d
erinnlebaron3/python
/decimalVSfloat.py
2,791
4.46875
4
# in python all decimals are floating numbers unless decimal is called # you can create a decimal is to copy decimal it has to be all like this with it titled with the capital D and decimal spelled out and then because it's a # function we're going to call decimal. # when it comes to anything that is finance related o...
4fcd050807e486bc67e4448dadf1609114c67e86
erinnlebaron3/python
/WeightedLotto.py
2,020
4.09375
4
# weighted lottery function is Kind of a, not a predetermined amount because the system has to be random, but it wins a majority of the time. # in game senario # input is: is a dictionary. # output is: should be a string that should return in this case winning, break_even, or losing, and it should do it in the rig...
f3566a6b295b511718e3fac82156d6bad58b52a0
erinnlebaron3/python
/FuncConfigFallBck.py
1,356
4.40625
4
# syntax for doing is by performing something like this where I say teams and then put in the name of the key and then that is going to perform the query. # want to have a featured team so I can say featured team store this in a variable. teams = { "astros": ["Altuve", "Correa", "Bregman"], "angels": ["Trout", "...
8c042a8af371b41b874d514234fb6478e1fd0b19
erinnlebaron3/python
/CondFullList.py
984
4.09375
4
# comparison operators. # List of comparison operators # == Equality # != Inequality # <> Inequality (deprecated) # > Greater than # >= Greater than or equal to # <= Less than # <= Less than or equal to != Inequality username = 'jonsnow' if username != 'jonsnow': print('welcome') else: print('You shall not pass...
023d47ee8dced82d994b1660c359715d72761482
erinnlebaron3/python
/lenNegIndex.py
1,462
4.46875
4
# LENGTH # the length function and it's actually called the L E N which is short for length # this is going to give you the count for the full number of elements in a list # there is a difference between length and index # LENGTH # remember the counter starts and the index starts at 0. # even though we have four el...
6a88efb4a656dfda208f49f561d287175734e755
erinnlebaron3/python
/FilesinPy.py/Create&WriteFile.py
1,659
4.625
5
# very common use case for working with the files system is to log values # gonna see how we can create a file, and then add it to it. # create a variable here where I'm going to open up a file. # I'm going to show you here in the console that if I type ls, you can see we do not have a file called logger. # functi...
0ae57c234dc5a9daa688426e8c4953980f510f65
erinnlebaron3/python
/Slice2StoreSlice.py
2,968
4.78125
5
# here are times where you may not know or you may not want to hard code in this slice range. # And so in cases like that Python actually has a special class called slice which we can call and store whatever these ranges we want # biggest reasons why you'd ever use this slice class over using just this explicit versi...
9128cb5c5289a25e45c01afad9ee9729f6937d2e
ehiggins98/EECS448-Project-4
/character_classifier/context.py
44,694
4.0625
4
""" Keeps track of the current context to to allow fetching all valid characters at the current position in the code. """ import re import copy starting_chars = "[A-z$]" non_starting_chars = starting_chars + "|\\d" context_headers = ['function', 'for', 'while', 'if', 'elseif', 'else'] declaration_flags = ['var', 'let'...
ab3600e968a6a5d63e5e331114ad9c6dfb04addd
amrita0208/DEEP-LEARNING
/ASSIGNMENT02ACTIVITY01.py
4,323
4.125
4
#!/usr/bin/env python # coding: utf-8 # # ACTIVITY 1 # # 1)Sigmoid: # It is also called as logistic activation function. # f(x)=1/(1+exp(-x) the function range between (0,1) # In[1]: import matplotlib.pyplot as plt import numpy as np def sigmoid(x): s=1/(1+np.exp(-x)) ds=s*(1-s) return s,ds x=np.ara...
4e45e0e8cc8c155dbaa14f012f8843ddaf18d740
01010000and01100001/test
/first/nums.py
146
3.515625
4
def plus(a,b): return a+b text="new text" def mnus(a,b): return a-b if __name__== '__main__': print (plus(2,2)) print(mnus(4, 2))
3d6747935043aa544588e899f165480cb69e9c0f
hhwon/exercise
/03/run.py
286
3.515625
4
# -*- coding: utf-8 -*- # __author__ = 'huang_wang' """ 377 Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. """ GCD = lambda a, b: (GCD(b, a % b) if a % b else b) print(GCD(9, 3))
371eb6c8f5b2156766d6cbea5b53b29c571edd58
hyznlp/python
/python_tutorial_binarytree.py
1,841
3.984375
4
class Node(): def __init__(self, item): self.item = item self.left = None self.right = None class Tree(): def __init__(self): self.root = None def addNode(self, item): node = Node(item) if self.root == None: self.root = node return ...
54e71f9a34b8132292332b10d4e54cab914f230b
oliveroneill/wikipedia-citation-scraper
/main.py
5,418
3.84375
4
"""A script for generating a citation list for a wikipedia article.""" import argparse import json import os import re import article_scraper import requests import typing import util API_URL = 'https://en.wikipedia.org/w/api.php' """ Citation is a namedtuple representing a sentence and its source. Args: senten...
0bbe36f522ba6d21acf6a7ede6dac443c4b9c470
theantonius/3DPrintLux
/Week10 Iteration/PythonToRhinoscript/CircleIteration.py
1,048
3.78125
4
# Create a circle from a center point and a circumference. # Iterate until tiniest circle allowed. import rhinoscriptsyntax as rs import math global center global circumference def CreateCircle(): if center: plane = rs.MovePlane(rs.ViewCPlane(), center) length = circumference ...
99781212a4c4e1c55857db96e5be5f24bcbd6b4a
UWPCE-PythonCert-ClassRepos/SP2018-Python220-Accelerated
/Student/kristianjf/lesson03/factorial.py
181
4.375
4
#! /usr/bin/env python3 def factorial(n): if n == 1: return n else: a = n * factorial(n-1) return a print('Factorial 5 is {}'.format(factorial(5)))
7d3a10af6c05f2d7dc6d2c0d7505fee832a61ac5
bhardwajat/PythonProjects
/gasoline.py
631
3.8125
4
gallons = float(input('Please enter the number of gallons of gasoline: ')) liters = 3.7854 *gallons print (gallons, ' gallons is the equivalent of ',liters,' liters ') barrels = float(gallons/19.5) print (gallons, ' gallons of gasoline requires ',barrels,' barrels of oil ') pounds = float(gallons*20) print (gallons, ' ...
0885def0f815114d919571848c700eee9f2380dc
bhardwajat/PythonProjects
/guess.py
492
3.859375
4
print ('We are going to play a game. I want you to pick a number then do a series of calculations. I bet I know what the result of those calculations will be!') player1 = int(input('This will be the answer. Select a number 10-49: ')) player2 = int(input('Pick any number 50-99: ')) factor = 99 - player1 factor1 = factor...
17b1bbc1139ea646cd49dbeea977f2c2cea826a4
Vicmaister97/CRIPTO-COMPUTACION
/p0/4-3-19/my-miller-rabin.py
3,951
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from math import * from random import * from fractions import * # AUX FUNCS ------------------------------------- def read_in(): if len(sys.argv) != 3: print ("Error en los params de entrada") exit() return p = int(sys.argv[1]) t = int(sys.argv[2]) #...
d336485e00010ea5caf8141212ba0e89cf3633e8
toppeak-web/python-tutorial
/11.list(리스트).py
826
3.984375
4
subway = [10, 20, 30] print(subway) subway = ["박민재", "라이온", "이상용"] print(subway) #이상용씨가 몇 번쨰 칸에 타고 있는가? print(subway.index("이상용")) #2 #다음 정류장에 오사용씨 탑승 subway.append("오상용") print(subway) # 오형훈씨를 박민재 / 라이온 사이에print(subway) subway.insert(1, "오형훈") print(subway) #지하철 뒤에서부터 하차 print(subway.pop()) print(subway) subway.a...
c1c371c674ba45585f523dc640b57101163ca222
Konohayui/Codewars
/python/Double Cola.py
840
3.734375
4
def whoIsNext(names, r): # your code total_people = len(names) if r <= total_people: return names[r - 1] else: base = 0 total_length = total_people temp = 0 while total_length < r: base += 1 temp = total_length tot...
f1244b7f5b1b92f4a6e1b59556550b20ea8c69f1
Konohayui/Codewars
/python/Descending Order.py
268
3.765625
4
def Descending_Order(num): n = sorted(str(num))[::-1] return int("".join(n)) # Array.diff def array_diff(a, b): if a != []: new = [] for e in a: if e not in b: new.append(e) return new return []
c0c958c8957c9423c72e5c757c6fe59009294f48
Konohayui/Codewars
/python/weight of weight.py
348
3.5
4
def order_weight(string): order = {} for ind, weight in enumerate(string.split()): w = sum(map(int, weight)) try: order[w].append(weight) except: order[w] = [weight] weights = [] for k in sorted(order): weights += sorted(order[k]) return "...
cae0d40bcef596e1495acb1b4fdbe11a319bef69
ayman-elkassas/Scipy-CrashCode
/6-linearAlg/ling.py
519
3.734375
4
import numpy as np from scipy import linalg # We are trying to solve a linear algebra system which can be given as # x + 3y +10z = 10 # 2x + 12y + 7z = 18 # 5x + 8y + 8z = 30 # Creating input array a = np.array([[1, 3, 10], [2, 12, 7], [5, 8, 8]]) # Solution Array b = np.array(...
6df2c2dc7d197d64320730a24e7aa1bb7a30821b
bvd3160/Python
/python_Cheatsheet.py
20,284
4.5625
5
# Commenting in Full Beginner Python uses # for a single line, as you can see. """ And now you can see that using 3 apostrophes/half-single-quotes(??) creates a multi line comment. """ # importing 'Modules' import os import random # printing something like 'Hello there' print("Hello there") # in Full Beginner Python...
70e3302a5c627360831c2778ddaa3f439e5a2c62
gantonious/c275-enthalpy
/quadtree.py
4,368
3.546875
4
import pygame # Define some colors BLACK = (0, 0, 0) class Quadtree: """ --------- | 0 | 1 | --------- | 2 | 3 | --------- """ def __init__(self, x, y, width, height, max_depth, max_capacity, depth=0): self._x = x self._y = y self._width = width self._h...
cf1fdb37488e74bb9cab7392e9d313cab8cb651f
cldelossantos/tkh-phase1-solutions
/I2020_DS_solution/week-007/claudia-wk7-project.py
1,918
3.984375
4
import random class RockPaperScissor: def __init__(self, rounds=3): self.rounds = rounds self.score = { 'computer': 0, 'player': 0 } def computers_turn(self): choices = { 0: 'rock', 1: 'paper', 2: 'scissors' ...
f37c3a1845e50d99aa920a9c7c0d20186cf21d0c
Ziad-Usama/B1RTHD4Y_C4LCUL4T0R
/time.py
272
3.9375
4
import time from datetime import date today = date.today() birthday = date(today.year, 9, 20) #insert date Here (YY , MM, DD) if birthday < today: birthday.replace(year=today.year +1) days_left = abs(birthday - today) print(str(days_left.days)+" Days Left")
a7fa548173406462f85d086ab4751ac2815a6c57
educharlie/LearningPython
/chapter4.py
452
3.8125
4
#coding=utf-8 ''' number = int('32') print number number = int(1.24) print number number = float('1.23') print number number = str(23) print number print type(number) ''' ''' import math radians = math.sin(0.7) print radians x = math.exp(1/360.0 * 2 * math.pi) print (x) ''' def getSum(a,b): print "Esta es una función...
3c34b20a2bfb075095cd8395e86b312cb3b418e0
pravallikachowdary/pravallika
/pg23.py
465
4.1875
4
# in arr[] of size n # python function to find minimum # in arr[] of size n def smallest(arr,n): # Initialize minimum element min = arr[0] # Traverse array elements from second # and compare every element with # current min for i in range(1, n): if arr[i] > min: min =...
16e59dd59cb3c23e049537b27c46fc221a581d01
sparkybagger/ICTPRG-Python
/Quiz7.py
399
3.6875
4
def PrintBoxByWidth(): rows = 5 columns = 60 for i in range(1, rows + 1): for j in range(1, columns + 1): if(i == 1 or i == rows or j == 1 or j == columns): print("x", end='') elif(i == 2 or i == 4): print(" ", end='') ...