blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fc42d01d6b1c0f3401ae9a8ba61b2c3c317c0e71 | nurseybushc/Udacity_IntroToSelfDrivingCars | /Module 2 - Bayesian Thinking/parallel_parking.py | 897 | 3.796875 | 4 | # CODE CELL
#
# Write the park function so that it actually parks your vehicle.
from Car import Car
import time
def park(car):
# TODO: Fix this function!
# currently it just drives back and forth
# Note that the allowed steering angles are
# between -25.0 and 25.0 degrees and the
# allowed va... |
c8c5b5a547bd49fb679d4e7c722c5f8286bb0aa4 | bherren98/data-science-is-our-passion | /DataCleanlinessLyrics.py | 1,422 | 4.125 | 4 | #Project 1: for cleaning the data for lyrical data
import pandas as pd
import numpy as np
def main():
myData = pd.read_csv('LyricData.csv', encoding='latin1') #reading csv file directly into panda object
missingValues(myData) #call to find the missing values of the pandas dataframe
def missingValues(... |
a2eb2ddca67ae4ebc1844eff7aec36f2e6adfe37 | YaniLozanov/Software-University | /Python/PyCharm/02.Simple Calculations/09. Celsius to Fahrenheit.py | 343 | 4.3125 | 4 | # Problem:
# Write a program that reads degrees on the Celsius scale (° C) and converts them to degrees Fahrenheit (° F).
# Look for an appropriate formula on the Internet to make the calculations.
# Round the score to 2 decimal places.
celsius = float(input())
fahrenheit = celsius * 9/5 + 32
print(float("{0:.2f}".... |
59ddfaebf0a81f46c28fb72b0445a4533899120c | FelpsFon/curso_python | /1/matematica.py | 96 | 3.59375 | 4 | numero1 = 20
numero2 = 2
resultado = (numero1-numero2)**numero2*6
resultado = 20+3
print(22%5) |
6955a27ab909bd7a55235829d2eb3390cbdb75f8 | rekikhaile/Python-Programs | /4 file processing and list/list_examples.py | 828 | 4.28125 | 4 | # Initialize
my_list = []
print(my_list)
my_list = list()
print(my_list)
## Add element to the end
my_list.append(5)
print(my_list)
my_list.append(3)
print(my_list)
# notice, list can contain various types
my_list.append('Im a string')
print(my_list)
## more operations on lists
my_list.remove('Im a string')
print(my... |
19e092c8f33e2c1f43d577a2c11049ac923a1b91 | claudiosouzabrito/UFPB | /PO/teste.py | 68 | 3.578125 | 4 | a = ['a', 'b', 'c', 'd', 'e']
b = [1,0,1,1,0]
print(a[i] for i in a) |
386a0ce6fd362f09cefc33394e584fec92b7aa5e | MontyPy1212/IronAnne | /Labs/07_Pandas/Old Files/Pandas Lab.py | 6,163 | 4.34375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 17 11:11:47 2021
@author: Annie
"""
li
#Activity 1
#Pandas official documentation: https://pandas.pydata.org/docs/index.html
#1. Aggregate data into one Data Frame using Pandas.
import pandas as pd
print(pd.__version__)
insurance_df = pd.read_c... |
c8809a05f121b19939ce9cb7c5fd033c4535bb9c | swozny13/Python-Introduction | /gui/calculator.py | 2,289 | 3.578125 | 4 | from tkinter import *
class Calculator(Frame):
def __init__(self, master):
super(Calculator, self).__init__(master)
self.grid()
self.create_widgets()
# self.btn7 = 7
def create_widgets(self):
# results
self.results = Text(self, height=3, width=23).grid(row=0, ... |
cdfc8f7b424c29e430db0abb60a1e6f43137f70e | oayllon-bf/pythoncourse | /session_4/example_2.py | 546 | 3.828125 | 4 | """
This is the header of the python file
company name: pythoncourse
"""
# csv reader example
import pandas as pd
counts_dict = {}
# Iterate over the file chunk by chunk
for chunk in pd.read_csv("iris.csv", chunksize=10):
# Iterate over the "species" column in DataFrame
for entry in chunk["species"]:
... |
1695d8516163e5dc3617d0b9f67c900cf9358c44 | PiterPG00/Lista1 | /Quest3.py | 297 | 3.75 | 4 | #PiterPG
divida = float(input("Valor da Divida: "))
atra = int(input("Dias Atrasados: "))
multa = float(input("Valor da Multa por Dia: "))
print("\nValor da Divida R${:.2f} \n\
Dias Atrasados [{}] \n\
Multa de R${:.2f} \n\
Valor Final: R${:.2f}".format(divida,atra,multa,(multa * atra) + divida)) |
41744c74b183c23309de83a8fe1eace51b418b43 | amanda-shlee/tic-tac-toe-python | /tictactoe_computer.py | 3,150 | 3.828125 | 4 | import random
board = [['_', '_', '_'], ['_', '_', '_'], ['_', '_', '_']]
current_player = "X"
count = 0
winner = False
def print_board():
for rows in reversed(board):
print(rows)
print_board()
def valid_check(x, y):
if -1 < x < 3 and -1 < y < 3:
if board[y][x] == "_":
return T... |
388b31973205c3578083769ae3ed4a745f677366 | NataliaNasu/cursoemvideo-python3 | /PacoteDownload/ex058b.py | 555 | 3.84375 | 4 | #outra maneira, com indicações de mais perto...
from random import randint
print("*** \033[31mADIVINHE O NÚMERO\033[m ***")
pc = randint(0, 10)
acertou = False
maior = menor = tentativas = 0
while not acertou:
jogador = int(input('Número? '))
tentativas += 1
if jogador == pc:
acertou = True
els... |
56431d4f85c7c70304b4d1cfb9069d65c5357aa0 | sabrina-boby/practice_some-python | /overriding.py | 264 | 3.5 | 4 |
class Phone:
# def __init__(self):
# print("I am from phone class")
def name(self):
print("my name is boby")
class samsung(Phone):
def __init__(self):
super().name()
print("i am from samsung class")
s=samsung()
|
913278c01669fbf8ca0732a01877a2561221da68 | ajayvenkat10/Competitive | /adaschool.py | 186 | 3.671875 | 4 | t = int(input())
for i in range(t):
line = input().split()
a = int(line[0])
b = int(line[1])
if(a%2==0 or b%2==0):
print("YES")
else:
print("NO")
|
391c1d6b8c48a2f216b18476a66b7038da65f27d | pritishyuvraj/CompetitiveProgramming | /binarySearch/Mortgage.py | 1,510 | 3.78125 | 4 | #Question: TopCoder Statistics (Top Coder Statistics)
#Name: Mortgage
#Link: https://community.topcoder.com/stat?c=problem_statement&pm=2427&rd=4765
#Solution: O(N log n)
#Author: Pritish Yuvraj
import math
class Mortgage:
def __init__(self):
pass
def monthlyPayment(self, loan, interest, term, x = None):
pri... |
aa55af77dd180538db028bc2c45bf2e33dfd725e | hvr9/lab | /L4.ThresholdValue.py | 1,588 | 4.125 | 4 | """Harsha vardhan reddy
121910313001
Matrix to SparseMatrix using functions and taking input from user"""
#input
def input_matrix():
r= int(input("Enter the number of rows: ")) #size of row
c = int(input("Enter the number of columns: ")) #size of col
matrix = []
#taking in elements
... |
f368c92c05d17dc1155d4fa35825d45cea14ef59 | cuyu/leetcode | /225.用队列实现栈.py | 2,043 | 3.9375 | 4 | #
# @lc app=leetcode.cn id=225 lang=python3
#
# [225] 用队列实现栈
#
from collections import deque
# @lc code=start
class MyStack:
def __init__(self):
"""
Initialize your data structure here.
"""
self._in_queue = deque()
self._out_queue = deque()
self._top_in = True
... |
aa8a817dc8a9cdfcc63ee555117fdbe89c9d506f | MatthewZheng/UnitsPlease | /unitClass.py | 3,127 | 3.671875 | 4 | #!/usr/bin/python
_author_ = "Matthew Zheng"
_purpose_ = "Sets up the unit class"
class Unit:
'''This is a class of lists'''
def __init__(self):
self.baseUnits = ["m", "kg", "A", "s", "K", "mol", "cd", "sr", "rad"]
self.derivedUnits = ["Hz", "N", "Pa", "J", "W", "C", "V", "F", "ohm", "S", "Wb",... |
3bd14c1a990439011e62d81d440ec4b44b444190 | YinzhanTang/Week-2-Python-Basics | /erroraise.py | 332 | 4 | 4 | price = int(input('Price: '))
while price <= 0:
print ('Declined.Price must be non negative')
price = int(input('Please input again: '))
print ('price accepted ')
population = int(input('Population: '))
while population <= 0:
raise ValuError ('Declined.Population must be non negative')
print ('population... |
0a509e46940d4bed61b110e5b197e0b45bc0764d | yafeile/Simple_Study | /Simple_Python/standard/decimal/new/decimal_2.py | 141 | 3.5625 | 4 | #! /us/bin/env/python
# -*- coding:utf-8 -*-
import decimal
# Tuple
t = (1,(1,1),-2)
print 'Input :',t
print 'Decimal :',decimal.Decimal(t) |
cae3545a25a77669d3d850b1037a5cc423706796 | christophergeiger3/Tutoring-Pset | /TeachingSet/2BasicOperations.py | 269 | 4 | 4 | """
1. Adding
2. Subtracting
3. Multiplying
4. Dividing
"""
# Do this part in the Python shell
"""
Why doesn't print("Five plus five: " + 5+5) work?
Type casting:
str(), int(), float(), bool(), list(), tuple()
If you don't know what type a value is, do: type()
"""
|
6932166d14f1f7d70aafeb62d811a3ebb51d83a3 | seandlg/liveoverflow | /bin-series/protostar/05-stackfive/exploration/addressrange.py | 138 | 3.703125 | 4 | #!/usr/bin/python
base = 0xbffffdf0
r = range(0xff)
for i in range(-0xff, 0xff+1):
value = base+i
print("0x%X" % value)
|
a0b0562d2889a0c9227975e031ee30df1c1be8f8 | danieltshibangu/Mini-projects | /rps_game.py | 1,934 | 4.375 | 4 | # program lets users play rock paper scissors
#import the random module
import random
# define variables
rock = 1
paper = 2
scissors = 3
player_choice = 0
com_choice = 0
#define limits
CHOICE_LIMIT = 3
# main function will ask for user
# choice and call oppoenent_choice function
# then display the results
def main... |
09a0733aa76c0e73769c3c0692236634f48a75ef | frederico-prog/python | /Scrips-Python/adivinhacao1.py | 2,569 | 3.703125 | 4 | numero_secreto = 42
total_de_pontos = 1000
nivel = int(input('Selecione o nível para o jogo: \n1- 20 Tentativas \n2- 10 Tentativas \n3- 5 Tentativas \n'))
if nivel == 1:
total_tentativa = 20
for rodada in range(0, total_tentativa):
print(f'Tentativa {rodada+1} de {total_tentativa}.')
chute = ... |
ce563d83554c937323dad1109f77b7b835443ceb | guilhermeribg/pythonexercises | /buzz.py | 80 | 3.75 | 4 | num= int(input("Número "))
if num%5==0:
print("Buzz")
else:
print(num) |
93be8b8aad2b00bb457be8916951cc1d1967a0a2 | Ben-Morrison/MyMovieList-Python-Interface | /Main.py | 2,936 | 3.5625 | 4 | from Movie import *
from User import *
from Database import *
import sys
import getpass
import mysql.connector
dbserver = "192.168.1.3"
dbname = "mymovielist_db"
dbuser = "user_defaultddd"
dbpassword = "password"
conn = None
running = False
try:
conn = Database(dbserver, dbname, dbuser, dbpassword)
running = Tru... |
67776ac67015ce159fe2e4c884b0fbf2d7c42717 | Al-Ip/Python-Client---Server-Program | /Python_Client-Server/PythonServer2.py | 1,673 | 3.671875 | 4 | #!/usr/bin/python
# imports
import socket
# create the socket
sock = socket.socket()
print "Socket successfully created"
# setting the server port
port = 1050
#Kill proccesses assosiated with the port number
#sudo fuser -k 1050/tcp
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADD... |
ddd5ca2eb072153759f47c085dc611549fd7376b | stban94diaz/technical_test | /queens2.py | 703 | 3.53125 | 4 | n = 8
def queens(nR=0, solution=[-1 for i in range(n)], cols=[], d45=[], d135=[]):
if nR == n:
m = [['0' for i in range(n)] for j in range(n)]
for i in range(len(solution)):
m[i][solution[i]] = 'x'
for row in m:
print(row)
input("Press key ENTER")
else:
... |
dd6a9a2ac0e6ac0bd0ea7fd6a787170a41f998d7 | qcianna/Python | /lab7/mod1.py | 292 | 3.875 | 4 | import math
def newton(n,k):
if(n >= k):
return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
else:
return 0
def pascal(n):
for i in range(n):
for j in range(n-i):
print(end = " ")
for j in range(i+1):
print(newton(i,j), end=" ")
print()
|
cc4dfe837bf76574c976b880196ac26e0838d864 | kongtianyi/cabbird | /leetcode/search_for_a_range.py | 425 | 3.5625 | 4 |
def searchRange(nums, target):
start=0
end=len(nums)-1
res=[]
while start<=end:
if nums[start]==nums[end]==target:
res.append(start)
res.append(end)
break
if nums[start]!=target:
start+=1
if nums[end]!=target:
end-=1
... |
6628ffedd57fc14840b5be7ee37e875a87507f71 | tommymag/CodeGuild | /python/practice:wall-painting.py | 800 | 4.1875 | 4 | # All our friends are re-painting one wall of their rooms.
# They want us to figure out how much it’s going to cost.
# Assume one gallon of paint covers 400 square feet.
# Ask the user for:
# Width of the wall
# Height of the wall
# How much a gallon of paint costs
# Figure out then print how much it will cost to pai... |
70357d52ddc99d4a2e794cd75b9d8bdf84b2fb08 | gaurang1703/algorithm-practice-python | /python/programmers/lv_one_027.py | 885 | 3.5 | 4 | class Solution:
""" 자릿수 더하기
자연수 N이 주어지면, N의 각 자릿수의 합을 구해서 return 하는 solution 함수를 만들어 주세요.
예를들어 N = 123이면 1 + 2 + 3 = 6을 return 하면 됩니다.
제한사항
N의 범위 : 100,000,000 이하의 자연수
입출력 예
N answer
123 6
987 24
"""
def my_solution(self, n: int) -... |
ac7b18a8dec2eb04b592fc24bdd49b168d186efa | dariianastasia/Instructiuni-de-introducere-aplicatie-practica- | /exercitiul.7.py | 511 | 3.765625 | 4 | """Marina vrea sa verifice daca greutatea si inatimea ei corepunde virstei pe care o are.Ea gasit intr-o carte urmatoarele formule de calcul ale greutatii si inaltimiiunui copil , v fiind virsta:greutatea=2*v+8(in kg), inaltimea= 5*v+80(in cm).Realizati un program care sa citeasca virsta unui copil si sa afiseze greut... |
7e85bb671bcdd14ba7960a2b0565e17408d27bd5 | iezyzhang/Project | /Demo/第一季/基础知识/printformat.py | 2,523 | 3.671875 | 4 |
if __name__ == "__main__":
# num01, num02, = 200, 300
# print("八进制输出:%0o, %0o" % (num01, num02))
# print("十六进制输出:0x%x, 0x%x" % (num01, num02))
# print("二进制", bin(num01), "二进制", bin(num02))
#
# num01 = 1234567.8912
# print("标准的模式:%f" % num01)
# print("保留两位有效数字:%.2f" % num01)
# print... |
74762dd3ea498c6f4f6ff432f0fb3baf9873be93 | Juicechuan/workspace | /cs134-SNLP_PA/SNLP-PA2-HANDIN/evaluator.py | 5,895 | 3.515625 | 4 | """Evaluator functions
You will have to implement more evaluator functions in this class.
We will keep them all in this file.
"""
def split_train_test(classifier, instance_list, proportions):
"""Perform random split train-test
Train on x proportion of the data and test the model on 1-x proportion
return the perfo... |
85cdf30ccb812243c2a1429ce2a0f5d5c8d2ce3f | bus1029/HackerRank | /Python_30days/Day 03_Intro To Conditional Statements/ConditionalStatement.py | 385 | 3.84375 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
if __name__ == '__main__':
N = int(input())
if int(N) % 2 == 1:
print("Weird")
elif int(N) % 2 == 0 and 2 <= int(N) <= 5:
print("Not Weird")
elif int(N) % 2 == 0 and 6 <= int(N) <= 20:
print("Weird")
... |
adfff7b06f3b3031891ceff2683e2dc5235927d8 | Anandhakrishnan2000/Python_PS_Programs | /test.py | 636 | 3.765625 | 4 | from array import *
a = 5
b = 6
a=a+b
b=a-b
a=a-b
print("The value of a is: ")
print(a)
print("The value of b is ")
print(b)
x= int(input("Enter the first number"))
y= int(input("Enter the second number"))
s = x+y
print("The sum is" ,s)
result = eval(input("Enter an expression"))
print(result)
if result%2 == 0:
... |
140fd943d28f9bf159accc19388d535495396d48 | dagomty/datatranslator_tarea | /String Warm-up.py | 2,916 | 4.53125 | 5 | # String Warm-up
# 1. Look at the code in `warmup1.py`. What is the letter at index 14 of `my_str`? Think about this first, then feel free to print just that letter to check your answer.
my_str = 'This String was not Chosen Arbitrarily...'
print(my_str.upper())
a=my_str[13]
print("Letter at index 14 is: "+str(a)... |
bded95306672a7ee20909f5bdf4aa86c1908fc56 | bach2o/NguyenNgocBach-fundamentals-c4e15 | /Session2/sum.py | 59 | 3.734375 | 4 | i=int(input("Enter the number:"))
sum=i*(i+1)/2
print(sum)
|
733e65471d5c4c5361f8912d2932ec615f75939c | abhik12295/Show-me-the-Data-Structure | /problem_1.py | 3,269 | 3.671875 | 4 | # Your work here
# Using Hash map and Doubly Linked List
# LRU CACHE
class Node:
# creating DLL
def __init__(self, key, value):
self.key = key
self.value = value
self.next = None
self.prev = None
class LRU_Cache(object):
# defining DLL nodes
def __init__(self, capacity... |
f61ae959d44a7a58bcaf34518c01998873137f81 | sunil1745/py3 | /asin10.1.py | 327 | 3.53125 | 4 | f=input('Enter file')
fhand=open(f)
mails=dict()
for lines in fhand:
lines=lines.split()
if len(lines)<3 or lines[0]!='From':continue
mails[lines[1]]=mails.get(lines[1],0)+1
#print (mails)
lst=list()
for k,v in mails.items():
lst.append((v,k))
lst=sorted(lst,reverse=True)
#print(lst)
for v,k in lst[0:1]:
prin... |
fb1891bb40a5292cdf8ac86d2102b5a0d985ebe8 | ddx-510/python | /practical4/q4_print_reverse.py | 174 | 4.21875 | 4 | # reverse a number
def reverse_int(n):
if len(n)==1:
return n
return n[-1]+reverse_int(n[:-1])
number = input("Enter a number: ")
print(reverse_int(number))
|
39d620e7a106543406cb5ae1b6e0b3374ee4ba45 | luzzetti/HackerRank_Solutions | /Python/02 - Basic Data Types/[Easy] - Nested Lists.py | 593 | 3.53125 | 4 | if __name__ == '__main__':
L = []
for _ in range(int(input())):
name = input()
score = float(input())
L.append([score,name])
#Codice che mi vergogno di aver scritto
T = []
L.sort(reverse=True)
T.append(L.pop())
for l in L:
if l[0] == T[0][0]:
... |
c70a4bffe0324383fdc34a31df82c28bdc48ba84 | kamiloleszek/2017win_gr_kol3 | /kol1.py | 1,889 | 4.21875 | 4 | #Banking simulator. Write a code in python that simulates the banking system.
#The program should:
# - be able to create new banks
# - store client information in banks
# - allow for cash input and withdrawal
# - allow for money transfer from client to client
#If you can thing of any other features, you can add ... |
cc3761a1130f1b7accf90bcc93119341927c4ebd | Caleb-Mitchell/code_in_place | /discord_extension/Mindset/mindset_build.py | 1,572 | 4.21875 | 4 | import json
START_YEAR = 1800
END_YEAR = 2015
N_YEARS = END_YEAR - START_YEAR + 1
'''
Creates a file mindset.json that stores the data as a giant dictionary.
The dictionary associates years with all data for that year.
Each year is a dictionary from country name to country data. For example:
{
"1800":{
... |
87829c2ef595635d684bf5231e6baea056163c95 | jeongmingang/python_study | /chap05/file02.py | 371 | 3.734375 | 4 | def fopen1(filename):
file = open(filename, "w")
file.write("Hello Python Programming...")
file.close()
def fopen2(filename):
with open(filename, "w") as f:
f.write("Hello Python Programming...!")
# read
def f_read(filename):
with open(filename, "r") as f:
contents = f.read()
r... |
fb053616991964f42293dd721635bdcd159bdb96 | kiteros/TPE-enigma-replica | /rsa/Chiffrement RSA.py | 2,359 | 3.671875 | 4 | from time import *
# encoding: utf-8
# L'utilisateur entre p
p = int(input('Entrez un grand nombre premier p : '))
# L'utilisateur entre q
q = int(input('Entrez un grand nombre premier q : '))
# On calcule n
n = p*q
print ("\nn = ",n,)
# On calcul phi(n)
phiden = (p-1)*(q-1)
print ("\nphi de n ... |
603ba5d0c5dced7fa276dac52783a9d251993b50 | forbearing/mypython | /Scrapy/1/2_网络爬虫/7_动态渲染/2.7_selenium_延时等待.py | 3,319 | 3.796875 | 4 | 延时等待
1:在 Selenium 中, get() 方法会在网页框架家在结束后结束执行,此时如果获取 page_source,
可能并不是浏览器完全加载完成的页面. 如果某些页面有额外的 Ajax 请求.我们在网页中
也不一定能成功获取到, 需要延迟等待一定时间,确保节点都加载出来.
2:等待方式由隐式等待,显式等待
1:隐式等待
1:当使用隐式等待执行测试的时候,如果 Selenium 没有在 DOM 中找到节点,将继续等待,超出
设定时间后,则抛出找不到节点的异常
2:当查找节点而节点没有立即出现的时候,隐式等待将等待一段是时间再查找 DOM, 默认的... |
7066e50821005fb4e3c192688d1f2d553ecc775a | ilinaos/task_1 | /prog.py | 578 | 3.640625 | 4 | # entry = input('I\'m waiting for text...\n').lower()
# num_a=0; num_e=0; num_y=0; num_u=0; num_o=0; num_i=0;
# for i in entry:
# if i=='a': num_a+=1
# elif i=='e': num_e+=1
# elif i=='y': num_y+=1
# elif i=='u': num_u+=1
# elif i=='i': num_i+=1
# elif i=='o': num_o+=1
# print (f'a={num... |
bd6f3d8e132b53814f0829984489fa9ee0b32ecc | pamo18/dbwebb-python | /kmom02/flow/Vilkor-loopar.py | 2,699 | 4.3125 | 4 | #!/usr/bin/env python3
"""
Testar Python
"""
number_of_apples = 9
if number_of_apples > 10:
print("Du har mer än 10 äpplen")
elif number_of_apples <= 10 and number_of_apples > 5:
print("Du blev snabbt mätt och åt bara upp några av dina äpplen")
else:
print("Du har nog varit hungrig och ätit upp dina äpple... |
9473c758fb0bf5035fc4c814a014d0d2ac4268a9 | HersheyChocode/Python_Spring2019 | /AoPS python/permute.py | 1,578 | 4.3125 | 4 | def anagrams(string):
#Base Cases
if len(string)==0:#If list is empty
return []; #Return empty list
elif len(string) == 1: #If list contains one argument
return [string] #Return that list
#Recursive Case
else: #Otherwise...
anagram = [] #Create empty ... |
7d7434a4cc4c6ca507dbcc39c2447c0b3a2d67dd | dgaiero/Resistor-Band-Picture-Creator | /Test Scripts/resistorAlgorithm5Band.py | 4,016 | 3.609375 | 4 | # 2 DECIMAL POINT
#9-3-17
# Initialize resistor colors
BLACK = ['black', 0, 0, 0, 1, None]
BROWN = ['brown', 1, 1, 1, 10, "1%"]
RED = ['red', 2, 2, 2, 100, "2%"]
ORANGE = ['orange', 3, 3, 3, 1000, "3%"]
YELLOW = ['yellow', 4, 4, 4, 10000, "4%"]
GREEN = ['green', 5, 5, 5, 100000, "0.5%"]
BLUE = ['blue', 6, 6, 6... |
0ccd7a7dc7405c6a5a59c7a52a863c35b2040038 | kmju1997/python_study | /Tkinter/파이썬 1-8.py | 226 | 3.78125 | 4 | import random
target_num= random.randint(1,9)
a = input("숫자를 맞춰보세요! ")
a=int(a)
if a!=target_num :
print("땡! 숫자는 %d이였습니다." %target_num)
else :
print("맞췄습니다! 대단해요!")
|
c3e5367addf98290dac86681eee5105ef5ce95ce | rotus/the-python-bible | /function_basic_add.py | 89 | 3.640625 | 4 | # very simple function examples
def add(x,y):
return x + y
a=5
b=10
print(add(a,b))
|
e51b341a6e280acd65ee8e89d69d15b9f3723062 | antonyalexcm/Bridgelabz_updated | /Data_structures/Balanced_parentheses.py | 1,584 | 4.0625 | 4 | import array as arr
class Stack:
def __init__(self):
self.array = arr.array('u',)
self.count = 0
def push(self):
''' Function to push the opening parentheses to the stack'''
self.array.append('(')
self.count +=1
def string_traversal(self,string):
... |
dea0a0490ac4467a22133d68c576811095a337f9 | Taranoberoi/GUI-TKinter | /GUI-1.py | 576 | 3.828125 | 4 | from tkinter import *
# function for button
def funct():
print("Look I got clicked")
root = Tk()
root.title("First Programme")
root.geometry("800x800")
# Label inside the windows
label = Label(root,text="Check this out").grid(row=1,column=2)
label2 = Label(root,text="Check this second statement").grid(row=1,co... |
e6fa0a12b4726ca552b1468ba411642840879c72 | ShubhangiDabral13/Data_Structure | /Matrix/Sparse Matrix/Implementation_Of_Sparse_Matrix_Using_Array/Implement_Sparse_Matrix_Using_Array.py | 862 | 4.3125 | 4 | """
2D array is used to represent a sparse matrix in which there are three rows named as
Row: Index of row, where non-zero element is located
Column: Index of column, where non-zero element is located
Value: Value of the non zero element located at index – (row,column)
"""
def sparse_matrix(arr):
rows,co... |
b46802ad9b76da5fbec9cf5e2fc6f4adef560c66 | Md-Monirul-Islam/Python-code | /Advance-python/Pickling and Unpickling in Python -1.py | 394 | 3.53125 | 4 | import pickle
class Student:
def __init__(self,name,roll,phn):
self.name = name
self.roll = roll
self.phn = phn
def display(self):
print(f"Name : {self.name}, Roll : {self.roll}, Phone : {self.phn}")
with open("student.dat",mode="wb") as f:
Student_1 = Student("Munna","1801... |
5833ce94570b2c7f2708385057c9d8968d3bd393 | youngsheep7/datastructure_algorithm_for_python | /programmer_algorithm_interview/prj/production_codes/linkedlist_reverseorder.py | 1,215 | 3.921875 | 4 | import random
class LinkedListNode:
def __init__(self, data, next):
self.data = data
self.next = next
def __init_linkedlist(hashead, i_length, isdatarandom):
'''
:param hashead:
:param i_length:
:param isdatarandom:
:return:
'''
if hashead == True:
head = LinkedListNode(i_length, None)
cur = head
i... |
a3f5f2a722112234b0af1a23739c7fb204a19334 | JuDa-hku/ACM | /leetCode/81SearchInRotatedSortedArrayII.py | 1,913 | 3.53125 | 4 | class Solution:
# @param {integer[]} nums
# @param {integer} target
# @return {integer}
def search(self, nums, target):
n = len(nums)
if n==0:
return False
return self.searchHelp(nums, target, 0, n-1)
def searchHelp(self, nums, target, start, end):
middle... |
6508f44971692f005c171c7beda5d76a4752e82e | rluong003/chatApp | /createdb.py | 490 | 4.125 | 4 | import sqlite3
with sqlite3.connect("Login.db") as db:
cursor = db.cursor()
cursor.execute(""" CREATE TABLE IF NOT EXISTS user(
username VARCHAR(20) PRIMARY KEY,
password VARCHAR(20) NOT NULL);""")
cursor.execute("""
INSERT INTO user (username,password)
VALUES("p1", "123")
""")
cursor.execute("""
INSERT INTO us... |
624a90e5729410be80668c8497faa63804718513 | robertdavidwest/RealPython | /sql/sqla.py | 1,650 | 4.40625 | 4 | # Create a SQLite3 database and table
# import the sqlite3 library
import sqlite3
import csv
import urllib2
# create a new database if the databasee doesn't already exist
conn = sqlite3.connect("new.db")
# get a cursor object used to execute SQL commands
#cursor = conn.cursor()
# create a table
#cursor.execute("""... |
5f1e635f1e94096caa1b89f6e3216b779e7e1291 | yubajin/FirstPy | /src/Class/Python_test.py | 1,050 | 3.75 | 4 | '''
Created on 2017年8月7日
重写方法__str__对应print()方法, __dir__
创造一个对象,先用__init__函数实例化,然后调用__setattr__给属性赋值,赋值一个属性,调用一下函数
@author: Administrator
'''
class Programer(object):
def __init__(self,name,age):
print('I\'m creating myself!')
self.name = name
if isinstance(age, int):
self.... |
1fab4af240a632f52f61a01f9f7437b67f3f368e | ihaku4/scripts | /pythontest.py | 593 | 3.53125 | 4 | def create_adder(x):
def adder(y):
return x + y
return adder
add_10 = create_adder(10)
result = add_10(3)
print result
print create_adder(123)(123)
print (lambda x: x > 2)(3)
import math
print dir(math)
import time
import thread
def timer(no, interval):
cnt = 0
while cnt<1... |
9a41001bf10f73a79a04cb9483aea65699201ee8 | kayyali18/Python | /Python 31 Programs/Ch 10 Challenges/Guess My Number Challenge (Clears every 5 lines).py | 4,026 | 4.125 | 4 | ## Guess My Number Game GUI
from tkinter import *
import random
# put the random number as a global variable so it doesnt change
# with every function call
number = random.randint (1,100)
class Application (Frame):
""" A GUI Game where a user has to guess a number picked by computer """
def __in... |
b3c96de5c50e7fdde2e7ae70d6d8411ad3824469 | vScourge/Advent_of_Code | /2021/03/2021_day_03_1.py | 2,446 | 4.21875 | 4 | """
--- Day 3: Binary Diagnostic ---
The submarine has been making some odd creaking noises, so you ask it to produce a diagnostic
report just in case.
The diagnostic report (your puzzle input) consists of a list of binary numbers which, when
decoded properly, can tell you many useful things about the conditions of ... |
548ce681456ac4c2d275431f4693a3f46ef1dc64 | AspiringOliver/kkb | /课外程序/pdf跳页截取.py | 537 | 3.546875 | 4 | import PyPDF2 as pdf
inputfile = "input.pdf"
outputfile = "output1.pdf"
reader = pdf.PdfFileReader(inputfile)
pages = [1, 3, 5, 7]
getpages = list()
for i in pages:
page = reader.getPage(i - 1) # page number starts with 0
getpages.append(page)
writer = pdf.PdfFileWriter()
for page in getpages:
writer.ad... |
5a4448a57efd7d71e79c1f652d7fdc8910c92681 | gaoyucai/Python_Project | /数据结构与算法/快速排序.py | 202 | 3.765625 | 4 | # Author:GaoYuCai
def insert_sort(li):
for i in range(1,len(li)):
tmp=li[i]
j=i-1
while j>=0 and li[j] >= tmp:
li[j+1]=li[j]
j=j-1
li[j+1]=tmp |
93db43c5529f82cbf2392ed49296cedc42d0b065 | hooong/TIL | /algorithm/6/1.py | 522 | 3.515625 | 4 | # 최대점수 구하기
def dfs(l, sum, time):
global max_score
if time > m:
return
if l == n:
max_score = max(max_score, sum)
else:
dfs(l+1, sum + problems[l][0], time + problems[l][1])
dfs(l+1, sum, time)
if __name__ == '__main__':
n, m = map(int, input().split())
... |
341dbb67f6b118a7a30aff2e2d6292f28c3f2ff5 | JoaoPauloAntunes/Python | /curso-em-video/mundo1/input.py | 55 | 3.75 | 4 | name = input('Name:')
print('Hello, '+name+"!")
input() |
e9ee787c760d6cb93d4f3fa4ce6af485901e4dca | chelsea-banke/p2-25-coding-challenges-ds | /Exercise_46.py | 497 | 3.984375 | 4 | # Find the maximum number in a jagged array of numbers or array of numbers
def maxNum(array):
for elt in array:
max = 0
if isinstance(elt, list):
maxIf = elt[0]
for val in elt:
if val > max:
maxIf = val
else:
maxElse = e... |
95115bdfb9ee518160c7fff738e5c069c61413ee | SJeliazkova/SoftUni | /Python-Fundamentals/Exercises-and-Labs/list_advance_lab/02_todo_list.py | 305 | 3.796875 | 4 | command = input()
todo_list = [0 for _ in range(11)]
while command != "End":
note = command.split("-")
index = int(note[0])
task = note[1]
todo_list.pop(index)
todo_list.insert(index, task)
command = input()
result = [task for task in todo_list if not task == 0]
print(result) |
85f6e24354205363ba097a3f77cd41238a4ef2d9 | henuliyanying/pythonDemo | /randomNum.py | 103 | 3.59375 | 4 |
#生成指定范围的随机数
import random
#random.randit(a,b) a<=N<=b
print(random.randint(0,9)) |
5cba565fa152d6c937d1b7e390f1c309b7f32514 | srinivas40687/Python_Lab_Assignments | /Lab1/Source/Lab1_D.py | 1,090 | 3.953125 | 4 | #Students who are attending python class are stored in List1:
List_1 = ['Srinivas', 'Kranthi', 'Avinash', 'Sireesha', 'Dinesh', 'Sudheer', 'Pujita']
#Students who are attending Web_Application class are stored in List2:
List_2 = ['Srinivas', 'Girish', 'Dinesh', 'Pujita', 'Prudhvi', 'Sireesha', 'Avinash', 'Yeshwanth', ... |
0cd980129628c00b467627a81e7cd4641cdd7547 | Raneem91/My-projects | /Paper rock .. scissors Game | 3,317 | 4.25 | 4 | #!/usr/bin/env python3
import random
"""This program plays a game of Rock, Paper, Scissors between two Players,
and reports both Player's scores each round."""
moves = ['rock', 'paper', 'scissors']
"""The Player class is the parent class for all of the Players
in this game"""
class Player:
def move(self):
... |
e4eed096aed81be1e76ca69cf12351f6154eae8a | ajayk01/Python-Programing | /Sort/quicksort.py | 515 | 3.9375 | 4 | def part(a,l,h):
i = (l-1 )
pivot = a[h]
for j in range(l,h):
if a[j] <= pivot:
i = i+1
a[i],a[j] = a[j],a[i]
a[i+1],a[h] = a[h],a[i+1]
return ( i+1 )
def quickSort(a,l,h):
if l< h:
pi = part(a,l,h)
quickSort(a,l, pi-1)
quickSort(a, pi+1, h)
a=[];
n = int(input("Enter the no of th... |
197bb561134e36d715306877a49398ff240852b8 | mdzimmerman/advent2018 | /13/day13.py | 6,759 | 3.546875 | 4 | # -*- coding: utf-8 -*-
from enum import Enum
import numpy as np
class Dir(Enum):
UP = 0
LEFT = 1
DOWN = 2
RIGHT = 3
class Cart:
dir_to_char = {
Dir.RIGHT: '>',
Dir.DOWN: 'v',
Dir.LEFT: '<',
Dir.UP: '^'}
cw = {
Dir.RIGHT: Dir.DOWN,
Di... |
68ec65a664d54a36f22878076115dd23278550e5 | medha1511/pythonPprograms | /area.py | 460 | 4.21875 | 4 | #arae and circumference of circle
'''r=2
pi=3.14
print(pi*r**2)'''
'''pi=3.14
r=float(input("enter r"))
a=(pi*r**2)
c=2*pi*r
print("area of circle is",a,"circumference is",c)'''
#arae of square
l=float(input("enter side of square"))
area=l**2
print("arae of sqr is",area)
#arae of rect
l=float(... |
d4cfddd6735e751ff39658a9aa42e87da72d91cc | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_118/2547.py | 866 | 3.640625 | 4 | import math
import sys
def isPalindrome(x):
palindrome = True
xstr = str(x)
for dindex in range(len(xstr)):
if (xstr[dindex] != xstr[-dindex-1]):
palindrome = False
return palindrome
def solve(a,b):
count = 0
x = math.sqrt(a)
xs = int(x * x)
if (x==int(x)) and isPalindrome(int(x)) and isPalindrome(xs):... |
f39fde8d85ed67b93a7c7ccc664758107f38fc8b | Greengon/CheesPuzzleBuilder | /Board/ChessBoard.py | 7,303 | 4.15625 | 4 | from Pieces.NoPiece import NoPiece
from Pieces.Bishop import Bishop
from Pieces.King import King
from Pieces.Knight import Knight
from Pieces.Pawn import Pawn
from Pieces.Queen import Queen
from Pieces.Rook import Rook
class ChessBoard:
"""
This class represent the board itself.
It is build off tiles obje... |
fbf2cbe2781bd0d2abc3f0f2341cdacc4f8f06c4 | MerleLiuKun/my-python | /books/flute-py/chap14/sentence_iter.py | 1,074 | 3.96875 | 4 | """
迭代器模式实现
可迭代的对象一定不能是自身的迭代器
可迭代的队形必须实现 __iter__ 方法,但不能实现 __next__ 方法.
迭代器应该一直可以迭代,迭代器的 __iter__ 方法应该返回自身。
"""
import re
import reprlib
RE_WORD = re.compile(r"\w+")
class Sentence:
def __init__(self, text):
self.text = text
self.words = RE_WORD.findall(self.text)
def __r... |
b1da9fd2dfcc4d0ddc3abd2d7a4f694cd61bcb20 | thangarajan8/misc_python | /search.py | 792 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 27 21:40:44 2020
@author: Thanga
"""
class Search():
def __init__(self,data,search_item):
self.data= data
self.search_item = search_item
pass
def linear(self,search_item=None):
"""
if element is found you will get... |
1b6177d4fc5e40532ca5ee792bd706318781470e | chenyur/projecteuler | /7.py | 548 | 3.921875 | 4 | import math
import sys
import pdb
def prime(index):
current = 2
count = 2
while 1:
for i in range(2, current):
if current % i == 0:
break
if i == current - 1:
if count % 100 == 0:
print(current, count)
coun... |
60fbe0e128e0293877342985692ca10198b305d8 | kateodell/Exercise06 | /wordcount.py | 784 | 4.25 | 4 | # Word Count (Exercise 06)
import operator
from sys import argv
import string
# open, read, and put file into list where each element is delineated by a 'space'
# or period
script, filename = argv
file_text = open(filename)
file_content = file_text.read()
# initialize a dictionary
word_count = {}
words_in_text = fi... |
8a5e6f0cfb3933effedddace26fa905cd5f6b474 | sanjeevseera/Hackerrank-challenges | /Arrey/Array_Manipulation.py | 1,302 | 3.9375 | 4 | """
Input Format
The first line contains two space-separated integers n and m, the size of the array and the number of operations.
Each of the next m lines contains three space-separated integers a, b and k, the left index, right index and summand.
Output Format
Return the integer maximum value in the finished arra... |
33a82e90a28dedcaf3eba131b29ddb78d9059dba | rodrigoc-silva/Python-course | /Lab03_functions/exercise-24.py | 1,937 | 4.5625 | 5 |
#This program calculates the area of a triangle.
def getData() -> (float, float):
'''ask for user input the length and height of the triangle'''
length = float(input("Enter the length of the triangle: "))
height = float(input("Enter the perpendicular height of the triangle: "))
return length, height
... |
42693bc3bda20d6c9d63149607862dd5f68f2d0b | GabrielGalucio/Visualiza-o-de-dados-com-Python | /001_grafico_linha.py | 438 | 4 | 4 | # Criando uma demonstração de gráfico em linha com o mtaplotlib.py
# Importanto a Bilbioteca
import matplotlib.pyplot as plt
x = [1, 2, 5] # Definindo a largura
y = [2, 3, 7] # Definindo a altura
# Inserindo um título no gráfico
plt.title("Gráfico com Matplotlib")
# Inserindo um título no eixo X e Y
plt.xlabel("Eix... |
1c8edcffe4217a5279bbfd34002b49c749f9ae9c | jy-hwang/CodeItPython | /j_z/somclass_bad_variableName.py | 627 | 4.1875 | 4 | # 추상화의 안 좋은 예시
class SomeClass:
class_variable = 0.02
def __init__(self, variable_1, variable_2):
self.variable_1 = variable_1
self.variable_2 = variable_2
def method_1(self, some_value):
self.variable_2 += some_value
def method_2(self, some_value):
if self.variable_2 ... |
0f56cfce193db803403b61faa00270bacfc2d646 | UBC-MDS/prepackPy | /prepackPy/stdizer.py | 4,522 | 4.0625 | 4 | #!/usr/bin/env python
import numpy as np
import pandas as pd
from typing import Any, List
def stdizer(X: Any, method: str = "mean_sd", method_args = None) -> Any:
"""
Standardize a dataset (X) based on a specificed standardization method (method & method_args).
Parameters
----------
X: numpy ... |
90cd163a4eb85435049758fbc9b0ca3112ceb5fa | Liguangchuang/base_knowledge | /数据结构基础/面试遇到——编程真题.py | 5,042 | 3.703125 | 4 | ###############################################################################
'''给定4个点,判断是否能组成正方形'''
def calcu_distance(p1, p2):
return (p1[0] - p2[0])*(p1[0] - p2[0]) + (p1[1] - p2[1])*(p1[1] - p2[1])
def is_square(p1, p2, p3, p4):
distance_list = []
distance_list.append(calcu_distance(p1, p2))
... |
e030024ceae2acdeb22f0270fe929df5b392c292 | choly1985/liuhua_src | /LearningPython-master/SecondWeek/ForthDay/task.py | 2,698 | 3.953125 | 4 | """
@Name: task
@Version:
@Project: PyCharm Community Edition
@Author: liujinjia
@Data: 2017/11/21
"""
# 第二个作业
class Dog:
def __init__(self,weight,height,hair,type):
self.weight = weight
self.height = height
self.hair = hair
self.type = type
type = '狗'
# type 没有被用到
... |
612d74f610fe076c2034cc90d67593f48a071157 | deepaksng29/computer-science-a2 | /pythonLists/Deepak Ex3.py | 701 | 3.9375 | 4 | # Deepak Singh
# Ex.3
students = []
markList = []
sortedMarks = []
def __init__():
studentName = input('Please enter your name: ')
students.append(studentName)
for i in range(10):
mark = int(input('Please enter your mark: '))
markList.append(mark)
sortedMarks = sorted(ma... |
aae80f89b3cce4e6a6045ea2245a65fa688e5ae6 | ritlinguine/linguine-python | /linguine/ops/remove_hashtags.py | 378 | 3.734375 | 4 | """
Removes all hashtag tokens, #, from a text.
Returns the text as a single string separated by spaces.
"""
import re
class RemoveHashtags:
def run(self, data):
results = []
for corpus in data:
temp_corpus = re.sub(r'#', '', corpus.contents)
corpus.contents = temp_corpus
... |
18270095f604a835771290fa502733c3b7ccef7c | shenmishajing/python | /week12/6-4.py | 478 | 3.578125 | 4 | def fib(n):
if n == 0 or n == 1:
return 1
else:
return fib(n-1)+fib(n-2)
def PrintFN(m, n):
res = []
cur = 1
cur_number = fib(cur)
while cur_number < n:
if m <= cur_number <= n:
res.append(cur_number)
cur += 1
cur_number = fib(cur)
return... |
925294e9c03ec5c6ba42ad12c90106a2a7bc4fda | sug5806/TIL | /Python/data_struct/Linked_list/dummy_double_linked_list/double_linked_list.py | 5,500 | 3.546875 | 4 | class Node:
def __init__(self, data=None):
self.__data = data
self.__previous = None
self.__next = None
def __del__(self):
print(f"deleted data : [{self.__data}]")
@property
def data(self):
return self.__data
@data.setter
def data(self, data):
s... |
0e71ddab7103aa963bb99ce00963f12f16cc8eed | sayahna22/sayahna | /python/right shift.py | 73 | 3.578125 | 4 | m=int(input("Enter the no"))
n=int(input("Enter the times"))
print(m>>n)
|
4e6e7c64230eb847fa427d17adeb73b5ba22ed58 | gsrr/leetcode | /hackerrank/Moody_Analytics_Women_in_Engineering_Hackathon/strong_correlation.py | 299 | 3.5625 | 4 | #!/bin/python
import sys
def solve(n, p, d):
# Complete this function
print n, p, d
if __name__ == "__main__":
n = int(raw_input().strip())
p = map(int, raw_input().strip().split(' '))
d = map(int, raw_input().strip().split(' '))
result = solve(n, p, d)
print result
|
993fa53049f1e08e1f4cf786f61040052c6793f9 | ksgifford/data-structures | /src/d_graph.py | 2,523 | 4.15625 | 4 | """Defines data structure for implementing simple directed graph structure."""
# -*- coding: utf-8 -*-
class DGraph(object):
"""Class for implementing our direted graph structure."""
def __init__(self):
"""Initialize an empty dict for storing the graph."""
self._d_graph = {}
def nodes(se... |
078b987ccada7f6daf186226acdc6af757044b18 | Suryamadhan/9thGradeProgramming | /CPLab_15/Practice.py | 526 | 3.78125 | 4 | __author__ = 'Surya'
def main():
check = input("Please enter a String: ")
count = 0
for i in range(0, len(check)):
if check[i] == "s":
count+=1
print("The String " + check + " contains ", count, " ss.")
main()
def contains13(num):
return num % 13 == 0
def main():
number ... |
96790c903012003f86ae0ea9ceabb018b8d3a72f | PierreRust/PythonPerformance_RayTracing | /raytracer/vector.py | 5,898 | 4.40625 | 4 | import math
from typing import Union
class Vector3:
"""
Vector3 represents a 3-dimensional vector.
Standard vector operations are provided: cross product, dot product, norm.
All operators a defined for element-wise and scalar operations.
"""
def __init__(self, x, y, z):
self.x = x
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.