blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
6230e0a9a9e27b3a2b7f3982ed0319d10a69de9f | avapan/python-challenge | /PyBank/main.py | 1,669 | 3.515625 | 4 |
import csv
file_input = "budget_data.csv"
file_output = "budget_analysis.txt"
total_months = 0
total_revenue = 0
pre_revenue = 0
month_of_change = []
revenue_change_list = []
biggest_decr = ['', 99999999999]
biggest_incr = ['', 0]
with open(file_input,newline="") as csvfile:
csvreader = csv.DictReader(csvfil... |
2850646fd7876477bc168ab58e38283239d9cf09 | elzilrac/binf-scripts | /rmDup.py | 7,993 | 3.65625 | 4 | #!/usr/bin/env python
# Created by Allison Carlisle on 03-26-2013
# acarlisl@soe.ucsc.edu
# Usage: rmDup.py -r reads [-o outputFile]
# takes in a fasta or fastq file and removes all identically duplicate reads
# keeps the read with the higher score
# technically this will work with any squences formatted like a fasta... |
ccd0024084eda3b1550d49a34df9780f0acf85e8 | the-factory/kdevelop-python | /documentation_files/EasyDialogs.py | 6,769 | 3.5625 | 4 | #!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
""":platform: Mac
:synopsis: Basic Macintosh dialogs.
:deprecated:
The :mod:`EasyDialogs` module contains some simple dialogs for the Macintosh.
The dialogs get launched in a separate application which appears in the dock and
must be clicked on for the dialogs be displ... |
116a69abaf4a9b14b281b980b1d08b45b3b3901d | swadipa123/Python-Examples | /csvFile_copy.py | 330 | 3.59375 | 4 | # copy the data of one csv file to another csv file
import csv
with open(r'E:\python-examples\mycopy.csv','w') as csvfile:
filewriter = csv.writer(csvfile)
with open(r'E:\python-examples\myfile.csv','r') as infile:
filereader= csv.reader(infile)
for row in filereader:
filewriter.wri... |
e3bfbe2e34690fa126406ba5926910e0f2da4b60 | dunn0052/UofM | /4041/test.py | 594 | 3.828125 | 4 | import disjoint_set
import random
def test(n):
ds = []
for i in range(n):
ds.append(disjoint_set.make_set(i))
for i in range(0, n-1, 2):
disjoint_set.union(ds[i], ds[i+1])
return ds
def print_test(ds):
for d_set in ds:
print(disjoint_set.find_set_i(d_set).... |
8922805e5b5bfffd23045d414ea32eee26f080a3 | berkcangumusisik/CourseBuddiesPython101 | /Pratik Problemler/01 - Temel Bilgiler - Seviye 1/01 - sum.py | 147 | 3.640625 | 4 | """
İki sayı alan ve bu iki sayının toplamını veren bir fonksiyon yazın.
"""
def sum(num1 , num2):
return num1 + num2
print(sum(3,5))
|
fb9bce02576b0b8bceb8a2fc11e287269e51ff9c | lincappu/pycharmlearningproject | /LNH/day5/04 Object oriented inheritance.py | 4,014 | 3.984375 | 4 | # !/usr/bin/env python3
# _*_coding:utf-8_*_
# __author__:FLS
# 继承的关系:
# class Animal:
# def __init__(self,name,aggr,life_value):
# self.name=name
# self.aggr=aggr
# self.life_value=life_value
#
# def func(self):
# print(self.name)
#
#
# class Foo:
# def func(self):
# ... |
2d5790cd8008b9d7538bb6e2577fd37d7e6c173f | lovekeshmanhas/PythonWork | /PythonTut/tutorial_ex1.py | 312 | 3.9375 | 4 | dict_English_meaning = {"condensation":"The conversion of a vapour or gas to a liquid",
"recreant":"Cowardly",
"reincarnation":"The rebirth of a soul in another body"}
print("Enter word to find meaning")
word_input = input()
print(dict_English_meaning[word_input]) |
da0f87af556eb70430c33ff3555fc4b6622c51d9 | pzoliveira/Cursoemvideo | /ex052.py | 465 | 3.921875 | 4 | num = int(input('Digite um número inteiro qualquer positivo diferente de zero: '))
indica = 0
vezes = 0
for cont in range(1, num +1):
indica = 1 if num % cont == 0 else 0
vezes += indica
print('\033[33m' if indica ==1 else '\033[31m', end = ' ')
print('{}'.format(cont), end=' ')
print('\n\033[m')
print(... |
675fe68509ac6297dcfea52e392d1923424841ac | gamt89/misiontic2022-ciclo1 | /RETO2.py | 2,550 | 4.125 | 4 | print ('Bienvenidos al sistema de Descuentos de Matrícula')
BeneficioEdad=0
BeneficioPuntaje=0
BeneficioIngresos=0
BeneficioTotal=0
Nombre=input('Digite el nombre completo: ')
Edad=int(input('Digite la edad en años: '))
Puntaje=int(input('Digite el puntaje obtenido en el examen de 0 a 100 (números enteros): ')... |
bf40e5ef1e038b8d416db31c7693fa02d706fb0c | bespontoff/checkio | /solutions/Incinerator/army_battles.py | 4,599 | 4.21875 | 4 | #!/home/bespontoff/PycharmProjects/checkio/venv/bin/checkio --domain=py run army-battles
# In the previous mission - Warriors - you've learned how to make a duel between 2 warriors happen. Great job! But let's move to something that feels a little more epic - the armies! In this mission your task is to add new classes... |
b9e4978e600d0a13ba5fa2c952335f691d274a7b | mehmetgelir/pythonExercise | /p19.py | 101 | 3.59375 | 4 | a=[]
for i in range(7):
x=input ("Bir sayi giriniz");
a.append(x);
y = 0
for x in a:
if y = x
|
8e91fa068bb2700f4a5b27e3c16c55b45430c2bf | lycantropos/robust | /robust/parallelogram.py | 5,462 | 3.75 | 4 | from numbers import Real
from . import bounds
from .hints import Point
from .utils import (sum_expansions,
to_cross_product,
two_diff_tail,
two_product,
two_two_diff)
def signed_area(first_start: Point,
first_end: Point,
... |
15143b390cb2f06e949f2a738c0bca0ccee64e3e | JulianDavidG07/holbertonschool-higher_level_programming | /0x0B-python-input_output/8-load_from_json_file.py | 220 | 3.609375 | 4 | #!/usr/bin/python3
import json
'''
funcion object JSON representation
'''
def load_from_json_file(filename):
'''
Write a object to a text file
'''
with open(filename) as f:
return json.load(f)
|
df0d75cfb12543c763c1ca97af3dfd3612e6df4c | CollinsLiam21/unit5 | /stat.py | 551 | 3.640625 | 4 | #Liam Collins
#4/26/18
#stat.py
L = []
while True:
nums = input('Enter a list of numbers, Type q when finished: ')
if nums != 'q':
L.append(float(nums))
else:
break
for item in L:
print(item)
print('Min: ', min(L))
print('Mean: ', sum(L)/(len(L)))
print('Max: ', max(L))
christo = 0
f... |
a6b46895d55939327c04d0f99bf97531bdeb025d | rene-d/math | /projecteuler/p066.py | 1,543 | 3.75 | 4 | """
Diophantine equation
https://projecteuler.net/problem=66
"""
from math import sqrt
from fractions import Fraction
# Quelques liens...
# https://oeis.org/A033313
# Smallest positive integer x satisfying the Pell equation x^2 - D*y^2 = 1
# for nonsquare D and positive y.
# Calcul de la fraction continue de √S
... |
8c13a56410d3ea5c177e69b3cb89b35bfa7c5a9d | love-adela/algorithm-ps | /acmicpc/10039/10039.py | 131 | 3.515625 | 4 | nums = [int(input()) for _ in range(5)]
for i in range(len(nums)):
if nums[i] < 40:
nums[i] = 40
print(sum(nums)//5)
|
450bf503b949c7f279256907b49027526dfbe6a3 | SebastianG343/80-Ejercicios | /Ejercicio 44.py | 155 | 3.90625 | 4 | n=int(input("Digite un numero"))
n1=int(input("Digite un numero"))
if n in range (0,5) and n1 in range (0,5):
print(True)
else:
print(False)
|
2da6e00b675fdb9974b15ed98fec73cc0833bb07 | c2huc2hu/Isometric-Game | /product.py | 421 | 3.609375 | 4 | class Product():
"""Static constants related to the things that cities can build"""
NOTHING = "nothing"
WALL = "building:wall"
ARCHER = "unit:archer"
CAVALRY = "unit:cavalry"
cost = {NOTHING:0, WALL:30, ARCHER:5, CAVALRY:10}
@staticmethod
def isUnit(product):
return "... |
1bdaf690624182be336fec6e07a129e24b9c4fc8 | Raunak173/hacktoberfest | /LeetCodeSolutions/removeadjacent.py | 289 | 3.609375 | 4 | class Solution:
def removeDuplicates(self, S):
if not S: return s
stack = []
for ch in S:
if stack and stack[-1]==ch:
stack.pop()
continue
stack.append(ch)
return "".join(stack)
|
b692c34f2f815a84913e492d795f0764b5ca34a8 | kavishsanghvi/Student-Repository | /Student_Repository_Test_Kavish_Sanghvi.py | 1,859 | 3.59375 | 4 | import unittest
import datetime
from Student_Repository_Kavish_Sanghvi import main
class TestMainFunction(unittest.TestCase):
def data(self):
# Note path is optional parameter so by default it passes ''
self.university_data = main('Stevens University')
def test_student_name(self):
"""... |
a816a6d0364c028c55ee47c0edaaaa4a257df671 | hjgarcia1/30-days-of-python | /day-9/exercise-1.py | 317 | 3.65625 | 4 | main_characters = [
("BoJack Horseman", "Will Arnett", "Horse"),
("Princess Carolyn", "Amy Sedaris", "Cat"),
("Diane Nguyen", "Alison Brie", "Human"),
("Mr. Peanutbutter", "Paul F. Tompkins", "Dog"),
("Todd Chavez", "Aaron Paul", "Human")
]
for character, actor, animal in main_characters:
print... |
d6ce94b52c7bab93d72de34e13fbe83812eadc55 | MattCKU/OfficialFortranFanclub_Minesweeper | /matchgui.py | 3,153 | 3.5 | 4 | import pygame
import tkinter as tk
import random
from random import shuffle
from tkinter import messagebox
from tkinter import *
class matchgui:
"""constructor to define the variable and buttons(cells)"""
def __init__(self):
self.if_win=False
global root
root = tk.Tk()
chances =... |
6f3a4d03478a1abd61f1c25e327b73147519332c | KumaKuma0421/PythonSample | /test/DateTime.py | 707 | 4.15625 | 4 | import time
# エポックからの秒数を浮動小数点で返します。
currentTime = time.time()
print("currentTime=" + str(currentTime))
print("localTime(currentTime)=" + str(time.localtime(currentTime)))
# time.struct_time型を返します。
# gmtime()、localtime()、strptime()が該当します。
# 引数はtime.time()のエポックタイムになります。
currentLocalTime = time.localtime()
print("curre... |
cf72b2147b9b5d6ae7d5360c69336511e097bd22 | fchikwekwe/InterviewPrep | /binary_search_tree.py | 1,398 | 4.09375 | 4 | """ Implement a binary search tree from scratch """
class Node(object):
""" inherits from Python object class
attributes: data, right, left """
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class BinarySearchTree(object):
""" inherits from Py... |
a5677852b8e608c6792fdec01432627f365f27aa | 171456998/szc | /day04/__init__.py | 1,491 | 3.65625 | 4 | def pingjie_demo():
a=9
b=10
c=a+b
print(c)
def pingjie1_demo():
a='你是'
b=250
print(a,b)
def jiafa(a,b):
a=1
b=2
a_b = a + b
return a_b
if __name__ == '__main__':
# pingjie_demo()
# pingjie1_demo()
# a = 1
# b = 2
# i = jiafa(a, b)
# print(i)
# l... |
d0a272b452bffa17014fb0f6f494ba9cd335aa5e | ckitagawa/Algorithms-And-DataStructures | /python_algorithms_data_structures/sorting.py | 3,040 | 4.09375 | 4 | # Sorting in general
# Most systems use Heap, Insertion, or Quicksort all of which are on average (n log n) algorithms
# In embedded or memory restricted applications Heap or an optimially gapped Shell sort might be preferred
# Radix sort is useful in the event n is large and word size (length of integers) is relativel... |
71958edd4d76adc560ff2219d571e5fdebeedf34 | Elmioor/hometask5 | /main.py | 8,844 | 4.03125 | 4 | # 1. Создать программно файл в текстовом формате, записать в него построчно данные, вводимые пользователем. Об окончании ввода данных свидетельствует пустая строка.
#
# file_one = open("my_file_task_1.txt", 'w')
#
# print("enter strings")
#
#
# while True:
# user_input = input()
# if r' ' in user_input:
# ... |
6247a2bea90ace4bdfed5ee981c7c365223630aa | Forif-PythonClass/Assignments | /Sangjin/HW2/2-3.py | 104 | 3.9375 | 4 | name=input("name: ")
age=int(input("age: "))
print("{} will be 100 after {}years".format(name,100-age))
|
b5ec341aad609bbd1b6f458d620cad6d3de083b6 | wuxiukai/python-3.7-daimaku | /22/def_222.py | 281 | 3.890625 | 4 | def power(x,y):
if y == 0:
return 1
else:
return x*power(x,y - 1)
number = int(input('请输入一个整数:'))
index = int(input('请输入一个整数:'))
result = power(number,index)
print("%d 的 %d 次幂是 %d"%(number,index,result))
|
1d94f2866dacff565dd123a736ab661b30761038 | Rushikesh93/pyprojects-1 | /guess user.py | 394 | 3.75 | 4 | import random
def comp_guess(x):
low = 1
high = x
feedback = ''
while feedback != 'c':
guess = random.randint(low, high)
feedback = input(f"IS {guess} too high, too low(L),or correct(c)".lower())
if feedback == 'h':
high = guess-1
if feedback == 'l':
... |
457aac4bf72fdfb960249a78eb2db543f9ec4fda | sunshinewxz/leetcode | /529-updateBoard.py | 996 | 3.59375 | 4 | class Solution:
def updateBoard(self, board, click):
"""
:type board: List[List[str]]
:type click: List[int]
:rtype: List[List[str]]
"""
x, y = click[0], click[1]
return self.dfs(board, x, y)
def dfs(self, board, x, y):
if board[x][y] == '... |
f3134fb1ad7bd159218079fc140e0b05d46eb3df | ppalves/desafios-de-programacao | /aula-19-6/c.py | 459 | 3.578125 | 4 | # x (letra no alfabeto)
# y (input)
import math
def resolve(y):
if(y%2 == 0):
return 'a'
r1 = math.log(y + 1, 2)
if abs(round(r1) - r1) <= 0.001:
return chr(round(r1) + 97)
logteta = 0
for k in range(1, y + 1):
logteta = math.log(k + 0.5, 2)
if abs(round(r1 - ... |
d2ff2fe9f86985ec2fd1dd4a4f5547a4bd8153d5 | thebmo/Checkio_Solutions | /home/min_max.py | 1,298 | 3.6875 | 4 | def min(*args, **kwargs):
key = kwargs.get("key", None)
items = sorted(get_items(args), key=key)
min = items[0]
if key == int:
min = int_key(items, min)
return min
def max(*args, **kwargs):
key = kwargs.get("key", None)
items = sorted(get_items(args), key=key)
max = items[-1]
... |
33fe592af24e16a6b4601a662c4819297cef7208 | staubhp/euler_solutions | /euler1.py | 201 | 3.8125 | 4 | def main():
mySum = 0
for x in range (0,1000):
if x%3==0 or x%5==0:
mySum = mySum + x
print(mySum)
return mySum
if __name__ == "__main__":
main()
|
6b573e3338bb5ca69e3a4e0f616fdc2e180b04cd | acselerai/pyf | /home_work_6/task_4/car.py | 899 | 3.625 | 4 | class Car():
def __init__(self, speed, color, name, is_police):
self.speed = speed
self.color = color
self.name = name
self.is_police = is_police
def go(self):
return f'{self.name} rides'
def stop(self):
return f'{self.name} stopped'
def turn(self, dire... |
cde91e325b292785d14085449fa26a51bfbd4415 | korodoff/my-python | /assig7.py | 806 | 4.09375 | 4 | # what is time tuple?
# time tuple is a useage of tuple in used for the ordering and notation of time
import time
print(time.gmtime())
# wirte a program to get format time
print(time.asctime(time.gmtime()))
import datetime
d=datetime.date.today()
print("today month is",d.month)
import datetime
d=datetime.date.today()... |
8cb1f3dca1fd4edc978e805e0288d68e6d8cb020 | jeffreyleeon/python-tutorials | /08_using_built_in_library.py | 803 | 4.21875 | 4 | '''
Introduction to python built-in library
Teaching how to import a library, use functions in a library
Documentation from python v2: https://docs.python.org/2/library/random.html
Documentation from python v3: https://docs.python.org/3.3/library/random.html
- randint
- random
'''
import random
randomInteger = rand... |
84717012ed78b1965cd12fdec5b3249419fde129 | AmitKulkarni23/Leet_HackerRank | /Contest/868_binary_gap_submission.py | 1,920 | 4.15625 | 4 | # Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N.
#
# If there aren't two consecutive 1's, return 0.
#
#
#
# Example 1:
#
# Input: 22
# Output: 2
# Explanation:
# 22 in binary is 0b10110.
# In the binary representation of 22, there are thre... |
99afa3a2716e241b7c5dbeb885507bde2d03d549 | ushanirtt55/python | /Python Basics/Python_proj/codewars/6u/X_pattern.py | 120 | 3.65625 | 4 | def pattern(n):
for i in range(n,0,-1):
print " "*(n-i) + str(i) + " "*(i) + str(i) + " "*(n-i)
pattern(5)
|
ae686c9c24972384b51f65e2d38bdbd62bebbff2 | tapumar/Competitive-Programming | /Uri_Online_Judge/1755.py | 326 | 3.5625 | 4 | casos = int(input())
for i in range(casos):
din,n = input().split()
din = int(din)
valor = input().split()
maior = 0
for j in valor:
j = float(j)
qnt = int(din/j)
if din-(qnt*float(j)) > maior and j<=din:
maior = din-(qnt*float(j))
print('%.2f' % m... |
1c0844e3c04f201687718b037286e60a567a7cc0 | mohammadasim/python-course | /python_generators/generator.py | 2,410 | 4.71875 | 5 | '''
We have learned how to cerate functions with def and the return statement. Generator functions allow us to write a
function that can send back a value and then later resume to pick up where it left off.
This type of function is a generator in Python, allowing us to generate a sequence of values over time.
The main... |
9fef420655fb947ed6bac97e3193e15d4fb443b1 | Zeranium/PythonWorks | /Ch06/lib/Person.py | 268 | 3.609375 | 4 | class Person :
__name : None
__age : 0
def __init__(self, name, age):
self.__name = name
self.__age = age
def hello(self):
print("-----------------")
print("이름 :", self.__name)
print("나이 :", self.__age) |
a4e54e92f17dab907f25f4263d356d9aac7b9fd1 | SemyonSinchenko/NetKetTests | /python/src/Ising.py | 3,511 | 3.859375 | 4 | import netket as nk
class Ising(object):
def __init__(self, n_spins, J, h, pb):
"""
Create the model.
:param n_spins: the number of spins
:param J: JZ in the model
:param h: h in the model
:param pb: Periodic Boundary true?
"""
self.n_spins = n_spins... |
c22d11af88365c384c47b811d46ab895121479c8 | josephdiniso/YouQR | /src/create_label.py | 3,287 | 3.59375 | 4 | #!/usr/bin/env python3
from typing import List
import numpy as np
import cv2
import argparse
import requests
import re
from b64_to_bar import b64_to_bar
class BarGenerator:
"""
BarGenerator object which takes in a list of numbers, which are the octal representations
of a YouTube embedded URL
"""
... |
9c064b22f2359bfd3e9f86cc6a2f78a5827ebaac | l33tdaima/l33tdaima | /p901m/stock_spanner.py | 619 | 3.84375 | 4 | class StockSpanner:
def __init__(self):
self.stack = []
def next(self, price: int) -> int:
sum_count = 1
while self.stack and self.stack[-1][0] <= price:
sum_count += self.stack.pop()[1]
self.stack.append((price, sum_count))
return sum_count
# Your StockSpa... |
e941c9c01feea05eb1c2c6aca2a5ee322171a37f | santhosh790/competitions | /randomprobs/BST.py | 1,980 | 3.984375 | 4 | '''
Binary Search Tree
'''
class BST_Node:
def __init__(self, data):
self.val = data
self.left = None
self.right = None
class BST_Ops:
def construct_tree(self, data, root):
if root is None:
root = BST_Node(data)
elif root.val > data:
if root.le... |
e94cef6ab6576128ecf77d9cca4650416ef613ab | DanielCodez-py/Codecamp | /app2.py | 145 | 3.875 | 4 | print("This program returns the letter V an approximate 10 times")
v = 1
t = 0
while v <= 10:
t += 1
v += 1
print(f"{t}.\tV") |
306adeee9c5cb54c3b1d4e7f61afc25a89c668ea | aayushhindwan/Tic-Tac-Toe | /tic_tac_toe.py | 4,388 | 3.65625 | 4 | from math import inf as infinity
from random import choice
import platform
import time
from os import system
wi=[];
lose=[];
draws=[];
print("YOU ARE O 3*3 BOARD IS WITH YOU CHOSE ONE CELL TO PLACE THE O IN IT AND WE ARE O WE WILL PLAY TOGETHER.\n");
board = [
[0 ,0 ,0],
[0 , 0 ,0],
[ 0, 0 ,0],
]
def wins... |
7d32cb3f144edb9e9594ff9d2deca590859af1d9 | ArvindRadhakrishnan94/hello-world | /task2.py | 122 | 3.5 | 4 | def sum_number(a,b):
count=0
for i in range (a,b,1):
if (i%2==0):
count+=i
return count
print(sum_number(99,500))
|
87749b59b4d77a0a04eb5d8d3b65332c48e4a7b1 | Gusstr/Uppgifter | /uppgift3.py | 129 | 3.671875 | 4 |
T = int(input("tal: "))
def delfem(a):
if a % 5 == 0:
return True
else:
return False
print(delfem(T))
|
126440233c1bf1075fdfb1970f2ed51e1e61fdd7 | mcfa77y/python | /socialNetwork/BridgeEdgesv4.py | 15,022 | 4.15625 | 4 | #!/usr/bin/python27
# Bridge Edges v4
#
# Find the bridge edges in a graph given the
# algorithm in lecture.
# Complete the intermediate steps
# - create_rooted_spanning_tree
# - post_order
# - number_of_descendants
# - lowest_post_order
# - highest_post_order
#
# And then combine them together in
# `... |
fc9fc9ad5f5774207b0237bccf98ffaec885055a | AplusB/ACEveryDay | /IvanJobs/cf/edu16/A.py | 255 | 3.546875 | 4 | line = raw_input().strip()
c = ord(line[0]) - ord('a') + 1
r = 9 - int(line[1])
if r > 1 and r < 8 and c > 1 and c < 8:
print 8
elif (r > 1 and r < 8 and (c == 1 or c == 8)) or (c > 1 and c < 8 and (r == 1 or r == 8)):
print 5
else:
print 3
|
487c91a9b3b72f6e75de2eb063d28ad41db66729 | GenryEden/kpolyakovName | /3747.py | 198 | 3.875 | 4 | def f(x):
if x < 5:
return 0
if x == 5:
return 1
if x == 10 or x == 15:
return 0
ans = f(x-1)
if x - 1 != 11:
ans += f(x-2)
if x - 2 != 11:
ans += f(x-3)
return ans
print(f(18)) |
656ebbac2789ccc28bf0757c5ad5574d1a84cdb4 | The-Totti/marvin | /fase04/ex01/nove.py | 120 | 3.671875 | 4 | def nove(num1):
num1 = str(num1)
if num1[-1] == "9":
return (True)
else:
return (False)
|
21b5a60e343296e61219cbe78eb4c2fcfde62ad2 | ebubekirtrkr/pythonWorkShop | /Sololearn/Factorial_Zeros(3).py | 209 | 4.0625 | 4 | from math import factorial
nmbr=int(input("Please Enter Number\n"))
fact=factorial(nmbr)
res=0
while str(fact).endswith(str(0)):
res +=1
fact/=10
print ("{}! has {} trailing zeros.".format(nmbr,res)) |
74b76a1d86b52a9397914ddefc63b0c6dc3deb9d | Yushgoel/Python | /integer.py | 168 | 4.15625 | 4 | number = raw_input("Please enter a number.")
number = int(number)
if number > 0:
print "Positive"
else:
if number == 0:
print "Zero"
else:
print "Negative"
|
08c5f4b4edb0a0c6985d9c735ad3484152ff9c98 | skorohodovn/sda | /venv/python fundamentals/07-collections/list-exercise.py | 585 | 4.0625 | 4 | my_list = [1, 2, 3, 4, 5]
print(list)
print(f"The length is {len(list)}")
list.append(2)
print(list)
print(f"The amount of 2s in the list is {list.count(2)}")
print(f"The amount of 7s in the list is {list.count(7)}")
list.extend([6,7,8])
print(list)
print(list.index(7))
print(f"It is indeed on the position of {l... |
5bd7c53d76914517cc80bd86867a6b5c48194639 | wantyouring/Algorithm | /1076.py | 1,377 | 3.5 | 4 | a = input()
b = input()
c = input()
'''
black 0 1
brown 1 10
red 2 100
orange 3 1000
yellow 4 10000
green 5 100000
blue 6 1000000
violet 7 10000000
grey 8 100000000
white 9 1000000000
'''
def func(str,mul):
if str == 'black':
if mul:
return 1
else:
return 0
elif str... |
b92c17bf2c7958bdba9d2b5e61f0510b46dde0ec | BryantLuu/daily-coding-problems | /7 - Decoding combinations.py | 1,675 | 4.375 | 4 | """
Good morning. Here's your coding interview problem for today.
This problem was asked by Facebook.
Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded.
For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'.
You c... |
29f6428a569b6bd957b1b7cc38ecce537781d7f0 | chewesther/ICT1002-Programming-Fundamentals | /Python/Lab 01/WeeklyPaymentCalculator/weeklyPaymentCalculator.py | 784 | 3.6875 | 4 | import sys
def calculateSalary(whours, nrate, orate):
if 168 > whours < 41:
# total 168 hours in a week
n_salary = whours * nrate
o_salary = orate * 0
salary = n_salary + o_salary
print("Normal Salary:%0.2f" % n_salary + ", Extra Salary:%0.2f," % o_salary + " Total Salary:%... |
5a1c4d8761386333dce54890c6dc185538624e9d | VishalGupta2597/batch89 | /V_FormDB.py | 955 | 3.640625 | 4 | from tkinter import *
root = Tk()
root.geometry("350x400+500+150")
root.title("MyDBform")
root.resizable(0,0)
def submit():
top = Toplevel()
top.resizable(0,0)
top.geometry("350x400+500+150")
label= Label(top,text="Your Account Details",fg="green", bd=5, bg="black",width=30,height=2, font=("Ariel",12... |
f8fa9c60f421c594d6569b9494f91bc44cbfe930 | nickmoran06/holbertonschool-higher_level_programming | /0x03-python-data_structures/10-divisible_by_2.py | 266 | 3.90625 | 4 | #!/usr/bin/python3
def divisible_by_2(my_list=[]):
boolean_list = []
for counter in range(len(my_list)):
if my_list[counter] % 2 == 0:
boolean_list.append(True)
else:
boolean_list.append(False)
return boolean_list
|
bf36beaaef7320f9012b3a1e22343c2f3a196de2 | jadhavarsanket1598/TCS-Coding-Question-Practice | /sqrtwtoanyfun.py | 188 | 4.21875 | 4 | #Find square of any number without using any inbuilt functions
num = int(input("Enter the number for finding square::"))
num_sqre = num ** 2
print("Square of a ",num ,"is",num_sqre) |
b1eef354e50d4694454195c9953d8ee2bd774543 | aedawid/pyprot | /vector3d.py | 5,210 | 4.125 | 4 | """
Module for handling 3d vectors.
"""
import numpy as np
from random import uniform
from math import sin, cos, sqrt, pi
class Vector3d:
"""
Vector3d is a class to handle 3d vectors of floats.
The coordinates are accessible by attributes x, y, z.
"""
def __init__(self, *args, **kwargs):
... |
61734904a75f8eefcfd73f4a032cfd0e950aa78e | lmdragun/milk-and-cookies | /w11/d02_warmup/fizzbuzz.py | 264 | 3.703125 | 4 | # numbers = list(range(1, 101))
for n in list(range(1, 101)):
fizz = n%3 == 0
buzz = n%5 == 0
word_fizz = "fizz"
word_buzz = "buzz"
if fizz and buzz:
print word_fizz + word_buzz
elif fizz:
print word_fizz
elif buzz:
print word_buzz
else:
print n
|
81639eea8486fef1f12b6787ed85690f0508be29 | quantbruce/leetcode_test | /剑指offer/68 - II. 二叉树的最近公共祖先(难).py | 2,712 | 3.609375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def lowestCommonAncestor(self, root: TreeNode, p: TreeNode, q: TreeNode) -> TreeNode:
stack_p = [] # 用来储存从上往下遍历找到p的轨迹
st... |
57a96fba26a1e6b780f63071a4a43f6067a4ab76 | pcamateur/pyt | /math/digit/a.py | 927 | 3.515625 | 4 | # def digits(n,s,e):
# lis = []
# for x in range(s, e + 1):
# if x % n == 0:
# lis.append(x)
# return lis
# # print(digits(6, 1, 65535))
# def three():
# lis = []
# for x in range(1, 65535):
# if x % 2 == 0 and x % 3 == 0:
# lis.append(x)
# return ... |
3e111743b25168ff963068c88f9b9ebe5dc2a55b | zaoyuaner/Learning-materials | /python1901/1_python基础/day05/1.作业.py | 2,808 | 3.84375 | 4 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
# author:zhangjiao
'''
1.打印星星号
从控制台输入1
*
输入3
*
***
*
输入5
*
***
*****
***
*
依次类推
'''
# while True:
# n = int(input("请输入一个奇数:"))
# if n%2 ==0:
# print("这个数为偶数,输入非法,请重新输入。。。。")
# else:
# break
#
#
# for x in range(1,n+1,2):
# print(("*"*x... |
b702ea2603de581f20a8c68a33287d879a622b7c | akb46mayu/Data-Structures-and-Algorithms | /LintcodePartI/li376_binaryTreePathSum.py | 2,729 | 3.96875 | 4 | """
Given a binary tree, find all paths that sum of the nodes in the path equals to a given number target.
A valid path is from root node to any of the leaf nodes.
Have you met this question in a real interview? Yes
Example
Given a binary tree, and target = 5:
1
/ \
2 4
/ \
2 3
return
[
[1, 2, ... |
cb63c5f80ae97f5a50f2de535104970fcf9f4642 | doyeonkp/Programmers | /binTodec.py | 266 | 4.34375 | 4 | # binary to decimal
# int(binary, 2) -> 2 is base => it can convert to decimal
# but if you want to make this logic program
# follow the below
binary = raw_input('enter a number: ')
decimal = 0
for digit in binary:
decimal = decimal*2 + int(digit)
print decimal
|
97a28f27ac83571d6666af842c8ada2cbb42ebfa | nbwsc/sklearnDemo | /other/iris.py | 828 | 3.625 | 4 | import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
# 加载数据
iris = datasets.load_iris()
data_X = iris.data
data_y = iris.target
# 数据维度、特征与目标值的前3项
print('data:', data_X.shape, data_y.shape)
print('features:', data_X[... |
f0780893bc44a7d1df9bc7e9fbfb4f2b68bf3d7f | zyk930/leetcode | /045_jump-game-ii.py | 1,460 | 3.84375 | 4 | #!/usr/bin/env python
# _*_coding:utf-8 _*_
#@Time :2019/1/20 21:24
#@Author :ZYK
#@FileName: 045_jump-game-ii.py
'''
数组中的每个元素代表你在该位置可以跳跃的最大长度。
你的目标是使用最少的跳跃次数到达数组的最后一个位置。
示例:
输入: [2,3,1,1,4]
输出: 2
解释: 跳到最后一个位置的最小跳跃数是 2。
从下标为 0 跳到下标为 1 的位置,跳 1 步,然后跳 3 步到达数组的最后一个位置。
说明:
假设你总是可以到达数组的最后一个位置。
'''
class Solut... |
88e6fd74bfb736a00bc47dd7d8e5f494f824ae1d | mamadyonline/Projet_HPC | /TreeMethods/RandomForest.py | 3,057 | 3.921875 | 4 | from random import randrange
from random import seed
seed(1)
class RandomForest (object):
"""
A Random Forest base class.
Classification and Regression Random Forests will be derived classes
that override certain functions of this class. This was done
because many common methods, so to reduce code they are wr... |
d5a5a6f5faa9f1dd83af36846346c437375221df | lakshaysinghal/Leetcode | /2_Add_Two_Numbers.py | 1,285 | 3.78125 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
carry = 0
cur1,cur2 = l1,l2
result = None
cur = result
... |
e8f06b4f7863bde44f6010bb68b7c2697b373bd5 | louwjlabuschagne/weeklySessions | /session2/circuitDemo.py | 284 | 3.984375 | 4 | #define the function
def calcCurrent(V,R):
I = V/R
return(I)
#get input from user
V_input = input("V?")
R_input = input("R?")
#calculate the current using the calcCurrent fucntion
I_result = calcCurrent(float(V_input), float(R_input))
#print the results
print(str(I_result)+"A")
|
9ea1c5e32654572a978a04bd7d462b753686b61a | filippoferrando/Python | /course/Es4/es.py | 90 | 4.03125 | 4 | from math import pi
r = float(input("write the radius: "))
print("area = " + str(pi*r**2)) |
c635b4a0c433ffd08099b042de0c322c8c17a9e6 | jinurajan/Datastructures | /LeetCode/booking/reward_top_k_students.py | 2,236 | 3.890625 | 4 | """
Reward Top K Students
You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. Note that no word is both positive and negative.
Initially every student has 0 points. Each positive word in a feedback report increases the po... |
fc93070a29b8573bb4a16ce0ff8ecabc7802d907 | gitgamedev/WordRPG | /script/Story.py | 1,169 | 3.84375 | 4 | from script import Screen
class gender_struct:
def __init__(self, gender):
is_female = gender == "female"
self.he_she = 'she' if is_female else 'he'
self.him_her = 'her' if is_female else 'him'
self.his_her = 'her' if is_female else 'his'
# This is where the intro story will be t... |
078d449dcdb4a287403e17bb81c3418170aba7f4 | N3CROM4NC3R/python_crash_course_exercises | /files_and_exceptions/silent_cats_and_dogs/silent_cats_and_dogs.py | 509 | 3.609375 | 4 | filename_cats = "catss.txt"
filename_dogs = "dogss.txt"
try:
with open(filename_cats,'r') as file_object:
cats_name = file_object.readlines()
print("Cats names:")
for cat_name in cats_name:
print(cat_name)
except FileNotFoundError:
pass
try:
with open(filename_dogs,'r')... |
f8a7f2af8e75b36287813f48fb8b918bf94df172 | himu999/problem_solving | /E#1/problem_10.py | 476 | 3.828125 | 4 | t = int(input("Enter the value : "))
i = 1
while i <= t:
opposition_run, team_run, ball_left = map(int, input("Enter the number : ").split())
current_rr = (team_run / ((300 - ball_left) / 6))
required_rr = (((opposition_run + 1) - team_run) / (ball_left / 6))
if opposition_run < team_run:
re... |
f4bfab02b190628495e96704836bc21e7d52f33e | netscruff/2013-08-22-ku-darren | /fbsearch.py | 1,678 | 3.53125 | 4 | #!/usr/bin/env python
"""
fbsearch.py
Created by Darren Boss on 2013-08-21.
"""
import urllib, urllib2
from bs4 import BeautifulSoup
import argparse
def page_results(soup):
"""Return a list of names
Given an instance of BeautifulSoup, will return all the names it can find
in the search result table
... |
94fe436509383dd0baf263de0dde168ccdc7ff32 | SK556531/CS_1-1 | /1_1/113_tower.py | 914 | 4.0625 | 4 | # a113_tower.py
# Modify this code in VS Code to alternate the colors of the
# floors every three floors
import turtle as trtl
painter = trtl.Turtle()
painter.speed(0)
painter.pensize(5)
# starting location of the tower
x = -150
y = -150
# height of tower and a counter for each floor
num_floors ... |
d71446c028cf559a69abe2e3a8e8bd6a527fc4ff | pptnz/aes-identification | /classifier/tensorflow/trainer/cnn_trainer/timer.py | 472 | 3.609375 | 4 | import time
class Timer:
def __init__(self):
self.total_elapsed_time = 0
self.start_time = None
def start(self):
self.start_time = time.time()
def stop(self):
end_time = time.time()
self.total_elapsed_time += end_time - self.start_time
self.start_time = No... |
953001697c068c077243c44776773326fe66ab23 | Rohithv07/ml | /own_k_neighbor.py | 991 | 3.640625 | 4 | from math import sqrt
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
from collections import Counter
style.use('fivethirtyeight')
dataset ={'k':[[1,2],[2,3],[3,1]],'r':[[6,5],[7,7],[8,6]]}
new_features=[5,7]
def k_nearest_neighbors(data,predict,k=3):
if len(data)>=k:
warni... |
d03b445ceae9174163b767ba2e4e3a4ca2bb3bb8 | Nightlamp1/ProjectEuler | /Python/Problem6.py | 762 | 3.953125 | 4 | '''
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of the squares of the first ten natural
numbers and the square of the sum is 3025 − 385 = 2640... |
22aed0df629a19bd9db4d9ed79c7cfd72e2fe381 | Zhenye-Na/data-structures-ucb | /lectureCode-sp18/intro1/larger.py | 118 | 4 | 4 | def larger(x, y):
"""Returns the larger of x and y."""
if (x > y):
return x
return y
print(larger(-5, 10)) |
bce60d69a59a4f28f0d3c204a43635ac705628b1 | Momerhussain/Artificial-Intelligence-Practice-Labs | /greedy.py | 823 | 3.671875 | 4 | import queue as q
class greedysearch:
def search(self,d,start,goal):
que=q.PriorityQueue()
que.put((start.h,start))
path=list()
while(not que.empty()):
node=que.get()
node=node[1]
path.append(node)
que=q.PriorityQueue()
if n... |
93c7d7b96cb88c90c79173c7bea582dd3211bb9e | tl230419/learn_py | /day03/day03_4.py | 2,759 | 3.671875 | 4 | '''
*****************
Date: 2020-04-13
Author: Allen
*****************
'''
'''
import utils
print(utils.age)
print(utils.name)
utils.func()
'''
#from utils import func, age, name
from utils import *
print(name)
print(age)
func()
#while True:
def show_menu():
print('*' * 50)
print('欢迎使用[名片管理系统]V1.0')
pr... |
41862d4c07b443ee2381cc321c97938580e11a5a | CDCfishzz/PythonLearning | /lesson4.py | 609 | 3.640625 | 4 | import math
def move(x, y, step, angle=0):
nx = x + step * math.cos(angle)
ny = y - step * math.sin(angle)
return nx, ny
r = move(100, 100, 60, math.pi / 6)
print(r)
def quadratic(a, b, c):
delta = b * b - 4 * a * c
if delta < 0:
raise TypeError("delta < 0, 此方程无实根")
elif delta == 0... |
e2199b0bc34dac83ae3c5043cc0bbeaaea689f3e | loveltyoic/PythonProject1 | /iflytek/Test.py | 3,153 | 3.546875 | 4 | #-*- coding: UTF-8 -*-
'''
@author: chenwuji
'''
def increaseVote(index1):
if (voteDict.__contains__(index1)):
current = voteDict.get(index1)
voteDict.update({index1:current+1})
else:
voteDict.setdefault(index1,1)
voteDict = {}
def test(list1, k ):
for i in range(0,len(list1[0:... |
200b83d4920c851f67b93331d138ccd20aa29c91 | JohnKlaus-254/python | /Python basics/funtion work.py | 4,188 | 4.15625 | 4 | #Q1 practice question
#
# We should create a function that ‘findsgrade’ by
# taking in marks of each subject as parameters
# calculating total from the parameters(subjects) passed
# calculating the average from the total
# using if statement to find grade
# what if I want to get total marks! and average?
# def ... |
baadb22fe8d839692e925a06e744a2608490ce2d | tnakaicode/jburkardt-python | /matrix_exp/jordan.py | 8,016 | 3.796875 | 4 | #! /usr/bin/env python
#
def jordan ( m, n, alpha ):
#*****************************************************************************80
#
## JORDAN returns the JORDAN matrix.
#
# Formula:
#
# if ( I = J )
# A(I,J) = ALPHA
# else if ( I = J-1 )
# A(I,J) = 1
# else
# A(I,J) = 0
#
# Example:
#
# ... |
c47996b5df25efec28899e69738f94656021ad5b | avinabadey6/python | /oddeven.py | 509 | 3.921875 | 4 | x=1
while x<=100:
# print(x)
x=x+2
y=0
while y<=100:
print(y)
y=y+2
p=0
while p<=50:
if p%2==0:
print(p,"-even")
else:
print(p,"-odd")
p=p+1
l=0
while l<=100:
if l%2==1:
print(l,"-odd")
else:
print(l,"-even")
l=l+1
for r in range(1,101):
if r%... |
214de330a0c34f3c1e722ee4294867352e893ed5 | leeso1718/dsc80-wi20 | /discussions/05/disc05.py | 883 | 4.0625 | 4 | import pandas as pd
import numpy as np
def impute_with_index(dg):
"""
impute (i.e. fill-in) the missing values of column B
with the value of the index for that row.
:Example:
>>> dg = pd.read_csv('data.csv', index_col=0)
>>> out = impute_with_index(dg)
>>> isinstance(out, pd.Series)
... |
8e0a7fada931b3ab99763f715965e7ff7501b1d7 | PaliwalSaurabh/TestGit | /Addition.py | 127 | 3.5625 | 4 | # This is an addition Program# -*- coding: utf-8 -*-
x=3
y=4
z= x+y
print(z)
# Adding the substraction
x=10
y=6
z=x-y
print(z) |
a067762cd1240acb28c41f81416897247f059711 | ntexplorer/PythonPractice | /PythonCrashCoursePrac/Chapter10_Prac/10-11_12.py | 624 | 3.59375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 5/30/2020 10:24 PM
# @Author : Tian Z
# @Site :
# @File : 10-11_12.py
# @Software: PyCharm
# @Version:
import json
filename = "favorite_number.json"
try:
with open(filename) as f_obj:
favorite_num = json.load(f_obj)
except FileNotFoundError:
wit... |
59e93eeeea0b5bb80f9c1cf9cf60dd8cfe32a3e2 | fabioarnoni/python-journey | /ex6_expressions.py | 281 | 4.125 | 4 | # Numeric operations + expressions
a = 12
b = 3
print(a + b)
print(a - b)
print(a * b)
print(a / b) # Result given as float
print(a // b) # Result given as integer
print(a % b) # Division Rest
for i in range(1, a // b):
print(i)
i = 1
print(i)
i = 2
print(i)
i = 3
print(i) |
327eb0368561e5754bdd15e13b2bed94dd851a8b | MAPTblHOB/GeekBrains | /L1_HW1.py | 372 | 3.859375 | 4 | x = int(input("Введите трехзначное число для получения суммы и произведения его цифр: "))
a = x % 10
b = x % 100 // 10
c = x // 100
y = a + b + c
z = a * b * c
print("Сумма цифр введенного числа:", y)
print("Произведение цифр введенного числа:", z)
|
9cec279e8f2f9a49427bfc194ec78c430eaa3fee | JerinPaulS/Python-Programs | /MinTimeToType.py | 2,565 | 4.21875 | 4 | '''
1974. Minimum Time to Type Word Using Special Typewriter
There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'.
Each second, you... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.