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 |
|---|---|---|---|---|---|---|
589711d1ded07944ae022d3487578f7f4ddf932e | jonnytaddesky/python | /HW3/HW3_2.py | 157 | 4.21875 | 4 | value = int(input('Enter second value: '))
for i in range(value+1):
if i % 2 == 0:
print(f'{i} is EVEN')
else:
print(f'{i} is ODD')
|
03beece3047fcc20e7722d7ed9824aeed410c635 | jonnytaddesky/python | /HW3/HW3_7.py | 297 | 4.0625 | 4 | number = int(input('Enter a number: '))
reversed_number = 0
tmp_original = number
while tmp_original > 0:
reversed_number = (reversed_number * 10) + tmp_original % 10
tmp_original = tmp_original // 10
if number == reversed_number:
print('Polindrom')
else:
print('No Polindrom')
|
705a897d98767ab822d0fe50b01dc9b148b4825b | elliottqian/autoDiff | /myself/node.py | 6,342 | 3.671875 | 4 | # -*- coding: utf-8 -*-
import numpy as np
class Node(object):
"""
节点可以分为3类
常数节点;
const_attr代表节点的常数值
变量节点:
操作符节点:
op成员用于存储节点的操作算子
name是节点的标识
"""
def __init__(self):
self.inputs = []
self.op = None
self.const_attr = Non... |
0700f44ab1b11b60d28cd635aeaf20df5b90959d | jaolivero/MIT-Introduction-to-Python | /Ps1/ProblemSet1.py | 779 | 4.125 | 4 |
r = 0.04
portion_down_payment = 0.25
current_savings = 0.0
annual_salary = float(input( "What is your annual salary: "))
portion_saved = float(input("what percentage of your salary would you like to save? write as a decimal: "))
total_cost = float(input("what is the cost of your deam home: "))
monthly_sav... |
061c1b23767f20fb9aa74997077d35a7c09925c4 | codeepicure/python-bootcamp | /16 - OOPS Coffee Machine/main.py | 807 | 3.546875 | 4 | from menu import Menu, MenuItem
from coffee_maker import CoffeeMaker
from money_machine import MoneyMachine
current_selection = "on"
my_menu = Menu()
my_coffeeMaker = CoffeeMaker()
my_moneyMachine = MoneyMachine()
while current_selection != "off":
current_selection = input(f"What would you like? {my_menu.get_ite... |
618a734576921a60a9e962b9c09eafb48764f083 | EsdrasAlvino/Aux-Lab-111 | /Lab-111Tarea2-2.py | 305 | 3.875 | 4 | a = int(input("Introduce un valor para a:"))
b = int(input("Introduce un valor para b:"))
c = int(input("Introduce un valor para c:"))
print("Calculando el Discriminante...")
print("El Discriminante es:")
D = b**2 - 4*a*c
print(D)
if D<0:
print("Por lo tanto...NO existen soluciones reales")
|
0c8755c85970423a6330afde7db43b2e36b961cd | castodius/adventofcode | /2020/13/hard.py | 325 | 3.578125 | 4 | raw_input()
data = raw_input().strip().split(',')
data = [int(element) if element != 'x' else element for element in data]
curr = data[0]
multiplier = curr
for shift, value in enumerate(data[1:],1):
if value == 'x':
continue
while (curr + shift) % value != 0:
curr += multiplier
multiplier*=value
print ... |
b1021d601078a53b234da3b4cbb514534b996a96 | Namdrib/os_algorithms | /disk_scheduling/scheduler.py | 1,850 | 3.625 | 4 | import sys
import strategies
class Scheduler:
# This constructor should be used - pass in the result of parser.parse_args()
def __init__(self, args):
self.requests = [] # list of pair <time, location> of requests in the file_handle
self.disk_size = 0 # number of cylinders on the disk
# Stati... |
2d0bfa0fd3628efc7d46fbc1ad6f0105f77a32be | aadarshtn/PythonAlgorithms | /LinearSearch.py | 534 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 22 23:54:44 2019
@author: ADARSH
"""
def linear_search(n,x):
element=[]
for i in range(1,n):
element.append(i)
count=0
flag=False
for i in element:
if i==x:
print("Yes!!! Found the number at position : "+... |
e2e69ced0b3d7767ec453070309e8a9633331e45 | aadarshtn/PythonAlgorithms | /BinarySearch.py | 794 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 00:43:31 2019
@author: ADARSH
"""
def binary_search(n,x):
first_pos = 0
last_pos = len(a)-1
flag=False
count=0
while(first_pos<=last_pos and flag==False):
count+=1
mid=(first_pos+last_pos)//2
if x=... |
6548e90a2767c3ab76c49b8b6dcaaad0549a6cb2 | emanoeladolpho/exercicios_python | /salario_empresa.py | 3,691 | 3.734375 | 4 | class Empregado:
def __init__(self,matricula,nome,salarioFixo):
self._matricula = matricula
self._nome = nome
self._salarioFixo = salarioFixo
# GETTERS AND SETTER
def getMatricula(self):
return self._matricula
def setMatricula(self,matricula):
self._matricula = matricula
... |
b70f0a839267f652e30a288a80eb6ea2867175df | Ye-eun-Kim/AlgorithmStudy | /210506.py | 1,773 | 3.765625 | 4 |
def solution(numbers):
'''
문자열 파싱, 조합해보기-1개, 2개, ... , n개(최대 7개)
소수인지 판별->소수이면 cnt+=1
'''
from itertools import permutations
import math
cnt=0
prime = []
num = list(numbers)
for k in range (1, len(num)+1) :
number = list(set(map(''.join, permutations(num, k))))
... |
e32723786e7ef8b1ec5dcbc64ae1bafba516c406 | C-CCM-TC1028-102-2113/tarea-3-programas-que-usan-funciones-SamyEa12 | /assignments/10Bisiesto/src/exercise.py | 405 | 3.8125 | 4 |
def main():
#escribe tu código abajo de esta línea
def es_bisiesto(x):
if x%400==0 and x%4==0 and x%100==0:
return "True"
elif x%4==0 and x%100==0:
return "False"
elif x%4==0:
return "True"
else:
return "False"
año=int(input()... |
c6fceff4a09055383264456146605064c527e492 | HabaresHabaras/zenva_python_game | /beginnerExercises/Functions_text.py | 793 | 3.796875 | 4 | # Python language basics 6
# Functions
# Implementing, calling, parameters, return values
x_pos = 0 # global variable
y_pos = 2
e_x_pos = 4
def move(): # brackets are for parameters
global x_pos # if you don't write global, x_pos can't be referenced inside of the function
# instead it wi... |
8b31735dfdfe18af6b023d22b67ae2eac1d21fbe | msahani10294/Python_Code | /args_kwgs/sum.py | 187 | 3.671875 | 4 | import math
n = int(input("how many no you want to add : "))
l = []
j = 1
for i in range(n):
number = int(input("enter {} no :".format(j)))
l.append(number)
j+=1
print(sum(l)) |
a5ad2663260941cdb2e8b5a82a93dd9b628b0b81 | msahani10294/Python_Code | /decorator.py | 207 | 3.53125 | 4 | def decor(num):
def inner():
a = num()
print("======")
return a
return inner
@decor
def num():
return 10
# result_fun = decor(num)
# print(result_fun())
print(num()) |
963bec5b00d28351b37fd48404c5f8edbb4671af | msahani10294/Python_Code | /list_comprehension/sqr_no.py | 97 | 3.609375 | 4 | n = int(input("enter a no : "))
l = list(range(1, n+1))
sqr_no = [i**2 for i in l]
print(sqr_no) |
dea1d8d124930b100b4bebe82d85119592996783 | msahani10294/Python_Code | /list_comprehension/odd_no.py | 102 | 3.890625 | 4 | n = int(input("enter a no range: "))
l = list(range(1, n+1))
odd = [i for i in l if i%2!=0]
print(odd) |
b3c74e2d555342de51dd32dfa1871846f522897f | giordang/3308_project_repo | /app/functions/cookie.py | 687 | 3.859375 | 4 | import random
#function to get random fortune from text file, returns string
def getAFortune(test=False):
if test: #check if function call is for test to determine appropriate path name to text file
fortuneList = open("./Fortune_data.txt").readlines()
else:
fortuneList = open("app/functions/Fortune_data.txt").re... |
2119d3ba019ea7ce3a7869ea44ceb4b8ca573ccf | teodorstelian/Personal-Games | /Python/Chess/src/square.py | 759 | 3.609375 | 4 | class Square:
def __init__(self, row, col, piece=None):
self.row = row
self.col = col
self.piece = piece
def __eq__(self, other):
return self.row == other.row and self.col == other.col
def has_piece(self):
return self.piece is not None
def is_empty(self):
... |
2014e78dbd2dfe34ae1c30d24674d32fc63278e9 | hhhhhhh2019/vector-math-python-1 | /vec_math.py | 12,170 | 3.5 | 4 | from math import acos
# МАТРИЦЫ
class mat2:
def __init__(self, a, b):
self.mat = [
[a.x, a.y],
[b.x, b.y]]
class mat3:
def __init__(self, a, b, c):
self.mat = [
[a.x, a.y, a.z],
[b.x, b.y, b.z],
[c.x, c.y, c.z]]
class mat4:
def __init__(self, a, b, c, d):
self.mat = [
[a.x, a.y, a.z, a.w]... |
282813f10da960b58065cf47f56043b9e8dfbd20 | ShivangeeSingh/python | /List.py | 251 | 3.84375 | 4 | #!/bin/python3
a=[1,2,3,1,4,5,66,22,2,6,0,9]
c=[]
d=[]
print("1.For number > 5")
b=[i for i in a if i >5]
print(b)
c.append(b)
print("2.For number <= 2")
x=[i for i in a if i <= 2]
print(x)
d.append(x)
print("List 1 is: ",c)
print("List 2 is: ",d)
|
affea05a049607d1316ba9ce8bee1eb1c96537d1 | kaneru-soju/advent-of-code-2020 | /day01/day1.py | 1,234 | 4 | 4 | """Day 1 of Advent of Code 2020."""
import pkgutil
def report_repair(all_lines: list[int], goal: int) -> int:
"""
Calculate report repair (2sum).
:param all_lines: Input data
:param goal: Target goal
:return: Result
"""
# use 2 for loops to find the two numbers in the list that sum to 20... |
7340091d0ae6d586569e4000f73c3ae65331ef93 | kaneru-soju/advent-of-code-2020 | /day10/day10.py | 1,786 | 4.09375 | 4 | """Day 8 of Advent of Code 2020"""
import pkgutil
import itertools
from copy import deepcopy
def copy(og_data: list[int]):
"""
Makes a copy of the origial data set and returns it with the proper
start and end values as defined by the problem (also sorted).
:param og_data: the original data set
:... |
2ad6e328724aa0b1636f9a0e121d2c7b66aaf153 | sdandiwala/CIS024c | /main.py | 334 | 3.578125 | 4 | import sys
from helper import add
print "Number of Parameters:", len(sys.argv)
number1=0
number2=0
print "Type of sys.argv", type(sys.argv)
#print "sys.arg values:"
for val in sys.argv:
print val
if len(sys.argv)== 3:
number1= int(sys.argv[1])
number2= int(sys.argv[2])
print "Result:", add(num... |
9cad7aa8cfe951db1a9b949111bedf51810a491b | yazici/procedural-content-generation-wiki | /perlin/biomes.py | 1,861 | 3.640625 | 4 | import perlin, sys, math, pygame
# The coordinates of the top left corner being displayed.
top = 0
left = 0
# Setup to get the Pygame window going.
pygame.init()
screen = pygame.display.set_mode((500, 500))
pygame.display.set_caption('Biome Generation')
# We will see 50x50 blocks at any given time.
grid = [[0]*50]*5... |
45989780bad82cec3186704b60471f74921c92aa | alecordev/pygaming | /arcade/infiniworld/src/infiniworld/physics.py | 13,845 | 3.5625 | 4 | #! /usr/bin/python
"""Physics engine.
"""
# Standard library.
from __future__ import division
import math
# My stuff.
from .geometry import Vector
# pylint: disable-msg=C0103
# Invalid names. Pylint thinks my variable names are too short. I think not,
# I'm just sticking to mathematical notations.
def rk4(x, v, ... |
04acb5cf7f7f70354415001e67ba64b6062e97aa | isiddey/GoogleStockPrediction | /main.py | 2,377 | 4.25 | 4 | #Basic Linear Regression Tutorial for Machine Learning Beginner
#Created By Siddhant Mishra
#We will try to create a model to predict stock price of
#Google in next 3 days
import numpy as np
import pandas as pd
import quandl as qd
import math
from sklearn import preprocessing, cross_validation
from sklearn.linear_mod... |
0f8b6e2add87248a3c250c97acef24ee10044d09 | braysia/epitope_barcoding | /src/utils.py | 275 | 3.515625 | 4 | from collections import OrderedDict
class ImageDict(OrderedDict):
def __sub__(self, other):
new = ImageDict()
for key in self.iterkeys():
arr = self[key] - other[key]
# arr[arr<0] = 0
new[key] = arr
return new |
d17d8f8d9b21f605fc0d1ec1019c9ce2d5700055 | Jensssen/design_patterns | /Observer_Pattern/Observable.py | 621 | 3.6875 | 4 | from abc import ABC, abstractmethod
import Observer
class Observable(ABC):
"""
The Subject interface declares a set of methods for managing subscribers.
"""
@abstractmethod
def addObserver(self, observer: Observer) -> None:
"""
Attach an observer to the subject.
"""
... |
5c87b2cff91a2e331dc81d32ea3eeaf099200bfe | yp0975eu/cstone-lab1 | /camelcase.py | 1,324 | 4.09375 | 4 | import re
def isvalid_variable_name(sentence):
''' returns a list of errors '''
errors = []
# get first letter and check if firstLetter is a digit
firstLetter = sentence[0]
if firstLetter.isdigit():
errors.append(
'First letter is a digit and would not be a valid variable nam... |
bce794085b2f95c8a34d0fb1a4397bfb62244acb | saifazmi/learn | /languages/python/sentdex/basics/64-68_sqlite/65_insertingVariables.py | 1,249 | 4.0625 | 4 | # SQLite inserting data from variables into db
'''
' When it comes to real world usage, we rarely hardcode values into the db
' The values generally come from a source, stored in a variables which is
' passed into the db.
'''
import sqlite3
import time
import datetime
import random
conn = sqlite3.connect("tutorial.d... |
6545045e6e520f70af769078d008a3e72492c4fe | saifazmi/learn | /languages/python/sentdex/basics/48-53_matplotlib/51_legendsAndGrids.py | 728 | 4.15625 | 4 | # Matplotlib labels and grid lines
from matplotlib import pyplot as plt
x = [5,6,7,8]
y = [7,3,8,3]
x2 = [5,6,7,8]
y2 = [6,7,2,6]
plt.plot(x,y, 'g', linewidth=5, label = "Line One") # assigning labels
plt.plot(x2,y2, 'c', linewidth=10, label = "Line Two")
plt.title("Epic Chart")
plt.ylabel("Y axis")
plt.xlabel("X ... |
b6a0bc120206cbb24f780c8b35065925c9ae038a | saifazmi/learn | /languages/python/sentdex/intermediate/6_timeitModule.py | 1,765 | 4.1875 | 4 | # Timeit module
'''
' Measures the amount of time it takes for a snippet of code to run
' Why do we use timeit over something like start = time.time()
' total = time.time() - start
'
' The above is not very precise as a background process can disrupt the snippet
' of code to make it look like it ran for longer than it... |
dcc08fb3c7b4ef7eeee50d79bd1751b537083339 | saifazmi/learn | /languages/python/sentdex/basics/8_ifStatement.py | 302 | 4.46875 | 4 | # IF statement and assignment operators
x = 5
y = 8
z = 5
a = 3
# Simple
if x < y:
print("x is less than y")
# This is getting noisy and clutered
if z < y > x > a:
print("y is greater than z and greather than x which is greater than a")
if z <= x:
print("z is less than or equal to x")
|
f9d01749e966f4402c3591173a145b65380d2102 | saifazmi/learn | /languages/python/sentdex/basics/62_eval.py | 900 | 4.6875 | 5 | # Using Eval()
'''
' eval is short for evaluate and is a built-in function
' It evaluates any expression passed through it in form of a string and will
' return the value.
' Keep in mind, just like the pickle module we talked about, eval has
' no security against malicious attacks. Don't use eval if you cannot
' trust... |
27634a1801bd0a5cbe1ca00e31052065a8e4ce9b | saifazmi/learn | /languages/python/sentdex/basics/64-68_sqlite/66_readDB.py | 852 | 4.40625 | 4 | # SQLite reading from DB
import sqlite3
conn = sqlite3.connect("tutorial.db")
c = conn.cursor()
def read_from_db():
c.execute("SELECT * FROM stuffToPlot") # this is just a selection
data = c.fetchall() # gets the data
print(data)
# Generally we iterate through the data
for row in data:
pr... |
95443c1973cf14c5467b2fb8c4e24fda942bdfa9 | saifazmi/learn | /languages/python/sentdex/intermediate/7_enumerate.py | 830 | 4.40625 | 4 | # Enumerate
'''
' Enumerate takes an iterable as parameter and returns a tuple containing
' the count of item and the item itself
' by default the count starts from index 0 but we can define start=num as param
' to change the starting point of count
'''
example = ["left", "right", "up", "down"]
# NOT the right way o... |
f1b52763441b92a829363e8647dbaebae5822a8d | saifazmi/learn | /languages/python/sentdex/basics/40_tkinter.py | 1,073 | 4.0625 | 4 | # Tkinter introduction
'''
' Tkinter is part of the standard library in python
' this module is a wrapper around tk which is a wrapper around tcl
' tcl is what actually creates windows and gui
'
' Because of all these wrapper, we can create a very simple window with
' only a few lines of code (~ 8 lines), which would ... |
8bbb0737979d0709d1edca705a4966f369a110de | saifazmi/learn | /languages/python/sentdex/intermediate/2_strConcatAndFormat.py | 1,161 | 4.21875 | 4 | # String concatenation and formatting
## Concatenation
names = ["Jeff", "Gary", "Jill", "Samantha"]
for name in names:
print("Hello there,", name) # auto space
print("Hello there, " + name) # much more readable, but makes another copy
print(' '.join(["Hello there,", name])) # better for performance, no co... |
04652bd04e648972fd819c39d288b8f52577eb14 | saifazmi/learn | /languages/python/sentdex/basics/43_tkMenuBar.py | 1,464 | 4.25 | 4 | # Tkinter Menu Bar
'''
' Menus are defined with a bottom-up approach
' the menu items are appended to the menu, appended to menu bar,
' appended to main window, appended to root frame
'''
from tkinter import *
class Window(Frame):
def __init__(self, master = None):
Frame.__init__(self, master)
... |
1b7e5423aebd760e7b8e42c6fcb4b99f5abe8030 | saifazmi/learn | /languages/python/sentdex/basics/48-53_matplotlib/53_plottingCSV.py | 1,253 | 3.640625 | 4 | # Matplotlib plotting from CSV files
from matplotlib import pyplot as plt
from matplotlib import style
import numpy as np # generally imported as np
style.use("ggplot")
'''
' How to import CSV files? there are many options, we can use open() or
' the built-in csv module. But here we will be using NumPy, again not pa... |
4c48d4c1af0b698ecc4d4183bb9fb226bb5cfb67 | Ekram-B/Json_parser | /Deeplearni_ng/src/json2.py | 2,099 | 3.90625 | 4 | # Module declarations
import json as j
"""
Description: Determine whether a key exists or not for the given example
"""
# Global variables
# Functions
def isPalindrome(s):
if isinstance(s,str) == False:
A = str(s)
return A == A[::-1]
else:
return s == s[::-1]
# This is for a tree of height 1
def key_value_... |
36b40c4054a53c7801f9f27126b8871eca26f3ce | Krishna-10feb/python-related-projects-and-assignments- | /to find the reminder and quotient of a number.py | 212 | 3.578125 | 4 | def find(n, m):
# for quotient
q = n//m
print("Quotient: ", q)
# for remainder
r = n%m
print("Remainder", r)
# Driver Code
find(10, 3)
find(99, 5) |
e53d791049111223b3ea324cf62ba4ba7af59143 | Krishna-10feb/python-related-projects-and-assignments- | /power of a number.py | 173 | 4.28125 | 4 | #to calculate power
base_number=int(input("enter the base number "))
exponent=int(input("enter the exponent "))
power=base_number**exponent
print("result is =",power)
|
14fce7033aa0c5757e0d878f6d32e88f1a409947 | Krishna-10feb/python-related-projects-and-assignments- | /square root of 2 numbers.py | 150 | 4.21875 | 4 | #square root of 2 numbers
num = float(input('Enter a number: '))
num_sqrt = num ** 0.5
print('The square root of %0.2f is %0.2f'%(num ,num_sqrt))
|
de9b011666db3b1eed7a7b6792e071d1ff6ca84b | Grz3hu/GameOfLife | /game.py | 841 | 3.578125 | 4 | def neighbours(board,size,x,y):
if(board[x][y]=='x'):
sm=-1
else:
sm=0
x-=1
y-=1
for i in range(3):
for j in range(3):
if(board[map(x+i,size)][map(y+j,size)]=='x'):
sm+=1
return sm
def nextState(a,neigh):
if a==' ':
... |
2f6bb6a1d83586fe2504c1ceb787392891bd011d | lucky1506/PyProject | /Item8_is_all_digit_Lucky.py | 311 | 4.15625 | 4 | # Item 8
def is_all_digit(user_input):
"""
This function validates user entry.
It checks entry is only digits from
0 to 9, and no other characters.
"""
numbers = "0123456789"
for character in user_input:
if character not in numbers:
return False
return True
|
9c74b607bda1d7188b4ccf7007131d76c2427965 | lucky1506/PyProject | /Item4_search_a_student_Lucky.py | 858 | 3.765625 | 4 | # Item 4 - Search ID (Lucky)
def search_student(search_file, id_lookup):
"""
This function takes a file name and an id to search
a student in the file. First it reads the data from
the file in a dictionary in memory. Then it looks for
id in in the dictionary. It returns the search result.
It all... |
947ba6abee50e62ca0f6d4b12fa44fca390f26cd | lucky1506/PyProject | /Item11_student_data_manager_app_STEPH.py | 14,740 | 3.984375 | 4 | # Item 11 -- Student Data Manager App (COMBINED)
# Item 14
def get_non_empty_input(question):
""" This function checks for non empty input and prompts
the user to enter a non empty data """
value = input(question)
value = value.strip()
while value == "":
print("No value entered.... |
79b6bd2b3510ba091f9b7ca5ebdbff86685462ca | Michal-Pokorny/test1 | /PythonApplication1.py | 335 | 3.84375 | 4 | i = 100
num1 = 5
num2 = 3
word1 = 'Agile'
word2= 'Software'
word12 = 'Testing'
while i > 0:
if i%num1 == 0 and i%num2 == 0:
print(word12)
elif i%num1 == 0:
print(word1)
elif i%num2 == 0:
print(word2)
else:
print(i)
i+=-1
input("Press Enter to close..."... |
086101d275de833242f8fcfd2acddbfd6af62919 | gelfandbein/lessons | /fibonacci.py | 1,176 | 4.625 | 5 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 4 18:50:32 2020
@author: boris
"""
"""Write a program that asks the user how many Fibonnaci numbers to
generate and then generates them. Take this opportunity to think
about how you can use functions. Make sure to ask the user to enter
... |
4df59de8ea06f1de1c4b6f698a6538fd4afd4dac | gelfandbein/lessons | /16/iterators.py | 2,054 | 3.6875 | 4 | import sys
import random
a_list = ["ab", "cd", "ef"]
for w in a_list:
print(w)
it = iter(a_list)
# print(next(it))
# print(next(it))
# print(next(it))
# list = [x*x for x in range(1_000)]
# print(list)
import sys
class Square:
def __init__(self, max_num):
self.max_num = max_num
self.curre... |
70823f296f0d8840a7ae7be380d05b81a6e5da66 | Marianagiacconi/Tateti | /tateti.py | 2,748 | 3.75 | 4 |
class TaTeTi():
def __init__(self):
self.tablero_inicial = '1.1|1.2|1.3\n---+---+---\n2.1|2.2|2.3\n---+---+---\n3.1|3.2|3.3'
self.positions = ['1.1', '1.2', '1.3',
'2.1', '2.2', '2.3',
'3.1', '3.2', '3.3']
... |
b0d34741b9de03eafe535eac8f30c8f977fa6518 | gordonramsayjr/Procedural-Programming | /fizzbuzz.py | 239 | 4.1875 | 4 | import math
for x in range(100):
if x % 5 == 0 and x % 3 == 0:
print("Bingo!")
elif x % 3 == 0:
print(x,"Is divisible by 3!")
elif x % 5 == 0:
print(x,"Is divisible by 5!")
print(x) |
f9778a21e1a0175d1e467ce44c754d6ecb0e2400 | bevans64/sudoku2 | /sudoku.py | 10,835 | 3.953125 | 4 | #!/usr/bin/env python3
#
# SUDOKU 2
# Adventures in Sudoku
#
class constant:
square_dim = 3
board_dim = 9
# Number States
unknown_state = 0
fixed_number = 1
unconflicted_number = 2
conflicted_number = 3
# Grid Display Modes
displa... |
5a9234a842f29304f4775898db160eeb0670a55e | solaresjuan98/OLC1_Proyecto1_201800496 | /Analizadores/Lexrmt.py | 9,687 | 3.5625 | 4 | from enum import Enum
class Token(Enum):
ID = "Identificador"
NUM_ENTERO = "Numero entero"
OP_MULT = "Operador multiplicacion"
OP_SUMA = "Operador suma"
OP_RESTA = "Operador resta"
OP_DIVISION = "Operador division"
PAR_IZQ = "Parentesis izq"
PAR_DER = "Parentesis der"
SALTO_LINEA ... |
eabbc8071925c42d579fe00f9736c7319f5b2a65 | somvud9843/leetcode | /Spiral Matrix.py | 1,422 | 4.1875 | 4 | '''
Spiral Matrix I
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For example,
Given the following matrix:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
You should return [1,2,3,6,9,8,7,4,5].
Spiral Matrix II
Given an integer n, generate a square matrix filled... |
656dfe9756850f4b1c661fc02fb817137e0e08e1 | jdy0120/dataStructure | /sort/main.py | 1,518 | 3.765625 | 4 | # -*- coding: utf-8 -*-
import random
from timeit import default_timer as timer
from datetime import timedelta
from selectionSort import selectionSort
from insertSort import insertSort
from bubbleSort import bubbleSort
from mergeSort import mergeSort
from quickSort import quickSort
def getTimeAndList(division, dataL... |
0ace5aff54c0bbe6e5cd67682f0290a7e8ddc802 | jdy0120/dataStructure | /sort/selectionSort.py | 463 | 3.90625 | 4 | # -*- coding: utf-8 -*-
# Selection Sort 최선: O(N^2) 최악: O(N^2)
def selectionSort(unordered):
ordered = unordered[:]
for x in range(len(ordered)):
minimum = where = -1
for y in range(x+1, len(ordered)):
if minimum == -1 or minimum > ordered[y]:
minimum = ordered[y]
... |
a1077cbfcbf71480970b17e8f8ed5cef1af90f26 | shivi42/CheckingAround | /main.py | 615 | 3.96875 | 4 | import random
name = input ("Hello, what's your name? \n")
number = random.randint(1,10)
print(number)
Guessed_number = int(input("Welcome," + name + " \nGuess a number in between 1 to 10.\n"))
if Guessed_number > number :
print("ohh " + name + " you need to think little low!")
if Guessed_number < number :
pri... |
7d7d6e70123576f89a5c8d318fc7339ec7c1a771 | shreyan-naskar/Python-DSA-Course | /Strings/Max frequency/prog.py | 532 | 4.3125 | 4 | '''
Given a string s of latin characters, your task is to output the character which has
maximum frequency.
Approach:-
Maintain frequency of elements in a separate array and iterate over the array and
find the maximum frequency character.
'''
s = input("Enter the string : ")
D = {}
Freq_char = ''
Freq = 0
for i in s... |
306f07a2159c83f1213a2d5d58b9b83a8a2778e5 | shreyan-naskar/Python-DSA-Course | /Patterns/floyd triangle/prog.py | 229 | 4.25 | 4 | #Generating the Floyd Triangle
n = int(input("Enter the number of rows : "))
v = 1
print('The Floyd Triangle would look like :\n')
for i in range(1,n+1) :
for j in range(1,i+1) :
print(v , end = ' ')
v = v + 1
print('\n') |
591e06efb766c4fd99986c756192b68d91ea2fd3 | shreyan-naskar/Python-DSA-Course | /Functions in Python/find primes in range/primes.py | 429 | 4.15625 | 4 | #Finding all primes in a given range.
def isPrime( n ) :
count = 0
for i in range(2,n) :
if n%i == 0 :
count = 0
break
else :
count = 1
if count == 1 :
return True
else :
return False
n = int(input('Enter the upper limit of Range : '))
List_of_Primes = []
for i in range(1,n+1) :
if isPrime(i) ... |
86da6e7a39b47a4c79382415725c00a9a5a45396 | p1rko/GuessTheNumberOOP | /main.py | 1,645 | 3.90625 | 4 | import datetime
import json
import random
class Result:
def __init__(self, player_name, attempts, secret, date, wrong_guesses):
self.player_name = player_name
self.attempts = attempts
self.secret = secret
self.date = date
self.wrong_guesses = wrong_guesses
name = input("Ple... |
0380f241360459437d103c12bab40aa434a29024 | Tincy23/Patientflow | /main.py | 473 | 3.859375 | 4 | import pandas as pd
houseno=int(input("enter the houseno"))
place=input("enter the place")
housename=input("enter the housename")
price=int(input("enter the price"))
squarefeet=int(input("enter the squarefeet"))
d={"housenumber":[houseno,1,2],"place":[place,'a','b'],"housename":[housename,'w','f'],"price":[price,... |
cc6a94f1b9e3465ec55e90996f4a452490fdebeb | skgitbrain/python | /lesson_1/Task_3.py | 116 | 3.796875 | 4 | num = input("Введите чило: ")
num2 = num + num
num3 = num2 + num
print(int(num) + int(num2) + int(num3))
|
5e7a8347a71dafd785b3207e10d979ed8a4172fc | skgitbrain/python | /lesson_4/Task_7_L4.py | 146 | 3.765625 | 4 | def fact(num):
fact_1 = 1
for i in range(1, num + 1):
fact_1 *= i
yield fact_1
num = 4
for x in fact(num):
print(x)
|
38c01cd3021407b11582b25e3ef15ef9699f8695 | skgitbrain/python | /lesson_8/Task_3_L8.py | 468 | 3.625 | 4 | class MyError(Exception):
def __init__(self, txt):
self.txt = txt
new_list = []
while True:
number = input("введите число: ")
try:
if number == "stop":
break
elif number.isdigit() != True:
raise MyError("Это не число! вводить нужно только числа")
e... |
1cae10a6bc910b84ca6d38e66ef6a177b7cffac6 | akhild17/MovieRecommenderSystem | /Content-based recommender.py | 11,326 | 3.828125 | 4 | #!/usr/bin/env python
# coding: utf-8
# # **The Age of Recommender Systems**
# There are basically three types of recommender systems:-
#
# > * **Demographic Filtering**- They offer generalized recommendations to every user, based on movie popularity and/or genre. The System recommends the same movies to users wit... |
f8978664bd66c8f0ea1d3b59b08894f73a273b59 | Lorentsonr/Python | /python_fundamentals/SelectionSort.py | 298 | 3.984375 | 4 | def selection_sort(list):
for i in range(0,len(list)):
x = list[i]
for j in range(0,len(list)):
if x < list[j]:
list[i], list[j] = list[j], list [i]
x= list [j]
return list
print(selection_sort([-1, 3, 5, 0, 23,-23, 40, -10, -5])) |
18f90513e2a029e6dabed4ddd83d5c8a21c9139c | tanzeelak/CS131 | /project/disc/firstn_generator_style.py | 630 | 3.578125 | 4 | # TA Note
# The variable 'i' is a class variable.
# For an instance variable, use with the 'self' object.
# The 'self' object can be renamed.
# def __iter__(s):
# return s
class firstn(object):
i = 123
def __init__(self, n):
self.n = n
self.num, self.nums = 0, []
def __iter__(se... |
04b1266c9dda4e59258dccae1c98dba755b308c1 | ArelyL/Sorts | /pygame2.py | 3,233 | 3.984375 | 4 | import sys, pygame, time
pygame.init()
size = width, height = 1000, 650 #tamao de la pantalla
speed = [2, 2]
speed2 = [3, 3]
# Define the colors we will use in RGB format
black = 0, 0, 0
WHITE = (255, 255, 255)
BLUE = (0, 0, 89)
GREEN = (0, 100, 0)
RED = (169, 0, 0)
Pink = (255, 102, 102)
Purple =... |
24e417db7e405f03f69c190931dffdd8b1541aec | ArelyL/Sorts | /BubbleSort.py | 517 | 3.953125 | 4 | #!/env/bin/python
import random
n=10000
def BubbleSort(A):
for i in range(1,n):
for j in range(0,n-1):
if A[i]<A[j]:
aux=A[j]
A[j]=A[i]
A[i]=aux
if __name__=='__main__':
A=[[]]
for i in range(n):
V=r... |
65c9af039f3084e2adb2b203a91a3757d4d4f904 | econchick/roguelib | /tree.py | 1,618 | 3.546875 | 4 | from collections import deque
class TreeNode:
def __init__(self, value):
self.value = value
self.parent = None
self.children = []
def __repr__(self):
return str(self.value)
def link(parent, child):
parent.children.append(child)
child.parent = parent
class BinaryTree:
def __init__(self, root):
if ... |
4a5df9ab6d87cdec37c4f14f210864a745d506ea | happa64/AtCoder_Beginner_Contest | /Unrated/TENKA1_2012_Qual_C/TENKA1_2012_Qual_C-A.py | 584 | 3.59375 | 4 | # https://atcoder.jp/contests/tenka1-2012-qualC/submissions/13909069
# A - 与えられた数より小さい素数の個数について
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def is_prime(n):
if n == 1:
return False
for k in range(2, int(pow(n, 0.5)) + 1):
if n % ... |
fb4ebe97550881d2583abc63048bd9c1e3d844b4 | happa64/AtCoder_Beginner_Contest | /Library/AVL.py | 11,487 | 3.65625 | 4 | class Avltree:
"""
AVL木
Methods
-------
search(x: int) -> Union(int)
◯.data == x のものが存在するある場合それを出力、ない場合 None を返す
insert(x: int) -> None
◯.data == x がない場合 ◯.data == x なる頂点を作る。ある場合はなにもしない(上書きしない)
y.to_s() -> int
頂点yのdataを返す
y.left_s() -> ... |
61a3cfaf9c7f6981e3dfdfba94aad83ab8c02c48 | AshTech19/Week1and2_python | /Week2/ReverseOrder.py | 160 | 4.21875 | 4 | def name():
firstname = input("Enter your first name: ")
lastname = input("Enter your last name: ")
print(f'Reverse order: {lastname} {firstname}') |
01fa6d1a1d3c6247a43bd984258d55726da80a11 | felix-lau/ebu_adm_renderer | /ear/fileio/adm/time_format.py | 1,299 | 3.96875 | 4 | from fractions import Fraction
import re
_TIME_RE = re.compile(r"""
(?P<hour>\d{1,2}) # one or two hour digits
: # :
(?P<minute>\d{1,2}) # one or two minute digits
: # :
(?P<second> # second decimal consisting of:
\d{1,2} # two ... |
b4c4d44235eb95face034c8eb3a347d83bea8ae1 | Winedays/Introduction-to-FinTech | /TA/hw2/sample/rrEstimateAll.py | 2,359 | 4.03125 | 4 | # How to invoke this program:
# python rrEstimateAll.py
import sys
import numpy as np
import pandas as pd
from test import myStrategy
# Compute return rate over a given price vector, with 3 modifiable parameters
def computeReturnRate(priceVec, stockType):
capital=1000 # Initial capital at hand (持有資金)
capitalOrig=cap... |
6e3c12ac862240bf41a28c9ceb3577844229c11f | sabrikrdnz/LYK-17-Python-Examples | /38recursivesil.py | 237 | 3.8125 | 4 | import os
dizin = input("Dizin?")
def listele(path):
dosyalar = os.listdir(path)
for dosya in dosyalar:
print(dosya)
if os.path.isdir(os.path.join(path,dosya)):
listele(dosya)
listele(os.path.join(path,dosya)
listele(dizin) |
578805d2d8dccdf4fd7999205af0196e2ece5969 | sabrikrdnz/LYK-17-Python-Examples | /33BaseException.py | 157 | 3.90625 | 4 | while True:
x = input("sayi gir:")
if not x:
break
try:
print(float(x)**2)
except BaseException as e:
print("girdiğin şey nasıl bişey:",str(e)) |
e60448cf8bc9dce51e49808f5145991b32922498 | sabrikrdnz/LYK-17-Python-Examples | /14diziiciarama.py | 131 | 3.6875 | 4 | a = [1,2,3,4,5]
b = 3
x = 0
for i in a:
if i==b:
index = x
print("a arrayinin %d'nci elemanı b'ye eşittir" % index)
x += 1 |
1a1d3c64cae1ea221896af4bcc27ce3a5e123f05 | sabrikrdnz/LYK-17-Python-Examples | /siniflar/7muzikornek2.py | 1,712 | 4.03125 | 4 | #Kullanıcı şarkı adı girsin
#Kullanıcı şarkı süresi girsin.
#Albüm isimleri listelensin
#Kullanıcı listedeki albüm isimlerinden birini seçsin
#Şarkı adı ve şarkı süresi kullanılarak bir şarkı nesnesi oluşturulsun
#Bu şarkı nesnesi için albume_ekle() metodu çağırılsın
#Metodun içinde albümün şarkılar özelliğine bu şarkı... |
edddb750e49578bcc289caaa4a0f61bcfc663dfe | sabrikrdnz/LYK-17-Python-Examples | /siniflar/6muzikornek.py | 1,075 | 3.65625 | 4 | # Önce albüm class ı oluştur Albüm(isim, tür)
# sonra şarkı class ı oluştur. şarkı(isim,süresi)
#{"pop":["Yolla","Karakedi"],"sanatmüziği:"["saklıkayıtlar,intizar"]}
#kullanıcı öncelikle şarkı eklemek istesin.
#şarkıyı bir albüme dahil etsin.
#albüme her şarkı ekledikten sonra albümdeki şarkıları listelesin
#ve albümt... |
2f515cd9fc2ce21513a7588454952bf020c79111 | MysterEdge/parol | /parol.py | 2,632 | 3.765625 | 4 | import turtle
import math
DEG36 = 36 * math.pi / 180
DEG54 = 54 * math.pi / 180
# some constants to allow flexibility in construction
GRADS = 36
RUFFLES = 5
SIDE = 100
SHORTSIDE = SIDE * math.sin(DEG36) / math.sin(DEG54)
# convenience function to draw a left parol tail
def draw_left_tail(turt):
for i in range(1,... |
2dbeef63ca251b9d9ab446b8776ea376ac3b0451 | akshajbhandari28/guess-the-number-game | /main.py | 1,584 | 4.1875 | 4 | import random
print("welcome to guess the number game! ")
name = input("pls lets us know ur name: ")
print("hello, ", name, "there are some things you need tp know before we begin..")
print("1) you have to guess a number so the number u think type only that number and nothing else")
print("2) you will get three chance... |
e8686162ef0c922fe97967cd15103a5ed4c5851d | HearthCx/BCACriminalHistoryPublic | /Radcliffe/insert.py | 624 | 3.734375 | 4 | # Module: insert.py
#
# This module inserts values into a database table.
# row - insert a single row
# rows - insert a list of rows
#
# Parameters:
# cur - a database cursor
# table - the name of an SQL table
# vals - a tuple of values to insert
# manyvals - a list of tuples to insert
#
# Called by: p... |
cc7a97056a7b9d04e405ac0f762bdb162e89a96c | alexaris/xproject | /cmd.py | 1,514 | 3.71875 | 4 | import string
class CLInterpreter:
"""A simple class for writing line-oriented command interpreters.
"""
prompt = '> '
identchars = string.ascii_letters + string.digits + '_'
def __init__(self):
pass
def parseline(self, line):
"""Parse the line into a command name and argu... |
a879ffe66c60b1ec0f09cbc2c812d1ddf44f8324 | amakashov/python_homeworks | /Homework2/Task7.py | 428 | 3.9375 | 4 | # Пятая необязательная задача
# Я не очень понял условие - просто взять и удалить повторяющиеся пробелы?
sampleString = "I don't realy understand the point of this task. Should I simply remove all unnecesary whitespaces?"
print (sampleString)
strList = sampleString.split();
newString = str.join(" ", str... |
a5a9b78279d1d8711f51337d7698b55a70202556 | Meowsers25/py4e | /chapt6/tests.py | 1,978 | 3.984375 | 4 | # zot = 'abc'
# print(zot[5]) # traceback error
#
# fruit = 'banana'
# print(len(fruit)) # len is a buuilt in function
# fruit = 'banana'
# index = 0
# while index < len(fruit):
# letter = fruit[index]
# print(index, letter)
# index += 1
# prefer for loop
# fruit = 'banana'
# for letter in fruit:
# ... |
e262ab3f8dbe1cdf07c55dfeaf61ebc6e58d9ac8 | Meowsers25/py4e | /chapt3/ex3_2.py | 329 | 3.6875 | 4 | sh = input("Enter hours: ")
sr = input("Enter rate: ")
try:
fh = float(sh)
fr = float(sr)
except:
print("Error, please enter numeric input")
quit()
if fh > 40:
oth = fh - 40
regh = fh - oth
otr = fr * 1.5
print("You've earned", (oth * otr) + (regh * fr))
else:
print("You've earned", ... |
3829020674ee0e08dd307a6e89606752f27f810b | Meowsers25/py4e | /chapt7/tests.py | 2,099 | 4.125 | 4 | # handle allows you to get to the file;
# it is not the file itself, and it it not the data in file
# fhand = open('mbox.txt')
# print(fhand)
# stuff = 'hello\nWorld'
# print(stuff)
# stuff = 'X\nY'
# print(stuff)
# # \n is a character
# print(len(stuff)) # 3 character string
# a file is a sequence of lines with \n... |
e1c7a8b10f8fdb183ec52927bf7b2fde52116971 | Meowsers25/py4e | /chapt5/counting.py | 1,245 | 4.15625 | 4 | # counting
# zork = 0
# print("Before: ", zork)
# for thing in [9, 41, 12, 3, 74, 15]:
# zork += 1
# print(zork, thing)
# print("After: ", zork)
#
# # summing
# zork = 0
# print("Before:", zork)
# for thing in [9, 41, 12, 3, 74, 15]:
# zork = zork + thing
# print(zork, thing)
# print("After:", zork)
#
#... |
6098b61b1ada8341f108e68dbe47f50462cf7dad | jflezzer/Python-Work | /hw81.py | 179 | 3.8125 | 4 | numbers = [1, 2, 3, 4, 5, 6, 7, 8]
def chop(numbers):
for n in numbers:
numbers = numbers[1:len(numbers)-1]
numbers.sort
print numbers
chop(numbers)
|
c8c2cdfe61f86de97eea4242ba118bc57a67590c | jflezzer/Python-Work | /hw72.py | 387 | 3.71875 | 4 | # Use the file name mbox-short.txt as the file name
try:
fname = raw_input("Enter file name: ")
fh = open(fname)
except:
print 'File not found:',fname
exit()
val = ""
for line in fh:
if not line.startswith("X-DSPAM-Confidence:") : continue
else:
for letter in line:
if not letter.isdigit(): conti... |
9fa6470e2bb7725a7673ccb17b4aea9396d3a28a | Antropom/blackjack | /blackjack.py | 3,774 | 3.546875 | 4 | from random import *
import sys
# Code pour jouer avec un jeu unique sans piocher les mêmes cartes
"""cartes = [0] * 52
incr = 0
carte = 2
tirees = []
for loop in range(13):
for boucle in range(4):
cartes[incr] = carte
incr += 1
carte += 1
def points():
if pioche > 10 and pioche < 14:
... |
d835b1cc43e1d5970fdc6c4e70b05b9963fd501a | lucasg-mm/alg-exercises | /dynamic_prog/10.py | 1,568 | 3.5625 | 4 | # Calcula a solução ótima com estratégia de prog. din. (versão iterativa)
def minimiza_troco(moedas, val_dado):
# ordena as moedas de maneira crescente e coloca uma moeda "dummy", apenas para a correta execução do alg.
moedas.append(0)
moedas.sort()
# só precisamos das moedas que tenham valor menor do ... |
26403735eb5b01eb950677a6323239153dff8d61 | jlb3n5/Wumpus-World | /Wumpus.py | 7,425 | 3.921875 | 4 | #########################
#
# CS 101
# Program 8
# Justin Balino
# jlb3n5@mail.umkc.edu
#
# Problem: Write a puzzle game, called Wumpus World
#
# Algorithm:
# 1. Help menu of what actions can be used and what format.
# 2. Cell class model one square in the map.
# 3. Map class contains a 2-dimensional lis... |
bf41299fd7c18ccc59e2b05aea0f5296baffbe64 | magasser/augis | /controls/raspberry-pi/thread_handler.py | 920 | 3.78125 | 4 | """
Authors: Manuel Gasser, Julian Haldimann
Created: 01.05.2021
Last Modified: 08.05.2021
"""
import threading
locks = {
"print_lock": threading.Lock(),
"pub_lock": threading.Lock(),
"engine_halt_lock": threading.Lock(),
"engine_reset_lock": threading.Lock(),
"engine_stop_lock": threading.Lock(),... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.