blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
edec4a87a37e8b793a1b419c1be2261745b99fb6 | akimi-yano/algorithm-practice | /lc/review_1291.SequentialDigits.py | 1,300 | 3.78125 | 4 | # 1291. Sequential Digits
# Medium
# 878
# 67
# Add to List
# Share
# An integer has sequential digits if and only if each digit in the number is one more than the previous digit.
# Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits.
# Example 1:
# Input: l... |
f9a7ae48d416bf6506247ad7aa0681e64023216e | GL324/Facial_Keypoints | /models.py | 1,558 | 3.53125 | 4 | ## TODO: define the convolutional neural network architecture
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
# can use the below import should you choose to initialize the weights of your Net
import torch.nn.init as I
class Net(nn.Module):
def __init__(sel... |
685df561822b4feeb37e4685fbaf44b17f8e094c | SILIN-WANG/Sandbox | /Prac_02/files.py | 498 | 3.8125 | 4 | out_file = open("name.txt","w")
name = input("What is your name?")
print(name, file=out_file)
out_file.close()
out_file = open("name.txt","r")
name = out_file.readline()
print("Your name is {}".format(name))
out_file.close()
out_file = open("number.txt","r")
num1 = int(out_file.readline())
num2 = int(out_file.readl... |
5683a39f5287fe231ff0f4806dbbdaab6dd4715b | vineethkuttan/College_Programs | /PYTHON/Semester 2/session7/t3.py | 69 | 3.59375 | 4 | import re
x=input()
y=re.findall('[A-Z][a-z]+',x)
print(' '.join(y))
|
3a8e799e3816df332189107a9050b5d4d8357ac0 | pkasper/info1-bm | /2016/tutor_sessions/unit_3/notebooks/3_Student_task_solved.py | 652 | 3.78125 | 4 |
# coding: utf-8
# In[ ]:
# Opening the file and reading the data
import pickle
with open('small_list.pickle', 'rb') as file:
number_list = pickle.load(file)
# In[ ]:
# Calculate the mean from a list of numbers
# In[ ]:
def calc_median(elem_list):
elem_list.sort()
length = len(elem_list)
half_l... |
25ccb700e14d4bdc99dd0225ffc32cd37d0b7cab | jwright0991/KruskalsMSF | /KruskalsMSF.py | 3,195 | 3.796875 | 4 | import heapq
import sys
#Author - Josh Wright
#Kruskals's Programming Assignment
#Reads in a formatted file that contains an edge-weighted directed graph.
#Uses Union-Find data structure with path compression to text for cycles.
#Heapq data structure implemented by adding all the elements to a list and heapifying the l... |
81d49875724b37520079b9b41c02d6cd63829445 | MayankMaheshwar/fullpython | /Untitl.py | 586 | 3.890625 | 4 | class Mom:
def __init__(self,name,color):
self.name=name
self.color=color
def lov(self):
print("hello " + self.name)
def __add__(self,other):
return Mom(self.name+ other.name,self.color+ other.color)
class Mayank(... |
d53744b645336afc93dcddcd1a77d4bbd895b125 | dabeiT3T/Data-Structures-Answer | /Chapter 4 Arrays and Linked Structures/Quiz 2/arrays.py | 1,120 | 4.28125 | 4 | #!/usr/bin/env python3
'''
Author: dabei
My answer to Chapter 4 Quiz 2.
'''
class Array:
'''Represents an array'''
def __init__(self, capacity, fillValue = None):
self._items = [fillValue for i in range(capacity)]
# logical size
self._logicalSize = 0
def size(self):
'''Get ... |
f56742594244dcc5edf17389b2b7d9c8621dbb81 | zhangpanzhan/leetcode-solution | /20120901 Recover Binary Search Tree.py | 1,158 | 3.78125 | 4 | class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
'''
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n) space is pretty straight forward. Could you ... |
1db6d0a11e1e462a7fda8b1ea7923709e016fb5c | KhanWhale/Sudoku | /Board.py | 7,122 | 3.640625 | 4 |
class Tile:
num = None
candidates = []
row = 1
column = 5
square = 3
def __init__(self, val, board=None):
self.board = board
if val not in range(1,10):
self.num = None
self.candidates = list(range(1,10))
else:
self.num = val
def __... |
dc9c4f5a9c22f8902bc8a272cf05861052e0b6f5 | ArBond/ITStep | /Python/lessons/lesson10_function/main7.py | 491 | 4.125 | 4 | #7.Напишите функцию fib(n), которая по данному целому неотрицательному n возвращает n-e число Фибоначчи.
# В этой задаче нельзя использовать циклы — используйте рекурсию.
def fib(n):
if n <= 2:
return 1
else:
return fib(n - 1) + fib(n - 2)
n = int(input("Kakoje chislo chislo: "))
pri... |
ab0cd1ceae1c83b7df3389f2e465ae2da257be39 | Nev-Iva/my-projects | /basic python (0 level)/7 exception handling/1.py | 307 | 3.6875 | 4 | fruit_list_1 = ['Яблоко', 'Банан', 'Киви', 'Апельсин', 'Манго', 'Персик']
fruit_list_2 = ['Яблоко', 'Мандарин', 'Апельсин', 'Фрукт_1', 'Фрукт_2']
result = []
result = [fruit for fruit in fruit_list_1 if fruit in fruit_list_2]
print(result) |
ce1c7cc68598892a6f6e5bb6ba6d93add0822d4c | Dimitrioglo/Find_Betrayal | /game.py | 3,952 | 3.75 | 4 | from random import randint
class CreateBot():
def __init__(self, bot_name, bot_color, bot_pos, bot_tip):
self.bot_name = bot_name
self.bot_color = bot_color
self.bot_pos = bot_pos
self.bot_tip = bot_tip
def new_bot(self, arr):
for i in range(n):
for j in ra... |
0c3bf4478f0e06bba10a475971db4aaeefca111e | ThomasCarstens/SelfStudyIRM | /Data_structures/dictionary.py | 2,295 | 4.03125 | 4 | import numpy as np
import math
import test
import matplotlib.pyplot as plt
# orders = {
# 'cappuccino': 54,
# 'latte': 56,
# 'cortado': 41
# }
#
# sort_orders = sorted (orders.items(), key=lambda x: x[1], reverse=True)
#
# for i in sort_orders:
# print (i[0], i[1])
#
# #also:
# [print(key, value) for (... |
8802d8396d5858c7cd221e1d04cbedfd2685e61e | chrislucas/hackerrank-lp-python | /builtin/Lambda/src/xplore/XploreReduce.py | 356 | 3.59375 | 4 | from functools import reduce
def summation():
return reduce(lambda x, y: x + y, [1, 2, 3, 4, 5])
def sumTerms(_list, i):
_list[i&1] = _list[i & 1] + _list[(i-1) & 1]
def fib(n):
_list = [0, 1]
reduce(lambda a, i: sumTerms(_list, i), [i for i in range(1, n + 1)])
return _list
print(fib(30))
... |
de999cf213bef860ac5bcce9c3e99ab824a48cdb | athdsantos/Basic-Python | /CourseC&V/mundo-1/ex017.py | 463 | 3.875 | 4 | '''catOposto = float(input('Cateto Oposto: '))
catAdj = float(input('Cateto Adjacente: '))
hi = (catOposto ** 2 + catAdj ** 2) ** (1/2)
print('Cat OP {} Cat Adj {} e hip {:.2f}'.format(catOposto, catAdj, hi))
'''
from math import hypot
catOposto = float(input('Cateto Oposto: '))
catAdj = float(input('Cateto Adja... |
f431ce7067a9060c9c5c55490d430c1d64f43afe | karolinanikolova/SoftUni-Software-Engineering | /2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/03-Lists-Basics/02_Exercises/04_Number-Beggars.py | 1,205 | 3.78125 | 4 | # 4. Number Beggars
# Your task here is pretty simple: given a list of numbers and a number of beggars, you are supposed to return a
# list with the sum of what each beggar brings home, assuming they all take regular turns, from the first to the last.
# For example: [1,2,3,4,5] for 2 beggars will return a result of 9 a... |
13be1d398842417f58eef082f7741f62225057ff | 610yilingliu/leetcode | /Python3/490.the-maze.py | 1,101 | 3.59375 | 4 | #
# @lc app=leetcode id=490 lang=python3
#
# [490] The Maze
#
# @lc code=start
class Solution(object):
def hasPath(self, maze, start, destination):
"""
:type maze: List[List[int]]
:type start: List[int]
:type destination: List[int]
:rtype: bool
"""
def dfs(x,... |
47851b2b9f0b337f1395c2332e4980cd9fe87c3c | calgaryfx/2021_programs | /Edabit/profitable_gamble.py | 436 | 3.6875 | 4 | # Create a function that takes three arguments prob, prize, pay and returns
# True if prob * prize > pay; otherwise return False.
def profitable_gamble(prob, prize, pay):
if prob * prize > pay:
return True
else:
return False
a = profitable_gamble(0.2, 50, 9)
print(a)
a = profitable_gamble(0.9,... |
e59470052824a345087dd03ca528709d55b4f09b | zuoyuanh/365-lab1 | /lab1-1/schoolsearch.py | 4,669 | 3.6875 | 4 | import sys
class Student:
def __init__(self, data):
self.stLastName = data[0]
self.stFirstName = data[1]
self.grade = data[2]
self.classroom = data[3]
self.bus = data[4]
self.gpa = data[5]
self.tLastName = data[6]
self.tFirstName = data[7]
def matchedByStLastName... |
3dfbb8ed9c5baf84ebf333d77f2045502d38fc94 | xueanxi/learnAi | /test/18_array.py | 449 | 4 | 4 | array1 = ("a",) # 声明一个元组 ,如果里面只有一个对象,需要加一个逗号
print("len of array1 : ", len(array1))
array2 = ("a", "b", "c", "d") # 声明元组的方法1
print("len of array2 : ", len(array2))
array3 = "e", "f" # 声明元组的方法2
print("len of array3 : ", len(array3))
array4 = ("g", "h", array2)
print("len of array4 : ", len(array4))
print("array4 ... |
111ef66915c38eeb41a2a3e177df994dfc7b4710 | hayfiz/Base-Converter | /Base Converter.py | 1,619 | 3.65625 | 4 |
# coding: utf-8
# In[2]:
def convert(input, source, target):
if (source == "0123456789") & (target == "01"): #converting decimal to binary
return bin(int(input))[2:]
if (source == "01") & (target == "0123456789"): #converting binary to decimal
return int(input, 2)
if (... |
67716d4e2a1beaad2b11c0eec63d41509b2fc63f | simi153/python_kurs | /dzien_4/dunkcje_zadanie_1.py | 444 | 3.921875 | 4 | def is_anagram(text1, text2):
text1 = sorted(list(text1.lower()))
# text1.sort()
text2 = sorted(list(text2.lower()))
# text2.sort()
if text1 == text2:
return True
else:
return False
def test_is_anagram():
assert is_anagram("Tokyo", "Kyoto") == True
assert is_anagram("An... |
445815c6ca1b6df27dd14da5472bde64db35e4bd | pavlosZakkas/benchmarking-streaming-ddps | /generator/connector.py | 626 | 3.53125 | 4 | import socket
class SocketConnectionException(Exception):
pass
def wait_for_connection_to(host, port):
"""
Opens a socket at the given host and port, waits for the client
system to connect, and returns tha socket connection
"""
try:
stream_socket = socket.socket(socket.AF_INET, socke... |
662e588c12a1b86f9466a2ab5875c3ab420bc327 | L0ganhowlett/Python_workbook-Ben_Stephenson | /35 Dog Years.py | 180 | 3.703125 | 4 | # 35 Dog Years
x = int(input("Enter the number of human years = "))
if x < 2:
age = 10.5 * x
else:
age = 21 + (x - 2) * 4
print("The number of dog years is = ",age)
|
84c942a850adda406ea8ed17162644052f4e9beb | CauchyPolymer/teaching_python | /python_class/a04_mi.py | 613 | 3.765625 | 4 | class Grandparent():
def __init__(self):
self.car = 'Great Car'
class Father(Grandparent):
def __init__(self):
Grandparent.__init__(self)
self.house = 'Big house'
class Mother(Grandparent):
def __init__(self):
Grandparent.__init__(self)
self.land = 'Big Land'
class... |
b51c161a6d4c6fc7509b1594d08b2030b3308d49 | ramesh1990/Python | /Easy/sumOfKfrom2Lst.py | 454 | 3.828125 | 4 | '''
Find Sum of two number as K.
input :
A = [0,0,-5,30212]
B = [-10,40,-3,9]
K = -8
output = True, (-5,-3)
'''
def sumOfTwo(lst1,lst2,k):
hash = {}
for i in lst1:
r = k - i
if i not in hash:
hash[r] = i
for j in lst2:
if j in hash:
return (True,(j,has... |
a9eeb58801ae703ca3a7ee86bc82cb194bd20958 | mbu4135/syntax | /help_createtable.py | 596 | 3.6875 | 4 | #!python
import mysql.connector
# MySQL Connection 연결
mydb = mysql.connector.connect(
host="localhost",
user="mbu4135",
passwd="1288zpmqal",
charset="utf8",
database="menshut"
)
mycursor = mydb.cursor()
mycursor.execute('DROP TABLE IF EXISTS help')
mycursor.execute("CREATE TABLE help (id int(11) NOT NULL A... |
3dcc4ac57b0ce744901cf619bb131b7410435c04 | RAMKUMAR7799/Python-program | /Beginner/Gnumbers.py | 286 | 4.25 | 4 | num1=int(input("Enter your number"))
num2=int(input("Enter your number"))
num3=int(input("Enter your number"))
if(num1>=num2 and num1>=num3):
print(num1,"is greatest number")
elif(num2>=num1 and num2>=num3):
print(num2,"is greatest number")
else:
print(num3,"is greatest number")
|
47a8edd0833009d7d9cf2c0279ffe122f9c81171 | flippersmcgee/Refactoring-Practice | /Tennis/python/tennis.py | 2,804 | 3.796875 | 4 | # -*- coding: utf-8 -*-
class TennisGameRefactored:
score_names = {0: "Love", 1: "Fifteen", 2: "Thirty", 3: "Forty"}
def __init__(self, player1Name, player2Name):
self.player1Name = player1Name
self.player2Name = player2Name
self.p1points = 0
self.p2points = 0
def ... |
72b33aee52b5c2f8daeb8f2678d32fb9b0588391 | jtm172018/assignment-6 | /ps1.py | 522 | 3.890625 | 4 | ###### Assignment 1 parity check and framing .py file ###########
####### write your code here ##########
def parity(x): # function for parity bit
z=x.count('1')
if z%2==1:
return 0
else:
return 1
x= input()
x=str(x)
z=parity(x)
z=str(z)
frame=(x+z)
print(frame) #frame after parity bit addition
m=f... |
74f1bce02dc47a95a2f2e4a5dec4032249346ae8 | shaktisingh7409/faulty_calculator | /rough_work.py | 170 | 4 | 4 | list1 = ["shakti", "deepak", "abhishek", "himanshu", "23",5,11,23,4,45,2,7,657]
for item in list1:
if type(item) == int:
if item > 6:
print(item) |
21f0e3f8d661bdf915b459fae23f416cb87410f5 | Twicer/Homeworks | /Homework9-15.03/Task2(bd).py | 3,787 | 3.71875 | 4 | """
Задача 2
Реализовать программу с базой учащихся группы (данные хранятся в файле).
Записи по учащемуся: имя, фамилия, пол, возраст.
Программа должна предусматривать поиск по одному или нескольким полям базы.
Результат выводить в удобочитаемом виде с порядковым номером записи.
Скрипт программы должен принимать парам... |
9178b61b24d57472299854f0ad1b127834220e0d | sankeerth/Algorithms | /Tree/python/leetcode/add_one_row_to_tree.py | 2,754 | 3.765625 | 4 | """
623. Add One Row to Tree
Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth 1.
The adding rule is: given a positive integer depth d, for each NOT null tree nodes N in depth d-1,
create two tree nodes with value v as... |
a19bfb60cdb49c381d7b789e352c41fdc305ac3d | haithamsha/grukking_book | /recursion.py | 309 | 3.578125 | 4 | def count_down(i):
print(i)
#base case
if i <= 1:
return
else:
#recursive case
count_down(i-1)
# count_down(10)
#factorial
def fac(i):
#base case
if(i == 1):
return 1
else:
#recursive case
return i * fac(i -1)
print(fac(3)) |
6c7783c62db2839518e43922895b2b6147128f2a | AbirameeKannan/Python-programming | /Beginner Level/swap,for,if.py | 827 | 3.71875 | 4 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: user
#
# Created: 20/02/2018
# Copyright: (c) user 2018
# Licence: <your licence>
#-------------------------------------------------------------------------------
def... |
0a6bad2984378728d4b7119d74d2b031e434f931 | manurFR/sudoku-resolver | /src/main/python/HiddenSingleResolution.py | 3,864 | 3.75 | 4 | #!/usr/bin/env python
# -*- coding: UTF8 -*-
import logging
import Stats
from Grid import SIZE, startCoordinatesOfBlock
class HiddenSingleResolution:
""" A hidden single is a cell where one digit can only appear in its row, column or block.
For a given cell, we will only consider the digits from the remai... |
7d4026b1157ce7ca44b6f70dee784b14eff7e306 | DamjanR/SN-2019-predavanje | /HM8.1.py | 441 | 3.765625 | 4 | # 8 predavanje (1 naloga)
mood = input("Opiši svoje razpoloženje:")
if mood == "vesel":
print("Lepo te je videti veselega!")
print("")
elif mood == "žalosten":
print("Ej stari 3× globoko vdihni!")
print("")
else:
print("NO GO!")
print("Danes si lahko le >>vesel<< ali >>žalosten<<!")
print(""... |
19384c599d76e902e3abd7928830dbaed3b38463 | Maneesha-Jayasundara/fyp | /pos.py | 328 | 3.515625 | 4 | import nltk
text = "learn php from guru99"
tokens = nltk.word_tokenize(text)
print(tokens)
tag = nltk.pos_tag(tokens)
print(tag)
grammar = "NP: {<DT>?<JJ>*<NN>}"
cp=nltk.RegexpParser(grammar)
result = cp.parse(tag)
print(result)
result.draw() # It will draw the pattern graphically which can be seen in Noun Phrase ch... |
856e1ae0ea62c85f15e834b0ab88eddc113554f2 | felipeaaguiar/toolsfordatascience | /teste.py | 132 | 3.5625 | 4 | a = 2
b = 3
dicionario = {'nome': 'Felipe', 'idade': 32}
print('Olá Python!')
print('É tudo meu')
c = a
d = b
a = 7 |
b84bcbaaac5140273efff3ec8ab1daee280a5657 | denispin/python_training1 | /test.py | 98 | 3.71875 | 4 | a = 3
print(a)
w = [2.3,3,5,5]
for a in w:
while a < 5:
print(a*3)
a = a+1
|
64c7eb0778621e512429ffd40c0e1d2597d6e876 | Vractos/studying-python | /main.py | 708 | 3.515625 | 4 | #!python3
# print('Hello World')
# import pacote.sub.arquivo
# import tipos.variaveis
# from tipos import variaveis, basicos
# import tipos.lista
# import tipos.tuplas
# import tipos.conjuntos
# import tipos.dicionario
# import operadores.unarios
# import operadores.aritimetricos
# import operadores.relacionais
# i... |
2f0a8bc7a01b163f59ac2fd8ab1288d8bc539f33 | NevssZeppeli/my_ege_solutions | /Вариант 14/14.py | 283 | 3.578125 | 4 | y = (((9**22) + (3 ** 66) - 18))
c=0
def ternary (n):
if n == 0:
return '0'
nums = []
while n:
n, r = divmod(n, 3)
nums.append(str(r))
return ''.join(reversed(nums))
for x in ternary(y):
if x == '2':
c+=1
print(c) |
f4d9d1c65ff3f85c1125246688fce1d5c04fef90 | anzumpraveen/Dictionary | /comprehension_dict.py | 111 | 4.15625 | 4 | d={"one":"1","two":"2","three":"3"}
a={}
for key in d:
newlist = {x for x in d}
a[key]=newlist
print(a) |
55ed2b583f856e0752f53e698bd9e7395d3f6076 | EliasAltrabsheh/Managing-Big-Data-with-MySQL-Coursera- | /Managing Big Data with MySQL/Exercise_jupytar/python code/MySQL_Exercise_09_Subqueries_and_Derived_Tables.py | 23,556 | 3.5 | 4 |
# coding: utf-8
# Copyright Jana Schaich Borg/Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
# # MySQL Exercise 9: Subqueries and Derived Tables
#
# Now that you understand how joins work, in this lesson we are going to learn how to incorporate subqueries and derived tables into our queries.
#
# Subque... |
bd9f19147302899732eabe5f2a52afc50d9d1942 | qs8607a/Algorithm-39 | /Euler/part2/p58.py | 1,160 | 3.84375 | 4 | ##Starting with 1 and spiralling anticlockwise in the following way, a square
##spiral with side length 7 is formed.
##37 36 35 34 33 32 31
##38 17 16 15 14 13 30
##39 18 5 4 3 12 29
##40 19 6 1 2 11 28
##41 20 7 8 9 10 27
##42 21 22 23 24 25 26
##43 44 45 46 47 48 49
##It is interesting to note that ... |
60007702d7524ef5349426036f99f4557cc812a1 | lisnb/lintcode | /ConvertExpressionToReversePolishNotation.py | 2,684 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: LiSnB
# @Date: 2015-05-07 09:00:52
# @Last Modified by: LiSnB
# @Last Modified time: 2015-05-07 09:03:37
"""
Definition of ExpressionTreeNode:
"""
class ExpressionTreeNode:
def __init__(self, symbol):
self.symbol = symbol
self.left, self... |
7b5f4b1b841bb3f49ee4977263ef253b4b5dc320 | Durbek1/1-Lineyniy-algoritm | /27-пример.py | 64 | 3.578125 | 4 | A=int(input('A='))
y1=A**2
y2=A**4
y3=A**8
print(y1,y2,y3)
|
dcc0bf12f96221efe05d17095e24f3c87829863e | ryanjeric/python_playground | /PROJECT/SnakeAndLadderWithoutBoard.py | 2,383 | 4 | 4 | import time
import random
print("Snake and ladder w/o Board - v1.0")
class Player:
def __init__(self, player_id):
self.score = 0
self.player_id = player_id
def addScore(self, dice):
""" If the player rolls a higher number than needed to land exactly on 100,
their piece does n... |
6930b7edce92f35f089a38a0b158a3619865e924 | Smerly/Lists-and-Loops-Tutorial | /main.py | 354 | 3.515625 | 4 | Songs = ["Rockstar", "Do it", "For the Night"]
print(Songs[0])
print(Songs[2])
print(Songs[1:2])
Songs[2] = "Yoru Ni Kakeru"
Songs.append("Tabun")
Songs.append("Halzion")
Songs.append("Lemon")
del Songs[5]
animals = ["Cat", "Dog", "Chicken"]
animals.append("Potato")
print(animals[2])
del animals[0]
for i in r... |
04738719f4df13568db11977988f28249fd0d15d | roozbehsayadi/AI-Class-for-Freshmen-of-1398 | /002 Minimax Algorithm/step3.py | 2,854 | 3.90625 | 4 | from random import choice
from time import sleep
from math import inf
human = "x"
computer = "o"
def create_empty_board():
return [["_", "_", "_"], ["_", "_", "_"], ["_", "_", "_"]]
def evaluate(b):
# Checking for Rows for X or O victory.
for row in range(0, 3):
if b[row][0] == b[row][1] and b[... |
2234fd813cf426e6d42c3ad7f61a8ab1a9a0ef45 | losskatsu/Programmers | /practice/sort/K번째수.py | 382 | 3.5 | 4 | # 100 점
def solution(array, commands):
answer = []
n = len(commands)
for i in commands:
tmp_array = []
init = i[0]-1
end = i[1]
n_ch = i[2]-1
for j in range(init, end):
tmp_array.append(array[j])
tmp_array.sort()
print(tmp_array)
a... |
33b01b2eebd61b7b48ea4abb4208bf585ca1f52c | Mahlatse0001/Pre-bootcamp-coding-challenges | /Task5.py | 288 | 4.15625 | 4 | a = int(input("Enter first side:"))
b = int(input("Enter second side:"))
c = int(input("Enter third side:"))
def area_calc(a,b,c):
p = (a + b + c)/2
area = ((p*(p - a)*(p - b)*(p - c))**0.5)
return area
print("The area of the triangle is: " + str(round(area_calc(a,b,c),2))) |
a1a5bf51c5ce2e04e6b1a4b143d83537b6163751 | sidsharma1990/Practicedose | /Matplotlib for grp 2.py | 2,441 | 3.9375 | 4 | # Matplotlib (Visualization)
import matplotlib.pyplot as plt
import numpy as np
x = [1,2,3,4,5,6]
y = [54,23,12,48,46,43]
plt.plot(x, y)
x = np.linspace(1,50,20)
y = np.random.randint(1,50,20)
y = np.sort(y)
plt.plot(x, y, 'r')
plt.plot(x, y, color = 'g')
plt.plot(x, y, color = 'black')
# Always r... |
3fd9d7b358ae340765073af9a7da5511ea206491 | violetyk/study-python | /statement.py | 568 | 4.0625 | 4 | # coding:utf-8
str = 'python'
if str == 'PYTHON':
print 'PYTHON!'
elif str == 'python':
print 'python!'
else:
print 'False!'
# 同じ深さのインデントが同じブロックになる
print '-----'
i = 0
while i < 5:
i += 1
print i
print i
# 無限ループ
# while i:
# print '.'
# for 文
print '-----'
k = 0
for k in xrange(5):
print k
# rang... |
cd4e73941d76d7665499f938b4f4686b2f6fa480 | ivan-yosifov88/python_fundamentals | /list_advanced_lab/todo_list.py | 309 | 3.59375 | 4 | command = input()
todo_list = [0] * 10
while not command == "End":
tokens = command.split("-")
index = int(tokens[0]) - 1
task = tokens[1]
todo_list[index] = task
command = input()
task_list = []
for tasks in todo_list:
if tasks != 0:
task_list.append(tasks)
print(task_list)
|
2ffe9fab1ab805217ab3d214648ab18fa0101bdd | KerronKing/python-projects | /Practice/loops.py | 669 | 4.34375 | 4 | # function that iterates over a list and print each element
def print_list(myList):
for item in myList:
print(item)
print_list([1, 2, 3, 4, 5])
# function that iterate over a list and prints all elements greater than 2
def print_over_two(myList):
for item in myList:
if item > 2:
... |
488b27e4033ad64448b178c59f313b70b9ffa427 | hernanre/rosebotics2 | /src/capstone_2_runs_on_robot.py | 2,517 | 3.921875 | 4 | """
Mini-application: Buttons on a Tkinter GUI tell the robot to:
- Go forward at the speed given in an entry box.
Also: responds to Beacon button-presses by beeping, speaking.
This module runs on the ROBOT.
It uses MQTT to RECEIVE information from a program running on the LAPTOP.
Authors: David Mutchler, his co... |
5f87b9e2486e557e0008efa6df67a1042c8b8296 | lofthouse/snippets | /adventofcode_2016/09.py | 677 | 3.625 | 4 | #!/usr/bin/env python
import sys
import os.path
import re
instruction=re.compile('\([0-9]+x[0-9]+\)')
if len(sys.argv) != 2 or not os.path.isfile(sys.argv[1]) :
print "Invalid argument"
sys.exit(1)
with open(sys.argv[1]) as input_file:
content = input_file.read().splitlines()
def decoded_length(line):
next_in... |
705ebed6af0d89a0b38155e05d125b26d827cfed | RubenMarrero/Project-Euler-Solutions | /sum_fibonacci_even/evenFibSum.py | 321 | 3.828125 | 4 | #!/bin/python/
def evenFib(n) :
if (n < 1) :
return n
if (n == 1) :
return 2
# calculation of
# Fn = 4*(Fn-1) + Fn-2
return ((4 * evenFib(n-1)) + evenFib(n-2))
evenFibSum = 0
i = 0
while evenFibSum <=4*(10**6):
evenFibSum += evenFib(i)
i+=1
print(evenFibSum)... |
25630fcfd78bba2d4f388a3df66293d6737a5a25 | Tonyhao96/LeetCode_EveryDay | /415_Add Strings.py | 913 | 3.5625 | 4 | # 415_Add Strings
#Using dict
class Solution:
def addStrings(self, num1: str, num2: str) -> str:
dict = {"1": 1, "2": 2, "3": 3, "4": 4, "5": 5,
"6": 6, "7": 7, "8": 8, "9": 9, "0": 0}
def toint(s):
res = 0
for i in range(len(s)):
res *= 10
... |
e685f94f8d6f8487e9941f875592b076e0120454 | Preetham97/HousePricePrediction | /code.py | 27,359 | 3.765625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Homework 3 - Ames Housing Dataset
# For all parts below, answer all parts as shown in the Google document for Homework 3. Be sure to include both code that justifies your answer as well as text to answer the questions. We also ask that code be commented to make it easier to f... |
d52f908fadff7db9ca77c75875cb47922296d3dd | anantkaushik/Competitive_Programming | /Python/GeeksforGeeks/facing-the-sun.py | 1,238 | 4.09375 | 4 | """
Problem Link: https://practice.geeksforgeeks.org/problems/facing-the-sun/0
Monu lives in a society which is having high rise buildings. This is the time of sunrise and monu wants see the
buildings receiving the sunlight. Help him in counting the number of buildings recieving the sunlight.
Given an array H represe... |
4b476354bde1d2228f005af90889f7bb75d92fa2 | wartrax13/exerciciospython | /Lista de Exercícios PYTHON BR/EstruturadeRepetição/26 - EtruturadeRepetição.py | 1,082 | 4.03125 | 4 | '''
Numa eleição existem três candidatos.
Faça um programa que peça o número total de eleitores.
Peça para cada eleitor votar e ao final mostrar o número de votos de cada candidato.
'''
A = []
B = []
C = []
eleitores = int(input('Quantos eleitores há? '))
print('-------------------------')
for x in range(eleitores):
... |
fe8a93634f25e83f01951ebc52f22d9c3674e8fb | TaniaHernandezB/Week2 | /medium.py | 560 | 4.1875 | 4 | number = int(input("Number: "))
if number == (1):
print("January")
elif number == (2):
print("February")
elif number == (3):
print("March")
elif number == (4):
print('April')
elif number == (5):
print("May")
elif number == (6):
print("June")
elif number == (7):
print('July')
elif number == (8):
print('A... |
56e2e6577474b3e58d3b3932cff056204efbd7f8 | Srinath619/Shady | /proofdiag.py | 173 | 3.765625 | 4 | def uniq(string):
a=[]
for i in range(len(string)):
if string[i] in a:
continue
a.append(string[i])
print(''.join(a))
def main():
str=input()
uniq(str)
main()
|
91c961c181bd35d9f32e2b0d500d21b0d1a35c6e | Luo-Kaiyi/Python-Learning | /7-9 熟食店牛肉卖完了.py | 453 | 3.765625 | 4 | food_order = ['鸡爪','鸭爪','鸡翅','鸭翅','鸡腿','牛肉']
print("牛肉卖完了!")
finished_order = []
while food_order:
food = food_order.pop()
if food != '牛肉':
print("给你一个" + food)
finished_order.append(food)
else:
print("不好意思,牛肉已经卖完了!")
print("现在,你有这些熟食了:")
while finished_order:
food = ... |
56ffc71dbbf6101991c7ed2f6de97c7154ac1d56 | unclebay143/UserApp | /login.py | 1,192 | 3.5625 | 4 | import dashboard
import recover_password
# login function
def login_area(name, username, phone, email, password, security_pin, security_question):
print("\n LOGIN AREA ")
user_name_attempt = input("Enter Username: ")
password_attempt = input("Enter Password: ")
if user_name_attempt == username and pas... |
3cf6aa6dc8f8e7938c7c29ecba86cef75190d081 | GregoryMNeal/Digital-Crafts-Class-Exercises | /Python/Snippets/Formatted_Print_using_keywords.py | 262 | 4.21875 | 4 | print("____(name)____'s favorite person in the whole world is ____(person)____")
name = input("What is name? ")
person = input("Who is their favorite person? ")
print("{name}'s favorite person in the whole world is {person}.".format(name=name, person=person))
|
2b4e2965b0b3ceaadabc21920bf8cadcb451f7d9 | theadamsacademy/python_tutorial_for_beginners | /08_operators/rule_1_precedence.py | 272 | 3.96875 | 4 | # ()
# *, /
# +, -
# <, <=, >, >=, !=, ==
# not
# and
# or
# Highest precedence at top, lowest at bottom.
# Operators in the same line evaluate left to right.
# a + b * c
# 1 + 2 * 3
a = 1
b = 2
c = 3
print("a + b * c =", a + b * c)
print("(a + b) * c =", (a + b) * c) |
e6058b96ed0df45ca4d43dc656f946efebc72ecf | IsaacNewLee/IndividualIcomeTax | /tax_calculation.py | 1,819 | 3.84375 | 4 | # coding=utf-8
def calculator(salary):
"""
税后工资计算器:2019年新税率个人所得税计算器,各地区五险一金比例有差异
"""
point = 5000
yanglao_rate = 0.08
hospital_rate = 0.02
unemployment_rate = 0.005
housing_money_rate = 0.12
five_one_money = salary * (yanglao_rate + hospital_rate + unemployment_rate + housing_money... |
08259d76c944e02bbc78e072e8949968225cc295 | sophialuo/CrackingTheCodingInterview_6thEdition | /17.21.py | 1,355 | 4 | 4 | '''
17.21
Volume of Histogram: Imagine a histogram (bar graph). Design an algorithm to compute the volume of water it could hold if someone
poured water across the top. You can assume that each historgram bar has width 1.
EXAMPLE
Input: 0, 0, 4, 0, 0, 6, 0, 0, 3, 0, 5, 0, 1, 0, 0, 0}
Output: 26
'''
def volum... |
a786bea79a82e245cb0d198b7154032f93420898 | Ryuodan/PPT-to-PDF-Converter | /PPT-to-PDF.py | 594 | 3.890625 | 4 | '''Author : Ryuodan'''
import win32com.client
def PPT_to_PDF(infile_path, outfile_path):
'''convert from PPT to PDF file format'''
powerpoint = win32com.client.Dispatch("Powerpoint.Application")
pdf = powerpoint.Presentations.Open(infile_path, WithWindow=False)
pdf.SaveAs(outfile_path, 32)
pdf.Clo... |
711061412adc6cc5927968337a42828d12bbd8e8 | AnandD007/Amazing-Python-Scripts | /Songs-By-Artist/songs_of_artist.py | 2,866 | 3.5625 | 4 | import pandas as pd
import spotipy
import config
# To access authorised Spotify data
from spotipy.oauth2 import SpotifyClientCredentials
client_id = config.client_id
client_secret = config.secret_key
client_credentials_manager = SpotifyClientCredentials(
client_id=client_id, client_secret=client_secret)
# spotify... |
4252c9c5da34e3b81630a6aeb266d281c3762ce3 | suhasv13/addition | /add.py | 137 | 4.03125 | 4 | #sum of two numbers
a=int(input("enter the first number "))
b=int(input("enter the second number "))
sum=a+b
print("THe sum is ",sum) |
6580c2d450a8ec5070e3de9baba8ac91e0f4eea3 | leebaek/TIL | /python/write_txt.py | 557 | 3.5 | 4 | # Write File
# 1. open()
f = open('mulcam.txt', 'w') # 'w' : write, 'r' : read, 'a' : append
# for i in range(10):
# f.write(f'Hello, Mulcam! {i}\n')
# f.close()
# 2. with open()
# with open('mulcam.txt', 'w') as f:
# f.write('Hello, Mulcam!\n')
# 2-1. writelines
with open('mulcam.txt', 'w') as f:
f.writ... |
f680f5deb0653aa00c080a84d992f8bacb58d6d0 | StRobertCHSCS/ics2o1-201819-igothackked | /unit_2/2_6_4_while_loops.py | 276 | 4.34375 | 4 |
numerator = int(input("Enter a numerator: "))
denominator = int(input("Enter denominator: "))
if numerator // denominator :
print("Divides evenly!")
else:
print("Doesn't divide evenly.")
while denominator == 0:
denominator = int(input("Enter denominator: "))
|
ec03b3cfe78b72958fcf89f0cdf9e97e0babc53e | moontree/leetcode | /version1/920_Number_of_Music_Playlists.py | 2,763 | 3.875 | 4 | """
Your music player contains N different songs and she wants to listen to L
(not necessarily different) songs during your trip.
You create a playlist so that:
Every song is played at least once
A song can only be played again only if K other songs have been played
Return the number of possible playlists. As the an... |
ae00b5a28d57f57c71ccae7cdc9ccc822ca24e35 | jakehoare/leetcode | /python_1_to_1000/347_Top_K_Frequent_Elements.py | 952 | 3.75 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/top-k-frequent-elements/
# Given a non-empty array of integers, return the k most frequent elements.
# Count the frequency of each element. Bucket sort the elements by frequency since the highest frequency cannot be
# more than the length of num... |
289723e4f22489ff9c92d042643d2cfd42957cc4 | GTxx/leetcode | /algorithms/1408. String Matching in an Array/python/solution.py | 506 | 3.765625 | 4 | from typing import List
class Solution:
def stringMatching(self, words: List[str]) -> List[str]:
words.sort(key=lambda word: len(word))
res = []
for idx, word in enumerate(words):
for word1 in words[idx+1:]:
if word in word1:
print(word, word... |
8f0d308f53670d2d5d0f8837de9fdd155a700362 | nhanthien1504/bai_tap_buoi_7 | /07.py | 12,650 | 4.21875 | 4 | '''
Thực hiện code lại hàm sau và cho biết ý nghĩa của nó
def enter_data():
while True:
n = input("Nhập 1 số nguyên: ")
if n.isnumeric():
n = int(n)
if n > 0:
print("Đã nhập số dương")
return n
print("Đã nhập số không dương. Chương ... |
9520b72cc8fcf7c3bef137cf69c4b3ad7de0095c | kerja-remote/fundamental-python | /fundamental1-konstruksi-dasar.py | 359 | 3.828125 | 4 | #konstruksi dasar python
#sequential
print('Hello World!')
print('by Bagus')
print('-'*10)
# percabangan: Eksekusi terpilih
ingin_cepat = False
if ingin_cepat:
print('jalan lurus')
else:
print('jalan lain')
# perulangan
jumlah_anak = 4
for index_anak in range (1, jumlah_anak+1): #jumlah perulangan = 5 - 1 =4... |
58a5345d62ee5b75496fca460f309a4092257177 | DT211C-2019/programming | /Year 2/Paul Geoghegan/S1/Labs/Lab11/l11q7b.py | 235 | 4.15625 | 4 |
#Creates list
color_list = ['Red', 'Blue', 'Green', 'Black', 'White']
#Changes list to upper case
for i in range(len(color_list)):
#Changes element to upper case
color_list[i] = color_list[i].upper()
#prints list
print(color_list) |
64117cb9a58355ef3d6da4d5758c2c9cd58f0fb3 | suhanacharya/Credit-Calculator | /Credit Calculator/task/creditcalc/creditcalc.py | 4,144 | 3.578125 | 4 | import math
import argparse
import sys
# Creating arguments that are to be passed in command line.
parser = argparse.ArgumentParser()
parser.add_argument("--type")
parser.add_argument("--principal")
parser.add_argument("--periods")
parser.add_argument("--interest")
parser.add_argument("--payment")
args = vars(parser.p... |
490780df10237c40bcd0222bec796dae5f1feec5 | eodenyire/holbertonschool-higher_level_programming-27 | /0x0F-python-object_relational_mapping/100-relationship_states_cities.py | 1,126 | 3.515625 | 4 | #!/usr/bin/python3
"""
State class:
In addition to previous requirements, the class attribute
cities must represent a relationship with the class City.
If the State object is deleted, all linked City objects
must be automatically deleted. Also, the reference from a
City object to his State should be named state
You mus... |
9b883c9d6e1c64fa3ebbc548b894bc3f3d748751 | jh-lau/leetcode_in_python | /02-算法思想/二分查找/744.寻找比目标字母大的最小字母.py | 1,801 | 3.625 | 4 | """
@Author : liujianhan
@Date : 2020/12/26 9:57
@Project : leetcode_in_python
@FileName : 744.寻找比目标字母大的最小字母.py
@Description : 给你一个排序后的字符列表 letters ,列表中只包含小写英文字母。另给出一个目标字母 target,请你寻找在这一有序列表里比目标字母大的最小字母。
在比较时,字母是依序循环出现的。举个例子:
如果目标字母 target = 'z' 并且字符列表为 letters = ['a', 'b'],则答案... |
c4ebaba8961307243c6c9f2c8a654a411befad7d | A-hungry-wolf/python | /study/fibs.py | 152 | 3.609375 | 4 | def fibs(num):
results = [0, 1]
for i in range(num - 2):
results.append(results[-2] + results[-1])
print(results)
print(fibs(10))
|
1b8fa28577b1e66ebcf07f1d09b372cd21bdd7e7 | Gangamagadum98/Python-Programs | /prgms/OperatorOverloading.py | 1,300 | 4.125 | 4 | # WE have diff methods for diff operators
# __add__(), __sub__(), __mul__() call as 'magic methods'
# a=5
# b=6
# print(a+b) Its possible with help of int/string bt no with class/obj
# print(int.__add__(a,b))
class Student:
def __init__(self,m1,m2):
self.m1 = m1
self.m2= m2
def __add... |
db1f5a6b87b54ad316dd5bc93c42b5fe6f0f99b9 | wancong/leetcode | /listnode/get_intersection_node.py | 1,957 | 3.671875 | 4 | """ Intersection of two linked lists
Write a program to find the node at which the intersection
of two singly linked lists begins.
A: a1 → a2
↘
c1 → c2 → c3
↗
B: b1 → b2 → b3
begin to intersect at node c1.
"""
class ListNode(object):
... |
2663aa80bc79556a62276664461455f0ba54870a | doct0rX/PythonMIT1x | /week2/assignments/guessMyNumber.py | 957 | 4.5625 | 5 | """
This was exercise 3 at week 2
In this problem, you'll create a program that guesses a secret number!
The program works as follows: you (the user) thinks of an integer between 0 (inclusive) and 100 (not inclusive). The computer makes guesses, and you give it input - is its guess too high or too low? Using bisectio... |
07137115d299454cde0578af41bb5d5acbe2877a | Gryphon90/Python | /TripCalculator.py | 652 | 3.96875 | 4 | ##TRIP COST CALCULATOR
def hotel_cost (nights):
return 140 * nights
def plane_ride_cost (city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475
def renta... |
f971b58b835579bb16a8c9923c2ed31ef502dc0d | BeniyamL/alx-higher_level_programming | /0x0B-python-input_output/9-student.py | 776 | 4.03125 | 4 | #!/usr/bin/python3
""" class defintion Student
"""
class Student:
""" implementation of class student """
def __init__(self, first_name, last_name, age):
""" initialization fuction of student
Arguments:
first_name: the first name of the student
last_name: the last nam... |
5047e5545ab8b9464e36d651866bdf92278ae1b9 | danhiel98/pensamento-computacional-python | /07_aproximacion.py | 513 | 3.875 | 4 | objetivo = int(input('Escriba un número: '))
epsilon = 0.01 # Margen de error o precisión
paso = epsilon**2 # Cantidad a aumentar por cada iteración
respuesta = 0.0
while abs(respuesta**2 - objetivo) >= epsilon and respuesta <= objetivo:
print(respuesta)
respuesta += paso
if abs(respuesta**2 - objetivo) >= ep... |
09b4443569bff7d35a119d8c1f7f148513e78872 | JohanHansen-Hub/PythonProjects | /Arkiv/SøkeAlgoritmer/iterative_binary_search.py | 415 | 3.625 | 4 |
eksamplelist = [5,3,8,1,9,2]
def iterativeBinarySearch(the_list, item):
start = 0
end = 0
found = 0
while start <= end and not found:
mid = (start + end) // 2
if the_list[mid] > item:
end = mid - 1
elif the_list[mid] < item:
end = mid - 1
else:
... |
3b4f6a278d3dd453ae3c3189bb2aeffb0774e4a2 | ATLJoeReed/CodecademyTraining | /intro_data_analysis/capstone/biodiversity/jreed_biodiversity_capstone.py | 12,320 | 4.1875 | 4 |
# coding: utf-8
# # Capstone 2: Biodiversity Project
# # Introduction
# You are a biodiversity analyst working for the National Parks Service. You're going to help them analyze some data about species at various national parks.
#
# Note: The data that you'll be working with for this project is *inspired* by real d... |
8ec484b45e201479b5dfbb3625be3fde5312a2c1 | emmanavarro/holbertonschool-higher_level_programming | /0x0B-python-input_output/0-read_file.py | 301 | 4.1875 | 4 | #!/usr/bin/python3
"""Read text file module
"""
def read_file(filename=""):
"""
Write a function that reads a text file
(UTF8) and prints it to stdout.
"""
with open(filename, mode='r', encoding='utf-8') as my_file:
print(my_file.read(), end='')
my_file.close()
|
dda8db23078ae3635f504fd3c4418ef902cc0d51 | Adrite04/BRACUCSE422 | /Assignment/P2.5.7.py | 377 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import time
start = time.time()
n = 27
def hailstone(a):
print(a)
if a != 1:
if a %2 == 0:
hailstone(a/2)
else:
hailstone(3*a + 1)
hailstone(n)
print("... |
a92d4076985b8279ddd0eebb44705b1c186dcec8 | Dearyyyyy/TCG | /data/3920/AC_py/518495.py | 135 | 3.65625 | 4 | # coding=utf-8
a=int(input())
b=int(a/100%10)
c=int(a/10%10)
d=int(a/1%10)
if b**3+c**3+d**3==a:
print("YES")
else:
print("NO") |
f11c35af93c8093b10a95b4a87b72aa83c10cad3 | alejandro-parra/Programming-Fundamentals---Python | /Act2.3.py | 303 | 3.984375 | 4 | print("Escribe una medida en pies que desea convertir:")
x=input()
x=float(x)
yarda=x/3
pulgada=x*12
centimetro=pulgada*2.54
m=centimetro/100
print("Valor en pies: "+str(x))
print("Valor en yardas: "+str(yarda))
print("Valor en metros: "+str(m))
print("Valor en pulgadas: "+str(pulgada))
|
cbf35bc9bbbd02a387e7b8d620ce554689a154ab | Ran-oops/python | /2/01Python中的字符串数学列表 内键函数 数学模型/07.py | 975 | 3.765625 | 4 | #数学函数
#abs 获取绝对值
num = -123.5
result = abs(num)
print(result)
#sum 计算一个序列的和(列表和元组集合)
lists = {1,2,234,6,21,57,156,7}
result = sum(lists)
print(result)
#max & min 获取最大值/最小值(列表和元组集合)
lists = [12,56,1,67,23,87,2,8,0,457,99]
maxresult = max(lists)
print(maxresult)
minresult = min(lists)
print(minresult)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.