blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
34ef1d17f521ec99c5e905d595e0fb005e45baeb | chrplr/AIP2017 | /doc/_build/html/_downloads/compute-sums-two-cols-csv.py | 363 | 3.625 | 4 | #! /usr/bin/env python
# Time-stamp: <2017-09-20 13:16:25 cp983411>
"""
Computes the sums of two columns from an headerless csv file.
Computes the sums of two columns from an headerless csv file.
"""
import csv
col1, col2 = 0.0, 0.0
for row in csv.reader(open('test.csv', 'r')):
col1 += float(row[0])
... |
8abb0a93c1323975684688079e0e41d883813409 | theakers/Class5-Python-Module-Week1 | /ders_puani_hesaplama.py | 1,041 | 3.96875 | 4 | #Kullanıcıdan Adi, Soyadi, Ogrenci Numarasi, 4 ders adi, bu derslerin Vize ve Final notlari istenecektir.
# Vize notunun % 40′ı ile Final Notunun %60′ınin toplamı yil sonu ortalamasini verecektir.
# Ortalama 50‘den küçükse ekranda “KALDI“, 50 ve üstüyse ekranda “GEÇTİ” yazdırılacaktır.
# Bu yazdirma islemi 4 ders ic... |
f53c7624ba06eaeaf254daa40ca1a1df77863169 | nm000/Suma | /PC2_Compresor-master/tree_dataStruct.py | 2,804 | 3.65625 | 4 | class nodeHuff:
def __init__(self, freq:int, symbol:str, left=None, right=None):
# frequency of symbol
self.freq = freq
# symbol name (character)
self.symbol = symbol
# node left of current node
self.left = left
# node right of current node
self.... |
904b5294cf9694f9db12da92ce8ef9953c7017a1 | SawlStone/InfopulsUniver_Python | /f3_3_class_PointLine.py | 489 | 3.703125 | 4 | __author__ = 'Sawl_Stone'
import math
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def distance(self):
return math.sqrt(self.x*self.x + self.y*self.y)
def distancePoints(self, otherPoint):
math.sqrt((self.x-otherPoint.x)**2 + (self.y-otherPoint.y)**2)
clas... |
7649d5eb829cdfd292cffd8fa2b2577cadab51b5 | GauravKTri/-All-Python-programs | /apni dictonary2.py | 89 | 3.65625 | 4 | d={"tum":"you","he":"boy","she":"girl"}
values=input("enter the name:")
print(d[values])
|
204545c2adb5375ad0918a8ae98b3d49cbf1c65b | imtengyi/oldboyS14 | /day02/threemenu.py | 2,156 | 3.703125 | 4 | #根据课堂老师带着一起完成的,仅供参考。
menu = {
'北京':{
'海淀':{
'五道口':{
'soho':{},
'网易':{},
'google':{}
},
'中关村':{
'爱奇艺':{},
'汽车之家':{},
'youku':{},
},
'上地':{
... |
6f0abcf618ad9bfc443de237b884d2f608bc98ef | windniw/just-for-fun | /leetcode/150.py | 756 | 3.578125 | 4 | """
link: https://leetcode.com/problems/evaluate-reverse-polish-notation
problem: 求逆序表达式
solution: 栈模拟即可。最大的问题在于python的标准和C不一样... 1 // -2 等于 -1 而不是 0,
因为C标准是向0取整,python标准是向无穷取整,题目要求前者,用int(a/b)代替 a//b
"""
class Solution:
def evalRPN(self, tokens: List[str]) -> int:
s = []
op = {
"+":... |
91548eaadeb4ea8966098bd2101213fadc03cd07 | RicardoBernal72/CYPRicardoBS | /libro/problemas_resueltos/Capitulo2/problema2_1.py | 171 | 3.6875 | 4 | N=float(input("numero de sonidos por min: "))
if N>0:
T=N/4 + 40
print(f"la temperatura aproximada del ambiente es de {T}°")
else:
print("Fin del programa")
|
e908667667651290435797d824603bdaab37ba21 | BR41N14C/Automated-Attack-Pexpect | /Automated_Attack_Pexpect.py | 2,238 | 3.5 | 4 | # importing the pexpect module
Import pexpect
def Access(secret_key, counter):
#IP
HOST = "83.212.97.72"
#Port
PORT = "80"
connect = 'nc {} {} '.format(HOST, PORT)
# this will execute the connection to the server
child = pexpect.spawn(connect)
child.expect("Login:")
child.sendline("max")
child.expect("Passw... |
d111a2841d1ce48d88a4d91b0da6ea316dc15977 | Micaiah-Chang/LPTHW | /gothon/bin/passwords.py | 638 | 3.765625 | 4 | from passlib.hash import bcrypt
def encrypt_this(password):
return bcrypt.encrypt(password, rounds = 10)
def verify_this(password,hash):
return bcrypt.verify(password,hash)
if __name__ == "__main__":
while True:
password = raw_input("Please enter a test password: ")
hash = encrypt_this(password)
print "Y... |
b24b1a2dfa931fcb6ad5d2d59be1cf6b6ea70c87 | ParthJindal32/Alphabets-Patterns | /V.py | 262 | 4.09375 | 4 | for row in range(7):
for col in range(5):
if ((col==0 or col==4) and row!=5 and row!=6) or (row==5 and col==1) or (row==5 and col==3) or (row==6 and col==2):
print("*",end=" ")
else:
print(end=" ")
print()
|
abed7f6da3503ab76ace6919612901863ea305e3 | geliefan/Python_test | /Ex12_3.py | 335 | 3.65625 | 4 | # -*- coding: cp932 -*-
#12.3 Pythoñu[Z
#ture: not 0, not null object
#false: 0, null object,None
print 2 < 3, 3<2
print 2 or 3, 3 or 2, 2 and 3
print [] or 3, 0 or 1
print [] or {}
#if/else
A = 't' if 'spam' else 'f'
print A
A = 't' if '' else 'f'
print A
print ['f','t'][bool('')]
print ['f','t'][bool('spam')]
|
38df545e1a18a680b130e255dea95b528a84ef5e | KeuryLendof/PythonTkinter | /cambiar color de fondo.py | 923 | 3.734375 | 4 | import tkinter as tk
import random
mywindow = tk.Tk()
def changeBG():
#mywindow.config(background = '#76880A')"""Esto es para cambiar un solo color"""
color = ["#76880A", "#7F8F87", "#65de4c", "#050ff4", "#78dd99", "black", "green", "cyan"]
random_color = random.choice(color)
mywindow.config(background... |
22835f24651a010b7528d08dc1d1a11aad2a496e | takaya0111/AtCoder | /157D.py | 1,539 | 3.625 | 4 | class UnionFind():
def __init__(self,n):
self.n = n
self.parents = [-1]*n
def find(self,x):
if self.parents[x]<0:
return x
else:
self.parents[x]=self.find(self.parents[x])
return self.parents[x]
def union(self,x,y):
x = self.f... |
57b2d785e3a33a6afecdde2ceff0f6c58d5a2343 | delmiro-j/calculando-em-python | /subitracaõ.py | 200 | 3.859375 | 4 | sb1 = float(input('Digite o número que você deseja subtrair : '))
sb2 = float(input('Digite o outro valor : '))
rs1 = sb1 - sb2
print('A subtração entre {} e {} é igual a {}'.format(sb1,sb2,rs1)) |
a12d6a7354e8460945f51c60bf9b266ab4f09fd5 | edirab/visualizing-Algorithms | /functions.py | 828 | 3.546875 | 4 | import random
import pygame
import math
def init_data(n_objects, screen_width, screen_height):
data = []
for i in range(n_objects):
data.append(random.randint(0, screen_height))
return data
def draw(surface, data, screen_width, screen_height):
rect_width = screen_width // len(data)
x = 0
... |
9835b9248ff20321d0b8ba8d11eb8997175d72cb | sarbojitdas/Flower_classification | /Flower_classification.py | 2,987 | 3.6875 | 4 | ##iris dataset
#load packages
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
#load dataset
iris=load_iris()
#print(iris)
#load iris database
db=iris.data
#print(db)
#load the feature
feature=iris.feature_names
#print(feature)
# divide the ... |
68595aa861edd3a92943ae0c8144f3e8ee858843 | Josalgue/python-challenge | /PyPoll/Analysis/main.py | 1,791 | 3.59375 | 4 | # Import file
import os
import csv
# Set file path
pypoll = os.path.join("..", "Resources", "election_data.csv")
# Assign variables
total_votes = 0
candidates = {}
candidates_percent = {}
# Enable csv reader
with open(pypoll, newline="") as csvfile:
csvreader = csv.reader(csvfile, delimiter=",")
csv_header =... |
1c3d03923c4dc1819969f1665aa031c565bf8b10 | jecky100000/VirtualHumanBatchProcessing | /utils/utils.py | 4,525 | 3.609375 | 4 | import os
#useful as a decorator for conversion files
def apply_to_folder(func, input_folder_path, output_folder_loc, output_file_format, input_file_filter_function, recursive_search = False, import_kwargs = {}, export_kwargs = {}, verbose = False):
'''
:param func: Function to be applied to all files in a fol... |
f53ac4e9969bd50ba3652c246bb7d45027b0fd55 | realnitinworks/bitesofpy | /291/srt.py | 1,277 | 3.5 | 4 | from datetime import timedelta
from typing import List
from collections import namedtuple
from dateutil.parser import parse
Section = namedtuple('Section', 'id duration text')
def get_srt_section_ids(text: str) -> List[int]:
"""Parse a caption (srt) text passed in and return a
list of section nu... |
2d68e70592c20f8d191ff725b7ede85b1c5b385a | RanjaniMK/Python-DataScience_Essentials | /while_statement_Demo.py | 100 | 3.859375 | 4 | i=0
while i<=10:
print(i)
i+=1
#Output: 0 1 2 3 4 5 6 7 8 9 10 (Columnar/Vertical Display)
|
e33898454bac1798917254cb7fe3015b20102018 | Halverson-Jason/cs241 | /week6/check6a.py | 1,441 | 3.84375 | 4 | # Checkpoint #6 A
# Jason Halverson
class Book:
def __init__(self):
self.title = ""
self.author = ""
self.publication = 0
def prompt_book_info(self):
self.title = input("Title: ")
self.author = input("Author: ")
self.publication = int(input("Publication Year: "))... |
2a32e3926808e0479ae242fe5980f50beaa284d2 | geediegram/parsel_tongue | /tosin/cartesian.py | 512 | 4.21875 | 4 | x_coordinate = float(input("Enter the value for x coordinate "))
y_coordinate = float(input("Enter the value for y coordinate "))
if(x_coordinate == 0 and y_coordinate == 0):
print("It's the origin")
elif(x_coordinate > 0 and y_coordinate > 0):
print("I")
elif(x_coordinate < 0 and y_coordinate > 0):
print("... |
5c8a130b76a65e7fde207aebfd5a5adc1fb8da2d | eligah/codingPractice | /leetcode/python/test-bit.py | 477 | 3.828125 | 4 | def countBits(num):
"""
:type num: int
:rtype: List[int]
"""
tnum=num
l=[0,]
if num==0:
pass
elif num==1:
l.append(1)
else:
l=[0,1]
power=0
while num//2 is not 0:
num=num//2
power+=1
rest=tnum-2**power
fo... |
82fa8ca9eed6c2903bb7baa73a2c903634b760b2 | damoye/algorithm | /insert_sort.py | 181 | 3.546875 | 4 | def insert_sort(A):
i = 1
while i != len(A):
j = i
while j != 0 and A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
j -= 1
i += 1
|
db0d7bb3f334022dfd4e2aa6e9df901954253958 | zhenghaoyang/PythonCode | /ex29.py | 580 | 4.03125 | 4 | # --coding: utf-8 --
people = 20
cats = 30
dogs = 15
if people < cats:
print "Too many cats! The world is doomed!"
if people > cats:
print "Not many cats! The world is saved!"
if people < dogs:
print "The world is drooled on!"
if people > dogs:
print "The world is dry!"
dogs += 5
if people >= dogs:
... |
3c0926ce03a3d653f24f8cd6e48f0771bff982a6 | kyuugi/saitan-python | /やってみよう_必修編/chapter05/5_9_no_users.py | 343 | 3.765625 | 4 | usernames = []
if usernames:
for username in usernames:
if username == 'admin':
print("こんにちはadmin、状況のレポートを見ますか?")
else:
print(f"こんにちは{username}、またログインしてくれてありがとう。")
else:
print("ユーザー募集中です!")
|
b2a522398f2307f72ece2ad350df935bb6f2d339 | lulukdog/leetcode-Python | /hackerrank/The Minion Game.py | 1,153 | 3.8125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
import re
import heapq
def minion_game(string):
# your code goes here
# countStuart,countKevin = 0,0
# vowels = ['A','E','I','O','U']
# for i in range(len(string)):
# for j in range(i,len(string)):
# # is vowel kevin
# ... |
4e56291fa2c482cd00a77d5153fbd98723abbc33 | damodharn/Python_Week1 | /Week1_Functional/Distance.py | 742 | 4.21875 | 4 | # *********************************************************************************************
# Purpose: To print the Euclidean distance from the point (x, y) to the origin (0, 0).
# Author: Damodhar D. Nirgude.
# ************************************************************************************************
from ... |
26336da3d3a8f87156d32073aa27c8877f41fb2c | leo-nardow/Exercicios-Python | /Fundamentos/ex008.py | 835 | 4.03125 | 4 | #################################################################
# File name: ex008 #
# Author: Leonardo Almeida #
# GitHub: leo_nardow #
########################################################... |
4a21012b4f94d5d700eedbc432b74c8215905cf3 | yassarq/Python | /Python_basics/product_assignments.py | 1,284 | 3.6875 | 4 | class Product:
def __init__(self, price, itemName, weight, brand):
self.price = price
self.itemName = itemName
self.weight = weight
self.brand = brand
self.status = "for sale"
def sell(self):
self.status = "sold"
return self
def addTax(self, tax):
... |
9b041876307d52f0c23047b806785710504dc826 | BrendaSpalenza/algoritmos | /dicionarioComListas.py | 550 | 3.9375 | 4 | games = {'nome': ['Super mario', 'Zelda', 'Pokemon'],
'videogame': ['Super Nitendo', 'Nitendo 64', 'Game Boy'],
'ano': [1990, 1998, 1999]}
print(games)
#Mesmo exercício, so que via input
games = {'nome': [], 'videogame': [], 'ano': []}
for i in range(3):
nome = input('Qual o nome do jogo?')
... |
baf1385e214b0b218fb130687ee6f64fc214bbf7 | aryanvashishtha82/python-lab-prog. | /circleareper.py | 125 | 4.125 | 4 | r=float(input('enter radius'))
PI=3.14
a=PI*r*r
p=2*PI*r
print("area of circle %.2f"%a)
print ("perimeter of circle %.2f"%p)
|
f551f3a1f20415a9d82d9adb51b734535ca84091 | edson-onishi/PythonURIOnlineJudge | /1008.py | 129 | 3.625 | 4 | numero = int(input())
horas = int(input())
sal = float(input())
print("NUMBER = {}\nSALARY = U$ {:.2f}".format(numero,horas*sal)) |
a182893cba65b9079ccd314e56319dfeb6a5edc0 | ianoti/Andela_Camp | /primenumbers.py | 192 | 3.734375 | 4 | def prime(num):
for i in range(2,num+1):
count = 0
for j in range (2,i):
if i%j !=0:
count += 1
if count == i-2: #this is due to starting from 2 in the primes
print (i) |
fe883fd960959d438ef6b798bda62bce5609541a | JiahangGu/leetcode | /Review Problem/gjh/110-balanced-binary-tree.py | 1,443 | 3.5 | 4 | #!/usr/bin/env python
# encoding: utf-8
# @Time:2020/8/28 22:40
# @Author:JiahangGu
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def isBalanced(self, root: TreeNode) -> bool:
"""
自顶向下的解法,对于每个非叶子节点,求出左右子节点的高度比较是... |
8ae776431e7f45937fe4af17a4fee4f25f1a234a | jacobcallear/prisoners_dilemma | /prisoners_dilemma/strategies.py | 9,796 | 4.40625 | 4 | '''Defines strategies for Prisoner's Dilemma.
'''
from abc import ABCMeta, abstractmethod
from random import choice, random
class Strategy(metaclass=ABCMeta):
"""Parent class for each strategy. Keeps track of both player's history.
Subclasses must add a `play` method that returns 'COOPERATE' or 'DEFECT'.
... |
9248d14e5b456d8a3686d135e11f68294a855d76 | Elmo33/e-olymp | /0000-0999/653.py | 324 | 3.796875 | 4 | a, b, c = map(float, input().split())
if a+b>c and a+c>b and b+c>a:
if a*a+b*b>c*c and a*a+c*c>b*b and b*b+c*c>a*a:
print("ACUTE")
if a*a+b*b<c*c or a*a+c*c<b*b or b*b+c*c<a*a:
print("OBTUSE")
if a*a+b*b==c*c or a*a+c*c==b*b or b*b+c*c==a*a:
print("RIGHT")
else:
print("IMPOSSIBL... |
5ed57f79814ee00146c6c325ba0d4dd29a8e31f3 | DatLombardo/Computational-Science-CSCI2072 | /IterationAssign1.py | 919 | 3.6875 | 4 | #Authour: Michael Lombardo
#SID: 100588642
#Date: 1/24/2017
#Assignment 1 : Iteration
import math
#Hardcoded Test Values, Converges at 18 iterations
maxIter = 20
prevX = 1.4
error = 0.00000001
residualErr = 0.0005
def func(x): #Function Definition
return ((1/(2*math.pi))*(math.sin(math.pi*x))) - ((1/... |
9c00fc746ac4f768f9dedc2d44a3fe46deafa331 | amy58328/python | /pandas/hello pandas.py | 795 | 3.796875 | 4 | import pandas as pd
# 準備傳入 DataFrame 的資料
data_1 = {
'name': ['王小郭', '張小華', '廖丁丁', '丁小光'],
'email': ['min@gmail.com', 'hchang@gmail.com', 'laioding@gmail.com', 'hsulight@gmail.com'],
'grades': [60, 77, 92, 43]
}
data_2 = {
'name': ['王小郭', '張小華', '廖丁丁', '丁小光'],
'age': [19, 20, 32, 43]
}
# 建立 Data... |
92e8b5037cd0b6b0692adc59c73ec3169825aa7e | qdbigyellow/pyprac | /optimizing_python_code/Exercise Files/Ch03/03_04/builtin.py | 695 | 4.125 | 4 | """Using built-in functions"""
# PYthon sorts tuple in lexicographical order (by name)
# Python string compare '3' > '200' is true
from operator import itemgetter
def sort_tasks(tasks):
"""Sort tasks by priority"""
# Key is a functin that get the object we'd like to compare, and
# return the va... |
cbcd909649aa236ca3ea8fa12610f5e0f1e235af | SirLeonardoFerreira/Atividades-ifpi | /Ensinando com as tartarugas/planetas_tartaruga.py | 532 | 4.28125 | 4 | from turtle import *
#uma função para desenhar um planeta de um tamanho específico
def drawPlanet(planetSize, planetColour):
color(planetColour)
pendown()
begin_fill()
for side in range(363):
left(1)
forward(planetSize)
end_fill()
penup()
#isso desenhar um fundo azul escuro
bgc... |
d075cf10595e86687ccb12bb373a460fdb45f20c | MrozKarol/Python | /adventure with python/value_as_a_ logical_condition.py | 437 | 3.90625 | 4 | # Demonstruje traktowanie wartości jako warunku
print("Witaj w Chateau D' Smakosz")
print("Wydaje się, że tego wieczoru mamy prawie komplet gości.\n")
money = int(input("Ile złotych wsuniesz do kieszeni maitre d'? "))
if money:
print("Och, przypomniałem sobie o wolnym stoliku. Proszę tędy.")
else:
print("Pro... |
cdb39b2debc997cf1e192c0e2ef9abd26c64f8fd | WeversonCelio/Exercicios | /Exercicio 2/exercicio_semana2.py | 1,980 | 4.21875 | 4 | import math
print("1- Faça todos os exemplos da apostila da Semana #2")
print("Hello Word")
#--------------------
print('Soma')
print(3+5)
print(9+12)
print(7+32)
#------------------
print('N decimais')
print(4.5+7.3)
print(7.9+18.2)
print(3.6+34.1)
#------------------
print('Subtracao')
print(5-2)
print(9-7)
print(15-... |
eeee74fb82435cb069261b075dee9d9624511d3a | Tousama/Python | /list_combination_elements.py | 397 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 22 23:01:53 2021
@author: mgune
"""
from itertools import combinations
def dongu(arr):
y=max(arr)
arr.remove(y)
for i in range(1,len(arr)+1):
x=list(combinations(arr,i))
for j in range(len(x)):
if sum(x[j]) == y:
... |
88285e79b83f6b77ee2bfe78665f2af38a592e45 | thiagofb84jp/python-exercises | /pythonCourseUdemu/algoritmosExercicios/estruturaDeDecisao/exercicio23.py | 377 | 4.15625 | 4 | """
23. Faça um Programa que peça um número e
informe se o número é inteiro ou decimal.
Dica: utilize uma função de arredondamento.
"""
numero = 38.65
if (numero == round(numero)):
print("Inteiro.")
else:
print("Decimal.")
print("Arredondado para baixo: ", round(numero - 0.5))
prin... |
4e90216eb7fe3331645229e0ea15c084c62dc12a | kirkwood-cis-121-17/exercises | /chapter-9/ex_9_2.py | 2,035 | 4.1875 | 4 | # Programming Exercise 9-2
#
# Program for memory drill of state capitals.
# This program picks a random state name from a dictionary to prompt for a capital,
# compares the user input, updates correct or incorrect score, loops until quit,
# then outputs the number right and wrong.
# to generate random ques... |
7276ad5142a62582af1b85ef70ea493d50ce1ec1 | RaviKumar10052/Product-Relevant-Feature-Extractor | /process_raw_review_data.py | 3,377 | 3.515625 | 4 | # BEFORE RUNNING THIS FILE CREATE A FOLDER NAMED 'list of products' IN THE SAME DIRECTORY AS THIS FILE
# AND REPLACE THE 'main_filename' variable with the file name of the file containing the reviews
import os
import scrap
import nltk
nltk.download('stopwords')
"""
This file takes data from review file and classifie... |
5e6a42bb73b90978d860118afc7d5708e4e24926 | estebanarivasv/AyG-2020-WiFiHistory | /practice/turing-machines/main/menu.py | 1,359 | 3.671875 | 4 | import os
from termcolor import colored
from main.turing_machines import BinaryParityTester, BinaryReplacer
def clear_screen():
if os.name == "posix":
os.system('clear')
else:
os.system('cls')
def string_catcher():
print("-------------------------------------------------------------"
... |
e6d9d7184f6f3d45a5468bca3dd0b9a8f8e32497 | vonce/6-Max-Mackerel | /player.py | 1,182 | 3.65625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 20 15:50:33 2018
@author: Vince
"""
class Player(object):
name = ''
hand = []
stack = 0.0
def __init__(self, name, stack, hand, act = '', betamt = 0.0, board = [], pot = 0.0, bets = [], debt = 0.0, error = ''):
self.nam... |
66ae4a54948194d5276feb08ce2b4925f53f7152 | xingjiehe/Queen | /queen_board.py | 1,943 | 4.09375 | 4 | from winning_move import find_winning_moves
import random
# return all the legal moves from current position(Q_position)
# the legal moves followed by the rule is directed to the final goal, and we can make any step of move
# row, column or diagoanl, but we can't stay in the original point.
# each element in the ret... |
e5cf005122a3cd0a52f31128c7dbfff189841d5d | TrungLuong1194/expert-system | /deductive_reasoning/main.py | 3,800 | 4.03125 | 4 | from collections import defaultdict
class Graph:
"""
Create graph for condition statements
Ex: A -> B
"""
def __init__(self):
self.graph = defaultdict(list)
def add_condition_statement(self, arg1, arg2):
self.graph[arg1].append(arg2)
def print_graph(self):
for k,... |
31c0714a8574d1292549f43fbda7e3210ad04995 | lawrencetheabhorrence/Data-Analysis-2020 | /hy-data-analysis-with-python-2020/part01-e06_triple_square/src/triple_square.py | 304 | 3.96875 | 4 | #!/usr/bin/env python3
def triple(n): return 3 * n
def square(n): return n * n
def main():
for x in range(10):
sq = square(x + 1)
tr = triple(x + 1)
if (sq > tr): break
print('triple({0})=={1} square({0})=={2}'.format(x + 1, tr, sq))
if __name__ == "__main__":
main()
|
8707a00db5a01fb0a1539481fb49161b2dbc296c | matheusms/Python-Training | /outros/Numeros_primos.py | 566 | 3.828125 | 4 | #descobre se um numero n é primo e retorna todos os primos até o numero n
def AllPrimo():
n=int(input("Digite um numero: "))
cont=0
for i in range (2,n):
if n%i==0:
cont+=1
if cont>=2:
print (n, " não é um numero primo")
else:
print (n, " é primo")
print ... |
6a87437eb0cd7ac31f124f2fea4700be6f64b2f7 | pavangeeber/atm_python | /withdraw_money.py | 579 | 3.859375 | 4 | import sys
import json
# takes the selected user dictionary entry as parameter from the calling funtion/file (or main?)
user_info=json.loads(sys.argv[1])# !!!DOES NOT WORK!!! Alternate to be checked
amount=input("Enter amount to dispense:")
amount=int(amount)
for acc_balance in user_info:
if (amount <= user_info[... |
9aee6db6c40af0fb7f299e7341f5f10c77189025 | jzhanay001/Python-Bootcamp | /week_one/odd.py | 247 | 4.03125 | 4 | N=int(input("Enter an upper limit:"))
print("Using for loop")
for number in range(1,N+1):
if number%2!=0:
print(number)
counter=1
print("Using While loop")
while counter<=N:
if counter%2!=0:
print(counter)
counter+=1
|
546b6b2699720de99ce9a3031a64b907d3317cdd | Maxim-Kazliakouski/Python_tasks | /111.py | 231 | 3.8125 | 4 | """word1 = "dasadasdassfa"
i = 0
j = len(word1)-1
print(j)
polindrom = True
while i < j:
if word1[i] != word1[j]:
polindrom = False
i += 1
j -= 1
if polindrom:
print("YES")
else:
print("NO")
"""
|
cc7402823fef6a951048b903bf2a1767b1ebad25 | T-Kalv/Longest-Increasing-Subsequence | /Longest Increasing Subsequence.py | 633 | 4.125 | 4 | """
Longest Increasing Subsequence
You are given an array of integers. Return the length of the longest increasing subsquence (does not have to be necessarily contiguous) in the array.
E.g. [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]
The following input should return 6.
"""
def subsequence(arr):
... |
cd7ee948348bfed6de216f32bbee0f7c9b391d2e | nukhbahmajid/CSC111-Assignments | /CSC111 - Assignment 3.py | 2,143 | 4.1875 | 4 | # ---------------------------------------------------------------------------
# Name: Nukhbah Majid (I didn't collaborate with anyone from class
# on this assignment)
# Filename: Assignment3.py
# Date: 09/29/18
#
# Description: Devise a calculator that allows manipulation user's string
# ... |
912ba0953f554d81655d2c3bd3ae0f061506316a | abretaire/BlackJack-py | /main.py | 7,716 | 3.609375 | 4 | from random import choices, shuffle
from os import system, name
SUITS = ("Coeur", "Carreau", "Trèfles", "Pic")
RANKS = (
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"Valet",
"Dame",
"Roi",
"As",
)
VALUES = {
"2": 2,
"3": 3,
"4": 4,... |
ba783df233a9e90124cb227ea2d8b2ae8308810f | Jonathan1214/learn-python | /BasicExerciseAndKnowledge/w3cschool/n2_how_much_bonus.py | 1,651 | 3.78125 | 4 | #coding:utf-8
# 题目:企业发放的奖金根据利润提成。
# 利润(I)低于或等于10万元时,奖金可提10%;
# 利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;
# 20万到40万之间时,高于20万元的部分,可提成5%;
# 40万到60万之间时高于40万元的部分,可提成3%;
# 60万到100万之间时,高于60万元的部分,可提成1.5%,
# 高于100万元时,超过100万元的部分按1%提成,
# 从键盘输入当月利润I,求应发放奖金总数?
# 一个简单的分段函数问题
# 非常难看的if嵌套... |
0e8ddff2f59cf42b6d27c89f8832c33dd3aaab86 | USCO-CO/test | /guess.py | 717 | 3.859375 | 4 | from random import randint
def getRandomNumber ():
return (randint(0,100))
def askUser ():
num = raw_input("Give me a number: ")
return int(num)
def compGetNum ():
return (randint(0,100))
count = 1
correct = False
print "Welcome to the guessing game. Try to pick a number between 1 and 100 before the comput... |
54f0134d3aa0732c47a27840685a44f7571b39a5 | alisakolot/Coding-and-Testing-Practice- | /linked_list_recursion_practice.py | 2,375 | 4.3125 | 4 | '''Object Orientation'''
# class MyObject:
# def __init__(self, data):
# self.columns = data
# self.rows = None
# self.attribute_name = ...
# class MyCar:
# def __init__(self, automatic, miles):
# self.transmission = automatic #boolean
# self.mileage = miles
# s... |
ec55ddd9f4bab2fc7b70f6433bc2860a7f3c328c | 215836017/LearningPython | /code/005_var.py | 2,740 | 4.25 | 4 | print('变量的命名和使用')
# 标题:变量的命名和使用
'''
在Python中,等号=是赋值语句,可以把任意数据类型赋值给变量,同一个变量可以反复赋值,而且可以是不同类型的变量
'''
'''
变量在程序中就是用一个变量名表示的,变量名必须是大小写英文、数字和_的组合,且不能用数字开头,比如:
a = 1
变量a是一个整数。
t_007 = 'T007'
变量t_007是一个字符串。
Answer = True
变量Answer是一个布尔值True
'''
'''
查看Python中的关键字时:导入keyword模块后,print(keyword.kwlist)即可
'''
'''
在编程中,在遵守命名规则的基... |
06bef2ea25b9149d6f55063ef70fa85cd37ef7a0 | mickstar/leetcode | /02-add-two-numbers.py | 1,252 | 3.6875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
current_l1 = l1
current_l2 = l2
added_ln = ListNode(current_l1.val + current... |
58c5c78fb11ad3ca36e576cea048d8ba28e179c5 | irmoralesb/MLForDevsBook | /Source/Chapter2/01 exploratoryAnalisys.py | 719 | 3.65625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("data/iris.csv")
print(df.columns)
print(df.head(3))
print(df["Sepal.Length"].head(3))
#Descrive the sepal length column
print("Mean: {0}".format(df["Sepal.Length"].mean()))
print("Standard deviation: {}".format(df["Sepal.Length"].std()))
print("Kur... |
14e095bdc674c57885d5ff478c51cdaa92ae3ba5 | Jasonpandiandpm/Logic-Building-Python3.6-and-higher | /Intermediate Level/converter.py | 2,283 | 4.34375 | 4 | '''
22.To convert decimal to binary, octal and Hexa-Decimal
'''
global decimal
decimal = int(input("Enter the Digit: "))
def decimal_binary(decimal):
print('Decimal TO Binary: ',end = ' ')
binary_list = [decimal%2]
while True:
decimal = decimal//2
binary = decimal%2
if de... |
81563f673d1a64d3ede28ec1f2628b5254ec340b | yukkkkun/Outlook_utils | /outlook_basic.py | 2,624 | 3.59375 | 4 | # -*- coding:utf-8 -*-
import win32com.client
import tkinter as tk
import win32com.client
from datetime import datetime
#######################################
###Utils
#######################################
#######################################
###Outlook基本コマンド
#######################################
outlo... |
c610ca0753d4269b23a3c46513d48fd8c25c3d48 | notken12/usaco | /1.3/transform/transform.py | 3,360 | 3.53125 | 4 | """
ID: kendotz1
LANG: PYTHON3
TASK: transform
"""
from io import TextIOBase
fin = open('transform.in', 'r')
fout = open('transform.out', 'w')
def read_square(file: TextIOBase, n: int) -> list:
square = []
# 2d array construct
for i in range(n):
line = fin.readline().strip()
square.appen... |
311da99e855c5664d5e389ea84a0ec8abef5529f | akatzuka/Python-Practice | /Hackerrank/Numpy/Transpose and Flatten.py | 215 | 3.625 | 4 | #!/usr/bin/python
import numpy
n, m = input().split()
arr = []
for _ in range(int(n)):
arr.append([int(i) for i in input().split()])
arr = numpy.array(arr)
print (numpy.transpose(arr))
print (arr.flatten())
|
5a737f32c1a720247ad8d84230577c2b80ae288e | jiangyuwei666/my-study-demo | /Algorithm/sword of offer/3.从头到尾打印链表.py | 508 | 3.5625 | 4 | import random
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def init_node_list(n):
head = ListNode(random.randint(0, 10))
p = ListNode(random.randint(0, 10))
head.next = p
for i in range(n - 2):
q = ListNode(random.randint(0, 10))
p.next = q... |
15591f565f7af7fa51d27140a90344310c835293 | KulosisCode/Python | /python_ky1/шифрование.py | 2,771 | 3.515625 | 4 | # Чыонг Ван Хао
# ИУ7И-11Б
# Шифрование- лаб_9
'''
Программа позволит с использованием меню:
0. Завершить программу
1. Ввод строки.
2. Настройка шифрующего алгоритма.
3. Шифрование строки, используя шифр Виженера.
4. Расшифровывание строки
'''
# f1 = кодовый номер первой буквы алфавита
# s_f = количество бу... |
ccf39a1165a5fe11103914a4f508e31823c077bd | antoniomsantos99/Toybox | /SortingView.py | 1,790 | 3.796875 | 4 | import random
import os
import time
def clearScreen():
os.system('cls' if os.name == 'nt' else 'clear')
def printList(list,tries):
for i in list:
print(str(i).zfill(len(str(max(list)))) +'-| <' + i * '=' + '>')
print('Shuffled ' + str(tries) + ' times!')
def is_sorted(data):
for i in range(l... |
cb9ee04b135c2b5b9f8f327f00990d5bd793f9e1 | bomrena/RaspberryPI_CO2_Monitor | /test_RGB.py | 1,535 | 3.640625 | 4 | import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
blue = 10 # blue LED is connected to Pin 10
red = 12 # red LED is connected to Pin 12
green = 13 # green LED is connected to Pin 13
button = 14 # Button is connected to Pin 14
GPIO.setup(blue, GPIO... |
b3b3081e806a4b0cef8105550c646ec5ad2d7bf6 | penelopy/interview_prep | /Basic_Algorithms/reverse_in_place.py | 393 | 4.375 | 4 | """ Reverse a list in place"""
list_1 = ["dog", "cat", "mouse", "bird", "tree"] # tree, bird, mouse, cat, dog
list_2 = [1, 2, 3, 4, 5, 6, 7]
def reverse_list(my_list):
for i in range(len(my_list)/2): # only need to iterate through half the list
my_list[i], my_list[-1 - i] = my_list[-1 - i], my_list[i]
... |
79d67deee5b4eadf1fb7d13b0923583779425b5f | swayamsudha/python-programs | /Sum_Natural.py | 252 | 4.15625 | 4 | ##WAP to find sum of the natural numbers;
num=int(input("Enter the number:"))
sum=0
temp=num
if(num<0):
print("Not a valid input!!")
else:
while(num!=0):
sum+=num
num-=1
print("The sum of " ,temp, "natural number is" ,sum)
|
f7e040aa80188cbaf24312aa52e8531383d22d6e | Aasthaengg/IBMdataset | /Python_codes/p02724/s628624611.py | 89 | 3.5625 | 4 | X = int(input())
ans = 0
ans += (X // 500) * 1000
X %= 500
ans += (X // 5) * 5
print(ans) |
de01c8fc279684711f11ce33343777ffbc8a67fc | AdaWat/3D-Ray-Tracing-Engine | /stl_reader.py | 2,286 | 3.71875 | 4 | """Read .STL files or accept user input to define spheres"""
from triangle_class import Triangle
from sphere_class import Sphere
import random
filename = input("Enter STL file name from meshes dir or type /s for spheres: ")
""" ↓ you can manually add spheres/triangles into this list ↓ """
objects = [] # li... |
198ba92ad0ffdd884d9dee9f7323fcf07d6d276b | rfbr/Reinforcement_Learning_Project | /main/env/tic_tac_toe.py | 5,086 | 3.828125 | 4 | """
Implements the tic-tac-toe game
"""
import numpy as np
from tqdm import tqdm
class TicTacToe:
def __init__(self, player_1=None, player_2=None):
self.board = np.zeros((3, 3))
self.player_1 = player_1
self.player_2 = player_2
def get_available_positions(self):
available_posi... |
77074c5928cce9cadbc6dfc41f7cf7efa52fdd35 | ebritto25/cascavel | /codigos/atividades/controle_repeticao/at_2_2.py | 219 | 4.1875 | 4 | numero = int(input('Digite um número:\n')) #Lê o número e faz a conversão
if numero < 0:
print('O número é negativo')
elif numero > 0:
print('O número é positivo')
else:
print('O número é zero')
|
9d03f883e2e820d41c9f433c225b437a05a304b7 | slycooper50/Python | /lec2/Ex6.py | 290 | 4 | 4 | print("Enter the number to find how many digits in it and print the sum of digits.")
x = str(input())
r=x[::-1]
count = 0
q = 0
for s in x:
q = q + int(x[count])
count = count + 1
print("The number of digits is: " + str(count))
print("The sum of the digits is: " + str(q))
print(r)
|
715484b52673b7190f0a8dda280173245a9dd77c | WadeCappa/DataStructures | /simpleStack.py | 965 | 3.890625 | 4 |
class Stack():
def __init__(self):
self.stack = [];
def push(self, val):
self.stack.append(val)
def pop(self):
value = len(self.stack)
self.stack.pop()
def top(self):
value = len(self.stack)
return(se... |
2b629c8d6950dede886998b56438f0044523fb71 | bmapa-iscteiul/SudokuSolverV2 | /SudokuSolver.py | 1,766 | 3.734375 | 4 | import time
sudoku = [
[0,0,4,3,0,0,2,0,9],
[0,0,5,0,0,9,0,0,1],
[0,7,0,0,6,0,0,4,3],
[0,0,6,0,0,2,0,8,7],
[1,9,0,0,0,7,4,0,0],
[0,5,0,0,8,3,0,0,0],
[6,0,0,0,0,0,1,0,5],
[0,0,3,5,0,8,6,9,0],
[0,4,2,9,1,0,3,0,0],
]
ROWS = 9
COLS = 9
BOARD_SIZE = len(sudoku[0])
def print_board(boar... |
01deffdc8f6e1043fa923ed56353ead64a402d1e | SvetlanaShutkova/Learning | /withfile3.py | 932 | 3.5 | 4 | def mean_rows(students):
students = students.split(';')
a = []
n = 0
for x in students:
if x.isdigit():
a.append(x)
for i in a:
n += int(i)
return n / len(a)
def mean_columns(z):
print(z)
subject = []
sum_marks = 0
amount_marks = 0
for mark in z:... |
7160f1d64a98b9570be5e9f9e0de3f45d275a374 | domiee13/dungcaythuattoan | /Hackerrank/compareTheTriplets.py | 1,612 | 4.03125 | 4 | # Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty.
# The rating for Alice's challenge is the triplet a = (a[0], a[1], a[2]), and the rating for Bob's challenge is the ... |
89fdd0a7337de83bef7c526de0eb2f1d64acc1ae | celsopa/CeV-Python | /mundo02/ex043.py | 870 | 3.9375 | 4 | # Exercício Python 043: Desenvolva uma lógica que leia o peso e a altura de uma pessoa, calcule seu Índice
# de Massa Corporal (IMC) e mostre seu status, de acordo com a tabela abaixo:
# - IMC abaixo de 18,5: Abaixo do Peso
# - Entre 18,5 e 25: Peso Ideal
# - 25 até 30: Sobrepeso
# - 30 até 40: Obesidade
# - Acima de 4... |
14a172240a298d1ebd959ff7cfd5f9335f576779 | tejakummarikuntla/algo-ds | /jose/Anagram.py | 946 | 3.953125 | 4 | def Anagram(str1, str2):
str1 = str1.remove(' ', '').lower()
str2 = str2.remove(' ', '').lower()
return sorted(str1) == sorted(str2)
def Anagram(str1, str2):
str1 = str1.remove(' ', '').lower()
str2 = str2.remove(' ', '').lower()
return sorted(str1) == sorted(str2)
#########################... |
0f78c8651203eff742e3358e4d37fe7eadcc88f0 | prathimacode-hub/Python-Tutorial | /Beginner_Level/file IO/File IO.py | 1,055 | 4.15625 | 4 | # writing to file
f= open("E:\\Python\\Beginner_Level\\file.txt","w")
f.write("I love Programming")
f.close()
print('\n')
# appending to file
f= open("E:\\Python\\Beginner_Level\\file.txt","a")
f.write("\nI love Coffee")
f.close()
print('\n')
# Reading file
f= open("E:\\Python\\Beginner_Level\\... |
b80e83feffdc2d8efec9629f6769c02fcdbfc302 | jmwoloso/Python_2 | /Lesson 11 - Database Hints/project/attempt_2/testClassFactory.py | 3,891 | 3.671875 | 4 | #!/usr/bin/python3
#
# A Program That Tests the ClassFactory Function
# testClassFactory.py
#
# Created by: Jason Wolosonovich
# 03-30-2015
#
# Lesson 11 - Project Attempt 2
"""
Testing module for the ClassFactory function.
"""
import unittest
from classFactory import build_row
import mysql.connector
from databa... |
8845eedd1bd4e9c78631e817c886f792a9ae4e15 | lidav953/blackjack | /game.py | 4,742 | 3.796875 | 4 | import random
suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs')
ranks = ('Ace', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King')
values = {'Ace':11, 'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':10, 'Queen':10, 'King':1... |
c5e75b12e0908db94ad4a449b9e73afa93755301 | nizguy/my_python_ltp | /pythag.py | 251 | 4.15625 | 4 | import math
a = input("The length of side A: ")
b = input("The length of side B: ")
c = (a * a) + (b * b)
c = math.sqrt(c)
print "{}*{} + {}*{} = {} " .format(a, a, b, b, (a * a) + (b * b))
print "the length of side c is {}" .format(c)
|
6363169c18c23ed75530eeee7996dde32e6d7c68 | Piripant/Graphi | /Code/StringManager.py | 1,976 | 3.5625 | 4 | __author__ = 'Davide'
import re
import Equator
import DrawToFile
delimiters = ["+", "-", "*", "/", "^", "(", ")"]
mchardel = ["(sin)", "(cos)", "(in)", "(log)", "(!)", "(sqrt)"]
parenthesis = ['(']
regexPattern = '|'.join(map(re.escape, delimiters))
multiPattern = '|'.join(mchardel)
def splitnums(list=[]):
list ... |
7b47cfce1b49e665c240f6649f5d141297d4e448 | NickKletnoi/Python | /04_Math/13_Sqrt.py | 1,576 | 3.78125 | 4 |
#Copyright (C) 2017 Interview Druid, Parineeth M. R.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
from __future__ import print_function
import sys
import math
def handle_error... |
0d1319e91c42263ff2ec6dafa15f9aff1361bd8f | JPChaus/InClassGit | /PasswordGen.py | 225 | 3.921875 | 4 | import string
import random
num = (int)(input("Enter a positive numer: "))
def passwordGeneration(num):
characters = string.ascii_letters + string.digits
print(''.join(random.choice(characters) for i in range(num))) |
ecfa35f090cda2df9fcceb94e38f4ad4103d6a0a | keni17j/python | /02_numpy.py | 5,746 | 3.65625 | 4 | """
Numpy.
"""
import math
import sys
import matplotlib.pyplot as plt
import numpy as np
def main():
# Notation settings.
# precision: The number of digits after the decimal point.
# suppress: No exponential notation.
np.set_printoptions(precision=2, suppress=True)
basic()
statistics()
... |
c58fdbd5766ba7e1bf90487c5e14aa42ae87eb25 | AlekseyAbakumov/PythonLearn | /Scripts/Python_HSE/WEEK4/homework/solution19.py | 144 | 3.53125 | 4 | def sumOfSequence():
n = int(input())
if n == 0:
return 0
else:
return n + sumOfSequence()
print(sumOfSequence())
|
c95bac4085d905d2f9aa6a8531870e42ac0925ed | roisinhanlon/hello-world | /ForLoop.py | 177 | 3.90625 | 4 | for element in range (1,10+1):
print (element)
#python starts the range at 0 so counts your range and prints the actual number starting from 0, add +1 to prevent
|
50476f32f8358b9760e41727344824d4f0149697 | rishitrainer/augustPythonWeekendBatch | /learn_day02/Comparisons.py | 295 | 4.03125 | 4 | first = 9
second = 2
# > < >= <= != ==
# Comparision or conditional operators always generate Boolean result
print(">" , first > second)
print("<" , first < second)
print(">=" , first >= second)
print("<=" , first <= second)
print("!=" , first != second)
print("==" , first == second) |
91185fb58ddf299a3eb6e4265576f2116cd2ed57 | 12hys/Project-Euler | /problems/completed/Problem0029.py | 485 | 3.546875 | 4 | import cProfile
def method_one():
numbers = range(2, 101)
answer = []
for aa in numbers:
for bb in numbers:
ans = pow(aa, bb)
if(ans not in answer):
answer.append(ans)
print "Answer: %s" % (len(answer))
def method_two():
numbers = range(2, 101)
... |
557b19797e78278ee005acebc127154fdef9a5fc | chrislevn/Coding-Challenges | /Orange/Mid_term/Palindromic_Series.py | 565 | 3.609375 | 4 | def process_number(n):
output = list(map(int, str(n)))
return output
# def is_palindromic(string):
if __name__ == "__main__":
t = int(input())
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
for i in range(t):
n = int(input())
temp = process_number(n)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.