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 |
|---|---|---|---|---|---|---|
404acd2dd261ffc0af69fb33739be5886fde2b4c | saitejakodakandla/mathgenie | /inherit.py | 1,317 | 4.03125 | 4 | class Triangle: # abstract class
ab=0
bc=0
ac=0
A=0
B=0
C=0
def __init__():
pass
def showSides(self):
print("Side 1: ab =>",self.ab)
print("Side 2: bc =>",self.bc)
print("Side 3: ac =>",self.ac)
return
def getArea():
... |
cce87af4f646dc366944678f47eb5870bc0967c6 | noahstettler/python-challenge | /PyBank/main.py | 1,732 | 3.8125 | 4 | import csv
# Text File
f = open("Bank.txt", "w+")
with open("budget_data.csv") as in_file:
csv_reader = csv.reader(in_file)
header = next(csv_reader)
data = list(csv_reader)
print("Financial Analysis")
f.write("Financial Analysis" + '\n')
# Number of Months in the Period
num_months = len(d... |
840bec47177afd3ac2b72834335be1d60b869396 | RadTechDad/AtBS | /Chapter 3/zigzag.py | 708 | 3.828125 | 4 | # zigzag.py
# AtBS - Chapter 3
# Code by Darrell Dudics
import time, sys
indent = 0 # How many spaces to indent
indentIncreasing = True # Wheter the indentation is increasing or not
try:
while True: # The main program loop.
print(' ' * indent, end = '')
print('********')
time.sleep(0.1) # Pause for 1/1... |
470b8a0d869d0d4ca831e28914818cda23850cdc | RadTechDad/AtBS | /Chapter 2/yourName2.py | 169 | 3.859375 | 4 | # yourName2.py
# AtBS - Chapter 2
# Code by Darrell Dudics
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
|
7257de39f296c20c9dcf1bbb2af60159e02b26cc | sortedcord/Ellis | /ask_wikipedia.py | 1,588 | 3.59375 | 4 | import wikipedia
from space import space
import textwrap
from voice import say
def checkEcodeRun(ecode, subject):
if ecode:
say("I could not find any information on this topic.")
else:
print("Source: Wikipedia")
say("Information on " + subject + " brought to you by wikipedia.")
def do... |
357ef173845b4d36275b745cfee0ff69719f33cc | NickyJay/PortfolioProject | /week3/using_strings.py | 273 | 3.53125 | 4 |
my_string = "alpha"
'''
multiline_string = """bravo
charlie"""
print(my_string)
print(multiline_string)
print(my_string[0])
print(my_string[3])
print(my_string[0:3])
print(my_string[:2])
print(my_string[2:])
print(my_string)
'''
for char in my_string:
print(char)
|
5f998128cd6755fd0c4a9b4183141e6c0e5abb48 | NickyJay/PortfolioProject | /Portfolio_Project/game1.py | 1,802 | 4.03125 | 4 | import random
import os
def WordList():
global generated_word
word_list =["blue", "green", "tiger", "dog", "black", "white", "monkey", "bat", "donkey", "gold", "look"]
generated_word = random.choice(word_list)
return generated_word
word = WordList()
for i in word:
print("_", end = " ")
def Chec... |
5e13a4066f53c3d50d324229aaa0b06ab20aa1a2 | A01376318/Mision_03 | /Trapecio.py | 745 | 3.625 | 4 | #Autor: Elena R.Tovar, A01376318
#Calcular área y perímetro midiendo base mayor, base menor y altura de trapecio isóceles
import math
#calcula area
def calcArea(ba,bb,h):
a=((ba+bb)/2)*h
return a
#calcula hipotenusa
def hipotenusa(ba,bb,h):
hip= math.sqrt((h**2)+(((ba-bb)/2)**2))
return hip
#... |
c5f0a01c6d9a641cd038ff4b8891013b8ffffb14 | pzar97/PreCourse-2 | /Exercise_5.py | 1,365 | 3.625 | 4 | # Python program for implementation of Quicksort
# Overall complexity:
# Bestcase: O(nlogn)
# Worst case: O(n^2)
# Average case: O(nlogn)
# This function is same in both iterative and recursive
def partition(arr, l, h):
#write your code here
i = l -1
# last element as pivot
pivot = arr[h]
for k in range(l,h... |
05f3b2e93acd957ac8cc703f005b284d0671985e | xsfar/StockScraper | /src/scrape.py | 2,111 | 3.515625 | 4 | """
use selenium to vist Yahoo finance and scrape request stock information
last update by Ilyass on 5/14/21
"""
from selenium import webdriver
geckodriver = '..\drive\geckodriver'
options = webdriver.FirefoxOptions()
options.add_argument('-headless')
driver = webdriver.Firefox(executable_path=geckodriver, options=opt... |
eb00893217b66050eebf35d0941cf58fc2e8979f | Natgho/PythonTraining | /ders_3/file_comparison.py | 730 | 3.59375 | 4 | # Açmak istediğim dosyayı seçiyorum, dosyayı ben burada direk ekledim, farklı
# Yerler için yolu ayrıca göstermek gerek.
d1 = open("icerik_1.txt")
# Dosyadaki her satırı 1 parça olarak kaydediyorum.
icerik_1 = d1.readlines()
#Karakter sayısını saymak için başlangıç değeri atıyorum.
sayi = 0
krkter = input("Lütfen ara... |
07581a1a06f2a2ebc3ace982c6c20b93519d18e6 | piedra234/weather-test | /weather_api/services/city.py | 3,632 | 3.703125 | 4 | #
from datetime import datetime, timedelta, timezone
import time
class City():
def __init__(self, coord, weather, base, main, visibility, wind, clouds, dt, sys, timezone, id, name, cod):
#External api values
self.coord = coord
self.weather = weather
self.base = base
self.m... |
fe3bc41f99316652f60eca527423d1bfc9a5eeb0 | gjwlsdnr0115/Computer_Programming_Homework | /lab8_2015198005/lab8_p2.py | 469 | 3.8125 | 4 | def removeValuesInPlace(L, threshold):
"""
removes elements in list that are above threshold
:param L: list to mutate
:param threshold: threshold value
:return: mutated list L
"""
del_list = [] #list to contain elements to delete
for num in L:
if num > threshold:
de... |
d0f5ff3a023448cb91e47db3e226901be4fc0160 | gjwlsdnr0115/Computer_Programming_Homework | /lab8_2015198005/lab8_p3.py | 436 | 3.671875 | 4 | def resetValues(L, threshold):
"""
creates new list with elements 0 if it is above the threshold
:param L: input list
:param threshold: threshold value
:return: Result list
"""
Result = [] #result list
for num in L:
if num > threshold: #if element above threshold
... |
10b263005eda61a3e11c7b168d4e13e7cd184737 | gjwlsdnr0115/Computer_Programming_Homework | /lab13_2015198005/lab13_p3.py | 5,869 | 3.59375 | 4 |
# Import our own constants:
from globals import FOODMAX, STEPMAX, WIDTH, HEIGHT, X_MAX, Y_MAX, MS_TO_QUIT
from globals import FOOD as food, GHOSTS as ghosts
# Import our own doboggi_man class:
from characters import doboggi_man
import turtle
class auto_doboggi_man(doboggi_man):
"""
Class au... |
706c8db3aee52aa6d6b51fde056507a7a591e69e | gjwlsdnr0115/Computer_Programming_Homework | /lab10_2015198005/lab10_p5.py | 2,324 | 4.03125 | 4 | # Sparse Text Program
def createModifiedFile(input_file, outputfile):
'''
For text file input_file, creates a new version in file outputfile
in which all instances of the letter 'e' are removed.
'''
empty_str = ''
num_total_chars = 0
num_removals = 0
#create list of vowels
... |
b938f3cd684ab67db3e0c05716f1fc5c4a0d9eba | gjwlsdnr0115/Computer_Programming_Homework | /lab6_2015198005/lab6_p1.py | 243 | 3.9375 | 4 | name = input('Enter a first and last name: ') #input name
first_name = name.split()[0] #allocate first and last name
last_name = name.split()[1]
full_name = last_name + ', ' + first_name[0] + '.' #make full name string
print(full_name)
|
0d55e9a32e80e3bf70ef0534f9f8bda1cec61684 | gjwlsdnr0115/Computer_Programming_Homework | /lab5_2015198005/lab5_p1.py | 431 | 4.28125 | 4 | # initialize largest number variable
largest_num = 0
# variable to stop while loop
more = True
while(more):
num = float(input('Enter a number: '))
if(num > largest_num) :
largest_num = num
if(num == 0):
more = False
if(largest_num > 0): # if there was a positive number input
print('... |
cca53fa2eae57d9c6a933cb4130a475c8cf3187c | gjwlsdnr0115/Computer_Programming_Homework | /lab2_2015198005/lab2_p5.py | 246 | 4.375 | 4 | print('This program will convert degrees Celsius to degrees Fahrenheit')
celsius = float(input('Enter degrees Celsius: '))
fahren = celsius * 9/5 + 32
print(celsius, 'degrees Celsius equals',
format(fahren, '.1f'), 'degrees Fahrenheit')
|
c71799fd5e433302d948027f4725ac335f486872 | japanett/hackToberFest | /arvoreBinaria/main.py | 1,233 | 3.65625 | 4 | from tarefa10 import ArvoreBinBusca
def main():
arvore = ArvoreBinBusca()
# arvore.insere(10)
# arvore.insere(20)
# print("teste: ", arvore.raiz.getItem())
# print("teste: ", arvore.raiz.getDir().getItem())
opcao = 10
while (opcao != 0):
opcao = int(input("\tMenu Arvore ... |
310d6b1c089243b4453206e7b6a3f1f9d40855d1 | lauvindra/Credit-Card-Validator-using-Luhn-s-Algorithm | /lhun.py | 994 | 4.09375 | 4 | card_no = "5610591081018250"
odd_sum = 0
even_sum = 0
double_list = []
#convert it to list to make iterations
number = list(card_no)
#enumerate to obtain index list
for (idx,val) in enumerate(number):
if idx %2!=0: #this is an odd number
odd_sum += int(val)#1.Find the sum of odd index values of the credit card.
el... |
9a056599da4b35f0dad27188f656430d43a38bdf | HazardDede/pytoolkit | /pytoolkit/env.py | 1,889 | 3.796875 | 4 | """Contains utilities to alter the current environment such as environment variables."""
import contextlib
import os
from typing import Iterator
@contextlib.contextmanager
def modify_environ(*remove: str, **update: str) -> Iterator[None]:
"""
Temporarily updates the `os.environ` dictionary in-place and reset... |
6dc1cd4351c16aee1dcd7d4ffced9f9bf4b4095e | HazardDede/pytoolkit | /pytoolkit/check.py | 1,322 | 4.0625 | 4 | """Contains various checking functions."""
from typing import Any
def is_iterable_but_no_str(candidate: Any) -> bool:
"""
Checks if the given `candidate` is an `iterable` but not a `str` instance
Args:
candidate (Any): The candidate to test.
Returns:
bool: Returns `True` if the give... |
86c6fb7d4fe40b9d8f94ecac544c7ebaa3c487da | Bekbolat-programmer/School_Lesson1 | /Гришина прога.py | 542 | 3.71875 | 4 | def lt_b(a, b):
a = ord(a) - ord('a')
a = (a + b) % 26
return chr(ord('a') + a)
def a_tr(a, b):
result = ''
for lt in a:
if 'a' <= lt.lower() <= 'z':
if lt.islower():
result += lt_b(lt, b)
else:
result += lt_b(lt.lower(), b).upper()
... |
f2bdfe0292298fb87905c484e102f5851c4f1e2b | paddygit/hands-on | /Python/DrChuck/Chapter2/py013.py | 218 | 3.890625 | 4 | # try/except
str1 = "Hello, world"
try:
istr = int(str1)
print("statement1")
except:
istr = -1
print(istr)
str2 = "123"
try:
istr = int(str2)
print("statement2")
except:
istr = -1
print(istr)
|
c3975359d057be83d947bbdc2666b8847777b442 | Jeansds/Python | /Exercicios/Lista-4/Ex 7.py | 771 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 8 09:59:21 2020
@author: U300398
"""
import random
vetor = ["maca", "laranja", "banana", "cereja"]
palavra=random.choice(vetor)
Vidas=6
i=0
def Jogo(resposta):
if resposta==palavra:
print("voce ganhou")
return 0
else:
print... |
069739315c2e7c0c2a2f8e62fb2f4338cb767650 | grahamh21/Python-Crash-Course | /Chapter 4/Try_it_yourself_chapter_4_2.py | 1,560 | 4.34375 | 4 | #Try_it_yourself 4-7
print('Try it yourself 4-7')
threes = list(range(3,31,3))
for three in threes:
print(three)
#Try_it_yourself 4-8
print('Try it yourself 4-8\n')
cubes = []
for cube in range(1,11):
cubes.append(cube**3)
print(cubes)
#Try_it_yourself 4-9
print('Try it yourself 4-9')
#list c... |
1acb5d026b59ef5e6387e30db6d0caff567b789b | grahamh21/Python-Crash-Course | /Chapter 9/user_module.py | 1,063 | 4 | 4 | class User():
'''A way to model a user'''
def __init__(self, first_name, last_name, job, birth_month, birth_year):
self.first_name = first_name
self.last_name = last_name
self.job = job
self.birth_month = birth_month
self.birth_year = birth_year
self... |
e21813eeb1869e5f1776dc82d68f08b17a02c9af | grahamh21/Python-Crash-Course | /Chapter 9/dog.py | 821 | 4.1875 | 4 | class Dog():
'''Simple dog class'''
def __init__(self, name, age):
'''Initialize name and age attributes'''
self.name = name
self.age = age
def sit(self):
'''simulate a dog sitting in response to a command'''
print(self.name.title() + ' is now ... |
3c8bd47f5780f7c462ae861352f50552e2a3f140 | grahamh21/Python-Crash-Course | /Chapter 5/try_it_yourself_chapter_5_part_2.py | 1,054 | 3.765625 | 4 | #Try It Yourself - 5:3
alien_color = 'Green'
if 'Green' in alien_color:
print('5 points!')
if 'Red' in alien_color:
print('10 points!')
#Try It Yourself - 5:4
alien_color1 = 'yellow'
if 'yellow' in alien_color1:
print('10 points!')
else:
print('15 points')
alien_color1 = 'red'
i... |
5a8d70ad3cd17cd99aee228b851d8aaa5c1ab3f7 | grahamh21/Python-Crash-Course | /Chapter 8/function_list.py | 711 | 3.75 | 4 | def emails(unconfirmedEmail, confirmedEmail, ):
while unconfirmedEmail:
currentEmail = unconfirmedEmail.pop()
print('confirming email: ' + currentEmail)
confirmedEmail.append(currentEmail)
def show_confirmed_emails(confirmedEmail):
'''show all the emails that were confirmed'''
... |
16f8dda94334bc8f587caef2509281aba41bf38d | grahamh21/Python-Crash-Course | /Chapter 6/try_it_yourself_chapter_6-3.py | 2,074 | 3.984375 | 4 | #Try it yourself 6-7:
person1 = {'name': 'kristy', 'surname': 'love', 'age':30 , 'city':'rochester',
'state': 'new york', }
person2 = {'name': 'John', 'surname': 'Macenroe', 'age':69 , 'city':'Paris',
'state': 'France', }
person3 = {'name': 'Jason', 'surname': 'Bourne', 'age':21 , 'city':'Madrid',
'st... |
42b13d5b26d98ebec3660bc7ad1b3224fee1352f | grahamh21/Python-Crash-Course | /Chapter 8/magicians.py | 184 | 3.59375 | 4 | def show_magicians(names):
for name in names:
print('Hello ' + name)
magicians = ['larry', 'greg', 'carol', 'dave']
show_magicians(magicians)
def make_great(the_great):
|
ffdd29ba05a562fc95e8580c13a2efca21f21f12 | grahamh21/Python-Crash-Course | /Chapter 9/Try_it_yourself_Chapter_9_Part_11.py | 519 | 3.8125 | 4 | #Try it yourself 9-14: Dice
from random import randint
class Die():
'''An attempt to model a dice'''
def __init__(self, sides = 6):
'''initializing the dice class'''
self.sides = sides
def roll_die(self):
'''a method used to roll the dice'''
print... |
d834088927713f9054ae634b9c6288a5ec12271e | grahamh21/Python-Crash-Course | /Chapter 6/try_it_yourself_chapter_6-1.py | 1,239 | 3.984375 | 4 | #Try it yourself 6-1:
person1 = {'name': 'kristy', 'surname': 'love', 'age':30 , 'city':'rochester',
'state': 'new york', }
print(person1)
print(person1['surname'])
print('\n')
#Try it yourself 6-2:
favorite_numbers = {
'greg': 35, 'carol': 21,
'steve': 6, 'jeremiah': 14,
'lily' : 42069,
... |
e22b71585457b49b0e2a9c4525ce003b9c84ed76 | grahamh21/Python-Crash-Course | /Chapter 9/Try_it_yourself_Chapter_9_Part_6.py | 2,010 | 4.34375 | 4 | #Try it yourself 9-8: Privileges
class User():
'''A way to model a user'''
def __init__(self, first_name, last_name, job, birth_month, birth_year):
self.first_name = first_name
self.last_name = last_name
self.job = job
self.birth_month = birth_month
self.b... |
41e74a856599e3ced6a57dcc0f6611fdf21bdcdc | grahamh21/Python-Crash-Course | /Chapter 4/Try_it_yourself_chapter_4.py | 730 | 3.59375 | 4 | #Try it yourself 4-1
print('Try it Yourself: 4-1\n')
pizzas = ['pepperoni', 'cheese', 'veggie', 'meat']
for pizza in pizzas:
print('I love ' + pizza.title() + ' pizza!')
print('Man boobs!\n')
#Try it yourself 4-3
print('Try it Yourself: 4-3\n')
for squa in range(1,21):
print(squa)
print('\n')
#Try it... |
c7989ec34c300885a8cfef8880455383acc30b45 | terranblake/practice | /problems/graph-two-coloring.py | 1,020 | 3.546875 | 4 | from structures.graph import Graph, GraphType, VertexState
from enum import Enum
class Colors(Enum):
BLUE = 1
RED = 2
UNCOLORED = 3
class TwoColoringGraph(Graph):
def process_edge_creation(self, u, v):
if u not in self.colors:
self.colors[u] = Colors.UNCOLORED
def complem... |
7ff50a6dcd7cd9088e51dd497268e90acee9d087 | terranblake/practice | /problems/structures/binarysearchtree.py | 4,137 | 3.984375 | 4 | from enum import Enum
class Traversal(Enum):
INORDER = 1
POSTORDER = 2
PREORDER = 3
class BSTNode:
def __init__(self, value = None):
self.value = value
self.left = None
self.right = None
def insert(self, value = None):
new = BSTNode(value)
current = se... |
2ecb0b4693bdf1151e12e928a88c8daed10cb93e | IagoFrancisco22/listaDeExerciciosPython | /Quarta lista de exercicios Python/exercicio4.py | 1,395 | 4.34375 | 4 | import os
print(''' Seja o statement sobre diversidade: “The Python Software Foundation and the global Python
community welcome and encourage participation by everyone. Our community is based on
mutual respect, tolerance, and encouragement, and we are working to help each other live up
to these principles. We want... |
4a1ff10e868b2fb83a91075316411c5d01f9197b | IagoFrancisco22/listaDeExerciciosPython | /Terceira lista de exercicios Python/exercicio2.py | 502 | 4.09375 | 4 | print('''Faça um programa que leia um nome de usuário e a sua senha e não aceite a senha igual ao
nome do usuário, mostrando uma mensagem de erro e voltando a pedir as informações.''')
nome=str(input("Digite um nome de usuario:"))
senha=str(input("Digite uma senha:"))
while True :
if nome==senha:
... |
38c726a507f57fe39460d94ae50a9fb214de35b8 | IagoFrancisco22/listaDeExerciciosPython | /Primeira lista de exercicios Python/exercicio8.py | 277 | 4.15625 | 4 | #enunciado
print('''Converta uma temperatura digitada em Fahrenheit para Celsius.''')
f=int(input("Digite o valor da temperatura em Fahrenheit:")) #temperatura em celsius
C = ((f-32)/9)*5#conversao para celsius (F = 9*C/5 + 32)
print("A temperatura e de",C,"Celsius")
|
ef100a376de3cd5d540a3a4374bf9fe77ffe0d1f | Mahrkeenerh/Encryption | /Caesar/caesarDecrypt.py | 439 | 3.5 | 4 |
def decrypt(file_name, offset):
file = open(file_name, 'rb')
out = open('d_' + file_name[2:], 'wb')
while byte := file.read(1):
out.write(((byte[0] - offset) % 256).to_bytes(1, 'big'))
file.close()
out.close()
def main():
inp = input("Input <file offset>: ").strip().split()
... |
c7ec943e8ce864f717cc2b5d8f1770c39f1a2654 | Akshat111999/Python | /GUI/button2.py | 393 | 3.84375 | 4 | from tkinter import *
import webbrowser
def openBrowser():
webbrowser.open_new_tab("https://www.google.com") # opens a new tab in the browser
root = Tk() // creates a root window
Button(root, text="Open Browser", command= openBrowser).pack() #.pack() method is used to organise the blocks in rows and columns
root... |
bbcd6f5f4addc2033fe5ac21c371ed3eb6381c90 | Akshat111999/Python | /String Processing.py | 198 | 3.96875 | 4 | import string
def string_processing(string_list):
z=string_list.lower()
p=''.join([x for x in z if not x in string.punctuation])
return p
st=string_processing("Hello, world!")
print(st)
|
4cfe68342c6d0ce20d2a7657ca106b29259b3345 | Akshat111999/Python | /problem03.py | 476 | 4.15625 | 4 | #take a list say adhoc=[1,2,3,1,4,5,66,22,2,6,0,9]
#write the program that will do
#i) print only those numbers greater than 5
#ii) also print those numbers those are less than or equals to 2 ( <= 2 )
#iii) store these answers in in two different list also
adhoc = [1,2,3,1,4,5,66,22,2,6,0,9]
for i in a... |
ab15519d9596907f5db90f2495970aa1f684e8bf | alejogs4/python-topics-udem | /tree.py | 2,263 | 3.65625 | 4 | class Tree:
def __init__(self, root_value):
self.root = { 'value': root_value, 'left': None, 'right': None }
def addChild(self, value):
current_node = self.root
while current_node is not None:
if value < current_node.get('value'):
if current_node.get('left') is None:
current... |
8684196996a78ed400f2de9b30077ad6e366d05b | nazaninsbr/Queue | /priority_queue.py | 1,106 | 3.921875 | 4 | class Queue:
def __init__(self):
self.values = []
self.front = -1
self.rear = -1
def enqueue(self, val, priority):
if self.isEmpty():
self.values.append([val, priority])
else:
added = False
for itemId in range(len(self.values)):
if itemId==len(self.values):
break
if self.values[itemId... |
72a89afe2af9ecd14846a6f4e5939029f18162bd | Victor-GuilhermeCN/Challenges | /Challenge1.py | 501 | 4.03125 | 4 | # Challenge number 1
# Creating the class and 3 methods.
class Car:
def __init__(self, model, color, year):
self.model = model
self.color = color
self.year = year
def turn_on(self):
print('Car starting!')
def turn_of(self):
print('Car turning off!')
def show... |
a5a739ec3f8c80eedbc5dfe01982860dd5236675 | Legitcoder/Data-Structures | /doubly_linked_list/doubly_linked_list.py | 3,682 | 4.375 | 4 | """Each ListNode holds a reference to its previous node
as well as its next node in the List."""
class ListNode:
def __init__(self, value, prev=None, next=None):
self.value = value
self.prev = prev
self.next = next
"""Wrap the given value in a ListNode and insert it
after this node. Note that this no... |
8adf115307dfd6d5c3fc8895b4680e7570ae032c | rafael-vieira-coelho/brickout_pygame | /brickout.py | 993 | 3.703125 | 4 | """
Sample Breakout Game
Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/
"""
# --- Import libraries used for this program
from settings import Settings
from game_functions import *
# Call this function so the Pygame library c... |
9100854d41b68d9ba582baef9ee47e656defbd28 | Fenikonir/2_GOD_1 | /Задачи/4.2.py | 290 | 3.859375 | 4 | import sqlite3
db2 = input()
conntact = sqlite3.connect(db2)
cur = conntact.cursor()
result = cur.execute("""SELECT * FROM Films
WHERE title like 'Х%'""").fetchall()
a = set()
for elem in result:
a.add(elem[2])
for i in range(len(a)):
s = a.pop()
print(s)
conntact.close()
|
c0e6f836bec6aef9b08f4ab8922c26a79b21582c | hiImDeni/flcd | /lab4/finite_automaton.py | 1,935 | 3.546875 | 4 | from transitions import Transitions
class FiniteAutomaton:
def __init__(self, file):
self.q = set() # states
self.alphabet = set() # sigma
self.transitions = Transitions()
self.F = set() # final states
self.__file = file
self.__read_file()
def __... |
6e1152b8436dca74168d4e9c1074a82f17de31df | AliHCS/Ejercicios-de-LeetCode | /1431.Kids-With-the-Greatest-Number-of-Candies.py | 3,941 | 3.65625 | 4 | #Descripcion del problema (Ingles)
# There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have.
# Return a boolean array result of length n, where result[i... |
a4f7b894e5eea2fa5bc08aaf7532ac46c0911069 | reshmarkn/hw-training | /2021-06-15/student.py | 570 | 3.625 | 4 | class Student:
def __init__(self,name=None,roll_no=None,subject=None,marks=None):
self.name=name
self.roll_no=roll_no
self.subject=subject
self.marks=marks
def Subjects(self,subject):
self.subject=subject
def Mark(self,marks):
self.marks=marks
def display(... |
339aafcc9662e066033a42589bcc263811474e73 | gustavodp22/adivina_el_numero_metodo1 | /adivina el numero metodo 1.py | 355 | 4.09375 | 4 | #metodo 1 adivina el numero
#!/usr/bin/python3
import random
n=random.randrange(1,100)
nu=int(input('Dime el número que crees que he elegido: '))
while nu!=n:
if nu>n:
nu=int(input('El número es mas pequeño'))
elif nu<n:
nu=int(input('El número es mas grande'))
print('Felicidades has adivinado q... |
08d1831b9af14b36f20be6fe96fe9de23322559e | franciscopantojag/cs50 | /pset6/cash/cash.py | 526 | 3.53125 | 4 | from cs50 import get_float
from math import floor
def main():
changeOwed = get_float("Change owed: ")
if changeOwed < 0:
return main()
quarters = floor(changeOwed / 0.25)
dimes = floor(round(changeOwed % 0.25, 2) / 0.1)
nickels = floor(round(round(changeOwed % 0.25, 2) % 0.1, 2) / 0.05)
... |
278014c7e052b291a7f963aab2fcecacfc625491 | AyuBuradkar26/21-DAYS-PROGRAMMING-CHALLENGE-ACES | /Sorting/selection_sort.py | 363 | 3.640625 | 4 | def selection(array,size):
for i in range(size):
min=i
for j in range(i+1,size):
if(array[min]>array[j]):
min=j
(array[min],array[i])=(array[i],array[min])
return array
arr=[14,7,54,34,45,67,12,30,60,97,2]
n=len(arr)
A=selection... |
a4bc633cdf6961bef191d396d09e412b1da6c390 | ankitppatel/Sample-Code | /TicTacToe_Computerized.py | 5,087 | 3.96875 | 4 | # written using Python 3
import random
# initialize my blank tic tac toe board
myMatrix = [[1,2,3], [4,5,6], [7,8,9]]
snapshots = [[1,1,1], [1,1,1], [1,1,1], [1,1,1], [1,1,1], [1,1,1], [1,1,1], [1,1,1]]
snapMap = ((1,2,3), (4,5,6), (7,8,9), (1,4,7), (2,5,8), (3,6,9), (1,5,9), (7,5,3))
#function to print the tic tac ... |
86b0fb2830534722a3aa297172e19ff9e3f3d2f1 | KeweiJia818/LC_practice | /reverseLinkedlist.py | 1,135 | 3.8125 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def reverseList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head == None:
r... |
31503627620d354c35b3d5d6af2a7892ba7bd71e | KeweiJia818/LC_practice | /twosum.py | 301 | 3.5625 | 4 |
class Solution(object):
def twoSum(self, nums, target):
for i in range(0, len(nums)):
for j in range(i+1, len(nums)):
if nums[i]+ nums[j] ==target:
answer = []
answer.append(i)
answer.append(j)
return answer
a = Solution()
print a.twoSum([3,2,4], 6)
|
0c7428daca787e4a3facc5821ca3bd96de2a7cd7 | supersowbow/python_practice | /prices.py | 1,600 | 4.03125 | 4 | import sys
import re
total = 0.00
while True:
# Prompt user to enter a filename
print("=" * 80)
print("Enter the file name. Type 'DONE' to quit.\n")
print("Type 'HELP' to display commands.\n")
print("=" * 80)
filename = input("> ")
# Exits out the program
if filename.lower() == 'done'... |
f9e8227b3dc50850b519433d10ac9535f2268c6f | jansenmtan/Project_Euler | /15_0a.py | 4,993 | 3.9375 | 4 | #-*-coding:utf8;-*-
#qpy:3
#qpy:console
#detects if destination is valid and is an integer
def can_move(matrix,destination):
try:
if isinstance(matrix[destination[1]][destination[0]],int):
return True
except:
return False
return False
#move_r and move_d detects if its possible ... |
08c221e36967711c6bc6ec7133d73db9da4a66df | BGCX067/fallas2-2do2010-svn-to-git | /trunk/sistema/fallas2/src/example.py | 896 | 3.5625 | 4 | # file: AWTTest.jy
#
#
# Import the AWT classes.
#
from java.awt import Frame
from java.awt import Panel
from java.awt import Button
from java.awt import TextArea
from java.awt.event import ActionListener
#
# Define the TestButtonAction class. TestButtonAction
# inherits from the Java ActionListener... |
18ea58920598f4a6d7e259b3877991e0c7149d60 | leeyoshinari/Small_Tool | /counter/Counter.py | 485 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: leeyoshinari
class Counter:
"""
统计函数执行次数
"""
def __init__(self, func):
self.func = func
self.count = 0
def __call__(self, *args, **kwargs):
self.count += 1
return self.func(*args, **kwargs)
i... |
2512efb06c08d5af5054178ad817378098e0e829 | princepurohit153/A-byte-of-python | /Socket-programming/socketserver.py | 636 | 3.828125 | 4 | '''
This is a simple program which demonstrates socket server programming in python.
@author Nitinkumar Gove
@version 1.1
'''
import socket
import sys
# create server socket for (host, port)
host = ''
port = 8888
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
s.bind((host,port))
except socket.error, ... |
60c99c8627039d5bdee57f79168b92429c497f73 | princepurohit153/A-byte-of-python | /extras.py | 361 | 3.65625 | 4 |
listone = [1,2,3,4,5,6,7,8,9,0]
listtwo = [ 2* item for item in listone if item!=0]
print listone
print listtwo
# -------- decorator -----------
def addtag(tag='none'):
def decor(func):
def new_func(text):
print text + ' <deco> ' + tag
return new_func
return decor
@addtag()
d... |
c9cfb718e456ebfc70546edc6e4e23af11d9030d | veenauppalapati/python-challenge | /PyBank/main.py | 4,435 | 4.15625 | 4 |
# First we'll import the os module to create file paths across operating systems
import os
# import the csv module for reading CSV files
import csv
def write_to_file(results_list):
# Define the output csv file
output_results_file = os.path.join("analysis", "results.txt")
#write to the file
with ope... |
46d4ad82c6d007797d045ef642bb5fe8c1e3030b | gildniy/mosquito-samples-mixer | /main.py | 3,511 | 3.78125 | 4 | import os
from datetime import datetime
from random import random
def increment_sample_counter(name, total):
"""
Create or rename a counter file depending on the no of the current
mosquitoes sample. The initial counter file needs to be in the root
folder with this script...
Example: An empty file ... |
c974e6a123110e76a4f33dd4ece78590272b072e | ly21st/my-algorithm | /python-vsc/geekbangtrain/week08-09/7a/Conroutine/p6_async_await.py | 862 | 3.59375 | 4 | # python3.4 支持事件循环的方法
import asyncio
@asyncio.coroutine
def py34_func():
yield from sth()
##################
# python3.5 增加async await
async def py35_func():
await sth()
# 注意: await 接收的对象必须是awaitable对象
# awaitable 对象定义了__await__()方法
# awaitable 对象有三类
# 1 协程 coroutine
# 2 任务 Task
# 3 未来对象 Future
############... |
1dedf992b7135a2d9aadcf8988d54e8b203f4861 | ly21st/my-algorithm | /python-vsc/geekbangtrain/week07/6a/NewClass/p6_2getattribute.py | 421 | 4 | 4 | class Human2(object):
"""
拦截已存在的属性
"""
def __init__(self):
self.age = 18
def __getattribute__(self,item):
print(f' __getattribute__ called item:{item}')
return super().__getattribute__(item)
h1 = Human2()
print(h1.age)
# 存在的属性返回取值
print(h1.noattr)
# 不存在的属性返回 AttributeErr... |
7eda3a574e393446da54a8bfbb58ffe754980268 | ly21st/my-algorithm | /python-pycharm/MyCircularDeque.py | 2,300 | 3.703125 | 4 | #! -*- coding:utf-8 -*-
class Node(object):
def __init__(self, value=-1):
self.pre = None
self.next = None
self.value = value
class MyCircularDeque(object):
def __init__(self, k):
self._size = 0
self._max_size = k
self._node = Node()
self._front = self._... |
76b57eeac3aec6f70f19f063ab7ee562b8ce6603 | ly21st/my-algorithm | /python-vsc/geekbangtrain/week08-09/job/my_map.py | 376 | 3.796875 | 4 |
def my_map(func, it):
return [func(x) for x in it]
def my_map2(func, it):
return (func(x) for x in it)
def my_map3(func, it):
for x in it:
yield func(x)
def power(x):
return x * 2
if __name__ == '__main__':
it = [10, 20, 30, 40, 50]
print(list(my_map(power, it)))
print(list(my_... |
d755294e211e66c44e04c990d383650b061d087c | ly21st/my-algorithm | /python-vsc/geekbangtrain/week01/1c/1c_python.py | 2,222 | 4.21875 | 4 | # 1 Python是一门简洁的语言
int temp = var1 ;
var1 = var2 ;
var2 = temp ;
var2, var1 = var1, var2
# 2 所有语言的开头 Hello world
print('Hello, World')
# 3 Python可交互可字节码
>>> x = 1
>>> help(x)
>>> dir()
>>> exit()
# 4 内置数据类型
数值 布尔
字符串
列表、元组、字典、集合
# 4.1 数值常见有 整数、浮点数、复数、布尔值
整数 1 -5 100 8888
整数没有大小限制,受限于内存
浮点数 2.5 4.8
复数 1+2... |
a088f0913a44f2613488d014a1547c998ef89946 | maronnax/aoc | /scripts/euler/problem_003 | 659 | 4 | 4 | #! /usr/env python
def smallest_prime_factor(number):
# Because we index on 2..number this always returns a prime.
for x in range(2, number+1):
if number % x == 0:
return x
def is_prime(num):
return (smallest_prime_factor(num) == num)
def get_prime_factorization(number):
factor... |
d758a3f7db1391f62de60fafdb8396d8977f1e70 | sudheer-sanagala/edx-python-course | /WEEK-01/square_of_numbers.py | 522 | 4.125 | 4 | """
Square of a given number
ex: 3^2 = 3*3 = 9; 5^2 = 5*5 = 25
"""
# using while-loop
x = 4
ans = 0
itersLeft = x # no of iterations remaining
while(itersLeft != 0): # while no of iterations not equal to 0
ans = ans + x # add the same number by itself for thje total no of loops
itersLeft = itersLeft - ... |
8d3a28a8e4f8159a91c900554289ec7e0780fe9b | JonKopp99/CS1.3 | /strings.py | 5,389 | 4.1875 | 4 | import re
import resource
import platform
def contains(text, pattern):
"""Return a boolean indicating whether pattern occurs in text.Always 0(n)
where n is the lengh of the string. Because we have to loop through
each character and find the pattens."""
assert isinstance(text, str), 'text is not a string... |
2c9379776e0198f819fef73f3af93ff997be26e5 | alexschindele/projects | /mpl_squares.py | 307 | 3.875 | 4 | import matplotlib.pyplot as plt
squares = [n * n for n in range(1, 6)]
# plt.plot(squares, linewidth = 5)
plt.title("Square Numbers", fontsize = 24)
plt.xlabel("Value", fontsize = 14)
plt.ylabel("Square of Value", fontsize = 14)
plt.scatter(range(1,6), [n * n for n in range(1, 6)], s = 100)
plt.show() |
9dab9e18addb355b2e6d5c98df8d61c495912de4 | kuldkkv/generic_code_repo | /cloud_proj_1/bin/gen_tst_data.py | 894 | 3.734375 | 4 | #!/usr/bin/env python
#import argparse
import string
import random
str_chars = string.ascii_letters + string.digits + '_-=-'
num_chars = string.digits
str1 = 'S:13,S:10,S:30,S:8,S:7,N:6,S:16,N:3,S:7,S:18,N:1,N:3,N:3,N:3,N:5,N:3,S:22,S:27,S:11,S:10,S:27,S:11,S:17,N:2,N:8,N:5,N:3'
num_lines = 10000 * 100
def gen_rand_... |
92a59a1b6e4db5c05c03a7b98fa98d8e6a387d5d | ryanchoi111/mywork | /UMICH SI 206 Project 1 /TextAnalyzer.py | 18,919 | 4.15625 | 4 | # Analyze Text with a TextAnalyzer object!
# Your name: Seokmin (Ryan) Choi
# Your student id: rsmchoi
# Your email: rsmchoi@umich.edu
# List who you have worked with on this project:
# import the library needed for testing
import unittest
# you can use the csv library to help you if you wish
import csv
import os
cl... |
532c25ce5d4fc2cef0accc681d5b3e060402e0b1 | HagaiNaday/DeepLearning | /s.py | 2,309 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 25 19:14:25 2019
@author: hagai
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset=pd.read_csv('Churn_Modelling.csv')
X=dataset.iloc[:, 3:13].values
Y=dataset.iloc[:,13].values
#Encoding
from sklearn.preprocessing import Labe... |
5158ade2e1632aec0de6d2fa0593735431e1f2fb | yemi33/PasswordCracking | /password_cracker.py | 6,428 | 3.625 | 4 | #!/usr/bin/env python3
import hashlib
import binascii
class PasswordCracker:
def __init__(self, wordFile, passwordFile, mode = "single"):
self.words = [line.strip().lower() for line in open(wordFile)]
self.passwordHashes = [line.strip().split(":")[1] for line in open(passwordFile)]
self.wordFile = wordFi... |
2f0eba0a047e7fbeae270ef2e34b14e080546cd7 | Amaan118/Password-Generator | /7_Random_Password_Genertor.py | 990 | 3.84375 | 4 | import random
import string
upper = 0
lower = 0
digits = 0
special = 0
def ask_user():
print("Choose 1 for Yes and 0 for No")
try:
global upper
upper = int(input("A. Include Upper Case Letters (1) or (0) : "))
global lower
lower = int(input("B. Include Lowercase Letters (1) or (0) : "))
global digit... |
874c1fbaafda7a096fc5538b9382ac4c000162d3 | t-lanigan/interesting-problems | /mult-of-3-and-5.py | 907 | 4 | 4 |
# If we list all the natural numbers below 10 that are multiples of 3 or 5,
# we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
import time
n = 1000
#solution #1 (using brute force)
t0 = time.time()
s = 0
for i in range(1,n):
if i % 3 == 0 or i % 5 ... |
9831120fea9491491edae789e0fcc6d4eb846c3e | t-lanigan/interesting-problems | /lattice-paths.py | 632 | 3.96875 | 4 | # Lattice paths
# Problem 15
# Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
# How many such routes are there through a 20x20 grid?
#solution using dynamic programing.
def lattice_paths(gs = 2):
gs = 20
... |
41e88c5fec71ca5b06ea1827f51750755f678a36 | X-KG-X/pythonTlgCourse | /apiSpaceX.py | 924 | 3.6875 | 4 | #!/usr/bin/python3
"""
Author: RZFeeser
This program harvests SpaceX data avail from https://api.spacexdata.com/v3/cores using the Python Standard Library methods
"""
# using std library method for getting at API data
import requests
# GOBAL / CONSTANT of the API we want to lookup
SPACEXURI = "https://api.spacexdata... |
fae7352c8c53a83e6e9785004381b43d869f76a3 | X-KG-X/pythonTlgCourse | /pyapi/norad/norad02.py | 1,249 | 3.59375 | 4 | #!/usr/bin/env python3
import requests
import pandas as pd
import json
def main():
resp=requests.get("http://www.celestrak.com/NORAD/elements/active.txt")
# print(resp)
#get data from the norad and write it to active.txt
with open("active.txt", "w") as f:
for line in resp.text:
f.w... |
4f7a76a97f8f929691b300804ed91bb591988817 | 1286211699/2019_1_23_pub_test | /1_10_面向对象的三大方法/07_chongxie_test.py | 1,620 | 3.625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/1/19 22:15
# @Author : for
# @File : 07_chongxie_test.py
# @Software: PyCharm
# class Dog(object):
# def print_self(self):
# print('Hello,I am dog')
# class Tom(Dog):
# def print_self(self):
# #调用父类的方法
# # super().print_self()
# ... |
16012044d2e43b12e2afc200af2d290e36977e9b | 1286211699/2019_1_23_pub_test | /1_9_面向对象/02_class_test.py | 1,853 | 3.703125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/1/17 21:09
# @Author : for
# @File : 02_class_test.py
# @Software: PyCharm
# class Cat():
# print('我是喵咪')
# #实例化一个tom对象
# tom = Cat()
# class Cat():
# '我是喵咪'
# def eat(self):
# '猫'
# print('猫在吃……')
# def drink(self):
# ... |
a48c182aec4e099b87b5930778bb9e87f7ad6e9c | 1286211699/2019_1_23_pub_test | /2019_2_3_public_test/test.py | 582 | 3.84375 | 4 | # L = []
# while True:
# text = input('请输入想要输入的内容:')
# if text:
# L.append(text)
# print(L)
# print('计算输入的几行内容')
# len_text = len(L)
# print(len_text)
# print('开始计算总共字符')
# num_str = 0
# for data in L:
# num_str += len(data)
# print(num_str)
# ... |
b7c2824107127d0c1a614ac7e656404473603d33 | 1286211699/2019_1_23_pub_test | /2019_2_22_public_test/02_yield_test.py | 631 | 3.71875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/2/23 10:29
# @Author : for
# @File : 02_yield_test.py
# @Software: PyCharm
# def my_yield():
# print('即将生成2')
# yield 2
# print('即将生成3')
# yield 3
# print('即将生成5')
# yield 5
# print('即将生成7')
# yield 7
# print('生成结束')
# gen... |
3f257d84c4a739b31914713772ab1eb7687060ff | agmrv/python-project-lvl1 | /brain_games/games/progression.py | 830 | 3.953125 | 4 | """'Brain-Progression' game logic."""
from random import randint
DESCRIPTION = "What number is missing in the progression?"
LENGTH_OF_PROGRESSION = 10
def generate_game_data():
"""Generate the 'Brain-Progression' game data.
Returns:
return the question and correct_answer.
"""
first_num = ra... |
594c97340ac55be24393c36102227c22a7d26c51 | Jesussilverioe/LeetHub | /linked-list-cycle-ii/linked-list-cycle-ii.py | 502 | 3.578125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def detectCycle(self, head: ListNode) -> ListNode:
if not head or not head.next:
return None
slow = head
mydic = {}
while... |
a13b2ee1416f154c9676f40a270830f95a5727fd | oliversssf2/ISEF_2021 | /dplm_base.py | 22,306 | 3.53125 | 4 | import csv
import os
import math
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from numpy.lib.arraysetops import in1d
def print_dir():
print(os.getcwd())
print("hi")
def RMSE():
pass
class dplm:
"""
A class used to represent a DPLM (Double parallelogram mechanism).
T... |
1c6a01ffad2fabee405191e2e4d6e5a6f094d55f | meltedfork/Python-1 | /Python Assignments/Bike_Assignment/bike.py | 890 | 4.21875 | 4 | class bike(object):
def __init__(self,price, max_speed,miles = 0):
self.price = price
self.max_speed = max_speed
self.miles = miles
def displayInfo(self):
print self.price,self.max_speed,self.miles
return self
def ride(self):
print "Riding..."
sel... |
aa894da9a10e60a2de42056c4c9be3733f1631fb | meltedfork/Python-1 | /Python Assignments/dictionary_basics/dictionary_basics.py | 287 | 4.15625 | 4 | def my_dict():
about = {
"Name": "Nick",
"Age": "31",
"Country of birth": "United States",
"Favorite Language": "Italian"
}
# print about.items()
for key,data in about.iteritems():
print "My", key, "is", data
my_dict() |
96802132507102146d1033f9c1c2d4bd917d29ef | jenyta-id/System-Fuzzy | /UAS Matematika Diskrit - Jenyta Primaranti.py | 788 | 3.84375 | 4 | print("=======================*===================*======================")
print("Pengelompokan Usia Menggunakan System Fuzzy dari Nilai Keanggotaan")
print("--------------------Jenyta Primaranti 2020080381------------------")
print("=======================*===================*======================")
# Array du... |
3bed285f835cc5e500ae14e0daaa9d738a53efcf | TamizhselvanR/TCS | /alternative_series.py | 967 | 4.25 | 4 | '''
For Example, consider the given series:
1, 2, 1, 3, 2, 5, 3, 7, 5, 11, 8, 13, 13, 17, …
This series is a mixture of 2 series – all the odd terms in this series form a Fibonacci series and all the even terms
are the prime numbers in ascending order.
Now write a program to find the Nth term in this series.
'''
d... |
14906d8c8564ae3aa73262570dfe1589c259f065 | TamizhselvanR/TCS | /lcm.py | 214 | 3.8125 | 4 | def lcm(a,b,maxi):
if(maxi % a == 0 and maxi % b == 0):
return maxi;
maxi += 1
return lcm(a,b,maxi)
if __name__ == '__main__':
a = 22
b = 6
maxi = max(a,b)
print(lcm(a,b,maxi)) |
2bcf4d3183f4871a6f2dd531a0533f5300fc5410 | ddilarakarakas/Introduction-to-Algorithms-and-Design | /Midterm/q3.py | 1,015 | 3.796875 | 4 | def insertion_sort(arr, low, n):
for i in range(low + 1, n + 1):
val = arr[i]
j = i
while j>low and arr[j-1]>val:
arr[j]= arr[j-1]
j-= 1
arr[j]= val
def partition(arr, low, high):
pivot = arr[high]
i = j = low
for i in range(low, high):
if arr[i]<pivot:
a[i], a[j]= a[j], a[i]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.