blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
1ae0e8b5f518602d898df8cdbd6b542efd02fbec | Utku-Cobanlar/Random_Projects | /tile_cost.py | 492 | 4.03125 | 4 | print("Hello, welcome to Tile World")
while True:
try:
wid = float(input("Enter width(in meters): "))
heig = float(input("Enter height(in meters): "))
cost = float(input("Enter the cost of a square meter of tiles: "))
def cost_square(wid,heig,cost):
x = wid*heig*co... |
14ac0c2bd16b284628224403eb464ad6bdbec554 | BIOINSTRUMENTACION/BIO4 | /1_Goniometro/Python/goniometro.py | 4,703 | 3.53125 | 4 | # 10/13/2020 Lozano Garcia Eduardo Alejandro
#### Read module #####
def read_from_arduino(COM="COM4",angle=180,pase=10):
data = dict() # Intialize empty dictionary
#angle # Start angle
#pase ... |
d72b26fe220ef28e9c6303603ebfe0a6c165242f | Sarah358/Skaehub-repo | /assignments/day4/recursion.py | 214 | 3.9375 | 4 | names = ["Jane", "Doe", "John", "Stan"]
# function to iterate through the list
def display_data():
for name in names:
print("My name is", name)
display_data()
# call the function
display_data()
|
3da5b34dd2c1c3a29038ea172a0baad975989b28 | Sarah358/Skaehub-repo | /assignments/day1/leap.py | 598 | 4.15625 | 4 | # function to determine whether a year is a leap year or not
def leap_year(y):
# if no remainder after dividing then the year is leap so return true
# applies to century years(those divisible by 100)
if y % 400 == 0:
return True
# if the year has no remainder after dividing by 100 the its no... |
eadb0af1b255ac2200d15f40f97acbc66bd30f09 | Sarah358/Skaehub-repo | /assignments/day2/page.py | 776 | 3.515625 | 4 | # import requests module
import requests
# execute the request
response = requests.get('http://example.com/')
# print response of google
print('The response')
print(response.text)
print("\n .....................................................") #seperate the outputs
# print content of url
print('\n content of url')... |
8a1465fe3c2e7de37de80f906709566d327922cd | Sarah358/Skaehub-repo | /assignments/day1/test_leap.py | 652 | 3.984375 | 4 | # import modules
import unittest
from unittest import result
import leap
class TestLeap(unittest.TestCase):
# function to test leap year
def test_leap_year(self):
y = 2020
result = leap.leap_year(y)
self.assertTrue(result,True)
# not leap year
def test_not_leap_year(self)... |
a7a8a7e5192bd68faf6de80205322111e76d1ae6 | Bharathi-raja-pbr/Python-if-else-exercises- | /2b1.py | 139 | 3.96875 | 4 | # to determine eligible to vote or not
age=int(input("enter your age"))
if age >= 18 :
print("eligilbe")
else:
print("not eligible")
|
ed18e03dacf091c53a1b99a932920ef13ca3cfb0 | Bharathi-raja-pbr/Python-if-else-exercises- | /2a2.py | 103 | 3.765625 | 4 | height=int(input("enter height"))
base=int(input("enter base "))
area=(0.5 * height * base)
print(area) |
8b941c62e3a4aa47b1f807f4d04eeccac0ac9bce | Bharathi-raja-pbr/Python-if-else-exercises- | /2b8.py | 311 | 4.09375 | 4 | print("enter a value between 0 and 100 ")
marks=int(input("enter total marks of student"))
while marks>100 or marks<0 :
marks=int(input("enter total marks of student"))
if marks>=90 :
print("A grade")
elif marks>=75 :
print("B grade")
elif marks>=50 :
print("C grade")
else:
print("fail")
|
9082ca60057dab15917f9e921c771eea53195769 | kc113/pyprog | /ex20.py | 451 | 4 | 4 | print("You enter a room with 2 doors. Do you go through door #1 or door #2")
door = int(input("<"))
if door == 1:
print("There is a giant bear. what do you do?")
print("1-Take the cake.")
print("2-Scream")
bear = int(input("<"))
if(bear == 1):
print("Bear eats your face")
elif(bear == 2):
print("Bea... |
1d07e30ef2ef1134985065eb9ba0bcbca78ad0b3 | neelreddy03/github-sample | /ex1.py | 70 | 3.71875 | 4 | a=int(input("enter the number"))
b=int(input("enter the number"))
a+b
|
89a9867eba8e2dde1d6ffa991b3968acc9bebbca | mister-one/python | /cs_introduction.py | 26,137 | 4.375 | 4 | # This is a Python Dictionary that contains all of the students in Kenny's class as well as their grades.
student_grades = {"Jeremy" : 87, "Kyla" : 82, "Ayesha" : 90, "Aleida" : 94, "Todd" : 79, "Maxwell" : 98, "Yolonda" : 81, "Kiyoko" : 71, "Dagmar" : 73, "Laura" : 91, "Shimeah" : 81, "Songqiao" : 92, "Frankie" : 87, ... |
c1c0184a248fda988741348f5aaf54d54a718d91 | mister-one/python | /modules.py | 2,229 | 4.40625 | 4 | # A module is a collection of Python declarations intended broadly to be used as a tool.
# Modules are also often referred to as "libraries" or "packages" — a package is really a directory that holds a collection of modules.
from module_name import object_name
#Let's get started by importing and using the datetime mo... |
7265c27a9933a87e56f88a487d568cf4faf8a957 | Gendo90/HackerRank | /Dictionaries/countTripletsUpgraded.py | 4,479 | 4.25 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
import numpy
#helper function from algorithms class:
def binary_search_recursive(a, x, left, right):
index = (left+right)//2
if a[index]==x:
return index
elif x>(a[right]) or x<a[left]: # first case where x is not in the list... |
8c8298422d49b985818678d21a3f7b26b87cbf8c | Gendo90/HackerRank | /Basic Algorithms/sherlockSquares.py | 463 | 3.90625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the squares function below.
def squares(a, b):
min_root = math.sqrt(a)
max_root = math.sqrt(b)
#find the integer values of the min and max roots
if(int(min_root)!=min_root):
min_root = int(min_root+1)
if(i... |
4515ab55fb202f05dc28e6b975cf48b77f59a5bc | Gendo90/HackerRank | /Arrays/reverseArray.py | 386 | 3.890625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the reverseArray function below.
def reverseArray(a):
a.reverse()
return a
print(reverseArray([1, 4, 3, 2]))
# Note that the code to format the input/output takes an array as the
# output of this function and then formats it -... |
ec5525766db639d2245f588c68686c2e0a77e9ca | Gendo90/HackerRank | /Dictionaries/twoStrings.py | 229 | 3.703125 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the twoStrings function below.
def twoStrings(s1, s2):
for letter in s2:
if(letter in s1):
return "YES"
return "NO"
|
112aa7a076640ba212516b1d05f76558b23934e9 | Gendo90/HackerRank | /Graphs/dfsMaxRegion.py | 1,345 | 3.5 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#can probably use a bfs anyway...
def bfs_matrix(start, grid, seen):
count = 0
queue = [start]
this_seen = {}
while(queue):
curr = queue.pop(0)
if(curr in this_seen and this_seen[curr]!=1):
continue
... |
4b6ccfd92686668e2398b501d313ae633555e216 | Gendo90/HackerRank | /Graphs/dijkstraShortestReach.py | 14,443 | 3.546875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
import time
import collections
#helper heap to be used to store edges for minimum spanning tree
class HeapMap():
def __init__(self):
self.indices = {}
self.heap = []
def push(self, elem):
self.heap.append(elem)
... |
32b80789fd6899a4c00db33025431679c55c0261 | Gendo90/HackerRank | /Python Language/Sets/symmetric_difference.py | 431 | 3.6875 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
if __name__ == "__main__":
num_a = int(input())
a = set(map(int, input().split(" ")))
num_b = int(input())
b = set(map(int, input().split(" ")))
output = [l for l in a.difference(b)]
output += [k for k in b.difference(a)]
... |
73a41f5a775c228175dcb8f492c37ef079d85dd0 | Gendo90/HackerRank | /Warmup/sockMerchant.py | 403 | 3.5625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the sockMerchant function below.
def sockMerchant(n, ar):
total = 0
colors_seen = {}
for color in ar:
if(color not in colors_seen.keys()):
total += ar.count(color)//2
colors_seen[color] = Tru... |
84dc710f9eb2009f8ea53eeb878186ba85664cb4 | Gendo90/HackerRank | /Basic Algorithms/cavityMap.py | 1,017 | 3.796875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the cavityMap function below.
def cavityMap(grid):
#small grid cases, no cavities possible
if(len(grid)<3):
return grid
grid = [[a for a in line] for line in grid]
for i in range(1, len(grid)-1):
for j... |
c0dcd581439cf45573f96e68495f3217a1f60fb2 | gulyash/AsyaPy | /LR3/LR3_1B_Migranova.py | 331 | 3.9375 | 4 | def fib():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
def fib_sub(start_number, end_number):
for cur in fib():
if cur > end_number: return
if cur >= start_number:
yield cur
max_num = int(input("Please input max number: "))
for i in fib_sub(0, max_num):
... |
c9ee04356bafe108d90ccb79f7896346b1bca725 | gulyash/AsyaPy | /LR6/LR6_4_Migranova.py | 1,013 | 3.515625 | 4 | stock = {
'milk': 2,
'bread': 4,
'tomatoes': 1,
'cheese': 5,
'sour cream': 2,
'potato': 9,
'carrot': 10,
'apple': 8,
'cookies': 3,
'pineapple': 7
}
print(*(k + ': ' + str(stock[k]) for k in stock.keys()), sep='\n')
good = input('Остаток на складе для: ')
print('Равен:', stock[go... |
956f038dbd57bf40766dd1a9571e3697cb91feec | gulyash/AsyaPy | /LR3/LR3_3_Migranova.py | 74 | 3.796875 | 4 | s = 0
for i in range(1, int(input("N: "))+1):
s += pow(i, 3)
print(s)
|
c0788452dc1c2e0bd1bb3fdcea680e9ae760bf47 | devdutt-dikshit/project-Euler | /PrN36.py | 481 | 3.5 | 4 | # PN36
def palindromic(i):
flag=False
i=str(i)
if i==i[::-1]:
flag = True
return flag
def com_binary(n):
binary=''
while(n!=0):
if n%2!=0:
binary=binary+'1'
else:
binary=binary+'0'
n=int(n/2)
if palindromic(binary):
return True... |
bff0361c5a58606796dc91f3d13a19c7508e8a28 | kiman121/password-locker | /user.py | 1,873 | 4.25 | 4 | class User:
'''
Class that generates new instances of a users
'''
user_list = []
def __init__(self, first_name, last_name, username, password):
'''
__init__ method helps in defining properties for the user object.
Args:
first_name: New user first name.
... |
9bda7bfa66905f23fa6b851f900a4b76c77ffe12 | comte/flotpython | /semaine2/semaine2-1_exo1.py | 2,119 | 3.640625 | 4 | # -*- coding: cp1252 -*-
## Comment manipule-t-on des objets en Python ?
## On utilise l'affectation (typage dymamique).
## On dit que l'on affecte un nom un objet ou que
## le nom rfrence l'objet. Parler du typage dynamique.
a = 1 + 2
b = a + 2
## Comment affiche-t-on un objet en Python ?
## On utilise print (on p... |
e322d8f680e528276a1db5b20d2e3a3a0191c43c | Dannark/Data-Structure-and-Algorithms | /Tree/Visualize Binary Tree.py | 658 | 3.5625 | 4 | import tkinter
import sys
from binary_seach_tree_check import *
root = tkinter.Tk()
canvas = tkinter.Canvas(root)
canvas.pack()
# for i in range(10):
# canvas.create_line(50 * i, 0, 50 * i, 400)
# canvas.create_line(0, 50 * i, 400, 50 * i)
# canvas.create_rectangle(100, 100, 200, 200, fill="blue")
# canvas.cr... |
21d50c3d0a0a9dbbf8ac4e5abd3db13826a11f48 | PatrykDluzynski/Projects | /CatsAndDogsML/CatsAndDogsModelTrainer.py | 2,863 | 3.953125 | 4 | import numpy as np
import keras
from keras.models import Sequential, load_model, save_model
from keras.layers import Conv2D, Activation, Flatten, Dense, Dropout, MaxPooling2D
from keras.callbacks import TensorBoard
import time
MODEL_NAME = 'cats_and_dogs_convnet_64x4-64_b30_7e_V2_{}'.format(int(time.time()))
tensorbo... |
70c2497256b7b7d169b8e53746263c0ca80866f3 | jackolantern/caddy | /units.py | 331 | 3.640625 | 4 | class Unit:
def __init__(self, value):
self.value = value
def __repr__(self):
return f"{self.value} {self.symbol}"
class Meter(Unit):
name = "meter"
symbol = "m"
class Centimeter(Unit):
name = "centimeter"
symbol = "cm"
class Millimeter(Unit):
name = "millimeter"
symb... |
5869bd1ea399b069dc491ca2a0913a40b1cf926b | maggieliuzzi/algorithms_data_structures | /algorithms/sorting/merge_sort.py | 908 | 4.34375 | 4 | """
Merge Sort
Time Complexity: O(n log n)
Stable: original order of repeated items is maintained
Cons:
Space Complexity: O(n)
"""
def merge_helper(left, right):
sorted = []
left_index = 0
right_index = 0
while left_index < len(left) and right_index < len(right):
if left[left_index] < right[... |
162a852c4944af0c3ffa97eb56ad453e117562ce | maggieliuzzi/algorithms_data_structures | /algorithms/sorting/insertion_sort.py | 700 | 4.09375 | 4 | """
Insertion Sort
Good for when a list is almost sorted
Good for small datasets
Stable
"""
def insertion_sort(list):
for i in range(1, len(list)):
key = list[i]
# move elements of list[0..i-1], that are greater than key, to one position ahead of their current position
j = i-1
whi... |
da9153b782cef5be3511f4488bf3c482acc6fc96 | maggieliuzzi/algorithms_data_structures | /problems/unique_character.py | 1,238 | 3.953125 | 4 | """
Find the extra character
Given two strings s and t which consist of only lowercase letters.
String t is generated by random shuffling string s
and then adding one more letter at a random position.
Find the letter that was added in t.
Input:
s = "abcd"
t = "abcde"
Output:
e
"""
def find_the_difference(s, t):
... |
abb38f853c120cf0fe8fe2157b06c4125ed57677 | maggieliuzzi/algorithms_data_structures | /problems/reverse_string.py | 775 | 3.953125 | 4 | """
Reverse string in-place
Given as an array
"""
def reverse(s):
# if len(s) == 0:
# return s
# Option 1
# s.reverse()
# Option 2
# s = s[::-1]
# Option 3
'''
# Time: O(N) (N/2 swaps). Space: O(N) (to keep recursion stack)
def helper(left, right):
if left < ri... |
df1404e98463f684c0d39e66df7b6ffe7a4767fc | athemeroy/DataStructure-and-Algorithm--python | /Algorithm/fib.py | 1,217 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 5 23:42:28 2018
@author: zqun(athemeroy)
"""
from memo import memo
@memo
def fib1(n):
"""
递归方式 很容易出现栈溢出
同时用cache来存储已经计算过的内容
空间消耗非常大
1000000 loops, best of 3: 260 ns per loop
"""
if n == 0 or n == 1:
return 1
... |
49e5c66240450aa71a08211d74af1b2b463adb0f | nyccowgirl/coding-challenges | /hackbright/circular_array.py | 6,732 | 4.40625 | 4 | """Implement a Circular Array
A circular array is defined by having a start and indexes (be
sure to think about optimizing runtime for indexing)::
>>> circ = CircularArray()
>>> circ.add_item('harry')
>>> circ.add_item('hermione')
>>> circ.add_item('ginny')
>>> circ.add_item('ron')
>>> circ.pr... |
185b8d6ee1ea9c2d256a6aa2fa6602d182553ac8 | nyccowgirl/coding-challenges | /psads/sudoku.py | 13,308 | 4.125 | 4 | # BASIC SUDOKU WITH BACKTRACKING ALGORITHM
def greeting():
"""Displays greeting to the game."""
print "Let's solve Sudoku!"
def instructions():
"""Displays position numbers for board.
Board index positions are as follows:
0,0|0,1|0,2||0,3|0,4|0,5||0,6|0,7|0,8
---|---|---||---|---|-... |
a79930137204b7ec80ed9836350718e4aa496f39 | nyccowgirl/coding-challenges | /psads/stack_revstring.py | 1,112 | 3.953125 | 4 | """Write a function revstring(mystr) that uses a stack to reverse the characters
in a string."""
class Stack:
"""Creates stack"""
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
... |
556ee833dd3eea2c3b594c81a77090f824910eb9 | nyccowgirl/coding-challenges | /hackbright/sortab.py | 1,926 | 4.15625 | 4 | """Given already-sorted lists, `a` and `b`, return sorted list of both.
You may not use sorted() or .sort().
Check edge cases of empty lists:
>>> sort_ab([], [])
[]
>>> sort_ab([1, 2,3], [])
[1, 2, 3]
>>> sort_ab([], [1, 2, 3])
[1, 2, 3]
Check:
>>> sort_ab([1, 3, 5, 7], [2, 6, 8, 10])... |
4b1fc609478823c2f3d42230c31757c551ed4a9c | nyccowgirl/coding-challenges | /leet/Python/mergesortedll.py | 2,089 | 4.21875 | 4 | """
Merge two sorted linked lists and return it as a sorted list.
The list should be made by splicing together the nodes of the
first two lists.
Example 1:
Input: l1 = [1,2,4], l2 = [1,3,4]
Output: [1,1,2,3,4,4]
Example 2:
Input: l1 = [], l2 = []
Output: []
Example 3:
Input: l1 = [], l2 = [0]
Output: [0]
Constra... |
d73487ab313ca81f6c8fb0830c004dac9580f772 | nyccowgirl/coding-challenges | /hackbright/pangram.py | 1,056 | 4.28125 | 4 | """Given a string, return True if it is a pangram, False otherwise.
For example::
>>> is_pangram("The quick brown fox jumps over the lazy dog!")
True
>>> is_pangram("I love cats, but not mice")
False
"""
def is_pangram(sentence):
"""Given a string, return True if it is a pangram, False otherwis... |
3de9915e147c77580099d0de420aa054e3959fd4 | Arkathon/lab_15_all_parts | /for.py | 917 | 4.09375 | 4 | """
for.py
=====
* count to 100 starting from 1
* print out every number
* count to 100 by twos from 0
* print out every number
* count backwards starting from 100 down to and including 0
* print out every number
* print out the sum the first 1-100 numbers (which, of course, [doesn't need a loop](http://betterexplai... |
e3a0c6b88eb3ff3a0ead39f7388b4c5e1aca7d39 | adepeter/sleekforum | /src/sleekapps/cores/utils/choice.py | 985 | 3.578125 | 4 | from collections import ValuesView
from typing import Tuple, List, Dict
class Choicify:
"""This is a utility class which returns tuple of choices
calculates length of individual choices for use in CharField
"""
def __init__(self, choices: Tuple) -> None:
self.__choices = sorted(choi... |
978884102f7e1720ce082de13c0951a663587f40 | BCMoon/python_test | /myTest2.py | 123 | 3.953125 | 4 |
i = input("Enter your number:")
if i<2 or i>9:
print "you input wrong number"
else:
for j in range(1,10):
print i*j
|
647032707ee1d3c3804f2452d2e7f0c037a8bdad | zfine87/spoj-fun | /prime/prime_test.py | 496 | 3.734375 | 4 | import sys
def prime_check(r):
while True:
s = r.readline()
if s == "":
print("EOF")
break
if s == '\n':
print("skip")
else :
if is_prime(int(s)):
print("good " + s)
else :
print(int(s))
break
def is_prime(n):
if n <= 3:
return n >= 2
if n % 2 == 0 or n % 3 == ... |
b932a7b9acca77139bc6c2dcfbcc2d9f4799aa51 | Franborat/gans | /models/base_model.py | 3,721 | 3.765625 | 4 | import os
from abc import ABC, abstractmethod
import torch
from models import network
class BaseModel(ABC):
"""
Abstract base class (ABC) for models.
To create a subclass, you need to implement the following five methods:
-- <__init__>: Class initializer
-- <set_input>: Unpack data from dataset an... |
ac09758bf900d38ab8d059b175ca4262fcacab74 | DiegoDs01/Aula1_Carol | /arredondando.py | 252 | 3.59375 | 4 | #from math import sqrt, ceil, floor
#from - escolhe o que vc quer importar
#import - Escolhe de onde importar
from math import floor
num = float(input("Digite num numero "))
redondo = floor(num)
print ("O numero arredondado e {}".format(redondo)) |
dc7a19a47fdc60116dd912ecf8680e63326940da | cselby57/general | /neovision/polygon.py | 11,787 | 3.828125 | 4 | from dataclasses import dataclass
import math
# geometry ref: http://paulbourke.net/geometry/pointlineplane/
tol = .000000001
@dataclass
class Vector3:
# hold 3 floats to describe a vector or point
X: float
Y: float
Z: float
def __add__(self, other):
new_x = self.X + oth... |
9d713a27beea7aa14aded814025480cabf3fdc81 | LoicS1/python-backup | /1.3.6/Scomparin_1.3.6.py | 2,102 | 4.5 | 4 | #4. (5,7,6) An example of a tuple
#5. This assigment needs to be completed with answers written as comments in the
# program file.
# Variable names are to be lowercase and not contain spaces.
#6. Tuples
#6a. some_values[1] will return b because b has index 1 within the tuple.
#6b. some_values[0:2] will return a and... |
5ae2f710977bf6a475af58bedcb8af805e988655 | sajeeshgit/ruby_tried | /python_trining/first.py | 270 | 3.953125 | 4 | #!/usr/bin/python
word1 = raw_input("Enter your First word:")
#word1 = "sajeesh"
len1 = len(word1)//2
word2 = raw_input("Enter your Second word:")
#word2 = "krishnan"
len2 = len(word2)//2
store1 = word1[len1:]
store2 = word2[len2:]
print store1, store2
|
a7484f033edaf90ca44e94f983ed841732bcf95a | Sam9Ves3/Python-basic-codes | /Mean of a multiples of 5 and 7 in a range.py | 373 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 20 09:39:02 2019
@author: Samuel Venegas
"""
def multiples():
sum = 0
counter = 0
x= range(0,100)
for x in range(0,1000):
if (x%7==0 and x%5==0):
sum += x
counter +=1
print ("The mean of all the multiples... |
df016daca3ea0cd7f069a7aaa4a67adbd2d7d480 | natan7366/Blackjack | /BlackJack.py | 6,350 | 3.90625 | 4 | import random
suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs')
ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace')
values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':10,
'Queen':10, 'Kin... |
556fded83bf76b4ebae5b6eba45a6638ae26623d | MariaKotiva/stepik-auto-tests-course | /lesson2_step3.py | 895 | 3.53125 | 4 | from selenium import webdriver
from selenium.webdriver.support.ui import Select
import math
import time
def calc(x, y):
return x + y
try:
driver = webdriver.Chrome()
driver.get("http://suninjuly.github.io/selects1.html")
x_element = driver.find_element_by_id("num1")
x1 = x_element.text
x = in... |
8716db00fe5f3528cc4f08ab2735e561886f4999 | s-saloni/StocksWebApp | /main.py | 7,412 | 3.53125 | 4 | """ Streamlit-based web app to view stock data from Yahoo Finance
"""
# libraries
import streamlit as st
from datetime import MAXYEAR, date
import yfinance as yf
import numpy as np
import pandas as pd
from plotly import graph_objects as go
import requests
from bs4 import BeautifulSoup
from sklearn.model_selection ... |
33efdbf136be70ac22d6fdb8a8d0dff3665c8b19 | dylan-fox/Python_Projects | /hardway/ex14.py | 757 | 3.890625 | 4 | #You really learn this one thing at a time, and when you look back, you've climbed a mountain.
from sys import argv
script, user_title, user_name = argv
prompt = 'Talk to me: '
print "Hi %s, I'm the %s script." %(user_name, script)
print "Oh, excuse me; I meant to use your official title, %s %s" %(user_title, user_na... |
e5d8628f444e7339a8322c2ce82c5619dc8c5aa1 | dylan-fox/Python_Projects | /hardway/ex33.py | 1,116 | 4.125 | 4 | """
#Using a simple while loop:
i = 0
numbers = []
while i < 6:
print "At the top of i is %d" %i
numbers.append(i)
i = i+1
print "Numbers now: ", numbers
print "At the bottom i is %d \n" %i
print "The numbers: "
for num in numbers:
print num
"""
"""
#Making it into a function that accepts l... |
e73431bed0eefdc0f098eb6de95bf8df224cedcf | dylan-fox/Python_Projects | /hardway/ex5.py | 811 | 3.8125 | 4 | name = 'Dylan Fox'
age = 25.0 #truth
height = 72.0 #inches
weight = 230.0 #lbs
eyes = 'Brown'
teeth = 'White'
hair = 'Dark Brown'
print "Let's talk about %s." % name
print "He's %d inches tall." % height
print "He's %d pounds heavy." % weight
print "Actually that's not too heavy."
print "He's got %s eyes and %s hair."... |
e1e0bff0b515b76648aee24b30a5b1c1d3a11991 | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/nondivisible_subset.py | 3,460 | 4.03125 | 4 | def nonDivisibleSubset(k, list_num) -> int:
"""Determine the longest permutation of non-multiples of k"""
longest_permutation = 0
counter = {}
for num in list_num:
remainder = num % k
try:
counter[remainder] = counter[remainder] + 1
except KeyError:
coun... |
892e2945358594511b89e95d165fb3d4f35d1faa | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/poker_nim.py | 276 | 3.59375 | 4 | def pokerNim(num_adds, piles) -> str:
"""Determine winner of nim game"""
nim_sum = 0
for num in piles:
nim_sum ^= num
if nim_sum == 0:
return "Second"
else:
return "First"
print(pokerNim(5, [1, 2]))
print(pokerNim(5, [2, 1, 3]))
|
dae17a7a748cd01af332d19703ab0d474703fbd4 | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/jim_orders.py | 476 | 3.75 | 4 | def jimOrders(orders) -> list:
"""Determine delivery times for orders"""
delivery_times = {}
for index in range(len(orders)):
order = orders[index]
serve_time = sum(order)
delivery_times[index + 1] = serve_time
delivery_order = sorted(delivery_times.items(), key=lambda t: t[::-1... |
efe51e7393904e9e813c70c3c429e5749021989e | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/icecream.py | 789 | 3.71875 | 4 | def icecreamParlor(cost, flavours) -> list:
"""Calculate total cost of purchase"""
purchase = []
index = 0
while index < len(flavours) - 1:
current_val = flavours[index]
should_break = False
for next_index in range(index + 1, len(flavours)):
next_val = flavours[next_i... |
09255289def1cf34d6d78d39c80769cbab2da625 | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/gemstones.py | 639 | 3.84375 | 4 | from test_case_data import string_data
def gemstones(list_stones) -> int:
"""Count the number of chars present in every string"""
unique_gems = sorted(list(set("".join(list_stones))))
count = 0
every = True
for gem in unique_gems:
for stone in list_stones:
if gem not in stone:... |
05f424b3a3870a004936414bc74228754b8b2965 | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/misere_game.py | 590 | 3.65625 | 4 | def misereNim(pile) -> str:
"""Determine winner of nim game"""
winner = "Second"
is_even = len(pile) % 2 == 0
max_num = max(pile)
if max_num == 1:
if is_even:
winner = "First"
return winner
else:
return winner
nim_sum = 0
for num in pile:... |
892a0ec41cbdbf5708703791a3f93d79def8fe61 | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/lisas_workbook.py | 458 | 3.578125 | 4 | def workbook(num_chapters, max_problems, list_problems):
page = 1
special_problems = 0
for problems in list_problems:
for index in range(1, problems + 1):
if index == page:
special_problems += 1
if (index % max_problems == 0 and index != problems) or index ==... |
9feba435621932846974b4de7e8cea0a2a166c51 | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/quick_sort.py | 437 | 4.15625 | 4 | def quickSort(arr) -> list:
"""Implement quicksort"""
pivot = arr[0]
left = []
equal = [pivot]
right = []
for index in range(1, len(arr)):
num = arr[index]
if num < pivot:
left.append(num)
elif num == pivot:
equal.append(num)
else:
... |
2fe9603e11fb911da2f2fe7754fd6243acb44f0e | CoderFemi/AlgorithmsDataStructures | /practice_challenges/python/chessboard.py | 900 | 3.84375 | 4 | from test_case_data import test_case_chessboard, test_chessboard_result
def chessboardGame(x, y) -> str:
"""Determine winner given board coordinates"""
winner = "First"
losing_coord_numbers = []
num = 1
while num <= 15:
num_pair = [num, num + 1]
losing_coord_numbers += num_pair
... |
9687abe7b82a618e72462b1416d86aedb71c7ac6 | alexherns/cmd48 | /app.py | 11,220 | 3.609375 | 4 | #!/usr/bin/env python
import curses
import random
import logging
logging.basicConfig(filename='logging.txt', level=logging.DEBUG)
def collapse_tiles(tile_array):
"""Collapse list of 4 tiles in 2048-style"""
tile_array = [val for val in tile_array if val]
output = []
while len(tile_array) >= 2:
... |
d70fc117e16e0cd1f5a705c07ef7be1052bc9295 | 404dev404/DataScienceLearning | /Python_Basics/Python_Data_types.py | 520 | 3.71875 | 4 |
# coding: utf-8
# ## Data Types
# ### int
# In[12]:
my_int_var = 100
# In[13]:
print(my_int_var)
# In[14]:
my_int_var_2 = 10
# In[15]:
print(type(my_int_var_2))
# ### float
# In[16]:
my_float_var = 9.9
# In[17]:
print(my_float_var)
# In[18]:
print(type(my_float_var))
# ### string
# In[19]:
m... |
1792bed867f9c3668bbcf89fd00ce764d051279a | exer047/homework_5 | /ex_1_upd.py | 189 | 3.53125 | 4 | import random
size = int(input("Enter list size: "))
def create_list(size):
numbers = [[random.randint(100,999) for j in range(size)] for i in range(size)]
return numbers |
106d0116a51a07c0652f9df9c48658f594fc2243 | lucasalme1da/codesignal | /The Core/11 - extraNumber.py | 180 | 3.640625 | 4 | def extraNumber(a, b, c):
l = [a, b, c]
for i in range(3):
aux = l[i]
l.remove(aux)
if aux not in l:
return aux
l.insert(i, aux) |
5696f11448e93c42cbd33b64ee4be9408096c0f7 | lucasalme1da/codesignal | /Intro/39 - knapsackLight.py | 413 | 3.5 | 4 | def knapsackLight(value1, weight1, value2, weight2, maxW):
if ((weight1 + weight2) <= maxW):
return value1 + value2
if (weight2 >= weight1):
if (value2 > value1 and weight2 <= maxW): return value2
if (weight1 <= maxW): return value1
if (weight1 > weight2):
if (value1 > value2... |
8902de1f5f2f0b07257d506586856b40c3383170 | LifangHe/speaker-recognition | /mlp_backprop_momentum.py | 4,608 | 3.703125 | 4 | import numpy as np
class MLP:
"""
This code was adapted from:
https://rolisz.ro/2013/04/18/neural-networks-in-python/
"""
def __tanh(self, x):
return np.tanh(x)
def __tanh_derivative(self, a):
return 1.0 - a ** 2
def __logistic(self, x):
return 1.0 / (1.0 + np.ex... |
71401641e1cef36043d2c1f2c8dd92580c19cf4b | MeltedHyperion7/aseprite-animated-svg | /utils.py | 333 | 3.609375 | 4 | from n_dim_matrix import n_dim_matrix
def animate_create_grid(width: int, height: int):
""" Creates a grid of empty lists as required by the [Animation] class. """
grid = n_dim_matrix((height, width), fill=None)
for row in range(height):
for col in range(width):
grid[row][col] = []
... |
11f9ab348a085388f8a9db3aabfb3182125d32b0 | Alouie412/holberton-system_engineering-devops | /0x16-api_advanced/2-recurse.py | 860 | 3.5625 | 4 | #!/usr/bin/python3
""" This script queries the Reddit API for a list of hot articles
of the given subreddit and returns the count. Written using
recursion because Holberton demanded it """
import requests
def recurse(subreddit, hot_list=[], next_topic=''):
try:
hot = requests.get('https://www.redd... |
e87ace65551e91c6011d10f11b41519d93b80cab | startatnoon/SQLite_practice | /database.py | 1,122 | 3.953125 | 4 | import sqlite3 as lite
import pandas as pd
con = lite.connect('getting_started.db')
cities = (('New York City','NY'),('Boston','MA'),('Chicago','IL'),('Miami','FL'),('Dallas','TX'),('Seattle','WA'),('Portland','OR'),('San Francisco','CA'),('Los Angeles','CA'),('Washington','DC'),('Houston','TX'),('Las Vegas','NV'),('At... |
cf6592d78f9524c48563f6c06bf5b4fda90254eb | 1264799190/1803 | /13day/5.名片系统.py | 2,365 | 3.75 | 4 | print('名片系统'.center(20,'*'))
print('1.新增名片'.center(20,' '))
print('2.查看名片'.center(20,' '))
print('3.修改名片'.center(20,' '))
print('4.删除名片'.center(20,' '))
print('5.退出系统'.center(20,' '))
cards = []
while True:
fun_number = int(input('请输入功能'))
if fun_number == 1:
#print('新增')
flag = 0
card = {}
name = input('请输入你... |
088c3acd8a11495dfc639f5311b98361d79ed5b0 | 1264799190/1803 | /08day/1.py | 501 | 3.59375 | 4 | acc = '12345'
pwd = '123'
i = 1
while i <= 3:
w_acc = input('请输入账号')
w_pwd = input('请输入密码')
if w_acc == acc and w_pwd == pwd:
hero = print(input('0---ADC 1---肉 3---法师'))
if hero == '0':
print('鲁班')
elif hero == '1':
print('程咬金')
elif hero == '3':
print('王昭君')
break
else:
print('登陆错误,请重新输入')
... |
4cf3f7e045bdf2a684329beeac09b1dda0a213be | 1264799190/1803 | /07day/高富帅.py | 364 | 3.734375 | 4 | shenjia = float(input('请输入你的身价'))
fice = int(input('请输入你的颜值分'))
height = float(input('请输入你的身高'))
if height > 180 and money >100000 and fice > 99:
print('高富帅')
elif shenjia > 100000 and fice > 99:
print('富帅')
elif fice > 99:
print('帅')
elif height < 160 and shenjia <100 and fice < 60:
print('矮穷矬')
|
6e35d7d6a8e3f64899fe58f70d21a8e79fc4cee9 | 1264799190/1803 | /09day/1.py | 115 | 3.78125 | 4 | i = 1
while i <=4:
print('%d排'%i,end = '')
w = 1
while w <= 5:
print('*',end = '')
w+=1
print('')
i+=1
|
6b3cab53aabd03fa28244fee90f6a806dda48b87 | CarterFiggins/drawings | /spiral.py | 1,455 | 3.515625 | 4 | import turtle
import math
nextDirection = {
'right': 'down',
'down': 'left',
'left': 'up',
'up': 'right',
}
def main():
screen = turtle.Screen()
screen.setup(900, 900)
t = turtle.Turtle()
# penSize = 2
# t.pensize(penSize)
goldenSpiral(t, 1, 1, {'x': 0, 'y':0}, 'right', True)
turtle.done()
... |
85c9061617ef8f3edd7769d1e5cb436a7036e21a | espooky7/shared_expenses | /python_challenge/03.py | 1,115 | 4.09375 | 4 |
def import_chunk(filename):
"""
Again, read in the block of text, saved in a separate txt file.
Remove \n and \t before returning the string.
"""
file_obj = open(filename, 'r')
text = file_obj.read()
text = text.replace('\n', '')
text = text.replace(' ','')
file_obj.close()
return text
def find_pattern(st... |
dc8a18ab5ca9a8a575845ceeae642558902c813a | CodeFirst19/CryptographyProject | /text_window.py | 17,202 | 3.5 | 4 | from tkinter import *
from tkinter import ttk as tk
from string import ascii_letters
from tkinter import messagebox
import random
from textwrap import wrap
from key_window import send_key
from tkinter import filedialog
# Command Function
# Send Own Text To Binary Generator Function For Encryption
def encrypt_own_text... |
c07d3ffad4c1f800c190c78a22d98617795cccbf | admiralmattbar/euler | /euler_triangle_formatter.py | 1,435 | 3.84375 | 4 | from array import *
import sys
'''
Format the grid for Project Euler 18 to get an array in c
Requires the following:
-Removing 0s from front of numbers
-Adding commas between numbers
-Adding curly brackets
Final formatting should look like a 2D C array with 0s inserted
for blanks in the triangle.
This should take ... |
d04775a62e25973b69273162fa6d8cc9822991d6 | Tomev/AoC2019 | /8/8.py | 1,434 | 3.5 | 4 | def get_layers():
image_width = 25
image_height = 6
number_of_digits_per_layer = image_height * image_width
layers = []
file = open('input', "r+")
puzzle_input = file.readline()
file.close()
layers.append([])
for i in range(len(puzzle_input)):
layers[-1].append(puzzle_inp... |
09bfe5200870d3c03fdda70a616d97a0d0409c0b | Tomev/AoC2019 | /4/4.py | 1,421 | 3.75 | 4 | def get_problem_1_solution():
possible_passwords = []
for password in range(153517, 630395):
if satisfies_criteria(str(password)):
possible_passwords.append(str(password))
print(f'Number of possible different passwords within given range is {len(possible_passwords)}.')
return pos... |
047dbc8f75bb23ddb083333ed1605253d27e037a | ayanamirei629/LeetCodeQ | /Valid Palindrome II/Valid Palindrome II.py | 744 | 3.578125 | 4 | class Solution(object):
def validPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
if s[::-1] == s:
return True
else:
for i in range(len(s)/2):
if s[i] != s[len(s) - 1 - i]:
temp_s = list(s)
... |
a0dd1dd68b0380fab4fbcd201169725025c1c4a4 | XURUI89/OPP-1- | /练习2.py | 1,039 | 3.84375 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
1.我定义了一个类,可以自动弹出窗口,输入年龄
2.我用age先取数
3.我用函数property完成三步走
4.第一步是修改,第二步输出,第三步删除
问题是:一个property只能修改一个变量
'''
class person():
def __init__(self):
self.age=eval(input("your age:"))
self.name=input("your name: ")
def nameget(self):
print("{0}"... |
bdb619445bb4503d411b82cd2e7bc8d99ce8e1dc | Saptarshi-prog/Path-through-graph-TCS_Codevita-2020 | /Graph.py | 858 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 22:18:22 2020
@author: Saptarshi
"""
M, N = [int(i) for i in input().split()]
def largest_factor(n):
a = int(n/2)+1
for i in range(2,a):
if n%i ==0:
return int(n/i)
return 1
max = max(M,N)
min = min(M,N)
if M==N:
... |
718edb3fc26a5cacb3b170c9b0a330d76f13bef8 | VANTABC/section5 | /5-3-2.py | 1,289 | 3.625 | 4 | import sqlite3
#DB 생성
conn = sqlite3.connect('C:\python\\section5\\databases\\sqlite1.db')
#커서 바인딩
c = conn.cursor()
#데이터 조회(전체)
c.execute("SELECT * FROM users")
#1개 로우 선택
#print(c.fetchone())
#지정 로우 선택
#print(c.fetchmany(size=4))
#전체 로우 선택
#print(c.fetchall())
#순회1
#rows = c.fetchall()
#for row in rows:
#pr... |
4d53d197ca7b703278e0914f71d3a8e9d3066127 | SpaxR/CapgeminiCodingChallenge | /Rule.py | 429 | 3.75 | 4 | from abc import ABC, abstractmethod
class Rule(ABC):
"""Class for the rules of evaluation of current office state"""
# checks whether for a given rule current state is optimal
@staticmethod
@abstractmethod
def state_optimal(self, rooms, building):
pass
# gives out list of strings on ... |
c2b00b534eea181f9f260e57d502c442c7222f64 | dawgfish/numbers | /convert.py | 927 | 4.21875 | 4 | #!/usr/bin/env python
'''
Python program to convert decimal number into binary, octal, and hexadecimal number system
'''
__author__ = "M. Jastad"
__copyright__ = "Copyright(c) 2015"
__license__ = "USE-AS-IS"
__version__ = "1.0.2"
__maintainer__ = "M. Jastad"
__email__ = "majastad@icloud.com"
def main():
while ... |
57cc2da7cf7eacd6c6e7a1700dcad5e483a537df | BlueHope1987/StudyBase | /helloPython/201607/5.py | 227 | 3.734375 | 4 | try:
a=int('1')
print a
except:
print 'an error happended'
astr='Hello Bob'
try:
istr=int(astr)
except:
istr=-1
print 'First',istr
astr='123'
try:
istr=int(astr)
except:
istr=-1
print 'Second',istr |
e90646c17f98c798278844578579dc51991e63d3 | BlueHope1987/StudyBase | /helloPython/201607/7.py | 189 | 3.578125 | 4 | [(i,'*',j,'=',i*j) for i in range(10) for j in range(10)]
while True:
line = raw_input('show me the money>')
if line =='five dollar':
break
print line
print 'Thank you!' |
28ae771dfdd0b5c46a7aa9a7fa8326c8155dc566 | magladde/Python-CSC-121 | /Lesson 03/Lab03P2.py | 740 | 4.53125 | 5 | # Calculate Time Program
# program greeting
print('Hello, this program calculates what time it is based off of the')
print('number of seconds past midnight. This program takes user input')
print('in the form of number of seconds past midnight.')
# get user input for number of seconds past midnight
num_seconds = int(i... |
abcbfc7d15157f834e5ae2a83282b2f85eff6697 | magladde/Python-CSC-121 | /Lesson 14/Lab14P1/main_module_dinner.py | 1,316 | 3.578125 | 4 | from Dinner_combo import Dinner_combo
from Delux_dinner_combo import Delux_dinner_combo
def main():
dinner_combo = int(input('Enter 1 for dinner combo and 2 for delux dinner '
'combo: '))
if dinner_combo == 1:
dinnerCombo()
elif dinner_combo == 2:
deluxDinnerCo... |
910af9085b200b0c38639d9c4da3b5a3e053e512 | magladde/Python-CSC-121 | /Lesson 08/zip function.py | 263 | 4.03125 | 4 | # prints returned iterator info
x = [1, 2, 3]
y = [4, 5, 6]
z_list = zip(x + y)
print(z_list)
# prints zipped lists
x = [1, 2, 3]
y = [4, 5, 6]
z_list = list(zip(x, y))
print(z_list)
# prints unzipped lists
x2, y2 = zip(*z_list)
print(list(x2))
print(list(y2))
|
a873f57d2402a2acaa70d2c093d40ec9fa9b30d5 | magladde/Python-CSC-121 | /Lesson 08/Lab08P4.py | 232 | 4.0625 | 4 | # Lesson 08 lab problem 4
average = lambda x: sum(x) / len(x)
list1 = [2, 1, 5, 9, 8]
list1_avg = average(list1)
print('list1 average:', list1_avg)
list2 = [17, 5, 2, 4]
list2_avg = average(list2)
print('list2 average:', list2_avg) |
d012dff406762cfe3fba2c672618b85684133a96 | magladde/Python-CSC-121 | /Lesson 11/Lab11P01.py | 1,675 | 4.125 | 4 | # Lab 11 Problem 1
def main():
# get user input
user_input = input('Enter a string: ')
dictionary = get_dictionary(user_input)
print(dictionary)
# take user input and check if in dictionary
user_char = input('Choose a letter: ')
dictionary = char_count(user_char, dictionary)
print('Dict... |
918b88942e74fed4c2d393f3fcbceaeb573097e7 | magladde/Python-CSC-121 | /Lesson 03/Lab03P3.py | 578 | 4.40625 | 4 | # Largest number program
# program introduction
print('This program takes user input for three numbers and selects the')
print('largest one.')
# get user input
num_one = float(input('Enter first number: '))
num_two = float(input('Enter second number: '))
num_three = float(input('Enter thrid number: '))
# compare to ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.