blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fa148a0454f7f4e46649ae27733ee6650327a47b | alisen39/algorithm | /algorithms/sword_offer/24_Solution.py | 888 | 3.671875 | 4 | #!/usr/bin/env python
# encoding: utf-8
# author: Alisen
# time: 2022/5/22 15:26
# desc:
""" 剑指 Offer 24. 反转链表
https://leetcode.cn/problems/fan-zhuan-lian-biao-lcof/
"""
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseList(self, head: ListNode)... |
8d1bae30d12867e1bc9764a70a9ac6cbfc5abc9c | geovanemelo/exercicios-py | /41.py | 494 | 4.21875 | 4 | #Programa que identifica a idade do usuario pelo ano de nascimento
#e informa a categoria dele na natação
Nascimento=int(input("Entre com o seu ano de nascimento: "))
Idade=(2019-Nascimento)
if Idade<=9:
print('Sua categoria é Mirim')
elif Idade >9 and Idade <=14:
print('Sua categoria é Infantil')
elif Idade ... |
54074cef99df8338239426a7bcfe6d9d8c87872f | 8787ooo/200819 | /add3.py | 149 | 3.71875 | 4 |
def add(x,y,z):
i = 0
i = x+y+z
return(i)
x = int(input('x'))
y = int(input('y'))
z = int(input('z'))
n = add(x,y,z)
print(n)
|
a3d780ba0d331d8cfb4ab4744ca5e72a52e46c16 | pjy08062/Winterschool2018 | /버튼2.py | 238 | 3.65625 | 4 | from tkinter import *
window=Tk()
btnList=[None]*3
for i in range(0,3) :
btnList[i]=Button(window, text='버튼'+str(i+1))
for btn in btnList :
btn.pack(side=TOP, fill=X, ipadx=30, ipady=30, padx=10, pady=10)
window.mainloop()
|
d3ae46ac5f49aae52aeec190691d47d9cd3e85ff | lcanalest/python_for_beginners | /20_ForLoop.py | 273 | 4.1875 | 4 | # For Loop (2:32:46)
word = "Sabuesito"
for letter in word:
print(letter)
friends = ["Hugo", "Paco", "Luis"]
print("")
for friend in friends:
print(friend)
print("")
for index in range(5):
print(index)
print("")
for index in range(5, 10):
print(index) |
547ce4f4d147f9e54c88dcc4ad4e9ef75b6a6b24 | NasipCOM/Python-4-Me | /durontu.py | 830 | 3.578125 | 4 |
global cases
cases = int(input())
def duronto_eagle():
planets_list = []
for i in range(cases):
num_of_planets = number_of_planets_inputs()
farthest_planet = -1
planet_index = -1
for j in range(num_of_planets):
x, y = inputs()
distance = x ** 2 + y ** 2... |
b1c9d4799d779e0edb5d0f7d60c34d3c9e4cecac | code-it-camp/day-4 | /tic-tac-toe.py | 5,151 | 4 | 4 | import random
def main():
while input("Play Tic-Tac-Toe? (yes/no) ").lower() == "yes":
game(int(input("How many players? (0/1/2) ")))
def game(num_users):
"""
Designates what type each player is, what their initial scores are,
and starts game loop. Each iteration of the game loop represents a player's turn.
""... |
ae13e4f2b9555e21d1e8823ef900d1b8dc913a9c | Sephfire05/LPTHW | /ex39.py | 2,611 | 4.4375 | 4 | # Dictionaries, Oh Lovely Dictionaries
# Dictionary data structure in Python {}
# Can be used as a database
# key : value
# access by stuff[key]
# create a mapping of state to abbreviation
states = { # Notice how each one is in a key : value
'Oregon': 'OR',
'Florida': 'FL',
'California'... |
d5e4b68234195b93c25a9388c6565c7ef4ad882c | HuXiLiFeng/LeetCode | /swordToOffer/IsPopOrder.py | 1,034 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。
假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但
4,3,5,1,2就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的)
"""
class Solution:
def IsPopOrder(self, pushV, popV):
if not pushV and not popV:
return Fals... |
e11de878666910a6379415ee0a6c1c239aaa7d35 | Aditya-Rajgor/Compyter_Vision | /Tech_with_tim/Tutorial5.py | 478 | 3.71875 | 4 | '''Detecting corners and drawing circle over it using openCV'''
import cv2
import numpy as np
img= cv2.imread('Images/chess_board.jpeg')
img = cv2.resize(img,(0,0), fx=0.5,fy=0.5)
grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
corners = cv2.goodFeaturesToTrack(grey,30, 0.01, 10)
corners = np.int0(corners)
... |
16092f51ccbf054f9d164a142a66d0eef80401a5 | ArMANIAK/cs50 | /pset6/credit/credit.py | 914 | 4 | 4 | from cs50 import get_int
card_num = get_int("Number: ")
card_digits = str(card_num)
total_digits = len(card_digits)
sum = 0
start_num = card_num // (10**(total_digits - 2))
# calculating hash sum
is_other = False
while card_num > 0:
if not is_other:
sum += card_num % 10
card_num //= 10
i... |
2a34cd83d2fff56022ff5165e5a8f0d2afbdaff7 | BryCant/Intro-to-Programming-MSMS- | /BPdebuggingHW.py | 1,109 | 3.71875 | 4 | # Bryant Perkins
# Introduction to Computer Programming
# Programming Assignment 1: Debugging
# Due Date: 25 Oct 2020
# Matt Ryan is the quarterback for the Atlanta Falcons. The following statistics are from their first win of the
# season versus the Minnesota Vikings. Matt Ryan was named NFC Offensive Player of the We... |
fa4ca7f71e2949945152de394d55e8a05180baf9 | Pseudoboss/Journey | /gameMaster.py | 2,414 | 3.734375 | 4 | import time
import random
import config
import exceptions
import entity
import zones
def attack_round(attacker, target):
"""Format and print both the attacker and target attacking.
Parameters
----------
attacker : Entity or subclass of Entity
The Entity that goes first in the round.
I... |
763f0531082091a537de4793f62e1f4df23f2ce8 | arvakagdi/GrokkingTheCodingInterviews | /GTCI_DFS/2/PathWithMaxSum.py | 1,400 | 3.734375 | 4 | import math
class TreeNode:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
class MaximumPathSum:
def find_maximum_path_sum(self,root):
self.GlobalSum = -math.inf
self.find_max(root)
return self.GlobalSum
d... |
a7ccf1dcabd6ce04513bc94c1585c517b58c3c73 | queenie88/cs231a-1 | /ps1/p2.py | 3,608 | 3.734375 | 4 | """CS231A Homework 1, Problem 2.
DATA FORMAT
In this problem, we provide and load the data for you. Recall that in the
original problem statement, there exists a grid of black squares on a white
background. We know how these black squares are setup, and thus can determine
the locations of specific points on the grid (... |
88ee08c5d682037357a094f809f46e99a748f92e | Ayon-Ghosh/Python_Practise | /shapes.py | 4,188 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat May 18 18:53:01 2019
@author: 140524
"""
#Write a program which will find all such numbers which are divisible by 7 but
# are not a multiple of 5, between 2000 and 3200 (both included). The numbers
# obtained should be printed in a comma-separated sequence on a sing... |
c7324fa21d37f4a95ce91f3b643d268c0ce9d4d0 | ajaysahu3964/pythonasminiprograms | /squareroot.py | 159 | 4.03125 | 4 | def square(num):
#num=int(input("enter a number:"))
square_root=num**0.5
return"square root of",num,"is",round(square_root)
print(square(81))
|
6f58f1f04bf085251463cbc468040e7252359459 | anurag5398/DSA-Problems | /Trees/PostOrder.py | 788 | 3.96875 | 4 | """
Given a binary tree, return the Postorder traversal of its nodes values.
NOTE: Using recursion is not allowed.
"""
class TreeNode:
def __init__(self, val):
self.val = val
self.left = self.right = None
from collections import deque
class Solution:
#postorder traversal
def postOrderTrave... |
bb2f9230f409959fa731e1f4a8e95c03e7cf650e | meiordac/Interview | /Code Fights!/countsubarray.py | 275 | 3.640625 | 4 | def Count_SubArray(Array, n, d):
answer=0
suma=0
for i in Array:
for j in Array:
for k in Array:
if i!=j and j!=k:
suma = i+j+k
if suma%d==0:
print (i,j,k)
answer+=1
return answer/3
print Count_SubArray([1,2,3,4,5,6,10,20,30,1,2,5,2,0],3,5) |
f8a557cb0f4bfec6a338c6bd855ad5f3061d2282 | DerHabicht/quickstatus | /expiration.py | 1,143 | 3.515625 | 4 | from datetime import datetime, timedelta
class TimeFormatError(Exception):
def __init__(self, timestamp):
self.timestamp = timestamp
def __str__(self):
return f'{self.timestamp} is not formatted as YYYY-MM-DDTHH:MM'
class Expiration:
def __init__(self, time):
self.time = time
... |
1fa9c4832ab718281b5f228b6992eebc482a373a | shira19-meet/yl1201718 | /lab3/oop.py | 1,123 | 3.9375 | 4 | class Animal(object):
def __init__(self,sound,name,age,favorite_color):
self.sound = sound
self.name = name
self.age = age
self.favorite_color = favorite_color
def eat(self,food):
print(" I like food " + self.name + " is eating " + food)
def description(self):
... |
167500736de86bd7fe8b4e9f06e68999dea99cc1 | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/codewar/_Codewars-Solu-Python-master/src/kyu6_Triangle_Type.py | 2,128 | 4.34375 | 4 | import math
class Solution():
"""
https://www.codewars.com/kata/53907ac3cd51b69f790006c5
In this kata, you should calculate type of triangle with three given sides a, b and c (given in any order).
If all angles are less than 90°, this triangle is acute and function should return 1.
If one angle ... |
ddae346350ee26df7d796739f1f7ebc7583ea33d | CalidaPereira/python-programmes | /hashtable.py | 561 | 4.46875 | 4 | # demonstrate hashtable usage
# Coded with referenec to Joe Marini's course on linkedIn
# TODO: create a hashtable all at once
items = dict({"key1":1,"key2":2,"key3": 3})
print(items)
# TODO: create a hashtable progressively
items1 = {}
items1["key1"]=1
items1["key2"]=2
items1["key3"]=3
print(items1)
# TODO: try t... |
b77e201796bb80e38a85e29f8de857f6da11abcf | arpanmishra09/Python | /Python_Loops conditional Statement and Strings/How to use Replace function.py | 63 | 3.671875 | 4 | n= input('enter the word')
new= n.replace('a','$')
print(new) |
7afb923ea17a6df03fcb3426ef0644d31c6c3474 | ShivaniSakpal/Python | /Basics/prime.py | 449 | 4.15625 | 4 | #WAP to accept a number from the user and check if its prime or not
def prime(n):
flag=0
if(n<2 or n==2):
return 0
elif(n%2==0):
return 0
else:
for i in range(3,n//2,2):
if(n%i==0):
flag=1
return 0
if(flag==0):
return 1
def main():
n=int(input("Enter the number"))
a=prim... |
f9b9e584bdf093aa5f4a7d0c2aec2d4d726ae618 | paiv/aoc2016 | /code/11-1-elevator/solve.py | 3,895 | 3.6875 | 4 | #!/usr/bin/env python3
import itertools
import re
def print_board(elevator, board):
def fmt(i, row):
floor = 'F{}'.format(i+1)
elev = 'E' if i == elevator else '.'
elems = ' '.join(row)
return '{} {} {}'.format(floor, elev, elems)
text = [fmt(i, row) for i,row in enumerate(bo... |
b34d1a46f3ebbb15ef442aaa70a9d7af5e78ee1f | Philex5/codingPractice | /TreeOperation/VerifySquenceOfBST.py | 952 | 3.65625 | 4 | """
剑指Offer 面试题33: 二叉搜索树的后序遍历序列
给出一个序列,判断是否能作为二叉搜索树的后序遍历序列
"""
def verifySquenceOfBST(sequence):
if not sequence or len(sequence) == 0:
return False
print(f'processing {sequence}', end=' ')
# 后序遍历,根节点在序列的最后
root = sequence[-1]
l = len(sequence)
i = 0
# 找到左右子树的分离点
while sequence[... |
fce2f09819c535adbc8708c7eb0ff861a22e0973 | jRead2k18/userOOP | /userOOP.py | 1,248 | 3.546875 | 4 | class User:
def __init__(self, username, email_address):
self.name = username
self.email = email_address
self.account_balance = 0
def make_deposit (self, amount):
self.account_balance += amount
def make_withdrawal(self, amount):
self.account_balance -= amount
... |
7fd0b4b47623943c4ba3018548aa79c8656788c4 | yuchien302/LeetCode | /leetcode274.py | 1,247 | 3.65625 | 4 | __author__ = 'yuchien'
import unittest
class Solution(object):
def hIndex(self, citations):
"""
:type citations: List[int]
:rtype: int
"""
sortedCits = sorted(citations, reverse=True)
n = len(citations)
if n == 0 or sortedCits[0] == 0:
return 0
... |
bd101d4a8a06fd5b09dc397dd8f1fa2a27ca1913 | amakhlin/Udacity-CS373-Artificial-Intelligence-for-Robotics | /unit4_8.py | 2,210 | 4.09375 | 4 | # ----------
# User Instructions:
#
# Define a function, search() that takes no input
# and returns a list
# in the form of [optimal path length, x, y]. For
# the grid shown below, your function should output
# [11, 4, 5].
#
# If there is no valid path from the start point
# to the goal, your function should... |
c3feda96f9779451f4c0a8bb0db324374fc1c35c | majkyun888/python_project | /数据结构/heap.py | 1,545 | 3.625 | 4 | # -*- encoding = utf-8 -*-
class MaxHeap(object):
def __init__(self, hp=None):
if not hp:
self.size = 0
self.heap = []
else:
self.heap = hp
self.size = len(hp)
i = self.size - 1
while i:
self._siftDown(self.__... |
8de43e5ccba6230fc6a13d4180cf6924e55c2488 | mixelpixel/RiceMOOC | /IntroToInteractiveProgramming/week4/optional_ex_4a/user41_VXSg1QhLeZ_0list_reference.py | 387 | 4.25 | 4 | # List reference problem
###################################################
# Student should enter code below
a = [5, 3, 1, -1, -3, 5]
b = a
b[0] = 0
print a
print b
###################################################
# Explanation
'''
b = a created a reference to the list a (the value of a?),
updating b updates... |
6366f6ffaa425809dd9cde12f54020fbdc9b68dc | wangpengfeido/MyLearn3 | /LearnPython/010基础/020基础/030使用list和tuple/020元组.py | 308 | 3.90625 | 4 | # 元组是不可变的,没有append、insert等方法
t1 = (1, 2, 3)
print(t1[1], '\n')
# 定义只有一个元素的元组时,要使用都要以避免歧义
t2 = (1,)
print(t2, '\n')
# 元组虽然是不可变的,但其引用的元素是可变的
t3 = (1, 2, ['a', 'b'])
t3[2][0] = 'aaa'
print(t3)
|
57fc4139a313332b4681393fed2a1262db2a7961 | Gouravsingh21/Algorithms | /DataStructure/linked.py | 525 | 4.09375 | 4 | # write a program to implement linked list
class Node:
def __init__(self,data):
self.data = data
self.next = None
class Linklist:
def __init__(self):
self.head = None
def printlist(self):
temp = self.head
while (temp):
print(temp.data,end=' ')
... |
8712ca1ee3f2628c3357c502553b95a1f833da6d | tianyu06030020/Numpy_CNN | /layer/relu.py | 327 | 3.625 | 4 | # -*- coding: utf-8 -*-
# @Author: Boyuan Jiang
# @Date : 11/30/18
import numpy as np
class ReLU(object):
def forward(self, x):
out = np.maximum(0, x)
cache = x
return out, cache
def gradient(self, dout, cache):
x = cache
dx = np.array(dout)
dx[x<=0] = 0
... |
a77b54092644b4cbabb6789ebe56df84ff90911f | srijitamukherjee/python-test-codes | /fibo.py | 85 | 3.53125 | 4 | a = 0
b = 1
print a
print b
for x in range ( 1, 10 ) :
c=a+b
a=b
b=c
print c
|
4cb63eb68775a968ed62978e3c5cbc0c2558b679 | lucgbrl/ecossistema-django | /none.py | 1,005 | 3.5625 | 4 | import json
data = {}
data ['people'] = []
data['people'].append({
'name':'Lucas',
'website':'santos@workers',
'from':'Brasil',
'degree': [
{
"college" : "Computer Engineer",
"Year" : "2013",
"Area" : "Web Optimization"
},
{
"colle... |
e457e26676fa9daea238288758233f787f2fe868 | burpcat/codedump | /dump1/19.py | 574 | 4.03125 | 4 | # Practise > Python > Strings > Minion Game
# https://www.hackerrank.com/challenges/the-minion-game/problem
def minion_game(mainStr):
vowels = 'AEIOU'
kevScore = 0
stuScore = 0
for i in range(len(mainStr)):
if mainStr[i] in vowels:
kevScore += (len(mainStr)-i)
else:
... |
6b0965f2a601e36a71bdd7ce5e4fb15e1a46cef0 | cmburgul/Graph-Search-Planning | /new_ana.py | 8,218 | 3.859375 | 4 | ## ANA* Algorithm
# import libraries
from sys import version_info
if version_info.major == 2:
# We are using Python 2.x
from Tkinter import *
import ttk
elif version_info.major == 3:
# We are using Python 3.x
from tkinter import *
from tkinter import ttk
import time as t
import numpy as np
''... |
231ecde16645a4685887016c50cff3e9c37398d8 | Hirukamunasinghe/Adding-even-numbers | /main.py | 152 | 4.03125 | 4 | total = 0
for number in range(1, 101):
if number % 2 == 0:
total+= number
print(f"The total of all even numbers from 1 to 100 is {total}") |
9a2e1d00f0fb44ddc6b696747a87a22c6617985f | sjhawkes/EQ_risk | /.ipynb_checkpoints/eq_risk-checkpoint.py | 6,069 | 3.6875 | 4 | # This script reads in historical earthquake data from the Los Angeles region
# and prompts the user to enter the lat-long coordinates of a house for which
# to determine the historical earthquake risk
import pandas
import numpy as np
import matplotlib.pyplot as plt
import math
#load earthquake data from 1950-2020
lo... |
c469ea8677c2ca450ca732bde5b1238cbd4586b3 | dwillist/ProjectEuler | /1-25/Euler5.py | 963 | 3.65625 | 4 | #!/usr/bin/python2.7
import math
def is_prime(integer):
for val in range(2,int(math.sqrt(float(integer)))):
if(integer % val == 0):
return False
return True
def factorize(integer,current = 2):
lis = []
for val in range(current,integer+1):
if( integer % val == 0 and is_pri... |
80aa21626054c2bdf612c9331bfec75f87e9d668 | RuiWu-yes/leetcode | /Python/Algorithms/Greedy/困难/区间问题/763 M_划分字母区间.py | 1,803 | 3.609375 | 4 | # -*- coding: utf-8 -*-
# @Author : ruiwu
# @Email : ryanwoo@zju.edu.cn
# @Title : 763 划分字母区间
# @Content : 字符串 S 由小写字母组成。我们要把这个字符串划分为尽可能多的片段,同一字母最多出现在一个片段中。
# 返回一个表示每个字符串片段的长度的列表。
from typing import List
class Solution:
def partitionLabels(self, S: str) -> List[int]:
# 贪心算法
# 在遍历的过... |
9acb4da9ef118f1b6c6cbd303479a5f15fc4d1ff | alexpradap/python_coursera | /Semana 1/python_m1/consola_calculo_imc.py | 480 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: alexander prada perez
"""
import calculadora_indices as calc
print("Esta funcion calcula el indice de masa corporal a partir de la altura \
y el peso de la persona\n")
nombre = input("Por favor escriba su nombre: ")
peso = input("Ingrese su peso en K... |
3114fd3e91ba785c8b865a6697dcb264fd0b2ff6 | FishGoddess/learn_python | /str_concat_speed.py | 1,880 | 3.921875 | 4 | '''
测试 python 各种字符串连接的速度
author: fish
date: 2018-2-8
'''
import time
# 两种测试数据:
# 一个是不同的字符,一个是相同的字符
diff_many_chars = tuple(str(i) for i in range(1000000))
diff_less_chars = tuple(str(i) for i in range(10))
same_many_chars = tuple("666" for i in range(1000000))
same_less_chars = tuple("666" for i in range(10))
# 测试的... |
269308f056b54fee980019d3b31a0086fc51b9e8 | ardus-uk/rpi-examples | /FruitBowl.py | 1,806 | 3.9375 | 4 | #!/usr/bin/python3
def article(name):
if name[0] in ('a','e','i','o','u'):
return "an"
else:
return "a"
def single_or_plural(simpleword,number):
# This is to pluralise words, simply by adding the letter "s".
# It's not going to work for a sheep, a goose, or a fly
# but at least we'd hope that ... |
ccfbb553b7e4e8570345a126cb4915856b7c1426 | hillal20/pythonToTurial | /whileLoop.py | 493 | 3.78125 | 4 | pots = ['hil', 'bill', 'tom']
for pot in pots:
print(pot)
for pot in pots[0:2]:
if pot == 'hil':
print(f'{pot} -is crazy')
break
else:
print(f'{pot}- not crazy')
age = 10
num = 0
while num < age:
print(num)
num += 1
if num == 5:
continue
print('hello')
fi... |
3c4fe389c7dddc920ad38f33a70508d0b6e85239 | antohneo/pythonProgramming3rdEdition | /PPCh6PE2.py | 937 | 3.984375 | 4 | # aaa
# Python Programming: An Introduction to Computer Science
# python3 & zelle graphics.py module
# Chapter 6
# Programming Excercise 2
def main():
verse("one", "eat a plum")
verse("two", "enquire who")
verse("three", "climb a tree")
verse("four", "hold the door")
verse("five", "keep it live")
... |
90bfe36c75e3d22a2762f4ebda98324deb1767c3 | padawin/cats | /src/city/underground.py | 2,677 | 3.6875 | 4 | # -*- coding: utf-8 -*-
class network(object):
'''
This class is a graph representation of the underground network.
It has a list of stations (nodes). each station has a list of connections
(edges).
if the station 1 has in its connections the station 42, then the station
42 will have the station 1 in its connect... |
fbf0ccfebae697799f6d171520917eef63799786 | Jane11111/Leetcode2021 | /055.py | 1,053 | 3.859375 | 4 | # -*- coding: utf-8 -*-
# @Time : 2021-03-09 09:41
# @Author : zxl
# @FileName: 055.py
"""
TODO 超时
"""
class Solution(object):
def recursiveJump(self,nums,idx,dic):
if idx >= len(nums):
return False
if idx == len(nums) - 1:
return True
if idx in dic:
... |
f00aae3d896a269fdb8d14786fa7da3e96f984da | theo-l/theo-l.github.io | /hacking_python_class_python_source/class_attribute_complex_demo.py | 1,822 | 3.59375 | 4 | class Meta(type):
def __getattribute__(self, item):
print(f'>>>>>>>>Access class attribute: {item} in Meta.__getattribute__!\n')
return super(Meta, self).__getattribute__(item)
def __getattr__(self, item):
print(f'>>>>>>>>Access class attribute: {item} in Meta.__getattr__!\n')
r... |
5056f5f4a1f14c2f7e5c9e5a1000fee12281e3e1 | Jamepaget/Quiz | /Ask user if played before.py | 795 | 4 | 4 | # Functions go here
def yes_no (questions):
vaild = False
while not vaild:
response = input(questions).lower()
if response == "yes" or response == "y":
response = "yes"
return response
elif response == "no" or response == "n":
response = "no"
... |
a76c69c791237617af847714842846d921cfe3e8 | FredericCanaud/Kattis | /Sibice/main.py | 316 | 3.546875 | 4 | import sys
import math
nombres = sys.stdin.readline().split()
nombre1 = int(nombres[0])
nombre2 = int(nombres[1])
nombre3 = int(nombres[2])
for i in range(0,nombre1):
line = int(sys.stdin.readline())
if(math.sqrt(nombre2*nombre2 + nombre3*nombre3) >= line):
print("DA")
else:
print("NE") |
80b301339739d92d7f84ce2bcd097a283229ebb8 | JackDoug/Exercicios-Python | /tabuada.py | 234 | 3.921875 | 4 | '''
n=int(input("digite o valor "))
x=0
while (x<=10):
print(n,"x",x,"=",n*x)
x=x+1
'''
n=int(input("digite o valor "))
x=0
while (x<=10):
print(n,"x",x,"=",n*x)
print("%d x%d =%d" % (n,x,n*x))
x=x+1
|
83d7e1af142f014f8414c430c19d5b9c745841b5 | NickWilsonDev/python-DigitalCrafts | /lunch_tracker/matplotlib.py | 294 | 4.15625 | 4 | # matplotlib.py demo
import matplotlib.pyplot as plot
def f(x):
# code that calculates values
return x
xs = range(-3, 4) # our x-axis values
ys = []
for x in xs:
ys.append(f(x)) # generate our y-axis values
plot.bar(xs, ys) # draw a bar graph
plot.show() # show the graph window
|
05be3dce93f176ee1655932f72baa85272d024cc | pulengmoru/simple_calculator | /function_tests/simple_calculator.py | 166 | 3.796875 | 4 | def add(*numbers):
return sum(numbers)
def multiply(*numbers):
output = 1
for each_number in numbers:
output *= each_number
return output
|
ecba506f9eb4837e43d49b65c3a54f9c34d53356 | atulag123/Codechef_Python_Codes | /rectangles.py | 293 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 11 23:21:51 2020
@author: ATUL AGARWAL
"""
#RECTANGLES
t=int(input())
for i in range(t):
lis=list(map(int,input().split()))
lis.sort()
if lis[0]==lis[1] and lis[2]==lis[3]:
print("YES")
else:
print("NO") |
d7632bef393acee0420b68d6cd09c5188275e05a | yuyuOWO/source-code | /Python/拓扑排序.py | 1,381 | 3.875 | 4 | def topo_sort(graph):
queue = []
for x in graph:
if graph[x]["indegree"] == 0:
queue.append(x)#首先将孤立的点都加入队列中
order_list = []
while len(order_list) != len(graph):#如果没有将所有顶点排完序
cur = queue.pop(0)
order_list.append(cur)
#每添加完一个新的顶点,将该顶点的所有邻接顶点入度都减1
for x... |
4815e980d6719e07006db19e100faf5a7c7236ea | albertosanfer/MOOC_python_UPV | /Módulo 5/Práctica5_2.py | 306 | 3.59375 | 4 | # Define la función miconcatena la cual haga solicite dos parámetros, la
# función deberá hacer un print concatenando ambos parámetros como cadena.
def miconcatena(parametro1, parametro2):
print(str(parametro1) + str(parametro2))
cadena1 = 'Hola'
cadena2 = 'mundo'
miconcatena(cadena1, cadena2)
|
5b2cb615e682ae4836270cefa74ef5c587f10c01 | v2krishna/PracticePython | /01_Basics/class19_OOPS3.py | 678 | 4.125 | 4 | """
Encapsulation
=============
name = "public"
_name = "protected"
__name = "private"
"""
class Demo:
def __init__(self):
self.name = "public"
self._age = "protected"
self.__year = "private"
def display(self):
print(self.name)
print(self._age)
print(self.__year)... |
e82793659de82c65a2110a50fd1bf08928a1394d | dimple1024/100DaysofDSAlgo | /triple_step_using_dp.py | 719 | 4.3125 | 4 | #Cracking the interview , ques 8.1
#Recursion requires extra memory due to call stack formed, and runtime 3**n,
#however if followed a bottom up approach and memoisation i.e using the cached result,
#we can reduce the time complexity to O(n)
def triple_step(n,steps):
steps[0]=1
steps[1]=1
steps[2]=2 # chil... |
ac3b84e5546206dbd8f9066e4d415f571debafb6 | philliphelms/rsvd | /rsvd.py | 2,699 | 3.578125 | 4 | import numpy as np
import time
def orthonormal_mat(v):
# Copy matrix
u = v.copy()
m,n = v.shape # m rows, n cols
# Make Orthogonal
for k in range(n):
for j in range(k):
u[:,k] -= np.einsum('i,i->',v[:,k],u[:,j])/np.einsum('i,i->',u[:,j],u[:,j])*u[:,j]
# Make normal
for k... |
f127674339289d8615b34c40d06d1e8020073503 | AmI-2015/python-lab1 | /primes.py | 1,717 | 3.859375 | 4 | '''
Created on Mar 18, 2014
Copyright (c) 2014-2015 Dario Bonino
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law... |
c0a33b4538f20b1194447b072c676ca06a3c5985 | jasonsu93/cebd_1100_code_winter_2021 | /Class 2/arithmatic_exercise.py | 167 | 3.640625 | 4 | x = 14
y = 8
# print(x + y)
# print(x - y)
# print(x * y)
print(x / y)
print(x // y)
# a = 8.5
# b = 3.4
# print(a + b)
# print(a - b)
# print(a * b)
# print(a / b) |
f17dec3f4c8c4e8a1c41a55e37e5c8b8cedb694a | device999/Machine_Learning | /HelloWorld/Algorithms_II/device999/binary.py | 771 | 4.0625 | 4 | class TreeNode:
def __init__(self,x):
self.value = x
self.rightNode = None
self.leftNode = None
def generate_tree(numbers):
if not numbers:
return None
middle = len(numbers)//2
node = TreeNode(numbers[middle])
node.leftNode = generate_tree(numbers[:middle])
node... |
bd30dceb612687ea85354a7ed0a0db46f097c030 | pallavi23022/Python-Programs | /splitList.py | 457 | 3.6875 | 4 | length=int(input("Enter length of a list: "))
list1=[]
list2=[]
srange=int(input("ENter range of splitting: "))
for i in range(length):# makine a list
num=int(input("Enter a number"))
list1.append(num)
for i in range(len(list1)):
list2.append(list1[0:srange])#appending srange into a new list
del list1[... |
cfa00328e161ebb031ba1eaebfce565b9edf1406 | VinayagamD/PythonTrainingBatch1 | /assigments_demo/bio_data.py | 2,946 | 4.375 | 4 | """
1) Design a class to take bio data:
Consists of following Information
a) Your name
b) Your age
c) Your school name
d) Your Father name and occupation
e) Your Mother name and occupation
f) Your Hobbies
g) Your Friends Name
h) Your ambition
Following Operation need to be done... |
14bd4815d9b4c884882979a55853c03722a1449f | jean3108/TwoPlayer-Game | /twoPlayerAiGame/stateGame.py | 5,011 | 3.828125 | 4 | from abc import ABC, abstractmethod
from twoPlayerAiGame.aiAlgorithms import minmaxDecision, negamaxDecision, randomDecision, humanDecision
class StateGame(ABC):
"""
Class wich represent a state of a two-player game
"""
@abstractmethod
def __init__(self, maxPlayer):
"""
C... |
ccc666c0e6eaefe3d042595b36292fcb8c81679a | oneplus-x/oneplus-x.github.io | /2018/01/17/Code-Challenges/aoc2018/DayFive.py | 1,162 | 3.53125 | 4 | #Instructions: https://adventofcode.com/2018/day/5
import time
from string import ascii_lowercase
with open('input.txt','r') as f:
d = f.read()
data = d
#Part one
start = time.time()
i = 0
while True:
cD = data
for c in range(len(data)):
try:
if data[c].lower() == data[c+1].lower() and data[c] != data... |
f1554a8acca64f708225fd9d9c40e3dd9310678f | chinmaymokashicm/programming | /decibinary.py | 3,832 | 4.1875 | 4 | """
Decibinary system:
(2008)decibinary = 2*2^3 + 0*2^2 + 0*2^1 + 8*2^0 = 24(10)
x Decibinary Decimal
1 0 0
2 1 1
3 2 2
4 10 2
5 3 3
6 11 3
7 4 4
For given 'x', calculate decibinary value
https://www.hackerrank.com/challenges/decibin... |
098c0eca5eee4074c3f6c489a40f49bef2a8f50f | rohitchandrakantgore/CodeRecipeGuide | /MarvellousAssignments/Assignment_5/Problem_4.py | 301 | 3.953125 | 4 | def sumofn(num):
if num==0:
return 0
return (num%10) + (sumofn(num//10))
if __name__ =="__main__":
num = int(input("Enter Number: "))
print("Sum of Digits: ",sumofn(num))
# >python MarvellousAssignments/Assignment_5/Problem_4.py
# Enter Number: 23124
# Sum of Digits: 12 |
f8402e800dac5702e47de4635bf9f3866f619535 | Shivani3012/PythonPrograms | /conditional ass/ques43.py | 217 | 4.40625 | 4 | #. Write a Python program to create the multiplication table (from 1 to 10) of a number.
n=int(input("Enter the number between 1 to 10 to print the table:"))
for i in range(1,11):
print("%s X %s = %s" %(n,i,n*i))
|
06e8c8495d7d531b44b82abc1e9bf78c800f011f | kazisohag/Problem-solving | /uri1038.py | 287 | 3.53125 | 4 | X,Y = map(int, input().split())
if X == 1:
T =(Y*4.00)
print("Total: R$ %d",T)
elif X == 2:
T = (Y*4.50)
print("Total: R$ %d",T)
elif X == 3:
T =(Y*5.00)
print("Total: R$ %d",T)
elif X == 4:
T =(Y*2.00)
print("Total: R$ %d",T)
elif X == 5:
T =(Y*1.50)
print("Total: R$ %d",T)
|
b399b63cb38666236045e0a59824c9d82cd7c904 | layanabushaweesh/data-structures-and-algorithms-401 | /challanges/merge_sort/merge_sort.py | 710 | 4.09375 | 4 | def Mergesort(array):
n = len(array)
if n > 1:
mid = int(n//2)
right = array[mid:]
left = array[0:mid]
Mergesort(right)
Mergesort(left)
Merge(left, right, array)
def Merge(left, right, array):
k = 0
i = 0
j = 0
while i < len(left) and j < len(right):
... |
1a561c93e2e9db6f6b14d7a88d5990c52aa12868 | jchrismiller/python_dec_2017 | /j_chris_miller_python/python_OOP/animal.py | 871 | 3.8125 | 4 | #Animal
class Animal(object):
def __init__(self, name):
self.name = name
self.health = 100
def walk(self):
self.health -= 1
return self
def run(self):
self.health -= 5
return self
def display_health(self):
print self.health
class Dog(Animal):
def __init__(self, name):
super(Dog, self).__init__(... |
946a05a10f055dac5210af526b6f885180af404e | ShengChieh623/python-crawler | /Python Training/number-string.py | 933 | 4.15625 | 4 | # 數字運算
x=3+6
print(x)
x=3-6
print(x)
x=3/6 # 小數除法,看小數點
print(x)
x=3//6 # 整數除法,不看小數點
print(x)
x=2**3 # 2的3次方
print(x)
x=2**0.5 # **0.5開根號
print(x)
x=7%3 # 餘數
print(x)
x=x+1 # 將變數中的數字 +1
print(x)
x+=1 # 同上簡寫法
print(x)
x-=1
print(x)
x*=2
print(x)
# 字串運算
s="Hello"
print(s)
s='Hello' # 與上述字串相同
print(s)
s="Hello\"" # \ 跳脫字串... |
4d60e8601c9fa6f64f61ed9078e1c3e8fa79cabd | krikavap/python-kurz | /nakupniSeznam.py | 964 | 3.6875 | 4 | """
nakupniSeznam.py
nejprve je zadáno počet položek nákupu
pak se zadávají položky seznamu a kontrolují se na duplicitu
seznam je vypsán před a po setřídění
"""
pocet = int(input("Zadej počet položek v seznamu: "))
i = 0
seznam = []
if pocet > 0:
while i in range(0, pocet):
j = i + 1
polozka = s... |
f664b0344d96d256955b74d52ba0992da1b8f47f | Arturok/TEC | /Intrucción y Taller de Programación/Progras en Clase/Hay_Entero_Lista_Ver1.0.py | 373 | 3.53125 | 4 | #E: Lista
#S: Booleano indicando si hay entero
#R: Lista no nula
def hay_entero(lista):
if lista != []:
return hay_entero_aux(lista)
else:
return "Error"
def hay_entero_aux(lista):
if lista == []:
return False
elif isinstance(lista[0], int):
return True
... |
af2ec9c5d25ceda9d0d129cfa846d38738ed16b9 | lara264/encrypt_decrypt | /substitution_cipher.py | 858 | 3.875 | 4 | alphabet = ""
for i in range(32, 127):
alphabet += chr(i)
print(alphabet)
key = ""
for n in alphabet:
key = n + key
print(key)
def encrypt(message):
result = ""
for letter in message:
location = alphabet.find(letter)
result += key[location]
return result
def d... |
b7c1974a355105d5871ee0d09d4eca1ce7668f35 | scohen40/wallbreakers_projects | /Leetcode/week_4/p0078_subsets.py | 1,425 | 3.71875 | 4 | from typing import List
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
return self.subsets_backtracking(nums)
def subsets_backtracking(self, nums: List[int]) -> List[List[int]]:
self.power_list = []
def _recurse(max_len, cur_len, index, path):
if... |
e7898e138fce1bdbcfcd086ecbe3a9f99ce9cfb9 | tenzinchoedak/webdev | /04-django/01-python-intro/greet.py | 133 | 3.765625 | 4 |
def greet(greeting):
name = input("What's your name?\n")
return greeting + name
print(greet("Hello "), "nice to meet!")
|
410cc041bffe2d4889979e96a399ae8158724a9e | EliRuan/ifpi-ads-algoritmos2020 | /LISTA Fábio 01_Parte 01/f1_q14.py | 344 | 4 | 4 | #entrada
nota_1 = int(input('Digite a primeira nota (peso 1): '))
nota_2 = int(input('Digite a segunda nota (peso 2): '))
nota_3 = int(input('Digite a terceira nota (peso 3): '))
#processamento
média_ponderada = ((nota_1 * 1) + (nota_2 * 2) + (nota_3 * 3)) / 6
#saída
print('A média ponderada das 3 notas é:',... |
8804631c5b9bde2344ee6494ff3dcaa1110b4c6a | Austraala/TP-TDLOG | /TP2/domino.py | 3,624 | 4.1875 | 4 | """ File for the class "Domino"
Jean-Loup Raymond & Benjamin Roulin
ENPC - (c) 05/10/2020
"""
class Domino:
"""
We define the Domino class
It contains two integers corresponding to the left and right part of it
"""
# We give the two numbers on both halves of the Domino
... |
6cbddf335d9d979d4b58b7a335e41f5c3eefcd14 | wirsu/scikit-image | /doc/examples/applications/plot_pixel_graphs.py | 3,620 | 3.8125 | 4 | """
====================================================
Use pixel graphs to find an object's geodesic center
====================================================
In various image analysis situations, it is useful to think of the pixels of an
image, or of a region of an image, as a network or graph, in which each pixe... |
762e620e2d4ab60ef60b65522353a81895730f55 | NotAKernel/python-tutorials | /sandwiches.py | 220 | 3.6875 | 4 | def sandwich(*items):
"""Prints a summary of the sandwich"""
print(f"\nHere is your sandwich:")
for item in items:
print(f"- {item.title()}")
sandwich('ham','cheese','butter', 'chicken', 'mayo')
|
ebd7870144e152ffbb075b357f011f6021a2a7a9 | alitsiya/interview_questions | /fibonacci_sequence.py | 1,064 | 4.28125 | 4 | # Write a recursive function to compute the Fibonacci sequence. How does the
# performance of the recursive function compare to that of an iterative version?
def fib_seq(n):
"""
Non recursive solution
>>> fib_seq(9)
[2, 3, 5, 7, 11, 13, 17, 19, 23]
"""
res = []
num = 2
while len(res)... |
60f2479ee5f84d4ca710e7c7e38bf5e66f35c444 | deepcapsule/Python | /datastructure/探查哈希策略/hashtable.py | 1,541 | 3.890625 | 4 | from arrays import Array
class HashTalbe(object):
"Represents a hash table."
EMPTY = None
DELETED = True
def __init__(self,capacity = 29, hashFunction = hash,
linear = True):
self._table = Array(capacity, HashTalbe.EMPTY)
self._size = 0
self._hash = hashFuncti... |
f8272f95eda0221fa4e416600291d1ccf97235f3 | nnnazek/ICT | /ict/33.py | 195 | 3.71875 | 4 | a = int(input())
print("loaves discount")
r = a*3.49
d = 0.6*3.49*a
a = 0.4*3.49*a
print("regular price "+str(r))
print("total discount "+str(d))
print("total amount to be paid "+str(a)) |
44999874180fa2d067e4054d5499bf14efedde08 | Th3Lourde/l33tcode | /5497_find_latest_group.py | 1,771 | 3.765625 | 4 | '''
Given a list of zeros.
As we loop through arr,
arr[i] represents the zero that
we are going to be setting to one.
We want to return the latest step,
where there exists an adjacent grouping
of ones of size m.
use sliding window in order to check
for ones.
Don't start until we have done a certain
number of steps... |
813fa35a13eb37d1472ac338c3215fa881c4824e | HyeonGyuChi/2019_1st_Semester | /Python_Programing/Exercise10/Q4.py | 3,773 | 3.734375 | 4 | from tkinter import *
from tkinter import messagebox
import sqlite3
window = Tk()
# tk 함수
def createTable():
con = sqlite3.connect("classDB")
cur = con.cursor()
try :
cur.execute("DROP TABLE IF EXISTS studentTable")
cur.execute("CREATE TABLE studentTable(name char(10), stdid char(15), gr... |
56f1c9051a35ef64d3eb05510e2025089fb30315 | potsawee/py-tools-ged | /gedformatconvert.py | 1,861 | 3.671875 | 4 | import sys
def one_word_to_one_sentence(input, output):
with open(input, 'r') as f1:
with open(output, 'w') as f2:
newline = []
for line in f1:
if line == '\n':
if len(newline) > 0:
f2.write(' '.join(newline) + '\n')
... |
45c6851895fee305907d7a68bc524f0e4c3c6642 | benpegg/GamestonkTerminal | /gamestonk_terminal/cryptocurrency/crypto_helper.py | 392 | 3.8125 | 4 | """
Helper script that generates a dictionary to convert between symbols and IDs.
This allows the user to input (for example) "btc" instead of the expected "bitcoin"
"""
from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
coins = cg.get_coins()
coin_symbol_to_id = {}
coin_ids = []
for coin in coins:
coin_sy... |
51db4abb162876e02cbc9b628a0c2620ae0cb622 | donaghy/Programming | /Python/jp.tmp/Ejercicios/Certamen I/5-Diseño de algoritmos/1-5-07-Numero_palindromo.py | 465 | 4.15625 | 4 | #! /usr/bin/env python
#coding: utf-8
numero = int(raw_input('Ingrese un número: '))
revez = 0
original = numero #Guardamos el numero original para compararlo mas tarde
while numero != 0:
revez = (revez*10 + numero % 10)
# n % 10 devuelve el ultimo digito de n
# asi 12345 % 10 = 5
# tambien funciona con 100, 100... |
d231ff95484cc4d8cfdee3eea81572671e277d8c | Inflearn-everyday/study | /realcrystal/Boj9012.py | 461 | 3.703125 | 4 | t = int(input())
for i in range(0, t):
target = input()
opCnt = 0
cpCnt = 0
result = True
for letter in target:
if letter == '(':
opCnt += 1
else: #letter == ')'
if opCnt == cpCnt:
result = False
break
cpCnt += 1
... |
ad3bea526fb841fdbbaa4dc1d541f38fc85fad22 | Gavinee/Leetcode | /617 合并二叉树.py | 1,396 | 3.984375 | 4 | """
给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。
你需要将他们合并为一个新的二叉树。合并的规则是如果两个节点重叠,那么将他们的值相加作为节点合并后的新值,否则不为 NULL 的节点将直接作为新二叉树的节点。
示例 1:
输入:
Tree 1 Tree 2
1 2
/ \ / \ ... |
97efa7bab89053183b74933d8651d94138d51d11 | Talha089/Python-for-Everybody | /Using Python to Access Web Data/Week2_RegEx/withoutRegEx.py | 244 | 3.734375 | 4 | # Extracting a host name using the find method and string slicing
data = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
atpos = data.find('@')
print(atpos)
#21
sppos = data.find(' ' , atpos)
print(sppos)
#31
host = data[atpos+1 : sppos]
print(host) |
f97b7b24c217f3ae1756cb44578e4879dca9774e | virgorasion/My-Python | /Check_palindrom.py | 605 | 3.984375 | 4 | from Module import Deque as deq
def isPalindrome(katas):
palindrome = deq.createDeque()
for kata in katas:
deq.addFront(palindrome, kata)
cek = True
while deq.size(palindrome) > 1:
if deq.removeFront(palindrome) == deq.removeRear(palindrome):
cek = cek and True
els... |
5e1701f7e6bacd906315ead36a73e75588a2c64c | aasthaagrawal/Algorithms_and_Data_Structures | /leetcode/415_Add_Strings_impl1.py | 1,533 | 3.734375 | 4 | #https://leetcode.com/problems/add-strings/
#Complexity: O(n)
class Solution:
def addThree(self, num1: str, num2: str, lenNum1: int, lenNum2: int):
carry=0
sumString=""
while(lenNum1>=0):
loopSum=int(num1[lenNum1],10)+int(num2[lenNum2],10)+carry
carry=loopSum//10
... |
df9308050e3d6efe7508b72e270656897643f386 | edu-athensoft/stem1402python_student | /py210912e/day01_210912/func_9.py | 371 | 3.859375 | 4 | """
How does it works?
"""
def travel():
"""
travel to my school
:return:
"""
print("getting my opus card")
print("walk to bus stop")
print("get to subway station")
print("get on board")
print("get off")
print("go into campus")
# call the function immediately
print("=== star... |
c094e3c26f0f659711cdb0206710ed5f7fea19c9 | valerii-other/Python-Lessons | /Lesson 3 task 4.py | 233 | 3.65625 | 4 | fig = input("PLease input yoyr number: ")
s = str(fig)
s2=""
if fig < 0:
s2+=s[0]
for i in range(len(s)-1,0, -1):
s2 += s[i]
elif fig > 0:
for i in range(len(s)-1,-1,-1):
s2+=s[i]
print(s2)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.