blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
0f9ea06acf0bedd8551ac0107c30784b8f424efc | zejacobi/ProjectEuler | /Solutions/0038.py | 2,309 | 4.1875 | 4 | """
# Problem #38: Pandigital Multiples
Take the number 192 and multiply it by each of 1, 2, and 3:
192 × 1 = 192
192 × 2 = 384
192 × 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the
concatenated product of 192 and (1,2,3)
The same can be achieved by starting ... |
6b434b661d84c4503318c5cda497bff6a51555c8 | AnthonyLzq/Python_course | /class_05/agenda.py | 2,362 | 3.828125 | 4 | class Agenda():
def __init__(self):
self.__conctacts = {
'Anthony': ['Luzquiños', '936962826', 'sluzquinosa@uni.pe'],
'Rubén': ['Ricapa', '987654321', 'rubenillo@uni.pe']
}
def show_conctacts(self):
print('\nContact list:')
for position, key in enumerate(... |
aae9d80c602849170188e1d18f0bc3cc9c0ded59 | amiralimoghadamzadeh/pythonn | /2-4.py | 217 | 3.625 | 4 | a = int(input("number of the students in the class"))
S = 0
L = []
for i in range(a):
score = int(input("enter the score"))
L.append(score)
S += score
print(max(L))
print(min(L))
print(float(S/a)) |
61c5751ed2815fbbf28de27d166e258c0b06d7ee | Svagtlys/PythonExercises | /PasswordGenerator.py | 2,542 | 4.21875 | 4 | import random
import string
# Write a password generator in Python. Be creative with how you
# generate passwords - strong passwords have a mix of lowercase
# letters, uppercase letters, numbers, and symbols. The passwords
# should be random, generating a new password every time the user
# asks for a new pas... |
70374def1e4562e7b1baa0b5c0923ebb9b0eac9f | ExQA/WebAcademyPython | /include/calcul.py | 432 | 3.953125 | 4 | first = float(input('first number >>> '))
operation = input('operation >>> ')
second = float(input('second number >>> '))
pattern_output = '{} {} {} = {}'
res = None
if operation == '+':
res = first + second
elif operation == '-':
res = first - second
elif operation == '*':
res = first - second
else:
... |
badecfa9c71115b80abf3e050435c642425724ee | FrancisJaGlez/Mision_02 | /cuenta.py | 335 | 3.65625 | 4 | #Francisco Javier González Molina A01748636
#Algoritmo que calcula el costo total de la comida
subtotal= int (input("Inserte el precio total de los platillos: $"))
propina=subtotal*.13
iva=subtotal*.16
totalapagar=subtotal+iva+propina
print ("""Costo de la comida: $%.2f
Propina: $%.2f
IVA: $%.2f
Total a pagar: $%.2f... |
adf2ab2ea686c67e413e3f1637d719a674a6ac6c | cognizant1503/Assignments | /PF/day2/Assignment16.py | 938 | 3.9375 | 4 | #PF-Assgn-16
def make_amount(rupees_to_make,no_of_five,no_of_one):
five_needed=0
one_needed=0
money=0
five=rupees_to_make//5
if(five>=no_of_five):
money = no_of_five * 5
ones = rupees_to_make - money
if(ones<=no_of_one):
five_needed = no_of_five
... |
b04dc5da47fed82aa85caf6b7b5078f39f71d90c | green-fox-academy/Komaxor | /week3/thu/8_list_introduction_2.py | 1,051 | 4.21875 | 4 | '''
Create a list ('List A') which contains the following values
Apple, Avocado, Blueberries, Durian, Lychee
Create a new list ('List B') with the values of List A
Print out whether List A contains Durian or not
Remove Durian from List B
Add Kiwifruit to List A after the 4th element
Compare the size of List A and List ... |
1b6f5f01d7b96fa5c4c96691415e695b2813b18c | eunic/bootcamp-final-files | /bank_account.py | 3,047 | 4.28125 | 4 | """
prompts customer to choose bank account form which he or she wishes to deposit, withdraw or view balance
"""
class BankAccount(object):
def __init__(self,balance):
self.balance = balance
class SavingsAccount(BankAccount):
def __init__(self):
self.balance = 500
def deposit(self):
... |
ffc77fedbdcc36734ed9e3dbcc2c394c0c8b061c | Zhansayaas/webdev | /week10/Инфоматрикс/c.циклы/while/d)e.py | 55 | 3.5 | 4 | k=int(input())
x=0
while(2**x<k):
x+=1
print(x) |
776958cebfb4db688d3f63ebffcff4e3b8575644 | JakubKazimierski/PythonPortfolio | /Coderbyte_algorithms/Medium/StringZigzag/StringZigzag.py | 1,385 | 4.59375 | 5 | '''
String Zigzag from Coderbyte
December 2020 Jakub Kazimierski
'''
def StringZigzag(strArr):
'''
Have the function StringZigzag(strArr)
read the array of strings stored in strArr,
which will contain two elements, the first some
sort of string and the second element will be a
nu... |
3ef60e1eaf5f6ad658da5eb4ec7e1f37b3b72a0b | Lightman-EL/Python-by-Example---Nikola-Lacey | /N5_For_Loop/042.py | 238 | 4.125 | 4 | total = 0
for i in range(1, 6):
number = int(input("Enter a number: "))
includ = input("Do you want that number included? (y/n)\n")
if includ.lower() == "y":
total = total + number
print("The total is ", total)
|
d7dc7171eea792d0d42225f25c5d2d8d1ededa07 | Remboooo/adventofcode | /2019/21-1.py | 1,055 | 3.6875 | 4 | from argparse import ArgumentParser
from intvm import IntVM
def main():
argparse = ArgumentParser()
argparse.add_argument("file", type=str, nargs="?", default="21-input.txt")
args = argparse.parse_args()
with open(args.file, "r") as f:
program = [int(c) for c in f.read().split(',')]
inst... |
e431a06eed951490db45ea56c7d54ae39939e501 | lalosuarez/machine-learning-projects | /users-leave-bank/users-leave-bank-ann/ann.py | 6,030 | 3.609375 | 4 | # Artificial Neural Network
# Installing Theano
# pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
# Installing Tensorflow
# pip install tensorflow
# Installing Keras
# pip install --upgrade keras
# Part 1 - Data Preprocessing
# Importing the libraries
import numpy as np
import matplotlib.pyp... |
153dd38c0c6bd0a127a9e3837db884e6b6e1f5fb | morningred88/data-structure-algorithms-in-python | /Array/q4-anagram.py | 979 | 3.859375 | 4 | """
Question 4: Anagram checking
Construct an algorith to check whether two words (or phrases) are anagrams or not
"An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once"
"""
def isAnagram(str1, str2):
# If the length... |
9f4baa32416c8d02dcdd2afa4ef8b44230a6eb61 | stjordanis/Fin6470 | /Spring2021/Module1/Notebooks/Chapter 2 (Hull)/.ipynb_checkpoints/m2m-checkpoint.py | 1,857 | 3.5625 | 4 | class MarginAccount(object):
def __init__(self, spot_price, init_margin, var_margin, num_contracts, units):
self.__ref_price = spot_price
self.__init_margin = init_margin
self.__var_margin = var_margin
self.__num_contracts = num_contracts
self.__units = units
self.__e... |
1bf55e7f33486c345beb2f7b9b06b8ff2aaf7ebe | hussain-abbas-06228/DS2-Project-Scrabble | /new pagoda.py | 4,064 | 3.9375 | 4 | class Node1:
def __init__(self, val: str, dat: str) -> None:
self._left = None
self._right = None
self._value = val
self._data = dat
class Pagoda1:
def __init__(self):
self._root:Node1 = None
def is_empty(self):
if self._root == None:
return True
... |
901701f7d13eea2ba035eeab304b4b03373930e5 | wangtao090620/LeetCode | /wangtao/leetcode/0501.py | 1,372 | 3.75 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# @Author : wangtao
# @Contact : wangtao090620@gmail.com
# @Time : 2020-03-02 18:42
"""
给定一个有相同值的二叉搜索树(BST),找出 BST 中的所有众数(出现频率最高的元素)。
假定 BST 有如下定义:
结点左子树中所含结点的值小于等于当前结点的值
结点右子树中所含结点的值大于等于当前结点的值
左子树和右子树都是二叉搜索树
例如:
给定 BST [1,null,2,2],
1
\
2
... |
d43b9fc35c4d135e0789004cf43c5c0b21f45db8 | ManishaHingne/PythonML | /Code/feb_22/page1.py | 187 | 3.984375 | 4 | numbers = list(range(0, 10))
print(numbers)
# for index in numbers:
# numbers.pop()
# print(numbers)
# numbers.pop(-1)
print(numbers)
number = '10.5'
print(number.isdecimal()) |
d3b76ae9f47a338716342decdf4689529cdc55a3 | tristanwinstanley/Networks | /grid_object.py | 15,967 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 19 22:52:22 2018
@author: matth
"""
import numpy as np
import T_grid
from random import randint as rnd
labels = {'empty':0,'obstacle':1,'start':2,'radar':2.5,'end':4.5,'path':3.5}
directions = [[1,1],[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1],[0,1]]
def p2_dist(a,b):
... |
edd41fd7695863768a1a79b43690e8266a42bb6d | bangalorebyte-cohort11/Control-Flow-Github-Terminal | /Control_Flow.py | 1,838 | 3.96875 | 4 |
# Control flow via indentation
if 2**2 == 4:
print('Obvious!')
# luckily ipython does the indentation whenever we move to a new line
# but if we did the following
if 2**2 ==4:
print('Obviously Not!')
#the interpreter tells us in this case where and how we went wrong
# Iteration
counter = 1
while counter... |
55819062e340a7c95763276f37cf6c72aba9f5a0 | peterhuyxuan/SelfOrderingFoodSystem | /src/inventory.py | 3,176 | 3.65625 | 4 | from src.inventory_item import inventoryItem
class inventory():
def __init__(self):
self._item = []
'''
Query Processing Services
'''
def item_search(self, name=None):
if name == None:
for item in self._item:
print(item)
else:
for... |
f5f03bb63bd2f633efa9de079ed14e077e6ff519 | pbarton666/learninglab | /kirby-course/session10/manager_one.py | 909 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 4, 2016
Modified Mon Dec 12, 2016
@author: Kirby Urner
Show how entering a context triggers the __enter__
tripwire. On __exit__ you may set off the emergency
buzzer (return False), or not (return True)
"""
class CodeCastle:
def __init__(self):
self.me... |
3bb5f7a1df1d8a72c1c2b2cca1729a5fe6a957b5 | orazioc17/python-avanzado | /operaciones_sets.py | 468 | 3.90625 | 4 |
def run():
set1 = {1,2,3,4,5}
print(f'set1: {set1}')
set2 = {5,6,7,8,9}
print(f'set2: {set2}')
union = set1 | set2
print(f'union: {union}')
intersection = set1 & set2
print(f'intersection: {intersection}')
diff1 = set1 - set2
print(f'diff1: {diff1}')
diff2 = set2 - set1
... |
8666853f4c6a9341f7a7ba80b4dfad390aa9fbff | heersaak/opdrachtenPython | /Opdrachten/Les 7/7_2.py | 706 | 3.828125 | 4 | ##Schrijf een nieuw programma waarin de gebruiker een woord moet invoeren. Dit woord moet uit vier
##letters bestaan. Is dat niet zo, dan wordt en foutmelding getoond en moet de gebruiker opnieuw een
##woord invoeren, net zolang totdat er een woord is ingevoerd dat uit vier letters bestaat. Dan eindigt
##het programma.... |
b591f9905f1215a50e3aac3efebbd4399cd124e4 | marjana155/basic-python-programs | /Data_Structure/dsChallenge.py | 384 | 4.0625 | 4 | text = input("Enter your text:")
count = {c: text.count(c)for c in text}
"""unique = []
for t in count:
if t not in unique:
unique.append(t)
count = unique
# print(unique)
count.sort(key=lambda item: item[1], reverse=True)"""
count_sorted = sorted(count.items(), key=lambda item: item[1], reverse=True)
pri... |
3ddd19eb2b2c7df490718be7d1bb5a8f45e6ff50 | smithadam7/DepositoryPython | /Search.py | 1,286 | 3.5625 | 4 | # Adam Smith
# Search algorithms
arr = []
f = open('wordlist.txt', 'r')
thefile = open('nearly-sorted.txt', 'w')
for line in f.readlines():
line = line.strip('!')
line = line.strip(' ')
line = line.strip(' ')
line = line.strip(' ')
line = line.strip(' ')
line = line.strip(' '... |
7637cd4ff54a8b3d08774de30aade7ef91a4508a | kovalbogdan95/MyPythonLearn | /SerpinskiTriangle/serpinskiTriangle.py | 3,858 | 4.03125 | 4 | """ Serpinski Triangle drawing function
Function is implemented in Python 3.
Function have three optional parametrs:
- Method: 1 = Iterative or 2 = Chaos methods. (Iterative is default)
- Depth of iterative method. (4 is default depth)
- Shift coordinats. ([0,0] is default)
"""
def serpinskiTriangle (method=1, depth=... |
0ed370dc80d5fb3730c33d04349bd49983f65a28 | duliodenis/python_master_degree | /unit_02/04_object-oriented/4-Dice_Roller/scoresheets.py | 1,700 | 3.96875 | 4 | #
# Object-Oriented Python: Dice Roller
# Python Techdegree
#
# Created by Dulio Denis on 12/22/18.
# Copyright (c) 2018 ddApps. All rights reserved.
# ------------------------------------------------
# Challenge 4: Chance Scoring
# ------------------------------------------------
# Challenge Task 1 of 2
# I've ... |
4f9c1872b1f969b91130a5da8dddd178e2052093 | jaochen/algorithm | /leetcode算法题/0066_加一.py | 1,294 | 3.796875 | 4 | '''
给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。
最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。
你可以假设除了整数 0 之外,这个整数不会以零开头。
示例 1:
输入: [1,2,3]
输出: [1,2,4]
解释: 输入数组表示数字 123。
示例 2:
输入: [4,3,2,1]
输出: [4,3,2,2]
解释: 输入数组表示数字 4321。
'''
class Solution:
# 递归解法
def plusOne(self, digits: List[int]) -> List[int]:
def addOne(index):
... |
f2e8535ddec7f764e2886c8871d55d66b4b885ca | iteachyou/homelesspup.help | /if statements.py | 202 | 4.03125 | 4 | name = input("What is your name?").strip().title()
if name == ("Jack"):
input("COPYCAT!")
elif name == ("Roxy"):
input("OH HAI ROXY!")
else:
input("Nice to meet you, " + name)
|
9714805e46cc579661df68d7974eb2d0d796cddd | zongninggong123/Stock-Prediction-Using-Stacked-LSTM | /WebApp.py | 954 | 3.765625 | 4 | import streamlit as st
from PIL import Image
st.write("""
# Stock Price Predictor Using LSTM:
Stock values is very valuable but extremely hard to predict correctly for any human being on their own. This project seeks to solve the problem of Stock Prices Prediction by utilizes Deep Learning models, Long-Short Term... |
1bcef64337760f2c607be786ba9c8d140b1b1f91 | DogsRulesAllTime/Py_tests | /classes/users.py | 757 | 3.703125 | 4 | class User():
"""class User"""
def __init__(self,name,surname,age):
self.name = name
self.surname = surname
self.age = age
self.login_atemp = 0
def user_info(self):
print(self.name,' ',self.surname,' ',self.age)
def great_user(self):
print('Hello ',self... |
98d4688a1f84c738acc68c69f5cb09b88d208fcd | shtnk/Iteration | /Python/7-continue.py | 123 | 3.78125 | 4 | # There is no continue label in python
i = 0
while i < 10:
i += 1
print("Hello")
if i == 5:
continue
print("World")
|
e08b51cf03230eb50283fe5d700743d0313c79d2 | thecskc/PythonTut | /tuts/conditionals.py | 323 | 4.03125 | 4 | a,b=5,1;
if a<b:
print('a {} is less than b {}'.format(a,b));
else:
print('b {} is less than a {}'.format(b,a));
print("foo" if a<b else "bar");
# Testing fibonacci now...
a=0
b=1
n=50
print(a)
print(b)
counter=1
while(counter<n):
d=a+b
a=b
b=d
print(d)
counter=counter+1
print("DONE!")
... |
40603e428e438de2118b3521cd0842e033351b4f | samadabbagh/sama-mft | /mft-twelve-section/practice_vector.py | 531 | 3.8125 | 4 | class Vector:
def __init__(self, x, y):
self.x = x
self.y = y
def __add__(self, other):
x_new = self.x + other.x
y_new = self.y + other.y
return Vector(x_new, y_new)
def __sub__(self, other):
x_sub = self.x - other.x
y_sub = self.y - other.y
... |
df66252879b2b0f05671b6b105eb8b5945648054 | MiKueen/Data-Structures-and-Algorithms | /Leetcode/0901-0950/0912-sort-an-array.py | 1,288 | 4.1875 | 4 | '''
Author : MiKueen
Level : Medium
Problem Statement : Sort an Array
Given an array of integers nums, sort the array in ascending order.
Example 1:
Input: nums = [5,2,3,1]
Output: [1,2,3,5]
Example 2:
Input: nums = [5,1,1,2,0,0]
Output: [0,0,1,1,2,5]
Constraints:
1 <= nums.length <= 50000
-50000 <= nums[i] <= 500... |
25f45c29ccbc7dfc012d551cd54419049de4edb4 | mlr0929/FluentPython | /03DictAndSet/merge_two_dict.py | 471 | 3.765625 | 4 | """
In Python 3.5 or greater: z = {**x, **y}
>>> x = {'a': 1, 'b': 2}
>>> y = {'b': 3, 'c': 4}
>>> z = {**x, **y}
>>> z['a']
1
>>> z['b']
3
>>> z['c']
4
In Python 2, (or 3.4 or lower) write a function
>>> x = {'a': 1, 'b': 2}
>>> y = {'b': 3, 'c': 4}
>>> z = x.copy() # make a copy
>>> z.update(y) # update with y, afte... |
ad6580417b74b8c8626a41a2fcbf65aa45857f16 | moidshaikh/hackerranksols | /chegg/piglatin.py | 1,442 | 4.15625 | 4 | '''
Write a program that reads lines of input from the user and converts each line into "Pig Latin."'
Pig Latin is English with the initial consonant sound moved to the end of each word,
followed by "ay". Words that begin with vowels simply have an "ay" appended.
Your program should continuously prompt the user for... |
ef3c2c2ad7a5f1dfa5b6cf93f5e70d65be38a94f | PatrykJurczyk/Wizualizacja_Danych | /Python Ćwiczenia 5/2.py | 290 | 3.765625 | 4 | class Kwadrat:
def __init__(self, x=0):
"""Konstuktor punktu."""
self.x = x
def __add__(self, point):
return Kwadrat(self.x + point.x)
def __str__(self):
return f'Kwadrat {self.x}'
p1 = Kwadrat(3)
p2 = Kwadrat(2)
p3 = p1 + p2
print(p3) |
8fa845bf5ce0f4a3b269d6f584180218db85e0de | Nick-FF/Python-Basics | /Car.py | 1,369 | 3.9375 | 4 | class Car:
speed = 60
color = "red"
name = "DeLorean"
is_police = False
def go(self):
print("Машина поехала")
def stop(self):
print("Машина остановилась")
def turn(self, d):
if d:
print("Поворот направо")
else:
print("Поворот налево"... |
62f04c0f44a5bb271b794b869c39e60de871d2d6 | DKU-STUDY/Algorithm | /programmers/난이도별/level02.땅따먹기/Go-yj.py | 1,384 | 3.578125 | 4 | '''
링크 : https://programmers.co.kr/learn/courses/30/lessons/12913#
문제 : 땅따먹기
처음에는 index가 같을 때 (직전 반복에서의 두번째로 큰수+지금의 제일 큰수),
(직전 반복에서의 제일 큰수+지금의 두번째로 큰 수)를 구해서 비교해서
answer에 바로바로 더하고 수정하는 방식으로 풀이하였습니다.
그러니까 풀이도 너무 복잡해지고 다 틀렸다고 나와서 다른 사람들 질문을 보고
동적 프로그래밍을 사용해야 하는 문제임을 알았습니다.
index가 같을 때는 직전에서 두번째로 큰 값을,
index가 다를 때는 직전에서 ... |
c83b1c78f68bfd5538e0984662394ee0d98713d7 | wienerjon/Futoshiki-Puzzle-Solver | /sourceCode.py | 9,915 | 3.6875 | 4 | def readInput(filename): # reads the input file and returns the initial board
# and the inequality constraints
f = open(filename, "r")
initialValues = []
for x in range(5): # get the initial board
line = f.readline()
lineArray = line.split()
lineArray... |
63532875dceb1babfb82fe871b627bd0c7632b38 | Vhyun/eureka-lang | /Python3/loop.py | 277 | 4.34375 | 4 | print("Now let's learn more about loops in python")
print("Suppose we have to print numbers from 1 to 10")
#for loops
for number in range(1, 11):
print(number)
print('print even numbers upto 20')
#while loop
i = 1
while i<20:
if i%2==0:
print(i)
i = i+1
|
f48a6ac6a0e1c4e07260655348d3c0df145533f2 | jamwomsoo/Algorithm_prac | /2018 카카오 블라인드 테스트/셔틀버스.py | 1,446 | 3.609375 | 4 | def turn_to_hour(second):
hour = second//60
second %=60
if 0<=hour<10:
hour= '0'+str(hour)
else:
hour = str(hour)
if 0<=second<10:
second ='0'+str(second)
else:
second = str(second)
return hour+':'+second
def solution(n, t, m, timetable):
answer = ''
t... |
fba389b27e0a398436b61ec86627f08919fc9991 | Mschikay/leetcode | /3longestsubstring.py | 1,578 | 4.15625 | 4 |
'''
append是作为一个整体追加
extend是整体且字符串会被拆分
insert是整体并且是特定位置添加
'''
#这是最长子序列????
# def solve(string):
# length = 1
# i = 1
# res = [string[0]]+[""] * (len(string)-1)
# while i < len(string):
# res[i] = res[i-1]
# if string[i] not in res[i]:
# res[i] = res[i] + string[i]
# ... |
31e0b564c54aac12450e149d92cba33cff7ec90a | vickyliau/CensusClassificationAPI | /test_predict.py | 5,070 | 3.765625 | 4 | """
Unit Tests for Income Prediction
author: Yan-ting Liau
date: October 16, 2021
"""
import pandas as pd
from app.predict import Income, incomemodel
from fastapi.testclient import TestClient
model = incomemodel()
from app.main import app
client = TestClient(app)
def test_preprocessing():
"""
Test whether... |
2a5fbdcbee9c893a7f4a1c0dea7eb64df864bdac | turamant/Chess | /chess_1.py | 1,700 | 4.0625 | 4 | class ChessFigure:
"""Chess piece class"""
IMG = None
def __init__(self, color):
self.color = color
def __repr__(self):
return self.IMG[self.color]
class Pawn(ChessFigure):
IMG = ('♙', '♟︎')
class King(ChessFigure):
IMG = ('♔', '♚')
class Queen(ChessFigure):
IMG = ('♕', ... |
1620f97ff4084b3a688b14ac61e94fb31fdf37a7 | misteraekkyz/CP3-Aekkarat-Phoburana | /Assignments/Lecture53_Aekkarat_P.py | 172 | 3.875 | 4 | def vatCalculator(totalPrice):
result = totalPrice+(totalPrice*7/100)
return result
Price = int(input("Enter Price : "))
print("Total is : ",vatCalculator(Price))
|
948c7f81b1251819eb5be208fefa6a79e7e8a091 | GabrieldeBlois/matchingCourse | /src/code/multivariate_analysis/titanic/pandas_infos.py | 1,063 | 3.671875 | 4 | import pandas as pd
# Load the data to a pandas dataframe
df = pd.read_csv("./input/titanic.csv")
# general info on the dataframe
print('---\ngeneral info on the dataframe')
print(df.info())
# print the columns of the dataframe
print('---\ncolumns of the dataset')
print(df.columns)
# print the first 10 lines of the... |
d2d84244449b3a935abc18e37d62a852399c0ca4 | Manas02/Advent-of-code | /day-5/day-5-2.py | 509 | 3.546875 | 4 | def fun(string):
a = []
for i in string:
if i == 'F' or i == 'L':
a.append('0')
elif i == 'B' or i == 'R':
a.append('1')
return ''.join(a)
with open('input.txt') as f:
data = f.read().splitlines()
b = []
for line in data:
row = int(fun(line[:7]), ... |
604d34285aeb11a89fd1db4156bc6ac983109b6c | lillySingh90/heroVsMonsterGame | /main_console.py | 1,216 | 3.578125 | 4 | import threading
import time
# global variables
hero_health = 40
orc_health = 7
dragon_health = 20
def thread_orc():
global hero_health
global orc_health
while orc_health > 0 and hero_health > 0:
time.sleep(1.5)
hero_health = hero_health - 1
print("Orc attacked... Hero health: ", ... |
b1e6d69006f60a34ce11e84ee72eae00c4f95a6f | joshfinnie/advent-of-code | /2020/day-06/part1.py | 204 | 3.65625 | 4 | import sys
def calc(string):
count = 0
for line in string.split("\n\n"):
count += len(set(line) - {' ', '\n'})
return count
with open(sys.argv[1]) as f:
print(calc(f.read()))
|
3fcaa8080d2ddc63113c9187da9c4ef7be12d943 | elliotjberman/algorithms | /pt2_week3/knapsack_recursive.py | 566 | 3.65625 | 4 | # Come back to this
import time
loaded_items = []
with open('knapsack_big.txt') as f:
first = True
for line in f:
split_line = line.split()
if first:
knapsack_size = int(split_line[0])
else:
loaded_items.append((int(split_line[0]), int(split_line[1])))
first = False
print('Finished reading input')
de... |
a69df3a8f2a55d48982db68729a929d49e482205 | Crisescode/leetcode | /Python/LinkedList/141. linked_list_cycle.py | 1,318 | 3.875 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# https://leetcode-cn.com/problems/linked-list-cycle/
"""
Given head, the head of a linked list, determine if the linked list has a cycle in it.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the ne... |
f93a36c23f3410c95ad85bd074ce2707a4128d06 | jxie0755/Learning_Python | /LeetCode/LC541_reverse_string_ii.py | 1,894 | 3.734375 | 4 | # LC541 Reverse String II
# Easy
# Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string.
# If there are less than k characters left, reverse all of them.
# If there are less than 2k but greater than or equal to k characters, then reve... |
c5f370b570163a20288541dc2c9aa121a8a1f64e | lroolle/CodingInPython | /leetcode/365_water_jug_problem.py | 952 | 3.75 | 4 | """LeetCode 365. Water and Jug Problem
> You are given two jugs with capacities x and y litres. There is an infinite
amount of water supply available. You need to determine whether it is
possible to measure exactly z litres using these two jugs.
If z liters of water is measurable, you must have z liters of water cont... |
7412acf2022c4a9509ddd22859ba8f85422abf57 | fobbytommy/Algorithm-Practice | /10_week_2/nth_largest.py | 386 | 4.34375 | 4 | # Given an array, return the Nth-largest element
from python_modules import bubble_sort
def nth_largest(arr, n):
list_length = len(arr)
if n <= 0 or list_length < n:
return None
sorted_arr = arr
bubble_sort.bubble_sort(sorted_arr)
return sorted_arr[list_length - n]
arr = [23, 32, -2 , 6 ,2 ,7, 10, 3, 10, ... |
6ae77b4b8678cac5f7a6b75d90b71cedabd41815 | thomlomDEV/Ascii-Art-Generator | /Main.py | 2,879 | 3.578125 | 4 | from PIL import Image
import os
file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'Image')
img = Image.open(os.path.join(file_path, 'kubrick.jpg')).convert('L')
pixel = img.load()
(img_width, img_height) = img.size
if img_width > 700 or img_height > 700:
print('This image is too large, for you... |
8625566b08c25ec900699d671a91bd25547e3085 | mongoz/Osnovy_prog_HSE | /week_1/q8.py | 432 | 4.03125 | 4 | """Дано трехзначное число. Найдите сумму его цифр.
Формат ввода
Вводится целое положительное число.
Гарантируется, что оно соответствует условию задачи.
Формат вывода
Выведите ответ на задачу."""
n = int(input())
total = 0
for i in str(n):
total += int(i)
print(total)
|
f04114b30ca2d3b8cbcb9f0eff405810bd90c4b1 | solouniverse/Python | /B2BSWE/Patterns/Prog_Asterisk.py | 245 | 4.28125 | 4 | print("Enter no of rows and columns to print asterisk")
rows = int(input("Enter no of rows: "))
columns = int(input("Enter no of columns: "))
for row in range(rows):
for col in range(columns):
print("*", end="")
print(end="\n")
|
7ca7a538f4c565f9374b407f664d9e4512f9344d | weizhengda/Python3 | /code/4.第四章/5.集合/set.py | 527 | 3.671875 | 4 |
## 1. 集合的特性
## 1.1 set是无序的,没有下表索引,不支持列表的所有方法
type({1,2,3,4,5,6}) ## class 'set'
## 1.2 集合是不重复的
{1,1,2,2,3,3} ## {1,2,3}
## 2. 集合的方法
1 in {1,2,3} ## true
1 not in {1,2,3} ## false
## 集合的差集
{1,2,3,4,5,6} - {3,4} ## {1,2,5,6}
## 集合的交集
{1,2,3,4,5,6} & {3,4} ## {3,4}
## 集合的合集
{1,2,3,4,5,6} | {3,4,7} ## {1,2... |
96888613b588ec1022a4bb52e8ba0368110174e9 | Inverseit/fifteen-puzzle | /gamelogic.py | 3,748 | 3.8125 | 4 | import random
# from pynput import keyboard
import os
# Provides the game core for fifteen game
class GameLogic():
def __init__(self, n):
self.n = n
self.board = self.getInitBoard()
self.goal = self.getInitBoard()
self.empty = (self.n-1, self.n-1)
def isGameOver(self):
r... |
605a258ba6e0b9d475179b3b0bf0f642034df6c2 | AndrewWoodcock/Advent-of-Code-2020 | /Advent_of_Code_9.py | 1,780 | 3.546875 | 4 | # Part 1 Unsolved
import itertools
# xmas_data = "xmas_test.txt"
xmas_data = "xmas.txt"
# g_preamble = 5
g_preamble = 25
def get_file_data(filename: str) -> list:
with open(filename, "r") as file:
return [int(line.strip()) for line in file]
def check_sum(lst: list, num: int) -> bool:
for x, y in i... |
9b525f3ef49aaecc2dcb412a13f7304c8844ded1 | Python51888/CCY | /求一个数的阶乘.py | 523 | 3.828125 | 4 | #递归函数
# def f(num):
# if num <= 1:
# return 1
# return f(num-1)*num
# pass
# if __name__ == '__main__':
# print(f(5))
'''
n!=1×2×3×...×n n!=1×2×3×...×(n-1)n
n的阶乘是求n与(n-1)阶乘的乘积
前提是: n>=1
'''
#非递归实现
#假如求10的阶乘 1*2*3*4*5*6*7*8*9*10
def func(num):
res = 1
for item in range(1,num+... |
4713647128033982db4c5a5e22f9c2498a760e56 | nilobud/Python_Learning | /fractal_tree.py | 358 | 3.875 | 4 |
import turtle
def tree(branchLen,t):
if branchLen > 5:
t.forward(branchLen)
t.right(20)
tree(branchLen-15,t)
t.left(40)
tree(branchLen-15,t)
t.right(20)
t.backward(branchLen)
t = turtle.Turtle()
t.shape("turtle")
t.left(90)
t.speed(0)
t.up()
t.backward(100)... |
e873d675cb9b0e5dcb08dadb143d6985503428f9 | Jordanzuo/Algorithm | /doublylinkedlistwithtail.py | 2,462 | 4.03125 | 4 | #!/usr/bin/python3
class Node:
def __init__(self, data):
self.data = data
self.prev = None
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def get(self, data):
if self.head == None:
return None, False
... |
1406b5098a2a3200dfabddba97bd8ac987e5da80 | Ivan1931/pcog | /pcog/messages.py | 1,476 | 3.6875 | 4 | from typing import List
class MessageType(object):
EXIT = -1
POSITION_UPDATE = 0
HEALTH_UPDATE = 1
ENTITY_WATER_SOURCE = 2
ENTITY_PREDATOR = 3
ENTITY_PREY = 4
WORLD_ENTITY = 15
NEW_PERCEIVED_AGENT = 5
REMOVE_PERCEIVED_AGENT = 6
STAMINA_UPDATE = 7
HUNGER_UPDATE = 8
TH... |
705a5f076bf082fed7388a117a899aac8d0ccd75 | ynonp/ex11-demo-solutions | /11_1.py | 204 | 4.09375 | 4 | list = []
counter = 1
for num in range(10):
print(counter, " from 10")
number = int(input("enter number\n"))
list.append(number)
counter += 1
print("the max num in list is: ", max(list))
|
14aac63a7916522ba61f381ce44deaba082c1103 | trohit920/leetcode_solution | /python/476. Number Complement.py | 1,056 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.
#
# Note:
# The given integer is guaranteed to fit within the range of a 32-bit signed integer.
# You could assume no leading zero bit in t... |
f41896cd4099aa04c78d9b01828448ec05ba8cef | Langesae/NEAT-Stocks | /Data/wrapper.py | 1,624 | 3.8125 | 4 | import stockprediction as prediction
import os
import csv
import pandas as pd
import xlrd
stock = ''
stocks = ['AXP', 'BAC', 'BRK.B', 'CB', 'C', 'CME', 'GS', 'JPM', 'USB', 'WFC']
buyPre = 5
sellPre = 5
percentage = 0
buy = False
sell = False
hold = False
FileName = os.getcwd()
def calc (file, buyPre, sellPre, buy , ... |
9d7e4f2bb0d891d66e1cebdd22b2c6545833fb0b | LiYingbogit/pythonfile | /ustc_12_高级变量.py | 721 | 4.21875 | 4 | # 列表的操作
name_list = ["小明", "大飞", "小红", "小红"]
# 取值取索引
print(name_list[2])
print(name_list.index("大飞"))
# 修改
name_list[1] = "大大飞"
# 增加
name_list.append("小花")
# 删除
name_list.remove("小明")
# 插入
name_list.insert(1, "小梅")
# 扩展
temp_list = ["dafei", "daet"]
name_list.extend(temp_list)
# pop默认可以把最后一个数据删除
name_list.pop()
# pop可以... |
e7a6a64817e8ff7e5f57cd9bbeb7ca9051c0634a | wahdanEw/Python-Rock-Paper-Scissors-game | /game.py | 1,450 | 4.15625 | 4 | print ("***********************************")
print ("WELCOME TO ROCK, PAPER, SCISSORS")
print ("***********************************")
ans = 'yes'
x = input('whats your name?:')
b = input('and your name?:')
print('\nHello, ' + x)
print('Hello, ' + b)
while (ans != 'no'):
player = x
stuff_in_string = "\n{}, do you... |
6f5a32061557d7348b6d842dfb98839d7c6b8ab7 | LinyiGuo96/PythonNotes | /One Python Course Notes/course3/Chap02/hello copy.py | 216 | 3.953125 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
x=123
print('Hello, World. {}'. format(x)) #python3
print('Hello, World. %d' %x) # python2, will be removed in the future perhaps
print(f'Hello. {x}') |
ca8943d7e6d79d55d8259bd68627ab91c654ea74 | BIDMAL/codewarsish | /HackerRank/Data Structures/Trees/Binary Search Tree Lowest Common Ancestor.py | 1,464 | 3.609375 | 4 | class Node:
def __init__(self, info):
self.info = info
self.left = None
self.right = None
self.level = None
def __str__(self):
return str(self.info)
class BinarySearchTree:
def __init__(self):
self.root = None
def create(self, val):
i... |
787bf57b8ce7d389d9ab2a02cdcaccfe12253ce4 | NULLCT/LOMC | /src/data/145.py | 869 | 3.609375 | 4 | def PaintColor(color):
if color == "r":
return "b"
else:
return "r"
import queue as q
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N - 1):
ai, bi = map(int, input().split())
G[ai - 1].append(bi - 1)
G[bi - 1].append(ai - 1)
q = q.Queue()
color = ["... |
734f584fd9bd7dfe0dbc205e086e8ba70ab00e5e | zjh0324/python | /demo03.py | 1,384 | 3.890625 | 4 |
# class 声明类的名字
# 类的名字首字母必须大写
# 面向对象编程
# 类里面所有的方法都必须传一个参数,叫self
class Girlfriend():
def __init__(self,sex,high,weight,hair,age):
self.sex = sex
self.high = high
self.weight = weight
self.hair = hair
self.age = age
def caiyi(self,num):
if num == 1:
... |
751259a41010803fe7117e20d5ef5c69d3a69d73 | reroes/ejemploSiete | /c8/demo.py | 92 | 3.78125 | 4 |
"""
Es un ejemplo de Python
"""
c = 100
i = 0
while i < c:
print(i)
i = i + 1
|
d77ed6bc12657ce144d3cf5db3182821474463d1 | mihirkelkar/languageprojects | /StInt/mirror_image_trees/tree_mirror_images.py | 1,196 | 3.8125 | 4 | class Node(obejct):
def __init__(self, value):
self.value = value
self.left = None
self.right = None
class BsTree(object):
def __init__(self):
self.root = None
self.traversal_list = list()
def addNode(self, value, root = None):
root = self.root if root is None else root
if value <=... |
4f12899c93f8a40e31551c8f24d15cdf05ed02a1 | shchoice/TIL | /Python/OOP/test.py | 250 | 3.703125 | 4 | characters = 'ABCDE'
codes = list(filter(lambda character: character > 66, map(ord, characters)))
print(codes) # 67, 68, 69]
characters = 'ABCDE'
codes = [ord(character) for character in characters if ord(character) > 66]
print(codes) # 67, 68, 69]
|
838a5bc9142e3714e281399aaf1698428f0262e1 | advenral/Exercise | /5.11.py | 428 | 3.9375 | 4 | #Ex1
word= ['a', 'b']
print(word)
first= word[-2]
print("The first word is "+ first+ ".\n")
a= [2, 3, 4]
tmp= []
for i in a:
tmp.append(i)
tmp[-1]= 'last'
print(a, tmp)
#Ex2
num= list(range(9, 15, 2))
print(num)
num[0]=12
print('change the first num')
print(num)
add= sum(num)
print('\nSum is')
print(add)
print(... |
ceb9510a6489f72b41888aa08cee6b985c0bb013 | tomosh22/practical-5 | /page_rank.py | 5,266 | 3.5625 | 4 | import os
import time
from progress import Progress
from random import choice
WEB_DATA = os.path.join(os.path.dirname(__file__), 'school_web.txt')
def load_graph(fd):
"""Load graph from text file
Parameters:
fd -- a file like object that contains lines of URL pairs
Returns:
A representation of ... |
cfb861732cb661fc8dada1bf968b8750f17af0ea | osipov-andrey/control_bot | /core/_helpers.py | 424 | 3.546875 | 4 | from enum import Enum
class ArgType(Enum):
STR = "string"
INT = "integer"
LIST = "list"
# USER = "user"
class Behavior(Enum):
USER = "user"
ADMIN = "admin"
SERVICE = "service"
# fmt: off
def get_log_cover(cover_name: str) -> str:
cover = (
f"\n{'#'*20} {cover_name} {'#'*20}... |
b75ffd4f6d95878ab191bc54b6a68e0d8bfc4811 | rupali23-singh/list_question | /marks1.py | 378 | 3.671875 | 4 | student_marks=[23, 45, 67, 89, 90, 54, 34, 21, 34, 23, 19, 28, 10, 45, 86, 87, 9]
index=0
less_than50=0
more_than50=0
while index<student_marks:
marks=student_marks[index]
if marks<50:
less_than50=less_than50 + 1
else:
more_than50=more_than50 + 1
index = index + 1
print("Marks more than ... |
4512596ae02c224d1d8dab5b62dc543ed48431d2 | Aasthaengg/IBMdataset | /Python_codes/p03213/s464282704.py | 1,664 | 3.5625 | 4 | class PrimeFactor():
def __init__(self, n):
"""
エラトステネス O(N loglog N)
"""
self.n = n
self.table = list(range(n+1)) # 最小素因数のリスト
self.table[2::2] = [2]*(n//2)
for p in range(3, int(n**0.5) + 2, 2):
if self.table[p] == p:
for q ... |
61927de9142a7f9c1f9d687155635e3185e71b74 | dolonmandal/PySnake | /PySnake.py | 1,738 | 3.859375 | 4 | import random
import curses
from curses import textpad
# initialising the screen
s = curses.initscr()
curses.curs_set(0)
# height and the width of screen
sh,sw=s.getmaxyx()
# opening new window
w = curses.newwin(sh,sw,0,0)
w.keypad(1)
w.timeout(100)
# initial positions of the snake(left center)
snk_x = sw/4
snk_y = sh... |
ad553e4760e84862625d497a75c09af3d6a53451 | yameenjavaid/University-projects-1 | /Collecto Python/final-programming-project-kelvin-collecto/Program/ball.py | 482 | 3.515625 | 4 | from Program.helpers.constants import Constants
class Ball:
def __init__(self, color):
self.color = color
self.neighbors = []
self.diameter = Constants.DIAMETER
self.position = 0
def set_position(self, position):
self.position = position
def get_position(self):
... |
f87f170ec9fca8bd20380f220561f0a0beefe3ae | rookie-LeeMC/Data_Structure_and_Algorithm | /leetcode/maxSubArray.py | 1,103 | 3.875 | 4 | '''
给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
示例:
输入: [-2,1,-3,4,-1,2,1,-5,4],
输出: 6
解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。
进阶:
如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。
'''
a = [0, 1, 2, 3, 4, 5]
print(a[1:2])
def maxSubArray(nums):
# if len(nums) == 1:
# return nums[0]
#
# max_sub_sum = nums[0... |
3b5864b671ddedb503da3b9725ad37e0b0a18c17 | sarahsam29/cs344 | /homework1/TSP.py | 2,897 | 3.90625 | 4 | """
The travelling Salesman Problem solved by local searches (Hill Climbing and Simulated Annealing)
@author: ss63
@date: February 23, 2019
@purpose: for CS 344
"""
from search import Problem, hill_climbing, simulated_annealing, \
exp_schedule, genetic_search
from random import randrange
import random
import math... |
98a9ce079c9b5c8602f4a95494b8e71a58e8c5ea | kottenator/code.kottenator.com | /src/project/auth/helpers.py | 339 | 3.75 | 4 | import types
def hide_key(key, hide=lambda s: s // 2):
"""
Hide part of the key and return e.g. 'abc***123'.
"""
key_len = len(key)
if isinstance(hide, types.FunctionType):
hide = hide(key_len)
before = (key_len - hide) // 2 + 1
after = before + hide
return key[:before] + '*... |
d7e6895b6101af4dd5a1048c6d021d4631a630d8 | Jiezhi/myleetcode | /src/876-MiddleOfTheLinkedList.py | 1,841 | 4.03125 | 4 | #!/usr/bin/env python
"""
CREATED AT: 2021/12/28
Des:
https://leetcode.com/problems/middle-of-the-linked-list/
GITHUB: https://github.com/Jiezhi/myleetcode
Difficulty: Easy
Tag:
See:
Ref: https://leetcode.com/problems/middle-of-the-linked-list/solution/
Time Spent: min
"""
from typing import Optional
from list... |
a39336bc7c1e0fb707af3de658152a03261f9b3c | alvas-education-foundation/albinfrancis008 | /coding_solutions/coding24.py | 416 | 3.984375 | 4 | #1) Python Program to read the number and compute the series.
n=int(input("Enter a number: "))
a=[]
for i in range(1,n+1):
print(i,sep=" ",end=" ")
if(i<n):
print("+",sep=" ",end=" ")
a.append(i)
print("=",sum(a)) print()
#2) Python program to count number of digits in it.
n=int(input("Enter number:"))
c... |
4c41c59b36be5474ffceb999e2a37d85092f5155 | dharmesh-coder/Full-Coding | /Hackerrank/Anagram.py | 105 | 3.78125 | 4 | a=input()
b=input()
a=sorted(a)
b=sorted(b)
if(a==b):
print("Anagram")
else:
print("NOt Anagram") |
1871e5992827dbfa17966ccfbd99a9fcfd3203cf | JGhost01/Fundamento-ejecicios | /ejercicio_8.py | 716 | 4 | 4 | #Modificar el ejercicio #7 para obtener el número de elementos únicos en la lista de compras. Por ejemplo: Si
#agrego dos veces “arroz”, solo me debería contar uno.
#Para agregar un ítem a la lista solo basta agregar su nombre.
#Al final solo se requiere que se muestre:
#- El número total de ítems agregados a la lista ... |
2c8eab55bb5bef1a37081c409e825edf878a5db5 | darrylpinto/TA-Tracker | /heap.py | 6,244 | 4.15625 | 4 |
class Heap:
"""
The heap consists of:
:slot heap_array: The list of Student objects (list)
:slot heap_size: Current Heap Size (int)
"""
__slots__ = ('heap_array', 'heap_size')
def __init__(self):
"""
The constructor of Heap
"""
self.heap_ar... |
e29cca918ffc87e1c5da845254bfc02716d59b6c | MrHamdulay/csc3-capstone | /examples/data/Assignment_6/sttbar001/question2.py | 1,059 | 3.859375 | 4 | """ vector equations
barak setton
20/04/2014
"""
import math
vectorsum = []
vectorin = input("Enter vector A: \n") # creating the vectors
vectorpart = vectorin.split(" ")
vectorin = input("Enter vector B: \n")
vectorpart2 = vectorin.split(" ")
vector = [[eval(vectorpart[0]),eval(vectorpart[1]),eval(vectorpar... |
b62b7af3f8c5180214d683101d6a48518052c586 | sangwoo0727/Algorithm | /LeetCode🥇/LeetCode_3_Longest_Substring_Without_Repeating_Characters.py | 1,095 | 3.640625 | 4 | class Solution:
def length_of_longest_substring(self, s: str) -> int:
return binary_search(len(s), s)
def binary_search(size: int, s: str) -> int:
left: int = 0
right: int = size
answer: int = 0
while left <= right:
middle = (left + right) // 2
if check(middle, s):
... |
d6ebd46e30c9bdad567373f228dfe8bb838de364 | vivienyuwenchen/InteractiveProgramming | /models.py | 5,017 | 3.875 | 4 | import os, sys
import pygame
from config import *
class Obstacle:
"""A square obstacle, defined by its top left hand coordinate, length, and color.
Also takes in screen as an argument to draw the obstacle."""
def __init__(self, obs_x, obs_y, obs_len, screen, color):
"""Initialize the instance."""... |
0395423a7152a1b959b9f46672b42dc9f71481ba | HalfMoonFatty/F | /082. Next Permutation.py | 3,000 | 3.890625 | 4 | '''
Problem:
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement must be in-place, do not allocate extra memory.
Here ... |
f282e4580c8095c1704409fc073e418d48d7757f | PFPCrunch/Vending-machine-thing | /Vending_Machine_Assignment/vendingMachine.py | 2,993 | 4.0625 | 4 | '''
Objective: Make program that acts like a vending machine; have items that have individual prices,
have user input float representing an amount of money, user buys a thing if they have enough money input,
give change in fewest coins possible, if not enough money input, make fun of user for not having enough theor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.