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 |
|---|---|---|---|---|---|---|
f1e1cdefd486ad1d588d88e8551fea770abb98f3 | lakshmi-ramamoorthy/ml_day2 | /exercise3.py | 1,315 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 27 23:01:57 2020
@author: RPS
"""
import pandas as pd
#dataset=pd.read_csv("BlackFriday.csv")
#print(dataset.groupby('Age').count())
"""
print(dataset.shape)
X=dataset.iloc[:,:-1].values
y=dataset.iloc[:,11].values
from sklearn.model_selection import tr... |
b01a5f2af95d63549e32d42d293def21fdc9df25 | Gavinee/Game | /迷宫/显示所走路径的步数的DFS.py | 7,497 | 3.515625 | 4 | """
走迷宫
蓝色的边界 :blue -1
每个格子之间的线:purple
障碍物:yellow 0
可以行走的格子:white 1
起始点 :red 2
终止点 :red 3
通过DFS所经过的路径:black 4
若起始地与终止点有路径可以到达,则将用黑色的路径找出所要经过的点
若起始点与终止... |
7ce9c4e93c541e762c04d9203bfaf1c376408ecc | RubioHaro/ToxicPython | /Toxic.py | 4,069 | 3.796875 | 4 | def liquid_distribution(liters, bottles):
'''
liters: an integer value, litters of hazardous liquid.
bottles: an integer array, bottles sizes to distribute the substance
return minValue: integer, minimum number of bottles needed to distribute all of the liquid
'''
calculator = Distribu... |
d99103049b500922d6d7bab8268503ad8190067c | osudduth/Assignments | /assignment1/assignment1.py | 1,987 | 4.1875 | 4 | #!/usr/bin/env python3
#startswith,uppercase,endswith, reverse, ccat
#
# this will tell you the length of the given string
#
def length(word):
z = 0
for l in word:
z = z + 1
return z
#
# returns true if word begins with beginning otherwise false
#
def startsWith(word, beginning):
for x in r... |
a6122e16478a7d97ba76c8fc75b5257015484787 | TeresaChou/LearningCpp | /A Hsin/Old homework/Operator_bool.py | 420 | 3.765625 | 4 | # Please fill in the quote marks with 'T' or 'F'
# according to different assigned value
T = True
F = False
# This is an exmaple
print(not T, "= False")
# Now try it yourself!
print(F or T, "= True ")
print((not F) and (not not T), "= true ")
print((100-100 == 0), "= true ")
print((15+15 != 30), "= false ")
pri... |
d0524ae575c3cf1697039a0f783618e247a96d18 | TeresaChou/LearningCpp | /A Hsin/donuts.py | 222 | 4.25 | 4 | # this program shows how while loop can be used
number = 0
total = 5
while number < total:
number += 1
donut = 'donuts' if number > 1 else 'donut'
print('I ate', number, donut)
print('There are no more donuts') |
9b3b99a4e7b286aa50009969786bb15100d7e704 | KwesiD/PeepThis | /Display/IP.py | 2,574 | 3.5 | 4 | import requests
#Gets IP address and location data
def getLocation():
ip = postal = 0
city = state = country = "Unknown"
request = None
status_code = 0
status = None #leave as none here. #0 = good to go, 1 = Connection Error, 2 = Timeout Error, 3 = Exceeded Rate Limit -1 = RIP Idk wtf happened
#catch when no wi... |
67665d6c2f8c6299b0655b8f393a8dd7dc54a718 | bsdoshi01/py2048 | /2048.py | 7,029 | 3.890625 | 4 | # This is a game similar to 2048 game but the user gets to decide what is the size of the grid and the final number where the game is supposed to end
import random
import readchar
import copy
from os import system, name
def clear():
if name == "nt":
_ = system('cls')
def game_initialize():
get_correct_game_initi... |
662dd4a205be2999c0cd96a85d569dff2f0b21ca | tpvt99/assignmentNUS | /src/planner/src/task1_dsda_planner.py | 4,029 | 3.8125 | 4 |
from base_planner import Planner
from util import PriorityQueue
from util import euclideanHeuristic, manhattanHeuristic
class DSDAPlanner(Planner):
def __init__(self, world_width, world_height, world_resolution, inflation_ratio):
super(DSDAPlanner, self).__init__(world_width, world_height, world_resolutio... |
878a225f1eb4a2455e7e298f14a374b96065b168 | Kizuki233/learnpython | /test.py | 279 | 3.796875 | 4 | #模块
import sys
#args存储了命令行的所有参数
#python 1.py 25(后面是参数)
def test():
args=sys.argv
if len(args)==1:
print('Hello')
elif len(args)==2:
print('Hello,%s!'% args[1])
else:
print('to many')
print(__name__)
if __name__=='__main__':
test() |
0d7273d3c8f1599fa823e3552d5dfe677f2eb37b | AdarshMarakwar/Programs-in-Python | /Birthday Database.py | 1,456 | 4.15625 | 4 | import sys
import re
birthday = {'John':'Apr 6','Robert':'Jan 2','Wayne':'Oct 10'}
print('Enter the name:')
name=input()
if name in birthday.keys():
print('Birthday of '+name+' is on '+birthday[name])
else:
print('The name is not in database.')
print('Do you want to see the entire databse?'... |
88a16a8780ebee140d4b5ec0503e890f5cf15526 | whbjob/holoviews | /holoviews/element/path.py | 8,682 | 4.21875 | 4 | """
A Path element is a way of drawing arbitrary shapes that can be
overlayed on top of other elements.
Subclasses of Path are designed to generate certain common shapes
quickly and condeniently. For instance, the Box path is often useful
for marking areas of a raster image.
Contours is also a subclass of Path but in... |
c91077369810a7c4c17bd3e7f386e0c565809386 | ConnorMul/RPGame | /main.py | 3,456 | 3.5 | 4 | from classes.game import Person
from classes.magic import Spell
from classes.inventory import Item
# CREATE BLACK MAGIC
fire = Spell("Fire", 10, 100, "black")
thunder = Spell("Thunder", 10, 124, "black")
blizzard = Spell("Blizzard", 10, 100, "black")
meteor = Spell("Meteor", 15, 200, "black")
quake = Spell("Earthquake... |
c9c800f320e87b02a3ff7bb2d2810a7930b7c9ce | paul-blankenbaker/frc-2019 | /minimal-py/math5511/stats.py | 921 | 3.578125 | 4 | class Stats():
""" Helper class to track statistics (min, max, cnt, sum, avg). """
def __init__(self):
self.zero()
def zero(self):
self.__min : float = 0
self.__max : float = 0
self.__cnt : int = 0
self.__sum : float = 0
def getMin(self) -> float:
return... |
28f930d8a067bc2fe1658cd2e53e8de91330832b | yrpol/python-project-lvl1 | /brain_games/games/progression_game.py | 765 | 3.875 | 4 | import random
condition = "What number is missing in the progression?"
def play_round():
progression_length = 10
step = random.randint(1, 7)
first_number = random.randint(1, 15)
hiden_number_index = random.randint(0, progression_length - 1)
progression = ''
correct_answer = ''
current_n... |
c576b2be425a9c014c1bf0de3d62739e6130f62c | mohseenxor/python-example | /doc24.py | 313 | 3.578125 | 4 | class person:
def display(self):
print("hello,this is class person")
class employee(person):
def printing(self):
print("hello,this is derived class emp")
class programmer(employee):
def show(self):
print("hello,another derived class programmer")
p1 = programmer()
p1.display()
p1.printing()
p1.show()
|
b8ac4850721ca0bd0a5ab51ce68202c93dd4a4b4 | mohseenxor/python-example | /doc49.py | 173 | 4 | 4 | num = int(input("enter a positive integer num"))
result = 0
for i in range(len(str(num))):
digit = num%10
result = result + digit
num = num//10
print("sum is ",result)
|
80ced0d706f7dbd490ea4c6c0c351567b86a9439 | mohseenxor/python-example | /ifel.py | 175 | 4.375 | 4 | if 5 > 3:
print("5 is greater than 3")
num = 0
if num > 0:
print("This is positive num")
elif num == 0:
print("Num is zero")
else:
print("This is negative num")
|
f25c4808ca27586f41368646d42dbd2606e6ae66 | mohseenxor/python-example | /doc27.py | 209 | 3.515625 | 4 | class dog:
def sound(self):
print("bow bow")
class cat:
def sound(self):
print("meow")
def makesound(animaltype):
animaltype.sound()
catobj = cat()
dogobj = dog()
makesound(catobj)
makesound(dogobj)
|
54636ee0ea8edd7d3f7da1f3aa28317e62dc170d | fazakus/labspy02 | /Tugas Praktikum 2.py | 451 | 3.875 | 4 | #Input 3 buah bilangan, menggunakan statement if
print ( "Menentukan bilangan terbesar dari 3 bilangan")
a = int ( input ( "Masukkan bilangan A: " ))
b = int ( input ( "Masukkan bilangan B: " ))
c = int ( input ( "Masukkan bilangan C: " ))
if a > b and a > c :
print ( "Jadi bilangan terbesarnya adalah =" , a )
elif b... |
06e857a4077bc6a1c7ace50868de0d922be39ce9 | cmanagoli/happy-numbers | /isHappy.py | 1,239 | 4.03125 | 4 | # Author: Chinmai Managoli
import sys as sys
# Function to add squares of individual digits of a number
def sumSquare(number):
string = str(number)
sum = int(0)
for x in string:
sum += (int(x))**2
return sum
# Function to determine if number is happy
def isHappy(number):
history = []
... |
f6f745b08e14bb8d912565e1efecf3bbf9a437a1 | mnk343/Automate-the-Boring-Stuff-with-Python | /partI/ch3/collatz.py | 321 | 4.1875 | 4 | import sys
def collatz(number):
if number%2 :
print(3*number+1)
return 3*number+1
else:
print(number//2)
return number//2
number = input()
try :
number = int(number)
except ValueError:
print("Please enter integer numbers!!")
sys.exit()
while True:
number = collatz(number)
if number == 1:
break
... |
34ce2cbc18f6a937592da46d748ce032e709cfa4 | Rusvi/pippytest | /testReact/BasicsModule/dictionaries.py | 867 | 4.125 | 4 | #Dictionaries (keys and values)
# simple dictionary
student = {
"name": "Mark",
"student_id": 15163,
"feedback": None
}
#Get values
print(student["name"])# = Mark
#print(student["last_name"]) KeyError if there is no key
#avoid by get("key","default value")
print(student.get("last_name","Unknown_key"))# = ... |
5a32961c7f3bb2807bf7065fd6e094cabab2061f | alina-filippova/MyFileInfoLib | /MyFileInfoLib/MyFileInfoLibClass.py | 2,271 | 3.828125 | 4 | import os
class MyfileInfoLibClass:
"""
This class finds the oldest and earliest created, the biggest and the smallest file from your entered files.
It has got some methods:
GetTheOldestFileName - it chooses the oldest file
GetTheNewestFileName - it chooses the earliest file
GetTheBiggestFile... |
330341e5951a30eb185e87c8cc6e1afa5d3cc3d0 | eFirewall/Firestuff | /Python_Learning/Python Jumpstart/Diario/journal.py | 1,018 | 3.5625 | 4 | """This is the journal module."""
import os
def load(name):
"""Create and load a new journal.
Args:
variable (name): This base name of the journal to load.
Returns:
data: A new journal data structure populated with the file data.
"""
data = []
filename = get_full_pathname(n... |
2551ba2b7412dc79f9eda10a281bd73f54299e66 | BoenShi128/python-learning-class | /day02 快速上手/代码/输出练习题.py | 358 | 3.71875 | 4 | # 1.使用print输出自己的姓名
# print("武沛齐")
# 2.换行输出
# print("春眠不觉晓,")
# print("出处闻啼鸟,")
# print("夜来风雨声,")
# print("花落知多少。")
# 3.一行输出
print("春眠不觉晓,", end="")
print("出处闻啼鸟,", end="")
print("夜来风雨声,", end="")
print("花落知多少。", end="")
|
cf80d7c9446923d06d725ff7face33159112b9ba | BoenShi128/python-learning-class | /day02 快速上手/代码/布尔类型实例.py | 131 | 3.859375 | 4 | name = input("请输入你的用户名:")
if name == "alex":
print("用户登录成功")
else:
print("用户登录失败") |
289a83eeedb62a1af9fc0f783d3db7378f794aa9 | Deniston2K/Forge-Python-basics-Shiny- | /Sum of n numbers.py | 80 | 3.53125 | 4 | n=1
sum=0
while n<=11:
# print(n)
sum=sum+n
n=n+1
print(sum)
|
a432260f329c353712d8b3c16690a8be52bf0834 | bitsunlei/Learn | /venv/ex_stockTimer.py | 633 | 3.546875 | 4 | import time
import sched
schedule=sched.scheduler(time.time,time.sleep)
def func(str1,float1):
print('Time is ',time.time,' | output=',str1,float1)
def timer(n):
print('one minute passed')
while True:
print(time.strftime('%Y-%m-%d %x',time.localtime()))
time.sleep(60)
def printHello():
... |
df6b3bcfd344981b5467acbbd09b30a542abff47 | Sujoy1/Smart-Automated-Soil-Nutrient-Analysis-and-feedback-System-using-Raspberri-pi-Deep-learning-model | /obstacle_avoiding_car.py | 2,868 | 3.5625 | 4 | import RPi.GPIO as GPIO #Import GPIO library
import time
#Import time library
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM) # programming the GPIO by BCM pin numbers
TRIG = 17
ECHO = 27
TRIG1 = 18
ECHO1 = 28
led = 22
m11=16
m12=12
m21=21
m22=20
GPIO.setup(TRI... |
26077227643e14f1a6d5960f62f06e90e88a97e8 | ikunikunkun/Python_Calculation_Method | /code/2/2_2.py | 1,624 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
拉格朗日线性插值和抛物线插值
"""
import numpy as np
import matplotlib.pyplot as plt
def _2_2(X, Y, x, method='linear'):
if method == 'linear':
y = Linear(X, Y, x)
elif method == 'parabola':
y = Parabola(X, Y, x)
return y
def Linear(X, Y, x):
for i in range(le... |
cdb494cd2b5d488598fd0fedf88e55f6115975b8 | weiyunna/webprogramming | /lambda.py | 220 | 3.96875 | 4 | people=[{"name":"Harry","house":"1"},
{"name":"Cho","house":"2"},
{"name":"Draco","house":"3"} ]
def f(person):
return person["name"]
people.sort(key=f)
people.sort(key=lambda person: person["name"])
print(people) |
c1d7711ea53d3456ef585c15e325ea7803ecc409 | weiyunna/webprogramming | /conditions.py | 68 | 3.9375 | 4 | n = int(input("NUmber: "))
if n > 0:
print(f"{n} is positive")
|
805d78256f3094aa57cd0a43ee12c9ed65655546 | denkochin/python_generation_advanced | /Course Solutions.py | 107,595 | 3.640625 | 4 | def easy(a, b):
'''
2.1.2 На easy
На вход программе подаются два целых числа a и b. Напишите программу, которая выводит:
сумму чисел a и b;
разность чисел a и b;
произведение чисел a и b;
частное чисел a и b;
целая часть от деления числа a на b;
остаток о... |
e0f5a7a9989f039601a52885fdb854a51e062ea3 | SimmaLimma/pad2drums | /detection.py | 683 | 3.84375 | 4 | import numpy as np
def stereo_to_mono(stereo_audio):
"""
"""
# Not sure if this is actually left
left_audio = stereo_audio[:, 0]
right_audio = stereo_audio[:, 1]
mono_audio = (left_audio + right_audio ) / 2.0
return mono_audio
def detect_sound(signal, stereo=False):
"""
Checks... |
0da9a31255de863a9ec641b724b63dcbe32fe68e | skamens/advent_of_code_2020 | /day22/crab.py | 3,915 | 3.671875 | 4 | #!/usr/bin/python3
import sys
import re
import math
import functools
import copy
filename = 'day22/input.txt'
class Deck:
def __init__(self):
self.cards = []
self.playerNum = 0
def load(self, file_obj):
line = f_obj.readline()
a = re.match(r'^Player (\d+).*', line)
... |
cbe0bd8fd5a681e5a5c62a90abfae4e5e7757336 | skamens/advent_of_code_2020 | /day17/cubes.py | 2,589 | 3.5 | 4 | #!/usr/bin/python3
import sys
import re
import math
import functools
filename = 'day17/input.txt'
space = {}
def countActiveNeighbors(x, y, z, w, space):
cnt = 0
for x1 in [x-1, x, x+1] :
for y1 in [y-1, y, y+1] :
for z1 in [z-1, z, z+1] :
for w1 in [w-1, w, w+1] :
... |
a0669cca881f97790a79f5ae40634ad0aa7dc814 | tnickerson10/CSD-205 | /Module_6/example.py | 197 | 4.15625 | 4 | userInput = int(input('Enter a number between 0 and 11: '))
print(f'The value entered was {userInput}.')
if userInput > 0 and userInput < 11:
print(f'The value of {userInput} is correct.') |
a8f63040a7d6acc7292f8a35d811750344367447 | BonJarber/AdventOfCode2020 | /05/part_one.py | 901 | 3.609375 | 4 | """
"""
from typing import List
def parse_seat(boarding_pass: str):
row = [i for i in range(0, 128)]
column = [i for i in range(0, 8)]
for letter in boarding_pass:
if letter == "F":
row = row[: len(row) // 2]
elif letter == "B":
row = row[len(row) // 2 :]
e... |
b48ca1f3a91dc03be3c7d1fef03b2c86f4c1380b | BonJarber/AdventOfCode2020 | /18/part_one.py | 1,812 | 3.78125 | 4 | """
"""
from typing import List
def perform_action(total, new, operator):
if operator == "+":
total += new
elif operator == "-":
total -= new
else:
total = total * new
return total
def sum_chars(line: str):
# print("Starting new sum_chars")
curr_total = None
cur... |
2ef3984c577083943be9ef2c47a49d21ef65a48a | BonJarber/AdventOfCode2020 | /11/part_two.py | 2,500 | 3.578125 | 4 | """
"""
import copy
from typing import List
def solve_p1(seat_input: List[str]):
new_grid = []
for row in seat_input:
new_grid.append(list(row.strip()))
changes = None
while changes != 0:
changes = 0
grid = new_grid
new_grid = copy.deepcopy(grid)
for i in ran... |
6cd4ed48798c28e4a4272f4bed268518c6b3b2db | BonJarber/AdventOfCode2020 | /02/part_two.py | 1,671 | 4.03125 | 4 | """
Each policy actually describes two positions in the password, where 1 means the first character, 2 means the second character, and so on. (Be careful; Toboggan Corporate Policies have no concept of "index zero"!) Exactly one of these positions must contain the given letter. Other occurrences of the letter are irrel... |
0eb8624cbe3c84cfbeeb7c3494e271fb00bfb726 | SchoBlockchain/ud_isdc_nd113 | /6. Navigating Data Structures/Temp/geeksforgeeks/geeksforgeeks_BFS_udacity.py | 1,679 | 4.3125 | 4 | # Program to print BFS traversal from a given source
# vertex. BFS(int s) traverses vertices reachable
# from s.
from collections import defaultdict
# This class represents a directed graph using adjacency
# list representation
class Graph:
# Constructor
def __init__(self):
# default dictionary to... |
2f1e04bfad44e2cbbafdbedb4e4f1be5402f6326 | SchoBlockchain/ud_isdc_nd113 | /8. Computer Vision and Classification/Temp/helpers_anim_1.py | 6,394 | 3.625 | 4 | """
Given a list of standardized images (same size),
1. It crops (given)
2. Creates separate red,yellow,green lists based on attached labels
3. Creates HSV for each image and display all as an animation
This helps to get a overview of HSV variations for all images instead of having
to go through one by one
Author: ... |
4d6fe2f798ab9ba7044c9fa94a28681a8fd4ed25 | SchoBlockchain/ud_isdc_nd113 | /6. Navigating Data Structures/Temp/networkx/networkx_4.py | 1,466 | 3.59375 | 4 | from graphviz import Digraph, Source, render
import networkx as nx
import pydot
"""
Aim: Removing edge in a graphviz is not possible directly. So
1. Create a networkx graph
2. Render as Graphviz
3. Change the networkx graph
4. Render again as Graphviz
"""
# 1. Create a networkx graph
def createNx():
G = nx.Gra... |
159e871397fc737ce7261f1df4b7ec1d423603f4 | SchoBlockchain/ud_isdc_nd113 | /3. Working with Matrices/matrix/matrix_exercises.py | 3,154 | 3.609375 | 4 | def get_row(matrix, row):
return matrix[row]
def get_column(matrix, column_number):
column = []
for each_row in range(len(matrix)):
#print('get_column row index:{} col index:{}'.format(each_row,column_number))
column.append(matrix[each_row][column_number])
return column
def dot_product... |
254ad197a30a8aebbc72bf3d14e69512ca8c74ab | arthurono/AarthurOno | /lançamento_foguete.py | 179 | 3.90625 | 4 | #2 Contagem regressiva do lançamento de um foguete.
print("Contagem regressiva")
num = 10
while (num >= 0):
print("Número: ", num)
num = num - 1
print("Fogo!")
|
45b69a1426be7b31f69fb06f8b449fe51b520748 | fiscompunipamplona/satelites-lftapia | /E_Satelite.py | 1,144 | 3.515625 | 4 | #TALLER 1 EJERCICIO DEL SATELITE
#Escribir un programa para estimar h (altura) apartir de un periodo T dado.
G=6.67e-11 #Constante gravitacional
Mt=5.97e24 #Masa de la tierra
Rt=6371e3 #Radio de la tierra
pi=3.1416
T=float(input("Digite el periodo T (en segundos) :"))
h=(((G*Mt*T**2)/(4*pi**2))**(1/3))-Rt #Ecuacion... |
4599cd49493f9376018cee225a14f139fd9c316f | m-tambo/code-wars-kata | /python-kata/counting_duplicate_characters.py | 1,112 | 4.21875 | 4 | # https://www.codewars.com/kata/54bf1c2cd5b56cc47f0007a1/train/python
# Write a function that will return the count of distinct
# case-insensitive alphabetic characters and numeric digits
# that occur more than once in the input string.
# The input string can be assumed to contain only
# alphabets (both uppercase and ... |
981d7190029dca0daa3e234bfe911107e8254442 | G4braG4br/SnpCourse | /task_3.py | 449 | 4.03125 | 4 | def max_odd(lis):
maxi = 0
res = None
for i in lis:
if type(i) == int or type(i) == float:
if i%2 != 0 and abs(i) > maxi:
maxi = int(i)
res = maxi
return res
print(max_odd([1, 2, 3, 4, 4])) # => 3
print(max_odd([21.0, 2, 3, 4, 4])) # => 21
print(max... |
a062040bd8857d84c3c166075837fa32fc2ac0b6 | rom4ikrom/Practical-session-7-8 | /spaces.py | 164 | 3.875 | 4 | user_input = input("Enter a sentence: ")
spaces = 0
for char in user_input:
if char == " ":
spaces = spaces + 1
print(spaces)
|
9e3e0064118cbbdbefb4275a7fa8de05e936570c | ninehundred1/AcmeWine | /AcmeWineModule/AcmeWine/validate_CSV.py | 3,049 | 3.890625 | 4 | import verify_orders
import json
class validate_CSV(object):
"""Class that handles the current order batch. It parses the raw entries, then
formats and generates two lists of dicts, all_orders_details and
all_orders_summary. The latter can be returned in JSON format via get_orders_summary,
the former ... |
bf5ade3c4b757b5483f92475f32aa313ce2c0688 | tyronevb/inference_engine | /src/anomaly_detection_model.py | 3,982 | 3.578125 | 4 | """
Implements the AnomalyDetectorLSTM Class.
This class implements the LSTM-based Deep Learning Model using PyTorch.
"""
__author__ = "tyronevb"
__date__ = "2021"
import torch
import torch.nn as nn
class AnomalyDetectorLSTM(nn.Module):
"""Implements the LSTM Recurrent Neural Network Architecture for performi... |
39dd901b68ac263934d07e52ace777357d37edbc | ProgrammingForDiscreteMath/20170828-karthikkgithub | /code.py | 2,881 | 4.28125 | 4 | from math import sqrt, atan, log
class ComplexNumber:
"""
The class of complex numbers.
"""
def __init__(self, real_part, imaginary_part):
"""
Initialize ``self`` with real and imaginary part.
"""
self.real = real_part
self.imaginary = imaginary_part
def __rep... |
974e943d940a2adbe7b0c50980cb049cbae1bedb | rodolfoghi/urionlinejudge | /python/1134.py | 285 | 3.578125 | 4 | combustiveis = []
while True:
combustivel = int(input())
if combustivel == 4:
break
combustiveis.append(combustivel)
print("MUITO OBRIGADO")
print("Alcool:", combustiveis.count(1))
print("Gasolina:", combustiveis.count(2))
print("Diesel:", combustiveis.count(3))
|
24d661b2f9776d2d006680cb23c7b8fd71881f02 | rodolfoghi/urionlinejudge | /python/1131.py | 748 | 3.65625 | 4 | repeticao = 1
vitorias_inter = 0
vitorias_gremio = 0
empates = 0
while repeticao == 1:
gols_inter, gols_gremio = [int(g) for g in input().split()]
if gols_inter > gols_gremio:
vitorias_inter += 1
elif gols_gremio > gols_inter:
vitorias_gremio += 1
else:
empates += 1
print(... |
aaa4a6c29ec267f25bb7aaddd4cfb8c3bc2aa68f | rodolfoghi/urionlinejudge | /python/1117.py | 227 | 3.703125 | 4 | notas_validas = []
while len(notas_validas) < 2:
nota = float(input())
if nota >= 0 and nota <= 10:
notas_validas.append(nota)
else:
print("nota invalida")
print("media =", sum(notas_validas) / 2)
|
f620265ce47dbfb99a2aeeb15e2875ab0e72f23f | rodolfoghi/urionlinejudge | /python/1172.py | 171 | 3.59375 | 4 | x = []
for i in range(10):
valor = int(input())
if valor <= 0:
valor = 1
x.append(valor)
for i in range(10):
print('X[{}] = {}'.format(i, x[i]))
|
0fd54b9ea1d1849787d18494db202ae9ea06feda | rodolfoghi/urionlinejudge | /python/1149.py | 168 | 3.515625 | 4 | # -*- coding: utf-8 -*-
valores = input().split()
a = int(valores[0])
n = int(valores[len(valores) - 1])
soma = 0
for i in range(0, n):
soma += a + i
print(soma) |
ef37072e07bfe8e30eb45b4fd338a997d89fb738 | rodolfoghi/urionlinejudge | /python/3037.py | 387 | 3.640625 | 4 | def arremessos():
pontos = 0
for a in range(3):
arremesso = input().split()
x = int(arremesso[0])
d = int(arremesso[1])
pontos += x * d
return pontos
n = int(input())
for i in range(n):
pontos_joao = arremessos()
pontos_maria = arremessos()
if pontos_joao > p... |
1e2cd73192a622901ccdf80fea2c3c9fd4e8b8be | captainnatebeard/baseballSimulator | /baseball.py | 4,326 | 3.828125 | 4 | import random
class Team:
def __init__(self, lineup, pitchers, name):
"""
:type lineup: list
:type pitchers: list
:type name: str
"""
self.lineup = lineup
self.pitchers = pitchers
self.name = name
# assert type(lineup) == type([]), "lineup mu... |
d22ce426db1b09538c68f1993aab65a97c87b483 | jellee/cake | /lines.py | 858 | 3.921875 | 4 |
# Write a function to determine if a set of Cartesian points are collinear (lie on same line).
# input: [[1,2], [2,3], ..., [x,y], [3,4]]
# output: true|false
# y = mx + b
# m = slope
# b = y-intercept
# ------------------------------------
# create a line with the first two points
# check rest of the points to see ... |
67c345833ce32ce6d9e3885d2fc6d24845e6efe7 | Louis-Navarro/sudoku | /solver.py | 2,253 | 3.578125 | 4 | import numpy as np
def find_number(grid, row, col, min):
top = row // 3 * 3
left = col // 3 * 3
bottom = top + 3
right = left + 3
square = grid[top:bottom, left:right].reshape(9)
for num in range(min, 10):
if num not in (*grid[row], *grid[:, col], *square):
return num
... |
119bf3648fd50a971a31107f6209d3005d143cb6 | christian-million/practice-python | /04_divisors.py | 473 | 4.03125 | 4 | # 04 Divisors
# Author: Christian Million
# Started: 2020-08-18
# Completed: 2020-08-18
# Last Modified: 2020-08-18
#
# Prompt: https://www.practicepython.org/exercise/2014/02/26/04-divisors.html
#
# Create a program that asks the user for a number and then prints out a list
# of all the divisors of that number. (If yo... |
aef037a891c81af4f75ce89a534c7953f5da6f57 | christian-million/practice-python | /13_fibonacci.py | 653 | 4.1875 | 4 | # 13 Fibonacci
# Author: Christian Million
# Started: 2020-08-18
# Completed: 2020-08-18
# Last Modified: 2020-08-18
#
# Prompt: https://www.practicepython.org/exercise/2014/04/30/13-fibonacci.html
#
# Write a program that asks the user how many Fibonnaci numbers to generate and then generates them.
# Take this opportu... |
1ce0827402bda710f5c96b9f4f36cd156c455825 | D3DeFi/playground | /OpenWeatherMap-Python-Docker/app/getweather.py | 2,252 | 3.59375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Retrieves weather data fromm openweathermap.org for a provided city.
This module doesn't accept any command line arguments, required input is provided via
ENV variables. Where OPENWEATHER_API_KEY holds an API key for the openweathermap.org
service and CITY_NAME specif... |
ff773ee01dc5df58212272af56bf9a9e56c516d7 | tuongnguso03/daochituong-fundamentals-C4T4 | /Session03/RandomInt.py | 101 | 3.53125 | 4 | from random import randint
num = randint(0,100)
print ("A random number (0-100) : {0}". format(num))
|
483c660fec591d852571af2925c359faa5fca03a | tuongnguso03/daochituong-fundamentals-C4T4 | /Session01/Turtle _ConRua.py | 244 | 3.71875 | 4 | from turtle import *
speed(-1)
shape("triangle")
color("blue")
left(45)
for i in range(360):
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(90)
right(359)
mainloop() |
8ce6584bb5c00b08e11a43419a634f81acb32e31 | tuongnguso03/daochituong-fundamentals-C4T4 | /Session02/Homeworks/Turtle1.py | 185 | 3.609375 | 4 | from turtle import *
color("red")
left(30)
for i in range (4):
for k in range (2):
for l in (1,2):
forward(100)
right(l*60)
left(90)
mainloop() |
d60009947221014195f540be0b6e5d3b0e0e6c69 | tuongnguso03/daochituong-fundamentals-C4T4 | /Session05/Homeworks/20.8.1.py | 416 | 3.703125 | 4 | str_input=input("String : ").lower()
alphabet=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
count={}
for char in str_input:
if char in alphabet:
if char in count:
count[char]=count[char]+1
else:
cou... |
6264fd409874381b91a812ddc070dcd8c19ed379 | tuongnguso03/daochituong-fundamentals-C4T4 | /Session04/Homeworks/Sheeps.py | 1,622 | 4 | 4 | from random import randint
def RandomGenerator():
numbers=[]
for i in range (randint(6,10)): #đẻ ngẫu nhiên
numbers.append(randint(1,300))
return numbers
def MonthPass(numbers):
for i in range(len(numbers)):
numbers[i]=numbers[i]+50
return numbers
def She... |
6853cf3fa4775a8e64a1f491c6b8e8ae5b2e60a2 | anselmojuniorjj/numpy_pandas | /pandas/dados_ausentes.py | 569 | 3.609375 | 4 | import numpy as np
import pandas as pd
d = {'A': [1,2,np.nan], 'B': [5,np.nan,np.nan], 'C': [1,2,3]}
df = pd.DataFrame(d)
print(df)
# excluir valores fantantes, por padrão exclui linha (axis=0), td a linha
print(df.dropna())
# excluir coluna axis=1, td a coluna
print(df.dropna(axis=1))
# para excluir qdo houver 2 ... |
728dd0f8827fbbb9ea742b45287502d07c561997 | Lionofpride/Dev_utilits | /PythonBrasil_exer/sequencial/input_soma.py | 161 | 3.84375 | 4 | num1 = input(f'Informe o primeiro número ')
num2 = input(f'Imforme o segundo número ')
soma = int(num1) + int(num2)
print(f'A soma dos números é {soma}')
|
bf59c0ac2077afd2f8bff3c71d81ea102c41aa25 | Lionofpride/Dev_utilits | /PythonBrasil_exer/sequencial/input_conv_mts_cm.py | 124 | 3.765625 | 4 | num = input(f'Informe os metros ')
conv = float(num) * 100
print(f'A conversão do número para centimetro é {conv} cm')
|
88157f9c38fd2952634c6a17f987d0d1a5149965 | git-uzzal/python-learning | /genPrimeNumbers.py | 579 | 4.21875 | 4 | def isPrime(n):
for num in range(2,n):
if n % num == 0:
return False
return True
def get_valid_input():
''' Get valid integer more than equal to 3'''
while(True):
try:
num = int(input('Enter a number: '))
except:
print("I dont undersand that")
continue
else:
if num < 3:
print("Number m... |
5cadcd5b319204266066d8db029c9279fc76faae | geramirez/pyspec | /spec_test.py | 1,657 | 3.546875 | 4 | def get_indentations(self):
indentations = ''
parent = self.parent
while parent:
indentations += '\t'
parent = parent.parent
return indentations
class Describe:
def __init__(self, text, parent=None):
self.text = text
self.parent = parent
def __enter__(self):
... |
68458375020896dc88e355a3b010b73256951478 | praveen9375/Pandas | /Filtering_pandas.py | 632 | 3.84375 | 4 | #In this code exercises, we'll apply various filters to a predefined DataFrame, mlb_df, which contains MLB statistics.
#We'll first filter mlb_df for the top MLB hitting seasons in history, which we define as having a batting average above .300.
top_hitters = mlb_df[mlb_df['BA'] > .300]
#Next we filter for the players ... |
b66be7d96ddcc01087071e3f25c96b827945d537 | praveen9375/Pandas | /file#IO_pandas.py | 670 | 3.65625 | 4 | #First, we'll read from the two CSV files 'stats.csv' and 'salary.csv'. These files contain the stats and salaries, respectively, of various baseball players.
import pandas as pd
stats_df = pd.read_csv('stats.csv')
salary_df = pd.read_csv('salary.csv')
#we can just merge the stats_df and salary_df DataFrames.
import pa... |
6a51991f6f7a2f3d66f63e37a98b7922abc65201 | DjGameKing/Programming | /pe5_2.py | 307 | 3.8125 | 4 | leeftijd = int(input('Geef je leeftijd: '))
nlID = input('Nederlands paspoort: ')
if leeftijd < 18 or nlID == 'no' or nlID == 'nee' or nlID == 'Nee' or nlID == 'No':
print('Helaas, u mag niet stemmen!')
else:
print('Gefeliciteerd, u mag stemmen!')
# Oops, had deze opdracht al gedaan in the vorige |
1c13dbe6bc6de31624058e5f0fd6e176783df0ce | kindasimple/play | /python/sort/Sorting.py | 7,321 | 4.3125 | 4 | #!/usr/bin/python
"""This is a class that implements various sorting algorithms"""
from maths.Number import Number
from maths.Arithmetic import Arithmetic
import math
class Sorting:
"""Class that performs sorting operations using the custom Number
objects and arithmatic class"""
def InsertionSort(self, items) ... |
53e3800e49491c2a658cdb28ac17ec45d79864cf | arovesto/underdanger | /src/util/words.py | 393 | 3.71875 | 4 |
genitive_end_mapping = {
"а": "у",
"я": "ю",
"й": "я",
}
def name_to_genitive(name: str):
for m, e in sorted(genitive_end_mapping.items(), key=lambda x: len(x[0])):
if name.endswith(m):
return e.join(name.rsplit(m, 1))
return name + "а" # TODO иногда здесь я, иногда здесь нужн... |
e5d7cde3aa799b147de8bb6a5ff62b308cac45d5 | ruchit1131/Python_Programs | /learn python/truncate_file.py | 896 | 4.1875 | 4 | from sys import argv
script,filename=argv
print(f"We are going to erase {filename}")
print("If you dont want that hit Ctrl-C")
print("If you want that hit ENTER")
input("?")
print("Opening file")
target=open(filename,'w')
print("Truncating the file.")
target.truncate()#empties the file
print("Writ... |
e5d1047d5b43f408cf38dd65e0e686d6bd45a46d | zarkaltair/Python_algorithms | /Sort_algo/heap_sort_algorithm.py | 930 | 4.03125 | 4 | # heap sort
def heapify(arr, n, i):
# init largest as root
largest = i
# left
l = 2 * i + 1
# right
r = 2 * i + 2
# see if left child of root exists and is greater than root
if l < n and arr[i] < arr[l]:
largest = l
# see if right child of root exists and is greater than ro... |
45ee326ccf24fbe5d032276baa6d8bcb324f644a | louyza/HBSIS-Padawan | /desafio_par_claudia_louyza/pad_651/app/pad_651.py | 599 | 4.0625 | 4 | # Descrição:
#
# Neste desafio, você é solicitado a colocar todos os dígitos de um número ao quadrado.
#
# Por exemplo, se executarmos 9119 por meio da função, 811181 sairá, porque 9 2 é 81 e 1 2 é 1.
#
# Nota: A função aceita um número inteiro e retorna um número inteiro
class Quadrado:
def __init__(self):
... |
b78447afb963e71811e94415ea3942aa0f6217cb | Sgoal2/Sprint-Challenge--Graphs | /graph_dfs_debug/graph.py | 2,089 | 3.5 | 4 | """
Simple graph implementation compatible with BokehGraph class.
"""
class Vertex:
def __init__(self, label, component=-1):
self.label = str(label)
self.component = component
def __repr__(self):
return 'Vertex: ' + self.label
"""Trying to make this Graph class work..."""
class Gra... |
05aa1e3615d3804b1ebc43ed204f70b854b64431 | nvathu/python_learn | /demo01.py | 298 | 3.84375 | 4 | def main():
print("hello")
a = 10
print("a =",a)
a = "Hello world"
print("a =",a)
b = input("Enter a number b = ")
print("b =",int(b)+8)
c =int(input("Enter a number c = "))
print("c = ", c + 9)
if __name__ == "__main__":
main() |
4190ecc6095757d863e2f6b565c72159e09d61ad | nvathu/python_learn | /demo13.py | 521 | 3.890625 | 4 | def reserve(n):
reserveNum = 0
while n > 0 :
reserveNum = (reserveNum * 10) + (n % 10)
n= n // 10
return reserveNum
def isSymmetry(n):
reservenum=reserve(n)
return reservenum==n
def main():
n = int(input("Enter a number: "))
t = reserve(n)
print(... |
c1380bbef9c08568f0d682b0732a0ac03643ea74 | avidas/Code_snippets | /flower_garden_TCCC_04_D1L2.py | 3,969 | 3.578125 | 4 | '''
ACCEPTED
Problem Statement
You are planting a flower garden with bulbs to give you joyous
flowers throughout the year. However, you wish to plant the flowers
such that they do not block other flowers while they are visible.
You will be given a int[] height, a int[] bloom, and a int[] wilt.
Each type of flowe... |
8c7056cb054cffdab1879ab374d1b8c53c38d717 | adrixo/Codigos | /ejemplos/Ejemplo_Criptografia.py | 528 | 3.71875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
sys.path.append('../')
from src.Criptografia import *
mensaje = str(raw_input("Mensaje-> "))
encriptado = ""
desencriptado = ""
# Ejemplo encriptacion cesar:
clavePrivada = int(raw_input("Clave para caesar-> "))
encriptado = caesarCrypt(mensaje, clavePrivada)
prin... |
44dd6a05fbeab3e6c126cc185c592c2e08256e34 | Abhinandhan2000/Python-programs | /func1.py | 529 | 3.96875 | 4 | #Function without parameter
def fun():
print("LOL")
fun()
#Function with parmeter
def fun1(a):
b=a+1
print(b)
fun1(3)
#Function with parameters
def fun2(a,b,c):
h=a+b
print(a)
print(b)
print(h)
print(c)
fun2(5,3,"HAHA")
#Function with default parameter.
def fun3(a=5,b="nah"):
print(a)
a=a+6
print(a)
prin... |
d636b023af3f4e570bef64a37a4dbb5a162bd6db | chavarera/codewars | /katas/Stop gninnipS My sdroW.py | 1,031 | 4.34375 | 4 | '''
Stop gninnipS My sdroW!
Write a function that takes in a string of one or more words, and returns the same string,
but with all five or more letter words reversed (Just like the name of this Kata).
Strings passed in will consist of only letters and spaces.
Spaces will be included only when more than one word is pre... |
22c148afdefbfb8f4863c0ed0571cd903576f829 | novoqoorsky/Scripting-languages-university-classes | /Chemical Equations Balancer/computing/matrix_creator.py | 4,276 | 3.78125 | 4 | import unittest
import numpy as np
from collections import OrderedDict
from parsing.equation_parser import EquationParser
from parsing.molecule_parser import MoleculeParser
class MatrixCreator:
"""
A class for creating equation's matrix.
The matrix is a N x M matrix, where N is the number of unique atoms... |
9d02cbc450cfdb4ea2ae69d75b0db64bbfa12ce7 | Indu-Palanisamy/Numbers | /leap.py | 151 | 3.875 | 4 | try:
a=int(input("Enter the year: "))
if(a%4==0):
print("Leap year")
else:
print("Not a Leap year")
except ValueError:
print("Invalid input")
|
0620e1ed156264cc69464e952fc3665fc8f97e28 | andersonnatasha/LeetCode | /linked_list.py | 3,216 | 4.1875 | 4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def mergeTwoLists(l1, l2):
""" Merge two sorted linked lists and return it as a sorted list.
The list should be made by splicing together the nodes of the first two lists.
"""
if not l1 and not l... |
7df4e8aa19f1161fc915383d9119dad461538091 | Raihansatar/Algorithm-Assignment | /ExperimentingFolder/DONE/P1.py | 3,456 | 3.546875 | 4 | # import geopy
from geopy.geocoders import Nominatim
from gmplot import gmplot
from geopy import distance
# import tsp
from ExperimentingFolder.DONE import TSPdynamic
# creating a class for location information
class locationInfo:
def __init__(self, name):
self.name = name
def setAddress(self, addre... |
b24e83e6c8b5e64cdb2ff8eeebc22acd99879523 | HuDaMan0621/0402-2020 | /nested_loops.py | 176 | 3.703125 | 4 | #Start at 1
hours = 1
while hours <= 12:
minutes = 0.00
while minutes < 60:
print(f'{hours}:{minutes}')
minutes = minutes + 1
hours = hours + 1 |
12a4fadf74ca461627f4a3fd8014205e4292389a | RobG73/InkscapeFileMaker | /rect2.py | 1,642 | 3.984375 | 4 | # This is a program to create a rectangle
# with curved corners and horizintal gradient fill
from ifm import *
filename = "rect2.svg"
start(filename)
units("mm")
line_width(2)
page("A4", 1)
line_col('#FF0000',0.5)
linear_gradient("blue","cyan",0,0.9,0.2)
x = 30
y = 40
width = 150
height = 100
radius = 10
rect(x,y... |
617e9ca3475b8557dc9aace5ee9e0a4dbec22a85 | RobG73/InkscapeFileMaker | /turtle_spiro.py | 894 | 3.609375 | 4 |
#Python Turtle - Spirograph - www.101computing.net/python-turtle-spirograph/
import turtle
from math import cos,sin,pi
from time import sleep
def get_rots(nR,nr):
# Calculate number of rotations of
# inner circle around large circle
n=1
while n*nR/nr!=int(n*nR/nr):
n+=1
return n
window =... |
b103cee3893db07dc2c38c183ea294f74531e180 | AkshayTelkar/PyCharm | /List.py | 639 | 3.765625 | 4 | if __name__ == '__main__':
N = int(input())
commands = []
for i in range(N):
inp = [commands.append(input().split())]
list_1 = []
for command in commands:
if command[0] == 'insert':
list_1.insert(int(command[1]), int(command[2]))
elif command[0] == 'print':
print(list_1)
elif comma... |
c1a6d4efdd4a11497348303f075e5cb019ac7544 | AkshayTelkar/PyCharm | /LIST COMPREHENSION.py | 310 | 3.5 | 4 | N = int(input())
a = []
for i in range(N):
a.append(list(map(int,input())))
print(a)
for j in range(len(a)):
for k in range(len(a[j])):
print(a[j][k])
a = [list(map(int, input())) for i in range(int(input()))]
print(a)
res = [print(a[j][k]) for j in range(len(a)) for k in range(len(a[j]))]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.