blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
8c129db873f49c5186674479e7a3515c207300e3 | eSuminski/Python_Primer | /Primer/examples/regex_example/regex_example.py | 247 | 3.90625 | 4 | import re
phrase = "my mother loves me"
result = re.search("^my.*love", phrase)
# there are many ways to search through information, documentation is very helpful here
if result:
print(type(result))
else:
print("the criteria was not met") |
460b05a4409085e07d2052954a6465e5261f48f8 | Jitender214/Python_basic_examples | /10-Advanced Python Modules/03- Python Debugger.py | 197 | 3.75 | 4 | import pdb
x = [1,2,3]
y = 4
z = 5
result = y + z
print(result)
pdb.set_trace()
result2 = x + result# here it will error - TypeError: can only concatenate list (not "int") to list
print(result2) |
fe9c4af5dae6f3838f36e007bfffad683b249276 | Jitender214/Python_basic_examples | /10-Advanced Python Modules/04-Timing your code - timeit.py | 455 | 3.75 | 4 | #Sometimes its important to know how long your code is taking to run or at least know if a particular line of code
#slowing down your entire project
#Python had built-in timing module to do this
import timeit
print("-".join(str(n) for n in range(100)))
print(timeit.timeit('"-".join(str(n) for n in range(100))',number=... |
f1bbfccfcf6cbd4acde830aac37b9e335341150d | Jitender214/Python_basic_examples | /02-Python Statements/05-List Comprehensions.py | 507 | 3.9375 | 4 | mystring = 'Hello'
mylist = []
for letter in mystring:
mylist.append(letter)
print(mylist)
#using list comprehension
mylist = [letter for letter in mystring]
print(mylist)
mylist1 = [x for x in 'abcde']
print(mylist1)
mylist2 = [num for num in range(1,20)]
print(mylist2)
mylist2 = [num**2 for num in range(1,20... |
f294b5d241e782c77cf243666f82a043f7ae2c8b | Jitender214/Python_basic_examples | /02-Python Statements/03-while Loops, break,continue,pass.py | 808 | 4.1875 | 4 | # while loops will continue to execute a block of code while some condition remains true
#syntax
#while some_boolean_condition:
#do something
#else
#some different
x = 0
while x < 4:
print(f'x value is {x}')
x = x+1
else:
print('x is not less than 5')
x = [1,2,3]
for num in x:
#if we put comment afte... |
96f4c4be86ed6e56acf3864c6131dfda9f33e5c1 | Jitender214/Python_basic_examples | /02-Python Statements/02-for Loops.py | 956 | 4.375 | 4 | # we use for loop to iterate the elements from the object
#syntax:
#my_iterate = [1,2,3]
#for itr_name in my_iterate:
#print(itr_name)
mylist = [2,4,5,7,9,10]
for num_list in mylist:
print(num_list)
for num in mylist:
if num % 2 == 0:
print(f'number is even: {num}')
else:
print(f'number i... |
c9ffaee4d2e9fc627f2586c709ab3ee3e007f8c0 | Jitender214/Python_basic_examples | /00-Python Object and Data Structure Basics/04-Lists.py | 1,098 | 4.125 | 4 | my_list = [1,2,3,4,5]
print(my_list)
my_list = ['string',100,13.5]
print(my_list)
print(type(my_list))
print(len(my_list))#length of list
my_list = ['one','two','three','four']
print(my_list[0])
print(my_list[1:]) #slicing using index
print(my_list[-2:])#reverse slicing
another_list = ['five','six']
new_list = my_li... |
226d9dfd982905e8e74bc54c627d3c5340613619 | AbeVos/uvadlc_practicals_2019 | /assignment_2/part1/plot_eval_seq_len.py | 1,478 | 3.6875 | 4 | """
Plot the values from 'results.csv', a file containing the final accuracy of the
vanilla RNN after training on the Palindrome dataset using palindromes of a
particular length.
"""
import csv
import numpy as np
import matplotlib.pyplot as plt
from collections import defaultdict
if __name__ == "__main__":
model_... |
d42f21a081a52bd0d73764344489d5738bed8f70 | green-fox-academy/bauerjudit | /week-4/practice/2.py | 403 | 3.765625 | 4 | numbers = [3, 4, 5, 6, 7]
def filter(my_list):
new_list = []
for num in my_list:
if num % 2 == 0:
new_list.append(num)
return new_list
print(filter(numbers))
def filter2(my_list):
new_list = []
i = 0
while i > len(my_list)-1:
if my_list[i] % 2 == 0:
n... |
8e1a3b568d1eab03130e3481dfd2a509bcd9ed43 | green-fox-academy/bauerjudit | /week-4/friday/test_sudoku_solver.py | 2,332 | 3.578125 | 4 | import sudoku_solver
import unittest
class TestSudokuChecker(unittest.TestCase):
def test_is_complete_empty(self):
test_input = []
expected = False
actual = sudoku_solver.is_complete(test_input)
self.assertEqual(expected, actual, "The row is empty.")
def test_is_complete_too_sh... |
a86504a0e688fe9816b53ac2d9f8ac50a920babf | green-fox-academy/bauerjudit | /week-4/practice/6.py | 387 | 3.71875 | 4 | filename = "alma.txt"
def add_a(text):
new_text = (open(text)).read()
new_text.close()
split_text = new_text.split("\n")
output = ""
for line in split_text:
output += line + "A" + "\n"
return output
def add_a(text):
new_text = (open(text)).readlines()
new_text.close()
outp... |
1362bf15b3879abf6126c995fce389ca69e5f3f7 | green-fox-academy/bauerjudit | /week-4/monday/dictionary.py | 466 | 4.09375 | 4 | student = {"labmeret": 45, "nev": "Tibike", "kor": 8.5}
print(student)
print(student["labmeret"])
students = [
{"name": "tibi", "age": 6},
{"name": "adorjan", "age": 9},
{"name": "bela", "age": 6},
{"name": "aurel", "age": 12},
{"name": "dezso", "age": 4},
]
def students_at_leat_8(list):
output= []
for cha... |
c4eda2cb0c092937f014e170fef1825852274715 | green-fox-academy/bauerjudit | /week-3/monday/prim.py | 192 | 3.890625 | 4 | num = 4
if num == 0 or num == 1:
print("not prim")
for x in range(2, num):
if num % x == 0:
print("not prim")
break
else:
print("prim")
break
|
89e963558bb61b19e1f36c1f2b4eb101be8df32a | green-fox-academy/bauerjudit | /week-4/practice/1.py | 328 | 4.0625 | 4 | numbers = [3, 4, 5, 6, 7]
def reverse(nums):
output = []
for num in nums[::-1]:
output.append(num)
return output
print(reverse(numbers))
def reverse2(nums):
output = []
i = len(nums)-1
while i >= 0:
output.append(nums[i])
i -= 1
return output
print(reverse2(nu... |
1c72a980033b6b74bda6f397480cc32ad580cf0d | digitalkraut/personalityanalyser | /personalityanalyser.py | 449 | 3.765625 | 4 | #personality analyser to find out what kind of human you are
Startabfrage = "nein"
print ("================================================================")
print ("Ich bin ihr hochwissenschaftlicher Persönlichkeits Analaysator")
print ("================================================================")
Startabfrag... |
4c3fe04e1bf2190c4bcccbe43ba379ec4c894d33 | FTePe/antSimulation | /intersection.py | 1,031 | 3.8125 | 4 | from new_path import new_Path
class Intersection:
def __init__(
self,
name
):
# self.location = location
self.name = name
self.neighbours = []
self.branches = []
def add_link(self, intersection,path):
neighbour1 = (intersection,p... |
2b60dfbc739ce95ca6c51dd3cc0d5ddf68dfc0ed | FTePe/antSimulation | /path.py | 767 | 3.71875 | 4 |
class Path:
def __init__(
self,
angle,
location,
parents
):
# open to suggestions for variable names as these are kinda long!
self.foraging_pheromone = 0
self.exploration_pheromone = 0
self.angle = angle
# Not sure which is... |
f8e1b71568fbd2ea1e73cbe2cb164be0f0080a6b | HelloImKevo/PyPlayground | /src/tools/easy_crypt.py | 441 | 3.921875 | 4 | """I have no idea how this works!"""
def message(text, plain, encryp):
dictionary = dict(zip(plain, encryp))
newmessage = ''
for char in text:
try:
newmessage += dictionary[char]
except StopIteration:
newmessage += ' '
except IOError:
newmessage ... |
c2778fdc9169f3376f87d1e8b9b0302bf75a3d4b | GLAU-TND/python-lab-coolcodehk | /ques2.py | 394 | 3.703125 | 4 | #type error
try:
a=5
b='hk'
c=a+b
except TypeError:
print("Type Error")
else:
print('sucessfull')
#value error
try:
print(float('hk'))
except ValueError:
print("value Error")
else:
print('Sucess')
#atrribute Error
class Attributes(object):
a=2
try:
object=Attributes()
p... |
4ec5cc5fe8691664973fab740b0e6e8436e8e990 | mossingj1/CS50-Introduction-to-Computer-Science | /pset6/dna/dna.py | 3,118 | 3.921875 | 4 | from sys import argv
import csv
def main():
# Check for correct number of command line arguments.
if len(argv) != 3:
print("Usage: TBD")
exit(1)
# Extract names and individual SRT values from CSV file
data = get_data(argv[1])
# List of SRT's in CSV file
SRT = data[0]
# Li... |
af3ccd9f00a5b6f4b2a32460921b5936d5fff2a9 | longmen2019/Challenges- | /find an index number in an array.py | 367 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 1 18:18:37 2021
@author: men_l
"""
myarray = list(range(21))
print(myarray)
import numpy as np
myarray = np.array(myarray)
print(myarray)
def findIndexNumber(array, value):
for i in range (len(array)):
if array[i] == value:
print... |
8d6570ca6f135bcf1fa8caf94c374e4f2efbd4d7 | longmen2019/Challenges- | /Euler_Project_Problem_4.py | 736 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 8 21:22:28 2021
@author: men_l"""
"""A palindromic number reads the same both ways. The largest plindrome made from the product of two 2-digit numbers is
9009 = 91 x 99.
Find the largest palindrome made from the product of two 3-digit numbers"""
def is_pal... |
85ba509d6a9b622a780b761a96acac9f08b0d247 | amdadul3036/Python-for-Everybody | /Programming for Everybody (Getting Started with Python)/Week 6/assignment4.6.py | 287 | 4.03125 | 4 | def computepay(hours,rate):
if hours > 40:
pay = rate * 40.0
pay = pay + (1.5*rate*(hours - 40))
else:
pay = rate * 40
return pay
#return 42.37
hours = float(input("Enter Hours:"))
rate = float(input("Enter rate per hour: "))
p = computepay(hours,rate)
print('Pay',p) |
d0b31a5522ed73b5a6cdac39626ee8ca707cfc6e | Lomilpda/Lab_Python | /second_lab/2-3.py | 205 | 3.75 | 4 | sentence = 'she sell sea shells by the sea shore'
sentence = sentence.split()
new_string = ''
for word in sentence:
if word.startswith('se'):
new_string = 'like'+word
print(new_string)
|
8eff7d0e679b2c30ac2f704e9480ff346dd0883f | Lomilpda/Lab_Python | /first_lab/1-21.py | 783 | 4.21875 | 4 | """
21. Напишіть програму, яка створить стрічку в якій будуть записані
другі символи всіх слів з стрічки silly.
"""
silly = "newly formed bland ideas are inexpressible in an infuriating way"
silly = silly.split() # создаем из строки список, разделяя по пробелу
new_str = ''
for word in silly: # перебор всех слов в спи... |
b9fedf7eebb975fa0e3749471197f50ca4f211f5 | Lomilpda/Lab_Python | /second_lab/2-12.py | 325 | 3.53125 | 4 | import nltk
<<<<<<< HEAD
from nltk.book import text1
average_lenght = sum([len(word) for word in text1])/len(text1)
print(round(average_lenght, 4))
=======
from nltk.book import *
average_lenght = sum([len(word) for word in text1])/len(text1)])
print(round(average_lenght, 4)
>>>>>>> 19089d018dfd1bf25b32cb66dbe501d1098f... |
dd2c0b990337849b845ce3b74ed03d08367e8b5a | Twinkle0057/HowMuchDidYouRead | /new.py | 928 | 3.703125 | 4 | import sys
def listToString(t):
s = ""
for i in t:
s = s + " " + i
return s[1:]
def process(arr):
bookPages = []
bookRead = []
for line in arr:
line = line.split()
k = 1
for word in line:
if "pages" in word and k == 1:
word = word.replace("pages", "")
bookPages.append(int(word))
k = k+1
... |
3d591a33ae1cd1f0f03a67b14482537a817440c3 | rjquillen/senior-seminar-project | /Adafruit-Motor-HAT-Python-Library/examples/Robot.py | 5,383 | 3.78125 | 4 | # Simple two DC motor robot class. Exposes a simple LOGO turtle-like API for
# moving a robot forward, backward, and turning. See RobotTest.py for an
# example of using this class.
# Author: Tony DiCola
# License: MIT License https://opensource.org/licenses/MIT
import time
import atexit
from Adafruit_MotorHAT import... |
117ea1df94987806330f582fa509a39eb85003e8 | IlyaPyatkin/HLM-Genetic | /Geometry.py | 1,087 | 3.53125 | 4 | from functools import reduce
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
@staticmethod
def points_center(points):
center = reduce(lambda p1, p2: Point(p1.x + p2.x, p1.y + p2.y), points)
x = (center.x / len(points) + 0.5)
y = (center.y / len(points)... |
9453b6e990dd2e2c62899eaa8ccaeae2cc6a2b95 | mpaulweeks/parser-test | /json_wrapper.py | 400 | 3.515625 | 4 | from parser import Parser
class JSON_Wrapper:
parser = Parser()
def json(self, file):
entries = []
error_lines = []
line_number = 0
for line in file:
result = self.parser.parse_line(line)
if "error" in result:
error_lines.append(line_number)
else:
entries.append(result)
line_number += ... |
3d3f20f774ef6b7cee8cbed97dc1d96462fb2876 | wzrumich/serverlessCompiler | /inliner/inlineTest/unitTest/test1.py | 465 | 3.765625 | 4 | def test12():
print("test12 begins")
print(12)
print("test12 ends")
return 1
def test34(ooo):
print("test34 begins")
ooo = ooo * 34
print(ooo - 34)
print("test34 ends")
return ooo + 1
def test56():
print("test56 begins")
y = test12()
print(y)
print("test56 ends")
... |
a3a111b2e3c46479cab62acca662b3fe03a21320 | michellevrp/Python_Course | /Getting-Started-with-Python/pay_calculator_function.py | 458 | 4.09375 | 4 | #fourth exercise
#This code asks the user for hours and rate for hour, calculate total pay by computepay function, and print it.
#If more than 40 hours, the rate is 1.5 the initial rate.
hrs = input("Enter Hours:")
rate = input("Enter Rate:")
try:
h = float(hrs)
r = float(rate)
except:
print("Insert numbers")
d... |
86e177f18171b8c0611d9297bfd61609fce137ab | ImadDabbura/Deep-Learning | /scripts/coding_neural_network_from_scratch.py | 14,973 | 3.8125 | 4 | """
Implement fully connected neural network using Numpy.
"""
import matplotlib.pyplot as plt
import numpy as np
def initialize_parameters(layers_dims):
"""
Initialize parameters dictionary.
Weight matrices will be initialized to random values from uniform normal
distribution.
bi... |
d1ff7ecbebfdc97fcde089c6ba411bf52ce91778 | MattiooFR/project-euler | /Problem_5.py | 799 | 3.9375 | 4 | # 2520 is the smallest number that can be divided by
# each of the numbers from 1 to 10 without any remainder.
# What is the smallest positive number that is
# evenly divisible by all of the numbers from 1 to 20?
# def divisible(number):
# return all([not bool(number % i) for i in [20, 19, 18, 17, 16, 15, 14, 13... |
3fc03e43414a20f262f3955d274c94854443fafc | sundarideas2it/python | /dictionary.py | 917 | 3.859375 | 4 | """
Filename: dictionary.py
Author: Sundar P
Created On: 25 Jan 2017
Description: examples for dictionary related syntax
"""
dicvar = {'Test1':1001,'Test2':2010}
print(dicvar)
print(list(dicvar.keys()))
print(list(dicvar.values()))
dicvar = ('Test1',1001),('Test2',2010)
print(dicvar)
print(dict(dicvar))
forvar =... |
abe7ce0a177fd65e59a779a87438ed2008d8a54e | sundarideas2it/python | /fibonacci.py | 243 | 3.59375 | 4 | """ Filename: fibonacci.py
Author: Sundar P
Created On: 10 Jan 2017
Description: Fibonacci sequence
"""
n, a, b=10, 0, 1
print('Print Fibonacci sequence upto', n) #print is used display the given values
while(b < n):
print(b)
a, b=b, a+b
|
8ca9e8ef027bc56ef4a3860c94027a1360338ee1 | silverzzzzz/study06 | /api1.py | 587 | 3.5 | 4 | import requests
import urllib
def get_api(url):
result = requests.get(url)
return result.json()
def main():
keyword = input("キーワードを入力してください>>>")
#https://webservice.rakuten.co.jp/api/ichibaitemsearch/参照
#elements,カンマ区切りで出力pram指定
#商品名itemName,価格itemPrice
url = "https://app.r... |
dfc04c53bef6564fbf2d5c99647010161d7c1630 | gdotmount/CS313E | /A10/Fibonacci.py | 1,055 | 3.9375 | 4 | # File: Fibonacci.py
# Description:
# Student's Name: Gabriel Mount
# Student's UT EID: gmm2767
# Partner's Name:
# Partner's UT EID:
# Course Name: CS 313E
# Unique Number:
# Date Created: 10/09/2020
# Date Last Modified: 10/09/2020
import sys
memo = {}
def f(n):
if n == 0:
return '0'
eli... |
117b8e81da591cece71cd39e6f04ef762d5f3c4d | gdotmount/CS313E | /A18/TestLinkedList.py | 8,291 | 3.875 | 4 | # File: TestLinkedList.py
# Description:
# Student Name: Gabriel Mount
# Student UT EID: GMM2767
# Partner Name:
# Partner UT EID:
# Course Name: CS 313E
# Unique Number: 50845
# Date Created: 11/03/2020
# Date Last Modified:
import copy
class Link(object):
def __init__(self, data, next=None)... |
e9892043bd91b8b1317acc0c1180fd7f9af355a3 | WilliLam/Python-ML | /linear regression/matplot.py | 567 | 4.03125 | 4 | import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import LinearRegression
model = LinearRegression()
X = np.array([[6],[8],[10],[14],[18]]).reshape(-1,1)
y = [7,9,13,17.5,18]
model.fit(X,y)
test_pizza = np.array([[12]])
predicted_price = model.predict(test_pizza)[0]
print("a 12... |
52211cbe07d9cb812e01c77bb8de025392de0360 | dfranklinau/astronote | /astronote/bodies.py | 3,954 | 3.84375 | 4 | # -*- coding: utf-8 -*-
###############################################################################
# Bodies
###############################################################################
# Methods that calculate information for planetary bodies, including
# oppositions, conjunctions, elongations and visibility ... |
608a20a4d01b96b04db2f8cdccea6f9a73e078ad | rockchar/OOP_PYTHON | /PythonRegularExpressions.py | 2,146 | 4.5625 | 5 | #here we will discuss the regular expresssions in python
#import the regular expression module
import re
pattern = "phone"
text = "the agents phone number is 400-500-600"
print(pattern in text)
#now lets search the pattern using regular expressions
print(re.search(pattern,text))
#lets assign a match object
match =... |
01c3d559c8a51349938c70400e6b996d417861d6 | rockchar/OOP_PYTHON | /ClassInheritance.py | 637 | 4.40625 | 4 | ''' here we will discuss class inheritance '''
class Animal():
def __init__(self,type,name):
print("animal created")
self.type=type
self.name=name
def who_am_i(self):
print("I am an animal")
def eat(self):
print("I am an animal eating")
class Dog(Animal):
def ... |
35aac68f8c165dc3fb90d0cefcf051520e844e7c | gamgud/gggggg | /gudgam.py | 10,240 | 3.734375 | 4 | from tkinter import *
import os
import random
from tkinter import messagebox
root = Tk()
answers = [
"BOTTLE",
"GAMER",
"COMPUTER",
"SCIENCE",
"INDIA",
"AMERICA",
"DUBAI",
]
jumbled_words = [
"TOLETB",
"MAGER",
"PCEUORTM",
"CEISNEC",
"AIDIN",
"AIEARCM",
"BUDIA",... |
25ac1c14fcf74d01ff84c4cb8b8410b04183c384 | GregoryREvans/evans | /research/farey_series.py | 1,132 | 3.78125 | 4 | class Term:
# Constructor to initialize
# x and y in x/y
def __init__(self, x, y):
self.x = x
self.y = y
# GCD of a and b
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
# Function to print
# Farey sequence of order n
def farey(n):
# Create a vector to
#... |
31ac59afcc51dc8aeda5f19c5eac8d864c990e57 | marconilabs/cubes | /tutorial/tutorial_01.py | 2,372 | 3.765625 | 4 | import sqlalchemy
import cubes
import cubes.tutorial.sql as tutorial
# 1. Prepare SQL data in memory
engine = sqlalchemy.create_engine('sqlite:///:memory:')
tutorial.create_table_from_csv(engine,
"data/IBRD_Balance_Sheet__FY2010.csv",
table_name="irbd_balance",
... |
df1dad41db36bfa1940c8a43d6a278b8e4a30b7f | kwmoy/py-portfolio | /pre_2022/sort_array.py | 748 | 4.40625 | 4 | def sort_array(arr):
"""This function manually sorts an input array from ascending to descending order."""
sorted_arr = []
# Start off our list
sorted_arr.append(arr.pop())
print(sorted_arr)
for number in arr:
# With input arr, we compare it to each number currently in the list.
for i in ra... |
1f36fbbf2c3d3b53eb60a34365ea8132c26b37f9 | xuaoneto/Lista-Pilha-Fila-ED | /AlgoritmosdeOrdenaçãoPY/bubblesort.py | 338 | 3.8125 | 4 |
def BubbleSort(array):
for i in range(len(array)):
troca = False
for k in range(len(array)-1):
if array[k] > array[k+1]:
aux = array[k]
array[k] = array[k+1]
array[k+1] = aux
troca = True
if not troca:
... |
cd00a6e3d66ebcf437374622ca1c0b73add18081 | Jaydenmay-040/Data-distributation | /main.py | 320 | 3.5625 | 4 |
import matplotlib.pyplot as plt
x = [14.2, 16.5, 11.8, 15.3, 18.8, 22.5, 19.5]
y = [220.00, 330.00, 190.00, 340.00, 410.00, 445.00, 415.00]
# labeling and visuals
plt.xlabel("Temperatures(Degrees Celsius)")
plt.ylabel("Price in Rands(R)")
plt.title("Soup sales in relation to temperature")
plt.scatter(x, y)
plt.show()
|
fc6dd3b29f582db049c2c6c4c1d3d3d7964e627e | AmirMohamadBabaee/dijkstra-python | /Shortest Path/MinHeap.py | 4,509 | 3.640625 | 4 | import sys
from collections import defaultdict
class MinHeap:
"""
This class is an implementation for MinHeap in python
"""
def __init__(self, array= []):
self.heap_size = len(array)
self.nodes = array.copy()
self.hash_node = defaultdict(list)
if self.heap... |
d1933edbf3ef92526b5c2ba35c36e6bbf8e012b7 | madsaken/forritunh19 | /move.py | 1,595 | 4.34375 | 4 | Left = 1
Right = 10
def moverFunction(x):
#This function makes a new board.
newLocation = x
newX_left = newLocation-Left
newX_right = Right-newLocation
newBoard = "x"*newX_left + "o" + "x"*newX_right
print(newBoard)
ans = 'l'
placement = int(input("Input a position between 1 and 10:... |
04b90cc05f322dd3ef3527877f24d64d196ebced | madsaken/forritunh19 | /int_seq.py | 910 | 4.4375 | 4 | #Variables that will store data from the user.
count = 0
summary = 0
even = 0
odd = 0
largest = 0
current = 1 #Note that 'current' must start with the value 1 otherwise the loop will never start.
#A loop that will end when the user types in either 0 or less than zero.
while current > 0:
current = int(input('Enter ... |
b2bd249b33135647a480e3cb015a8600f238d520 | avmepy/applied_programming | /hw/T07(web server)/T7.1/cgi-bin/main.py | 724 | 3.546875 | 4 | #!/usr/bin/env python3
# -*-encoding: utf-8-*-
# author: Valentyn Kofanov
import cgi
HTML_PAGE = """Content-type: text/html; charset='utf-8'\n\n
<html>
<title>factorial check</title>
<body>
<form method="POST" action="http://localhost:8000/cgi-bin/main.py">
<p>Enter number: </p>
<input type=text name=val value="">... |
9028206fac76d1fc18efdd3dfaa544ff3d16a8b2 | avmepy/applied_programming | /hw/T21(regular)/2/main.py | 833 | 3.640625 | 4 | #!/usr/bin/env python3
# -*-encoding: utf-8-*-
# author: Valentyn Kofanov
import re
WORDS = ['error', 'warning', 'critical']
def main(filename_input, filename_output, words, register=True, whole=True):
with open(filename_input, 'r') as fin:
st = fin.read()
for word in words:
if register... |
004af93ee00164f3fe5ceb9d1206732698855a59 | avmepy/applied_programming | /hw/T08(db)/T29.10/main.py | 2,984 | 3.765625 | 4 | #!/usr/bin/env python3
# -*-encoding: utf-8-*-
# author: Valentyn Kofanov
import sqlite3
from tkinter import *
class ToysDB:
def __init__(self, filename):
self.filename = filename
def create(self):
conn = sqlite3.connect(self.filename)
curs = conn.cursor()
try:
... |
82b5a65ce0302d254c321168bc170cfc2e7a84b8 | v2thegreat/3D-Printer-Information-Screen | /src/3D_Printer_Information_Screen/Personnel.py | 11,128 | 3.515625 | 4 | # pylint: disable=invalid-name
# pylint: disable=pointless-string-statement
# pylint: disable=too-few-public-methods
import pickle
from os import rename, remove, listdir
PERSONNEL_INFO_CSV = 'Personnel Info.csv'
PERSONNEL_INFO_TXT = 'Personnel Info.txt'
AdminUsername = 'Admin'
AllPossibleCommands = """
Commands ... |
cfd14a4d8414039523c201f08a9031c6d6d31f23 | ryanlpeterson/database-manager | /Table.py | 4,463 | 3.6875 | 4 | import os
from Record import Record
class Table:
__records = []
__longest_title = ""
__longest_length = 0
__longest_amount_completed = 0
__table_title = ""
def __init__(self, table_title):
self.__table_title = table_title
def add_item(self, record):
self.__... |
fed98b93dc7828c88b7b5c972e523399935210e9 | Affanmir/Image-Manipulation-with-python | /myimage.py | 17,400 | 3.765625 | 4 | import PIL
from PIL import Image
import array as arr
import numpy as numpy
class MyListIterator:
''' Iterator class to make MyList iterable.
https://thispointer.com/python-how-to-make-a-class-iterable-create-iterator-class-for-it/
'''
def __init__(self, lst):
# MyList object... |
21f62f5134ed9e3a0b2a3cd67b03ad4b938ff0db | santmendoza/Parcial | /oc.py | 1,556 | 3.90625 | 4 |
from sys import argv
class Validar:
def __init__(self,conjunto1):
self.conjunto1 = conjunto1
def val_sintaxis(self,conjunto):
if conjunto.count(',,')==0 and conjunto.find(',')!=1 and conjunto.rfind(',')!=len(conjunto)-2 and conjunto.find('{')==0 and conjunto.rfind('}')==len(conju... |
fbf5fbd0223d8a8e45ca625d2951e7ada553bbea | EmereArco/ReadCsv | /Read_csv.py | 2,994 | 3.765625 | 4 | import csv
# STEP 1 - funzione che printa il csv riga per riga
def read_csv(filecsv):
csvfile = open(filecsv, 'rb')
csvreader = csv.reader(csvfile, delimiter=';')
result = ''
for row in csvreader:
result += str(row) + '\n'
return result
# print read_csv('ORARI.csv')
... |
e2c789a6e12d9b8e325f2191d70778b5ea0e718f | Aadhar3/minesweeper | /python/solver.py | 5,373 | 3.890625 | 4 | import random
from board import Board, Game
class Solver:
def __init__(self, board):
"""Create a new instance of the minesweeper solver
Arguments:
board: the minesweeper board to be solved
"""
self.board_object = board
self.board = self.board_object.board
... |
d49e726aff975bbe7a66707efea6054b2d1d0ba6 | JasonNgo/Algorithms | /PowerSet.py | 277 | 3.90625 | 4 | # Power Sets: Calculate all unique subsets of a given array
def powerSet(array):
subsets = [[]]
for element in array:
for i in range(len(subsets)):
currentSubset = subsets[i]
subsets.append(currentSubset + [element])
return subsets
|
8fa318635f73dff21b29e9226304c2377eb43f93 | AdaCore/Ada_Drivers_Library | /scripts/config/validation.py | 3,235 | 3.796875 | 4 | #! /usr/bin/env python3
class Int_Validation:
def __init__(self, min_value=None, max_value=None):
self.min_value = None if min_value is None else int(min_value)
self.max_value = None if max_value is None else int(max_value)
def __call__(self, value):
try:
int_val = int(va... |
c6e83f9e36fc5632fa2de933776d77625ffda9b3 | AEJ-FORMATION-DATA-IA/Exo_Python_NEMA | /algo.py | 435 | 4.09375 | 4 | A = input("Entrez un nombre entier : ")
int(A)
A = int(A)
if(type(A) != int):
print("Vous avez fait une erreur.")
else:
B = input("Entrez un autre nombre entier : ")
int(B)
B = int(B)
if(type(B) != int):
print("Vous avez fait une erreur.")
elif ( A > B ):
print(f"... |
6e9fccd21852955901c8444b56fbe0d5fb874272 | joel-simon/evoDesign | /experiments/utilities.py | 784 | 3.9375 | 4 | def max_area_histogram(heights):
""" Solve the 'largest rectangle under histogram' problem.
http://www.geeksforgeeks.org/largest-rectangle-under-histogram/
"""
S = [] # stack to store heights.
max_area = 0
i = 0
while i < len(heights):
if (len(S) == 0) or (heights[S[-1]] <= heig... |
c4887967c4468c0a21d17540df6a4da41d09d4a6 | tausiq2003/Hacktoberfest-Python | /tictactoe_game.py | 2,498 | 4 | 4 | import numpy as np
l=[1,2,3,4,5,6,7,8,9]
print("1- This game is a two member game only")
print("2- 1st player is 'X' & 2nd player is 'O'")
print("3- The player will win if it makes 3 symbol in same row,same column or same diagonal")
def fun():
print("\n")
print(" | | ")
print(" ... |
d902274351fadff02046465b2d37c7828189d659 | arjundas1/MFC-Tasks | /Task1.py | 5,197 | 3.671875 | 4 | # 1. Importing all the necessary libraries.
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import sklearn
import pickle
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import KNeighborsClassifier
from sklearn import preprocessing, svm, metrics
# ... |
96d639c451a90b25607f4b02af501a0bafe07506 | istrupin/python-practice | /src/Arrays/order_checker.py | 386 | 3.546875 | 4 | from typing import List
def check_order(di: List[int], ta: List[int], fulfilled: List[int]) -> bool:
t, d = 0, 0
for order in fulfilled:
if d < len(di) and di[d] == order:
d += 1
elif t < len(ta) and ta[t] == order:
t += 1
else:
return False
retu... |
6d30ddf10a6c8eb7ea18816622891edf5a3cf2c6 | istrupin/python-practice | /src/searchingAndSorting/find_pivot.py | 656 | 3.84375 | 4 | from typing import List
def find_pivot(arr:List[str]) -> int :
l, m, r = 0, len(arr) // 2,len(arr) - 1
#see if l -> m is sorted, if so this is rotation point
while l <= r:
m = l + ((r - l) // 2)
if arr[m-1] > arr[m]:
return m
elif arr[l] <= arr[m] and arr[m] <= arr[r]:
... |
15c53e55852be50456d7b879c0ebda60364e2699 | istrupin/python-practice | /reverselist.py | 298 | 3.859375 | 4 | from typing import List
def reverseList(list:List):
if list is None or len(list) == 0:
return
for i in range(0, len(list)//2):
complement = len(list) - i - 1
(list[i], list[complement]) = (list[complement], list[i])
a = ['a']
reverseList(a)
print(a)
|
438c63d072b0926bb243c0a5adec7bd4c09f1c57 | istrupin/python-practice | /src/dynamic/make_change.py | 1,653 | 3.5625 | 4 | from typing import Set, List
def make_change(amount:int, denominations:List[int]) -> List[List[int]]:
res = []
change_helper(amount, denominations, [], res)
return res
def change_helper(amount:int, denominations:List[int], so_far:List[int], results:List[List[int]], memo = {}, index = 0):
if amount ==... |
18fdf63e82eec6d76740837c5db6cafcce903c33 | 633-1-ALGO/introduction-python-Garmilan | /12.1- Exercice - Listes et Tableaux/liste1.py | 1,023 | 3.875 | 4 | # Problème : Réaliser une table de multiplication de taile 10x10 en utilisant la liste fournie.
# Résultat attendu : un affichage comme ceci : 1 2 3 4 5 6 7 8 9 10
# 1 1 2 3 4 5 6 7 8 9 10
# 2 2 4 6 8 10 12... |
0564c1eda7c4e05af33f529322b5f51dec67cb0f | rembold-cs151-master/Lab_SetSieve | /Lab20.py | 1,415 | 4.1875 | 4 | """
Investigating the number of words in the english language that can
be typed using only a subset of modern keyboard layouts.
"""
from english import ENGLISH_WORDS
import time
QWERTY_TOP = "qwertyuiop"
QWERTY_HOME = "asdfghjkl"
QWERTY_BOT = "zxcvbmn"
DVORAK_TOP = "pyfgcrl"
DVORAK_HOME = "aoeuidhtns"
DVORAK_BOT = "... |
1c4e81b4110935092be111fd9216a25449867a88 | aarron/sandbox | /zippy.py | 326 | 3.625 | 4 | # combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
# If you use .append(), you'll want to pass it a tuple of new values.
def combo(it1, it2):
l1, l2 = list(it1), list(it2)
mytups = ()
for index, item in enumerate(l1):
thetup = (l1[index], l2[index])
mytups.append(thetup)
return ... |
26486c39f177305fc27657d5f56fde8df29e3703 | xubaoshi/learn | /project/python/basic.py | 1,580 | 3.71875 | 4 | import datetime
import sys
import os
import time
# odds = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
# right_this_minute = datetime.today().minute
# if right_this_minute in odds:
# print('This mimute seems a little odd')
# elif right_this_minute in odds:
# print('Not an odd minute.')
# print(sys.platform)
# print(os... |
cb47d28fd0ef6dcedf87dd10543bb4906cd6acad | PascalUlor/code-challenges | /python/insertion-sort.py | 930 | 4.21875 | 4 | """
mark first element as sorted
loop through unsorted array from index 1 to len(array)
'extract' the element X at index i as currentValue
set j = i - 1 (which is the last Sorted Index)
while index of sorted array j >= 0 and element of sorted array arr[j] > currentValue
move sorted element to the ri... |
ca469bd9acb7c2fdba8ec887fc1e1eb531140dfb | PascalUlor/code-challenges | /python/linked_list_1.py | 6,447 | 4.25 | 4 | # Create Node constructror
class ListNode(object):
def __init__(self, value=None):
self.data = value
self.next_node = None #address to next node
# def __str__(self):
# return f"{self.data} → {self.next_node}"
# node = ListNode(5)
# node.next_node = 2
# print(node)
# create List Constr... |
e8fac8ecfa9d988f43c1bf80bb03ed3a7c64e54b | PascalUlor/code-challenges | /python/isBalanced.py | 2,310 | 4.0625 | 4 | import time
"""
By this logic, we say a sequence of brackets is balanced if the
following conditions are met:
1. It contains no unmatched brackets.
2. The subset of brackets enclosed within the confines of a matched pair of
brackets is also a matched pair of brackets.
Given strings of brackets, determine whether eac... |
ba595f4d529cdeec8442142a9c42f1a77b45ca3a | PascalUlor/code-challenges | /.leetcode/133.clone-graph.py | 3,662 | 3.671875 | 4 | #
# @lc app=leetcode id=133 lang=python3
#
# [133] Clone Graph
#
# https://leetcode.com/problems/clone-graph/description/
#
# algorithms
# Medium (42.10%)
# Likes: 4354
# Dislikes: 2080
# Total Accepted: 592.2K
# Total Submissions: 1.3M
# Testcase Example: '[[2,4],[1,3],[2,4],[1,3]]'
#
# Given a reference of a n... |
cdacfd72c015dfe2688cd4647eebea2369ebf1cd | PascalUlor/code-challenges | /python/angry_child.py | 1,618 | 3.609375 | 4 | """
1. Sort the array. The selected packets must be a subarray of k elements
2. Take a subarray of m elements and assume we have calculated the sum of the elements to be s and the unfairness sum to be u
Imagine what would happen to s and u if we add the next element to the subarray
Imagine what would happen to s and u ... |
a07b354a91aac112f25492ebc4366f1e81c089ca | PascalUlor/code-challenges | /python/sherlocks_valid_string.py | 1,678 | 4.09375 | 4 | def isValid(s):
# get the number of occurrence of each character
# create a counter to log number of occurrnce of charaters
# cache number of occurrence of each character in dict
# if all char occur is even or odd occur not > 1 return true
# else false
char_count = {}
for i in range(0, len(... |
823d5e34bc3d07ec31a5b10f31b4d5d7a544f3d9 | gagnonma/CIS365AIProject | /pathfinder.py | 6,818 | 3.515625 | 4 | import string
class Node:
def __init__(self, name):
self.adjacentVertices = set()
self.wallVertices = set()
self.name = name
def addWallVertex(self, vertex):
self.wallVertices.add(vertex)
vertex.wallVertices.add(self)
def getWallVertices(self):
ret... |
3fb6e4dd6dd7d392a65ad4ac5245469b4b59d59c | blackwraithh/hw15 | /homework_l15.py | 3,795 | 3.59375 | 4 | from typing import Any
import re
import collections
# Решить задачи, выложить .py файл с решениями на github. В личный кабинет прикрепить .txt файл с ссылкой на репозиторий.
# Задача 1. Найти количество различных элементов массива. Пример: для [1 4 5 1 1 3] ответ 4.
# def count_unique_elems(arr: list[Any])... |
d8a3a29257d1bf19fd7f32823fd29d243fd17fdd | AnandDhanalakota/Vin-Pro | /Python/sum2x2mat.py | 285 | 3.59375 | 4 |
mat = []
row = []
for i in range(2):
row.append(int(raw_input("Enter element")))
mat.append(row)
row = []
for i in range(2):
row.append(int(raw_input("Enter element")))
mat.append(row)
sum=0
for row in mat:
for col in row:
sum+=col
print mat,sum
|
cbd9c4403c07376f94f1dfca910e4a4142b88b7b | joshua9889/ENR120 | /09.07.17/9.7.17.py | 697 | 4.09375 | 4 | import logging
def calculate(first_, second_, third_):
return ((first_**2)+(second_**3))**(1./third_)
print ((3**2)+(6**3))**(1/2.)
print ((3**2)+(6**3))**(1/2)
print ((3**2)+(6**3))**(0.5)
print 0.5
print 1.0/2.0 #Returns float
print 1/2 #Returns int
while(True):
try:
t = str(input("Enter number: ")... |
072a24baab732c2ad8cf526ad0432f958ab221ad | joshua9889/ENR120 | /09.11.17/tempConv.py | 209 | 4.21875 | 4 | # A Celsius to Fahrenheit. conver
print "Convert Celsius to Fahrenheit."
degreeC = input("Please input celsius: ")
degreeF = degreeC*9./5. +32 # Calculate Fahrenheit.
print 'Fahrenheit value: ' + str(degreeF)
|
3e02f03051ab887913b1ea1cb591a7a9cd3a5267 | hjain28/Machine_Learning | /DNN.py | 2,985 | 3.578125 | 4 | from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
import tensorflow as tf
# Parameters
learning_rate = 0.001
batch_size = 100
beta = 0.01
# Network Parameters
n_hidden_1 = 250 # number of hidden nodes in layer1
n_hidden_2 = 250
n_hidden_3 = 250
... |
b827a032697734e8ea3406488de010df035d7410 | sourabhligade/fizzbuzz-code | /Untitled32.py | 314 | 3.828125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
def fizz_buzz(num):
if num%3==0 and num%5==0:
return 'fizzbuzz'
elif num % 3==0:
return 'fizz'
elif num % 5==0:
return ' buzz'
else:
return num
for i in range(1,100):
print (fizz_buzz(i))
# In[ ]:
|
8baa4e466f1b4615fd1c43f9eea46a170aad2f1b | arkostin/5pclass | /5pclass/pa3.py | 206 | 4.0625 | 4 | #!/usr/bin/python3
from random import randrange
a = int(input("How many experiments should run?"))
b = 0
for i in range(a):
b += randrange(1, 7)
b /= a
print("The average after", a, "experiments is", b)
|
170a77aa72f4db209fba5e8cb768a29356f91c8f | 17TigerLillys/python-challenge | /mainPoll.py | 1,288 | 3.5 | 4 | import os
import csv
voteCounter=0
candidateList=[]
candidate_count=0
candidate_name=""
winner_count=0
winner=""
csvpath=os.path.join('Resources', "election_data_2.csv")
vpath=os.path.join('Resources', "budget_data_1.csv")
with open(csvpath) as csvfile:
csvreader=csv.reader(csvfile, delimiter=",")
n... |
0650479d727f15987ef0e22dba65dec2a391d453 | jrlepere/CourseWork | /CPP_CS331_DesignAndAnalysisOfAgorithms/SelectKthSmallestProject/src/merge_sort.py | 1,740 | 3.8125 | 4 | from random import randint
# Merge Sort
def merge_sort(x):
if len(x) <= 1:
return x
else:
mid = len(x)/2
left = merge_sort(x[0:mid])
right = merge_sort(x[mid:len(x)])
left_i = 0
right_i = 0
x_i = 0
while (left_i < len(left)) and (right_i < len(rig... |
3f28a993a50d887f1851b3ba7aafe361f8dee56f | waltleeee/PythonProject | /PythonProject/practice/plugin/function.py | 208 | 3.90625 | 4 | def max(a,b):
return a if a>b else b
def min(a,b):
return a if a<b else b
print(max(10,5))
maxf=max
print(maxf(11,6))
minf=lambda a,b:a if a<b else b
print(minf(5,6))
minf2=minf
print(minf2(9,15)) |
8ae6cee5de0e74d9bc2a6f2b64618025d1c5b5e0 | bkbhanu/mytrypy2 | /helloworld.py | 290 | 3.734375 | 4 | print("Hello World !")
name=input("Enter your Name:")
#print("Hello "+name)
#a = 0
#while a<100:
# a=a+1
# if a%2==0:
# print(a)
# print(a**2)
# print("---")
# print(a**3)
# print("---")
#file object = open("C:\Python34\news.txt", "r")
|
fd7f46fa761ce3addd44b33f9bb0aa75cbf26b00 | ticotheps/practice_problems | /edabit/easy/amplify_multiples_of_four/amplify.py | 3,306 | 4.375 | 4 | """
AMPLIFY THE MULTIPLES OF FOUR
Create a function that takes an integer and returns a list from 1 to the given
number, where:
(1) If the number can be divided evenly by 4, amplify it by 10 (i.e. - return 10 times the number).
(2) If the number cannot be divided evenly by 4, simply return the number.
... |
331390dde109a4b9779b31522e4adcb520b908a2 | ticotheps/practice_problems | /code_signal/arcade/smooth_sailing/common_character_count/common_character_count.py | 950 | 4.21875 | 4 | """
****** UNDERSTAND Phase ******
Given two strings, find the number of common characters between them.
- Example:
- Inputs: "aabcc", "adcaa" (2; string data type; "s1" & "s2")
- Outputs: 3 (1; integer data type; "num_common_chars")
"""
def commonCharacterCount(s1, s2):
s1_dict = {}
s1_list = [x for ... |
cde036f6381893e9cd8cb5dde13155aa92194870 | ticotheps/practice_problems | /edabit/medium/shared_letters/shared_letters.py | 2,306 | 4.34375 | 4 | """
LETTERS SHARED BETWEEN TWO WORDS
Create a function that returns the number of characters shared between two
words.
Examples:
- get_shared_letters('apple', 'meaty') -> 2
- get_shared_letters('fan', 'forsook') -> 1
- get_shared_letters('spout', 'shout') -> 4
"""
"""
PHASE I - UNDERSTAND THE PROBLEM
Ob... |
3f8c4cb55b2e98e44e7c6f27e1cf059ded79064e | ticotheps/practice_problems | /edabit/hard/purge_and_organize/purge_and_organize.py | 5,227 | 4.09375 | 4 | """
PURGE AND ORGANIZE
Given a list of numbers, write a function that returns a list that...
1. has all duplicate elements removed.
2. is sorted from least to greatest value.
Examples:
- unique_sort([1, 2, 4, 3]) -> [1, 2, 3, 4]
- unique_sort([1, 4, 4, 4, 4, 4, 3, 2, 1, 2]) -> [1, 2, 3, 4]
- unique_sort(... |
26b12f3acdcc7266ced0bf8c9fb1046223588f9e | ticotheps/practice_problems | /algo_expert/easy/twoNumberSum/official_twoNumberSum.py | 1,478 | 3.9375 | 4 | myArray = [3, 5, -4, 8, 11, 1, -1, 6];
# BRUTE FORCE SOLUTION - Nested "for" Loops
# Time Complexity = O(n^2)
# Space Complexity = O(1)
# def twoNumberSum(array, targetSum):
# for i in range(len(array) - 1):
# firstNum = array[i]
# print('firstNum =', firstNum)
# for j in range(i + 1, len(array)):
#... |
a5683a9f6fb1cc226eb09cfc9215bca708bf87eb | ticotheps/practice_problems | /edabit/medium/oop_calculator/test_oop_calculator.py | 965 | 3.921875 | 4 | import unittest
from oop_calculator import Calculator
calculator = Calculator('calculator')
class Test(unittest.TestCase):
def test_add(self):
self.assertEqual(calculator.add(10, 5), 15)
self.assertEqual(calculator.add(10, -5), 5)
self.assertEqual(calculator.add(-10, -5), -15)
def tes... |
19dedc6f1b9082fda0afe546aa7dbd1cab0ba384 | ticotheps/practice_problems | /edabit/medium/a_circle_two_squares/a_circle_two_squares.py | 1,732 | 4.375 | 4 | """
A CIRCLE AND TWO SQUARES
Imagine a circle and two squares: a smaller and a bigger one. For the smaller
one, the circle is a circumcircle and for the bigger one, an incircle.
Objective:
- Create a function that takes in an integer (radius of the circle) and returns
the square area of the square inside the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.