blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
802cb5d0b00883c6768ce49e91e2c20e857d2171 | FIWARE-GEs/quantum-leap | /src/utils/thread.py | 2,208 | 3.953125 | 4 | from abc import ABC, abstractmethod
from threading import Event, Thread
class BackgroundRepeater(ABC, Thread):
"""
Run an action in a background thread at regular intervals.
Subclasses implement the ``_do_run`` method to actually run the action
which this thread calls every ``s`` seconds where ``s`` i... |
4fb0065b847d49f75c51926a94b1198da5cef0ed | Hayden-CHENPRO/Python_studyingpku | /others/用户登录程序.py | 1,359 | 4 | 4 | def enterprogram():
print("""
|--- 新建用户:N/n ---|
|--- 登录账号:E/e ---|
|--- 退出程序:Q/q ---|
""")
code = input("|--- 请输入指令代码:")
datebase = {'小甲鱼':'FishC'}
k = 1;i = 1
if code == 'N' or code == 'n' :
admin = input("请输入用户名:")
while k :
if admin in datebase:
... |
c4c646d4321014631236961bf2c57fb52944de46 | CRUCIFIER0/Steganography | /au1decryption.py | 1,134 | 3.625 | 4 | # Use wave package (native to Python) for reading the received audio file
import wave
song1=''
def call():
s=3
return(decrypt(decode(),s))
def decode():
song = wave.open(song1, mode='rb')
# Convert audio to byte array
frame_bytes = bytearray(list(song.readframes(song.getnframes())))
... |
9cfd2ab413096514e8d0a244c98571d639b4dccc | RichardRivaldo/AI_CG | /Simple-ANN/src/ann.py | 11,792 | 3.8125 | 4 | # Libraries
import pandas as pd
import numpy as np
class ArtificialNeuralNetwork:
# Constructor of the ANN
def __init__(self, dataset):
# The full dataset, splitted features and target of the training dataset
self.dataset = self.read_dataset(dataset)
self.features = self.get_features()... |
8539a64a5d31d1797f7d10eb60dc45fb1b725dac | carlchipperfield/log-service | /main/functional/ni/rest/rest_client.py | 2,200 | 3.609375 | 4 | import httplib2
import json
class RestClient:
''' A JSON based REST client.
'''
def __init__(self, host="127.0.0.1"):
self.conn = httplib2.Http()
self.conn.force_exception_to_status_code = True
self.system_url = "http://" + host
def get(self, uri):
''' Retrieve the r... |
198b084357f22be5bdef930f71c0157bbae93f01 | Harrison8939/Python | /customer_one.py | 1,148 | 3.84375 | 4 | #Variables that are assigned values of strings and integers respectively
lovely_loveseat_description = "Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white."
lovely_loveseat_price = 254.00
stylish_settee_description = "Stylish Settee. Faux leather on birch. ... |
01b54c275050b60329243fd51796ddeab5c250b1 | Harrison8939/Python | /Odd or Even.py | 708 | 4.3125 | 4 | #stores a value in the variables num, check, which the user inputs
num = int(input("Give me a number to check: "))
check = int(input("Give me a number to divide by: "))
#if statements that test if the number is a multiple of 4
if num % 4 == 0:
print(num, "Is a multiple of 4")
#if not, test if its an even number
... |
6edf6705a932e966da053d114a1ce8b2b51f04cd | jamespeace/algo | /chap2/bin.py | 611 | 4.25 | 4 | def Binsearch(A, value):
"""
Binary Search
A: an increasing sorted array.
size: size of array.
value: the value which need to be find.
>>> s = [5, 13]
>>> Binsearch(s, 5)
0
>>> Binsearch(s, 13)
1
>>> Binsearch(s, 18)
"""
#
# bounds for the both side and the ... |
cf165d093d172fb49bfa45c4ba90d274f1a26318 | Combatd/intro_cs_programming_python_6001 | /unit1/for.py | 148 | 3.9375 | 4 | # prints 2
# prints 4
# prints 6
# prints 8
# prints 10
# prints Goodbye!
num = 0
for i in range(5):
num += 2
print(num)
print('Goodbye!')
|
2c68c90cca04410ae6bb9dea794bf35aede2f94c | shannilmohaan/python-fundamentals | /ch04/.ipynb_checkpoints/roll_die-checkpoint.py | 790 | 3.828125 | 4 | #roll_die.py
""" Roll a six sied die 6,000,000 times """
import random
#face frequency counters
face_1 = 0
face_2 = 0
face_3 = 0
face_4 = 0
face_5 = 0
face_6 = 0
#roll the die 6,000,000 times and count the occurences of each face.
for i in range(6_000_000): # used the _ here to make the number more readable.
face... |
c1e27304ca2a15f2f0bb217947474607c638e213 | KnIfER/landscapes | /docs/scrap/z_preorder_traversal.py | 3,022 | 3.71875 | 4 |
from collections import deque
class Node:
def __init__(self, node=None):
self.parent = node
self.children = []
self.value = None
def linear_tree(levels):
root = Node()
root.value = (0,'>')
stack = [root]
while len(stack):
node = stack.pop()
... |
466aa4c094e28dae73b6ddb3d36ad9f07e271781 | coconumberzzz/linuxgit | /0719.py | 3,932 | 3.9375 | 4 | #집합
s1=set([1,2,3])
l1=list(s1) #리스트로 변환
print(l1)
print(l1[0])
t1=tuple(s1) #튜플로 변환
print(t1)
print(t1[0])
s1=set([1,2,3,4,5,6])
s2=set([4,5,6,7,8,9])
s1&s2 #교집합
s1|s2 #합집합
s1-s2 #차집합
s1=set([1,2,3])
s1.add(4) #1개 추가
s1.update(5,6,7) #여러개 추가
s1.remove(7) #삭제
# 튜플 >> (소괄호),
... |
41b1cbc588329be41d722c5b7a0297cb0b61dbe8 | Griffin-Brome/Dr-Notadoctor-MD | /python/Testing.py | 464 | 3.671875 | 4 | import nltk
from nltk.corpus import wordnet
from nltk.corpus import stopwords
from nltk.stem import *
stop_words = (stopwords.words('english'))
sentence = "I have a really bad stomach ache"
sentence = sentence.lower()
sentence = sentence.split()
cleansentence = ""
print("have" in stop_words)
for word in sentence:
... |
1655592c9357c135d330b425c74733159798f3e7 | HabibullahMetin/bilgisayargormesi | /pythonGiris/kod06/program.py | 1,574 | 3.96875 | 4 | import sys
#diziler
# python da diziler köşeli parantezler ile tanımlanır
sayilar = [1,2,3,4,5,6]
print("sayilar = "+str(sayilar))
#dizinin ikinci elemanına erişmek için index kullanmak yeterlidiri
print("sayilar[2] = "+str(sayilar[2]))
#bir dizinin elemanlarını kullanarak yeni bir dizi oluşturabilirsiniz
#örneğin... |
828e80e7d7844c5070e0800a76420c2bffa20987 | shubhi1907/Python-exercise | /ps1a.py | 741 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
annual_salary = float(input("Enter your annual salary: "))
portion_saved = float(input("Enter the percentage of your salary you plan on saving monthly: "))
total_cost = float(input("Enter the price of your dream house: "))
count = 1
curre... |
f93cf812b60feaf9d289764657017effe65ad370 | SUMUKHA-PK/Vehicle-Routing-Problem | /TSP/tsp.py | 4,945 | 3.734375 | 4 | from collections import defaultdict
import time
start = time.time()
def addEdge(city,u,v,weight):
city[u].append(v)
cost[u].append(weight)
def generateEdges(city):
edges = []
for node in city:
for neighbour in city[node]:
edges.append((node,neighbour))
return edges
... |
e15c7e5737a960fd7656552e9aed0d6c29620f78 | ahmedfadhil/PyTip | /disjoint_set.py | 967 | 4.4375 | 4 | # A Simple python 3 program to check
# if two sets are disjoint
# Returns true if set1[] and set2[] are disjoint, else false
def areDisjoint(set1, set2, m, n):
# Take every element of set1[] and search it in set2
for i in range(0, m):
for j in range(0, n):
if set1[i] == set2[j]:
... |
ba4a776a19ffb338794dad582a1cdcc2ab82212f | ahmedfadhil/PyTip | /set_subset.py | 594 | 4.0625 | 4 | def main():
# List of string
list1 = ['Hi', 'hello', 'at', 'this', 'there', 'from']
# List of string
list2 = ['there', 'hello', 'Hi']
'''
check if list1 contains all elements in list2
'''
result = all(elements in list1 for elements in list2)
result2 = any(elements i... |
2bd5f47d49bdbc014b8e2fcf51b1231eb85bdeea | CrazyStoneJy/PythonStudy | /functional_programming/sorted.py | 657 | 3.8125 | 4 | #!/usr/bin/python3
# -*- encoding: utf-8 -*-
from operator import itemgetter
ll = sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower)
print(ll)
ll2 = sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower,reverse = True)
print(ll2)
students = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]
def by_name... |
1a2f9c21b458d9027f8c32db7c8f114c14ddda43 | NelinVitaliy/Chapter_3__Task_3 | /Task_3.py | 1,237 | 4.15625 | 4 | # data_user = list(input("Enter you string: "))
# shift = int(input("How many to shift the string: "))
# for x in data_user:
# # получаем значение ASCII
# a = int(ord(x))
# b = a-shift
# # декодируем символ обратно через функцию chr
# print(str(chr(b)), end='')
def select_method():
while True:... |
518c6ae3ad42b6c3dbdeba1bf0b5bcf6c8ef73e3 | almamuncsit/HackerRank | /Python/02 Basic Data Types/Lists.py | 594 | 3.734375 | 4 | if __name__ == '__main__':
N = int(input())
my_list = []
for i in range(0, N):
input_str = input()
l = input_str.split()
if l[0] == 'insert':
my_list.insert(int(l[1]), int(l[2]))
elif l[0] == 'print':
print(my_list)
elif l[0] == 'remove':
... |
7e2449977a7db7c2fcdb07706355e3ce002d9325 | almamuncsit/HackerRank | /Python/04 set/Symmetric Difference.py | 346 | 3.5 | 4 | if __name__ == '__main__':
m = int( input() )
m_set = set( input().split() )
n = int( input() )
n_set = set( input().split() )
data_list = list(m_set.difference(n_set)) + list(n_set.difference(m_set));
data_list = list( map(int, data_list) )
data_list.sort(reverse=False)
for item in range(0, len(data_list)):
... |
3abc85ed99bebafc28b4411c411f37f500bba225 | almamuncsit/HackerRank | /Data Structures/04 Trie/01-contacts.py | 1,515 | 3.59375 | 4 | #!/bin/python3
import os
import sys
from collections import defaultdict
class TrieNode:
def __init__(self):
self.children = defaultdict()
self.terminating = False
self.counter = 1
class Trie:
def __init__(self):
self.root = TrieNode()
# Insert word into trie
def in... |
c2da294d250f124729b85e96d1f4bd6bf8b475be | almamuncsit/HackerRank | /Python/03 String/14-Merge-the-Tools.py | 343 | 3.640625 | 4 |
def merge_the_tools(string, k):
for i in range(0, len(string), k):
unique_list = []
str_list = list(string[i:i+k])
for c in str_list:
if c not in unique_list:
unique_list.append(c)
print("".join(unique_list))
if __name__ == '__main__':
string, k = input(), int( input() )
merge_... |
b0f2a84d832962e491c2220d3019cf016e1f58ea | xi-xi/takeover_document | /vol4/src/class_sample.py | 257 | 3.625 | 4 | class Car:
def __init__(self):
self.x = 0.0
self.y = 0.0
def main():
car1 = Car()
car2 = Car()
car1.x, car1.y = 1.0, 1.0
car2.x, car2.y = 5.0, 5.0
print(car1)
print(car2)
if __name__ == '__main__':
main()
|
b0bf9cf7f93ac93b96f9a47f40c9e7c673c8ff17 | Mitchell-Chatterjee/CSI-4142-TermProject | /dataStaging/pop_crime.py | 7,110 | 3.5625 | 4 | from multiprocessing import Pool
from csv import writer, QUOTE_MINIMAL
import datetime
import pandas
""" Handles the population of the Crime table
Global Variables:
GLOB_DENV_DATA: Contains the denver data
GLOB_VAN_DATA: Contains the vancouver data
Categories:
traffic-accident
homicide
mischief
... |
b709372006e294368114f73c8dca716858036923 | maxroyatx/Data-Structures | /heap/heap.py | 965 | 3.59375 | 4 | class Heap:
def __init__(self):
self.storage = [0]
self.size = 0
def insert(self, value):
self.storage.append(value)
self.size += 1
self._bubble_up(self.size)
def delete(self):
item = self.storage[1]
self.storage[1] = self.storage[self.size]
self.size -= 1
self.storage.pop()
... |
8e3ef272444e01b86d9e1f25eb68bcdbd66474c9 | poplarli/learn-python | /samples/simple.py | 3,917 | 4.03125 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
print("123");
print('''
hahah
llll
aaa
''')
print(1>0);
classmates=['xiaoming','xiaowang', 123];
print(classmates[0])
print(classmates[-1])
classmates.pop(1)
print(classmates[1])
teachers=('dazhang', 'daniu');
print(teachers)
t=(1,)
print(t[0])
#age = input("enter a n... |
db6207805079b92b1fc7ee00d56043d6d2455bc3 | PhurpaSherpa16/Python2.0 | /PythonProjets/forLoop.py | 212 | 3.84375 | 4 | import math
x = int(input("Enter Number:"))
for i in range(x):
if i%5!=0:
print(i)
for j in range(30,x+1,+1):
print(j)
for k in range(x,50):
x = math.sqrt(k)
if k%x==0:
print(k)
|
97c5d83078e7ac7712a7b5af9118c78f5e20dbce | PhurpaSherpa16/Python2.0 | /OOP/InnerCalss.py | 965 | 3.78125 | 4 | #inncer calss
class student:
def __init__(self,name,roll):
self.name = name
self.roll = roll
def show(self):
print("Name is ",self.name," and roll is ",self.roll,".")
class ComputerDetails:
def __init__(self,brand,processor,RAM):
self.brand = brand
... |
581e26dca32ffa41ef8e42009360a0b2f9fe2f79 | PhurpaSherpa16/Python2.0 | /OOP/inheritance.py | 725 | 3.796875 | 4 | class GrandParents:
def name1(self):
print("GrandParents is Kami")
def cast1(self):
print("Cast is Sherpa")
class Fathername:
def name2(self):
print("Father is Kami")
def cast2(self):
print("Cast is Sherpa")
def location(self):
print("Living in Dhading")
cla... |
e40fabb458e04244b5d76a79ce5abac7e5b9052f | PhurpaSherpa16/Python2.0 | /PythonProjets/test.py | 209 | 3.875 | 4 | a = int(input("Enter Numbers : "))
i = 1
while i<=a:
if i%3!=0 or i%5!=0:
print(i)
i+=1
j = 1
while j<=a:
z = j
while z<=a:
print(z,end=" ")
z+=1
j+=1
print()
|
8b9c40255352af4ee829c3fc221f425ddb3fd1f5 | PhurpaSherpa16/Python2.0 | /OOP/ExceptionHandaling.py | 579 | 3.859375 | 4 | try:
a = int(input("Enter Number: ")) #to catch eror statement should be written in try block
b = int(input("Enter Number: "))
print("resource open")
print(a/b)
except ZeroDivisionError as e: #handle only zero divission error
print("You cannot divide by zero")
print(e) #message given by machine
... |
4400a38569c7bad498e45d1e90cd003f2aed11cd | PhurpaSherpa16/Python2.0 | /PythonProjets/userInput.py | 156 | 3.609375 | 4 | #a = input('Enter any character you want : ')
#print(a[0])
a = input("Enter any alphabet : ")[0]
print(a)
result = eval(input("Problems : "))
print(result) |
616a7f160600949722d837ccfc0c53d216d995c1 | raghavgr/clrs | /ch15_dynamic_programming/coin_change.py | 2,685 | 4.34375 | 4 | """
Use dynamic approach to solve coin change problem.
Given the change required, and the available coin
denominations, return the least number of coins required
to give the change.
Ex:
Change = 63
Coin Denominations available = 1, 5, 10, 25
Sol: 25 + 25 + 10 + 1 + 1 + 1
Greedy approach used above. If coin denominati... |
589a43811883a28f1cf1bc53c510b895a76e563f | Raj-Sanjay-Shah/Hindi-English-Translation | /Python - Stemmer/main.py | 1,661 | 3.640625 | 4 | # main.py / Stemmer
# Gourav Siddhad
# 07-04-2018
import stemmer
from tkinter import *
def perform_operation():
object = stemmer.Stemmer()
object.stem_init(e1.get())
e2.delete(0, END)
e3.delete(0, END)
try:
object.hstem()
e2.insert(0, object.rem)
e3.insert(0, object.outpu... |
517581edc06f115afd41d3a94cce0598bcdc9737 | s0m35h1t/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 704 | 4.15625 | 4 | #!/usr/bin/python3
"""
This is the "4-print_square.py" module.
The 0-add_integer module functions: say_my_name(first_name, last_name="").
"""
def print_square(size):
"""
print_square: prints a square with the character #.
Args:
size (int): the size length of the square
Returns:
None
... |
0c54c1954bd6bf3866219351abfce72021244927 | s0m35h1t/holbertonschool-higher_level_programming | /0x0B-python-input_output/13-student.py | 1,453 | 3.953125 | 4 | #!/usr/bin/python3
"""
Define: Strudent Class
"""
class Student:
"""Represents a Rectangle
Attributes:
first_name (str): student first name
last_name (str): student last name
age (int): student age
"""
def __init__(self, first_name, last_name, age):
"""Initializes a r... |
d8d3c4dc2d5e93d7528982628ef6a5185004e9bd | s0m35h1t/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/rectangle.py | 4,800 | 3.625 | 4 | #!/usr/bin/python3
"""Define: Rectangle Class"""
from models.base import Base
class Rectangle(Base):
"""Representation of Rectangle"""
def __init__(self, width, height, x=0, y=0, id=None):
"""Initialization a Rectangle
Args:
width (int): Rectangle width
height (int):... |
d8669932172477d5a9732b017f1d01679413dc13 | s0m35h1t/holbertonschool-higher_level_programming | /0x0A-python-inheritance/1-my_list.py | 434 | 3.875 | 4 | #!/usr/bin/python3
"""Defines: class MyList"""
class MyList(list):
"""Represents a MyList
Attributes:
None
"""
def __init__(self):
"""Initializes a List
Args:
None
Returns: None
"""
super().__init__
def print_sorted(self):
""... |
4ea67327e551d472d9e045eff9d54967181db61e | vishalbelsare/matrixabm | /src/matrixabm/agent.py | 3,355 | 3.734375 | 4 | """Agent and Agent Population interface."""
from abc import ABC, abstractmethod
from . import asys
class Agent(ABC):
"""Agent interface.
The Agent interface models a single agent in the simulation.
Agents in the Matrix are not actors themselves.
They are managed by a agent runner actor.
The age... |
598302109a45390fded3850783ffeabad5c3491e | CJ0823/CCJ | /palindrome.py | 238 | 3.90625 | 4 | def is_palindrome(word):
syl = list(word)
for i in range(0,int(len(syl)/2)):
left = syl[i]
right = syl[-1-i]
if left != right:
return False
return True
print(is_palindrome("raceca")) |
5db626ee084a341ad9384a483435f023f030f943 | CJ0823/CCJ | /ID_number.py | 454 | 3.9375 | 4 | # 매출 파일 열기
# 파일 경로는 "data/chicken.txt" 입니다.
raw = open('data/chicken.txt','r', encoding = 'utf-8')
# 열린 파일을 string으로 만들기
string=''
for i in raw:
string += i
# string을 '\n'기준으로 split
list=[]
list = string.split()
print(list)
#list에서 매출항만 추출
list_price=[]
for i in range(1,int(len(list)/2),2):
... |
611c1ca129ae11f952946b2624ae7ad1b77b25ca | rahulnijhawan/python | /practice/mainModule.py | 767 | 3.859375 | 4 | # https://docs.python.org/2/tutorial/classes.html
# depth first used in mutliple inheritence,
# breadth first
a = 'global'
class cl:
"""doc string """
i = [];
def __init__(self):
self.ii = 20
def get(sel, n):
sel.i.append(n)
return 'get'
def getKind(slef):
return 'cl'
class animal:
#def __init__(s... |
f01a8efd19011571ea0bdfad24746b002355f21d | sarahbarron/adventure | /adventure.py | 1,344 | 4.375 | 4 | from data import locations
# dictionary of directions if we are currently at (1, 1) moving east will result in (1+1,1+0) = (2,1)
directions = {
'west': (-1, 0),
'east': (1, 0),
'north': (0, -1),
'south': (0, 1),
}
position = (0, 0) # starting position
while True:
location = locations[position] #... |
3c2557ff136f0de4415695c76b92d89ae2c622c2 | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio 13.py | 614 | 4.15625 | 4 | #Ler as notas da 1ª e 2ª avaliações de um aluno. Calcular a média aritmética simples e escrever uma mensagem
# que diga se o aluno foi ou não aprovado (considerar que nota igual ou maior que 6 o aluno é aprovado).
# Escrever também a média calculada.
print('Calculo media simpes')
print('Digite a nota da avaliacao 1... |
7539b7183b196aa7b09948214e66cdec4f39c20f | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio 43.py | 233 | 3.890625 | 4 | #Ler um valor N e imprimir todos os valores inteiros entre 1 (inclusive) e N (inclusive).
#Considere que o N será sempre maior que ZERO.
print('Digite um valor N')
valor_n = int(input())
for i in range(1, valor_n ):
print(i)
|
31c2cdeabfe9aa3c995a2dd1c7828538444a31fb | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio 19.py | 633 | 3.6875 | 4 | #Tendo como dados de entrada o nome, a altura e o sexo (M ou F) de uma pessoa, calcule e mostre
# seu peso ideal, utilizando as seguintes fórmulas:
#para sexo masculino: peso ideal = (72.7 * altura) - 58
#para sexo feminino: peso ideal = (62.1 * altura) - 44.7
print('digite seu nome')
nome = str(input())
print('dig... |
a367393d5c4f1b2525bb90fe93672250f97118ff | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio lista (array) - 7.py | 828 | 3.890625 | 4 | #Faca um algoritmo para ler um valor N qualquer (que será o tamanho dos vetores). Após, ler dois valores A e B
#de tamanho N cada um) e depois armazenar em um terceiro vetor_soma, a soma dos elementos do vetor A
#com os do vetor B (respeitando as mesmas posições) e escrever o vetor soma.
tamanho_vetor = 0
vetorA = []... |
b20980cbe53466ee0cedae71c9aaab54c1aac0fc | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio 49 - questao a mais.py | 494 | 3.796875 | 4 |
print('Média geral dos alunos')
print('Qual a quantidade de alunos?')
qtd_alunos = int(input())
print('Quantas notas por aluno?')
qtd_notas = int(input())
soma_notas = 0
for aluno in range(0, qtd_alunos):
# aluno [0, 1, 2]
for nota in range(0, qtd_notas):
# nota [0, 1]
print('Aluno {} ... |
2ed71e8adec5cd7de2cabb54da6ec595b1110048 | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio lista (array) - preco frutas.py | 1,402 | 3.875 | 4 | # Almir vende frutas na sua barraca na feira
# e com o sucesso do ultimo ano ele planeja criar
# preços diferentes para alta e baixa temporada.
# A sua ideia é que cada fruta tenha 2 preços: alta temporada e baixa temporada
# Crie um algoritmo que permita a Almir cadastras os preços de cada uma
# das sua frutas e em se... |
95bc86387accfadd39298a8808fe5020a990b65d | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio 45.py | 440 | 3.859375 | 4 | #Escreva um algoritmo que calcule e imprima a tabuada do 8 (1 a 10).
tabuada = 8
for multiplicador in range(1, 11, 1):
resultado = tabuada * multiplicador
print('{} x {} = {}'.format(tabuada,multiplicador,resultado))
#COM WHILE
#multiplicador = 1
#while multiplicador < 11
#resultado = tabuada * multipl... |
bb75e50cf170eae140f614118d084b51630272c3 | josiane-sarda/CursoPythonHbsisProway | /Aulas Marcello/exercicio 47.py | 607 | 3.8125 | 4 | #Ler 10 valores e escrever quantos desses valores lidos estão no intervalo [10,20]
#(incluindo os valores 10 e 20 no intervalo) e quantos deles estão fora deste intervalo.
dentro_intervalo = 0
fora_intervalo = 0
valor = 0
for i in range(10):
valor = float(input('Escreva o {}º valor:'.format(i + 1)))
if (va... |
c437223dde2570af997cd0cb9062065e0823d2c4 | EmFord/ucspU | /P0/Task3.py | 2,698 | 4.15625 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 3:
(080) is the area code for fixe... |
eea695bb97a6944193be6b7c45f4703d617d3666 | EmFord/ucspU | /P0/Task2.py | 1,191 | 4.125 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 2: Which telephone number spent the ... |
55c029b0d56eaadb11f4f353e14de8ec61329caf | ramontiveros/2014_1_Fundamentos | /promedio_n_numeros.py | 334 | 4.0625 | 4 | total = 0
num = 0
count = 0
continuar = True
print("Teclee numeros y si desea terminar teclee 0")
while continuar:
num = int(input("Teclea el numero {}: ".format(count+1)))
total += num
count += 1
continuar = num != 0
print("El promedio de los {0} numeros es: {1}".format(
count-1,
int(total... |
082c4d479c0c986fb17d1d7b0a758083f4f68ac9 | CquKeith/MyMachineLearningJourney | /numpy&pandas/numpy/createArray.py | 711 | 3.75 | 4 | # -*- coding: UTF-8 -*-
# @Time : 2019-01-15 14:16
# @Author : Keith
# @File : createArray.py
# @Software : PyCharm
# @About : numpy 创建array测试
import numpy as np
a = np.array([2,23,4])
print(a)
a = np.array([2,23,4],dtype=np.float32)
print(a)
a = np.array([[2,3,... |
153a4887dc97d0998bc4c73c30a11db109699e6e | rich-s-d/Python-Tutorial | /unittests/testguessinggame.py | 660 | 3.546875 | 4 | import unittest
import guessinggame
class TestGuessingGame(unittest.TestCase):
def test_input(self):
result = guessinggame.run_guess(5, 5)
self.assertTrue(result)
# self.assertEqual(result, True) # above better.
def test_input_wrong_guess(self):
result = guessinggame.run_guess... |
45a6204e68a0bc574e77a3093a9adb862cd1c0ca | rich-s-d/Python-Tutorial | /__pycache__/modules/specialiseddatatypes.py | 875 | 3.609375 | 4 | from array import array
import datetime
from collections import Counter, defaultdict, OrderedDict
#li = [num for num in range(1, 8)]
li = [1, 2, 3, 4, 5, 6, 7, 7]
sentence = 'blah blah blah thinking about python'
print(Counter(li)) # Retruns a dict where value is the count of list contents.
print(Counter(sentence))
... |
33624bb365e4a346a55a4fce207dc29d6f61bde7 | permCoding/speedCoding-01-solutions | /py/05.py | 108 | 3.53125 | 4 | n = int(input())
r = 0
input()
for i in range(n-2):
s = input()
r += s[1:-1].count('X')
input()
print(r) |
8e64bcf1c435a6d4c9c91a59ccd8f25c2314e1c5 | kypopthuk1996/python_learning | /Type/Task/task_4_5.py | 573 | 3.640625 | 4 | # -*- coding: utf-8 -*-
#Из строк command1 и command2 получить список VLANов, которые есть и в команде command1 и в команде command2.
#Результатом должен быть список: ['1', '3', '8']
command1 = 'switchport trunk allowed vlan 1,2,3,5,8'
command2 = 'switchport trunk allowed vlan 1,3,8,9'
command1 = command1.split( )
c... |
56ddfc604f0698f72b9ffb95822d9298e9bb595a | kypopthuk1996/python_learning | /control_programs/exception.py | 2,647 | 4.125 | 4 | # -*- coding: utf-8 -*-
#Для работы с исключениями используется конструкция try/except:
try:
2/0
except ZeroDivisionError:
print("You can't divide by zero")
#Конструкция try работает таким образом:
#сначала выполняются выражения, которые записаны в блоке try
#если при выполнения блока try не возникло никаких... |
05d08ea207d49c7c6999514589f3cbe984908924 | kypopthuk1996/python_learning | /feature/List_dict_set_comprehensions.py | 4,389 | 3.640625 | 4 | #Python поддерживает специальные выражения, которые позволяют компактно создавать списки, словари и множества.
#На английском эти выражения называются, соответственно:
#List comprehensions
#Dict comprehensions
#Set comprehensions
#Генератор списка - это выражение вида:
vlans = ['vlan {}'.format(num) for num in range(... |
da3e7b12999774127ad0ddab973daab5917eb120 | ColonelAVP/python_projects | /Morse code converter/Morse_Code_Converter.py | 3,930 | 3.5625 | 4 | def translate(sentence):
translation = " "
for letter in sentence:
if letter in "Aa":
translation = translation + " .- "
elif letter in "Bb":
translation = translation + " -... "
elif letter in "Cc":
translation = translation + " -.-. "
elif le... |
12c1e24ae2ff5e6e7821b659c52ddcd0a73f348b | saidmasoud/practicepython | /exercises/exercise23.py | 718 | 3.765625 | 4 | #Given two .txt files that have lists of numbers in them, find the numbers that are overlapping.
# One .txt file (http://www.practicepython.org/assets/primenumbers.txt) has a list of all prime numbers under 1000, and
# the other .txt file (http://www.practicepython.org/assets/happynumbers.txt) has a list of happy numbe... |
26b71356f8cc046b804624611256b6e543ae4b82 | saidmasoud/practicepython | /exercises/exercise18.py | 1,581 | 4.15625 | 4 | #Create a program that will play the “cows and bulls” game with the user. The game works like this:
#Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit that the user
# guessed correctly in the correct place, they have a “cow”. For every digit the user guessed correctly in the
#... |
38b3fdb0e8b74a81b6c907c841d9dca625d4f5c1 | saidmasoud/practicepython | /exercises/exercise02.py | 991 | 4.40625 | 4 | #Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message
# to the user. Hint: how does an even / odd number react differently when divided by 2?
#Extras:
#If the number is a multiple of 4, print out a different message.
#Ask the user for two numbers: one number to c... |
607d0bb159468bf0982afc071e998b0f5ce70e58 | saidmasoud/practicepython | /exercises/exercise22.py | 1,922 | 3.921875 | 4 | # Given a .txt file that has a list of a bunch of names, count how many of each name there are in the file,
# and print out the results to the screen. I have a .txt file for you, if you want to use it!
# http://www.practicepython.org/assets/nameslist.txt
#Extra:
# Instead of using the .txt file from above (or instead... |
2678da21901ce098bb440fcf3272ff71b174c35f | rwolf527/manning_live_project_delivery_notes_automation | /dn.py | 759 | 3.84375 | 4 | import os
def getfiles(root_dir=".", file_type=".pdf"):
"""finds all files of the specified type in the specified root_dir
and all subdirectories.
Keyword Arguments:
root_dir {str} -- the starting directory to look in. (default: {'.'})
file_type {str} -- the file extension to look for]... |
00f8fe6b0aca392bc646d52ed4e15f845fe14f12 | joshualambert/dotfiles | /bin/filecount.py | 450 | 3.90625 | 4 | #!/usr/bin/env python
"""Walk a directory structure and get a count of files and directories."""
import os
if __name__ == '__main__':
files = []
directories = []
for dirname, dirnames, filenames in os.walk(os.curdir):
for dirname in dirnames:
directories.append(dirname)
for fi... |
f113d0172b96367b88fb01151ce7bdd478433f54 | DariaKutkanych/py-homeworks | /comprehensions/task4.py | 505 | 3.75 | 4 | # Write a function that takes 2 dictionaries where keys are cars and values
# are their prices. The function checks whether the sum of prices in 1
# dictionary is equal to the sum in the 2nd
def compare_prices(cars1: dict, cars2: dict) -> bool:
pass
assert compare_prices({'BMW': 20000, 'Nissan': 15000},
... |
a273bfbe82b1533c3f35c706590b684869b6a401 | Lharp5/comp4106-assignments | /project/generate_data.py | 1,473 | 3.6875 | 4 | from deck import Deck
from hand import Hand
import random
correct_file = 'correct_move.txt'
incorrect_file = 'incorrect_move.txt'
def write_entry(input_file, play):
with open(input_file, 'a') as write_file:
write_file.write(play.to_binary() + '\n')
def generate_data(num_data):
num_left = nu... |
4922b179fcb547463c182921f66fef45c78f8f2d | wes-novack/adventofcode | /2020/day6/puzzle1.py | 742 | 3.921875 | 4 | def count_groups(file_name):
groups_list = get_groups(file_name)
return len(groups_list)
def get_groups(file_name):
groups_list = []
with open(file_name) as file:
group = set()
for line in file:
if line.strip() != "":
for letter in line.strip():
... |
1617df65501e89a8df22d304f7e7bc46c435292f | wes-novack/adventofcode | /2019/day3/puzzle2.py | 2,716 | 4.03125 | 4 | def read_file():
with open("input2.txt") as input:
intcodes = input.readlines()
return intcodes
def calculate_manhattan_distance(wire1,wire2):
if wire1 == "R75,D30,R83,U83,L12,D49,R71,U7,L72" and wire2 == "U62,R66,U55,R34,D71,R55,D58,R83":
return 159
elif wire1 == "R98,U47,R26,D63,R33,... |
2e0d030356bbe21bba062c63ba7bdbaf7826f118 | wes-novack/adventofcode | /2018/day6/puzzle1.py | 1,227 | 3.671875 | 4 | def read_file(file_name):
lines = []
with open(file_name) as file:
for line in file:
lines.append(line.replace("\n",""))
return lines
def solve_puzzle(lines):
return 17
def determine_outer_coords(lines):
outer_coords = { "nw": [1000, 0], "ne": [0, 0], "se": [0, 0], "sw": [100... |
bbe17e71284596002a5f04a0f6af7be5d1ced63a | ajhofmann/Poker | /Poker.py | 9,728 | 3.671875 | 4 | # Author: Adam Hofmann
# Five Draw Poker Game designed and developed in Python to gain experience in GUI.
import random
import PIL.Image, PIL.ImageTk
import tkinter as tk
from tkinter import *
random.seed()
suits = ['C', 'D', 'H', 'S']
cards = ['A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2']
deck = ... |
6d5bd788412e59906a3dd044920ed061f4143aaa | Bhogavarapuvaralakshmi/python- | /prime number in for loop.py | 192 | 4.03125 | 4 | n=int(input('enter a number'))
count=0
for i in range(1,n+1):
if n%i==0:
count+=1
if count==2:
print(n,'is a prime number')
else:
print(n,'is not a prime number')
|
286d5344a685e764fa7b58508a86258238521739 | Bhogavarapuvaralakshmi/python- | /while loop.py | 343 | 3.9375 | 4 | i=0
while True:
print('good morning')
i+=1
if i==5:
break
i=0
while True:
print(i)
i+=1
if i==5:
break
i=0
while True:
print(i,end=" ")
i+=1
if i==5:
break
i=5
while True:
print(i,end=" ")
i-=1
if... |
47fe4d1ef667bd27504c3450299d0a83aaba8691 | Bhogavarapuvaralakshmi/python- | /program5.py | 94 | 3.59375 | 4 | a=float(input('enter a value'))
b=float(input('enter b value'))
print(type(a),type(b),a,b)
|
3e5211ace72dfde3799876c672340012ca2424a1 | anulata1234/python-coding | /to_find_pivot_in_array.py | 611 | 3.9375 | 4 | # pivot is a number from where the number order is not ascending or decending , in this case the number is 4
def findPivot(arr, low, high):
# base cases
if high < low:
return -1
if high == low:
return low
#low + (high - low)/2;
mid = int((low + high)/2)
if mi... |
a27f44ce51a99dc7717d1f651f293821832ce6cf | meghavardhini/python | /ck12.py | 217 | 3.578125 | 4 | def mn():
n=int(input("enter the no:"))
sum=n
r=0
while(n>0):
i=n%10
r=r*10+i
n=n//10
if(sum==r):
print("yes")
else:
print("no")
mn()
|
55d491f534ed0aeabaad448b56016dac5a75607f | meghavardhini/python | /ck105.py | 114 | 3.59375 | 4 | n1=int(input())
n2=int(input())
if(n1%2==0):
b=n1//2
print(b)
print(n2)
else:
print(n1)
|
f2bdeaf291a1eeb0fe9a6d1eaf7d921d19677e59 | meghavardhini/python | /ckplay9.py | 101 | 3.53125 | 4 | m=input().split()
m[0]=m[0].capitalize()
m[1]=m[1].capitalize()
print(m[0],end=" ")
print(m[1])
|
49b76849ef1e8b435f409550a091bc5e8bf1d122 | meghavardhini/python | /ck26.py | 112 | 3.515625 | 4 | def mn():
a=int(input())
b=int(input())
a=a^b
b=a^b
a=a^b
print(a,b)
mn()
|
46ec4baa932bb30a2af71822441687f0b22ac5ae | meghavardhini/python | /ck24.py | 203 | 4.09375 | 4 | str1 = input("Please Enter your Own String : ").split()
total = 0
i = 0
while(i < len(str1)):
total = total + 1
i = i + 1
print("Total Number of Characters in this String = ", total)
|
4ab07e89e522cfaa50dfa9fb5d70d138040e5764 | meghavardhini/python | /ckplay3.py | 89 | 3.890625 | 4 | d=input("")
if d=="Saturday" or d=="Sunday":
print("yes")
else:
print("no")
|
7a54f3706c42e2ad33b4744281f4826d7d6b766c | meghavardhini/python | /ckplay20.py | 188 | 3.59375 | 4 | def mn_gcd(x,y):
while(y):
x,y=y,x%y
return x
def mn_lcm(x,y):
lcm=(x*y)//mn_gcd(x,y)
return lcm
m=list(map(int,input().split()))
print(mn_lcm(m[0],m[1]))
|
96352d9834d75bd8362a6d6da6ada5cd5ec58838 | fossabot/plotplayer | /plotplayer/helpers/file_helper.py | 277 | 3.984375 | 4 | """
Simple helper functions for File Operations
"""
WRITE_FILE_MODE = 'w'
def save_file(file_name, data):
"""
Function to save data to a file, overwriting the file if it exists
"""
file = open(file_name, WRITE_FILE_MODE)
file.write(data)
file.close()
|
a859fc8658d068b974c11d74e0e36452543db6e7 | zingpython/greatKaas | /day_six/bubblesort.py | 401 | 4.09375 | 4 | def bubbleSort(unsorted):
swapped = True
while swapped == True:
print(unsorted)
swapped = False
for index in range( len(unsorted) ):
if index != len(unsorted)-1:
if unsorted[index+1] < unsorted[index]:
temp = unsorted[index]
unsorted[index] = unsorted[index+1]
unsorted[index+1] = temp
... |
d2ffd7494b68359f85ec993c555a135fd14662c8 | zingpython/greatKaas | /day_two/day_two_exercise_4.py | 967 | 4.03125 | 4 | limit = int(input("Enter the limit: "))
sieve_list = list( range(2, limit+1) )
#While loop moves from start of list to end of list
#We use a while loop because we will be removing items from the list
index = 0
while index < len(sieve_list):
#Index2 starts at index +1 because we want to check if every item after th... |
45152df6f27de0f074bfb3df4bdded3bd165d8cc | oldmud0/zero-grav-soccer | /button.py | 591 | 3.703125 | 4 | import pygame
class Button(pygame.sprite.Sprite):
"""Represents a button that can be used in UI."""
def __init__(self, off_path, on_path, action, pos):
pygame.sprite.Sprite.__init__(self)
self.image_on = pygame.image.load(on_path).convert()
self.image_off = pygame.image.load(off_path)... |
75558fc136ba3533a6ff51fc9d75ff905e666ca1 | zhetkergendarkhan/Web-Dev | /informatics/2/D.py | 80 | 3.8125 | 4 | a=int(input())
if a>0:
print(1)
elif a<0:
print(-1)
elif a==0:
print(0) |
4158a2fe64a86e4f9e1b22c43b92daa947500952 | leenlab2/Visualizing-Sea-Levels | /map_setup.py | 1,206 | 3.984375 | 4 | """This module contains the MapArea and Midpoint classes.
Together they represent the points of the map that we are working with.
"""
from typing import Tuple
from dataclasses import dataclass
@dataclass
class MapArea:
"""A map of a certain area.
Instance Attributes:
- latitude: the range... |
a79e722c5059644080e5ba10987961d35918a11f | peacemaker07/iot_making_for_raspberry_pi | /utils/date_time.py | 1,032 | 3.625 | 4 | from datetime import datetime, timezone, timedelta
class TimeMeasure:
"""
経過秒、タイムアウトなどを管理するクラス
"""
start_time = None # 開始時間
time_out_sec = 0 # タイムアウト(秒)
def __init__(self, time_out_sec=None):
"""
初期化処理
:param time_out_sec: タイムアウト(秒)
"""
self.start_t... |
16bcaf1dc262785dece0ba5ace6b3de4a8cd19c4 | msahasan/Result_DataEng | /data-processing.py | 1,981 | 3.875 | 4 | #import pandas lib
import pandas as pd
#read data from file
df=pd.read_csv("dataset.csv",sep=",")
# define split function
def split_column_name(dataframe):
# split the name column into first ,last
dataframe['first_name']=""
dataframe['last_name']=""
dataframe[['first_name','last_name']] = dataframe["... |
333f52f800189b333fe1d51e856a92f869d1b78b | prawee/python-practicse | /if_statements.py | 773 | 4.0625 | 4 | # should_continue = True
# if should_continue:
# print("Hello")
# know_people = ["John", "Anna", "Mary"]
# person = input("Enter the person you know: ")
# if person in know_people:
# print("You know {}!".format(person))
# if person not in know_people:
# print("You don't {}!".format(person))
## Exercise
d... |
da3ed7b5337e0c5a794d97990dbf9fbcbd5924ce | Pragnesh30/multi-client-socket-programming-httprequest-python | /client.py | 579 | 3.609375 | 4 | # pylint: disable-all
# Import socket module
import socket
def Main():
# local host IP '127.0.0.1'
host = '127.0.0.1'
# Define the port on which you want to connect
port = 80
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
# connect to server on local computer
s.connect((host,port))
# messag... |
6ff776e255915b01a3d334a397a67c0cf44c83ad | brunobara/lista1 | /exercicio8.py | 649 | 4.15625 | 4 | """
Dicionários. Dado o dicionário: d = {‘a’: 0}: faça programas que
8.1 acrescente um par (chave, valor) {‘b’: 1}, ao dicionário;
8.2 verifique se a key ‘c’ está presente?
8.3 Concatene um dicionário a um outro dicionário: e = {z : 23}. Use o método
‘update’!
"""
# Dado o dicionário: d = {‘a’: 0}
d = {'a': 0}
print(d... |
9c7913ab8002a99f996522dc5dcb9946a0a126c2 | brunobara/lista1 | /exercicio2.py | 394 | 4.21875 | 4 | """
Exercício 2
Altere o programa acima para que o usuário possa entrar com o número máximo de estrelas.
"""
def patern(size=5):
for i in range(1,size):
print('* ' * i)
for i in reversed(range(1,(size-1))):
print('* ' * i)
return patern
if __name__ == '__main__':
maximo = int(input('P... |
6ad3da9c5c69535ec575d29e488002e058caa27b | brunobara/lista1 | /exercicio7.py | 970 | 4.09375 | 4 | """
Exercício 7
Escreva um programa que, dada uma lista de números [-2, 34, 5, 10, 5, 4, 32] qualquer,
retorne: o primeiro valor, o número de valores, o último valor, a soma, a média e a mediana.
*** Obs. Para listas com tamanho ímpar, a mediana é o valor do meio, quando ordenada
(sorted()). Para listas pares, retorne... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.