blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
887d7d7c1863ebf6939a008884b137af0063f2f8 | W17839213903/git111 | /python/lianxi.py | 5,529 | 3.6875 | 4 | #list(列表) srt(字符串) float(浮点数) tuple(元组) dict(字典) int(整数) bool(布尔值)
#none(空值) set(集合)
#第一个内置函数type(变量名) 产看数据类型
# a=89
# print(type(a))
# a='wuldss'
# print(type(a))
# a=input('<<<<')
# b=a.split()
# b.sort()
# print(b)
# a=input('<<<<')
# b=a.split()
# b.sort()
# a1=int(b[0])
# a2=int(b[1])
# a3=int(b[2])
#... |
6bafb17cbaa6a88d397a9dd4b1276d556f01a17c | W17839213903/git111 | /python/gwc.py | 1,340 | 3.625 | 4 | #!/usr/bin/env python
# -*- coding:utf -* -*-
a=int(input('请输入总资产'))
goods = [
{'name': '电脑', 'price': 1999},
{'name': '鼠标', 'price': 10},
{'name': '游艇', 'price': 20},
{'name': '美女', 'price': 998}
]
for i,j in enumerate(goods):
print(i+1,j['name'],j['price'])
print('已进入购物车,按exit退出购物车')
# whi... |
00416619ea6ea655e17b97004be54dd70b890faa | swarnim321/ms | /dataStructures_Algorithms/longest_common_Prefix.py | 525 | 3.765625 | 4 | def commonPrefix(strs):
lcp=""
if (len(strs)==0):
return lcp
minLen = len(strs[0])
for i in range(len(strs)):
minLen = min(len(strs[i]), minLen)
strng= strs[0]
for i in range(minLen):
for j in range(1,len(strs)) :
print(strs[j][i])
i... |
84956569572fc36cd921466ffc0c4c422e5668c3 | swarnim321/ms | /dataStructures_Algorithms/search.py | 404 | 3.9375 | 4 |
lst=[]
size = int(input("enter the size of the array"))
#j=size-1
for i in range(size):
val = int(input("enter the elements in the array on by one"))
lst.append(val)
x=int(input("enter the elements to be searched"))
for i in range(0,size):
if i==size-1:
print("No")
eli... |
e7dbe559e2c6f96e669e93aac9f6d610da5d27b9 | swarnim321/ms | /dataStructures_Algorithms/substring.py | 756 | 3.734375 | 4 | def check(strng,substrng):
count=0
j=0
for i in range(len(strng)):
if j==len(substrng):
print("true")
exit(1)
elif strng[i]==substrng[j]:
count+=1
j+=1
print(count)
else:
j=0
print("False")
... |
6e87b011e0c5d271b6773eed9243e7095838e01f | swarnim321/ms | /dataStructures_Algorithms/vowels.py | 404 | 3.625 | 4 | import heapq
vowels=['a','e','i','o','u']
strng=str(input("enter the string"))
dic={}
max_heap=[]
heapq.heapify(max_heap)
for i in range(len(strng)):
if strng[i] in dic:
dic[strng[i]]+=1
else:
dic[strng[i]]=1
for key,value in dic.items():
heapq.heappush(max_heap,[-value,key])
... |
ba71dc4cd012e6e35c6c3ed46d6212f0f82f06fb | swarnim321/ms | /dataStructures_Algorithms/merge_sorted_linked_list.py | 507 | 3.78125 | 4 | def mergeLists(head1, head2):
main = temp = node()
if head1 is None:
return head2
if head2 is None:
return head1
while head1 is not None or head2 is not None:
if head1.data <head2.data:
current = head1.data
head1 =head1.next
if head2.data... |
b7283ba7e0fb5d90bc1abf8113b6cb799e9f0d4a | swarnim321/ms | /dataStructures_Algorithms/reverse.py | 244 | 3.796875 | 4 | size=int(input("enter the size of the array"))
print("enter the elements of the array")
lst = list(map(int,input().split(" ")))
for i in range(size//2):
temp= lst[i]
lst[i]= lst[size-i-1]
lst[size - i - 1]=temp
print(lst)
|
dcf4456d331bfd6c3aa560503a4c288c60c4b277 | swarnim321/ms | /dataStructures_Algorithms/anti_diagonal.py | 1,314 | 3.953125 | 4 | def anti_diagonal(mat):
m=len(mat)
n=len(mat[0])
for col in range(m):
startcol=col
startrow=0
while startcol>=0 and startrow<m:
print(mat[startrow][startcol], end=" ")
startrow+=1
startcol-=1
print()
for i in range(1,n)... |
4f9e9241ebdd4405e5794463f1af684c6a6502cf | iamdarshan7/Python-Practice | /formatting.py | 1,296 | 3.890625 | 4 | # person = {'name': 'Jenn', 'age': 23}
# sentence = 'My name is {} and I am {} years old.'.format(person['name'], person['age'])
# print(sentence)
tag = 'h1'
text = 'This is a headline'
sentence = '<{0}><{1}></{0}>'.format(tag, text)
print(sentence)
# class Person():
# def __init_(self, name, age):
# s... |
22b96428465ba2920dda4a9519b7845c900811d2 | iamdarshan7/Python-Practice | /special.py | 974 | 3.8125 | 4 | class Employee:
raise_amt = 1.04
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.email = first + '.' + last + '@email.com'
self.pay = pay
def fullname(self):
return '{} {}'.format(self.first, self.last)
def apply_raise(self):
... |
1debc549e8b99c3d09c91e837ae03551d4dd4a6d | sunm22/final-project-SI206 | /population_data.py | 6,010 | 3.734375 | 4 | import requests
import sqlite3
import json
import os
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
#
# Name: Mingxuan Sun
# Who did you work with: Tiara Amadia
#
def setUpDatabase(db_name):
'''This function takes in the name of the database, makes a connection to server
using nane given, an... |
0cb59c4b644410eb0e48ff890e844b55bd2221e8 | nss-day-cohort-18/bank-teller | /bank.py | 736 | 3.875 | 4 | import locale
class BankAccount():
def __init__(self):
self.balance = 0
self.account = None
def add_money(self, amount):
"""Add money to a bank account
Arguments:
amount - A numerical value by which the bank account's balance will increase
"""
self.balance += float(amount)
def w... |
9f9e207b57d42ed716c9d1acfb00c10de98c014f | LizBaker/Data-Structures | /binary_search_tree/binary_search_tree.py | 916 | 3.6875 | 4 | class BinarySearchTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def insert(self, value):
if value > self.value:
if self.right is None:
self.right = [value]
else:
self.right.append(value)
elif value < self.value:
if self.... |
744631ed71bbb2e308a85b42baca861a5f5f0b02 | Samana19/Employeemgmt | /Management.py | 13,040 | 3.875 | 4 | from tkinter import *
import tkinter.ttk as ttk
import tkinter.messagebox as tkMessageBox
import sqlite3
# function to define database
def database():
""" database function is used to create table with specifies number of columns"""
global conn, cursor
# creating student database
conn = sqlite3.conne... |
9f03da334a6ca63a3835f6a9082d5fa7543dace5 | svn2github/pyquante | /PyQuante/Util.py | 1,031 | 3.9375 | 4 | def parseline(line,format):
"""
Return the line split and with particular formats applied.
Format characters:
x Skip this record
s Convert the record to a string
f Convert the record to a float
d Convert the record to an int
i Convert the record to an int
Exampl... |
d3d9a97c2707e954968d6cf037373c8b38a70f53 | robertrbeckett/Tic-Tac-Toe | /tic-tac-toe.py | 4,311 | 4.25 | 4 | #Text-Based Tic Tac Toe (Computer Makes Moves Randomly)
#Using https://repl.it/languages/python3
#Author: Robert Beckett
from random import randint
#This function prints the board. (View section)
def PrintBoard():
print(a1, a2, a3)
print(b1, b2, b3)
print(c1, c2, c3)
print("\n")
#This function checks whether e... |
540aae5486f38c2c8a3954ac15e72f4c64b1d9ad | klaudiar/Lab_02 | /Server.py | 1,306 | 3.75 | 4 | from rock_paper_scissors import *
class Server:
my_choice = 0
def __init__(self, address, port):
self.server(address, port)
def server(self, address, port):
connection = runSocket(address, port)
answer = 0
while answer == 0:
while True:
try:
... |
138922bf805c35255037d86640adc1e8a8dfbf2c | ingoGuzman/SoftArq2020 | /Tutorial_4_PyTest_TDD/fizzbuzz/fizz.py | 232 | 3.53125 | 4 | from checker import has_3
from checker import has_5
def buzz(n):
a=False
for i in range (1,n+1):
a=""
if i%3==0 or has_3(i):
a+="Fizz"
if i%5==0 or has_5(i):
a+="Buzz"
if a=="":
a=i
print(a)
return a
buzz(150)
|
d3d2936f7426bffb68c80b60457f075a8320d215 | emasters603/coding-challenges | /wonders_challenge.py | 576 | 3.796875 | 4 | Cards = ['w/b/s/o', 'w', 's/b', 's'] #for testing can make it raw input
make = "WWSS" #this is the final answer I am seeing if the cards can make
def sort(cards, make):
for i in cards:
i.split("/")
cards.sort() #sorting so it'll hit faster
need = list(make)
need.sort()
while len(need) > 0: #loop until... |
a016e66d51b7afc886f9784b23185622e23f3ad6 | coertquinton/population_subset | /subset.py | 1,626 | 3.5625 | 4 | import itertools
import datetime
import time
class SubsetCalculator(object):
def get_subset(self, my_list, target_number):
for i in range(1, len(my_list)+1):
total_tupple = itertools.combinations(my_list, i)
subset_tupple = self.test_sublist(total_tupple, target_number... |
fb9656e7a916af86eeef3f4ea02d676d0b2bd899 | yungvldai-practice-2020/cv-stream-viewer | /image_processors.py | 246 | 3.515625 | 4 | import cv2 as cv
def scale(image, w, h):
scale_x = w / 320
scale_y = h / 240
width = int(image.shape[1] * scale_x)
height = int(image.shape[0] * scale_y)
return cv.resize(image, (width, height), interpolation=cv.INTER_AREA)
|
77a7141ae39c329f2e4398647c7e3b0c9954ceed | EraSilv/day2 | /def/tipacalcdef.py | 1,006 | 3.546875 | 4 | # def calc(a,b,suf):
# if suf == '*':
# print( a * b )
# elif suf == '/':
# print(a / b)
# elif suf == '+':
# print(a + b)
# elif suf == '-':
# print(a - b)
# elif suf == '%':
# print(a % b)
# n1 = int(input('NO.1: '))
# n2 = int(input('NO.2: '))
# s = input(... |
093dd2b4103c3af5814e06047983dfa877f89e12 | EraSilv/day2 | /Practiceself/day15.py | 2,053 | 3.578125 | 4 | # username = 'ERA'
# print('NAMe: {0}'.format(username))
# print('AGE: {0} yo {1} {2}'.format(24,'Era','Yrysbaev'))
#-----------------------------------------------------------------------------
# num1 = 26
# num2 = 65
# print('{0} + {1} = {2}'.format(num1,num2,num1+num2*2))
#----------------------------------------... |
e42ee3e2ecd1a0fb40359c837fa60cb53644b865 | EraSilv/day2 | /cw/cww.py | 713 | 3.765625 | 4 | # products = {
# 'утюг': 3500,
# 'телевизов': 24000,
# 'стиральная_машина': 30000,
# 'фен': 5500
# }
# a = products['утюг'] + products['телевизов'] + products['стиральная_машина']+products['фен']
# print(a)
# s = a * 0.85
# print('u need only: ',s, 'dollars')
#----------------------------------------... |
c228953849e21432db65957399e9f2b155d60ec7 | EraSilv/day2 | /day5_6_7/Transfermoney.py | 1,140 | 3.84375 | 4 |
print('online shipping from AliEx')
print('way to pay for airpods')
way = (input('PAYMENT: ')).lower()
balance = 6000 #balance
acer = 3500 # costs
if way == 'mastercard':
print('sorry... MS is not maintainig!')
elif way == 'elcard':
print('sorry...Ed is not maintaing!')
elif way == 'visa' or way == 'paypa... |
68097abbf240ee911dfd9cf5d8b1cc60dedb6bf8 | EraSilv/day2 | /day5_6_7/practice.py | 2,677 | 4.3125 | 4 | # calculation_to_seconds = 24 * 60 * 60
calculation_to_hours = 24
# print(calculation_to_seconds)
name_of_unit = "hours"
#VERSION 1:
# print(f"20 days are {20 * 24 * 60 * 60} seconds")
# print(f"35 days are {35 * 24 * 60 * 60} seconds")
# print(f"50 days are {50 * 24 * 60 * 60} seconds")
# print(f"110 days are {110... |
4e8737d284c7cf01dea8dd82917e1fc787216219 | EraSilv/day2 | /day5_6_7/day7.py | 879 | 4.125 | 4 | # password = (input('Enter ur password:'))
# if len(password) >= 8 and 8 > 0:
# print('Correct! ')
# print('Next----->:')
# else:
# print('Password must be more than 8!:')
# print('Try again!')
# print('Create a new account ')
# login = input('login:')
# email = input('Your e-mail:')
# print('Choos... |
dce3ca1360dd31c7888f2dd98b256f39eab1ca15 | taylorbenwright/AdventOfCode2019 | /lib/day01.py | 820 | 3.5625 | 4 |
from math import floor
import helpers
@helpers.timer
def solve_01():
masses = [int(line) for line in open("../inputs/day01.txt", "r").read().splitlines()]
fuel_needs = [(floor(mass / 3) - 2) for mass in masses]
return fuel_needs
@helpers.timer
def solve_02():
masses = [int(line) for line in open("... |
167176ab607d2bc30b88eeb558ce5d71d278347c | ericlarslee/Algorithm_Intro | /Problem_Set/year.py | 1,505 | 3.96875 | 4 | from months import Month
def year_function():
temp_year = Year()
year = tuple(temp_year.month_list)
entry = int(input('which number month are you looking for a holiday in?')) - 1
if year[entry].holidays is not None:
print(f'{year[entry].name} has {year[entry].holiday_name} on {year[entry].holida... |
8d6281cc7b07d7ac5894b3f82495af97a9424dd3 | RaduAlbastroiu/Python-Projects | /Home Projects/Homework number 1.py | 7,551 | 4 | 4 | #
# mainFile.py
#
# Created by Radu Gabriel Albastroiu
#
def matrixRead():
# input reading
print(" Add another matrix, after the last row of the matrix enter an empty row")
matrix = []
while True:
aline = input()
if not len(aline):
break
matrix.append(a... |
2bb0afcd6465edcffe436a298ff3a3abf36246d5 | RaduAlbastroiu/Python-Projects | /Home Project4/RaduAlbastroiu.py | 690 | 4.03125 | 4 | # Homework2 Radu Albastroiu
# Homework number: 2
from Bank import Bank
# bank init, there could be more banks but for ease will use just one
ING = Bank()
comand = 1
while comand > 0:
# command for bank :
# - new account
# - login
# - delete account
comand = int(input("For creating a... |
08a01f3a3fa969e0e40ef89d06b788995d441612 | Sean7419/sort-visualizer | /SortAlgoVis/visualizer.py | 3,989 | 3.65625 | 4 | from tkinter import *
from tkinter import ttk
import random
from sortAlgos import bubble_sort, merge_sort
# Global Variables
data = []
# Functions
def display_data(data, color_list):
"""
This function will clear the old data from canvas and display the new data
data is normalized to allow bars to be sized... |
736fe753e179f2650d038206df41cd0671b48e77 | Naitik-Gandhi/Best-Enlist | /Day2.py | 1,560 | 4.03125 | 4 | Python 3.9.5
>>> print("30 days 30 hour challenge")
30 days 30 hour challenge
>>> print('30 days 30 hour challenge')
30 days 30 hour challenge
>>> Hours = "thirty" print(Hours)
SyntaxError: invalid syntax
>>> Hours = "thirty"
>>> print(Hours)
thirty
>>> Days = "Thirty days"
>>> print(Days[0])
T... |
76f09844a2ee8abc1ebb5d7be2432a9f7b568a93 | Aayushi-Mittal/Udayan-Coding-BootCamp | /session3/Programs-s3.py | 648 | 4.3125 | 4 | """
a = int(input("Enter your value of a: ") )
b = int(input("Enter your value of b: ") )
print("Adding a and b")
print(a+b)
print("Subtract a and b")
print(a-b)
print("Multiply a and b")
print(a*b)
print("Divide a and b")
print(a/b)
print("Remainder left after dividing a and b")
print(a%b)
# Program 2
name=input("Ent... |
3253b6843f4edd1047c567edc5a1d1973ead4b00 | watson1227/Python-Beginner-Tutorials-YouTube- | /Funtions In Python.py | 567 | 4.21875 | 4 | # Functions In Python
# Like in mathematics, where a function takes an argument and produces a result, it
# does so in Python as well
# The general form of a Python function is:
# def function_name(arguments):
# {lines telling the function what to do to produce the result}
# return result
# lets consid... |
0081a9128b1bb5a3c0821900d8fdcd043c4d03bc | HAMZA-420/Word-Search-Game | /WORD SEARCH GAME.py | 20,990 | 4.1875 | 4 | def game():
import random
#A subroutine to replace all "-" (empty characters) with a random letter
def randomFill(wordsearch):
LETTERS="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for row in range(0,12):
for col in range(0,12):
if wordsearch[row][col]=="-":
... |
8b742963ccb231788702ea9f266bbbcf9ae9100d | Amina-Yassin/Steve | /Attempt5.py | 155 | 3.828125 | 4 | print ("N1", '\t', "N2", '\t', "N1 * N2",)
print ("-----", '\t', "-----", '\t', "-------")
for x in range (5,21):
print (x, '\t', x, '\t', x*x)
|
6efa2595801663a5a27dbdf37c3a3d8c5423b8c6 | reyandoneil/BelajarPython | /tipedata_dictionary.py | 474 | 3.90625 | 4 | mahasiswa1 = {"NIM":106,
"Nama":"Anang Nugraha",
"Prodi":"Teknik Informatika",
"Status Mahasiswa":"Aktif"}
mahasiswa2 = {"NIM":104,
"Nama":"Aerosh Nugraha",
"Prodi":"Sistem Informasi",
"Status Mahasiswa":"Aktif"}
print(mahasiswa1["Nama"])
p... |
3dfc2952a75b3645d1ad79c6d21239047f0e16a6 | reyandoneil/BelajarPython | /loopingteknik.py | 886 | 3.546875 | 4 | namaband = ['Noah',
'Ungu',
'Vagetoz',
'Kangen Band',
'Kadal Band']
kumpulanlagu = ['Menunggumu',
'Laguku',
'Kehadiranmu',
'Aku kau dan dia',
'Cinta tak direstui']
#Mengunakan "enumerate" untuk penomoran li... |
ac83e2326fa7af2d2bb63315c52faab99c3de3e3 | reyandoneil/BelajarPython | /list_lanjutan.py | 456 | 3.890625 | 4 | Barang = ['laptop','mouse','cangkir','mangkok','piring']
#method
#method menambah di akhir
Barang.append('sendok')
print(Barang)
#menyisipkan
Barang.insert(3,'keyboard')
Barang.insert(3,'laptop')
print(Barang)
Jumlahlaptop = Barang.count('laptop')
print('jumlah laptop dalam list',Jumlahlaptop)
Barang.remove('cangk... |
a69b5adbcdf6934f43a3f7f424c85071840242e4 | aoishiki/randpoesie | /main.py | 412 | 3.53125 | 4 | # coding=utf-8
import random
import sys
args = sys.argv
if len(args) < 2 :
print("put number")
else :
samplenum = int(args[1])
for line in open('word.txt', 'r') :
wordList = line[:-1].split(',')
listlen = len(wordList)
if samplenum > listlen :
print("引数は",listlen,"以下にしてください")
else :
sampleWords = random.s... |
93276b1fa5e8647e04e1fc34911d427990fea9c1 | pchamburger/AID1910- | /day15/login_db.py | 1,670 | 3.65625 | 4 | """
模拟注册登录
"""
import pymysql
# 链接数据库
db = pymysql.connect(host='localhost',
port=3306,
user='root',
password='123456',
database='dict',
charset='utf8')
# 获取游标(操作数据库,执行sql语句)
cur = db.cursor()
# 注册
def register... |
9d428c28ad55ea61b5471c8d866e3a7f01c3de40 | h-skye/random_work | /tictactoe.py | 3,514 | 3.765625 | 4 |
# 7 | 8 | 9
# --+---+--
# 4 | 5 | 6
# --+---+--
# 1 | 2 | 3
class Board():
def __init__(self):
self.state = [['-', '-', '-'], ['-', '-', '-'], ['-', '-', '-']]
self.num_pad = [['7', '8', '9'], ['4', '5', '6'], ['1', '2', '3']]
self.number_of_moves = 0
def print_avail_spots(sel... |
0455a80b366388a6e0c7c6449f15417bff5472f2 | Peter-Zheng-Sp/SafeBoard | /hackathon_2017_developers/solutions/python/11.sum.of.digits.hard/solve.py | 518 | 3.5 | 4 | # Author: Maxim Yurchuk
def get_count(digit, pos, n):
k = 10 ** (pos + 1)
full_cycles = n / k
count = full_cycles * (10 ** pos)
reminder = n % k
if reminder > (digit + 1) * (10 ** pos):
count += 10 ** pos
else:
if reminder > (digit) * (10 ** pos):
count += reminder -... |
21414bdd6d4af5ff2b2ec2a855d7ef490ad44222 | kumar084/python-challenge | /PyPoll/main.py | 1,251 | 3.53125 | 4 | import os
import csv
# Path to collect data from the Resources folder
election_data = os.path.join( 'Resources', 'election_data.csv')
# Read in the CSV file
with open(election_data, 'r') as csvfile:
# Split the data on commas
csvreader = csv.reader(csvfile, delimiter=',')
print(csvreader)
#Skipping the ... |
16afc21ac9d3c72905afdcb28558ade43a850f52 | piyushkashyap07/Application-of-time-complexity | /arrayintersection.py | 836 | 3.609375 | 4 | from sys import stdin
def intersection(arr1, arr2, n, m) :
arr1.sort()
arr2.sort()
i=0
j=0
while i<n and j<m:
if arr1[i]==arr2[j]:
print(arr1[i],end=" ")
i+=1
j+=1
else:
if arr1[i]<arr2[j]:
i+=1
... |
de12c3cb06a024c01510f0cf70e76721a80d506e | ytlty/coding_problems | /fibonacci_modified.py | 1,049 | 4.125 | 4 | '''
A series is defined in the following manner:
Given the nth and (n+1)th terms, the (n+2)th can be computed by the following relation
Tn+2 = (Tn+1)2 + Tn
So, if the first two terms of the series are 0 and 1:
the third term = 12 + 0 = 1
fourth term = 12 + 1 = 2
fifth term = 22 + 1 = 5
... And so on.
Given thre... |
00d5af5d8a37988279c8958ed760ad506cae2e91 | Aryan985/C-103 | /scatter.py | 184 | 3.796875 | 4 | import pandas as pd
import plotly.express as px
df = pd.read_csv("data.csv")
graph = px.scatter(df,x="Population",y="Per capita",color = "Country",size="Percentage")
graph.show() |
b2d68fcbcf523fc294e6c0e7d5126359c0a78e2c | lomnpi/data-structures-and-algorithms-python | /Helpers/nodes.py | 635 | 3.515625 | 4 | class SimpleTreeNode:
def __init__(self, val, left=None, right=None) -> None:
self.val = val
self.left = left
self.right = right
class AdvanceTreeNode:
def __init__(self, val, parent=None, left=None, right=None) -> None:
self.val = val
self.parent = parent
self.... |
8d97636d1e094ba6070889cc584ad76b1b2aaf4f | pigmonchu/bzChallenges | /dientes_de_leon/diente_leon_v.2.py | 663 | 3.546875 | 4 | import turtle
miT = turtle.Turtle()
'''
Ahora vamos a dibujar dos y para ello vamos a utilizar bucles anidados
'''
#Limpiar pantalla
miT.reset()
#Posición vertical
miT.left(90)
#Diente de leon
miT.pd()
miT.forward(100)
miT.right(90)
miT.pu()
miT.fd(6)
for repes in range (15): #Hacemos 15 repeticiones con un for
... |
2567d52a2276d22ed6dbfc9ec1e9296466682e5e | SH22Hwang/PythonExcercise | /PyPLHomework01/main.py | 553 | 3.625 | 4 | from account import *
def main():
accList = []
accNum = 0
while True:
showMenu()
choice = int(input("선택: "))
if choice == 1:
accList.append(openAcc())
accNum += 1
elif choice == 2:
depositAcc(accList, accNum)
elif choice == 3:
... |
892bbf925fe73bf5dc94d795137eefa927099103 | DalenWBrauner/Sudoku-Generator | /Puzzle.py | 6,573 | 3.921875 | 4 | """
[Name] Puzzle.py
[Author] Dalen W. Brauner
[DLM] 12/31/2013 01:54 PM
[Purpose] To allow for the creation and manipulation of Sudoku
Puzzles.
"""
#
##
### These functions exist primarily to assist Sudoku object functions
### yet are not exclusive... |
a215924f85c43e78eb576ab4c45f40e54eac6bf2 | IngArmando0lvera/Examples_Python | /22 listas detalladas.py | 436 | 3.953125 | 4 | array =["futbool", "pc", 18, 16, [2, 3, 5], True, False]
array.append(66) #agregar datos al final
array.append(True)
array.insert(1,88) #indice 1, registro (dato)
array.extend([1, 88, True, 100]) #Agregamos elementos al final de la lista
print("lista: ",array)
print("longitud: ",len(array))
'''Concaten... |
960c3725f672166836afded6734d7e47914741b4 | IngArmando0lvera/Examples_Python | /9 entrada de datos.py | 215 | 3.84375 | 4 | # Enetrada de datos
cadena = input("¿Como se llama tu proyecto? : ")
print(f"Tu proyecto se llama {cadena}")
cadena = float(input("¿Que version es?: "))
print(f"La version de tu proyecto es {cadena + 1}") |
47cdeb51b084e1d5eff7380fdfd8de18a6dfa60a | IngArmando0lvera/Examples_Python | /21 array listas.py | 737 | 3.96875 | 4 | #seccion 5
'''En las listas podemos almacenar cualquier tipo de datos,
es decir no tiene que ser de un solo tipo la lista'''
array =["futbool", "pc", 18, 16, [2, 3, 5], True, False]
print("\n\nlista: ", array)#imprimir toda la lista
print("\nprimer elemento: ", array[0])#imprime primer elemento
'''el numero se ... |
72ae3e467d970bfce2e8a72f17d6690b69867f02 | FayK12/recruiting-exercises | /inventory-allocator/src/test.py | 4,546 | 3.59375 | 4 | import unittest
from shipment import optimal_shipping, warehouse_purchase
class TestCase(unittest.TestCase):
# test empty shipping list
def test_zero(self):
shipment_order_0 = {}
warehouses = [{ "name": "owd", "inventory": { "apple": 6,"mango": 1, "potato": 1} },
{ "name": "oz", "inventory": {}}, { "n... |
e5e73a0a462812ea6940811e869beceb82702008 | oddaspa/TDT4120 | /Øving 3/pipesortering2.py | 3,631 | 3.640625 | 4 | #!/usr/bin/python3
from sys import stdin
# Alle kall jeg gjør mer enn 1 gang skal få variabel.
# NOTICE: Random quicksort would be better.
def sort_list(A):
less, equal, greater = [], [], []
if len(A) > 1:
pivot = A[0]
for num in A:
if num > pivot:
greater.append(nu... |
9f955e3f839b7646365a142c85bb139c6c1ef292 | oddaspa/TDT4120 | /Øving 4/flexradix.py | 1,510 | 3.921875 | 4 | #!/usr/bin/python3
from sys import stdin
def flexradix(A, d):
# Returns the list A sorted.
# creates a new list of the words sorted after length
list3 = sort_length(A)
return counting_sort(list3, d)
def counting_sort(A, d):
# creates empty list of length of the longest word
list = [0] * d
... |
145bf56b934df223e2c4bc366fc9c62a594f0bf3 | akhilmaskeri/lemonade | /15-puzzle/solver.py | 3,586 | 3.578125 | 4 |
# huge respect to Ken'ichiro Takahashi and Orson Peters
import random
# idea is to use iterative deepning A* search
class Solver:
def __init__(self,h,neighbours):
self.h = h
self.neighbours = neighbours
self.found = object()
def solve(self,root,is_goal,max_cost = None):
self.is_goal = is_goal
self.... |
27f4d3f333ad5eae6ca281be067c92a006b7c180 | Otteri/python-scripts | /ransac/fitline.py | 2,320 | 3.5 | 4 | from numpy import array
import numpy as np
# Finds eigenvectors and values by doing principal component analysis
# @param data_array: data points (x,y) in column vector
# @return: 2D array of eigenvalues and eigenvectors
def sklearn_pca(data_array):
from sklearn.decomposition import PCA
pca = PCA(2)
pca.fi... |
be167e0ae54599d158c82a992c1f37e2a62f646f | AlexanDelimi/PDDYG | /Range_Tree/RangeNode.py | 9,198 | 3.609375 | 4 | class RangeLeaf():
''' Contains a list of points. '''
def __init__(self, point):
self.point_list = [point]
class RangeNode():
'''
Contains a value, left and right children
and the corresponding range tree of the next dimension,
if it has one.
'''
def __init__(self, value):
... |
a62d496faff1b188215e470952c48e6d071bfcab | zid93/MPM_Repository | /Number2.py | 845 | 3.640625 | 4 | def wordSplit(wordList, word):
listoutputword = []
listword = [[False for i in range(len(word))] for x in range(len(word))]
for i in range(1, len(word) + 1):
for j in range(len(word) - i + 1):
if word[j:j + i] in wordList:
listword[j][j + i - 1] = True
lis... |
f69783e7a620ca692a6b6213f16ef06b491b35e5 | lily-liu-17/ICS3U-Assignment-7-Python-Concatenates | /concatenates.py | 883 | 4.3125 | 4 | #!/usr/bin/env python3
# Created by: Lily Liu
# Created on: Oct 2021
# This program concatenates
def concatenate(first_things, second_things):
# this function concatenate two lists
concatenated_list = []
# process
for element in first_things:
concatenated_list.append(element)
for elemen... |
30829d7ff346e374e7024dcdb0783009438a88da | yildirimyigit/irl_sfm | /python_ws/dme_irl/environment.py | 10,499 | 3.5625 | 4 | from bisect import bisect_left
import math
import random
import numpy as np
from utils import *
min_goal_dist = 0.2
min_human_dist = 0.2
# This class initializes actions and states arrays and also has the transaction function
class Environment(object):
# delta_distance : this represents the default distance tha... |
22b50722a6e726a6dc88d61bd5010c898d1f0801 | JulianNymark/stone-of-the-hearth | /soth/player.py | 2,410 | 3.546875 | 4 | from .card import *
from .utility import *
from .textstrings import *
class Player:
"""A player in the game"""
mana = 1
mana_used = 0
overload_now = 0
overload_next = 0
health = 30
armour = 0
damage = 0
attack = 0
def __init__(self, ct, npc=False):
self.classtype = ct
... |
c797ef3f37f49d5a00e88fc2e76d5809ea82e0dd | andrezaserra/pyChess | /src/checker.py | 9,763 | 3.515625 | 4 | import alert
def check_straight_path(board, start, to):
keep_same_line = start[0] == to[0]
if keep_same_line:
smaller_column = start[1] if start[1] < to[1] else to[1]
bigger_column = start[1] if start[1] > to[1] else to[1]
for i in range(smaller_column + 1, bigger_column):
... |
a26846eee4e595884b555310b1b8c9ffec969089 | michaelsprintson/me.nu | /menu_read/just_read_food.py | 4,920 | 3.53125 | 4 | import os
import io
from collections import defaultdict
import json
import re
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
def findprice(usemenu):
price_list = []
for lineidx in range(len(usemenu)):
if is_number(usemenu[lineidx]):
... |
77569a6d1e2e6a9fa3d3d8d7a49d5adf1d924af6 | carlos-hereee/Algorithms | /rock_paper_scissors/rps.py | 848 | 3.71875 | 4 | #!/usr/bin/python
import sys
# generate all possible plays per game where n is the number of plays per round
# You'll want to define a list with all of the possible Rock Paper Scissors plays.
def rock_paper_scissors(n):
# we're building up a list of results
outcome = []
choices = ['rock', 'paper', 's... |
096f74428c55f6898bdb8f646230d823f5acd7c2 | KebadSew/scratch_python | /numpy_2.py | 1,848 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 24 09:51:18 2020
@author: legen
"""
from clear_console import cls
import numpy as np
cls()
# Generate some random data using numpy
data = np.random.randn(2,3) # 2 by 3 array; 2 rows / 3 columns
print(data)
data=data*2
print(data)
print(data + data)
print(data.shape)
... |
894232f801fc4288ba570dbf99ba065ddaf2333d | KebadSew/scratch_python | /tuple1.py | 782 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 22:29:46 2020
@author: legen
"""
from clear_console import cls
cls()
tup = 1,2,3.5,'hello',['a','b','c']
print(tup)
tup[4].append('d')
print(tup)
nested_tup='a','b','c',(1,3,4), 'd',(6,7)
print(nested_tup)
print(tuple("mike world!")[0].upper())
print(tuple(['a','b... |
7994795a5d18192f34008eb09414b943a591f078 | bretcolloff/home | /Python/solutions/inversions/inversions.py | 1,768 | 3.59375 | 4 | import os, sys
from itertools import islice
# def inversionmerge(input):
# length = len(input)
# if len(input) == 1:
# return (0, input)
#
# def merge(left, right):
# resultl = []
# resultc = 0
#
# while left and right:
# if left[0] <= right[0]:
# ... |
ee72d1073360456a8cc824b2892529719d7f8933 | bretcolloff/home | /Python/solutions/ctci/arraysandstrings.py | 2,996 | 3.921875 | 4 |
# Implement an algorithm to determine if a string has all unique characeters.
def onepointone(input):
print("1.1")
print(len(set(input)))
# What if you cannot use additional data structures?
total = 0
lastletter = ''
for letter in sorted(input):
if letter != lastletter:
las... |
1843aaa61cf284ffe9b28291b272823e0ec17b63 | rkhapov/chip8 | /virtualmachine/timer.py | 607 | 3.65625 | 4 | #!/usr/bin/env python3
class Timer:
def __init__(self, count: int =0):
if not isinstance(count, int) or count < 0 or count > 255:
raise ValueError('Timer count must be integer value in range [0;255]')
self._count = count
def decrease(self):
if self._count != 0:
... |
292dcce71348062f01014015df4525d23502d09e | rumman07/python | /IT210/PythonCode/discount.py | 301 | 3.890625 | 4 | #computer bookstore kilobyte day example.
originalPrice = float(input("Please enter thr price: "))
#dicounted rates
if originalPrice < 128:
discountRate = 0.92
else:
discountRate = 0.84
discountedPrice = discountRate * originalPrice
print("Price $%.2f" % discountedPrice)
|
bdba4dfc4df3eb7d21cccfd4b2c4a5db7464bd70 | rumman07/python | /IT210/PythonCode/msog.py | 340 | 3.875 | 4 | str1 = "string1"
str2 = "some other stuff"
str3 = "still more stuff"
print(str1)
print (str2,str3)
str4 = str3 + str3
print(str4)
x = 4
outstr = "the value of x is" + "x"
print(outstr)
in_val = input("Enter an integer diameter of a circle")
print(in_val)
out_val = int(in_val)
print (out_val)
x = out_val... |
3a69e2726e0daddd5219296fbad5ef2b9b1f58ce | rumman07/python | /IT210/PythonCode/Quiz2.py | 375 | 3.75 | 4 | def main():
windSpeed = 0
temp = 0
for i in range (1, 11):
V=i*5
WC = 35.74+0.6215*temp-3.75*V**0.16+0.4275*temp*V**0.16
#temperature
for temp in range (-45, 40, 5):
print (2*" ",temp, end=" ")
print("\n"," "*2,"-"*105)
#Wind Speed
for windSpeed i... |
d368798240b86c8a85f14cd5cab1318474bcdccc | rumman07/python | /IT210/PythonCode/Algorithm3.py | 255 | 4.0625 | 4 | #Prompt utill a match is found
valid = False
while not valid:
value = int(input("Please enter a positive vlaue < 100: "))
if value > 0 and value < 100:
valid = True
else:
print("The value is not valid")
|
4567497d8e02483b5359e568f6d0e793f898e52f | rumman07/python | /IT210/PythonCode/wage.py | 563 | 4.0625 | 4 | #Lab3 Rumman Ahmed
#Read user input hours worked and hourly rate
hours = float (input("ENTER THE HOURS WORKED AS INTEGER"))
rate = float (input("Enter the hourly pay rate as an integer"))
if hours > 40:
gross = 40 * rate + (hours - 40) * rate * 1.5
print ("Overtime")
else:
gross = hours * rate
... |
5c0805b05748c02724627dd96a267b15af9312de | rumman07/python | /recursion.py | 181 | 3.953125 | 4 | #!/usr/bin/python3.8
def printTriangle(sideLength):
if sideLength < 1 :
return
printTriangle(sideLength - 1)
print("[]" * sideLength)
printTriangle(2)
|
cff8a895ec8bbe2c1997d04f5b5f6e1851bc731d | jzaldivar/SciData-tareas | /C01_Tarea02b.py | 527 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
C01.Tarea02b
"""
# Definiciones
estaciones = {'PRIMAVERA': ['abril', 'mayo', 'junio'],
'VERANO': ['julio', 'agosto', 'septiembre'],
'OTOÑO': ['octubre', 'noviembre', 'diciembre'],
'INVIERNO': ['enero', 'febrero', 'marzo']}
# Entradas
me... |
5a0cd3cb52e874fd30351a48375beb2806c2843c | Hbodor/MOPSI | /Longstaff Schwartz (BS , Regression + NN ).py | 8,847 | 4 | 4 | from numpy import linalg, zeros, ones, hstack, asarray
import itertools
def basis_vector(n, i):
""" Return an array like [0, 0, ..., 1, ..., 0, 0]
>>> from multipolyfit.core import basis_vector
>>> basis_vector(3, 1)
array([0, 1, 0])
>>> basis_vector(5, 4)
array([0, 0, 0, 0, 1])
"""
x... |
2015152c0424d7b45235cefa678ea2cb90523132 | ChiselD/guess-my-number | /app.py | 401 | 4.125 | 4 | import random
secret_number = random.randint(1,101)
guess = int(input("Guess what number I'm thinking of (between 1 and 100): "))
while guess != secret_number:
if guess > secret_number:
guess = int(input("Too high! Guess again: "))
if guess < secret_number:
guess = int(input("Too low! Guess again: "))
if gues... |
e9a2f1aa4c0059022f39600a3f73453b07901052 | devil927/Python_ap | /calculator.py | 4,724 | 3.734375 | 4 | # Import library
#===========================================================================================================
from tkinter import *
# Button operation
#==================================================================... |
de0e2524796403090559ac0db966ce3513474396 | kyien/py-proj | /tuples.py | 494 | 4.03125 | 4 | #control/Decision Making statements
#if statement
#if..else statements
#nested if statements
#elif statement
print('*******Starting a transaction*****')
amount=int(input("Enter amount to withdraw: "))
discount=0
if amount <1000:
discount=amount *0.45
print('Net amount is: ', amount+discount)
elif amount <2000:
di... |
16457bef18a30cee6b1014e3ae7a46822ea55bc5 | Robert-Kolodziej/Python-Progams- | /Prog4Kolodziej.py | 1,195 | 3.90625 | 4 | ##Bobby Kolodziej
##
##File: Prog4Kolodziej.py
##
##Purpose: The purpose of this program is to play a random gambling game with dice
##
##Input: The input for this program is the ammount of money the player wants to play with.
##
##Output: The output for this program will be the pot, the value on die 1, the va... |
d8ae1578be3c1d7b4964f09ce344d75f3747249e | Robert-Kolodziej/Python-Progams- | /click.py | 663 | 3.890625 | 4 | #File: click.py
from graphics import *
def main():
#get clicks from the user and tell her where she clicked
radius = 5
clicks = int(input("How many clicks do you want: "))
win = GraphWin("Click Me", 300,300)
center = Point(150,150)
label = Text(center, "Click randomly times a... |
7765d35c1b8eba17fe14118d7a2f3873af1cec6c | Robert-Kolodziej/Python-Progams- | /tryGraphics.py | 1,249 | 3.890625 | 4 | #fun with gtraphics
#tryGraphics.py
#import the graphics package
from graphics import *
#we need a graphics window to start
win = GraphWin("My Graphics Window", 400,400)
#make a point or two
p = Point(50,60)
p2 = Point(140,100)
x = p.getX()
y = p.getY()
print(x,y)
p.draw(win)
p2.draw(win)
#dra... |
803a94b72c70de9135d1f221c7a2232304b27b11 | Robert-Kolodziej/Python-Progams- | /Prog8Kolodziej.py | 3,059 | 4.375 | 4 | ##Bobby Kolodziej
##
##File: Prog8Kolodziej.py
##
##Purpose: This program gives a list of options and the user picks one
## and this program reads another file and makes a rectangle
##
##Input: The user inputs the width of the rectangle and the height of the rectangle
## and the fillstyle of the recta... |
f024329bc3bcc1c260fcffd73d03b0c3308d358d | 11054/eadv-vi20iisa120 | /studentFolders/11019/hangman_project(incomplete).py | 3,172 | 3.96875 | 4 | # hangman display:
def display_hangman(tries):
stages = [ """
--------
| |
| O
| \\|/
| |
| / \\
-
""",
"""
... |
b9e8f7f83ff89e2066e4128f6d66a624bd7e73fb | piotrszacilowski/adventofcode-2020 | /day-01/day_01.py | 645 | 4.0625 | 4 | from itertools import combinations
def read_file_to_array(file):
with open(file, 'r') as file:
report = [line.strip() for line in file]
return report
def find_the_sum_of_two_numbers(report):
for x, y in combinations(report, 2):
if int(x) + int(y) == 2020:
return int(x) * ... |
726d8f6ae44f878b04a9ba0227742dae0dd507c8 | lis5662/Python | /python_crash _course_book/chapter 3/chapter 3 - 1.py | 3,341 | 3.578125 | 4 | bicycles = ['trek', 'cannondle', 'redline', 'specialized']
print(bicycles[0].title())
print(bicycles[1])
print(bicycles[3])
print(bicycles[-1])
bicycles = ['trek', 'cannondle', 'redline', 'specialized']
message = "My first bcycles was a " + bicycles[0].title() + "."
print(message)
# Изменение элементов сп... |
a1227220847949b53d5dae0e76ea87c41830fec7 | lis5662/Python | /python_crash _course_book/chapter 9/chapter 9.py | 7,915 | 4.53125 | 5 | # Создание и использование классов
class Dog():
"""Простая модель собаки."""
def __init__(self, name, age):
"""Инициализирует атрибуты name и age."""
self.name = name
self.age = age
def sit(self):
"""Собака садится по команде."""
print(self.name.title() +... |
7ef797d1c697f36db885c71a279d9b17d25e1bf8 | lis5662/Python | /decorator_function.py | 811 | 3.6875 | 4 | from datetime import date, datetime
from functools import wraps
# Создаем функцию декоратор
def find_time_for_execute(func):
@wraps(func)
def cover(*args, **kwargs):
start = datetime.now()
my_current_age = func(*args, **kwargs)
before_20000_days = 20000 - int(my_current_age)
... |
c32d98eba0eaa2db722d2318b87c707f395ff0b3 | lis5662/Python | /python_crash _course_book/chapter 4/chapter 4.py | 3,562 | 4.40625 | 4 | # Работа со списками цикл for
magicians = ['alice', 'david', 'carolina']
for magicians in magicians:
print(magicians)
# Более сложные действия с циклом for
magicians = ['alice', 'david', 'carolina']
for magician in magicians:
print(magician.title() + ", that was a great trick!")
print("I ca... |
c6d9bf7de16d662ce134d0437be31efa03a2e3e2 | lis5662/Python | /python_bootcamp/sql_lite_python/select.py | 435 | 4.03125 | 4 | import sqlite3
conn = sqlite3.connect("my_friends.db")
# create cursos object
с = conn.cursor()
# с.execute("SELECT * FROM friends WHERE first_name IS 'Rosa'")
с.execute("SELECT * FROM friends WHERE closeness > 5 ORDER BY closeness")
#Iterate over cursor
# for result in с:
# print(result)
# Fetch One Result
# prin... |
39a794fee3d4e8a05c324571c91453d39c66e801 | lis5662/Python | /python_bootcamp/functions/cpin_flip.py | 472 | 3.78125 | 4 | from random import random
# 1
def flip_coin():
# generate random number 0-1
r = random()
if r > 0.5:
return "Heads"
else:
return "Tails"
print(flip_coin())
# 2
def flip_coin():
if random() > 0.5:
return "HEADS"
else:
return "TAILS"
print(flip_c... |
8d59c011088498bf3945544db053c2fc3adc6a53 | clowdcap/Tree | /tree.py | 4,951 | 3.796875 | 4 | import random
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __str__(self):
return str(self.data)
class BinaryTree:
def __init__(self, data=None, node=None):
if node:
self.root = node
elif data:
... |
fa6c59bbc3b132d22f51162f1ca2495b30bf609d | ankur715/GUI | /Tkinter/grid.py | 526 | 3.796875 | 4 | # grid(): It organizes the widgets in a table-like structure.
# Much like a Frame, a grid is another way to organize the widgets. It uses the Matrix row-column concept.
import tkinter
from tkinter import *
top = tkinter.Tk()
CheckVar1 = IntVar()
CheckVar2 = IntVar()
tkinter.Checkbutton(top, text = "Machine Lea... |
1ac0dd4af8183b0cb8708b55363bb6889b1763a3 | StudiousStone/CNN_Accelerator | /Deep_Learning_from_Scratch/Ch04_Learning_Phase_NN/Numerical_Differentiation/derivative.py | 413 | 3.515625 | 4 | import numpy as np
import matplotlib.pylab as plt
def function_1(x):
return 0.01 * x ** 2 + 0.1 * x
def numerical_diff(f, x):
h = 1e-4 # 0.0001
return (f(x+h) - f(x-h)) / (2 * h)
x = np.arange(0.0, 20.0, 0.1) # array from 0 to 20 with step = 0.1
y = function_1(x)
# plt.xlabel("x")
# plt.ylabel("y")
# plt.plot(x... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.