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 |
|---|---|---|---|---|---|---|
2028185ced3c005ace0b7cb772c21839166f34ac | Randi20/24-hour-shift-plan- | /Vagtplan2/Submit.py | 4,104 | 3.515625 | 4 | from tkinter import *
import sqlite3
from Vagtplan2.Editor import *
class Submit:
def delete(self):
# Create a database or connect to ons
conn = sqlite3.connect('vagt_plan_app.db')
# Create cursor
c = conn.cursor()
# Delete a record
c.execute("DELE... |
7908fea42d6e688f22fbf804af1821d7d4de7b05 | VenpleD/Python_Demo | /Demo1.py | 261 | 3.546875 | 4 | import os
a = 10
print(type(a))
b = 20
print(type(b))
# c = input("请输入年龄:")
#
# d = input("请输入姓名")
#
# print("我的年龄是:%i"%(a))
# print("我的名字:{},年龄:{}".format(d, c))
if a == 10 and b == 20:
print(a, end=" ")
|
cf321557ea5cf2aea708484b321b2ace1b208afc | kyky2912/UTS_REKAYASA-APLIKASI-TERDISTRIBUSI | /server.py | 2,340 | 3.59375 | 4 | #imports
import socket
import select
HEADER= 1
IP = "127.0.0.1"
PORT = 8888
#Membuat socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#Alamat socket digunakan kembali
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind((IP, PORT))
server_socket.listen()
#L... |
6dbe84052e4841a882ecb524616868c5651860ea | virocha/EP3---DESOFT | /Tabuleiro.py | 3,417 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Insper - Engenharia 1B
Design de Software
EP3: Jogo da Velha
Vitória Rocha e Isabella Oliveira
"""
import tkinter as tk
import tkinter.messagebox as tkm
from Jogo import Jogo
class Tabuleiro:
def __init__(self):
self.meu_jogo = Jogo()
# Janela principal
self.... |
483a246fd2716da637750e1ba1f728e2ad843455 | ChrisStreadbeck/Python | /learning_notes/dictionaries/nested_dictionaries.py | 474 | 3.984375 | 4 | teams = [
{
'astros': {
'2B': 'Altuve',
'SS': 'Correa',
'3B': 'Bregman',
}
},
{
'angels': {
'OF': 'Trout',
'DH': 'Pujols',
}
}
]
# print(teams[0])
angels = teams[1].get('angels', 'Team not found') #this is treating it like a list. We knew it was a dictionary, so ... |
f69d4a3a4e1abadb5d462889976fcaffafbdc9f8 | ChrisStreadbeck/Python | /apps/fizzbuzz.py | 705 | 4.1875 | 4 | var_range = int(input("Enter a Number to set the upper range: "))
def fizzbuzz(upper):
for num in range(1, upper):
if num != upper:
if num % 3 == 0 and num % 5 == 0:
print('FizzBuzz')
elif num % 3 == 0:
print('Fizz')
elif num % 5 == 0:
print('Buzz')
else:
... |
34bf9545e8d5e9189df557c957e6f3bc6442b4c9 | ChrisStreadbeck/Python | /learning_notes/functions_and_methods/named_args.py | 327 | 4.09375 | 4 | #Named Arguments
def full_name(first, last):
print(f'{first} {last}')
full_name(first = 'Kristine', last = 'Hudgens')
full_name(last = 'Hudgens', first = 'Kristine')
#order doesn't matter in python, this is more explicit. Rule of thumb
# is to use named arguments if you have more than three being called in the fu... |
14adf897de38f2d27bc32c8bc7d298b9f1ffbbed | ChrisStreadbeck/Python | /learning_notes/lambdas.py | 440 | 4.1875 | 4 | #Lambda is a tool used to wrap up a smaller function and pass it to other functions
full_name = lambda first, last: f'{first} {last}'
def greeting(name):
print(f'Hi there {name}')
greeting(full_name('kristine', 'hudgens'))
#so it's basically a short hand function (inline) and it allows the name to be called
# si... |
3ce71d04d48488071e8bbab36fae5b8efd986809 | ChrisStreadbeck/Python | /learning_notes/lists/lists_2.py | 734 | 4.0625 | 4 | tags = ['python', 'development', 'tutorials', 'code']
number_of_tags = len(tags) #remember 4 means index 0 to 3
last_item = tags[-1] #shows last value item in the list
index_of_last_item = tags.index(last_item) #gives index of last item when paired with the line before.
print(number_of_tags)
print(last_item)
print... |
7182f0c5e9e969fd8d9f3eb17e2a8946bfb3e224 | ChrisStreadbeck/Python | /apps/annoying_toddler_sim.py | 282 | 3.96875 | 4 | from random import choice
questions = ["Why was Prince Hans mean?", "Why Anna punch him?", "Why did Elsa run away?"]
question = choice(questions)
answer = input(question).strip().lower
while answer !="just because":
answer = input("but.. why? ").strip().lower()
print("Oh.. Okay") |
e0f419a4c740d58617078e0483afc3cabf69e4b9 | ChrisStreadbeck/Python | /learning_notes/if_elif_else.py | 190 | 4.1875 | 4 | num1 = 10
num2 = 5
if num1 > num2:
print("num1 is bigger than num2")
elif num1 == num2:
print("num1 is equal to num2")
elif num1 < num2:
print("num2 is bigger than num1")
|
9abb45d4fcf7d9f851bf4c92a3dc9354be857976 | bespokeeagle/Cousera-Python-re-up | /web-scrapper.py | 1,008 | 4 | 4 | #Scraping Numbers from HTML using BeautifulSoup In this assignment you will write a Python program similar to
#The program will use urllib to read the HTML from the data files below, and parse the data, extracting numbers and compute the sum of the numbers in the file.
# import statements to enable GET requests
impor... |
f91112d5f2d441cb357b52d77aa72c74d586fc73 | Shady-Data/05-Python-Programming | /studentCode/Recursion/recursive_lines.py | 928 | 4.53125 | 5 | '''
3. Recursive Lines
Write a recursive function that accepts an integer argument, n. The function should display
n lines of asterisks on the screen, with the first line showing 1 asterisk, the second line
showing 2 asterisks, up to the nth line which shows n asterisks.
'''
def main():
# Get an intger... |
dfc8a8902bff7cb34efefbf67ea932c241be6b7f | Shady-Data/05-Python-Programming | /studentCode/zip_func.py | 323 | 3.734375 | 4 | # zip() function
# This is a good way to take 2 different sequences of
# data and pair them together
# set up 2 lists
prices = [72.51, 9.27, 153.74, 30.23, 53.00]
names = ["CAT", 'GE', 'MSFT', 'AA', 'IBM']
# use for loop and zip() to pair lists together
for name, price in zip(names, prices):
print(name, '=', pric... |
44147daf5db0fb48d23759c14e23515af7edf827 | Shady-Data/05-Python-Programming | /studentCode/filter_func.py | 624 | 4.09375 | 4 | # filter()
# Takes in two arguments, function and an iterable
# Only returns items in the list that are True
def isPrime(x):
for n in range(2, x):
if x % n == 0:
return False
return True
filterObject = filter(isPrime, range(10))
print('Prime numbers between 1-10: ', list(filterObject))
# ... |
db773a98b8c70a91aab88dc6c38c30c73bdd87c6 | Shady-Data/05-Python-Programming | /studentCode/Trivia/pickle_trivia_ques.py | 960 | 3.546875 | 4 | import pickle
import csv
from random import randint
def main():
with open('Trivia_v2.csv', 'r') as csv_file:
csv_read = csv.reader(csv_file)
csv_list = []
for line in csv_read:
csv_list.append(line)
questions = []
answers = []
correct = []
for line in csv_list:... |
671db6f7df24c7f99178b538dc8cdfe44b33a7c2 | Shady-Data/05-Python-Programming | /studentCode/Recursion/forever_recursion.py | 249 | 3.640625 | 4 | # Endless recursion
def forever_recursion(times):
annoying_message(times)
def annoying_message(times):
if times > 0:
print('Nudge Nudge, Wink Wink, Say No More Say No More')
annoying_message(times -1)
forever_recursion(995) |
630e3b1afa907f03d601774fa4aec19c8ae1fbbb | Shady-Data/05-Python-Programming | /studentCode/cashregister.py | 1,718 | 4.3125 | 4 | '''
Demonstrate the CashRegister class in a program that allows the user to select several
items for purchase. When the user is ready to check out, the program should display a list
of all the items he or she has selected for purchase, as well as the total price.
'''
# import the cash register and retail item class mo... |
6849e93f6a59e6e69fe7346ae49974ba4729e240 | Shady-Data/05-Python-Programming | /studentCode/Trivia/triviagame.py | 5,044 | 4.34375 | 4 | '''
8. Trivia Game
In this programming exercise you will create a simple trivia game for two players. The program will
work like this:
• Starting with player 1, each player gets a turn at answering 5 trivia questions. (There
should be a total of 10 questions.) When a question is displayed, 4 po... |
443db5f0cfbc98abc074444ad8fccdf4a891491c | Shady-Data/05-Python-Programming | /studentCode/CellPhone.py | 2,681 | 4.53125 | 5 | """
Wireless Solutions, Inc. is a business that sells cell phones and wireless service.
You are a programmer in the company’s IT department, and your team is designing a program to manage
all of the cell phones that are in inventory. You have been asked to design a class that represents
a cell phone. The data that sh... |
915a6111d78d3bd0566d040f9342ddb59239c467 | Shady-Data/05-Python-Programming | /studentCode/Recursion/recursive_printing.py | 704 | 4.46875 | 4 | '''
1. Recursive Printing
Design a recursive function that accepts an integer argument, n, and prints the numbers 1
up through n.
'''
def main():
# Get an integer to print numbers up to
stop_num = int(input('At what number do you want this program to stop at: '))
# call the recursive print number a... |
5a229c15df2083e3cc76075b6b555611f041c57b | Shady-Data/05-Python-Programming | /studentCode/notes_master/tree_definitions.py | 3,517 | 3.734375 | 4 | '''
Binary Tree is a tree data structure in which each node has at most two children which are left child and right child
- top node is root
Complete binary tree - every level, except possibly the last, is completely filled and all nodes in the last level are as far left as possible
Full binary tree - A full bi... |
c4d39fadba7f479ce554198cd60c7ce4574c2d6b | Shady-Data/05-Python-Programming | /studentCode/Recursion/sum_of_numbers.py | 874 | 4.40625 | 4 | '''
6. Sum of Numbers
Design a function that accepts an integer argument and returns the sum of all the integers from 1 up
to the number passed as an argument. For example, if 50 is passed as an argument, the function will
return the sum of 1, 2, 3, 4, . . . 50. Use recursion to calculate the sum.
'''
de... |
a8d51535c905c2f78445f2cfb6c607d163a96330 | stufflebear/connect4 | /connect4.py | 1,541 | 3.578125 | 4 | import sys
from grid import Grid
class Connect4():
"""
Plays Terminal Connect 4
"""
def __init__(self):
self.grid = Grid()
self.lastMove = -1
def runGame(self):
p1sTurn = False
self.grid.printGrid()
self.nextMove(1)
while not self.grid.isWinningSt... |
2ab8916d18ca47e2ec254c41a45a6ddb2db7e55a | GoncaloFerreira00/Python-Algorithms | /CountVowels.py | 537 | 3.65625 | 4 | vogais = ['a','e', 'i', 'o', 'u']
frequencia = [0, 0, 0, 0, 0]
palavra = input("Digite uma palavra: ")
for i in palavra.lower():
if i in vogais:
indexVogais = vogais.index(i)
value = frequencia[indexVogais]
frequencia[indexVogais] = value + 1
print("ocorrências com a vogal A: ", frequencia... |
b9c6aa7aa70c2f28eae154e5d4a6c3d326822713 | sdvornikov/thermostat-master | /local_store.py | 2,306 | 3.609375 | 4 | import sqlite3
from sqlite3 import Error
sql_create_sensors_table = """ CREATE TABLE IF NOT EXISTS sensor (
id integer PRIMARY KEY,
name text NOT NULL
); """
sql_create_data_table = """ CREATE TABLE IF NOT EXISTS d... |
fd2dff6222f7014bd6bebded1968d787a395e4b6 | fouad20-meet/YL1-201819 | /lab7_8.py | 243 | 3.90625 | 4 | class Cake():
def __init__(self,flavor):
self.flavor = flavor
def eat(self):
print("Yummy!!! Eating a " + self.flavor + " cake :)")
cake = Cake("chocolate")
cake.eat()
# what I want to be printed: Yummy!!! Eating a chocolate cake :)
|
96387763eafc4c2ee210c866e43f30ebd9fbb6b5 | Vinod096/learn-python | /lesson_02/personal/chapter_4/14_pattern.py | 264 | 4.25 | 4 | #Write a program that uses nested loops to draw this pattern:
##
# #
# #
# #
# #
number = int(input("Enter a number : "))
for r in range (number):
print("#", end="",sep="")
for c in range (r):
print(" ", end="",sep="")
print("#",sep="")
|
d4420e85272e424bdf66086eda6912615d805096 | Vinod096/learn-python | /lesson_02/personal/chapter_3/09_wheel_color.py | 1,617 | 4.4375 | 4 | #On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are
#as follows:
#• Pocket 0 is green.
#• For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered
#pockets are black.
#• For pockets 11 through 18, the odd-numbered pockets are black and the even-numbered
#po... |
6411437fe4e73b46d8756a61d44f929a83c8dbf7 | Vinod096/learn-python | /lesson_02/personal/chapter_6/03_line_numbers.py | 386 | 4.34375 | 4 | #Write a program that asks the user for the name of a file. The program should display the
#contents of the file with each line preceded with a line number followed by a colon. The
#line numbering should start at 1.
count = 0
file = str(input("enter file name :"))
print("file name is :", file)
content = open(file, 'r'... |
b09e8d2cd18d517e904889ecf2809f1f1392e7eb | Vinod096/learn-python | /lesson_02/personal/chapter_4/12_population.py | 1,321 | 4.71875 | 5 | #Write a program that predicts the approximate size of a population of organisms. The
#application should use text boxes to allow the user to enter the starting number of organisms,
#the average daily population increase(as a percentage), and the number of days the
#organisms will be left to multiply. For example, assu... |
f5a8090ff67003d79e2f431256d4b277381c8dd7 | Vinod096/learn-python | /lesson_02/personal/chapter_3/01_Day.py | 757 | 4.40625 | 4 | #Write a program that asks the user for a number in the range of 1 through 7. The program
#should display the corresponding day of the week, where 1 = Monday, 2 = Tuesday,
#3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. The program should
#display an error message if the user enters a number tha... |
322e33e0feb4d816a5b812a1bf8d60be1559cc91 | Vinod096/learn-python | /lesson_02/personal/functions/food.py | 2,581 | 3.9375 | 4 | from secrets import choice
from tkinter.messagebox import YES
from sqlalchemy import true
from sympy import And
def customer():
user = str(input("What type of food you requried : "))
if user == 'burgers':
print("Food item is available")
else:
print("You've entered unavailable it... |
e0b176c877b9b553dbcee2b6124cfde4dd4c128c | Vinod096/learn-python | /lesson_02/personal/For_loop/scrimba.py | 220 | 4.15625 | 4 | names = ['Jane','John','Alena']
names_1 = ['John','Jane','Adeev']
text = 'Welcome to the party'
names.extend(names_1)
for name in range(1):
names.append(input("enter name :"))
for name in names:
print(name,text)
|
7feb19a5121eeb321f0b2a187852cae0becb4c4f | Vinod096/learn-python | /lesson_02/personal/chapter_2/ingredient.py | 1,022 | 4.40625 | 4 | total_no_of_cookies = 48
cups_of_sugar = 1.5
cups_of_butter = 1
cups_of_flour = 2.75
no_of_cookies_req = round(int(input("cookies required :")))
print("no of cookies required in roundup : {0:2f} ".format(no_of_cookies_req))
req_sugar = (no_of_cookies_req / total_no_of_cookies) * cups_of_sugar
print("no of cups of suga... |
3689740b0bc43992cf29f1ddcff04c88dbaf0705 | Vinod096/learn-python | /lesson_02/personal/chapter_2/stock.py | 2,466 | 3.90625 | 4 | #12. S tock Transaction Program
#Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the
#purchase:
#• The number of shares that Joe purchased was 2, 000.
#• When Joe purchased the stock, he paid $40.00 per share.
#• Joe paid his stockbroker a commission that amounted to 3 percent of the ... |
dd42d5e406efde3b62d76588eeb37a7470edafe8 | Vinod096/learn-python | /lesson_02/personal/chapter_8/01_initials.py | 463 | 4.5 | 4 | #Write a program that gets a string containing a person’s first, middle, and last names,and then display their first, middle, and last initials. For example, if the user enters John William Smith the program should display J. W. S.
first_name = str(input("Enter First Name : "))
middle_name = str(input("Enter Middle N... |
ad1f65388986962de297bba5f1219809634fccd3 | Vinod096/learn-python | /lesson_02/personal/chapter_4/09_ocean.py | 380 | 4.28125 | 4 | #Assuming the ocean’s level is currently rising at about 1.6 millimeters per year, create an
#application that displays the number of millimeters that the ocean will have risen each year
#for the next 25 years.
rising_oceans_levels_per_year = 1.6
years = 0
for i in range (1,26):
years = rising_oceans_levels_per_ye... |
da15e6e27a561aa3c7bb1f3d377f9b999482bbf7 | Vinod096/learn-python | /lesson_02/personal/chapter_2/temperature.py | 103 | 3.71875 | 4 | Celsius = float(input("enter the celsius : "))
far = 9 * ( Celsius / 5 ) + 32
print(Celsius)
print(far) |
80906ba30bc751f48e177907ab2967803c269022 | Vinod096/learn-python | /lesson_02/personal/chapter_5/12_Maximum_of_Two_Values.py | 867 | 4.625 | 5 | #Write a function named max that accepts two integer values as arguments and returns the
#value that is the greater of the two. For example, if 7 and 12 are passed as arguments to
#the function, the function should return 12. Use the function in a program that prompts the
#user to enter two integer values. The program ... |
83b9e523b3ff90d47c7689f3293b77a16d05a965 | Vinod096/learn-python | /lesson_02/personal/chapter_5/06_calories.py | 1,078 | 4.65625 | 5 | #A nutritionist who works for a fitness club helps members by evaluating their diets. As part
#of her evaluation, she asks members for the number of fat grams and carbohydrate grams
#that they consumed in a day. Then, she calculates the number of calories that result from
#the fat, using the following formula:
#calorie... |
0b4bd4faeb2a1fdc777b1d1dd799be3cd68d7ba9 | LDoubleZhi/PythonLearn | /eg.py | 744 | 3.53125 | 4 | # encoding:utf-8
def DemoString():
stra = 'hello world'
print stra.capitalize()
def Dict():
dicta = {'a': 1, 'b': 2}
print 1, dicta
print 2, dicta.keys(), dicta.values()
for key, value in dicta.items():
print key, value
class User:
type = 'USER'
def __init__(self, name, uid)... |
8557471f67dfdb15e878f6e00d948966c424d02e | harsha16208/Training | /sumofprimes.py | 529 | 3.5625 | 4 | from math import sqrt as s
for i in range(int(input())):
l,r=[int(x) for x in input().split(" ")]
def sumOfPrimes(l,r):
primes=['','']
for i in range(2,r+1):
primes.append(True)
for j in range(2,int(s(r))+1):
if primes[j]==True:
for k in r... |
76b1ab54ae7e0cf832236dcf6a3f49e9fbdb27b9 | RKramare/advent-of-code-2020 | /day2.py | 795 | 3.5625 | 4 | DAY_NUM = 2
def input():
f = open("input/day" + str(DAY_NUM) + ".txt")
inp = [l.rstrip('\n') for l in f]
f.close()
return inp
def checkPasswords(inp):
res1, res2 = 0, 0
for line in inp:
x = line.split(" ")
fir = int(x[0].split("-")[0])
sec = int(x[0].split("-")[1])
... |
b168f20cfbbe2df83a2152f9f35847a9e9507168 | jtibbertsma/python-sudoku | /sudoku/concrete.py | 3,344 | 3.703125 | 4 | """
Concrete sudoku solver classes which use various algorithms to solve sudoku
puzzles.
"""
from .errors import Catastrophic, NoNextMoveError
from .solver import (BasicSolver, Solver, Elimination, HiddenSingles,
NakedPairs, NakedTriples, NakedQuads,
HiddenPairs, HiddenTriples... |
11a462649f8ebd34f0d29ab619e6d36bc98160af | Moandh81/python-self-training | /tuple/9.py | 494 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to find the repeated items of a tuple.
mytuple = ("dog", "cat", "cow", "fox", "hen", "cock", "lion" , "zebra","duck" ,"bull", "sheep", "cat", "cow", "fox", "lion")
frequency = {}
for item in mytuple:
if item.lower() not in frequency:
... |
71998f2f85093291d6de0a61e49d012bbca4bdc0 | Moandh81/python-self-training | /datetime/30.py | 218 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to convert a date to the timestamp.
from datetime import datetime
now = datetime.now()
timestamp = datetime.timestamp(now)
print(timestamp) |
ac6d44000cce88e231a9a85d082c8538b44fd515 | Moandh81/python-self-training | /datetime/32.py | 272 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to calculate a number of days between two dates.
from datetime import date
t1 = date(year = 2018, month = 7, day = 12)
t2 = date(year = 2017, month = 12, day = 23)
t3 = t1 - t2
print("t3 =", t3)
|
fee021a37c322579ad36109a92c914eaf4a809b7 | Moandh81/python-self-training | /functions/1.py | 657 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*
# Write a Python function to find the Max of three numbers.
import re
expression = r'[0-9]+'
numberslist = []
number1 = number2 = number3 = ""
while re.search(expression, number1) is None:
number1 = input('Please input first number: \n')
while re.search(expressio... |
4a43f7f498cda12296b75247c5b6d45941519527 | Moandh81/python-self-training | /conditional-statements-and-loops/5.py | 268 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program that accepts a word from the user and reverse it.
word = input("Please input a word : \n")
newword = ""
i = len(word)
while i > 0:
newword = newword + word[i-1]
i = i - 1
print(newword) |
c78566301e0cc885f89c65310e9245fb5072dce1 | Moandh81/python-self-training | /dictionary/24.py | 517 | 4.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to create a dictionary from a string. Go to the editor
# Note: Track the count of the letters from the string.
# Sample string : 'w3resource'
# Expected output: {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1}
txt = input('Please... |
7897869a67893a3ea72027ae8911e80e9e1d8f6a | Moandh81/python-self-training | /datetime/7.py | 450 | 4.4375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to print yesterday, today, tomorrow
from datetime import datetime, date, time
today = datetime.today()
print("Today is " , today)
yesterday = today.timestamp() - 60*60*24
yesterday = date.fromtimestamp(yesterday)
print( "Yesterday is " ... |
cdf3abaafdf05f6cc6a164b72120b100c010fe28 | Moandh81/python-self-training | /sets/6.py | 256 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to create an intersection of sets.
set1 = {"apple", "banana", "cherry" , "strawberry"}
set2 = {"cherry", "ananas", "strawberry", "cocoa"}
set3 = set1.intersection(set2)
print(set3) |
f552ed71c41a45b8838d36ca289e6ded418370f5 | Moandh81/python-self-training | /tuple/12.py | 355 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to remove an item from a tuple.
mytuple = ("dog", "cat", "cow", "fox", "hen", "cock", "duck" ,"bull", "sheep")
myliste = []
txt = input("Please input a text : \n")
for element in mytuple:
if element != txt:
myliste.append(element)
myl... |
c05aca3c8637d78d9f31db8209ec7f3f1d6060cd | Moandh81/python-self-training | /functions/2.py | 360 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*
# Write a Python function to sum all the numbers in a list. Go to the editor
# Sample List : (8, 2, 3, 0, 7)
# Expected Output : 20
liste = [1,2,3,4,5]
def sumliste(liste):
sum = 0
for item in liste:
sum = sum + item
print("The sum of the numbers in the list ... |
601024dde5afc78a8e89a2065009fd376c1e04fb | eightys3v3n/matter_simulator | /test_vectors.py | 6,012 | 3.5 | 4 | import unittest
import utils
from space import Vector3f,Position3f,Position2f
class TestVector3f(unittest.TestCase):
def test___init__(self):
a = Vector3f()
self.assertEqual(a.origin,Position3f())
self.assertEqual(a.destination,Position3f())
with self.assertRaises(TypeError):
Vector3f(1)
... |
b8d9bdd2e06b0ed23b477c46e24bd320d9c54103 | eightys3v3n/matter_simulator | /test.py | 4,012 | 3.5 | 4 | import os
from sys import exit
from types import ModuleType
import test_files
"""
Contains a framework for automatically compiling and running tests
"""
class Test():
"""
Stores a refernece to the actual test function, and a list of tests that must be run before this one is
"""
def __init__(self,function,re... |
6ea91562526656fb3b566cfbdaaee74c1c1d4d88 | jmacarter/Python-Data | /chapter 8.py | 1,662 | 4 | 4 | for i in [5,4,3,2,1]:
print i
print "Blastoff!"
friends = ['Joseph','Jeremy','Jimmy Jackhammer','Tyrone', 'Jamal', 'Terrance']
for i in friends:
print i+' is a friend'
print range(len(friends))
for i in range(len(friends)):
friend = friends[i]
print friend+' is a good friend'
a = [1,2,3]
b = [4,5... |
d3557aa58cd0ffc9a317979cb632e71b01dbf3ca | aevalo/aev | /python_stuff/return_test.py | 199 | 3.71875 | 4 | def ret_3():
return 1, 2, 3
def main():
a, b, c = ret_3()
print("a = {0}, b = {1}, c = {2}".format(a, b, c))
print("a = %d, b = %d, c = %d" % (a, b, c))
if __name__ == "__main__":
main() |
2617a2ae708f1b4c24600a0bad94ecabf410cd2a | J-Krisz/project_Euler | /Problem 20 - Factorial digit sum.py | 356 | 3.59375 | 4 | # n! means n × (n − 1) × ... × 3 × 2 × 1
# For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
# Find the sum of the digits in the number 100!
# The page has been left unattended for too long and that link/button is no longer active. Pl... |
4870640a39e9da3773c603ccb30b877b56c6c693 | J-Krisz/project_Euler | /Problem 4 - Largest palindrome product.py | 462 | 4.125 | 4 | # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
def is_palindrome(n):
return str(n) == str(n)[::-1]
my_list = []
for n_1 in range(100, 1000):
for... |
0818f935f67ba43847d75076c4755343f79a8c34 | plazmonik/compare_model_tool | /iris_example.py | 867 | 3.515625 | 4 | # At first, let's try to use the application for a famous Iris dataset;
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from app import two_model_feature_importance_app
# The data is ... |
3b2c787354767c33e08fa2991820ead0ae30e56d | bertrandvidal/stuff | /alternating_characters/alternating.py | 388 | 3.625 | 4 | number_test_cases = int(input("Enter the number of test cases: "))
for idx in range(number_test_cases):
test_case = input("Test case #{} ".format(idx+1))
suppression = 0
for i, c in enumerate(test_case):
if i < 1:
continue
if c == test_case[i-1]:
suppression += 1
... |
7263d1e36de8add654306c2da70f1fcb79cb3110 | dgan11/Cracking_The_Coding_Interview_Python_Solutions | /Chp1_Arrays_and_Strings/1.5_One_Away.py | 3,309 | 4.15625 | 4 | """
There are three types of edits that can be performed on strings:
- insert a charachter
- remove a charachter
- replace a charachter
Given two strings, wrtie a function to check if they are one edit
(or zero) edits away
Ex:
pale, ple -> True // {'a':1}
pales, pale -> True // {'s':1}
pale, bale -> True // {'... |
f11e726a83933846f8ffc4e5d12f15bbb789145b | saadmk11/image_downloader | /image_downloader/downloader.py | 1,598 | 3.96875 | 4 | import os
import urllib.parse as urlparse
import urllib.request
def image_downloader(file):
"""
This Function Downloads all images from a Text File including urls.
Args:
file: the path of the text file.
On Execution:
Downloads the images from URLs provided on the text file
an... |
4aef5e6a7c9cc50af0ba2fa439f8ecf870b7d68f | uchicago-cs/debugging-guide | /examples/runtime/runtime-error.py | 332 | 3.609375 | 4 | #!/usr/bin/python3
import sys
def foo(a, b):
return a // b
def bar(a, b):
return foo(a, b)
if __name__ == "__main__":
if len(sys.argv) != 3:
print("USAGE: runtime-error.py NUM1 NUM2")
sys.exit(1)
a = int(sys.argv[1])
b = int(sys.argv[2])
x = bar(a, b)
print("a / b = {}... |
f3e31b5d7485467c5a8b08d95aefecd6d9cad5b3 | rohit04445/Creating-Engineering-Notation | /engineering.py | 4,887 | 4.09375 | 4 | def multiply(num, power_of_ten):
num = str(num)
if num.find('.') == -1:
num = num + '.'
point_index = num.find('.')
while len(num[point_index + 1:len(num)]) < power_of_ten:
num = num + '0'
point_index = num.find('.')
num = num.replace('.', '')
num = num[0:point_index + power_... |
2898083afcc9242417f89af4fd4de2786818d7f5 | djeikyb/learnpythonthehardway | /ex15a.py | 639 | 3.6875 | 4 | # allow us to take arguments for the script
from sys import argv
# unpack the first two argv array elements
script, filename = argv
# variable txt is now an open file
txt = open(filename)
# print the file name
print "Here's your file %r:" % filename
# read and print the open file that is txt
print txt.read()
# ask ... |
4f05572563bd615a85bccc3d225f28b8a4ae36b5 | djeikyb/learnpythonthehardway | /ex19a.py | 1,298 | 4.125 | 4 | # write a comment above each line explaining
# define a function. eats counters for cheese and cracker boxen
# shits print statements
def cheese_and_crackers(cheese_count, boxes_of_crackers):
# print var as decimal
print "You have %d cheeses!" % cheese_count
# print var as decimal
pr... |
47d3f9feac0d9304cbe51bc2eb87f25f56ca9e49 | k-sashank/Phone_Number_and_Email_Extractor | /Phone_Number_And_Email_Identifier.py | 1,296 | 3.765625 | 4 | #Import required Libraries
import pyperclip, re
#Regular Expressions to detect Phone Numbers and Email Addresses
phoneRegex = re.compile(r'''((\s|\+|\.)?(\d{2}|\(\d{2}\))?(\s|-|\.)?(\d{10}))''', re.VERBOSE)
emailRegex = re.compile(r'''([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,4}))''', re.VERBOSE)
#List to sto... |
40ebb96140e37fd9540dd5fda11c60a17cb3bfda | jithendra945/mountblue-dataproject-sqlalchemy | /generating_json.py | 6,787 | 3.53125 | 4 | """
Generating JSON data files to plot graphs on Browser
"""
# importing the required libraries
import csv
from collections import defaultdict
import json
from sqlalchemy import Column, Float, String, create_engine, desc
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
fro... |
5b3354f55435f6e34724c4a7a02b0180bb079e10 | Arvindvishwakarma/Multiplication-Table-Python | /multiplication table.py | 836 | 3.875 | 4 | from tkinter import *
def MulTable():
print("\n")
print("Table")
for x in range(1,11):
m = int(EnterTable.get())
print((x), 'once the', (m), '=', (x*m))
win = Tk()
win.geometry('200x200')
win.title('Multiplication Table')
EnterTable = StringVar()
label = Label(win, t... |
44142626c57508d50cf1977411479703657439fc | stjohn/csci127 | /errorsHex.py | 1,179 | 4.21875 | 4 | #CSci 127 Teaching Staff
#October 2017
#A program that converts hex numbers to decimal, but filled with errors...
Modified by: ADD YOUR NAME HERE
define convert(s):
""" Takes a hex string as input.
Returns decimal equivalent.
"""
total = 0
for c in s
total = total * 16
... |
9dfe3923af1ed8a1f91c44815d32590acab926f9 | canvasnote/hanabiAI | /test/TestDeck.py | 2,956 | 3.78125 | 4 | import unittest
from Deck import *
from Card import *
class TestDeck(unittest.TestCase):
def test_init(self):
# starter
assumeResult = \
"Y1 Y1 Y1 Y2 Y2 Y3 Y3 Y4 Y4 Y5 " + \
"G1 G1 G1 G2 G2 G3 G3 G4 G4 G5 " + \
"W1 W1 W1 W2 W2 W3 W3 W4 W4 W5 " + \
"R... |
f0a6897e5d202e1f445af2addcaf9f913bc4c480 | heraudk/Digicom | /test/test.py | 1,897 | 3.78125 | 4 | #a=5
#print (a)
#b=8.2
#print(a+b)
#a = (b+1)
#print(a)
#c = 1
#c = c + 3
#print(c)
#a, b = 4, 5.2
#print(a,b)
#c = a
#a = b
#b = c
#print(a,b)
#print(type(a))
#print(type(b))
#chaine = """Et voila, du texte"""
#print(chaine)
#var = 10
#print(type(var))
#var = str(var)
#print(type(var))
#var = float(var)
#print(... |
2a07a1991ddede46faa3ac411306644c137e0dcf | Tamby998/Test | /diviseur.py | 258 | 3.9375 | 4 | a = 0
b = 0
r = 0
print('Donner 2 entiers positif A et B')
print('A : ')
a = int(input())
print('B : ')
b = int(input())
r = a
while r > 0:
r = r - b
if r == 0:
print('A est Divisible par B')
else:
print('A n\'est pas divisible par B')
|
b82d34ef7d95c94244ab552d6fc6ed8ee5f70163 | danilocamus/curso-em-video-python | /aula16a - Fatiamento.py | 482 | 4 | 4 | '''Tuplas são imutáveis.'''
linguagens = ('Python', 'JavaScript', 'C#', 'PHP')
print(linguagens[1]) #mostra a tupla que esta no índice 1 nesse caso o JavaScript
print(linguagens[0][1]) #mostra a tupla de indice 0 e o caractere de índice 1 dessa tupla
print(linguagens[1:3])
print(linguagens[1:])
print(linguagens[-... |
1fd8f54834d80b0e0e56e54bc2e1e09d3aaac106 | danilocamus/curso-em-video-python | /aula 21/aula21d.py | 591 | 4.03125 | 4 | '''def somar(a=0, b=0, c=0):
s = a + b + c
print(f'A soma vale {s}')
somar(3, 2, 5)
somar(2, 2)
somar(7)
'''
def somar(a=0, b=0, c=0):
s = a + b + c
return s
r1 = somar(3, 4, 1)
r2 = somar(1, 9)
r3 = somar(2, 4)
print(f'{r1}, {r2}, {r3}')
print(somar(3, 2, 8))
def fatorial(num=1):... |
280ee2912d42ad706451ef7bea4647c6bafad1ba | danilocamus/curso-em-video-python | /aula 13/desafio 053.py | 548 | 3.921875 | 4 | frase = str(input('Digite uma frase: ')).strip().upper()
frase = frase.replace(" ", "")
''' ou
palavras = frase.split()
junto = ''.join()palavras
'''
inverso = ''
for letra in range(len(frase) - 1, -1, -1):
inverso += frase[letra]
print('O inverso de {} é {}'.format(frase, inverso))
if inverso == frase:
... |
1eaa7fdb7ff4bde5dfd7365e20c38112315e3fca | danilocamus/curso-em-video-python | /desafio 013.py | 160 | 3.71875 | 4 | sal = float(input('Digite o salário atual para aplicar o aumento: '))
aum = (sal * 115) / 100
print('O salário era R$ {} e agora é R$ {}'.format(sal, aum)) |
dccef04f9cecca3e75bede170891e9768801ced0 | danilocamus/curso-em-video-python | /desafio 024.py | 159 | 3.71875 | 4 | n = str(input('Digite o nome de sua cidade: '))
div = n.split()
print('A cidade é {}\nEla possui santo no nome?\n{}'.format(n, 'santo' in div[0].lower()))
|
c2a4be9846b6603c8e292cba0c915ab2853ea895 | danilocamus/curso-em-video-python | /aula 13/desafio 055.py | 455 | 3.8125 | 4 | peso = 0
maior = 0
menor = 0
qnt = int(input('Digite quantas pessoas você quer analisar: '))
for c in range(1, qnt + 1):
peso = int(input('Digite o peso da pessoa {}: '.format(c)))
if c == 1:
maior = peso
menor = peso
else:
if peso > maior:
maior = peso
... |
78f47980996c9081dd8d301daa92193f2156a20d | danilocamus/curso-em-video-python | /aula 15/desafio 068.py | 1,170 | 3.515625 | 4 | import random
ia = 0
tot = 0
vit = 0
while True:
n = int(input('Digite um valor: '))
pi = ' '
while pi not in 'PI':
pi = str(input('Par ou Ímpar? [P/I] ')).strip().upper()[0]
ia = random.randint(0, 10)
tot = (n + ia) % 2
if tot == 0:
if pi in 'P':
print(f... |
fe3389ffe3afc3c607418d461b8628cf8dfd50ee | danilocamus/curso-em-video-python | /aula 17/desafio 081.py | 487 | 3.875 | 4 | lista = []
cont = 0
while True:
sair = ' '
lista.append(int(input('Digite um valor para pôr na lista: ')))
cont += 1
while sair not in 'SsNn':
sair = str(input('Você deseja continuar? [S/N] '))
if sair in 'Nn':
break
print(f'Foram digitados {cont} números')
lista.sort(reve... |
9f47f94c531526d90ab4b3340852892d56e24f11 | danilocamus/curso-em-video-python | /aula 13/desafio 054.py | 426 | 3.703125 | 4 | from datetime import datetime
maior = 0
menor = 0
quant = int(input('Digite quantas pessoas você quer analisar: '))
data = datetime.now()
for c in range(1, quant + 1):
idade = int(input('Informe o ano de nascimento da pessoa {}: '.format(c)))
if (data.year - idade) < 18:
maior += 1
else:
... |
8dea88d32f690c94db0d91c77430c73137d0d5b8 | danilocamus/curso-em-video-python | /aula 15/desafio 071.py | 504 | 3.6875 | 4 | cedulas = 50
saque = int(input('Digite o valor a ser sacado: '))
totced = 0
total = saque
while True:
if total >= cedulas:
total -= cedulas
totced += 1
else:
if totced > 0:
print(f'total de {totced} cédulas de R$ {cedulas}')
if cedulas == 50:
c... |
e99f64f7a7c47001fda2b7493f136c528b0d2da2 | danilocamus/curso-em-video-python | /aula15b.py | 361 | 4 | 4 | nome = 'Amanda'
idade = 28
salario = 987.35
print(f'A {nome:10} tem {idade} anos e ganha R$ {salario}')
print(f'A {nome:^10} tem {idade} anos e ganha R$ {salario}')
print(f'A {nome:-^10} tem {idade} anos e ganha R$ {salario}')
print(f'A {nome:->10} tem {idade} anos e ganha R$ {salario}')
print(f'A {nome:-<10} ... |
7bb50d2132b47e415d67bd07dcdf4a82ce95fc16 | danilocamus/curso-em-video-python | /aula18a.py | 327 | 4.28125 | 4 | pessoas = [['Pedro', 25], ['Maria', 26], ['Jaqueline', 29]]
print(pessoas[1]) #mostra a lista de índice 1 que esta dentro da lista pessoas
print(pessoas[0][1]) #mostra o conteudo de índice 1 da lista de índice 0 que esta na lista pessoas
print(pessoas[0][0])
print(pessoas[1][1])
print(pessoas[2][0])
print(pessoas... |
7bfde9995154ed324c387c2c211583ee1e42cfe9 | cuihee/LearnPython | /Day01/c0108.py | 471 | 4.375 | 4 | """
字典的特点
字典的key和value是什么
新建一个字典
"""
# 字典
# 相对于列表,字典的key不仅仅是有序的下标
dict1 = {'one': "我的下标是 one", 2: "我的下标是 2"}
print(dict1['one']) # 输出键为 'one' 的值
print(dict1[2]) # 输出键为 2 的值
print('输出所有下标', type(dict1.keys()), dict1.keys())
# 另一种构建方式
dict2 = dict([(1, 2), ('2a', 3), ('3b', 'ff')])
print('第二种构建方式', dict2)
|
451ec9dda32cce125e3ff29be9592c2ff06e9b4f | cuihee/LearnPython | /Day04/c0401_iter.py | 561 | 3.78125 | 4 | l1 = [1, 2, 3, 4]
l1_iter = iter(l1)
print(next(l1_iter))
print(next(l1_iter))
print(next(l1_iter))
print(next(l1_iter))
l1_iter = iter(l1)
for _ in l1_iter:
print(_, end=" ")
print()
class MyNumbers:
def __iter__(self):
self.a = 10
return self
def __next__(self):
if self.a<=30:
x ... |
f1739857331375f4a48f609922e3b12caa103d48 | cuihee/LearnPython | /Day01/c0110.py | 2,182 | 3.953125 | 4 | # math
"""
在python中如何进行数学运算
"""
x, y = 2, 3
print('两个数比较的三个结果 -1 0 1:', (x > y) - (x < y))
'''
abs(x) 返回数字的绝对值,如abs(-10) 返回 10
ceil(x) 返回数字的上入整数,如math.ceil(4.1) 返回 5
exp(x) 返回e的x次幂(ex),如math.exp(1) 返回2.718281828459045
fabs(x) 返回数字的绝对值,如math.fabs(-10) 返回10.0
floor(x) 返回数字的下舍整数,如math.floor(4.9)返回 4
log(x) 如math.log(math... |
58300c6d8bcadcc21a62e52a29c69e80cc6dbfc3 | RamrajSegur/Computer-Vision-Python | /OpenCV-Python/imagemasking.py | 924 | 3.625 | 4 | import cv2
import numpy as np
img1=cv2.imread('/home/ramraj/Downloads/messi.jpg',0)#Image that is going to be on background
img=cv2.imread('/home/ramraj/Downloads/mainlogo.png',0)#Image that is going to be on foreground
rows,columns=img.shape
roi=img1[0:rows,0:columns]#Making the region on interest
ret,img_thres=cv2.t... |
59412e27906d5aa3a7f435bfb4ab63d9ee5ed5a2 | RamrajSegur/Computer-Vision-Python | /OpenCV-Python/line.py | 1,046 | 4.125 | 4 | #Program to print a line on an image using opencv tools
import numpy as np
import cv2
# Create a grayscale image or color background of desired intensity
img = np.ones((480,520,3),np.uint8) #Creating a 3D array
b,g,r=cv2.split(img)#Splitting the color channels
img=cv2.merge((10*b,150*g,10*r))#Merging the color channels... |
7df534569230d885c07c1b24f81c5d32361063ef | mozartkun/TakeHomeAssignment | /Charles&Keith/ZhaoYunkun_CharlesKeith_Question1.py | 14,869 | 3.515625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Question 1: Neo Saves World
# ### Python Version 3.5+
# In[ ]:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#Python version: 3.5+
from collections import defaultdict
import random
import string
import sys, os, time, datetime
from copy import deepcopy
# In[ ]:
# Define ... |
b4aa1339a99c1743c6c27102d987bfaf5ff52916 | gulcanfatih/python-kodlari | /7_if.py | 1,213 | 3.984375 | 4 | # if kullanarak hesap makinesi yapma işlemi
print("---MENÜ---")
print("1-toplama")
print("2-çıkarma")
print("3-bölme")
print("4-çarpma")
print(10 * "-")
secim = int(input("seçiminizi giriniz :"))
if secim == 1:
print("toplama")
sayi1 = int(input("1.sayıyı giriniz :"))
sayi2 = int(input("2.say... |
c4c484d4a0d445ce4324e4804e4ec3a609c6c97c | arya140101/Pemrograman-Jaringan- | /Python/kelilingdanluas.py | 277 | 3.6875 | 4 | panjang=eval(input("Masukkan panjang persegi panjang = "))
lebar=eval(input("Masukkan lebar persegi panjang = "))
luas=panjang * lebar
print("\nLuas Persegi Panjang adalah = %d"%(luas))
keliling=2*(panjang + lebar)
print("nkeliling Persegi Panjang adalah = %d"%(keliling)) |
5aa8cf71a6585c139789e83b13447e3f51de6fe3 | ScipioXaos/BUGZ | /engine/world/Location.py | 805 | 3.90625 | 4 | # BUGZ! - A Python 'Learning' Adventure coded in Python!
# File Description: Location.py is a wrapper class used to pair two integers
# together. These integers represent an X-Y coordinate
# pair and a "Location" in a Map instance.
# Class Description: Location is th... |
dac4fea633910137cc60dc5c73d8558886877f09 | dennisSaadeddin/pythonDataStructures | /manual_queue/Queue.py | 2,121 | 4.15625 | 4 | from manual_queue.QueueElem import MyQueueElement
class MyQueue:
def __init__(self):
self.head = None
self.tail = None
self.is_empty = True
def enqueue(self, elem):
tmp = MyQueueElement(elem)
if self.head is None:
self.head = tmp
if self.tail is not... |
ba1922c5b9c011d78ce7928c2c0de395f468e521 | saifulmz/learning-python | /one-code-per-day/2017-05-15-sensitive_words-replace.py | 1,980 | 4.09375 | 4 | # -*- coding: utf-8 -*-
'''
敏感词文本文件 filtered_words.txt,
里面的内容为以下内容("北京 程序员 公务员 领导 牛比 牛逼 你娘 你妈 love sex jiangge",
当用户输入敏感词语,则用 星号 * 替换,例如当用户输入「北京是个好城市」,则变成「**是个好城市」。
2017-05-15
Jing Qin
'''
import string
import sys
def sensitive_words(filtered_file):
# read file and save it as a sensitive_words list
with op... |
23d8c3236510bb3c7c8aceccea380067093deaa2 | PhathuAuti/intro-oop | /bank_account.py | 837 | 3.640625 | 4 | class BankAccount:
def __init__(self, bank_account_number, balance, int_rate, month_fee, customer):
self.bank_account_number = bank_account_number
self.balance = balance
self.int_rate = int_rate
self.month_fee = month_fee
self.customer = customer
def finish_month(sel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.