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 |
|---|---|---|---|---|---|---|
38af1cc91d8307cf8d0adfb77e19b558ad5b6bb5 | EngrDevDom/Everyday-Coding-in-Python | /SciPy/polynomials.py | 830 | 4.25 | 4 | from numpy import poly1d
# We'll use some functions from numpy remember!!
# Creating a simple polynomial object using coefficients
somePolynomial = poly1d([1,2,3])
# Printing the result
# Notice how easy it is to read the polynomial this way
print(somePolynomial)
# Let's perform some manipulations
print("\nSquaring ... |
5cd437a5ff34fb62df32139deeda866520fcd5a2 | EngrDevDom/Everyday-Coding-in-Python | /diff_Grav_diff_Res.py | 639 | 3.90625 | 4 | '''
Time and Period
Different Gravity -> Different Results
-> Now, imagine we conducted this experiment in three different places
'''
from sympy import FiniteSet, pi
def time_period(length, g):
T = 2*pi*(length/g)**0.5
return T
if __name__ == '__main__':
L = FiniteSet(15, 18, 21, 22.5, 25... |
d43dcc1e99425696cdaeff16dc969344a3205a95 | EngrDevDom/Everyday-Coding-in-Python | /Identify_triangle.py | 496 | 4.4375 | 4 | # This program identifies what type of triangle it is
# based on the measure of it's angle
angle = int(input("Give an angle in degrees: "))
type = ""
if angle > 0 and angle < 90:
type = "ACUTE"
elif angle == 90:
type = "RIGHT"
elif angle > 90 and angle < 180:
type = "OBTUSE"
elif angle == 180:
type = ... |
01824c8aef821aab863e5d01733c0a6cbf6de479 | EngrDevDom/Everyday-Coding-in-Python | /Quadratic.py | 680 | 4.09375 | 4 | # File : Quadratic.py
# Desc : A program that computes the real roots of a quadratic equation.
# Illustrates use of math library.
# Note: This program crashes if the equation has no real roots.
import math # Makes the math library available.
def main():
print("This program finds the ... |
96ff1baf71e2a5f8e24a0985a95a4cf52e2d14b4 | EngrDevDom/Everyday-Coding-in-Python | /Ladder.py | 447 | 4.46875 | 4 | # File : Ladder.py
# Desc : This program determine the length of the ladder required to
# reach a given height leaned.
import math
def main():
angle = float(input("Enter the value of angle in degrees: "))
radians = math.radians(angle) # Convert degrees to radians
height = float(input(... |
5c65f378b60ff5cbd419a04598be00acec8525f6 | EngrDevDom/Everyday-Coding-in-Python | /quizzes.py | 508 | 4.09375 | 4 | # File : quizzes.py
# Desc : A program that accepts a quiz score as an input and uses a decision
# structure to calculate the corresponding grade.
def main():
grade = int(input("Enter your grade: "))
scale = ''
if grade == 5: scale = 'A'
elif grade == 4: scale = 'B'
elif g... |
268146dd78f992024930942fe373967d6d8d90fa | EngrDevDom/Everyday-Coding-in-Python | /Dog.py | 351 | 3.75 | 4 | class Dog:
kind = 'canine' # class variable shared by all instances
def __init__(self, name):
self.name = name # instance variable unique to each instance
self.tricks = [] # creates a new empty list for each dog
def add_trick(self, trick):
... |
d1db825fe1408cea37babcd9ea843fe5476fd1c1 | EngrDevDom/Everyday-Coding-in-Python | /Calc_Mean.py | 402 | 3.84375 | 4 | '''
Calculating the Mean
'''
def calculate_mean(numbers):
s = sum(numbers)
N = len(numbers)
# Calculate the Mean
mean = s/N
return mean
if __name__ == '__main__':
donations = [100, 60, 70, 900, 100, 200, 500, 500, 503, 600, 1000, 1200]
mean = calculate_mean(donations)
N = len(don... |
5f31d91cf2708bcb155105868279aa6d6f95a80d | EngrDevDom/Everyday-Coding-in-Python | /Web Browser using Tkinter/Web_browser.py | 972 | 3.671875 | 4 | # Create Web Browser using Tkinter
import tkinter as tk
from tkinter import *
import webbrowser
top = tk.Tk()
top.title("Web Browser")
top.geometry("250x250")
top.iconbitmap("wiki.ico")
def google():
webbrowser.open("www.google.com")
def youtube():
webbrowser.open("www.youtube.com")
def twitter():
webb... |
86ef4b0616c3251e465ae372103b27dc4820b7e2 | EngrDevDom/Everyday-Coding-in-Python | /Defining_str_.py | 358 | 3.921875 | 4 | class CarRecord:
def __init__(self):
self.year_made = 0
self.car_vin = ''
# FIXME add __str__()
def __str__(self):
return print('Year: {}, VIN: {}'.format(self.year_made, self.car_vin))
my_car = CarRecord()
my_car.year_made = int(input("Enter car year made: "))
my_car.car_vin = inp... |
65296bbbf2eae04aaa32b73258cc4d4f94ce096f | EngrDevDom/Everyday-Coding-in-Python | /Ch# 118-123.py | 6,014 | 4.15625 | 4 | """ Subprograms """
# Ch 118
def ask_value():
num = int(input("Enter a number: "))
return num
def count(num):
n = 1
while n <= num:
print(n)
n += 1
def main():
num = ask_value()
count(num)
main()
# Ch 119
import random
def pick_num():
low = int(input("Enter the bottom ... |
f5a54240a718fc80a8c65de4baaf5ade4d39ad06 | EngrDevDom/Everyday-Coding-in-Python | /Decomposing_Numbers.py | 450 | 4.0625 | 4 | """
Decomposing_Numbers.py
Decomposing is when we break the number apart.
"""
while True:
user = input('Enter a number: ')
y = user[0] + "0" * (len(user)-1)
res = ""
z = int(user)
for i in range(len(user)):
if y == "0": break
else:
res += y + " + "
... |
087e83c360ece1b9d53baddc60d538d49098d760 | EngrDevDom/Everyday-Coding-in-Python | /Passwords.py | 3,866 | 3.734375 | 4 |
""" Challenge #3 : Passwords.py """
import csv
def get_data():
file = list(csv.reader(open("passwords.csv")))
tmp = []
for x in file:
tmp.append(x)
return tmp
def create_userID(tmp):
name_again = True
while name_again == True:
userID = input("Enter a new user ID: ")
u... |
0cea260a3dcf1852cbd66920e3aa23e94e7d26b7 | EngrDevDom/Everyday-Coding-in-Python | /quadratic_5.py | 702 | 4.1875 | 4 | # File : quadratic_5.py
# Desc : A program that computes the real roots of a quadratic equation. Version 5.0
# Note: This program catches the exception if the equation has no real roots.
import math
def main():
print("This program finds the real solutions to a quadratic\n")
try:
a = ... |
de25351bfb982437ac08ebd4d1c7ba94ffd86490 | EngrDevDom/Everyday-Coding-in-Python | /quizzes_2.py | 549 | 4.1875 | 4 | # File : quizzes_2.py
# Desc : A program that accepts a quiz score as an input and uses a decision
# structure to calculate the corresponding grade.
def main():
grade = int(input("Enter your grade: "))
scale = ''
if grade <= 100 or grade >= 90: scale = 'A'
elif grade <= 89 or grade... |
352ed245d3c6ade57f6b7df5867700e4e3d678f4 | EngrDevDom/Everyday-Coding-in-Python | /A_Shuffling_Problem.py | 2,462 | 4.03125 | 4 | """
+==========+==========-==========*==========-==========+==========+
|| A SHUFFLING PROBLEM ||
|| ||
|| Description: By computer simulation this program determines ||
|| the prob... |
12bd89013323ba49dd1abcc1242c6be976990cbc | EngrDevDom/Everyday-Coding-in-Python | /Pygame/Lerping.py | 245 | 3.53125 | 4 | # File : Lerping.py
# Desc : Simple Lerping Example
def lerp(value1, value2, factor):
return value1 + (value2 - value1) * factor
print(lerp(100, 200, 0.))
print(lerp(100, 200, 1.))
print(lerp(100, 200, .5))
print(lerp(100, 200, .25)) |
6c750f4baf3661049811dbbb9d99cd9d881c0fad | EngrDevDom/Everyday-Coding-in-Python | /bytes_size.py | 177 | 3.921875 | 4 | # This method returns the length of the string in bytes.
def byte_size(string):
return(len(string.encode('utf-8')))
print(byte_size('?'))
print(byte_size('Hello World'))
|
5830ae1c98b1ee27942069709e66873d1e7c2d0c | EngrDevDom/Everyday-Coding-in-Python | /string_to_int.py | 98 | 3.5 | 4 | # Converting String to Int
a = "23"
print(a)
print(type(a))
b = int(a)
print(b)
print(type(b))
|
f05e35fdc63cfcb45bb19620d0478dfc7b91ab8c | EngrDevDom/Everyday-Coding-in-Python | /Eq_of_Motion.py | 261 | 4.28125 | 4 | # Program for computing the height of a ball in vertical motion
v0 = 5 # Initial velocity (m/s)
g = 9.81 # Acceleration of gravity (m/s^2)
t = 0.6 # Time (s)
y = v0*t - 0.5*g*t**2 # Vertical position
print("Height of the ball: ", y, " m")
|
bd36879f42214d4ae9d97d90fd5c3dea1718b87d | EngrDevDom/Everyday-Coding-in-Python | /Python Functions/return_statement.py | 271 | 3.859375 | 4 | # Function definitio is here
def sum(arg1, arg2):
"Add both the parameters and return them."
total = arg1 + arg2
print("Inside the function: ", total)
return total
# Now you can call sum function
total = sum(10, 20)
print("Outside the function: ", total) |
0db588fb91a034b200427bc709206e201947fc9f | EngrDevDom/Everyday-Coding-in-Python | /Algorithms/Sorting Algorithms/Tim_sort.py | 2,652 | 4.28125 | 4 | # Tim_sort Algorithm
from random import randint
from timeit import repeat
def timsort(array):
min_run = 32
n = len(array)
# Start by slicing and sorting small portions of the
# input array. The size of these slices is defined by
# your `min_run` size.
for i in range(0, n, min_run):
in... |
4fc7f95567c554cd669dc0ef802228a9ed290040 | EngrDevDom/Everyday-Coding-in-Python | /Algorithms/Sorting_from_StackAbuse/Python_sort.py | 584 | 4.28125 | 4 | # Python Built-in Sort Functions
# Sort
apples_eaten_a_day = [2, 1, 1, 3, 1, 2, 2]
apples_eaten_a_day.sort()
print(apples_eaten_a_day) # [1, 1, 1, 2, 2, 2, 3]
# Sorted
apples_eaten_a_day_2 = [2, 1, 1, 3, 1, 2, 2]
sorted_apples = sorted(apples_eaten_a_day_2)
print(sorted_apples) # [1, 1, 1, 2, 2, 2, 3]
# Reverse
# Re... |
88f6afcf9589102e21cd694e2ce4f9104d61b08e | EngrDevDom/Everyday-Coding-in-Python | /Resistor_Color_Coding.py | 508 | 4.21875 | 4 | '''
Resistor Color Coding
- This program calculates the value of a resistor based on the colors
entered by the user.
'''
# Initialize the values
black = 0
brown = 1
red = 2
orange = 3
yellow = 4
green = 5
blue = 6
violet = 7
grey = 8
white = 9
gold = 0
silver = 0
bands = input('Enter the color bands: ')
c... |
6fc87cfb1ace01402fb2c0b9fc7776a8600b9be1 | EngrDevDom/Everyday-Coding-in-Python | /Eqs_of_Line.py | 276 | 3.625 | 4 | """
File : Calculus.py
Description : This program solve for slope and y-intercept
in a given equation of a line
Last Modified : 03/06/2020
Author : Engr. Dom
"""
import math
print("*** Equations of Lines ***")
print("1. Slope")
|
619c7c147bf2d1d528526256462584962e0f34f2 | EngrDevDom/Everyday-Coding-in-Python | /Ch# 20-26.py | 1,219 | 4.0625 | 4 | # Ch 20
firstname = input("Enter your first name: ")
print(len(firstname))
# Ch 21
firstname = input("Enter your first name: ")
surname = input("Enter your surname: ")
fullname = firstname + surname
print(fullname, ",", len(fullname))
# Ch 22
firstname = input("Enter first name in lower case: ")
surname = input("Ente... |
609a8b00dec388448f0f2e2bbf299070e7f52d5b | conqueror-1/lib | /pandas/test.py | 187 | 3.578125 | 4 | import pandas as pd
Age = pd.Series([10,20,30,40],index=["age1","age2","age3","age4"])
print(Age[0])
filtered_age = Age[Age>20]
print (filtered_age)
print(Age.values)
print(Age.index)
|
ef0c14eab142eb6b42bbddd5a038e70bebfdce3a | Jomiko325/guess | /conversion_tool.py | 521 | 3.8125 | 4 | print("Wilkommen zum Konversionstool")
while True:
print("Bitte geben Sie einen Euro-Betrag ein, den Sie in Deutsche Mark umrechnen moechten.")
euro = input("Betrag Euro: ")
euro = float(euro.replace(",", "."))
euro = round(euro ,2)
dm = round(euro * 1.95583 ,2)
print("{0:.2f} Euro entspre... |
d523ac367da0cd824c6ccc7c1fd0d22928e20957 | lgrosu/Complete-Python-3-Bootcamp | /playground.py | 1,273 | 3.96875 | 4 | #
myString = 'Hi I am ready to learn'
myList = [1, 2, 3, 'asdad', 'gggg[']
# print(myString[::-1])
vari = 104.32442343241241344
# print(f'Variabila are valoarea {vari:1.2f}')
# myDict = {'key1': "value1"}
# print(myDict['key1'])
# with open('D:\\PROJECTS\\Complete-Python-3-Bootcamp\\00-Python Object and Data Str... |
bf01db8554ef4876c80466a685da19909fb8463d | android156/python_basics | /Les4/task2.py | 1,932 | 4.0625 | 4 | # Представлен список чисел. Необходимо вывести элементы исходного списка,
# значения которых больше предыдущего элемента. Подсказка: элементы,
# удовлетворяющие условию, оформить в виде списка. Для формирования списка
# использовать генератор.
# Пример исходного списка: [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55].... |
58f8f08c800773e50c6b4cbc9ddd52c7a4fcfaf5 | android156/python_basics | /Les4/task6.py | 1,286 | 4.03125 | 4 | # Реализовать два небольших скрипта:
# а) итератор, генерирующий целые числа, начиная с указанного,
# б) итератор, повторяющий элементы некоторого списка, определенного заранее.
# Подсказка: использовать функцию count() и cycle() модуля itertools. Обратите
# внимание, что создаваемый цикл не должен быть бесконечным. Не... |
0984a7d7398f97a7918626b2d2cd7e8e6420d101 | GitLaser/shortlife | /regular/ddddddeepcopy.py | 300 | 3.703125 | 4 | # -*-coding:utf8 -*-
from copy import deepcopy
__author__ = "陈子昂"
__datetime__ = "2018/1/21 15:58"
l1 = [1,2]
l2=[3,4,l1]
# l3=l2.copy()
l3=deepcopy(l2)
l1.append('a')
print(l3)
def ge():
for i in range(5):
yield 'ok'+str(i)
a=ge()
print(next(a))
print(next(a))
print(next(a))
|
7d5ad562c1fd4fd490af54eeca2429e41b04e95c | sreedhr92/Computer-Science-Laboratory | /Design And Analysis of Algorithms/power_iterative.py | 251 | 4.28125 | 4 | def power_iterative(x,n):
result =1
for i in range(0,n):
result = x*result
return result
x = int(input("Enter the base:"))
y = int(input("Enter the exponent:"))
print("The value of",x,"to the power of",y,"=",power_iterative(x,y)) |
c3ba60bb4404117650b10e4458f82068da056fb3 | sreedhr92/Computer-Science-Laboratory | /Design And Analysis of Algorithms/Nut_and_bolts/nab3.py | 789 | 3.609375 | 4 | def partition(a,b,low_a,high_a,low_b,high_b):
i=low_a-1
pivot=a[high_a]
index=[]
for j in range(low_a,high_a):
if a[j] < pivot:
i=i+1
a[j],a[i]=a[i],a[j]
a[i+1],a[high_a]=a[high_a],a[i+1]
index.append(i+1)
i=low_b-1
for j in range(low_b,high_b):
if... |
4cbf689ebc738a8a7877d546bfb79d06833bdce9 | sreedhr92/Computer-Science-Laboratory | /Design And Analysis of Algorithms/Insertionsort/fast_power_mat.py | 1,556 | 4 | 4 | class error(Exception):
pass
class power_error(error):
pass
def print_matrix(a,m,n):
for i in range(m):
for j in range(n):
print(a[i][j],end =" ")
print("\n")
def read_matrix(a,m,n):
for i in range(m):
for j in range(n):
a[i][j]=0
a[i][j]=in... |
0e56194f13009d61a2ade9f57b82ab333791f416 | sreedhr92/Computer-Science-Laboratory | /Design And Analysis of Algorithms/Nut_and_bolts/nab.py | 243 | 3.890625 | 4 | def nut_and_bolts(a,b):
n=len(a)
for i in range(len(a)):
for j in range(len(b)):
if a[i] == b[j]:
print("The nut",i+1,"has its bolt in",j+1,"position")
a=[1,2,3,4,5]
b=[4,2,3,1,5]
nut_and_bolts(a,b) |
c870d394883076dff102e0ffaf637a4c9f3bb8c7 | UzairIshfaq1234/python_programming_PF_OOP_GUI | /01_sales.py | 464 | 3.8125 | 4 | sales = float(input("Please enter total sales in this month: "))
bonus = 0
commission_rate = 0
commission = 0
if sales >= 50000:
bonus = 500.0
commission_rate = 0.12
if sales < 50000:
bonus = 200.0
commission_rate = 0.10
commission = sales * commission_rate
print("Total Commission: ", commissio... |
910d9d682ef9a8c258b3395b0226a5a4c2039b43 | UzairIshfaq1234/python_programming_PF_OOP_GUI | /list using if statment.py | 551 | 4.15625 | 4 |
print("________________________________________")
list1=[input("enter name 1: "),int(input("Enter any number: ")),input("enter name 2: "),int(input("Enter any number: "))]
print("________________________________________")
for item in list1:
if str(item).isalpha():
print(item)
print("___________________... |
d66c4015d4e6995ec3a6e3158830b067b2d24a33 | UzairIshfaq1234/python_programming_PF_OOP_GUI | /inheritance.py | 670 | 3.734375 | 4 | class Person:
def __init__(self, name, cnic, gender, age):
self.name = name
self.cnic = cnic
self.gender = gender
self.age = age
def info(self):
print("Name:", self.name)
print("CNIC:", self.cnic)
print("Gender:", self.gender)
print("Age:", self.... |
764f351c8feb5875b2b316a985f4a30dadf5bddf | UzairIshfaq1234/python_programming_PF_OOP_GUI | /expert3.py | 711 | 3.6875 | 4 | class CD:
def __init__(self):
self.collect=[ ]
def add(self,artist=input("ENTER ARTIST NAME: "),song=input("SONG NAME: "),playingtime=int(input("ENTER PLAYING TIME: ")),tracks=int(input("ENTER TRACKS: "))):
self.artist=artist
self.song=song
self.playingtime=playingtime
se... |
807f0f0f4547493c4af483f93b524e121d14a618 | UzairIshfaq1234/python_programming_PF_OOP_GUI | /dictinoraylogin.py | 2,158 | 3.90625 | 4 | name={}
while True:
print("______________________________________________________________")
print("______________________WELCOME TO LOGIN SYSTEM_________________")
print("_______________________PRESS 1 FOR Signup_____________________")
print("_______________________PRESS 2 FOR Login_________________... |
8c695650dd2474917eca2082493749d1151ba041 | UzairIshfaq1234/python_programming_PF_OOP_GUI | /bank.py | 515 | 3.578125 | 4 | class Bank:
def __init__(self, balance):
self.balance = balance
self.accounts = []
self.year = 1
def get_balance(self):
return self.balance
def set_balance(self, balance):
self.balance = balance
def deposit(self, balance):
self.balance += balance
... |
6d627bc12a607d323bb1f626e3c5473d47e60bd4 | UzairIshfaq1234/python_programming_PF_OOP_GUI | /classes.py | 2,321 | 4.0625 | 4 | class login:
def __init__(self,choice):
self.choice=choice
self.data={}
#sign in to data
def datasign(self):
self.n=input("\t\t ENTER YOUR NAME : ")
if self.n in self.data.keys():
print("_______________________")
print("Username already ... |
eddc331da6b7280908ee08b254974db9fb006f0e | UzairIshfaq1234/python_programming_PF_OOP_GUI | /patron.py | 438 | 3.625 | 4 | class Patron:
def __init__(self, name):
self.name = name
self.books = []
self.number_of_books = len(self.books)
def get_name(self):
return self.name
def borrow_book(self, book):
if self.number_of_books > 3:
print("Return the book first...than barrow!!")... |
15544b46b10a29d6f235de86dbf6a1af00bae4bd | UzairIshfaq1234/python_programming_PF_OOP_GUI | /07_color_mixer.py | 891 | 4.46875 | 4 | colour1 = input("Enter the first primary colour: ")
colour2 = input("Enter the second primary colour: ")
mixed_colour = ""
if (colour1 == "red" or colour1 == "blue" or colour1 == "yellow") and (colour2 == "red" or colour2 == "blue" or colour2 == "yellow"):
if (colour1 == "red" and colour2 == "blue") or (colour2 ... |
f8d641ea4352a27b00c1d30c84545fd5e5c7744c | nirakarmohanty/Python | /controlflow/IfExample.py | 248 | 4.375 | 4 | print('If Example , We will do multiple if else condition')
value =int(input('Enter one integer value: '))
print('You entered the value as : ',value)
if value>0:
print('value is an integer')
else:
print('Please enter one integer number')
|
9a107acee38a1fc5a4632d6ed1c20b5b81408161 | nirakarmohanty/Python | /datatype/ListExample.py | 513 | 4.46875 | 4 | #Define simple List and print them
nameList=['Stela','Dia','Kiara','Anna']
print(nameList)
#List indexing
print(nameList[1],nameList[2],nameList[3])
print(nameList[-1],nameList[-2])
#length of List
print(len(nameList))
#Add a new list to the original list
nameList= nameList + ['Budapest','Croatia','Prague']
print(n... |
b753d80321b91f0f8521a1592f5f329d3cb87560 | nirakarmohanty/Python | /Numpy/ArrayExample/IndexingAndSlicingExample.py | 460 | 3.921875 | 4 | import numpy as np
print("###### Indexing and Slicing ##################")
list_indexing = np.array([(1,2,3),(4,5,6)])
print(list_indexing)
print("First Row",list_indexing[0])
print("Second Row",list_indexing[1])
print("First Column ",list_indexing[:,0])
print("Second Column ",list_indexing[:,1])
print("Third Column... |
b9ec0f8c814393ce080abe964c5c59f417dfc897 | dspwithaheart/blinkDetector | /modules/read_csv.py | 2,833 | 4.1875 | 4 | '''
csv module for reading csv file to the 2D list
Default mode is 'rb'
Default delimiter is ',' and the quotechar '|'
# # #
arguments:
csv_file - read csv file name
coma - if True replaces all the comas with dots (in all cells)
header - specify how many lines (from the beg... |
2f847a3a20f92699d51b34090ac24a442845c021 | arip995/star-invasion | /star.py | 5,402 | 4.1875 | 4 | import os
import math
import turtle
import random
#set up the screen
wn=turtle.Screen()
wn.bgcolor("black")
wn.title("space invaders")
#Draw border
border_pen=turtle.Turtle()
border_pen.speed(0)
border_pen.color("white")
border_pen.penup() #the turthle is created at the centre and if we move it without penu... |
f5c045617d3ecd540dc6f150bf71fefa662fb72a | Ictiss/PythonHomework | /task7_2.py | 654 | 3.984375 | 4 | from abc import ABC, abstractmethod
class Clothes(ABC):
def __init__(self, size):
self.size = size
@abstractmethod
def calculation(self):
pass
class Coat(Clothes):
@property
def calculation(self):
return round(self.size/6.5 + 0.5, 2)
class Suit(Clothes):
@property
... |
2809410f047eb54e9ef6e0dbccddf5445450ca47 | Eloneron/3.Largest_Prime_Factor | /main.py | 361 | 3.53125 | 4 | """
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
"""
from math import sqrt
number = 600851475143
factors = []
for i in range(2, round(sqrt(number))):
if number % i == 0:
number /= i
factors.append(i)
print(f'Largest prime factor o... |
0747a9981a94e645039092d1ab3c686261ad8030 | dpekkle/Code-Euler-Solutions | /problem_3.py | 503 | 3.703125 | 4 | """The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?"""
def primefactors(number):
factors = [1]
n = 2
while n <= number:
if number%n==0:
factors.append(n)
number /= n
else:
n += 1
return factors
x = primefactors(600851475143)
Answer =... |
097d7f921514355711c939dad82b80c86715e710 | paullatzelsperger/bfi-python-intro | /samples/primeseq1.py | 583 | 4.0625 | 4 | from primecheck import is_prime
def print_primes(upper: int):
count = 0
for i in range(0, upper, 1):
if is_prime(i):
print(str(count) + ') prime number found: ' + str(i))
count += 1
def is_invalid_input(text: str):
return isinstance(text, float) or (not text.isdigit()) or... |
df9881bc73e5ca9f411e862fcd62a6b76b3aef27 | paullatzelsperger/bfi-python-intro | /samples/converter/program.py | 529 | 3.78125 | 4 | import sys
from converter import Converter
conv = Converter()
inpt = ''
while inpt != 'q':
inpt = input(
'enter for conversion\n[f] celsius to fahrenheit\n[c] fahrenheit to celsius\n[b] number to binary\n[q]quit: ')
val = input('now input the value: ')
if inpt == 'f':
print(conv.celsius_... |
c1b09d8ddc7b6e0a0e2a744f2b03377f6be411f6 | paullatzelsperger/bfi-python-intro | /samples/converter/converter.py | 690 | 3.703125 | 4 | class Converter:
def num_to_binary(self, number: int) -> str:
if isinstance(number, float):
raise ValueError
if isinstance(number, str):
raise ValueError
if number == 0:
return "0"
s = ''
while number > 0:
if number & 1 == 1:... |
6de6511dd1a8304af391bbf902a0fa380a875b01 | jullynobre/research-and-ordering | /quick-sort/quick-sort.py | 543 | 4 | 4 | def swap(array, n1, n2):
temp = array[n1]
array[n1] = array[n2]
array[n2] = temp
def partition(array, lo, hi):
pivot = array[hi]
i = lo - 1
for j in range(lo, hi):
if array[j] <= pivot:
i += 1
swap(array, i, j)
swap(array, i + 1, hi)
return i + 1
def qu... |
b644701eebc5958ecf4eab9f353526c133d01bfa | jullynobre/research-and-ordering | /quick-sort/quick-sort-graph.py | 1,314 | 3.9375 | 4 | import matplotlib.pyplot as plt
from random import randint
import timeit
def desenhaGrafico(x,y,xl = "Entradas", yl = "Saídas"):
plt.plot(x,y, label = "Melhor Tempo")
plt.legend(bbox_to_anchor=(1, 1),bbox_transform=plt.gcf().transFigure)
plt.ylabel(yl)
plt.xlabel(xl)
plt.show()
def generateList(... |
f5d3e6fd5725f4c2ae62fc8b34f0d7235ad7da71 | jullynobre/research-and-ordering | /counting-sort/counting-sort-graph.py | 1,205 | 3.9375 | 4 | import matplotlib.pyplot as plt
from random import randint
import timeit
def desenhaGrafico(x,y,xl = "Entradas", yl = "Saídas"):
plt.plot(x,y, label = "Melhor Tempo")
plt.legend(bbox_to_anchor=(1, 1),bbox_transform=plt.gcf().transFigure)
plt.ylabel(yl)
plt.xlabel(xl)
plt.show()
def generateList(... |
d6eb08c7bb110804d4023532f5785205ab12eac2 | shounakchandra007/Python-Mailman-Game | /TextBasedGame.py | 2,197 | 3.53125 | 4 | import sys
rooms = {
'H1': {'West': 'H2'},
'H2': {'West': 'H3', 'East': 'H1'},
'H3': {'South': 'H4', 'East': 'H2'},
'H4': {'East': 'H5', 'North': 'H3', 'South': 'H7'},
'H5': {'East': 'H6', 'West': 'H4'},
'H6': {'West': 'H5'},
'H7': {'North': 'H4', 'East': 'H8'},
'H8': {'East': 'H9', 'Wes... |
8ad9166fa06a4959d3f4ed1001eebb28ca0a59a8 | fullVinsent/lab_Pyton_1 | /1_level.py | 447 | 4.125 | 4 | import math
frustrumHeight = float(input("Input H:"))
smallRadius =float(input("Input r:"))
bigRadius = float(input("Input R:"))
frustrumLenght = math.sqrt(math.pow(frustrumHeight,2) + (math.pow(bigRadius - smallRadius,2)))
frustrumSideArea = math.pi * frustrumLenght * (bigRadius + smallRadius)
frustrumAllAreaSum =... |
4889be86c48edbdcff8d6c91d047d0efd02dfa77 | jacklov3/advance_python3 | /thread_test/threadpool_test.py | 1,172 | 3.765625 | 4 | #-*- coding:utf-8 -*-
'''
线程池
'''
from concurrent.futures import ThreadPoolExecutor
import threading
import time
#定义一个准备作为线程任务的函数
def action(max):
my_sum = 0
for i in range(max):
print(threading.current_thread().name+' '+str(i))
my_sum +=1
return my_sum
# #创建一个包含2条线程的线程池
# pool = ThreadP... |
ee9dd7c500e311cbc458911871ff9575914cc318 | jacklov3/advance_python3 | /thread_test/thread_local.py | 576 | 3.53125 | 4 | #-*- coding:utf-8-*-
'''
线程局部变量测试
'''
import threading
from concurrent.futures import ThreadPoolExecutor
#定义线程局部变量
mydata = threading.local()
#定义准备作为线程执行体使用的函数
def action(max):
for i in range(max):
try:
mydata.x +=i
except:
mydata.x=i
print('%s mydata.x的值为:%d'... |
80603f74d9463868153abac5eabef1f8d0a6818d | KMadhu21/python-programs | /operators.py | 202 | 3.796875 | 4 | a=int(input("enter a"))
b=int(input("enter b"))
c=a+b
d=a-b
e=a*b
f=a//b
g=a%b
print(f"{a}+{b}={c}")
print(f"{a}-{b}={d}")
print(f"{a}*{b}={e}")
print(f"{a}//{b}={f}")
print(f"{a}%{b}={g}")
|
0e4673dc3bb5cb3024857dee189304a14aaa198b | KMadhu21/python-programs | /4.2 strings.py | 203 | 3.84375 | 4 | #strings
a=input("enter a name")
b=input("enter a name")
c=len(a)
d=len(b)
if c==d:
for i in range(c):
print("{}{}".format(a[i],b[i]),end='')
else:
print("the length of two strings are not same") |
d8e846803268fff91b74cf6e2ff9690b2b3f1fea | KMadhu21/python-programs | /kg to p.py | 75 | 3.75 | 4 | #kg to pounds
n=float(input("enter kilogams "))
p=2.2*n
print(p, "pounds")
|
5af308ed35e7d1c9bd564718aea46cae468acb8f | eshnil2000/blocktools | /blocktools.py | 2,353 | 3.96875 | 4 | import struct
def uint1(stream):
#ord("a") - returns Given a string of length one, return an integer representing the Unicode code point of the character when the argument is a unicode object, or the value of the byte when the argument is an 8-bit string. For example, ord('a') returns the integer 97, ord(u'\u2020') ... |
3f75bb36a459419d1b23167acd67a417c41ce07e | SeabassTheFish/oaracle | /src/parseRaceName.py | 2,325 | 3.5625 | 4 | #!/usr/local/bin/python3
import re
testStrings = ["Men's Lightweight 2x", "Junior Womens Varsity Double", "Lightweight mens novice 8+", "Open women's 4+"]
def parseRaceName(name):
outputDict = {'boatType': '8+'}
brokenName = name.split(" ")
re.I = True
for s in brokenName:
if re.fullmatch(r"[1... |
1be0b7b358860f722b5091010081214c28eef72f | preetising/function | /More_7Q.py | 189 | 3.5 | 4 | list1 = [1, 342, 75, 23, 98]
list2 = [75, 23, 98, 12, 78, 10, 1]
i=0
a=[]
while i<len(list1):
if list1[i] in list2:
a.append(list1[i])
a.sort()
i=i+1
print(a)
|
1c43a8a8cccb45600465dc2389894102763ad40b | a-bl/counting | /task_1.py | 243 | 4.15625 | 4 | # What is FOR loop?
sum = 0
while True:
n = int(input('Enter N:'))
if n > 0:
for num in range(1, n + 1):
sum += num
print(sum)
break
else:
print('Enter positive integer!')
|
96132cb1f6138663897e447672b6dee51b2da20b | xwyf05/tensorflow_end2end_speech_recognition | /experiments/utils/data/labels/character.py | 3,119 | 3.625 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
def char2num(str_char, map_file_path):
"""Convert from character to number.
Args:
str_char: string of characters
map_... |
d0baa2970a4fc9f178c001dc19ae81070921283a | mtkp/432-final-project | /app/game.py | 5,353 | 3.546875 | 4 | # File: game.py
# Authors: Matt Kipps, Greg Parker
# Date: June 2nd, 2014
# Class: CSS 432 A
# Professor: Brent Lagesse
# Assignment: Final Project
# Description:
# Game is another program view module, which is displayed after the program
# changes to the GAME state. Game handles use... |
c4be7a85bf107b9fd2d749f6c208f059614f6145 | mtkp/432-final-project | /app/gameserver.py | 12,280 | 3.6875 | 4 | # File: gameserver.py
# Authors: Matt Kipps, Greg Parker
# Date: June 2nd, 2014
# Class: CSS 432 A
# Professor: Brent Lagesse
# Assignment: Final Project
# Description:
# GameServer is a smart, centralized server implementation supporting the
# "type it" game.
#
# GameServer is imple... |
bdb2f90d9d6efd1ad06f9d7e939ebff224d8d19e | LukaszMaruszak/Python | /zestaw6/frac.py | 6,035 | 3.765625 | 4 | from math import gcd
import unittest
class Frac:
"""Klasa reprezentująca ułamek."""
def __init__(self, x=0, y=1):
if y != 0:
self.x = x
self.y = y
nwd = gcd(self.x, self.y)
if nwd > 1:
self.x //= nwd
self.y ... |
2a26296309abbfa3e7fd6653bbe8a7acc2f6b9b1 | LukaszMaruszak/Python | /zestaw7/zadanie7.1.py | 11,553 | 3.765625 | 4 | from math import gcd
import unittest
class Frac:
"""Klasa reprezentująca ułamek."""
def __init__(self, x=0, y=1):
if y == 0:
raise ValueError("Mianownik nie może być równy 0!")
else:
self.x = x
self.y = y
nwd = gcd(self.x, self.y)
... |
784c56bb43c8f7784acf4a4df7c68e96e27d15c6 | saurabhshukla01/Shukla-Design | /html/database-py.py | 986 | 3.515625 | 4 | '''
import mysql.connector
db_connection = mysql.connector.connect(
host= "localhost",
user= "root",
passwd= "Abc@1234"
)
# creating database_cursor to perform SQL operation
db_cursor = db_connection.cursor()
print(db_cursor)
# executing cursor with execute method and pass SQL query
db_cursor.execute("CREATE DATABASE... |
a23c7e2578b2fcbf8096e315bf1a050d8ce482ab | bmilius-nmdp/pyimgthla | /t.py | 3,714 | 3.984375 | 4 | from lxml import etree
def printnodeinfo(alleleid):
'''printing some info about what xpath returns'''
path='//hla:allele[@id="' + alleleid + '"]'
allelenodes = TREE.xpath(path, namespaces=NSMAP)
print(type(allelenodes))
print('# of alleles with an id of', alleleid, '=', len(allelenodes))
def pri... |
d320cb00b58b1dfd99ac94b0c84717749c48abf8 | Cabarne/storage | /jsonstorage.py | 393 | 3.578125 | 4 | import json
from os import name
dictionary ={
"name": "json",
"number": "1111"
}
class JSONStorage:
def __init__(self):
self.name = "data.json"
def save(self,data):
with open (self.name, "w") as j:
json.dump( data, j )
def load(self):
with open(self.name, '... |
9a2f30f4a5830a32f965efa07230a58cadc86b40 | mastergap/hackerrank | /bin/Implementation.py | 11,643 | 3.8125 | 4 | from math import sqrt, ceil
import itertools
from bin.utils.Decorators import measure_decorator
# Implementation: Angry professor
def check_present_students(students, k):
"""
:type students: list[int]
:type k: int
:rtype: str
"""
present_students = sum(1 for x in students if x < 0)
return ... |
75cd12fa9482519edb8ef6bc5f985c433af795d6 | jasper-tambur/school_exercises | /programmerimise_alused/yl6.py | 93 | 4 | 4 | a = int(input("Arv: "))
if (a%2) :
print("Arv on odd")
else:
print("Arv on even") |
92e46d1fffca03431653fcef8b738aebf056be70 | Harikalatheeswaran/Magic-Trick | /Magic_Trick.py | 4,539 | 3.921875 | 4 | print("Hello There !!! ")
print("\n")
print("This is a MAGIC TRICK which will read your mind !!!")
print("Follow the instructions.")
print("\n")
n = 21
main = [i for i in range(1,n+1)]
print("These are the set of numbers >>")
print("\n")
print(main)
print("\n")
print("Remember a number from the above set of ... |
06be8a3d51c0fabebda62114c027bc9aa5e0724a | gk425/Achohol-By-Volume | /ABV.py | 8,791 | 3.671875 | 4 | # Math121, Fall 2017, Miniproject 2
# ---------------------------------------------------------------------------#
# You will need to implement and use the following functions.
# ---------------------------------------------------------------------------#
# shooters.txt
# Takes a string-type filename, which is the n... |
658740c8634dbe2ae1239dac67398492d979b6b2 | abrichardson00/Music-Generator | /NN.py | 7,273 | 3.625 | 4 | import numpy as np
import random
from Neuron import Neuron
from NN_Display import NN_Display
class NN(object):
"""
Class for defining and training neural networks using stochastic gradient descent.
One defines a network structure with the input dimension, and then a list [x,...] giving the number... |
f1c7e39847211d3b84f52c99a958b0e8dabbbcb4 | samDeopa/CECques | /SortingAlgo/majorityElement.py | 982 | 3.703125 | 4 | def FindMaj(arr):
ele = -1
maxCount = 0
for i, val in enumerate(arr):
curr = val
count = 1
for j in range(1, len(arr)):
if(arr[j] == curr):
count += 1
if(count > maxCount):
maxCount = count
ele = curr
if(maxCount > (len(... |
63690bb18c7b2eeac0723f10dec6d979911e4eca | ishoxo/chess | /board_to_vector_function.py | 462 | 3.625 | 4 | import chess
board = chess.Board()
pieces_dict = {'P': 1, 'N': 2, 'B': 3, 'R': 4, 'Q': 5, 'K': 6, 'p': -1, 'n': -2, 'b': -3, 'r': -4, 'q': -5, 'k': -6}
def board_to_vec(board):
board_vec = []
for square in chess.SQUARES:
if board.piece_at(square) is None:
board_vec.append(0)
else:
... |
46f085b32bfb118e393913c3a82b1c87f23b5391 | bbhhoonn/python | /basic/function.py | 196 | 3.65625 | 4 | def f():
print('1')
print('2')
return None
print('3')
print(f())
a=10
def aplus():
global a # 피치 못하게 전역 변수 사용시 global
a+=10
return a
print(aplus()) |
07df67caa1d230b64078db106e2126780fee9989 | bbhhoonn/python | /practice/quiz_game.py | 1,477 | 3.6875 | 4 | def new_game():
guesses=[]
correct=0
option_num=0
for key in questions:
print(key)
print(options[option_num])
guess=input('A,B,C,D 중 하나를 입력하세요. ').upper()
guesses.append(guess)
correct+=check_answer(questions.get(key),guess)
option_num+=1
display_score... |
859807051e99459e41ffe5c781d0b78979be6497 | karthikhemu/robot-framework-demo | /data/Read.py | 773 | 3.5625 | 4 | import csv
class dd:
# def read(self,filename):
# data = []
# with open(filename, 'r') as csvfile:
# reader = csv.reader(csvfile)
# for row in reader:
# data.append(row)
# return data
def read(self,filename,row,column):
with open(filename... |
178f23b99d8e7b70a25e3eb65aab1fd743b03efa | pedro-eduardo-garcia-leyva-2019630556/-Compiladores2021B | /Practicas/Construcciones de Thompson/precedencia_operadores.py | 4,290 | 3.6875 | 4 |
class PrecedenciaOperadores:
""" Clase que recorre y sustituye las sub_regex de una regex con un No. de operacion con base en la precedencia de operadores para expresiones regulares"""
def __init__(self):
self.operaciones = []
def parentesis(self, regex):
""" Se revisa si hay alguna sub_r... |
326d837bdf002913e5c4e3e35c6e4fe7a36eac14 | LeoAnnArbor/ArmLab | /test.py | 129 | 3.796875 | 4 | import numpy as np
x = list()
# x.append([1, 1, 1])
print(str(x))
if not x:
print('x empty')
else:
print('x not empty')
|
305d19dddb1fb2b8c48979fc571bb0c52ef7c3a4 | kimusho0124/AtCoder | /test22.py | 120 | 3.515625 | 4 | N = int(input())
S = input()
count = 0
for i in range(2, N):
if S[i-2:i+1] == 'ABC':
count += 1
print(count) |
8e034a147c903727bbd482c36ca2f832bfa673e8 | pranithmacha/PythonExamples | /textmate.py | 165 | 3.625 | 4 | def dictionary_example():
dict = {}
dict['name'] = 'macha'
dict['age'] = 24
dict = {'gender':'male','car':'mustang'}
print dict['gender']
dictionary_example() |
588d1e2bb6cd9ae4fe3d1b1473ba9f52c4925e3c | pranithmacha/PythonExamples | /conversion.py | 330 | 4.0625 | 4 |
number = int(input("enter the number here:"))
def convert_int_to_list(number):
number_converted_to_string = "%s"%number
return [int(c) for c in number_converted_to_string]
def cube_of_numbers(numbers_list[]):
for number in numbers_list[]:
number = number**3
return numbers_list
def mai... |
746e8e7ec090e6e5d9482406960c0b2347eea654 | pranithmacha/PythonExamples | /range.py | 231 | 4.09375 | 4 | def range(number1,number2):
while number1<number2:
print number1
number1 +=1
def range(number1,number2,incrementation):
while number1<number2:
print number1
number1 += incrementation
range(0,10,2)
range(0,10) |
4662b537a36de0b0c3d1c5e8dc0f1904b8ad6d0a | doPggy/py-try | /8-dict.py | 1,323 | 3.515625 | 4 | # 基操
## 生成
a = {}
print(a)
a = dict()
print(a)
## 插入键值
a = {}
a["one"] = "1"
a["two"] = "2"
a[3] = "3"
print(a)
## 查看键值
print(a["one"])
## 更新键值
a["one"] = 11
## 无顺序
print(a)
print(a)
# 键值需要不可变类型
synonyms = {}
synonyms['mutable'] = ['changeable', 'variable', 'varying', 'fluctuating',
'shifting'... |
5c0b83edb879a11d8cebdbf743dd4bce34088fc3 | doPggy/py-try | /23-decorator.py | 954 | 3.84375 | 4 | ## 修饰符
'''
修饰符是一个函数,用于接收一个函数,输出一个函数
'''
def dec(f):
print("i am decorating function", id(f))
return f
declen = dec(len)
def loud(f):
def new_func(*args, **kw):
print('call with', args, kw)
rtn = f(*args, **kw)
print('return : ', rtn)
return rtn
return new_func
loudlen =... |
4975132e271e96890159a05fca542a2f3ea82701 | mihirkawatra/tkinter-login | /login.py | 2,584 | 3.578125 | 4 | from tkinter import *
from tkinter import messagebox
import pickle
headingfont = ('arial', 20, 'bold')
labelfont = ('arial', 15)
class Login:
def __init__(self):
self.root = Tk()
self.root.configure(background='black')
self.root.title("Login Page")
self.root.geometry("700x400")
... |
37ea97a604e826d7ffe9995c43317b9c32f1ec15 | med-iv/PythonIntro2020 | /07_Iterators/VirtualTurtle.py | 791 | 3.8125 | 4 | def turtle(coord, direction):
cur_coord = list(coord)
cur_direction = direction
command = ""
while True:
command = yield cur_coord
#print(command)
if command == 'f':
if cur_direction == 0:
cur_coord[0] += 1
elif cur_direction == 1:
... |
eab951a8ffe917e1d68a6fa756d939bf73eb4c2a | med-iv/PythonIntro2020 | /03_Sequences_and_for/hidden_text.py | 863 | 3.609375 | 4 | def primes(n):
pr = []
lp = [0 for i in range(n + 1)]
for i in range(2, n + 1):
if lp[i] == 0:
lp[i] = i
pr.append(i)
j = 0
while j < len(pr) and pr[j] <= lp[i] and i * pr[j] <= n:
lp[i * pr[j]] = pr[j]
j += 1
pr.insert(0, 1)
re... |
a99329de91535fa4869eec75fea99cedc2c62056 | derekawilson72/TelnetSocket | /telnetSocket.py | 3,260 | 3.890625 | 4 | # Echo server program
import socket
import threading
import datetime
import time
class telnetSocket():
"""
Establish a socket connection usable through telnet to monitor a process
by relaying messages from the process. when the user makes a telnet (or other)
socket connection, the class will relay th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.