blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
6e97bbd63aa14a83909ebf785a9fc9aec6b28e00 | salazc2/CS-Intro-to-Python | /Salazar.project09.py | 5,485 | 4.25 | 4 | #Christopher Salazar
#CSC 110, project 9
# The program maintains a file of friends and his or her ages while handling exceptions
#that might occur
import os
def main():
#opening the files
numberOfFriends = open('FriendCount.txt', 'r')
ageOfFriends = open('FriendAgeData.txt', 'a')
numberOfFriends... |
df93fbcc33223e83a86b477f1bf94bc6f2b6b43b | markwanders/AdventOfCode2019 | /day10/asteroids.py | 1,641 | 3.625 | 4 | import math
with open("input.txt") as f:
lines = f.read().split()
def collinear(point1, point2, point3):
return point1[0] * (point2[1] - point3[1]) + \
point2[0] * (point3[1] - point1[1]) + \
point3[0] * (point1[1] - point2[1]) == 0
def between(point1, point2, point3):
return (poi... |
4b3cca04159c8f79badc04301ebf042cc292b7b8 | markwanders/AdventOfCode2019 | /day13/arcade.py | 3,942 | 3.5 | 4 | # coding=utf-8
with open("input.txt") as f:
ops = [int(i) for i in f.readline().split(",")]
def display(outputs, score):
lines = ""
for y in range(min(map(lambda k: k[1], outputs.keys())), max(map(lambda k: k[1], outputs.keys()))):
line = ""
for x in range(min(map(lambda k: k[0], outputs.... |
e4597e116b890cdd415ae71e28db871e12c31dec | ionblast25/css-225-homework | /problem_3_mod_7.py | 303 | 4.125 | 4 | #justine Rosado
#11/14/2020
#this problem make you type out A,B,or C and will end the command when you type out any of the three letters.
user_input = input("type out B ,A,or C")
while user_input != ("B")and user_input != ("A") and user_input != ("C"):
user_input = input("type out B, A, or C")
|
4a671258275895503123131eb0adba9c8abca4de | Celery-Qin/head_first_design_patterns_python | /01_rewrite_with_python/07_pizza_store_ingredient/pizza_store.py | 2,287 | 3.953125 | 4 | import pizza
class PizzaStore():
def choose_type(self):
pass
def create_pizza(self,ingredients_factory):
pizza_created = pizza.Pizza(ingredients_factory)
return pizza_created
def order_pizza(self,ingredients_factory):
pizza_ordered = self.create_pizza(ingredients_facto... |
fa638721f484f92fb7f2e1b87df7bc7cdc119516 | Celery-Qin/head_first_design_patterns_python | /01_rewrite_with_python/23_duck_flock.py | 4,062 | 3.84375 | 4 |
class Quackable():
def quack(self):
pass
class Flock(Quackable):
def __init__(self):
self.quackers = list()
# self.len = self.quackers.__len__()
self.current_position = 0
def __iter__(self):
return iter(self.quackers)
def __next__(self):
# Python3中只能使用__... |
d447109935a694bb98156f9ad4e2afaf04defbf4 | Celery-Qin/head_first_design_patterns_python | /01_rewrite_with_python/15_menu/iterator.py | 1,614 | 3.8125 | 4 | class Iterator():
def __init__(self):
self.items = list()
self.position = 0
def next(self):
pass
def has_next(self):
pass
class DinnerMenuIterator(Iterator):
def __init__(self, iterator):
Iterator.__init__(self)
self.items = iterator #... |
2bee8682f8d60796aad19ddf1aa60978593e3330 | Celery-Qin/head_first_design_patterns_python | /01_rewrite_with_python/15_menu/menu.py | 2,868 | 4.125 | 4 | '''
这里的是两家餐厅的原始设计,变更较小。
'''
import iterator
class MenuItem():
def __init__(self, name, description, vegetarian, price):
self.name = name
self.description = description
self.vegetarian = vegetarian
self.price = price
def get_name(self):
return self.name
def get_des... |
61728505be7f5412876fd896fd14147f68d2f487 | mrnucleation/TribalGA | /src/StringObject.py | 6,387 | 3.5 | 4 | from random import random, shuffle
from math import exp, fabs
#Binary String Object. By default the constraint applies to the number of 0s allowed
#Example Object = "01000100100001110000"
class StringObj(object):
#----------------------------------------------------
def __init__(self, initial=False):
... |
cfb476136a0234d8b88af0e2079da19a4cae7c6b | viveksahu26/chatbox | /server.py | 1,014 | 3.640625 | 4 | #socket programing is a combination of ip and port no.
import socket
import os
import threading
#import function
#Need to specify which protocol to use.
# $$ udp protocol
my_protocol = socket.SOCK_DGRAM
#Ip Address comes under Address Family. Similarly, many different types of address comes under it. It will help to ... |
ecbadf5440cd74c3ad7ceac9daf0c20171162728 | dillonko/python | /tutorial1.py | 4,072 | 3.984375 | 4 | #tutorial1.py
def tut():
print("Welcome to the tutorial, In this tutorial I will show you how broadcast and \nrecieve information from servers.")
cont = raw_input("")
print("First off we need to connect to a server.")
cont = raw_input("")
print("But we don't have a server module.")
cont = raw_input("")
... |
d45b32a54de66784c5052b455b778b0a66904896 | dillonko/python | /homepass.py | 664 | 3.734375 | 4 | def checkio(data):
checks = [data.isdigit, data.islower, data.isupper, len(data) > 10]
if all(checks) == True or False:
print True or False
return True or False
#
#Some hints
#Just check all conditions
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__mai... |
c9f73cf61f2911068f352c1610dbbaca7db46a77 | yadavprashant510/python | /Tutorial/Python tutorial/counter.py | 493 | 3.859375 | 4 | from collections import Counter
words = ["Ayodhya and directed the Centre to allot an alternative 5 acre plot\
to the Sunni Waqf Board for building a new mosque at a prominent place\
in the holy town in Uttar Pradesh"]
split_word = str(words).split()
print("Splitted Word :",split_word)
words_counts = C... |
d238575d74a9b3d7802a94691e407c62be543668 | mayank2424/first-python-mini-project | /test.py | 679 | 3.78125 | 4 | # def hello(name="mayank"):
# print "hello %s" % (name)
# hello()
# hello( "Amayank")
STATUS_MESSAGE=["Test1", "Test2" ,"TEST3", "test4", "test5"]
def add_status(Current_status_message):
choice= raw_input("Would you like to add new message (y/n) ??")
if choice == "y":
new_message= raw_input("what... |
407b6887a6d08d08626f6e1fb7d578aa267bc470 | conoroshea1996/A-Leetcode-A-Day | /twoSum/twoSum.py | 368 | 3.65625 | 4 | def two_sum(nums, target):
lenght = len(nums)
for i in range(lenght):
for j in range(lenght):
value = nums[i] + nums[j]
if value == target and i != j:
return print(' number ' + str(nums[i]) +
' number ' + str(nums[j]) + ' = ' + str(... |
4133370f223a9e59fd7d91c9bb8c0c9cc6debeb5 | thtitech/AOJ | /ALDS/9-2.py | 891 | 3.8125 | 4 | import sys
def get_left(i):
return 2 * i + 1
def get_right(i):
return 2 * i + 2
def get_parent(i):
return int((i - 1) / 2)
def make_heap_tree(array, i, item_num):
left = get_left(i)
right = get_right(i)
largest = i
if (left < item_num) and (array[left] > array[largest]):
largest ... |
74ec44d6bcafcc3ca2c1c8079eed6fbf649ecff4 | maxxsalov/python | /homework_5.py | 415 | 3.796875 | 4 | s = input("Введите строку: ")
def polindrom(str):
i = 0
j = len(str) - 1
palindrom = True
while i < j:
if s[i] != s[j]:
palindrom = False
i += 1
j -= 1
if palindrom == True:
print("Строка явялется палиндромом")
else:
print("Строка не является... |
2264f3c24b3cf3212433c2a8d7401115a43bbbd9 | maxxsalov/python | /homework_6_pi.py | 698 | 3.5625 | 4 | name_of_file = "pi_million_digits.txt"
print("Пришло время узнать, есть ли ваша дата рождения в трансцидентном числе PI")
pi_str = ''
with open(name_of_file) as file:
lines = file.readlines()
for line in lines:
pi_str += line.strip()
i = 0
birth = input("Введите дату вашего рождения?: ")
if birth i... |
ce228ecc3003e9e5dc0488b8ea863b719159975d | kent10636/Learn_Python | /filter.py | 1,173 | 4.09375 | 4 | # filter()接收一个函数和一个序列,用于过滤序列。和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素
def is_odd(n):
return n % 2 == 1
print(list(filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15]))) # 在一个list中,删掉偶数,只保留奇数
print()
def not_empty(s):
return s and s.strip()
print(list(filter(not_empty, ['A', '', 'B', None, 'C', ' ']... |
eca1d30301ae8304d60c904eb62ef5bf311aaae1 | kent10636/Learn_Python | /func.py | 1,427 | 4.0625 | 4 | print(abs(100))
print(abs(-20))
print(abs(12.34))
print()
max(1, 2)
max(2, 3, 1, -5)
print()
print(int('123'))
print(int(12.34))
print(float('12.34'))
print(str(1.23))
print(str(100))
print(bool(1))
print(bool(''))
print()
# 可以把函数名赋给一个变量,相当于给这个函数起了一个“别名”
a = abs
print(a(-1))
print()
# 定义一个函数要使用def语句,依次写出函数名、括号、括号中的... |
83b9dee002a4eabf9ad5aa0bec50febcb3c73bc1 | narender2999/Netflic-movie-suggetions | /movie-tv suggetion netflix.py | 24,290 | 3.78125 | 4 | print("welcome to Netflix movie suggetion program ")
in1 = input("are you watching with chldern? yes or no ")
in1 = str(in1)
if in1 == "yes":
in2 = str(input("do you have to watch with them? yes/y or no/n "))
if in2 == "yes":
in3 = str(input("feeling nostalgic? yes/y or no/n"))
if in3 == "yes":
... |
8dee0995ae3ec464dc202acd2dc74c95cf05508c | synara/estudospy | /conversor.py | 169 | 3.875 | 4 | tempFahreinheit = input("Digite uma temperatura em fahreinheit: ")
tempCelsius = (float(tempFahreinheit) - 32) * 5 / 9
print("A temperatura em celsius é", tempCelsius) |
4b29280735602b900573cadc7ea9d7df340be0db | synara/estudospy | /educado.py | 170 | 3.65625 | 4 | nomeDaMae = input("Qual o nome da sua mãe? ")
nomeDoPai = input("Qual o nome do seu pai? ")
print("Bom dia, senhora", nomeDaMae,"!!! E bom dia, senhor", nomeDoPai, ".") |
8f384388c4a31ee5eeb49c88930b79c539e3c4d3 | snulion-study/algorithm-adv | /jenny/sorting/[필수]H-index.py | 652 | 3.71875 | 4 | """
[정렬] 프로그래머스 H-index
정렬을 안썼는데 흠 ..
핵심:
1. 꼭 list에 있는 애가 h-index의 후보가 되는 것은 아님
2. 가장 적은 인용 개수가 전체 논문 수보다 클 때는 for loop 이 끝나, 그때는 자기 길이 반환
"""
def solution(citations):
for i in range(max(citations),min(citations)-1,-1):
if len([j for j in citations if j>=i]) >= i:
return i
# m... |
68685b3dca14bf22fa3e8d8812b6bbf19b0fdb70 | snulion-study/algorithm-adv | /jenny/sorting/[필수]단어정렬.py | 602 | 4 | 4 | """
[정렬] 백준 1181번
sort의 기준이 정해져 있을 때,
python 내장 함수의 sorted와
lambda로 sort 기준의 우선순위를 정해준다.
: sorted(iterable, key= lambda x: [기준])
내장함수 말고 직접 구현하는게 핵심인 것 같은데 난 귀찮으니 생략.
"""
def solution(word_list):
word_list = sorted(set(word_list), key=lambda x: [len(x), x])
for w in word_list:
print(w)
return ... |
2927d366a737df7c0dd905d1c08692ec86fb5557 | EMendy/Homework-6 | /Dataset ONE - Beer cans_Mendenhall.py | 10,768 | 4.09375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Homework 6, Part One: Lots and lots of questions about beer
# ### Do your importing and your setup
# In[1]:
import pandas as pd
# ## Read in the file `craftcans.csv`, and look at the first first rows
# In[2]:
df = pd.read_csv('craftcans.csv', na_values = ['Does not ap... |
7343f9554b204bdd48b30e3b80d03da93b4b9e96 | mattjegan/getting-started-with-python-testing | /main.py | 807 | 4 | 4 |
# Attempt 1
# def fibonacci(position):
# if position == 1 or position == 2:
# return 1
# return fibonacci(position - 2) + fibonacci(position - 1)
# Attempt 2
# def fibonacci(position):
# if position == 0 or position == 1:
# return 1
# return fibonacci(position - 2) + fibonacci(position... |
386baa073cab5246f85d0c66e013dec092615224 | katlegomfx/packed_code | /package/sorting.py | 1,544 | 4.15625 | 4 | def bubble_sort(items):
'''Return array of items, sorted in ascending order'''
sorted_items = items
for x in range(len(sorted_items)):
for y in range(len(sorted_items)-1-x):
if sorted_items[y] > sorted_items[y+1]:
sorted_items[y], sorted_items[y+1] = sorted_items[y+1] , s... |
7ffd5f027bb3b5cb9e07c0a81494c43dafeac5df | chasefridgen/Lab4 | /lab4-exercise4.py | 1,732 | 4.21875 | 4 | #!/usr/bin/env python3
import sqlite3
#some initial data
id = 4;
temperature = 0.0;
date = '2014-01-05';
#connect to database file
dbconnect = sqlite3.connect("my.db");
#If we want to access columns by name we need to set
#row_factory to sqlite3.Row class
dbconnect.row_factory = sqlite3.Row;
#now we create a cursor to ... |
550ad945fd3f6e891e85dc96783d5f5ee71cba8d | gmaru95/changwonai | /init_cats.py | 398 | 3.625 | 4 | class Cat():
def __init__(self, name, color = ' white'):
self.name = name
self.color = color
def meow(self, name = "나"):
print("My name is : {}, my color {}, MEOW~ 주인은 {}"\
.format(self.name, self.color,name))
nabi = Cat('나비','검은색')
nero = Cat('네로','흰색')
raon = Cat('라온',... |
a2643fc1166e189c3dd0b98dd89d4cf1560c1902 | Vindhesh/demopygit | /program_22.py | 274 | 3.953125 | 4 | # for x in range(1, 11):
# for y in range (1, 11):
# # print(x*y, end = ' ')
# print('{:8}' .format(x*y), end = '')
# print()
for i in range(1, 11):
for j in range(1, 11):
k = i * j
print('{:8}'.format(k), end = '')
print() |
ee7bc01f68ebaf811628d502e41c64f364875794 | Vindhesh/demopygit | /area_of_circle.py | 494 | 4.21875 | 4 | def circle():
from math import pi
value = input("Give me diameter (d) or radius (r): " )
if value == str('r'):
v1 = input("what is the radius of circle?: ")
r1 = float(v1)
area = round(pi*(r1)**2)
print(f"area of circle is:{area} sq. units")
elif value == str('d'):
... |
2b10c51fb461c04708af43b820e3a7367ff410ec | Vindhesh/demopygit | /nested_loops.py | 506 | 4.375 | 4 | # Given an integer,n, perform the following conditional actions:
# If n is odd, print Weird
# If n is even and in the inclusive range of 2 to 5, print Not Weird
# If n is even and in the inclusive range of 6 to 20, print Weird
# If n is even and greater than 20, print Not Weird
n = input("Enter your number: ")
n = in... |
960eecc2375e2ddbd862ce270aaba62c6116c0f6 | Vindhesh/demopygit | /multipleinheritence.py | 3,526 | 3.96875 | 4 | from abc import ABCMeta, abstractmethod
from random import randint
class Account(metaclass = ABCMeta):
@abstractmethod
def createAccount():
return 0
@abstractmethod
def authenticate():
return 0
@abstractmethod
def withdraw():
return 0
@abstractmethod
def deposit(... |
15e28fe7948a45a6e43920bbb3183624840ea4eb | Vindhesh/demopygit | /temp.py | 427 | 3.671875 | 4 | first_name=input(f'Enter your first name: ')
last_name = input(f'Enter your last name: ')
mobile = input(f'Enter your mobile number: ')
email_id = input(f'Enter your email id: ')
import xlsxwriter
workbook = xlsxwriter.Workbook('temp.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', first_name)
works... |
4b691047f135aeed97047f3435d8197d328550ea | Vindhesh/demopygit | /func.py | 698 | 4.03125 | 4 | # def sum(a, b):
# c = a + b
# return c
# x = sum(3, 4)
# print("x is", x)
# y = sum(5, 7)
# print("y is ", y)
# def odd_even(num):
# if num % 2 == 0:
# print(num, "is even")
# else:
# print(num, "is odd")
# odd_even(12)
# odd_even(13)
# def fact(n):
# prod = 1
# while n>=1:... |
e2018a37d3423b89b64f51aeefe46eb156489554 | sumit6b/Introduction-to-interactive-programming-using-python- | /guessthenumber.py | 2,440 | 4.25 | 4 | # template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import simplegui
import random
import math
# initialize global variables used in your code
num_range = 100
num_of_guesses = 7
random_num = 50
game_num = 1
# helper ... |
ae5292de4a66f54668bf8e2dc215d98a3136db32 | ToSuperGod/Passion | /classGroup.py | 1,561 | 3.921875 | 4 | # 组合:在一个类中以另外一个列的对象作为数据属性(一个类的属性是另一个类的对象)
class Equip:
def fire(self):
print("Fire")
class Riven:
camp='Noxus'
def __init__(self,name):
self.name = name
self.equip = Equip() # 用Equip类产生一个装备,赋值给equip属性
r1 = Riven('公孙离')
r1.equip.fire()
# 继承:建立派生类与基类之间的关系,是一种‘是’的关系
# 组合:建立类与组合之间的关系,是... |
8441d0a856f941aa05d04ba24576265e0a8c6479 | ToSuperGod/Passion | /判断二叉树是否相等.py | 1,105 | 3.8125 | 4 | class bTree(object):
def __init__(self):
self.data = None
self.left = None
self.right = None
def is_equal(root1, root2):
if root1 is None and root2 is None:
return True
if root2 is None and root1 is not None:
return False
if root1 is None and root2 is not None:
... |
1381dd7db0617a795ea5f7f54b905d56ce69aa08 | CarlosHL/ml_projects | /Project1/cleaningData.py | 932 | 3.6875 | 4 |
class CleanData:
def __init__(self, file_name):
self.file_name = file_name
def clean_data(self):
"""Cleans the data and writes it in a new file"""
# data: POPULATION | PROFIT
print "> Cleaning data"
# open file
file_content = open(self.file_name).readlines()
... |
ff89f9ad8beb040f133f5a4ad4c8e4ea2f1a6c3d | AlexHerry/python | /traveltime.py | 412 | 3.8125 | 4 | # -*-coding:gb2312 -*-
print "ʱھٶȣʱ"
speed = 80.0 #ٶ
journey = 200.0 #ó̵ľ
time = journey / speed
print "Ҫѣ",time,"Сʱʱ"
# չ
"""
speed = float(input("ٶ:\n"))
journey = float(input("ó̵ľ\n"))
time = journey / speed
print "Ҫѣ",time,"Сʱʱ"
""" |
5ddeedc1e165992df85dc77de1580e5ecd834263 | aislan-leite/EstruturaDeDados | /recursao.py | 1,229 | 3.984375 | 4 | # Faça uma função recursiva que calcule e retorne o fatorial de um número inteiro N.
def calcularFatorial(n):
if n == 0 or n == 1:
return 1
else:
return calcularFatorial(n - 1) * n
# Faça uma função recursiva que calcule e retorne o N-ésimo termo da sequência Fibonacci.
def calcularFibo(n): #... |
61bbe19459485e87fe341c2a5cb00170f2ec0e2a | Iris104/TICT-V1PROG-15-Iris | /Les 08/Final Assingnment.py | 2,026 | 3.8125 | 4 | def inlezen_beginstation(stations):
while True:
beginstation = input('Welk station is uw beginstation? ')
if beginstation in stations:
return beginstation
break
else:
print('Uw station bevindt zich niet in het traject Schagen-Maastricht.')
def inlezen_ei... |
6720806e768a76eb3763424a5e8470195ed5cdce | shinaisorensen/udemypython | /Final Projects/Numbers/Coin Flip Simulation/Main.py | 3,925 | 4.375 | 4 | # -*- coding: utf-8 -*-
"""
@author: Shinai Sorensen
@date: October 27, 2020
This is a coin flip simulator that asks the user how many times they want to flip a coin.
Records the number of tails and heads and prints out the results.
"""
import random
# Flip the coin
def flip(x):
count = 0 # coun... |
fe197091262d6663707ba10cd673d3aada7eea60 | erniehs-zz/pythonasyncio | /multi_thread.py | 372 | 3.515625 | 4 | import time
from threading import Thread
THREADS = 4
COUNT = 50000000
def countdown(n):
while n > 0:
n -= 1
threads = [Thread(target=countdown, args=(COUNT // THREADS,))
for _ in range(THREADS)]
start = time.time()
for t in threads:
t.start()
for t in threads:
t.join()
end = time.ti... |
7131eb85b87012d295cebedb941297b5100c6a56 | cisco7507/100daysofcode-with-python-course | /days/04-06-collections/bite30/movies_directors.py | 3,240 | 4.25 | 4 | '''
from: https://codechalleng.es/bites/30/#console
In this Bite we are going to parse a csv movie dataset to identify the directors with the highest rated movies.
Write get_movies_by_director: use csv.DictReader to convert movie_metadata.csv into a (default)dict of lists of Movie namedtuples. Convert/filter the data:... |
1ed1f39b3308992d6023ceef10ac7ffb3900649b | angsgdo/lesson1 | /info.py | 248 | 3.84375 | 4 | user_info = {'first_name': '', 'last_name': ''}
first_name = input('Введите ваше имя: ')
last_name = input('Введите вашу фамилию: ')
user_info = {'first_name': first_name, 'last_name': last_name}
print(user_info)
|
ca5a977d4bbdd4a826053150af601d3c18758f6e | sabareesh123/number.py | /same string.py | 82 | 3.640625 | 4 | n=input("")
s=n.split(" ")
if(s==(s[0::])):
print("yes")
else:
print("no")
|
7b7de5a298482e724634dc911a7cb1973b92f482 | sabareesh123/number.py | /lower upper.py | 55 | 3.75 | 4 | a='abcD'
lo=a.lower()
up=a.upper()
print(a.swapcase())
|
ecc86db92c1ed34b0cafcc014e6afc1f4ac60d98 | sabareesh123/number.py | /space count.py | 119 | 3.765625 | 4 | string='laptop is good'
space=0
for i in string:
if(i==' '):
space=space+1
print(space)
|
0284d55a0e37e26a4125a6a8917161b2eb57b88c | paperleander/ikt440 | /assignment_2/tsetlin_machine.py | 7,158 | 3.6875 | 4 | import numpy as np
import random
class Automaton:
def __init__(self, n_states):
self.n_states = n_states
self.state = np.random.randint(2 * n_states)
def evaluate(self):
return self.state >= self.n_states
def reward(self):
"""
Reward each automaton by pushing the ... |
3ecf16412b64d7f39bff9606a992cf49541ef7f6 | Anupaul24/pythonclasses | /src/fabnoci.py | 1,920 | 3.984375 | 4 | """
num = int(input("enter the integer value"))
a = 0
b = 1
if num<1:
print("Invalid number")
else:
print("Fabnoci series of ",num,"is" )
print(a)
print(b)
for i in range(2,num):
c = a + b
a = b
b = c
print(c)
"""
"""
num = int(input("enter the num... |
d272d84c28ce232f06423c6079bfc1977de80c9b | eichelb4rt/SAT-LAB | /global_libs/read_dimacs.py | 2,743 | 3.71875 | 4 | #!/bin/python3
# SHEBANG
import argparse
from typing import List
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
metavar = 'input',
dest = 'input',
type = str,
help = 'Input file where DIMACS notation of a formular is stored.'
)
args = parser.parse_a... |
658af17d1a9641bf67ddf03ecadb7c20bedc370c | ravicse114/ImportantAlgorithm | /SORTING/1_Quick_Sort/Quick_sort.py | 774 | 3.609375 | 4 | #=======================================================#
# AUTHOR :- RAVI SHANKAR KUMAR #
# FROM :- SITAMARHI(BIHAR) , 843317 #
# NIT JALANDHAR, CSE PRE-FINAL YEAR #
#=======================================================#
def part (arr,start,last):
pivot=arr[s... |
f971309d265490fa6d9c0a744291c9ac252ede8e | SamirDjaafer/Python-Basics | /Excercises/Excercise_104.py | 835 | 4.21875 | 4 | import random
# Magic number game!
# I want you to use operators
# equate something
# As a user, I want to be able to guess a number and know if i got it correct or not, so that I can know if I won or not.
# We should define/assign number to a variable called magic_number. We have imported 'random' and assigning a ra... |
a63d7a83fd8ac09f2b13a462fadd1a93a63cde03 | SamirDjaafer/Python-Basics | /eng_57.py | 597 | 3.96875 | 4 | print('Hello World')
favorite_team = 'rockets'
favorite_player = 'harden'
favorite = favorite_team + ' ' + favorite_player
print(favorite)
first_name = input()
print(first_name)
print('What is your first name?')
first_name = input()
print('Ok, now what is your last name?')
last_name = input()
print('Fascinating.... |
857d05f6ebe4465d801f743dcc3c16e3f0012c4f | ssiddam0/Python | /Lab5/lab5-8_Sowjanya.py | 2,169 | 4.5 | 4 | # program - lab5-8_sowjanya.py 19 April 2019
'''
This program uses the modular design approach to calculate the total cost of the paint job
and labor charges given the square feet of wall space to be painted.
1) main() method is used to get the data from the user and call the remaining functions
2) calculate_... |
cc03649d1b32d17c635a354f39f18a44596b7724 | Renato-Camapum/Bill-roulette | /main.py | 314 | 3.796875 | 4 | # This is a bill roulette, it will choose randomly a person to pay the bill.
names_string = input("Give me everybody's names, separated by a comma. ")
names = names_string.split(", ")
import random
x = len(names)
picked = random.randint(0, x)
print(f"The person to pay the bill today is {names[picked]}")
|
606c18119f52c8910493c44d49c061c2eb4b643f | SynedraAcus/phylome | /one-shots/read_segfiltered.py | 842 | 3.609375 | 4 | #! /usr/bin/env python3
from Bio import SeqIO
from argparse import ArgumentParser
parser = ArgumentParser(description='Filter FASTA file by the percentage of X and lowercase letters')
parser.add_argument('-f', type=str, help='FASTA file')
parser.add_argument('-n', type=float, help='Max acceptable proportion of X and ... |
f7edf9e2a7c68f3b7dfc7fdbe8ff7b7595db8678 | nemui/ascii_rooms | /debug.py | 210 | 3.5625 | 4 | from game import Game
choice = ' '
while choice != "q":
game = Game()
game.step()
snapshot = game.ascii_snapshot()
print(snapshot)
print(f'{len(snapshot)} characters')
choice = input()
|
bf6265f444e1e36e9c12632b6e349a7ecfd6a269 | JackStruthers/CP1404_Practicals | /CP1404_Practicals/week_02/count_letters.py | 221 | 4.03125 | 4 | def letter_counter():
user_string = "Please"
number_of_letters = 0
for char in user_string:
if char.isalpha():
number_of_letters += 1
return number_of_letters
print(letter_counter())
|
c68c3fdaf6ee3b5a2802ace563680459e439ca18 | JackStruthers/CP1404_Practicals | /CP1404_Practicals/week_02/secret_number.py | 280 | 3.875 | 4 | import random
SECRET_NUMBER = random.randint(1, 10)
user_number = int(input("Please guess a number between 1 and 10: "))
while user_number != SECRET_NUMBER:
user_number = int(input("wrong answer, please try again: "))
print("You got it, the answer was", str(SECRET_NUMBER))
|
cb4ef565754f5c6d67bcb3eca180380df1222522 | JackStruthers/CP1404_Practicals | /CP1404_Practicals/week_02/password_checker_v2.py | 1,911 | 4.46875 | 4 | """
CP1404/CP5632 - Practical
Password checker "skeleton" code to help you get started
"""
MIN_LENGTH = 2
MAX_LENGTH = 6
SPECIAL_CHARS_REQUIRED = True
SPECIAL_CHARACTERS = "!@#$%^&*()_-=+`~,./'[]<>?{}|\\"
def main():
"""Program to get and check a user's password."""
print("Please enter a valid password")
... |
4244505a110ab4984ba422f92815d25e6b34871f | Angiey1/PyClock | /pyClock.py | 4,397 | 3.5 | 4 | from tkinter import *
from tkinter import ttk # contiene el separador
import time
import locale
locale.setlocale(locale.LC_ALL, 'es') # hace que el nombre del mes aparezca en español
# declaración de variables globales para usarlas en la función cronometro()
horas = 0
minutos = 0
segundos = 0
s = 0
m = 0
h = 0
cont... |
0b530bb1c27182fc7a3c36b42495a44c142a0b82 | briancruz453/CSP_Final | /Ethan Oliver/Commented_Code.py | 1,242 | 3.796875 | 4 | import random
import time
#These are the available responces, obviously, they are not finished and the letters are placeholders.
response=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","Q","R","S","T","U"]
def Input():
raw_input("Whats on your mind: ") #This is the prompt to start the asking process
... |
7f47a0736fa2019cb9b7066a05d94f3d9454e409 | sanxofon/basicnlp3 | /simpleRegexUTF8.py | 4,950 | 4.03125 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Este script muestra como realizar búsquedas y reemplazos
de cadenas de texto mediante Expresiones Regulares (REGEX)
utilizando caracteres Unicode.
>> python simpleRegexUTF8.py
"""
# La librería "re" nos permite realizar expresiones regulares en Python
import re
# ... |
6897f12f0971ce778feaad398e19d4bf9d9c1776 | sanxofon/basicnlp3 | /mediumRegexUTF8.py | 4,373 | 3.859375 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
# Importamos la librería de expresiones regulares (re)
import re
# Definimos la cadena sobre la que vamos a trabajar
# Usamos triples comillas para entrecomillar un texto con saltos de línea, tabs, etc.
cadena = u"""—¡Joven «emponzoñado» con el whisky, qué fin… te... |
27dbe26a68017be8a4fa187c11771a75d175df30 | hugo-labixiaoxin/cs61a-self-edition | /lecture/code23.py | 1,447 | 3.546875 | 4 | class Students:
def __init__(self,number,teacher,school,cla,course):
self.number=number
self.teacher=teacher
self.school=school
self.cla=cla
self.course=course
def __str__(self):
return 'number:{0},teacher:{1},school:{2},cla:{3},course:{4}'.format(self.number,self... |
ae416950fbb866e291a58de2d4571eca575025d7 | hugo-labixiaoxin/cs61a-self-edition | /lecture/code3.py | 270 | 3.765625 | 4 | def identity(k):
return k
def cube(k):
return pow(k,3)
def summation(n,term):
total,k=0,1
while k<=n:
total,k=total+term(k),k+1
return total
def sum_naturals(n):
return summation(n,identity)
def sum_cubes(n):
return summation(n,cube)
|
c03fc62f3be5bcd22ee0730ad460cd21a4ed186b | rahulraghu94/daily-coding-problems | /8.py | 703 | 3.984375 | 4 |
"""
Good morning! Here's your coding interview problem for today.
This problem was asked by Google.
A unival tree (which stands for "universal value") is a tree where all nodes
under it have the same value.
Given the root to a binary tree, count the number of unival subtrees.
For example, the following tree has 5 ... |
6304cd1f0858c2344a54a364f66879d3bce6be08 | rahulraghu94/daily-coding-problems | /27.py | 1,632 | 4.15625 | 4 | """
Good morning! Here's your coding interview problem for today.
This problem was asked by Facebook.
Given a string of round, curly, and square open and closing brackets,
return whether the brackets are balanced (well-formed).
For example, given the string "([])[]({})", you should return true.
Given the string "([... |
524b8dae4f012d74902d7a6dd2dabc1eba9b04ba | piksel/advent_of_code_2016 | /plilja-python3/day9/day9.py | 890 | 3.609375 | 4 | import re
from collections import namedtuple
Marker = namedtuple('Marker', 'chars repeat')
marker_re = re.compile('\(\d+x\d+\)')
def parse_marker(marker_text):
without_parens = marker_text[1:-1]
[chars, repeat] = list(map(int, without_parens.split('x')))
return Marker(chars, repeat)
def step1(s):
... |
12acdeca14bebeed0ab160ac0f059aa3d54823d0 | piksel/advent_of_code_2016 | /masssssy-python27/16/day16.py | 525 | 3.765625 | 4 | def main():
input = "00111101111101000"
length = 35651584
str = input
while len(str) < length:
str = str + "0" + str[::-1].replace('1', '2').replace('0', '1').replace('2', '0')
str = str[0:length]
checksum = str
while len(checksum) % 2 == 0:
checksum = check(checksum)
print checksum
print len(checksum)
... |
3c139b224643d6d9cb674aca7ab336c9d55ae1dc | piksel/advent_of_code_2016 | /hbldh-python2and3/13.py | 2,882 | 3.640625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Advent of Code, Day 13
======================
Author: hbldh <henrik.blidh@nedomkull.com>
"""
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from collections import namedtuple
try:
from queue import Pr... |
b93eecf5d2400f14e8de2927e50c919edebe871e | piksel/advent_of_code_2016 | /hbldh-python2and3/01.py | 1,063 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Advent of Code, Day 1
=====================
Author: hbldh <henrik.blidh@nedomkull.com>
"""
from operator import add
with open('input_01.txt', 'r') as f:
data = f.read().strip().split(', ')
turn_funcs = {
'R': lambda d: (d[1], -d[0]),
'L': lambda d: (-d[... |
c339d281ffd4ce266bbb94834a59c448153072f5 | piksel/advent_of_code_2016 | /mrinlumino-python/09.py | 3,549 | 3.5 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
print ''
print '***************************************************************************************'
print '* *'
print '* Advent of code 2016 9/12 ... |
382c1a1180a91bef7a125cc637a1f7c8bb2777b1 | makoalex/Python_course | /Sql/inserting_Python_not_recommended.py | 779 | 4.40625 | 4 | import sqlite3
# creating connection
connection = sqlite3.connect("chocolate.db")
c = connection.cursor()
# we can insert into Python using the sql method, which is a bit redundant
"""insert = "INSERT INTO chocolates values ('Lindor', 'Switzerland,EU'," \
" 'Lindt& Sprungli');
# we execute the new code
c.exe... |
a830f5583004a879903c4c28029a29f8cb146371 | makoalex/Python_course | /Sql/insert_Python_recommended.py | 578 | 4.21875 | 4 | import sqlite3
connection = sqlite3.connect("chocolate.db")
c = connection.cursor()
# we know we have data coming in but we don't know what it will contain
# for demonstration purposes we will use a variable and added to the database
data = ('Cadbury', 'Uk, Australia, New Zealand', 'Cadbury')
# the way to add to the d... |
60ae648a8a21e2cd3d932d3138e8e7f879f848f8 | makoalex/Python_course | /Sql/Selecting with Python.py | 1,312 | 4.25 | 4 | # until no we didn't get anything back when we committed into the database
# if we want to get a result back we can either iterate, or converting the data into an array or list
import sqlite3
connection = sqlite3.connect('director.db')
c = connection.cursor()
# c. execute("CREATE TABLE directors (first_name TEXT, last_... |
1ab1f8b66dc2681dbc34168b7303d22bf0800745 | makoalex/Python_course | /RockiePappieScissors.py | 1,636 | 4.03125 | 4 |
from random import choice
player_wins=0
computer_wins=0
while True:
print("WELCOME TO THE GAME")
print("Please enter your name player")
user = input().strip().lower()
print('Score:{}:{} vs computer {} '.format(user, player_wins,computer_wins))
print("Pick your poison: Rock, Paper, or Scissor... |
387903da61e817fa30c99ceb5520fc5fc5e01128 | makoalex/Python_course | /file_IO/file_exercices.py | 1,542 | 3.96875 | 4 | # # function that takes in 2 params and copies the contents of the first into the second
def copy(file_name, new_file_name):
with open(file_name) as file:
data = file.read()
with open(new_file_name, 'a') as new_file:
new_file.write(data)
print(copy('haiku.txt', 'text'))
# #function that that... |
3eda1fc388b47e0f908730fb6a454261acae78b9 | makoalex/Python_course | /green_quiz/game body.py | 612 | 3.625 | 4 | from random import choice
from csv import reader
# class Question:
# def __init__(self, question):
# self.question = question
#
# def __repr__(self):
# return "Green is a versatile word: it can be a noun, adjective, or verb;\n" \
# " we earn greenbacks to buy greens in the market... |
c64cfb3e29f2008119932686f828d8a29448e111 | makoalex/Python_course | /DeckCards.py | 1,550 | 3.890625 | 4 | from random import shuffle
class Card:
def __init__(self, value, suit):
self.suit = suit
self.value = value
def __repr__(self):
return '{} of {}'.format(self.value, self.suit)
class Deck:
def __init__(self):
self.cards = []
suit = ['Hearts', 'Clubs', 'Diamonds', ... |
28471f7deb36e0dd9068fbfe94706545174f644b | sankar-mukherjee/CoFee | /laurent/cluster.py | 9,983 | 3.515625 | 4 |
#Different sklearn clustering analysis techniques and plotting and dimension reduction. dataprep.py must be run before.
X_train, y_train = get_clusterdata(data,REAL_POS_FEAT+REAL_ACO_FEAT,'simple',WORKING_DIR + 'cluster_classifier.png')
#full features
#X_train, y_train = get_clusterdata(data,REAL_POS_FEAT+REAL_ACO... |
3442b9835823718d28ccca7558de6cadbe0ba55a | WeikangChen/algorithm | /lintcode/35_reverse-linked-list/reverse-linked-list.py | 782 | 3.8125 | 4 | # coding:utf-8
'''
@Copyright:LintCode
@Author: chenweikang
@Problem: http://www.lintcode.com/problem/reverse-linked-list
@Language: Python
@Datetime: 16-07-02 23:27
'''
"""
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = nex... |
0ba7d5f0dd8fe4ff2715d173694d0a1ffea0a223 | WeikangChen/algorithm | /lintcode/141_sqrtx/sqrtx.py | 465 | 3.625 | 4 | # coding:utf-8
'''
@Copyright:LintCode
@Author: chenweikang
@Problem: http://www.lintcode.com/problem/sqrtx
@Language: Python
@Datetime: 16-04-27 03:39
'''
class Solution:
"""
@param x: An integer
@return: The sqrt of x
"""
def sqrt(self, x):
if x < 0:
return -1
... |
9f4fb8d7ef3ca7e67ca9f70b060571536c611b5c | WeikangChen/algorithm | /lintcode/53_reverse-words-in-a-string/reverse-words-in-a-string.py | 347 | 3.5625 | 4 | # coding:utf-8
'''
@Copyright:LintCode
@Author: chenweikang
@Problem: http://www.lintcode.com/problem/reverse-words-in-a-string
@Language: Python
@Datetime: 16-04-25 01:12
'''
class Solution:
# @param s : A string
# @return : A string
def reverseWords(self, s):
list = s.split()
retu... |
8941070bbe1aa465885779a7a02d03dd6127a182 | puzzismael/Proyect2Quality | /Estado.py | 294 | 3.53125 | 4 | class Estado:
def __init__(self, localizacion, objetivos, lat, lon):
self.localizacion = localizacion
self.objetivos = objetivos
self.lat=lat
self.lon=lon
def __str__(self):
return( "(" +str(self.localizacion) + "," + str(self.objetivos) + ")")
|
97f4af5e401440a42d6cbb386a3ee5fd3a9c51c1 | Kuznetsova814/-1 | /Солнце.py | 1,212 | 3.90625 | 4 | print("Здравствуйте, сейчас вы узнаете немного информации обо мне.") #Приветствие
myName = 'Кузнецова Ульяна,' #Моё имя
myAge = '16,' #Мой возраст
WhereILive = 'Чудово,' #Место жительсва
iStudy = 'Новгородский строительный колледж(НСК)' #Место учёбы
mySpecialty = 'Информационные системы по отраслям(ИСО)' #Моя спец... |
d727fbe63e0996b1538fdb08c5aaffb1447b2324 | FlowsyCurls/2021_ANPI_Tarea1 | /Parte 2/metodos_p2.py | 7,325 | 4.1875 | 4 | """
Implementación del método de Newton-Raphson
"""
from math import *
from sympy import *
import numpy as np
from matplotlib import pyplot as plt
"""
Pregunta 2, Parte 1
"""
"""
Función para calcular derivadas usando las librerias de sympy y numpy
"""
#----Primera Derivada-----#
def derivate(func, z):
x = Symbo... |
76b13ff1eeb4c219aa877869549b334a830e784a | mihpir/praktika_mmad | /03_pract/run.py | 468 | 3.515625 | 4 | import numpy as np
import matplotlib.pyplot as plt
from k_means import kmeans
# исходные данные
X = np.array([
[4, 4],
[3, 3],
[5, 3],
[2, 3],
[5, 5],
[3, 2],
[2, 4],
[4, 5],
[5, 4],
[2, 2]])
# запуск кластеризации
ans = kmeans(2, X)
# отображение результатов
print(ans)
plt.... |
18012b782aee42fd7f659c654a6667a774e67f86 | HelderIury/Uri-Online-Judge | /Beginner/Python/1008.py | 203 | 3.609375 | 4 | number = int(input())
horas = int(input())
horas_trabalhadas = float(input())
salario = float(horas*horas_trabalhadas)
print('NUMBER = {}'.format(number))
print('SALARY = U$ {:.2F}'.format(salario))
|
764a925466f69e0b4b82b21c012d42756487e8cc | j-python-programming/python-programming | /src/03-paddle.py | 2,069 | 4.125 | 4 | # Python によるプログラミング:第 3 章
# 例題 3.2 上下にパドルを動かす
# --------------------------
# プログラム名: 03-paddle.py
from tkinter import *
from dataclasses import dataclass
import time
# 初期状態の設定
DURATION = 0.01 # 描画間隔(秒)
PADDLE_X0 = 750 # パドルの初期位置(x)
PADDLE_Y0 = 200 # パドルの初期位置(y)
PAD_VY = 2 # パドルの速度
@dataclass
clas... |
0b69ee93d81d493efe1b2c26d3e7d94e2c75f10e | j-python-programming/python-programming | /src/13-click-signal.py | 1,383 | 3.890625 | 4 | # Python によるプログラミング:第 13 章
# 例題 13.2 マウスイベントの取得
# --------------------------
# プログラム名: 13-click-signal.py
import pygame
S_RED, S_GREEN, S_YELLOW = (0, 1, 2)
COLOR_LIST = [(255, 0, 0), (0, 255, 0), (255, 255, 0)]
def handles_mouseup(event):
global signal # 関数外で宣言されたsignalを使う
print("pressed")... |
c975c17460f3af28d7dc292086ceaf7249de42e0 | j-python-programming/python-programming | /src/12-collision.py | 2,009 | 3.65625 | 4 | # Python によるプログラミング:第 12 章
# 例題 12.6 衝突処理
# --------------------------
# プログラム名: 12-collision.py
import pygame
FPS = 60 # Frame per Second 毎秒のフレーム数
LOOP = True
# ボールの描画関数
def draw_ball(screen, x, y, radius=10):
return pygame.draw.circle(screen, (255, 255, 0), (x, y), radius)
# パドルの描画関数
def dr... |
cab5bf0a165a989b46d72ea07b501325c06dc557 | j-python-programming/python-programming | /src/p10cell.py | 3,024 | 3.671875 | 4 | # Python によるプログラミング:第 10 章
# 実習課題 10.1 Cell ファイルの分割
# --------------------------
# プログラム名: p10cell.py
from tkinter import Tk, Canvas, CENTER
from dataclasses import dataclass, field
@dataclass
class Cell:
canvas: Canvas
width: int
height: int
cell_size: int
offset_x: int
offset_y: int
fon... |
12ec67fa356c898be962689dca7aefe61eb2b13a | j-python-programming/python-programming | /src/ex02-4-epidemic.py | 4,054 | 3.609375 | 4 | # Python によるプログラミング:第 2 章
# 発展問題 2.4 ウイルス感染のシミュレーション
# --------------------------
# プログラム名: ex02-4-epidemic.py
from tkinter import *
from dataclasses import dataclass
import time
import random # この課題では、「乱数」を使用する。
# パラメータの初期化
NUM_PERSONS = 10 # 人の数を規定する
DURATION = 0.01
NORMAL_COLOR = "black"
EPI_C... |
9c5e26a40041a0cb41a897598e04695d2aee634b | j-python-programming/python-programming | /src/01-draw-3.py | 972 | 4.25 | 4 | # Python によるプログラミング:第 1 章
# 例題 1-4 (3) y = x * x のプロット
# --------------------------
# プログラム名: 01-draw-3.py
from tkinter import *
import math
OX = 400 # (OX, OY)がキャンバス上での原点の位置
OY = 500
MAX_X = 800 # 座標軸の最大 ( キャンバス座標)
MAX_Y = 600
SCALE_X = 80 # キャンバス座標への変換係数
SCALE_Y = 80
START = -5.0
END = 5.0
DELTA = 0.01
def... |
a90330357c9e3bf79691e8cae756adc37765a9ed | j-python-programming/python-programming | /src/06-ex0-card.py | 283 | 3.890625 | 4 | from dataclasses import dataclass
@dataclass
class Card:
suit: str
rank: int
def print(self):
print("{} の {}".format(self.suit, self.rank))
cards = [
Card("spade", 1),
Card("spade", 2),
Card("spade", 3)
]
for card in cards:
card.print()
|
00551b82c6299436f737aeacf5953548eca6e697 | j-python-programming/python-programming | /src/ex01-car-1.py | 571 | 4.03125 | 4 | # Pythonによるプログラミング:第1章
# 練習問題 1-1 (1)
# --------------------------
# プログラム名: ex01-car-1.py
from tkinter import *
tk=Tk()
canvas = Canvas(tk, width=500, height=400, bd=0)
canvas.pack()
# 車体部分を描画する
canvas.create_rectangle(0, 0, 400, 200,
outline="black", fill="blue")
# 左のタイヤ
canvas.create_ov... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.