blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
acb0cc7f05d64d6852a64f839c0c14e198cb2971 | Git-Math/linear_regression | /file.py | 1,176 | 3.5 | 4 | import sys
def read_theta():
try:
with open("data/theta.csv", "r") as theta_file:
theta_file.readline()
theta_list = theta_file.readline().split(",")
theta0 = float(theta_list[0])
theta1 = float(theta_list[1])
theta_file.close()
except:
... |
a862750fa386a55b2995a86974fbea13283e09c5 | AishaGhayas/Artificial-Intelligence | /bookexercises/updatename.py | 156 | 3.53125 | 4 | with open("name.txt", "w") as f:
f.write("hello")
with open("name.txt", "a") as f:
f.write("Aisha")
with open("name.txt") as f:
print(f.read())
|
4e1ba46177292b8da6dcd2d5d3b30458fafc2ce4 | imyoungmin/cs8-s20 | /W3/p4.py | 251 | 3.859375 | 4 | """
Problem 4: Your Initials Here, Please...
"""
# Reading in first and surename.
name = input( "Input name: " )
# Splitting and retrieving initials.
splitAt = name.find( " " )
print( "Hello {}!".format( name[0].upper() + name[splitAt+1].upper() ) ) |
a320b940332a8e47aad2e19e0082ab2705e933ff | imyoungmin/cs8-s20 | /W5/p1.py | 461 | 4.09375 | 4 | """
Problem 1: Squares.
"""
# Reading in a number and making sure it is at least 1.
n = max( 1, int( input( "Provide square length: " ) ) )
# Printing the hollow square.
for i in range( n ):
for j in range( n ):
if j == 0 or j == n - 1: # First and last columns are always printed.
print( "*", end="" )
elif i... |
59b53e13a6f8bb9d2d606de898fc92738e5bd10b | imyoungmin/cs8-s20 | /W3/p6.py | 692 | 4.125 | 4 | '''
Write a program which takes 5 strings as inputs and appends them to a list l. Swap each element in l with its mirror - that is, for some element at index i, swap l[i] with l[4-i] if i < 3.
For instance, if l = ['Alex', 'Bob', 'Charlie', 'David', 'Ethan'], then after swapping, l should read
['Ethan', 'David', 'Char... |
98aabd046d1199b77b3ffc9e0bad9cf9a3a6bb27 | imyoungmin/cs8-s20 | /W3/p1.py | 307 | 3.96875 | 4 | '''
Given a string *s* of length 5, write a function to determine if *s* is palindromic.
'''
def isPalindromic(s):
for i in range (0, 2):
if s[i] != s[4-i]:
return False
return True
def main():
s = input()
print(isPalindromic(s))
if __name__ == '__main__':
main() |
952628cbcb0b3bcffc567eebd19a4b4b2477fa1f | Grace-TA/project-euler | /solutions/problem_004.py | 611 | 4.125 | 4 | from utils import is_palindromic
def problem_004(n_digits: int = 3):
"""
In a loop from sqrt(n) to 1 check if i is factor of n and i is a prime number.
- O(n^2) time-complexity
- O(1) space-complexity
"""
result = 0
for i in range(10**n_digits - 1, 10**(n_digits - 1) - 1, -1):
for... |
b152adfe7e1ff55ac64ebf85d89ca23ffcd501b7 | Grace-TA/project-euler | /solutions/problem_009.py | 443 | 3.6875 | 4 | def problem_009(n: int = 1000) -> int:
"""
Use loop over a with nested loop over b (express c = n - a - b).
- O(n^2) time-complexity
- O(1) space-complexity
"""
for a in range(1, n // 2 + 1):
for b in range(1, n // 2 + 1):
c = n - a - b
if a**2 + b**2 == c**2:
... |
8c1e1d27ec113d5b1c0161aaaf6dde6300bf6f44 | wuxum/learn-python | /25-time.py | 254 | 3.875 | 4 | #!/usr/bin/python
# website: https://pythonbasics.org/time-and-date/
import time
timenow = time.localtime(time.time())
year,month,day,hour,minute = timenow[0:5]
print(str(day) + "/" + str(month) + "/" + str(year))
print(str(hour) + ":" + str(minute))
|
9a0267943b24849377b0a9f5b00bec1e8d8a050c | wuxum/learn-python | /29-getter-setter.py | 352 | 3.765625 | 4 | #!/usr/bin/python
# website: https://pythonbasics.org/getter-and-setter/
class Friend:
def __init__(self):
self.job = "None"
def getJob(self):
return self.job
def setJob(self, job):
self.job = job
Alice = Friend()
Bob = Friend()
Alice.setJob("Carpenter")
Bob.setJob("Builder")
... |
45e42d4282a7485fb3265c29970a32e4cc41aea8 | EduardoMJ99/EstructuraDDatos | /U1_IntroEstructurasDatos/Practica1-U1-NumerosNaturales.py | 531 | 3.671875 | 4 | resultado = 1 #Declaro e inicializo variable.
def Operacion(resultado): #Metodo que recibe el valor 'resultado' y primero compara
if resultado <= 100: #si el valor es menor a 100, si si, lo imprime, si no,
print (resultado) #llama a este... |
eaee1fc7860608ca24c9d6457516d2710bb7b7f8 | EduardoMJ99/EstructuraDDatos | /U2_Recursividad/Practica9-U2-pop()cola.py | 5,925 | 3.671875 | 4 | cola = [] #Declaro mis variables
import sys #Importo esta libreria para poder salir del programa.
def Crear(): #Metodo que inicializa la cola a ceros.
cola = [0,0,0,0,0] #Regreso la cola inicializada.
return cola
... |
eb21c95cf20a2f7960bfbe2fdbec14c508b02433 | EduardoMJ99/EstructuraDDatos | /U2_Recursividad/Practica10-U2-peek()cola.py | 8,729 | 3.8125 | 4 | cola = [] #Declaro mis variables
import sys #Importo esta libreria para poder salir del programa.
def Crear(): #Metodo que inicializa la cola a ceros.
cola = [0,0,0,0,0] #Regreso la cola inicializada.
return cola
... |
1c2dfba6786bb367598814842bffc92d0717846c | EduardoMJ99/EstructuraDDatos | /U3_EstructurasLineales/Practica21-U3-ListaEnlazadaCircularPeek().py | 5,112 | 3.84375 | 4 | import sys
class Nodo(): #Esta clase crea los Nodos de la lista con 2 atributos, el valor y el enlace vacio.
def __init__(self,datos):
self.datos = datos
self.siguiente = None
def Enlazar(): #Este metodo se encarga de enlazar los nodos que... |
b74582b044926e0d37563f292f3d97e1f3dd42c0 | barnabycollins/cipher | /letterfreq.py | 1,348 | 3.875 | 4 | key = {}
alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
commonletters = ['e','t','a','o','i','n','s','h','r','d','l','c','u','m','w','f','g','y','p','b','v','k','j','x','q','z']
letters = {}
cipher = input("Cipher:\n")
print("\nAnalysing...\n"... |
b46aba74d16c03fefb468fb7282cb978022d740f | barnabycollins/cipher | /keyword.py | 1,354 | 3.71875 | 4 | #By AARON GILCHRIST ( https://agilchrist0.github.io )
def createKey(keyword):
alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
cyphertext_alphabet = []
for letter in keyword:
if letter.upper() not in cyphertext_alphabet:
... |
e0be6624b307bc25db6f7647228f2f4fdc594415 | barnabycollins/cipher | /caesar2.py | 713 | 3.546875 | 4 | alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
counts = {}
key = {}
curmax = 0
plain = ''
cipher = input("Cipher:\n").upper()
printnums = int(input("How many results do you want to output?\n--> "))
for i in alphabet:
counts[i] = cipher.count(i)... |
f86e49a04c6fb3e410bc9b5324aec78bfe9d4c22 | barnabycollins/cipher | /box.py | 1,169 | 3.578125 | 4 | # BARNABY'S BOX CIPHER SOLVER V1.0 https://github.com/barnstorm3r
# 10/11/2016 DEVELOPED IN PYTHON 3.5.2
cipher = input("Cipher:\n")
boxnum = int(input("How wide are the boxes?\n--> "))
boxes = []
currentstr = ""
move = []
rearranged = []
condensed1 = []
condensed2 = ""
if len(cipher) % boxnum != 0:
pr... |
676a5ad604903e33cc48e6f9535ccb49fb0c4559 | vgtgayan/algorithms | /dynamic_programming/can_sum/how_sum.py | 1,537 | 3.71875 | 4 | """
/*******************************************************
* Project : DP_MASTER
* Summary : Master Dynamic Programming Concepts
* Author(s) : VGT GAYAN
* Date : 2021/07/24
* Copyright (C) 2020-2021 {VGT GAYAN} <{gayanvgt@gmail.com}>
*
* This code cannot be copied and/or distributed without the expre... |
23c56a6242beb05236ad8ece5a356125adc58a0e | pk1510/Inductions | /RMI/Basic/Duplicate element.py | 448 | 4.09375 | 4 | arr = []
dict={}
duplicate = []
n = int(input("enter the number of elements"))
for i in range(0,n):
element = int(input("enter elementwise"))
arr.insert(i, element)
for i in arr:
if i in dict.keys():
duplicate.append(i)
else:
dict[i] = i
if arr[i] not in dict.keys():
dict[ar... |
afeafaf591cbffa8b98cd0b4cd072f3946957ad8 | TomersHan/CMRL | /cmrg/data_process/gen_data.py | 777 | 3.5625 | 4 | # print("w")
# def create_data_generator(shuffle=True, infinite=True):
# print("1212")
# while True:
# if shuffle:
# pass
# for i in range(10):
# print("this is inside", i)
# yield i
# if not infinite:
# break
# create_data_generator()
impo... |
73f585596248ef1b48fab824d5d8204911acf857 | ssong86/UdacityFullStackLecture | /Python/Drawing_Turtles/draw_shapes_no_param.py | 701 | 4.125 | 4 | import turtle
def draw_square():
window = turtle.Screen()
window.bgcolor("pink") # creates a drawing GUI with red background color
brad = turtle.Turtle() # drawing module
brad.shape("turtle")
brad.color("blue")
brad.speed(2)
for x in range (0,4): # runs from 0 to 3 (4-1)
brad.f... |
00195c0135e3dc939de792a7fb66b26e6c563727 | Failproofshark/simple-MUD | /mudroom.py | 1,371 | 3.640625 | 4 | '''
Bryan Baraoidan
mudroom.py
This file contains the definition for a room in the game world
'''
class MudRoom:
def __init__(self, name, description, contents, exits):
"""
str: name, description
str list: contents
str dict: exits
"""
self.name = name
self.de... |
cee753287bd21c7e222a6acfdc3e34412241a52f | vaishnav-nk/vaishanv-nk.github.io | /binarysearch.py | 442 | 3.953125 | 4 | def binarysearch(item_list,item):
first = 0
last = len(item_list) - 1
found = False
while(first<=last and not found):
mid = (first+last)//2
if item_list[mid] == item:
found = True
else:
if item< item_list[mid]:
last = mid-1
else... |
8617172f973154a1da17ff103ca0d7dcb55246aa | PavanjDot/pythonbible | /while.py | 158 | 4 | 4 | L=[]
while len(L) <3:
new_name = input("Add name: ").strip()
L.append(new_name)
if len(L)==3:
print(L)
|
0d204a13c441bb6ab2f42670d5e8f1caccd41b12 | paulinaflorezg/-INTRO-PROGAMACION-2021 | /clases/inputclase.py | 303 | 3.859375 | 4 | PREGUNTA_NOMBRE = "Como te llamas? : "
MENSAJE_SALUDO = "un gusto conocerte :"
PREGUNTA_EDAD = "Cuantos años tienes? :"
PREGUNTA_ESTATURA = "Cuanto mides?"
nombre = input (PREGUNTA_NOMBRE)
edad = int (input (PREGUNTA_EDAD))
print (MENSAJE_SALUDO,nombre)
estatura = float (input(PREGUNTA_ESTATURA))
|
7c5824da6d1e600f1d072deb73c22ed48b2ec659 | paulinaflorezg/-INTRO-PROGAMACION-2021 | /examenes/quiz3graficos.py | 1,963 | 3.515625 | 4 | #PUNTO 1
import matplotlib.pyplot as plt
snacks = ['jumbo','palito de queso','galletas oreo','perro','helado']
precio = [2000,4000,3500,5000,4000]
plt.bar(snacks,precio)
#########
plt.title('Snacks favoritos')
plt.xlabel('snacks')
plt.ylabel ('precio')
plt.savefig ('graficos snacksfavoritos.png')
#########
plt.show()
... |
32477b008d75266da42df96abeda03ae23d63718 | RelioXx/MyWorks | /ParadigmasProg/14_async_generators.py | 347 | 3.734375 | 4 | import asyncio
async def cuadrados():
for i in range(10):
pass
yield i ** 2
await asyncio.sleep(0.1) # Operación de IO que tarda
async def main():
r1 = [i async for i in cuadrados()]
r2 = [i for i in [1,2,3]]
print(r1)
print(r2)
if __name__ == '__main__':
... |
fb1795c96050d29340251a3dc328b14e70f3b7bf | jiazekun/Py | /ds_using_dict.py | 403 | 3.625 | 4 | ab={
'Swaroop':'swaroop@swaroopch.com',
'Larry':'larry@wall.com',
'Mali':'mali@qq.com',
'Spa':'spa@hotmail.com'
}
print('Swaroop \'s address is ',ab['Swaroop'])
del ab['Spa']
print('\nThere are{}contents in the address-book\n'.format(len(ab)))
for name,address in ab.items():
print('Contact {} at {... |
e09ff03629e07c3a3600f676f5545e34e717e83f | michael7ulian/training_python | /pertemuan ke6/module.py | 477 | 3.90625 | 4 |
class person(object):
def __init__(self,name,age,nama_lawan):
self.name = name
self.age = age
self.nama_lawan = nama_lawan
def sapa(self):
print("halo namaku: "+self.name)
print("namamu siapa?")
def salamkenal(self):
print("halo namaku: "+se... |
984658d5a0192e275cf8bdea9cd91db7d150b445 | J0sueTM/DSA | /Implementation/Mathematics/BasicMath/python/armstrongNumbers.py | 188 | 3.59375 | 4 | def isArNum(n, s):
c = 0
t = n
while t > 0:
r = t % 10
c += r ** s
t //= 10
return (c == n)
n = int(input())
s = len(str(n))
print(isArNum(n, s))
|
957bf35ebf75e8ba66062dcd42ef9d908f7024fc | J0sueTM/DSA | /Implementation/Mathematics/BasicMath/python/gcd.py | 387 | 3.796875 | 4 | import math
def gcdpf(a, b):
if a == 0:
return b
if b == 0:
return a
if a == b:
return a
if a > b:
return gcdpf(a - b, b)
else:
return gcdpf(a, b - a)
def gcdea(a, b):
if b == 0:
return a
return gcdea(a, a % b)
a = int(input())
b = int(inp... |
cbfdccb80a6d6feb89d9e3a9edfd120d200e8637 | VATSALagrawal/Bitcoin-price-Detection-Using-Neural-Networks | /bitcoin.py | 3,102 | 3.609375 | 4 | import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
# read the data , convert timestamp values to date and then group them according to their date
df = pd.read_csv('coinbaseUSD.csv')
df['Date'] = pd.to_datetime(df['Timestamp'],unit='s').dt.date
#df=pd.read_csv('BTC-USD.csv')
group = df.groupby(... |
9378de6f71d668ea2a9d250d78d19fb64b385ef0 | igorpejic/nx | /c.py | 6,253 | 3.5 | 4 | import math
import networkx as nx
import ast
def euclidean(node1, node2):
return math.sqrt((node2['x'] - node1['x']) ** 2 +
(node2['y'] - node1['y']) ** 2)
def get_direction_codes(nodes_list):
"""
Codes:
1 up
2 down
3 right
4 left
Return list of directions view... |
4bded11527826b9b2c978c2828fe22423d2f7435 | nemesmarci/Advent-of-Code-2019 | /17/common.py | 1,357 | 3.5 | 4 | from sys import stdout
from intcode import Intcode
def read_data():
with open('input.txt') as program:
return [int(code) for code in program.read().strip().split(',')]
class Scaffolding:
def __init__(self):
self.ic = Intcode(read_data())
self.area = dict()
self.x_size = self.... |
8981eef3f9fa9b9b245bfc45f77818bcbbbd0acf | nemesmarci/Advent-of-Code-2019 | /3/3_1.py | 183 | 3.5625 | 4 | from path import manhattan, read_data, parse
wires = read_data()
pathes = parse(wires)
distances = [manhattan(p, (0, 0)) for p in pathes[0] if p in pathes[1]]
print(min(distances))
|
c46fc22351db7e3fdafadde09aea6ae45b7c6789 | rajatthosar/Algorithms | /Sorting/qs.py | 1,682 | 4.125 | 4 | def swap(lIdx, rIdx):
"""
:param lIdx: Left Index
:param rIdx: Right Index
:return: nothing
"""
temp = array[lIdx]
array[lIdx] = array[rIdx]
array[rIdx] = temp
def partition(array, firstIdx, lastIdx):
"""
:param array: array being partitioned
:param firstIdx: head of the... |
2bb59194c7433002d4d3ab50ae6abb2a5344fa20 | 5yaaz/d | /palindrome.py | 197 | 3.65625 | 4 | def main():
s=int(input(""))
temp=s
rev=0
while(s>0):
dig=s%10
rev=rev*10+dig
s=s//10
if(temp==rev):
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
|
c4ec220c4abfbe6534537ea03b7029dfaa1b3e18 | v-antech/adventofcode | /src/main/python/similar1/solution.py | 3,355 | 4.03125 | 4 | #!/usr/bin/python
global alphabet
alphabet = "abcdefghijklmnopqrstuvwxyz"
def generate_matrix(input_string, size_of_matrix):
print "Size: {0}".format(size_of_matrix)
matrix = [[0 for x in range(size_of_matrix)] for x in range(size_of_matrix)]
location_in_word = 0;
for y in range(size_of_matrix):
... |
b5130d19dedec998008d90a4cbb7aaefe626d7f6 | Shayennn/ComPro-HW | /6-Second-HW/L03P5.py | 381 | 3.671875 | 4 | # -*- coding: utf-8 -*-
#std35: Phitchawat Lukkanathiti 6110503371
#date: 22AUG2018
#program: L03P5.py
#description: display positive and negative of input
posneg=[0,0]
while True:
number = int(input("Please input number : "))
if number > 0:
posneg[0]+=1
elif number<0:
posneg[1]+=1
els... |
564f6a56d42373ee2e4440bf13dd23304144f632 | Shayennn/ComPro-HW | /6-Second-HW/L03P3.py | 462 | 3.84375 | 4 | # -*- coding: utf-8 -*-
#std35: Phitchawat Lukkanathiti 6110503371
#date: 22AUG2018
#program: L03P3.py
#description: if and no elif .....
status={90:'Senior Status',60:'Junior Status',30:'Sophomore Status',0:'Freshman Status'}
while True:
credit = int(input("Enters the number of college credits earned : "))
f... |
16da508f62ddb353409ef723a4e6a6a3360ae592 | Shayennn/ComPro-HW | /2-First LAB/L01M1.py | 262 | 3.546875 | 4 | # -*- coding: utf-8 -*-
#std25: Phitchawat Lukkanathiti 6110503371
#date: 09AUG2018
#program: L01M1.py
#description: hello name and lastname
name = input("What is your name? ")
lastname = input("What is your lastname? ")
print("Hello",name,lastname)
print("Welcome to Python!")
|
603238d29b70b8d5c882d4cd32bf77e3ed01c10e | Shayennn/ComPro-HW | /8-TEST02/01_primeNDigit.py | 505 | 3.8125 | 4 | # -*- coding: utf-8 -*-
#std35: Phitchawat Lukkanathiti 6110503371
#date: 30AUG2018 quiz02
#program: 01_primeNDigit.py
#description: count prime that have n digits
n = int(input('n: '))
number_range = [True for _ in range(10**n)]
count=0
for number in range(10**n):
if number_range[number]==False or number < 2:
... |
c9a9fb8c6dd77916be383007a69350bff4cc3f70 | Shayennn/ComPro-HW | /6-Second-HW/L03M2.py | 921 | 3.84375 | 4 | unit=['K','C','F','R']
def temp2kelvin(temp,inunit):
if inunit == 0:
return temp
elif inunit == 1:
return temp+273.15
elif inunit == 2:
return ((temp+459.67)*5/9)
elif inunit == 3:
return ((temp-7.5)*40/21+273.15)
return -999
def kelvin2temp(kelvin,outunit):
if ... |
969e6b9efc208367d623176c3681af8869f2deac | Avery246813579/cs-diagnostic-avery-durrant | /Linked List Reversal.py | 1,371 | 4 | 4 | class LinkedList:
head = None
def add(self, element):
if self.head is None:
self.head = Node(element)
return
new_start = Node(element)
new_start.pointer = self.head
self.head = new_start
def pop(self):
if self.head is None:
... |
032cf9c4c13c608b7053e6af651481ee673b0500 | Mhmdabed11/CrackingtheCodingInterviewExcercisesTypeScript | /threeInOne.py | 1,777 | 3.796875 | 4 | class ThreeInOne:
def __init__(self, stackSize):
self.__stackCapaity = stackSize
self.__array = [None]*3*stackSize
self.__sizes = [0]*3
def push(self, stackNum, value):
if(int(stackNum) > 2):
print("Stack number should be less than 3")
return
if(s... |
a54e726b3a4c8ef2d26769fb60a86948089627e4 | Mhmdabed11/CrackingtheCodingInterviewExcercisesTypeScript | /returnKthtoLast.py | 560 | 4 | 4 | from linkedList import LinkedList
def returnKthToLast(linkedList, k):
ptr1 = linkedList.head
ptr2 = linkedList.head
for i in range(0, k-1):
try:
ptr2 = ptr2.next
except Exception as exception:
return exception
while(ptr1.next and ptr2.next):
ptr1 = ptr1.... |
3d1a886b8d61f6175cc9376dfddae520c822f8ba | Mhmdabed11/CrackingtheCodingInterviewExcercisesTypeScript | /sumLists.py | 2,511 | 3.796875 | 4 | from linkedList import LinkedList
import math
def sumLists(linkedList1, linkedList2):
number1 = ""
number2 = ""
current1 = linkedList1.head
while(current1):
print(current1)
number1 = number1+str(current1.value)
current1 = current1.next
current2 = linkedList2.head
while(... |
1b035eebd1088a5b976e5cd1c72f6d1d3706ad7a | petermchale/algorithms_and_data_structures_Python | /queues and stacks/queue built from stacks.py | 982 | 3.71875 | 4 | # https://www.youtube.com/watch?v=7ArHz8jPglw&index=31&list=PLOuZYwbmgZWXvkghUyMLdI90IwxbNCiWK
from stack import Stack
class Queue:
def __init__(self):
self.stack_newest_on_top = Stack()
self.stack_oldest_on_top = Stack()
def shift_stacks(self):
if self.stack_oldest_on_top.is_empty()... |
985fa1c907017b8a3ed95d6a50e2fdcf3693ad54 | Aetos19/PDJ2 | /Imp_Py/3_ex_contains.py | 464 | 3.53125 | 4 | class CaseInsensitive:
def __init__(self, **kwargs):
for key, value in kwargs.items():
self[key.lower()] = value
def __contains__(self, key):
return super(CaseInsensitive, self).__contains__(key.lower())
def __getitem__(self, key):
return super(CaseInsensitive, self).__getitem__(key.lower())
def __setit... |
bbc5ef85630d09469c0a64186d6c27d95d3a9c88 | DanielEstrada971102/Implementaciones_FPGA | /Interfaces/firstW_designer/firstW_onlyCode.py | 1,274 | 3.609375 | 4 | import sys
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow, QApplication
class Simple_window(QMainWindow):
"""
This is a simple examplo about how generate a GUI whith PyQt5
"""
def __init__(self):
super(Simple_window, self).__init__()
self.setGeometry(300, 300, 320, 300) # x, y,... |
a5531b6d065ff94953c67c60efe74d2f16cb44f2 | KulataevKanat/PythonData | /structures/cycles/comparisonOfNumbers.py | 867 | 4.09375 | 4 | #! Программа Сравнение чисел
print("Для выхода нажмите exit")
while True:
try:
value1 = input("Введите первое число: ")
if value1.lower().__eq__("exit"):
break # выход из цикла
value2 = input("Введите второе число: ")
if value2.lower().__eq__("exit"):
break... |
67dd07b7ffa31b09e4e7a667464da4a121741572 | KulataevKanat/PythonData | /structures/oop/object/str.py | 1,110 | 3.828125 | 4 | class Car:
def __init__(self, id, mark, color, model, dateOfManufacture) -> None:
self.id = id
self.mark = mark
self.color = color
self.model = model
self.dateOfManufacture = dateOfManufacture
def display_info(self):
print(self.__str__)
def __str__(self) ->... |
a7ed1cdd3e87253358419d20e5d1c6ffd4cae683 | KulataevKanat/PythonData | /GUI/button.py | 859 | 3.78125 | 4 | from tkinter import *
clicks = 0
def click_button():
global clicks
clicks += 1
root.title("Clicks {}".format(clicks))
root = Tk()
root.title("Графическая программа на Python")
root.geometry("400x300+300+250")
btn = Button(text="Hello GUI", # текст кнопки
background="#5DB11E", # фоновый ... |
9b36ee11bf5740fecaa7e197ad9b3b03478f5c8f | KulataevKanat/PythonData | /structures/exceptions/valueError.py | 251 | 3.6875 | 4 | try:
number = int(input("Введите число: "))
print("Введенное число:", number)
except ValueError:
print("Преобразование прошло неудачно")
print("Завершение программы") |
7b6b3d10531a4a5676472bbc7bc2280b2b07d1b0 | KulataevKanat/PythonData | /GUI/elements/entry/entryMethods.py | 1,841 | 3.828125 | 4 | from tkinter import *
from tkinter import messagebox
def clear():
name_entry.delete(0,
END
)
surname_entry.delete(0,
END
)
def display():
messagebox.showinfo("GUI Python",
name_entry.get... |
a0cb7e54077531cbcdf6ae61b9c846de87d68a37 | KulataevKanat/PythonData | /GUI/elements/elementPositioning/pack/fill.py | 776 | 3.5 | 4 | from tkinter import *
root = Tk()
root.title("Fill Method")
root.geometry("500x500")
btn1 = Button(text="CLICK ME",
background="#555",
foreground="#ccc",
padx="15",
pady="6",
font="15"
)
btn1.pack(side=RIGHT,
fill=Y
... |
84554e996c2ddf3894fff2a1112cd5318995ffb9 | KulataevKanat/PythonData | /structures/modules/randomModule.py | 610 | 3.875 | 4 | import random
print("random() - (0.0 до 1.0)): ")
number = random.random()
print(number)
print("\nrandom() - (0.0 до 100.0)): ")
number = random.random() * 100
print(number)
print("\nrandint(min, max): ")
number = random.randint(1, 13)
print(number)
print("\nrandrange(start, stop, step): ")
number = random.randrang... |
51e1776e41d1f4f0a02a23eec982b9ef948430c0 | alessioserra/Data_Science_Lab04 | /default/__init__.py | 2,101 | 3.5625 | 4 | import numpy as np
import matplotlib.pyplot as plt
# using class import
"""
from default.KMeans import KMeans
"""
from sklearn.cluster import KMeans
# EXERCISE 1
# read data set with numpy
data = np.loadtxt("gauss_clusters.txt", delimiter=",", skiprows=1)
x = [x for x, y in data] # saving all x and y in d... |
13ad5d8eadfd88a79fc51d5d5fb9ad808e735904 | Mouzouris/AI-project | /AI.py | 24,739 | 3.515625 | 4 | #This is the part 1 Assignment of Foundations of AI COMP
#initialised the board in the state that each location within the baord had a corresponding value such as
# ---- ---- ---- ----
# | 0 | 1 | 2 | 3 |
# ---- ---- ---- ----
# | 4 | 5 | 6 | 7 |
# ---- ---- ---- ----
# | 8 | 9 | 10 | ... |
7418a205641f3a6c09c71b3d8bd5c95b6947fae5 | chrhsmt/system_programming | /3/match_ends.py | 334 | 3.609375 | 4 | def match_ends(li):
# resultList = filter(lambda w:
# (len(w) >=2 and w[0] == w[-1]), li)
# return len(resultList)
return len([x for x in li if len(x) >= 2 and x[0] == x[-1]])
print match_ends(['aba', 'xyz', 'aa', 'x', 'bbb'])
print match_ends(['', 'x', 'xy', 'xyx', 'xx'])
print match_ends(['aaa', 'be', 'ab... |
ed57fc7bbf77ac2f9439bd2905a4a59fa7d8d93a | new-silvermoon/RecreationalMaths | /sumofcubes.py | 2,005 | 4.03125 | 4 | """
There is a popular conjecture in Maths which states that numbers that can be expressed as a sum of three cubes of integers,
allowing both positive and negative cubes in the sum. Refer https://en.wikipedia.org/wiki/Sums_of_three_cubes
Andrew Booker wrote an algorithm in March 2019 in order to find the result for ... |
18567c0c63270e54bc8a42310dea5f2c58baca18 | manjulive89/JanuaryDailyCode2021 | /DailyCode01282021.py | 500 | 4.03125 | 4 | # ---------------------------------------------------------
# Daily Code 01/28/2021
# "Convert Minutes into Seconds" Lesson from edabit.com
# Coded by: Banehowl
# ---------------------------------------------------------
# Write a function that takes an integer minutes and converts it to seconds
# convert(5... |
68fc5fd6c86607595d5eb547218c7a55781f3389 | manjulive89/JanuaryDailyCode2021 | /DailyCode01092021.py | 1,381 | 4.5625 | 5 | # -------------------------------------------
# Daily Code 01/09/2021
# "Functions" Lesson from learnpython.org
# Coded by: Banehowl
# -------------------------------------------
# Functions are a convenient way to divide your code into useful blocks, allowing order in the code, make it
# more readable, reu... |
9d1b835fd8b5e6aeadb4ff23d54c2bc0b5435b2f | manjulive89/JanuaryDailyCode2021 | /DailyCode01202021.py | 1,831 | 4.3125 | 4 | # -----------------------------------------------
# Daily Code 01/20/2021
# "Serialization" Lesson from learnpython.org
# Coded by: Banehowl
# -----------------------------------------------
# Python provides built-in JSON libraries to encode and decode JSON
# Python 2.5, the simplejson module is used, wher... |
5cac576e1c3b2e1ecd67bfd71ab20bc765b4eee3 | jtm192087/Assignment_8 | /ps1.py | 960 | 4.46875 | 4 | #!/usr/bin/python3
#program for adding parity bit and parity check
def check(string): #function to check for a valid string
p=set(string)
s={'0','1'}
if s==p or p=={'0'} or p=={'1'}:
print("It is a valid string")
else:
print("please enter again a valid binary string")
if __name__ == "_main... |
078ca69e4955028b2c0cedc634b1d3ec0353cc62 | VishwasShetty/Python | /cal.py.py | 5,354 | 3.96875 | 4 | #Auther:Vishwas Shetty
#Programming Language:Python 3
#Progarm:To Create Simple Calculator
#Start Date:30-11-2019
#End Date:1-12-2019
import tkinter
from tkinter import*
from tkinter import messagebox
val=""
num1=0
num2=0
operator=""
res=0
flag=0;
def button_clicked(n):
global val
val=val+str(n)
value.set... |
4a20648cdf7d4e19c953d7cc067392742788d8f9 | huairenxiao99/myedu-1902 | /day02/yunsuanfu.py | 330 | 3.78125 | 4 | def jisuan(a,b):
print(a + b)
print(a - b)
print(a * b)
print(a / b)
# 取余
print(a % b)
def dyu(a,b,c):
print(a > b)
print(a < b)
print(a == b)
print(a == c)
print(a >= b)
print(a <= b)
print(a != b)
if __name__ == '__main__':
a = 10
b = 6
c = 10
... |
22b799170338c2e388892893eb7a9a8aa36f4082 | saurabh-konpratiwar/heroku-st1 | /penguins-app.py | 1,559 | 3.609375 | 4 | import streamlit as st
import pandas as pd
import pickle as pk
import numpy as np
pickle_in = open('model_pickle','rb')
svc = pk.load(pickle_in)
def prediction(Pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,BMI,DiabetesPedigreeFunction,Age):
prediction = svc.predict([[Pregnancies,Glucose,BloodPr... |
266b2250dbbc45c22395f3542f587a1a575dc4d8 | Stengaffel/kattis | /heirsdilemma.py | 999 | 3.59375 | 4 | import sys
# Checks if the digit dig apppears in the number x
def check_digit(x, dig):
while x > 0:
if x % 10 == dig:
return True
x = x // 10
return False
def find_nums(upper, lower, cur_num, nums, dec):
if dec == 0:
nums.append(cur_num)
return
for i in rang... |
c5d38f28962bbe6c0d4de9c12d16ff0be77fac3c | Stengaffel/kattis | /apaxiaaans.py | 221 | 3.546875 | 4 | import sys
name = str( sys.stdin.readline() ).strip()
new_name = ''
cur_char = ''
for ch in name:
if cur_char == ch:
continue
else:
new_name = new_name + ch
cur_char = ch
print(new_name) |
1bcabc3abf05c755d74e36055f9a435b82cb2a32 | Stengaffel/kattis | /reversebinary.py | 741 | 3.859375 | 4 | import sys
# Returns an array containing the binary representation of the integer 'x'
def create_binary(x):
bin = []
cur_dig = 2**29
while cur_dig > 0:
if x >= cur_dig:
bin.append(1)
x = x - cur_dig
else:
if len(bin) > 0:
bin.append(0)
... |
7f1558ee13bd336adda19c4750a3aaf0be4dd1e5 | Stengaffel/kattis | /last_factorial_digit.py | 284 | 3.6875 | 4 | import sys
def factorial(x):
if x == 1:
return 1
else:
return x * factorial(x-1)
limit = int(sys.stdin.readline())
nums = []
for i in sys.stdin:
nums.append(int(i))
if len(nums) == limit:
break
for n in nums:
print( factorial(n) % 10)
|
286682527cf109dfab6d8c42ae80616d3592623b | Gabrielgjs/python | /SalarioFuncionario.py | 436 | 3.8125 | 4 | salario = float(input('Qual é o salário do funcionário? R$'))
aumento = salario * 0.10
aumento1 = salario * 0.15
if salario <= 1250:
print(f'Quem ganhava R${salario:.2f} passa a ganhar R${salario+aumento1:.2f} agora')
else:
print(f'Quem ganhava R${salario:.2f} passa a ganhar R${salario+aumento:.2f} agora')
''... |
71180623d83500bc518dfd6483fecc5e0149e25d | Gabrielgjs/python | /InteragindoComNome.py | 408 | 3.96875 | 4 | '''n = str(input('Digite seu nome completo: ')).strip()
nome = n.split()
print('Muito prazer em te conhecer!')
print(f'Seu primeiro nome é {nome[0]}')
print(f'Seu ultimo nome é {nome[len(nome)-1]}')'''
n=str(input('Digite seu nome completo: ')).strip()
nome=n.split()
print('Muito prazer em te conhecer!')
print('Seu p... |
a0c94fff02953dd66974b2476f299a4417e7605c | Gabrielgjs/python | /AnoAlistamento.py | 600 | 4.1875 | 4 | from datetime import date
ano = int(input('Ano de nascimento: '))
atual = date.today().year
alistamento = 18
idade: int = atual - ano
print(f'Quem nasceu em {ano} tem {idade} anos em {atual}.')
if idade == 18:
print('voê tem que se alistar IMEDIATAMENTE!')
elif idade > alistamento:
saldo = idade - alistamento
... |
c6d6c93a737c4c29f95d7ab9310329ec65dfbd66 | Gabrielgjs/python | /teste.py | 1,359 | 3.984375 | 4 | print('PESQUISA ESCOLA TRÂNSITO SEGURO')
contador = 0
r1 = input('Se o farol está vermelho. você pode avançar com o carro ? (sim ou não)')
if r1 == 'sim':
print('Errou, pesquise o assunto!')
elif r1 == 'não' :
print('Acertou, vamos para a proxima pergunta')
contador += 1
r2 = (input('se o farol está amarelo... |
cdc09fd55f7cf9c6a408287f9fa5d2bec4832880 | Gabrielgjs/python | /PrecoPassagem.py | 383 | 4.0625 | 4 | distancia = float(input('Qual é a distância da sua viagem? '))
print(f'Você está prestes a começar uma viagem de {distancia:.1f}km.')
if distancia <= 200:
print(f'O preço da sua passagem será R${distancia * 0.50}')
elif distancia > 200:
print(f'O preço da sua passagem será R${distancia * 0.45}')
#preço = dista... |
efca7b2a11ecafad103932c0d5a34335d354e7d8 | gvogel03/Pygame | /test.py | 9,806 | 3.5625 | 4 | """
LESSON: 5.1 - Sprites
EXERCISE: Code Your Own
"""
import pygame
pygame.init()
import tsk
import random
c = pygame.time.Clock()
window = pygame.display.set_mode([1018, 573])
background = tsk.Sprite("SkyScrolling.jpg", 0, 0)
image_sheet = tsk.ImageSheet("DragonFlying.png", 4, 6)
dragon = tsk.Sprite(image_sheet, 0, 0)... |
bfdbcb6a7e055bae5fd9409e64597c8354af4753 | morgulbrut/cookbook | /python/is_even/is_even.py | 99 | 3.609375 | 4 | #!/usr/bin/env python3
import is_odd
def is_even(number):
return not (is_odd.is_odd(number)) |
cafccf75a28b5f3c3460e7564a26e452414c86af | sindhu819/Greedy-2 | /Problem-136.py | 925 | 3.96875 | 4 | '''
Leetcode- 135. Candy - https://leetcode.com/problems/candy/
time complexity - O(N)
space complexity - O(N)
Approach - first we assign each child one candy each
2) Then we compare left neighbour, if it is greater then then we add 1 candy else it remains the same
3) Sameway we do compare the right... |
6e46e42ea4205b428807d2b960095074984916b5 | tanvir362/Python | /binary_search_tree_traversal.py | 2,433 | 3.6875 | 4 | import sys
pre_order_traversal_list = []
post_order_traversal_list = []
in_order_traversal_list = []
bfs_traversal_list = []
class Node:
def __init__(self, n):
self.value = n
self.left = None
self.right = None
def insert(self, n):
if n < self.value:
if self.left:... |
e2386b4c6fcb67f02c09f40ba80d3ce778517f9e | tanvir362/Python | /linked_list.py | 841 | 3.953125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def add(self, data):
if not self.head:
self.head = Node(data)
return
cur = self.head
while cur.next:
cur = cur.next
cur.next = Node(data)
def remove(self, data):... |
a041b93fec1ef0dbe5051bd7ab62339e9693107b | tanvir362/Python | /bfs.py | 617 | 3.5625 | 4 | n = int(input())
e = int(input())
graph = {}
vis = {}
for i in range(e):
u, v = [int(x) for x in input().split()]
if u not in graph:
graph[u] = []
if v not in graph:
graph[v] = []
graph[u].append(v)
graph[v].append(u)
s = int(input())
q = [s]
vis[s] = True
print(graph)
print(q)
pr... |
60bfafee9e036355bd9c1384d5d48adf8cd805cf | ViFLara/Information-security | /client_tcp/tcpclient.py | 814 | 3.5 | 4 | import socket
import sys
def main():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
except socket.error as e:
print("The connection has failed!")
print("Error: {}" .format(e))
sys.exit()
print("Socket successfully created")
target_host = input("Type the ... |
740ed3e23a6f6d4531ae28fbd1efce9df17aef28 | Kunal600/PythonMiniAssignments | /OverSalary.py | 313 | 3.9375 | 4 | #Program to calculate person Salary
Hours = raw_input("Enter Hours:")
Rate = raw_input("Enter Rate:")
if float(Hours) > 40.0:
over = float(Hours) - 40.0
Pay = 40.0 * float(Rate) + float(over) * 1.5 * float(Rate)
print 'Pay:',Pay
else:
Pay = 40.0 * float(Rate) + float(over)
print 'Pay:',Pay |
be982a03905d0ca95fe7e1b8c6bcdf7300b3a0e0 | vit050587/Python-homework-GB-2 | /lesson4.4.py | 847 | 4.25 | 4 | # 2. Вычисляет урон по отношению к броне.
# Примечание. Функция номер 2 используется внутри функции номер 1 для вычисления урона и вычитания его из здоровья персонажа.
player_name = input('Введите имя игрока')
player = {
'name': player_name,
'health': 100,
'damage': 50,
'armor' : 1.2
}
enemy_name ... |
6350e10279970611dc7596725282d31edb2648a1 | lacretelle/beta_bootcamp_python | /day00/ex05/kata03.py | 108 | 3.703125 | 4 | phrase = "The right format"
i = len(phrase)
while i < 42:
print ("-", end='')
i += 1
print (phrase)
|
2d64da9c1ef7e05354edf601ac253ff54f913678 | lacretelle/beta_bootcamp_python | /day01/ex01/game.py | 955 | 3.796875 | 4 | class GotCharacter:
"""A class representing the GOT character with their name and if they are alive or not
"""
def __init__(self, first_name, is_alive=True):
try:
if not first_name:
self.first_name = None
elif isinstance(first_name, str):
self.... |
4b4f20ebd7680757a8764a77720b31af1cef4c8a | Mahendra710/Number_Pattern | /7.11-Number Pattern.py | 241 | 4 | 4 | num=input("Enter an odd length number:")
length=len(num)
for i in range(length):
for j in range(length):
if i==j or i+j==length-1:
print(num[i],end=" ")
else:
print(" ",end=" ")
print() |
3afebab1061cedb3cd3649c6d9c7aeb920f37ccf | Mahendra710/Number_Pattern | /7.9-Number Pattern.py | 202 | 3.875 | 4 | n=int(input("Enter the number of rows:"))
for row in range(n):
val=row+1
dec=n-1
for col in range(row+1):
print(val,end=" ")
val=val+dec
dec=dec-1
print() |
578f3caf2d4247460b9331ae8f8b2a9cc56a4a74 | EgorVyhodcev/Laboratornaya4 | /PyCharm/individual.py | 291 | 4.375 | 4 | print("This program computes the volume and the area of the side surface of the Rectangular parallelepiped")
a, b, c = input("Enter the length of 3 sides").split()
a = int(a)
b = int(b)
c = int(c)
print("The volume is ", a * b * c)
print("The area of the side surface is ", 2 * c * (a + b))
|
c7b567bde9e143c404c3670793576644a26f6142 | AhmadQasim/Battleships-AI | /gym-battleship/gym_battleship/envs/battleship_env.py | 4,760 | 3.53125 | 4 | import gym
import numpy as np
from abc import ABC
from gym import spaces
from typing import Tuple
from copy import deepcopy
from collections import namedtuple
Ship = namedtuple('Ship', ['min_x', 'max_x', 'min_y', 'max_y'])
Action = namedtuple('Action', ['x', 'y'])
# Extension: Add info for when the ship is sunk
cl... |
1077c1381bc2376d9e18cbf9197a2382a31027e1 | leenatomar123/functions | /KBC.py | 1,186 | 3.859375 | 4 | print("wELCOME......TO......KBC")
Question_list=("how many states are there in India?"
"what is the capital of india?"
"NG mai konsa course padhaya jata hai?")
options_list=[
["Twenty-four","Twenty-five","Twenty-eight","Twenty-nine"]
["Bhutan","Pakistan","Delhi","China"]
["Software en... |
835133a36e6cd47c8b9f422f9c802262fcb987bf | dselig11235/pyrsa | /pyrsa.py | 3,158 | 3.53125 | 4 | from random import randint
from miller_rabin import is_prime
import base64
def gcd(x, y):
"""This function implements the Euclidian algorithm
to find G.C.D. of two numbers"""
while(y):
x, y = y, x % y
return x
# define lcm function
def lcm(x, y):
"""This function takes two
integers and retu... |
2531327f966f606597577132fa9e54f7ed0be407 | Rotondwatshipota1/workproject | /mypackage/recursion.py | 930 | 4.1875 | 4 | def sum_array(array):
for i in array:
return sum(array)
def fibonacci(n):
''''
this funtion returns the nth fibonacci number
Args: int n the nth position of the sequence
returns the number in the nth index of the fibonacci sequence
''''
if n <= 1:
return n
else:
... |
c49787ad7badc48c6cdc3ecdd63dbaf3f3e5eb6f | phyokolwin/pythonworkshop | /01/01E12.py | 100 | 3.984375 | 4 | # Choose a question to ask
print('What is your name?')
name = input()
print('Hello, ' + name + '.')
|
8ce437b775fd8fca2cb0c8ff2843b85a1b8c7265 | phyokolwin/pythonworkshop | /01/01E16.py | 204 | 3.546875 | 4 | age = 20
if age >= 18 and age <21:
print('At least you can vote')
print('Poker will have to wait')
if age >= 18:
print('You can vote.')
if age >= 21:
print('You can play poker.')
|
de7488333bd872a4925fdd261ae08138d1aa7945 | phyokolwin/pythonworkshop | /02/02E01.py | 130 | 3.828125 | 4 | shopping = ["bread","milk","eggs"]
print(shopping)
for item in shopping:
print(item)
mixed = [365,"days",True]
print(mixed)
|
63dc143aa10a6a0343b440633ebea3f16e5dd745 | maokitty/IntroduceToAlgorithm | /docDist/docDistance_listStruct_2.py | 6,408 | 3.625 | 4 | import math
class DocDistance(object):
def __init__(self):
self.file_1 = "../txtFile/javawikipage.txt"
self.file_2="../txtFile/pythonwikipage.txt"
def read_file(self,filename):
try:
file=open(filename)
return file.readlines()
except Exception as e:
print(e)
def word_split_file(self,records):
wor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.