blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
93173a6bfe98ad20e0492289b53e0fe63ec4bd37 | Alm3ida/resolucaoPythonCursoEmVideo | /desafio35.py | 646 | 4.125 | 4 | """Analise os comprimentos e verifique se é possível formar um triângulo"""
from math import fabs
a = float(input('Digite o valor do primeiro lado: '))
b = float(input('Digite o valor do segundo lado: '))
c = float(input('Digite o valor do terceiro lado: '))
"""
A condição de existência de um triângulo de lados a, b,... |
5cc6138c42835d73adba158d47b6e938bf54292a | Alm3ida/resolucaoPythonCursoEmVideo | /desafio52.py | 448 | 3.859375 | 4 | """
Faça um programa que leia um número inteiro e diga se ele é ou não um número primo.
"""
from time import sleep
t = 0
n = int(input('Digite um número: '))
for c in range (1, n+1):
if (n % c) == 0:
t += 1
print('\033[;33m{}\033[m' .format(c), end=' ')
else:
print('\033[m{}\033[m' .for... |
fc022efeb99cf1ca3f7c4e9b9e8b3754061d8439 | Alm3ida/resolucaoPythonCursoEmVideo | /desafio58.py | 684 | 4.15625 | 4 | """
Melhore o jogo do DESAFIO 028 onde o computador vai "pensar" em um número entre 0 e 10. Só que agora o jogador
vai tentar adivinhar até acertar, mostrando no final quantos palpites foram necessários para vencer
"""
from random import randint
contagem = 0
numC = randint(0, 10)
numP = int(input('''
Estou pensando em ... |
71bf8d6ad51e14531e4e35f94b8d962c9992e23e | Alm3ida/resolucaoPythonCursoEmVideo | /desafio29.py | 448 | 3.921875 | 4 | """
Escreva um programa que leia a velocidade de um carro. Se ele ultrapassar 80km/h, mostre uma mensagem dizendo
que ele foi multado.
A multa custará R$7,00 por cada Km acima do limite.
"""
v = float(input('Olá, digite a velocidade do seu carro:'))
if v > 80:
print('MULTADO! Você excedeu o limite permitido de 80K... |
92146b3c6056ca9ba4fcdcd849a340716999b743 | Alm3ida/resolucaoPythonCursoEmVideo | /desafio42.py | 925 | 4.125 | 4 | """
Refaça o desafio 35 dos triângulos, acrescentando o recurso de mostrar que tipo de triângulo será formado:
- Equilátero: todos os lados iguais
- Isósceles: dois lados iguais
- Escaleno: todos os lados diferentes
"""
import math
a = int(input('Digite o valor do primeiro lado: '))
b = int(input('Digite o valor do seg... |
0d9b196d2c57eade39ac338654d92d3d80caea4e | V1cknesh/Algorithms-In-Python | /2pivotQuicksort.py | 1,720 | 3.828125 | 4 | from random import randint
from random import seed
from random import random
import time
def dual_pivot_sort(array):
n = len(array)
if n<= 1:
return array
elif n == 2:
return sorted(array)
pivot1, pivot2 = sorted([array.pop(0), array.pop(0)])
a= []
b = []
c =... |
580ead57d275c6dc6059a3634dd4e5dec356df90 | Arigatouz/Turn-any-pic-into-ASSCII_CODE | /script.py | 1,056 | 3.703125 | 4 | import PIL.Image
ASCII_CHARS = ["@" ,"#" ,"$","%","?" , "*","+" , ";",":",",","."]
def resize_image(image , new_width=80):
width, heigh = image.size
ratio = heigh /width
new_height = int(new_width *ratio)
resized_image = image.resize((new_width,new_height))
return (resized_image)
def grayify(ima... |
6e90899a5ca1f43f7309461acb3e3e5f99d778da | 20BBrown14/Voice_Channel_Discord_Bot | /commands/emojify.py | 1,092 | 3.640625 | 4 | from client_interactions import delete_message, send_message
"""
Emojify Command
Converts a message to an emojify letter'd message
@param client: The discord client, generally assumed to be the bot user itself
@param message: The message the discord bot is responding to
@result: Sends a message always
@result: Delete... |
3000bdb6d63b1bd38b12cf921eb65e35a2d249f8 | 20BBrown14/Voice_Channel_Discord_Bot | /commands/friday.py | 951 | 3.515625 | 4 | import calendar
from datetime import datetime
from client_interactions import delete_message, send_message
"""
Friday command
Lets the user know if it's Friday or not
@param client: The discord client, generally assumed to be the bot user itself
@param message: The message the discord bot is responding to
@result: S... |
53fd7f929f0b0fb16bc38367e8ff2f5f56f1730b | liuhe37186/alg | /quicksort.py | 347 | 3.90625 | 4 | import random
def quicksort(arr):
if len(arr) < 2:
return arr
else:
pivot = arr[0]
less = []
greater = []
for i in arr[1:]:
if i <= pivot:
less.append(i)
else:
greater.append(i)
return quicksort(less) + [pivot] + quicksort(greater)
arr = []
for i in range(16):
arr.append(random.randint(0,... |
5a71beb4f20672936236da0df40a1c6b9b241e4d | NourozR/Deep-Learning-Datacamp | /single_layer_neural_network.py | 487 | 3.640625 | 4 | import numpy as np
def ReLU(x):
return max(0,x)
input_data = np.array([-2,2])
weights = {'node_0': np.array([1,1]),'node_1': np.array([-1,1]),'output': np.array([2,-1])}
node_0_input = (input_data*weights['node_0']).sum()
node_1_input = (input_data*weights['node_1']).sum()
node_0_output = ReLU(node_0_input)
node_... |
aec33181a9da2e56cec645542bb830ffc996c972 | shayan-azizi/Lipbir-Password-Generator | /main.py | 1,424 | 3.515625 | 4 | import random
import khengool
from tkinter import *
root = Tk()
root.title("Lipbir - Password Generator")
root.iconbitmap("icon.ico")
root.geometry("500x300")
# Define New Rand Function
def new_rand ():
# Clear Entry Box
password_entry.delete(0, END)
# Get Password Length
password_length = int(... |
084e9a1b292ac5e1c19fd5ec878712f9785f3a97 | dandenseven/Phase-2-Exercises | /Flask HW/models/studentrecord.py | 1,688 | 4 | 4 | import sqlite3
class StudentRecords:
tablename = "studentrecords"
dbpath = "../studentrecords.db"
def __init__(self, name, age, homeroom, grade, add_info):
self.name = name
self.age = age
self.homeroom = homeroom
self.grade = grade
self.add_info = add_info
def i... |
adc8efdf74878da8c8ecc886f483697d39c5a226 | Rex0747/pythonUtils | /servidor.py | 1,641 | 3.59375 | 4 | # -*- coding: utf-8 -*-
# Programa Servidor
# www.pythondiario.com
import socket
import sys
tamBloque = 4096
ruta = raw_input('Introduce ruta a donde descargar el fichero\n')
# Creando el socket TCP/IP
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#Enlace de socket y puerto
server_address = ('192.168.... |
42a67ec7b400299fc047c731f2df36993a26973f | sandeeplu/python_lu | /squre_num.py | 203 | 3.921875 | 4 | def get_square_numbers(numbers):
square_numbers = []
for n in numbers:
square_numbers.append(n*n)
return square_numbers
numbers = [2,5,8,9]
a = get_square_numbers(numbers)
print(a)
|
3f749cb2850ed64d6f566e23b75c1df30023bab7 | Divyalok123/CN_Data_Structures_And_Algorithms | /more_problems/Test2_P2_Problems/Minimum_Length_Word.py | 298 | 4.28125 | 4 | #Given a string S (that can contain multiple words), you need to find the word which has minimum length.
string = input()
newArr = string.split(" ")
result = newArr[0]
for i in range(1, len(newArr)):
if(len(newArr[i]) < len(result)):
result = newArr[i]
print(result)
|
1f61c314361e3fcf96150d39b7280561969207bd | LaWRInG/CP3-Naruebase-Polagoth | /Lecture53.py | 99 | 3.59375 | 4 | def vatcal(x):
return x + (x * 7/100)
price = int(input("Input price :"))
print(vatcal(price)) |
9217669f77e2b820e0616abee471c547bee4f505 | LaWRInG/CP3-Naruebase-Polagoth | /Exercise5_1_Naruebase_P.py | 317 | 4 | 4 | x = int(input("Please input the first integer number : "))
y = int(input("Please input the second integer number : "))
result_1 = x + y
result_2 = x - y
result_3 = x * y
result_4 = x / y
print(x, '+', y, "=", result_1)
print(x, "-", y, '=', result_2)
print(x, "*", y, "=", result_3)
print(x, "/", y, "=", result_4)
|
6d2e9a5b9ffa7e95310174268c99ca65c3b3ba6d | stephenmac7/misc-python | /distance.py | 338 | 3.8125 | 4 | from math import sqrt
def distance(co1, co2):
td = sqrt((co1[0] - co2[0])**2 + (co1[1] - co2[1])**2)
return td
co1 = [float(input("Coordinate 1 (x): ")), float(input("Coordinate 1 (y): "))]
co2 = [float(input("Coordinate 2 (x): ")), float(input("Coordinate 2 (y): "))]
answer = round(distance(co1, co2),2)
print("Dis... |
3123668691e367c67fbca6997e5357ebf46d560b | thechriskoka/Learning-APIs | /API Fundamentals/open_notify.py | 586 | 3.609375 | 4 | #Working with Open Notify API which gives access to data about the international space station.
import requests
#A request to know the who is at space currently.
response = requests.get("http://api.open-notify.org/astros.json")
print(response.status_code)
print(response.json())
import json
#Demonstrating how to use... |
0532c7a98e250f25ad3529d988f78e565a9e4d78 | chrismorales/unittest_coverage_talk | /unittest_coverage_talk/example4.py | 429 | 3.875 | 4 | # -*- coding: utf-8 -*-
def peep_hole(username):
"""
A list of special characters is defined and the username cannot have
any special characters defined. If it does return False otherwise return
True.
"""
special_chars = ('@', '#', '$', '%', '^', '&', '*', '(', ')')
for char in special_char... |
6c2f938809a305139e2f6cf8aa753a133f31f21b | AlixBernard/labyrinth_game | /Game/main.py | 5,814 | 3.8125 | 4 | """ File containing the main function and running the game. """
from labyrinth import Labyrinth
from player import Player
from game import Game
def play_game_labyrinth():
""" Start a game of the labyrinth.
Manage players turn until someone win or asked to exit the game.
"""
players = get_players()... |
03be41a110ea55dea226f822edc8165b42915bb9 | Khadbadesneha/pythonPrograms | /percentage.py | 493 | 3.515625 | 4 | """
DS=int(input("Enter the marks"))
Micro=int(input("Enter the number"))
Al=int(input("Enter the marks"))
Java=int(input("Enter the marks"))
net=int(input("Enter the marks"))
n=(DS+Micro+Al+Java+net)*100/500
if 0<=n<40:
print("D")
elif 40<=n<60:
print("C")
elif 60<=n<70:
print("B")
elif 70<=n<80:
pri... |
42c6c400f93fbc6095130a48c1f9ced05cd01d64 | Khadbadesneha/pythonPrograms | /listdivisibleby2&3.py | 147 | 3.828125 | 4 |
list_output=[]
list_range = list(range(1,101,1))
for i in list_range:
if i%2==0 and i%3==0:
list_output.append(i)
print(list_output)
|
decb9962c9a14bde6642df1891976a3388f86ca7 | Khadbadesneha/pythonPrograms | /Armstrongno.py | 224 | 3.8125 | 4 | """
sum=0
num=int(input("Enter the number"))
temp=num
while num>0:
n=num%10
sum=sum+n**3
num=num//10
if sum==temp:
print("armstrong")
else:
print("not armstrong")
"""
a=int(input("djf"))
count(a)
|
33455e6ddef6113a219cb69eebd88eee0178acb8 | Catherine-kay/pythonone | /demo02.py | 2,271 | 3.890625 | 4 | # a = 1
# b = 2
# if a > b:
# print("a大于b")
# else:
# print("a小于b")
"""
grade = float(input("请输入您的成绩:"))
if grade == 60:
print("及格")
elif grade > 60 and grade < 80:
print("中")
elif grade >= 80 and grade < 90:
print("良")
elif grade >=0 and grade < 60:
print("差")
else:
print("优")
"""
# a = "您好... |
2f603de3cf4f4762908d9a7fd32211565f044ad5 | ajbatistav/Practica-3 | /ex3.py | 179 | 3.75 | 4 | def bisiesto(year):
test = year % 4
if test == 0:
print(f"{year} es bisiesto")
else:
print(f"{year} no es bisiesto")
y= int(input("ingrese un año: "))
bisiesto(y) |
f312341382425fcd01f4a489b0fc7e615ac3ba22 | diek/backtobasics | /trade_apple_stocks.py | 1,541 | 4.1875 | 4 |
'''Suppose we could access yesterday's stock prices as a list, where:
The indices are the time in minutes past trade opening time, which was 9:30am local time.
The values are the price in dollars of Apple stock at that time.
So if the stock cost $500 at 10:30am, stock_prices_yesterday[60] = 500.
Write an efficient f... |
b9d96949e1c96ec1c11c84674eafc722c16e0e5e | IRafita/CodeGame | /2/06-Endangered Burl.py | 670 | 3.5625 | 4 | # Only attack enemies of type "munchkin" and "thrower".
# Don't attack a "burl". Run away from an "ogre"!
loop:
enemy = self.findNearestEnemy()
# Remember: don't attack type "burl"!
if enemy.type is "burl":
self.say("I'm not attacking that Burl!")
# The "type" property tells you what kind ... |
295c34c2ab83f19669b6dd972749b63587a46a08 | luojxxx/Coding-Practice | /hackerrank/dynamic_programming/recursive_digit_sum.py | 469 | 3.578125 | 4 | # https://www.hackerrank.com/challenges/recursive-digit-sum
def super_digit(n, k):
def _compute(num):
num_str = str(num)
total = sum(map(int, num_str))
if len(str(total)) == 1:
return total
else:
return _compute(total)
# n, k = [int(x) for x in ra... |
e75a23c6d56d017e236a42262369d5f0cecdc4d8 | luojxxx/Coding-Practice | /hackerrank/interview_prep/is_this_a_binary_search_tree.py | 1,681 | 4 | 4 | # https://www.hackerrank.com/challenges/ctci-is-binary-search-tree
class node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def check(node, depth = 0):
if node.left != None and node.right != None:
stateLeft, valMinLeft, valMaxLeft = check(node.le... |
7cb9061597072e9db433dc83b0874dbac21135d1 | shahroz461/python | /dic.py | 144 | 3.578125 | 4 | x = input()
months = {
"Jan": "january",
"feb": "february",
"mar": "march",
"apr": "april",
"ma":"May"
}
print(months[x])
|
7d6791a09502801e1a388c1fd1916922a9f488b5 | shahroz461/python | /functions.py | 9,091 | 3.9375 | 4 | Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> # print("Hello, World!")
#
# #Method
# def add(a,b):
# c = a + b
# print(c)
#
# add(4,4)
#
#
# print("Hello, wolrd")
#
# if 5 > 2:
# print(... |
2f89c93a5836e92fad7c4ffc2ee6d9a408eb51ab | Pro4tech/Machine-Learning | /Tensorflow/ML1.py | 1,205 | 3.65625 | 4 | import tensorflow as tf
import matplotlib.pyplot as plt
#Setting up of the Training and Testing Models
mnist=tf.keras.datasets.mnist #Import of Datasets
(x_train,y_train),(x_test,y_test)=mnist.load_data() #Loading of Datasets
#print(x_train) #The testing Tuple is being print
x_train=x_train/255.0 #Data is bei... |
4bdda67ee6f585a0d47785d0b03acf80f673dae3 | Pro4tech/Machine-Learning | /Basics/loops.py | 1,476 | 3.859375 | 4 | #Basic Loops
a=14
#If-Else [elif-Combi of both]
if a>0:
print("Positive")
elif a==0:
print("Zero")
else:
print("Negative")
if a<6 and a>4:
print("Num is 5")
elif a<4:
print("Below the range")
else:
print("Above the range")
c=[1,2,3,4,52,7,9,8,5,2]
if 51 in c:
print("element present")
else... |
26b401e44e6348b9331772320f1f3b8d87c2f0ba | LIHTU/mc_python_files | /MyAdventures/csvBuild.py | 1,091 | 3.546875 | 4 | # Intended for designing and building 2D objects along the ground
import mcpi.minecraft as minecraft
import mcpi.block as block
mc = minecraft.Minecraft.create()
GAP = block.AIR.id
WALL = block.GOLD_BLOCK.id
FLOOR = block.GRASS.id
FILENAME = "maze1.csv"
f = open(FILENAME, "r")
''' experiment with the origins.
... |
71adb73c58068b062aa9fa1d3f9e853c2a9ee6bf | LIHTU/mc_python_files | /mcpipy/turtleexample_fractaltree.py | 624 | 3.703125 | 4 | #Minecraft Turtle Example
import minecraftturtle
import mcpi.minecraft as minecraft
import mcpi.block as block
def tree(branchLen,t):
if branchLen > 2:
t.forward(branchLen)
t.up(20)
tree(branchLen-2,t)
t.down(40)
tree(branchLen-2,t)
t.up(20)
t.backward(branch... |
9cab43cee1bc985230a2a99bfb694e9acd4b360d | kevinantonino/CPSproject | /part2.py | 2,343 | 3.546875 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as mp
allData = pd.read_csv("C:/Users/Caleb/Desktop/Poolla Lab/Data/15min_all_homes_data.csv") # Load all the data
filterData = allData[["car1","grid","solar","local_15min","dataid","state"]] # cutting down for the sake of runtime
filterData = filterData.... |
2f4ab5f333119db4140201675e05894b0f6ba178 | AleBark/Python | /listas_stack.py | 844 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 28 00:22:23 2017
@author: aleba
"""
from estruturas3 import LList
class LStack(LList):
def __init__(self, info, next=None):
self.info = info
self.next = next
def insert(self, valor , pos):
if (pos == LList.length(self)):... |
88a0795a50bddd0d2a72e3ec8e83e873b978614e | morphex/IssueDealer | /Products/laf/utilities.py | 1,770 | 3.5625 | 4 | import validators, converters
class simple:
"""Simple class for emulating form records."""
def __init__(self, **keywords):
for key, value in keywords.items():
setattr(self, key, value)
types = (
# Type name, default, index type
('integer', 0, 'FieldIndex', 'An integral value, such as:... |
2b93fe18d0a63723f55fa131e2ff376c22b55bcf | printerscanner/project-euler | /14.py | 304 | 3.71875 | 4 | def collatz_sequence(n):
chain_length = 1
while n > 1:
if n % 2 ==0:
n = n/2
else:
n = 3*n + 1
chain_length+=1
return chain_length
start = 1
MaxCount = 1
for i in range(1,1000000):
count = collatz_sequence(i)
if count >= MaxCount:
MaxCount = count
start = i
print(MaxCount, start)
|
820376ccd1cad5112aa2fe7c187764f186d219bd | diyclassics/marc-pleiades | /data/json_prep.py | 506 | 3.609375 | 4 | import sys
import csv
import json
def convert_csv_to_json():
csvfile = open(sys.argv[1], 'r')
jsonfile = open('books.json', 'w')
fieldnames = ('date', 'precision_code', 'precision', 'region', 'location', 'pleiades_name', 'pleiades_id', 'lat', 'lng', 'title', 'imprint', 'series', 'shelf_location', 'bsn')
... |
e42ccd216094b08192767cfd9a8de13f14b4e9cb | rikeeckhout/python_exercises | /hello_world.py | 535 | 3.84375 | 4 | print("Hello Python world !\n")
message = "Hello Python world!"
print(message)
name="ada lovelace"
print("titlecase : {0}".format(name.title()))
print(name.upper())
print(name.lower())
print("Languages:\n\tJava\n\tC#\n\tPython")
favoritelang = ' Python '
print(favoritelang.rstrip())
print(favoritelang.lstrip())
print(f... |
4e3e614d6cb683ffae977643fab5d1a1c003a58e | wenglihong/learning_python3 | /oop_advance/use_slots.py | 1,188 | 3.9375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Student(object):
__slots__ = ('name', 'age') # 用tuple定义允许绑定的属性名称
class GraduateStudent(Student):
pass
s = Student() # 创建新的实例
s.name = 'Michael' # 绑定属性'name'
s.age = 25 # 绑定属性'age'
print(s.name)
print(s.age)
# ERROR: AttributeError: 'Student' object has no... |
589b13bbbfed3bf959701706ed012a110e26daa3 | Akthamkas/Pythoncodeforces | /Anton and Danik.py | 184 | 3.5 | 4 | n = int(input())
s = input()
count_a = s.count("A")
count_d = s.count("D")
if count_a>count_d:
print("Anton")
elif count_d>count_a:
print("Danik")
else:
print("Friendship") |
f63e6835d3bbb0e329d8f1b8ec2f3acfd24e2163 | Akthamkas/Pythoncodeforces | /Word Capitalization.py | 62 | 3.6875 | 4 | word = input()
word2 = word[0].upper() + word[1:]
print(word2) |
5ca0d9bf7f025148825509465d3a68203264ae81 | KIMINJOONG/python-study | /basic/if.py | 405 | 3.8125 | 4 | # 현재 시간이 12부터 1시이전이면 점심을 먹고
# 3시부터 4시이거나 아프면 휴식을 하고
# 아니면 일을 한다.
time = 12
sick = True
if 12 <= time < 1 and not sick:
print("점심먹으러감")
elif 3<= time <= 4 or sick:
print("휴식 시간")
else:
print("일하는중..")
name = "abcdef"
if "a" in name:
print("있음")
else:
print("없음")
|
cab13387039292514dfffce7873cbbf4c8ed00c9 | shubhii0206/Game_of_Life | /Game_of_Life.py | 4,638 | 3.5625 | 4 | import pygame
import random
from time import sleep
pygame.init()
screen = pygame.display.set_mode((500, 500))
ALIVE, DEAD = "1", "0"
BLACK = (0, 0, 0)
PINK = (255, 0, 126)
colour_names = ["RED","PINK", "BLUE", "GREEN"]
WHITE = (255, 255, 255)
screen.fill(WHITE)
dimensions = [(255, 0, 0), (255, 0, 126), (0, 1... |
b3cdfbe6767b185712a23418b2e8afe8a73690b4 | simozhou/homework_2 | /Sorting/fraudolent_network_activity.py | 914 | 3.640625 | 4 | #!/bin/python3
import sys
def counting_sort(lst):
min_lst = min(lst)
k = (max(lst) - min_lst) + 1
C = [0] * k
for i in lst:
C[i - min_lst] += 1
hold = []
for i, v in enumerate(C):
hold += [i] * v
return hold
def median(arr):
arr = counting_sort(arr)
size = len(ar... |
a0e534755de438b61477b6e823fca6069a07aeb4 | beggerss/algorithms | /Sort/quick.py | 1,410 | 4.1875 | 4 | #!/usr/bin/python2
# Author: Ben Eggers (ben@beneggers.com)
import time
import numpy as np
import matplotlib.pyplot as plt
import itertools
# Implementation of a quicksort in Python.
def main():
base = 10000
x_points = []
y_points = []
for x in range(1, 20):
arr = [np.random.randint(0, base*x) for k in range(b... |
2b97de629b05bf816ec3d1b226ebaf3a913aa6a3 | kriti-ixix/ait-fdp | /python/strings.py | 548 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 6 14:35:36 2021
@author: kritixblaze
"""
name = "Kriti"
s1 = f"Hello my name is {name}"
s2 = "Hello world!"
#String Indexing
print(s2[2])
print(s2[-1])
print(s2[-2])
#String slicing
#[start=0: stop=last (exclusive): step=1]
print(s2[1:5])
print(... |
3577e53287f07dff8833c50ce21816e1127a0164 | kriti-ixix/ait-fdp | /python/student system.py | 372 | 4.03125 | 4 | name = input("Enter your name: ")
print("Welcome to the Management System", name)
number = int(input("Enter number of students: "))
studentsList = []
for i in range(number):
d = {}
d['Name'] = input("Enter name: ")
d['Roll No'] = int(input("Enter roll number: "))
d['Marks'] = float(input("Enter marks:... |
735c3af7599fda8ebefe47bc2f52c91f9db49e21 | kriti-ixix/ait-fdp | /python/input and output.py | 766 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 5 14:33:24 2021
@author: kritixblaze
"""
'''
print('Hello world!')
x = 5
y = 10
z = x + y
print(x, y, z, sep='\n', end="...")
print(f"The sum of {x} and {y} is {z}")
print("The sum of {} and {} is {}".format(x, y, z))
'''
'''
Four data types:
... |
0935cfef574cea05cccc0e0d89db3c9ad95a3fa4 | zhang-xun/codeforce_try | /4C_RegistrationSystem.py | 433 | 3.65625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
n = int(input())
temp = dict()
for i in range(n):
input_name = input().strip()
if input_name not in temp:
temp.setdefault(input_name,0)
print("OK")
else:
outtime = temp.get(input_name)
... |
79a057497d2a5940ecac8e25a853ab7b079f2b66 | zhang-xun/codeforce_try | /3A_shortesPathOfTheKing.py | 743 | 3.65625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
startpoint = [ i for i in input()]
endpoint =[ j for j in input()]
x_distance = ord(startpoint[0]) - ord(endpoint[0])
y_distance = int(startpoint[1]) - int(endpoint[1])
x_abs_distance = abs(ord(startpoint[0]) - ord(endpoint[0]))
y_a... |
a140811b8ac24b2bacd9d2eb3bdcb07186d4d16b | zhang-xun/codeforce_try | /Singleton.py | 842 | 3.84375 | 4 | import threading
import time
def Singleton(cls):
_instance = {}
def _singleton(*argc, **args):
if cls not in _instance:
_instance[cls] = cls(*argc, **args)
return _instance[cls]
return _singleton
@Singleton
class A:
a = 1
def __init__(self, x = 0) -> None:
sel... |
18400c54ac77a96db3a99e0f147eb2a5a9f2c52a | trpatel/python | /tv.py | 2,881 | 4.0625 | 4 | class Television(object):
def __init__(self, __channel, volume, is_on):
self.__channel = __channel
self.volume = volume
self.is_on = is_on
def __str__(self):
reply = "\tTelevision object\n"
if self.is_on == "on":
reply += "-" * 30 + "\n"
reply += "... |
b57c6809b689ceeb7c9e7923291b7f14e2c2fc38 | yoanthiebault/py-gammon | /strategy.py | 1,875 | 3.703125 | 4 | """
Algorithms for evaluating how good a Board is for a given color.
"""
__all__ = ['Weights', 'simply_weighted', 'aggressive', 'safe']
import random
from functools import partial
from collections import namedtuple
from model import Board, SOUTH, NORTH
class Weights(namedtuple('Weights', ['jailed', 'homed', 'exposed... |
b11875ef2ab625fb4d1130af2e2a5a6f424d34d1 | Shasheen8/just_tests | /sum.py | 385 | 3.71875 | 4 | def sum(number):
try:
n= int(number)
if (n<=1):
return (n)
else :
return (n) + sum(n-1)
except ValueError:
return "numbers only"
def test1():
assert sum(5)==15
def test2():
assert sum(16)==136
def test3():
assert not sum (... |
73c1aedc7ee923d8b4ccbe83fd3df61e6cde374f | Shasheen8/just_tests | /unit/palindrome.py | 519 | 3.96875 | 4 | def reverse(s):
return s[::-1]
def isPalindrome(s):
# Calling reverse function
rev = reverse(s)
# Checking if both string are equal or not
if (s == rev):
return True
return False
# Driver code
s = "madam"
ans = isPalindrome(s)
if ans == 1:
print("Yes")
else:
print("No")
de... |
fc7388718bca1ed338e149cca0db47afca7f135c | Shasheen8/just_tests | /palindrome.py | 541 | 4.1875 | 4 | def Palindrome(mystr):
try:
mystr= "malayalam"
rev_mystr= reversed(mystr)
if (mystr == rev_mystr):
return ("The string is a palindrome")
else :
return ("The string is not a palindrome")
except ValueError:
return "valid only for a string"
... |
4938218aa82d8ecbd9949381693f1db147d59b4c | leerieo/coinstrip_python | /coinStripPy.py | 3,618 | 4.0625 | 4 | import random
#Make the Strip
notValidLength = True
while notValidLength:
length = int(input("What is the Strip Length?: "))
if length <= 1:
print("Not a valid strip length")
else:
notValidLength=False
strip=[]
i = 0
while i < length:
strip.append(0)
i+=1
#Insert the Coins
notVali... |
1b1f05958b5669bc5be39df8d76b764f3456839a | tigiridon/python | /algorithms_and_data_structures/HW3/task_7.py | 495 | 3.78125 | 4 | # 7. В одномерном массиве целых чисел определить два наименьших элемента.
# Они могут быть как равны между собой (оба минимальны), так и различаться.
import random
count = 15
massiv = [random.randint(0, count) for _ in range(count)]
print(f'Массив чисел: {massiv}')
massiv.sort()
print(f'Два наименьших элемента {mas... |
84582601e40b7036495a81021cb98a9f823d02e9 | lucas-source/data-science | /Airnbnb Australia/Pycharm_airbnb.py | 3,076 | 3.5625 | 4 | """
:autor = Lucas Rocha Vieira
"""
import pandas as pd
from IPython.display import display
import matplotlib.pyplot as plt
import seaborn as sns
# csv sydney-austrália
df = pd.read_csv("http://data.insideairbnb.com/australia/nsw/sydney/2021-04-10/visualisations/listings.csv")
# Tratativa para mostrar todas as colun... |
6b4aadb5ed62078e012377213208c38ea0a28f0c | NenadPantelic/Special-21-GeeksforGeeks-challenges | /10. Linked Lists/CountTriplets.py | 2,172 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 4 11:25:22 2020
@author: nenad
"""
"""
Problem URL: https://practice.geeksforgeeks.org/contest-problem/count-triplets/1/
Problem description:
Given a sorted linked list of distinct nodes (no two nodes have the same data) and an integer X. Cou... |
01011abf15512e39f7cc98a12fff45d62d99fe18 | NenadPantelic/Special-21-GeeksforGeeks-challenges | /1.Mathematics/m_and_n.py | 689 | 3.53125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 18:36:24 2020
@author: nenad
"""
"""
Problem descritpion: Given two positive integers M and N, after adding M and N if number
of digits in M+N and N are same return N otherwise return M+N.
Problem link: https://practice.geeksforgeeks.org/co... |
c98ff8316715f7c1157452d8eb0cd12848a03a3d | wzc-ob/PycharmProjects | /pcka/时间与日期.py | 285 | 3.765625 | 4 | import datetime
print(datetime.datetime.now())
import time
print(time.time())
t1 = datetime.datetime(2015,3,7,23,14,56,139627)
print(t1)
t2 = datetime.datetime.now()
print(t2)
sub = t2-t1
print(sub.seconds)#时间相差秒数
print(t2.year,t2.month,t2.day,t2.hour,t2.minute,t2.second) |
8379287062b8877c26f36c83be7ffa23fc9f1de7 | wzc-ob/PycharmProjects | /课设/用户注册系统.py | 3,554 | 3.59375 | 4 | # coding:utf-8
import tkinter
import tkinter.messagebox
import sqlite3
con = sqlite3.connect('login.db')
cur = con.cursor()
from register import RegisterWindow
from success import NewWindow
class Window:
def __init__(self):
self.root = tkinter.Tk()
# 创建菜单
self.usernamelabel = tkinter.Label(... |
2ec323a5a920e34520e4e479fc0f3dedef4b442f | Mejikano/Election_Analysis | /skilldrill.py | 507 | 3.71875 | 4 | counties_dict = {"Arapahoe": 369237, "Denver":413229, "Jefferson": 390222}
for key, values in counties_dict.items():
print(f"{key} county has {values} registered voters.")
voting_data = [{"county":"Arapahoe", "registered_voters": 422829}, {
"county":"Denver", "registered_voters": 463353},
{"county":"Jef... |
89142183354a8a6c46f2cd850fa089bc5fb80a0b | esthermsharia/RSA-Factoring-Challenge | /factors | 501 | 4 | 4 | #! /usr/bin/env python3
from sys import argv
def factorize():
with open(argv[1]) as f:
for number in f:
num = int(number)
flag = 0
for i in range(2, int(num / 2) + 1, 1):
if num % i == 0:
print("{:d}={}*{}".format(num, num // i, i))
... |
37ccf5dc35db06103d503150480cfcb6b4d85b9b | victorwongth/hackerrank-solutions | /interview-preparation-kit/dictionaries-and-hashmaps/hash-tables-ransom-note/hash-tables-ransom-note-v2.py | 1,161 | 3.71875 | 4 | # https://www.hackerrank.com/challenges/ctci-ransom-note/problem
#!/bin/python3
import math
import os
import random
import re
import sys
from collections import defaultdict
#
# Complete the 'checkMagazine' function below.
#
# The function accepts following parameters:
# 1. STRING_ARRAY magazine
# 2. STRING_ARRAY n... |
163be611bab372501c867276332fa4e3db4c6592 | victorwongth/hackerrank-solutions | /interview-preparation-kit/sorting/fraudulent-activity-notifications/fraudulent-activity-notifications-v2.py | 2,189 | 3.734375 | 4 | # https://www.hackerrank.com/challenges/fraudulent-activity-notifications/problem
# This solution avoid calculating median repeatedly by maintaining a dictionary
# for easier lookup of the (d // 2) and (d // 2 + 1) expenditure within a period
#!/bin/python3
import math
import os
import random
import re
import sys
fro... |
3c50a395000e9474c8be1cd4233e55137df20293 | jscs9/assignments | /moves.py | 1,681 | 4.1875 | 4 | import random as rand
def request_moves(how_many):
'''
Generates a string representing moves for a monster in a video game.
how_many: number of move segments to be generated. Each segment occurs in a specific
direction with a distance of between 1 and 5 steps. Segment directions
... |
852ae78d9360847fbe9dc631e5df934a78a3110d | zhugezuo/100exercises | /025.py | 165 | 3.703125 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
n = input("n:")
s = 0
for i in range(1, n + 1):
t = 1
for j in range(1, i + 1):
t *= j
s += t
print(s)
|
1ee949dfbd49b2acab96bd86b675f28996dfcaa2 | zhugezuo/100exercises | /036.py | 243 | 3.890625 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import math
def isPrime(n):
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
for i in range(2, 101):
if isPrime(i):
print i
|
8992f4fcabf0a207e10cedad8d6438cf2e87ae20 | zhugezuo/100exercises | /046.py | 98 | 3.59375 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
n = input("n:")
while (n * n > 50):
n = input("n:")
|
2116b519416756fbf1180b3b35ff7434ebbcc37d | MaddoxMaila/Vacuum-Cleaner-Agent-AI | /Vaccum/Main.py | 1,980 | 3.5625 | 4 | from Vaccum.Environment import Environment
from Vaccum.VacuumCleaner import VacuumCleaner
"""
Vacuum Cleaner Agent
Dirty Rooms = 1
Clean Rooms = 0
Environment Class Builds The Rooms Randomly With 10% Chance Of The Room Being Dirty!
Vacuum Will Traverse Each Room Sequentially,
If The Room Is Dirty -> Cleans Th... |
6d23223c1eebc973a47edd8d3d1518dc6d80413e | jungmannn/algorithmStudy | /기본정렬알고리즘/버블정렬_python.py | 683 | 3.828125 | 4 | alist = [4, 5, 2, 9, 7, 3, 6, 1, 8]
# def bubble_sort(anyList):
# for j in range(0, len(anyList)):
# k = len(anyList) - 2
# for i in range(len(anyList) - 1, 0, -1):
# if anyList[i] < anyList[k]:
# temp = anyList[i]
# anyList[i] = anyList[k]
# ... |
c39b6d116d3fcce01d38e6622fe3137670e456c5 | jungmannn/algorithmStudy | /기본정렬알고리즘/선택정렬_python.py | 407 | 3.671875 | 4 |
alist = [3, 4, 9, 8, 7, 5, 2, 6, 1]
# alist.sort()
def selection_sort(anyList):
for i in range(0, len(anyList) - 1):
min_idx = i
for k in range(i + 1, len(anyList)):
if anyList[min_idx] > anyList[k]:
min_idx = k
temp = anyList[i]
anyList[i] = anyList[min... |
5104592c229dcf0e8caab6f08581b501fed7f750 | hmilyvsillusion/Python | /Hello.py | 1,203 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#name=input('Please input a name:')
#print('Hello ', name)
#a=100
#if a>0:
# print(a)
#else:
# print(-a)
#print('I\'m OK')
#n='Hello, \'world\''
#print('%.2f' % 21313.1415926)
#小明原来成绩72,现在成绩85,成绩提升百分比,精确到小数点后一位
#s1=72
#s2=85
#rise=(85-72)*100/72
#print('小明的成绩提升... |
5cf6b062551592f47b631823c0f2f2f64c4c9399 | Mr-k-2020/Leetcode-learning | /0011 盛水最多的容器.py | 574 | 3.640625 | 4 | # _*_coding:utf-8_*_
# @Time : 2020/10/29 16:39
# https://leetcode-cn.com/problems/container-with-most-water/
'''
使用双指针,列表首尾各一个指针,比较头尾指针值大小,把小的那个指针向另一个方向移动
'''
class Solution:
def maxArea(self, height: List[int]) -> int:
i = 0
j = len(height)-1
W_L = []
while i < j:
... |
1ea79eac10fda3ad5ecf8d028d6eafad5ad2af5c | max-sixty/pytest-accept | /examples/add.py | 129 | 3.53125 | 4 | def add(x, y):
"""
Adds two values.
>>> add(1, 1)
3
>>> add("ab", "c")
'cab'
"""
return x + y
|
42412ab9e70d48376aa9977f37730dc21a640b0d | Changxin-Liu/Python-Practice | /a3_files/block.py | 7,832 | 3.5625 | 4 | """
Classes to represent blocks in the game world, and some useful constants
"""
__author__ = "Benjamin Martin and Paul Haley"
__version__ = "1.1.0"
__date__ = "26/04/2019"
__copyright__ = "The University of Queensland, 2019"
from physical_thing import PhysicalThing
# Mappings of block_id to its break table
# A brea... |
1cb656ba8bda903cd4f8e7b05c6ca84eb55943f7 | djaychela/100daysofpythoncode | /day19_21/day19_02.py | 133 | 3.8125 | 4 | from itertools import product
text_string = 'spoon'
for letter in product(text_string, repeat=len(text_string)):
print(*letter) |
40dc93e6ea4ac370358b981ad7a36e566d92ae7b | edsonbonfim/Solution-URI-Online-Judge | /1118 - Várias Notas Com Validação.py | 448 | 3.765625 | 4 | notas = []
while True:
while True :
if len(notas) == 2:
break
n1 = float(input())
if n1 >= 0 and n1 <= 10 :
notas.append(n1)
else :
print("nota invalida")
print("media = {:.2f}".format((notas[0]+notas[1])/2))
notas = []
x = 0
... |
349340c23fc18037f6dd623e8b25b408c5ac712e | Detlaf/Project-Euler | /10_sum_primes.py | 461 | 3.796875 | 4 | '''
David Gries, Jayadev Misra. A Linear Sieve Algorithm for Finding Prime Numbers
'''
N = 2_000_000
lp = [0 for i in range(N+1)] # minimum prime divisors
pr = [] # prime numbers
for i in range(2, N+1):
print(i)
if lp[i] == 0:
lp[i] = i
pr.append(i)
for j in range(len(pr)):
... |
c7c2101591f285e87ae877483bf25f7d4f341431 | lamarrg/Education | /cypher/homework.py | 464 | 4.03125 | 4 | import string
alphabet = string.ascii_lowercase + " "
letters = dict(enumerate(alphabet))
message = "hi my name is caesar"
encoding = {}
encryption_key = 3
for x in letters:
result = (x + encryption_key) % 27
encoding[letters[x]] = result
def caesar(the_message, the_encryption_key):
encoded_message... |
d743d3a14ada3869d20047f59194f3d92cee2d62 | okomeshino/python-practice | /basic/range.py | 398 | 4.125 | 4 | # encoding:utf-8
# 10を引数で渡す → 10回ループ
for i in range(10):
print(i)
if i == 9:
print("------------------------------")
# 2と10を引数で渡す → 2から始まって9までループ
for i in range(2, 10):
print(i)
if i == 9:
print("------------------------------")
# 負の数を渡すことも可能
for i in range(-2, 10):
print(i)
|
bddc6f9bf0aa1ac164b171ae0a4e28f9c3c7c779 | jaylusleep/python-projects | /binary_thing.py | 2,081 | 4.0625 | 4 | '''import csv
import string
# Open the CSV File and read it in.
f = open('countries.csv')
data = f.read()
# Split the data into an array of countries.
countries = data.split('\n')
length = len(countries)
print(countries[1])
print(countries)
# Start your search algorithm here.'''
#SOBS DRAMATICALLY
'''nums=[1,2,3,... |
78adc02c4ebd530abdba59fd6cd86d5ac8000518 | juliuswar/Big_data2 | /Analisis_2Data.py | 5,848 | 3.5625 | 4 | import pandas as pd
import numpy as np
import csv
import re
doc1 = pd.read_csv("pilpres2.csv",sep=';',error_bad_lines=False) #read csv DOC 1
doc2 = pd.read_csv("pilpres2.csv",sep=';',error_bad_lines=False) #read csv DOC 2
# df3 = doc1['text'] #print column text
df_doc1 = pd.DataFrame(data=doc1) #create data frame, ... |
018337176c84e08330e9266f3b8485f9186c968c | LalithNimmala/ProjectEuler | /Problem_0014/Sol0014.py | 338 | 3.578125 | 4 | max_len = 0
def gen_dict(x):
y = []
while x != 1:
if x%2 == 0:
x = int(x/2)
else:
x = (3*x) + 1
y.append(x)
return(y)
for i in reversed(range(1,1000000)):
if len(gen_dict(i)) > max_len:
max_len = len(gen_dict(i))
x = i
y = gen_di... |
f3443c678a843d8ee00567238cbadf5ec6b19722 | VaibhaviMandavia/pythoncodes | /findpair.py | 468 | 3.84375 | 4 | # find pairs of numbers whose sum equals to a given number
list1 = []
list2 = []
x = int(input("enter the number of elements : "))
for i in range(0,x):
y = int(input())
list1.append(y)
value = int(input("enter sum value : "))
for i in range(0,len(list1)):
temp = value-list1[i]
if temp in li... |
352165d42374be40ae24450fd5c82d156220978a | 120photo/pyPayCalculator | /PayCalc.py | 787 | 4.03125 | 4 | #! /usr/bin/env python
# main.py
# python-hours
#
# Created by Jose Juarez on 3/13/09.
# Copyright (c) 2009 Jose Juarez. All rights reserved.
#
hours = float(raw_input('how many hour did you work this pay period?\n'))
rate = float(raw_input('what is your pay rate?\n'))
ot = hours - 80
payment = hours * rate
ot_pay... |
12e966c7bd3a5a446ff4d59853e724a17ac1c804 | chaoguo1949/data-test | /recursion.py | 232 | 3.609375 | 4 | s = ''
def main(a):
global s
for i in a:
if type(i) is list:
main(i)
else:
s += str(i)
if __name__ == '__main__':
a = ['a',1,[12,3,['w','r',[2,'4']]]]
main(a)
print(s)
|
a77fa382d0086b208654915fd2e6dde4d31ce021 | krzysztof-laba/Python_Projects_Home | /Polymorphism/polymorphism_3.py | 1,194 | 4.21875 | 4 | class Document():
def __init__(self, name):
self.name = name
def show(self):
raise NotImplementedError("Subclass must implement abstract method.")
class Pdf(Document):
def show(self):
return "Show pdf documents!"
class Word(Document):
def show(self):
return "Show word ... |
76fdac55bb9ad2f379900b551a243610649c456d | krzysztof-laba/Python_Projects_Home | /Meetings-exercises/Factorial_Def.py | 498 | 3.671875 | 4 | print('hello Krzysztof in my new world')
def wpisz_liczbe():
n = input("Wpisz liczbe: ")
return int(n)
def obliczenia(n):
if 0 <= int(n) <= 1:
print("Silnia liczby: {0}! = 1".format(int(n)))
elif int(n) < 0:
print("Silnia liczby ujemnej nie istnieje!")
obliczenia(wpisz_liczbe(... |
1e9d15bcc381cea35ba1496e94a25c4ed981878f | krzysztof-laba/Python_Projects_Home | /CodeCademy/SchoppingCart.py | 970 | 4.15625 | 4 | class ShoppingCart(object):
"""Creates shopping cart objects for users of our fine website"""
items_in_cart = {}
def __init__(self, customer_name):
self.customer_name = customer_name
print("Customer name:", self.customer_name)
def add_item(self, product, price):
"""Add product to the cart"""
if not product... |
4850286dcf38e4c61b26d664518c4c4cd604dfb6 | krzysztof-laba/Python_Projects_Home | /Python 3 - YouTube/Klasy.py | 882 | 4.03125 | 4 | "TWORZENIE KLAS"
class Calculator():
def __init__(self): # Funkcja init wykonuje się przy tworzeniu instancji klasy.
print("Init !!")
def __del__(self): # Usuwanie/zwalnianie pamieci po wykonaniu clasy.
print("Del !!")
def __str__(self): # Konwertowanie na string i zwracamy 'Hallo' (można... |
62f641a0904014db2401b7b30e5475e373ee9a08 | krzysztof-laba/Python_Projects_Home | /Meetings-exercises/helloword.py | 539 | 4.03125 | 4 | print("Hello my new world Krzysztof")
def add_numbers(a, b):
return (a+b)
print(add_numbers(5,2))
number1=43
pi=3.141
print(float(number1))
print(int(pi))
print("hello MY NEW woRLd Krzysztof".capitalize())
print("123".isalpha())
print("some, cvb, my, world".split(","))
name = "Krzysztof"
machine = "Laba"
print(... |
8e0802314c8d2c9b5c803f06dea02fd68ae12d72 | Jason-Tellez/classification-exercises | /acquire.py | 3,721 | 3.5 | 4 | import pandas as pd
import numpy as np
import os
from env import host, user, password
def get_connection(db, user=user, host=host, password=password):
'''
This function uses my info from my env file to
create a connection url to access the Codeup db.
It takes in a string name of a database as an argume... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.