blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
6700b751ae3a6cbc30d4dc48cf063c60a87c91ae | fridriks98/Forritunarverkefni | /forritunaræfingar/daemi26.py | 596 | 4.25 | 4 | #Create a program that takes an integer as input, let ́s call it turns.
#This integer should indicate how many times the user wants to input a new integer.
#Next the program should let the user input turnsmany integers.
#The program should then print how many negative integers the user input.
number_of_intz = int(i... |
f24aa02eab24a100600cffa9354241ad02b6b91e | DC23/car-cost-calculator | /car_cost_calculator/depreciation.py | 2,255 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"Depreciation functions"
# pylint: disable=R0903
import numpy as np
class TwoStageRate:
"""Depreciation rate function with a 2-stage rate.
Defaults to 15% for first 3 years, then 10% after that.
"""
def __init__(
self,
stage_1_rate: float = 0.15,
st... |
bae9e6bd7763df5b242feb8f04b5459a646ba300 | SeonggonKim/Programmers | /프로그래머스/lv0/120822. 문자열 뒤집기/문자열 뒤집기.py | 131 | 3.578125 | 4 | def solution(my_string):
answer = ''
for i in range(1, len(my_string)+1):
answer += my_string[-i]
return answer |
3e377253fd166624155687575c0d6b9b2d428a22 | zuzanna-f/pp1 | /02-ControlStructures/02.38.py | 121 | 3.59375 | 4 | i=9
while i>0:
i+=-3
j=0
while j<3:
j+=1
print(f' {i+j}',end='')
print() |
fcc10423a48fd85250554a83256d31c7ec18b11a | ParanoidAndroid19/cracking_the_coding_interview_python | /Ch3_Stacks and Queues/3_stackOfPlates.py | 2,369 | 3.859375 | 4 |
class SetOfStacks:
def __init__(self, capacity):
self.items = [] # the current stack
self.stackSet = [] # will store the filled stacks, ones the items stack is full append it here and then items = []
self.capacity = capacity
def isEmpty(self):
return self.items == []
#... |
3123c25befd80233ffe2db476ddd3434b0991dd8 | kambwin/python | /zx.py | 421 | 3.609375 | 4 | import random
while True:
command = input("Скажи мудрость\n")
phrases = ['Знать ничего не хочу', 'Выйти']
if command == "Скажи мудрость":
print (random.choice(phrases))
if command == 'Знать ничего не хочу':
print('Ок(((')
if command == 'Выйти':
print("Выйти")
break
else:
print('Нев... |
64d717214c9c058ebfb0cb78d691546a97374487 | juechen-zzz/learngit | /python/语法/cycle.py | 207 | 3.75 | 4 | ##分数累加
name = ['a','b','c','d'];
for name in name:
print(name);
score = [1,2,3,4,5];
sum = 0;
for score in score:
sum = sum + score;
print(sum);
s = 0;
for x in range(110):
s = s + x;
print(s);
|
1356fa7c36e3d1d28c306cda6263ba676b71850e | Nacyo/computorV1 | /srcs/errors_eq.py | 1,350 | 3.859375 | 4 | import sys
import re
def format_error_degree(str):
str = str[1:]
return (int(str))
def handle_error_degree(list):
max_value = max(list)
deg = min(list)
if max_value > 2:
deg = max_value
print("The polynomial degree is {:d}, I cannot solve".format(deg))
else:
print("Th... |
b3197fc3646f16e1bc54d5611c2828c496ddfd05 | imzengyang/api0707 | /business/common.py | 522 | 3.5 | 4 | """
常用功能:
1. 发布话题
"""
import requests
def create_topic(topic_data):
create_url = "http://49.233.108.117:3000/api/v1/topics"
res_create_topic = requests.post(url=create_url, data=topic_data)
topic_id = res_create_topic.json()['topic_id']
return topic_id
def get_topic_detail(topic_id):
url = "http:/... |
d7f24821f55cba84145f6e3f4b14247a393df616 | Oliph/PhD-WebScience | /server_rand_gen.py | 1,361 | 3.53125 | 4 | #!/usr/bin/env python
# encoding: utf-8
import random
# # Found in
#http://stackoverflow.com/questions/352670/weighted-random-selection-with-and-without-replacement
# # Mention this article as the source of this algorythm ;
#http://www.sciencedirect.com/science/article/pii/S002001900500298X
# import heapq
# import mat... |
05136689b24d2b3cf6f0e6ff4dd80a916fd108a2 | helgaKalicz/2048 | /2048.py | 16,368 | 3.546875 | 4 | import display
import welcome
import win
import lose
import sum_print
import biglist
import curses
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
# First board printing
board = biglist.board(2)
def printing():
stdscr.clear()
partBetween1 = display.display_table(board[0])
part... |
09a7a72fbb6b032f254c0956b9f7bc73af3ce929 | agkozik/PyTest | /tests/unit_tests_whitebox/test_titlecase.py | 318 | 3.546875 | 4 | from titlecase import titlecase
class TitleCaseTests:
def test_lower_text_is_uppercased_correctly(self):
initial_text = 'this should be capitalized'
expected_text = 'This Should Be Capitalized'
result_text = titlecase.title_case(initial_text)
assert result_text == expected_text
|
fb5b6d4a5bcf623d78d7019e15e3280e3e7fad59 | luliyucoordinate/Leetcode | /src/0092-Reverse-Linked-List-II/0092.py | 1,341 | 3.96875 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseBetween(self, head, m, n):
"""
:type head: ListNode
:type m: int
:type n: int
:rtype: ListNode
"""
if head... |
8d814d04858f2619e104de74f57eaca97e40f6bb | zeppertrek/my-python-sandpit | /pibm-training/sample-programs/declaring_variables_example_004.py | 591 | 4.15625 | 4 | #declaring_variables_example_004.py
#
# Declaring string variables
print ("In Python, variables are NOT declared with a data type ")
print ("Python variables take their type information from the type of the object they’re assigned")
print ("Ok, in the program, I keep changing the type of object ")
starter = "Dim... |
fac61e412ccf1ee317142c2dedc71d7e18fccebf | elle-johnnie/Arduino_Py | /PythonPractice/OS_Walker.py | 807 | 3.5 | 4 | import os
# read directory and sub directories
def dir_walker(path):
for root, dirs, files in os.walk(path):
for file_ in files:
print(os.path.join(root, file_))
def dir_printer(path):
for root, dirs, files in os.walk(path):
for filename in files:
if filename.endswit... |
5cfbc8a5bdffe0a5cc3170ad10d2600020ba77ac | imaaduddin/100-Days-Of-Python | /Day 3 Control Flow & Logical Operators/Day-3-Love-Calculator-Exercise.py | 3,481 | 4.125 | 4 | # Love Calculator
# 💪 This is a Difficult Challenge 💪
# Instructions
# You are going to write a program that tests the compatibility between two people.
# To work out the love score between two people:
# Take both people's names and check for the number of times the letters in the word TRUE occurs. Then check for t... |
8e4aae71dde9a4d3d426c76f244a5ea75a8c95cb | joaobose/CI3641-exam-2 | /pregunta-1/church.py | 2,564 | 3.828125 | 4 | from functools import reduce
class Church:
# Representacion interna de un numero de Church.
# Esto para restringir las formas de construir un numero Church a solo zero y succ n.
class __Representation:
def __init__(self, fn):
# Representamos un numero Church por una lambda function.
... |
b593523f55cdda8ca9e8a6d2c8ff1c1d797168e4 | lsDantas/Cryptography-and-Number-Theory | /caesar_cypher.py | 1,224 | 4 | 4 | # Caesar Cypher
#
# Description: Encode and decode a string of text
# using the Caesar rotation cypher.
#
# Input
# text: a string of text to be used
# rot: rotation
#
# Output
# encoded: string encoded using Caesar cypher
# decoded: string decoded using Caesar cypher
#
def encode(text, rot):
alphabet =... |
9b811c161e0688db7a766ea3e64b959a84c1b41a | mnihatyavas/Python-uygulamalar | /tutorialspoint.com (50) ile Python/p20.py | 764 | 3.640625 | 4 | # coding:iso8859-9 Trke
# Python 3 - GUI Programming (Tkinter)
import tkinter
# Ana program kodlamas buraya eklenmeli...
pencere = tkinter.Tk()
pencere.mainloop()
kt = """
Pencere aletleri -ara, komponent, para- (Button, Canvas, Checkbutton, Entry,
Frame, Label, Listbox, Menubutton, Menu, Message, Radio... |
f563d5c3dadef27e8aa9f90987b046afec1f5cec | AMiesem/Shadowrun-Tools | /dice/dice.py | 1,156 | 4.3125 | 4 | #!/usr/bin/env python3
'''The Dice object'''
# -*- coding: utf-8 -*-
import random
class Dice:
'''Object that allows for the creation of single or multiple dice and provides the methods for
rolling and otherwise manipulatig them.'''
def __init__(self, rolls=1, sides=6, add=0):
'''Set initial va... |
f77480dbb71a1ada82c5156463180fdce6c06594 | adamgillfillan/PML | /pml.py | 5,146 | 3.65625 | 4 | __author__ = 'Adam'
import re
import sys
class PML:
"""A PML file manager.
A PML File is an HTML document with a twist. Python code is allowed in a PML document
with a tag indicator <pml> ... </pml>.
PML has file data, executes the python data, and parses it to provide an HTML readable document.
... |
91b66f1781f42c65eea160aba4b751523bee87e1 | guoguogewangzi/python_deal_json | /python_deal_json/json_deal.py | 689 | 3.6875 | 4 | #处理json字符串
import json
people_string = '''
{
"people":[
{ "name":"John Smith",
"phone":"615-555-7154",
"emails":["johnsmith@bogusemail.com","john.smith@work-place.com"],
"has_license":false},
{
"name":"jane Doe",
"phone":"560-555-5153",
... |
ddaa3c37130b81b9bdd5e2264f0849ba82e740d5 | SuzyWu2014/coding-practice | /python practice/Array/229_majority_element_ii.py | 1,157 | 3.859375 | 4 | # *--encoding: utf-8 ---*
# 229. Majority Element II
# Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.
# Hint:
# How many majority elements could it possibly have?
# https://segmentfault.com/a/1190000003972762
clas... |
a7e920c05451a10950548cea0c5a87fbfb3067d5 | luke90329/1081ProgramNote | /期末考/階乘.py | 109 | 3.59375 | 4 | def factorial(a):
count = 1
for i in range(1,a+1):
count *= i
print(count)
factorial(10)
|
46ef679dc6acaeb470d627b80e6607bcc18cb1dd | raguiar2/PraticeQuestions | /ctci/strings_arrays/one_away.py | 512 | 3.53125 | 4 |
def one_away(str1,str2,m=0,n=0,count=0):
if m == len(str1):
return len(str2) -n + count <= 1
if n == len(str2):
return len(str1) -n + count <= 1
if str1[m] == str2[n]:
return one_away(str1,str2,m+1,n+1,count)
else:
return one_away(str1,str2,m,n+1,count+1) or one_away(st... |
9b527ae2f577202d2fa04d5e13a25afd62f44256 | ZHAOJIAJIAHH/DASHUJIU | /zuoye02.py | 3,827 | 3.8125 | 4 | """
#编写程序,提示用户输入a、b和c的值,然后显示判别式的结果
def canshu(a,b,c):
r1 = (-b + (b*b - 4*a*c)**0.5)/2*a
r2 = (-b - (b*b - 4*a*c)**0.5)/2*a
pianbieshi = b*b - 4*a*c
if pianbieshi > 0:
print('The roots are',r1 ,'and',r2 )
elif pianbieshi == 0:
print('The roos is',r1)
else:
prin... |
cc8b13ddba9abdef908e3b91001896302aadbe8a | anirudhRowjee/Class11 | /python/insertionsort.py | 537 | 4.0625 | 4 | #insertion sort
o_list = []
x = int(input("Please give the number of elements in unsorted list"))
for i in range(1, x+1):
y = input("please give element " + str(i) + " >>> ")
o_list.append(y)
print("Unsorted list is ", o_list)
w_list = o_list
for i in range(0, len(w_list)):
# print("i ", i)... |
c74e55fac1c0e74026e16c788a4c52b8d8d5498f | VVIMT/BootcampPython-42AI | /day01/ex04/eval.py | 1,228 | 3.59375 | 4 | class Evaluator:
def __init__(self):
pass
def zip_evaluate(param1, param2):
if (isinstance(param1, list) and isinstance(param2, list)) and (len(param1) == len(param2)):
pass
else:
return (-1)
zipped = zip(param1, param2)
l_zipped = list(zipped)
... |
65af04ff2e2a9d3dba61f9d72ce5927b2d3bc480 | vividwang/python-start | /9-7.py | 685 | 3.765625 | 4 | class User():
def __init__(self,firstName,lastName):
self.firstName = firstName
self.lastName = lastName
def describeUser(self):
print("User name was " + self.firstName.title() + ' ' + self.lastName.title() + ".")
def greetUser(self):
print("Hi " + self.firstName.title() + ... |
2336e111c2b4e716b0b128a52539865d9ade76f3 | pi6220na/test_stuff | /class_test.py | 4,974 | 3.515625 | 4 | class Place(object):
def __init__(self, place_name, place_type=None):
self.name = place_name
self.type = place_type
class Dining(Place):
def __init__(self, dining_name, place_type="dining"):
super().__init__(dining_name)
self.type = place_type
class Restaurant(Dining):
de... |
6b9489f8ec427625ab54b42347bcf6caf7203c88 | KemelbekovRM/GeekBrains | /Zadanie_4.py | 460 | 3.875 | 4 | # 4. Пользователь вводит целое положительное число. Найдите самую большую цифру в числе.
# Для решения используйте цикл while и арифметические операции.
param = int(input('Введите число - '))
itog = 0
while param > 0:
max_chislo = param % 10
param //= 10
if max_chislo > itog:
itog = max_chislo
prin... |
075acbe51e61bc1d11fc0678f47b3b4f5536e893 | karandevgan/Algorithms | /QuickSortEquals.py | 1,855 | 3.984375 | 4 | import random
def Swap(list, index1, index2):
list[index1], list[index2] = list[index2], list[index1]
def Partition(list, left_index, right_index):
random_index = random.randint(left_index, right_index)
partition_index = left_index
Swap(list, random_index, right_index)
pivot = list[right_index]
... |
d39e23b0b2c310dbd1cf39bf8dcfadb66b41ca50 | DriesSmit/Recommendation-System | /TestAlgs/RecSysAlgorithms/kMeans.py | 843 | 3.921875 | 4 | #https://kevinzakka.github.io/2016/07/13/k-nearest-neighbor/
#http://www.data-mania.com/blog/recommendation-system-python/
import matplotlib.pyplot as plt
import numpy as np
from sklearn.cluster import KMeans
# First let's create a dataset called X, with 6 records and 2 features each.
X = np.array([[-1, -1], [-2, -4]... |
16eab4446f191ddcd5c9d1c8931dacad8c4dbb23 | andresavasconcelos/PSaaS_EngSoft | /estagio/Testes.py | 2,641 | 3.796875 | 4 | import time
import random
class Testes:
casosTeste = ["Primeiro Teste","Segundo Teste","Terceiro Teste","Quarto Teste","Teste Final"]
def executaFuncionalidade(self, funcionalidade, entrada):
if(random.random() <= 0.015):
print("Execucao falhou para : " + entrada)
re... |
b1ff51204eccab2c228fde92a6c8d7e24d17920e | pdicerbo/P1.1 | /D5-assignment/main.py | 2,301 | 3.671875 | 4 | import numpy as np
import matplotlib.pyplot as plt
from steppers import *
print("\n\tChoose your initial condition.")
print("\tIf you put a negative value for the central Mass, \n\tthe program will load automatically the values of the sun - earth system.\n\n")
M_start = float(input("\tCentral Mass value (g): "))
if... |
90175aa81bf98ce999345399b3cbba6f723c0b1d | kaevowen/archive | /boj/10988.py | 144 | 3.828125 | 4 | def check_palindrome(copy):
cat = ''
for i in reversed(copy):
cat += i
if copy==cat:
return 1
return 0
print(check_palindrome(input())) |
ef4dac5494439866b94ba8accce72c6a9158d09d | jfennell/Challenge | /friends_with_trie.py | 4,158 | 4.0625 | 4 | """
Two words are friends if they have a Levenshtein distance of 1. That is, you
can add, remove, or substitute exactly one letter in word X to create word Y. A
word's social network consists of all of its friends, plus all of their
friends, and all of their friends' friends, and so on. Write a program to tell
us how b... |
7f2fa8e30fa565cdb8ca08644d971b14fa60cb0d | flaviojussie/Exercicios_Python-Inciante- | /EstruturaDeDecisao - PythonBrasil/exec26.py | 755 | 3.5 | 4 | def calculadoracombustivel(lt, prec, desc):
precoTotal = (lt*prec)
precoTotal -= (precoTotal*desc)
return precoTotal
def calculoDesconto(lt, opcao):
if opcao == 'G' and lt > 0 and lt <= 20:
preco = 2.50
desconto = 0.03
elif opcao == 'G' and lt > 20:
preco = 2.50
desc... |
c6d7c71e85ddbcd4bf7f1784d2d44d06c87c3696 | FlorentRu/Python-Programming-Developement- | /NestedForLoop.py | 409 | 3.78125 | 4 | '''
Created on Jun 17, 2018
'''
for x in range(1,5 ):
### Inner for loop ###
for y in range(1, 5):
print('%d ' % (x))
print("\n")
print("*** Generates a list of 3 values starting from 0 ***")
for i in range(3):
print("Welcome",i,"times.")
print("*** Generates a list of 3 ... |
adcdf08aacaa651287c224eb749e1ce71356b716 | petrbojda/coding | /src/siggens/one_pulse.py | 2,391 | 3.578125 | 4 | """
Module provides functions to generate single pulses of various shapes and parameters. Functions accept a time
axis as an input argument. It suppose to be a NumPy array containing a row of time values defining moments
of sampling. Returned is a baseband signal which is a NumPy array of the same length as the time ax... |
e0b5a0184d3eae6a90b10a0b8e9206b6d926808d | Dathremar11/dathremar11_training | /algoritm_py/Check_list_mipt.py | 323 | 3.875 | 4 | def find(number, A):
"""
ищет number в А и возвращает True, если такой есть
False, если такого нет
"""
for x in A:
if number == x:
return True
return False
""" and """
flag = False
for x in A:
if number == x:
flaf = True
break
return flag
|
0adf3d486d70207bb67c54c1139f5c58d1b87797 | Jay952/Basic_python_programming | /pythontuts/Exercise6_Snake_Wtaer_Gun.py | 1,125 | 4.03125 | 4 | import random
lst1=["Snake","Water","Gun"]
print("You will play three Times!!\n")
k=0
computer=0
yourscore=0
while(k<3):
com = random.choice(lst1)
me = input("Enter your choice Snake,Water,Gun:")
if com == 'Snake':
if me == 'Gun':
print("You won")
yourscore=yo... |
9afba471a288a567fad42ff30e294a5030fe72eb | suleyagmurkara/SiberGuvenlikIcinPython | /Donguler/while1.py | 190 | 3.671875 | 4 | # Ekrana çift sayıları yazdır
sayi = int(input("Çift sayılar için üst sınır giriniz: "))
sayac = 0
while sayac < sayi:
if sayac % 2 == 0:
print(sayac)
sayac += 1
|
72f9896963558a66ae1e823de704ee825503f607 | namhyun-gu/algorithm | /misc/algorithm/binary_search.py | 1,121 | 4.0625 | 4 | """
Binary Search (= 이분탐색)
오름차순으로 정렬된 리스트에서 특정한 값을 찾는 알고리즘
Ref: https://ko.wikipedia.org/wiki/이진_검색_알고리즘
"""
def search(arr, value):
left = 0
right = len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] > value:
right = mid - 1
elif arr[mid] < valu... |
73e0d78b027dfffa2ab2ad4f52fd6d54dfc6d082 | saiprasadreddy96/sai | /cspp1-practice/m5/p1/perfect_cube.py | 238 | 3.859375 | 4 | """
perfect cube
"""
G = 1
N = int(input(""))
F = 0
while G < N+1:
if G**3 == N:
print(str(N) + " " + "is a perfect cube")
F = 1
break
G = G + 1
if F == 0:
print(str(N) + " " + "is not a perfect cube")
|
72954de884c546cd30d831d0c3d819cba1a84cad | edmilsonlibanio/Ola-Mundo-Python | /cursoemvideopython/desafio_034.py | 802 | 3.890625 | 4 | # Escreva um programa que pergunte o salário de um funcionário e calcule o valor do seu aumento. Para salários superiores a R$ 1.250,00, calcule um aumento de 10%. Para salários inferiores ou iguais o aumento é de 15%.
nome = str(input('Informe o seu nome: '))
salario = float(input('Informe o seu salário: '))
salariom... |
0cfc5099cbcc9d5d0ad197a8700f37350cebc787 | luokeke/selenium_python | /python_doc/Python基础语法/3.基本数据类型/字符串str/例子.py | 949 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/12/3 12:33
# @Author : liuhuiling
import os
'''一串文字,中间都数字,让我把数字输出并且顺序反转一下'''
str = "1sad4f5sadf155as12fdasdfasd4412d"
str1 = "0123456789"
str3 = ""
for i in range(len(str)):
if str[i] in str1:
str3 += str[i]
print(str3)#正序
print(str3[::-1])#倒叙
''... |
5a2d134e5a88679f2aa322188884203f2b162b09 | swethacmd2002/guvi.code | /sum_odd.py | 147 | 4.1875 | 4 | n = int(input("Enter Number to calculate sum: "))
sum = 0
for num in range(0, n+1):
if num%2 !=0:
sum = sum+num
print("numbers is: ", sum ) |
15df8b069768a02c7a2c759b0532a3ed8abd478b | KieranCoppins/Dungeon-Salvos | /Interface.py | 6,304 | 3.546875 | 4 | #Kieran Coppins
import tkinter as TK
class Interface():
def __init__(self):
self.root = TK.Tk()
self.mainframe = TK.Frame(self.root)
#Text Based map design - using characters to represent tiles.
self.map = TK.Text(self.mainframe, width = 100, height = 40)
self.map.grid(row = 1, rowspan = 2, column = 1)
... |
b1048d55b5bfdfca76281d8a02dc33b16058c6fd | mparadiso94/lyndatutorial | /Ch3/timedeltas_start.py | 847 | 4.0625 | 4 | #
# Example file for working with timedelta objects
# (For Python 3.x, be sure to use the ExampleSnippets3.txt file)
from datetime import date
from datetime import time
from datetime import datetime
from datetime import timedelta
print(timedelta(days=365, hours=5, minutes=1))
now = datetime.now()
print("today is:", ... |
830b91bd7209bc371e19638314de8332e4a805d4 | rubythonode/algorithm-king | /nypc/2019/day2/prob1.py | 425 | 3.796875 | 4 | # pypy2
from functools import reduce
# https://stackoverflow.com/questions/6800193/what-is-the-most-efficient-way-of-finding-all-the-factors-of-a-number-in-python
def factors(n):
return len(set(reduce(list.__add__,
([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
a, b = [int(i)... |
6dbd02302198e561cc6e60950e8577a0ea91b46a | Cute-Monster/Algorithm_Labs | /src/SearchAlgorithms/Secvent/Secventional_Search.py | 705 | 3.8125 | 4 | def Secventional_Search(array, value):
loop = 0
if len(array) is 0:
return 0, loop
for idx, element in enumerate(array):
loop = loop + 1
if element.salary == value:
loop = loop + 1
index = idx
return index, loop
loop = 0
return -1, loop
d... |
47c2fe4b108eb73c2c31c28ad01433e1f5c46fbf | qq714412541/leetcode | /algorithmINgraph/5_1_quicksort_test.py | 733 | 3.90625 | 4 | import random
# -*- coding:utf-8 -*-
def quickSort(series,l,r):
i = l
j = r
if i > j:
return
axis = series[i]
while i < j:
print(i,j,axis,'??')
while i < j and series[j] >= axis:
print('?')
j -=1
series[i] = series[j]
... |
761bc02c0070b3a4a6df73c722f4f7ddd8ea8001 | eMelkova/-eq- | /laba1_proga1.py | 283 | 3.5625 | 4 |
a = int(input())
b = int(input())
c = int(input())
k = int(input())
if b!=0 and a !=0 and a+b+c!=0 and k-a!=0 and(a+b+c*(k-a/b**3)+c+(k/b-k/a)*c)!=0:
print( abs(a**2/b**2+c**2*a**2)/(a+b+c*(k-a/b**3)+c+(k/b-k/a)*c))
else:
print ("oшибка, деление на 0")
|
041cace46506ecdac0210507913da62a23574b31 | rlhjansen/zsb_halma | /zsb2/halmavisuals-2.py | 12,676 | 3.8125 | 4 | # Done:
# The board and the pieces all appear on the screen.
# You can pick up a piece by clicking on it.
# You can release the piece in another position by clicking on that position.
# After the piece is released, it should be moved to the exact center of a square.
# TO DO:
# The piece should only move if it's... |
8ea5c444a868daed2bd0bde806704e51f312eb1e | SafonovMikhail/python_000577 | /000000stepikProgBasKirFed/Stepik000000ProgBasKirFedсh02p01st08TASK08_20210206_conditional.py | 924 | 4.21875 | 4 | '''
Напишите программу, которая определяет четность введенного числа
Формат входных данных
Единственное целое число N
Формат выходных данных
Если число N является четным, выведите "Число N является четным", в противном случае выведите "Число N является нечетным". Вместо "N" должно быть выведено само число (см. прим... |
a1f041b7e01d568dcd8373a53e4b67a7e16b86f5 | hrisinn/hackbulgaria | /week 0/3.py | 125 | 3.828125 | 4 | def sum_of_divisors(n):
sums=0
for i in range(1,n+1):
if n%i==0:
sums+=i
return(sums)
print(sum_of_divisors(8))
|
bfbd1a676d2bd6abfb85f02893c6ccd223d01dbe | Kwon1995-2/BC_Python | /chapter7/class_Calc.py | 504 | 3.703125 | 4 | class Calc:
count = 0
def add(self, a=0, b=0):
self.a = a
self.b = b
self.count += 1
return self.a + self.b
def minus(self, a, b):
if a == 0 or b == 0:
return a-b, self.count
else:
return a-b
obj = Calc()
print(obj.... |
eac1a04b558d7d57d657e4327ae8798452b7242d | tsaoalbert/test.tensor.flow | /1.weekend.asymptotic,stack.queue.deque.recursion.sorting/t.py | 277 | 3.5625 | 4 |
#Give the Big-O performance of the following code fragment:
def findRepeated(L):
"""
determines whether all elements in a given list L are distinct
"""
n=len(L)
for i in range(n):
for j in range(i+1, n):
if L[i]==L[j]:
return True
return False
|
0447c63e6f2cff2fc09b211897b89217d6f8bc76 | akkuzu/dictionary-example-python | /modules.py | 898 | 4.15625 | 4 |
'''
MODULES
They are tools that contain some functions and attributes that enable us to perform some functions easily.
It provides the opportunity to use these functions it hosts in different files and programs over and over again.
Thanks to the modules, Python has become a much more useful and easy-to-implement.
I... |
62d4f54dd62308c940c81a6a6d5341b7b982c098 | alaanlimaa/impactaADS | /semestre01/exercises_university_uri/1040.py | 601 | 3.671875 | 4 | valor = input().split()
a, b, c, d = valor
n1 = float(a) * 2
n2 = float(b) * 3
n3 = float(c) * 4
n4 = float(d) * 1
media1 = (n1 + n2 + n3 + n4) / 10
print(f'Media: {media1:.1f}')
if 5.0 <= media1 <= 6.9:
print('Aluno em exame.')
valor = input()
e = valor
exame = float(e)
print(f'Nota do exame: {exam... |
5a767ca49e1ac65771d983f0afac796f8bcd40f3 | ETFIRE/ippsi_python | /exos/python_ipair.py | 388 | 3.75 | 4 | #!/usr/bin/python3
"""
def ipair(n):
if n % 2 == 0:
print("pair")
else:
print("impair")
return(n)
lundi == 1
n = int(input('taper un chiffre'))
print(ipair(n))
"""
from datetime import datetime
d = datetime.now()
print(d)
if d.day % 2:
print('jour pair')
else:
print('jour impair')
print('numero du jour... |
732ce4e97c35ea5d66e615e6b119e527f1bb6d62 | Aasthaengg/IBMdataset | /Python_codes/p02273/s375656453.py | 710 | 3.59375 | 4 | import math
class coordinate:
def __init__(self, x, y):
self.x = x
self.y = y
def koch(n, p1, p2):
if n == 0:
return str(p2.x) + " " + str(p2.y)
else:
s = coordinate((2*p1.x + p2.x)/3, (2*p1.y + p2.y)/3)
t = coordinate((p1.x + 2*p2.x)/3, (p1.y + 2*p2.y)/3)... |
de64b30a7e93dad2016f69263a8f523a7191b779 | amituttam/Projects | /Numbers/gen_pi.py | 695 | 3.640625 | 4 | #!/usr/bin/env python
import sys
import math
def gen_pi(n):
count = 0
pi = 0
if n < 0:
return 0
# Set initial values for gauss-legendre algorithm
a = 1
b = 1/math.sqrt(2)
t = (1).__truediv__(4)
p = 1
diff = a - b
print "diff=%f (%s)" % (diff,type(diff))
while diff != 0:
print "count: %d diff=%f" % (c... |
275c5913f8a6fab2497a906c2fcb10d16ad70a7e | kartava/CheckIO-Solutions | /median.py | 561 | 3.9375 | 4 | def checkio(data):
y=sorted(data)
mid=int(len(y)/2)
if len(data)%2==0:
return (y[mid]+y[mid-1])/2
else:
return y[mid]
#replace this for solution
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert ch... |
ae4d72e8b2531ebb916efbe0ac5d847bd15af8c8 | a1424186319/tutorial | /sheng/tutorial/L2基础类型控制语句/8 while循环.py | 595 | 4.03125 | 4 | #while 循环
# if True:
# print('hello')
# while True:
# print('hello')
"""while <条件>:
如果条件为True,那么重复运行while语句块中的内容。
如果while循环的条件一直为True,(一直循环)死循环。
"""
# while True:
# number = 20
# user_number = int(input('请猜一个数字:'))
# if user_number < number:
# print('猜小了')
# elif user_number > n... |
a46eb3b4375c44a6e765dfd76506c01bc9cfb452 | alisonlauren/python-rpg-game | /herogamept1.py | 2,764 | 4.125 | 4 | print()
print()
print("----------------------------------------------------------------")
print("""Hello Hero! I know you were hoping to take the day
off today, but unfortunately you have encountered a goblin :(""")
print("----------------------------------------------------------------")
class Charachter:
def _... |
cce917d4ef3dc4f6348633961e6d6fb05d75c9b9 | SumanSunuwar/python-basic-advance | /calculator.py | 854 | 4.15625 | 4 | # def calculator(choice, num1, num2):
# if choice == 1:
# return num1 + num2
# elif choice == 2:
# return num1 - num2
# elif choice == 3:
# return num1 * num2
# elif choice == 4:
# return num1 / num2
#user input
# print("""--------choices for calculation----------
# 1 for addtion
# 2 for subtraction
#... |
6df61fb3a224d95dd6270a0ba040451e0da4cc65 | MarthaLisett/APODORAX | /graphics_drawer.py | 6,288 | 3.859375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Clase graphics
Clase que implementa toda la funcionalidad
de la libreria de graficos.
José González Ayerdi - A01036121
Martha Benavides - A01280115
03/05/2017 """
from graphics import *
class Graphics():
def __init__(self):
"""Inicializacion y creacion de ... |
ea7361ed3b0635f62fe94a3de42c16aa8d8f18af | hasika16/Python | /internetdata.py | 283 | 3.734375 | 4 | #Example file for retrieving data from internet
import urllib.request
def main():
webUrl = urllib.request.urlopen("http://www.google.com")
print("result code: " + str(webUrl.getcode()))
data = webUrl.read()
print("data is: " + str(data))
#print(data)
main()
|
cf6804862a0dac3eff2f582d29ec91af7410ab8b | akhatavkar17/Project-Euler | /Python/projecteuler-1 python.py | 72 | 3.53125 | 4 | n=0
for i in range(1,1000):
if not i%5 or not i%3:
n=n+i
print(n)
|
c4f11c947a7e897ffa1829008ae2ea2eabdfa819 | tonydavidx/Python-Crash-Course | /Chapter6/glossary2.py | 672 | 4.0625 | 4 | concepts = {
'for loop:' : 'a infinite loop when used program will run utill requirements satisfied',
'list:' : 'stores multiple number or strings',
'if:' : 'using boolean operators if statements run the program',
'tupl:' : 'tupl is similar to list but you cant edit a tuple once created',
'comment:'... |
f757072ea8f1dd3d8c51e63db0bcd12ebbc778e3 | CDC24/unit3 | /warmUp6.py | 266 | 4.15625 | 4 | #Caleb Callaway
#2/16/18
#warmUp6.py - uses for loops to print a sequence, and again with while loops
for i in range (1,11):
print (i,"Mississippi")
i+=1
for i in range (1,5):
print (" ")
i+=1
i = 1
while i <=10:
print (i,"Mississippi")
i+=1 |
258fe9210ed810246eb62f792d116905c83c3bdb | jw3030/git | /python/python_crawler/17_return.py | 261 | 3.875 | 4 | # f(x) = x + 1
# g(x) = x / 2
def f(x):
return x + 1
result = f(1) # 2
print(result)
def g(x):
return x /2
result = f(3)
result2 = g(1)
# f(3) + g(1) = 4.5
print("result:", result)
print("result2:", result2)
result3 = result + result2
print(result3)
|
4cec8c2260229f07b31fd1e0227152f2d3d33683 | y4le/practice | /python/binarytree.py | 3,805 | 3.640625 | 4 | import random
class BinaryTree:
def __init__(self):
self.root = None
class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def __eq__(self, other):
if type(other) == self.__class__:
... |
d02cf54d550f244affb0a76058212e7ab1a29518 | DmitriiOstr/bii-14s | /dima/pathbge.py | 1,933 | 3.65625 | 4 | #!/usr/bin/python
'''
shortest path in unweighted graph
'''
class Graph:
'''
idea for Graph class from http://code.activestate.com/recipes/569151-simple-graph-for-python/
'''
def __init__(self):
self.node = {}
self.neighbor = {}
def add_node(self,node):
self.node[node] = True
def add_edge(self,node,nodes... |
37fbfda3974c85d0bb881e613be83a15a9184668 | codethecoffee/leetcode-solutions | /python_solutions/0122_best_time_to_buy_and_sell_stock_II.py | 405 | 3.53125 | 4 | # Link to problem: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
def maxProfit(prices):
total_profit = 0
length = len(prices)
if length in {0, 1}:
return total_profit
for i in range(1, length):
if prices[i-1] < prices[i]:
# Buy at i-1 and sell a... |
1eecb71b23b77e46507974ee47539b1466a8a518 | timothynickels/qbb2018-answers | /day3-lunch/question-1.py | 359 | 3.59375 | 4 | #!/usr/bin/env python3
import sys
if len(sys.argv) > 1:
f = open(sys.argv[1])
else:
f = sys.stdin
count = 0
for line in f:
fields = line.strip().split()
if line.startswith("#"):
continue
if fields[2] == "gene" and "protein_coding" in line:
count += 1
print("Number of prot... |
3122b937b1dbf38ecc3b3016499eb1b2b8eb38a2 | AnujMacho/Python_programs | /unlucky.py | 212 | 4 | 4 | for i in range(1,21):
if i == 4 or i == 13:
print(f"{i} is an Unlucky number")
elif i%2 != 0:
print(f"{i} is an odd number")
else:
print(f"{i} is an even number") |
483123c9702fd35ee70012a9bbed632f5c7ed1c6 | laurynasas/doom-bot | /graph.py | 13,482 | 3.59375 | 4 | class Node:
def __init__(self, x, y):
self.x = x
self.y = y
self.reachable = None
def __str__(self):
return str(self.x) + " | " + str(self.y)
class Line:
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __init__(self, a,... |
d26b53802bb408f92ba199faea5606aac17ebc93 | yaoxuanw007/forfun | /leetcode/python/removeNthNodeFromEndOfList.py | 948 | 3.71875 | 4 | # https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
# 11:47 - 12:04
class Solution:
# @return a ListNode
def removeNthFromEnd(self, head, n):
curr = head
# move curr for n ... |
1a9dbd77ec69df3bbb55ffeaa91f3ca59b04943f | LemonTre/python_work | /Chap03/Hellp.py | 281 | 3.6875 | 4 | name_list = ['Ada', 'Xiaoli', 'Jessica', 'Linda']
message = name_list[0] + " is a good guy!"
print(message)
message = name_list[1] + " is a good guy!"
print(message)
message = name_list[2] + " is a good guy!"
print(message)
message = name_list[3] + " is a good guy!"
print(message) |
03507818664d98435c7e8233f912a22031d5dfcb | abhijeetbhagat/dsa-python | /DSA/binary_tree_traversals_repeat.py | 719 | 3.703125 | 4 | class Node:
def __init__(self, left, right, value):
self.left = left
self.right = right
self.value = value
def in_order(node):
if node is not None:
in_order(node.left)
print(node.value)
in_order(node.right)
def pre_order(node):
if node is not None:
p... |
35aa8fe0057f5342b016c411c1f1d670c1062dff | imatson9119/Datathon-Pathfinding | /.idea/TravelingSalesman.py | 4,334 | 3.515625 | 4 |
import matplotlib.pyplot as plt
import random as rand
# User guide:
# Use function greedyTravelingWithSwaps(nodes, startingNode)
# nodes is an adjacency matrix, in the form {0: [(0, 0), .. ,(n, distTonthNode)], 1: [(), .. , ()] ....}
# startingNode is the node to start at, can be in range [0, n]
# The return value re... |
c0269818c5513c0970675952b3d47c4a691bb064 | TimurNurlygayanov/test-tasks-example | /algs/stack_and_queue.py | 1,396 | 3.90625 | 4 |
class Node(object):
next = None
previous = None
def __init__(self, value):
self.value = value
# Stack - FIFO
class Stack(object):
head = None
tail = None
size = 0
def push(self, value):
node = Node(value)
if self.tail:
node.previous = self.tail
... |
5053db4679334447c69148a2a6801492cede2996 | LakshmiVinoj/ping-pong | /pingpong.py | 2,932 | 3.796875 | 4 | import turtle
# screen design
ds = turtle.Screen()
ds.title("The classic Ping Pong")
ds.bgcolor("yellow")
ds.setup(width=800, height=600)
ds.tracer(0)
###############################################################
# player and ball design
# player 1
p1 = turtle.Turtle()
p1.speed(0)
p1.shape("square... |
7362f39ff61194ebe0cb43b0e0b4afca910bcb48 | k-nox/swap-meet | /swap_meet/decor.py | 827 | 3.921875 | 4 | from .item import Item
class Decor(Item):
"""
A decor subclass if the Item class
Attributes:
name: a string that is the name of the item
condition: an int from 0-5 representing the condition of the item
age: an int representing how many years old the item is
category: a str... |
6c387b3568f920a3ebe9f1dc2458496392a61081 | agin0634/my-leetcode | /solution-python/0000-0499/0112-path-sum.py | 670 | 3.828125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def hasPathSum(self, root, sum):
"""
:type root: TreeNode
:type sum: int
:rtype: bool
... |
695d3352e1bd09faf54305cece59d272e65cfe70 | Freeloc-Free-lines-of-Code/data-visualization-using-python | /visualization.py | 1,212 | 3.640625 | 4 | import matplotlib
import matplotlib.pyplot as plt
import numpy as np
labels = [
"USA",
"Switzerland",
"Germany",
"United Kingdom",
"France",
"Australia",
"India",
]
salary = [106816, 88773, 54705, 59072, 40558, 47147, 7105]
col = [31524, 45715, 26562, 33831, 29738, 27772, 3272]
x = np.aran... |
a02ce23029ca8047eec66e0eae152ebeaaa8e37f | Jeason22/CS-learning-road | /python_youtube_learning/python_youtube_learning.py | 9,956 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 14:42:37 2020
python 学习记录
@author: Jeason Wu
#数据结构(字符串、数字、布尔值)
character_name = "Tom"
character_age = 50
is_male = True #\False
#打印函数用法
phrase = "Giraffe Academy"
print(phrase + "is cool ")
print(phrase.upper())#转换字符串都为大写
print(phrase.lower())#转换字... |
3bf18b2cb224a9a317407b3c9672f06038957837 | kkyaruek/project-euler | /python2/113.py | 1,616 | 3.640625 | 4 | from combinatorics import *
from time import *
def getEmptyMatrix(row, col, val):
returnMatrix = []
for r in range(row):
aRow = []
for c in range(col):
aRow.append(val)
returnMatrix.append(aRow)
return returnMatrix
# dp
start = time()
increasing = getEmptyMatrix(101, 10... |
1c91cf708443bb38983bdd02257c470a22338c69 | Cheater-84/zombot | /src/user_interface.py | 1,546 | 3.5625 | 4 | # coding=utf-8
class UserPrompt(object):
def __init__(self, gui_input=None):
self.gui_input = None
if gui_input:
import gui
self.gui_input = gui.InputClass(gui_input)
def prompt_user(self, prompt_string, choice):
if len(choice) == 0:
print "You ha... |
4578f1ddb598d43d0cd49dc17791138588695d6e | GabriellaSassoli/Hackaton1 | /smallestMultiple.py | 224 | 3.625 | 4 |
numbers = range(20,1000000000,20)
print(numbers)
for i in numbers:
num = []
for j in range(1,21):
if i % j == 0:
num.append(j)
if (len(num) == 20):
print(i)
break
|
5c99da550ff1ecfd19310982b5ea8e98daccec11 | forestbird3/forest_bird | /kind_of_triangle.py | 460 | 3.90625 | 4 | '''
a,b,c=map(float,input().split())
if a==b==c:
answer='regular triangle'
if a==b or b==c or a==c:
answer='isosceles triangle'
if a != b and a != c and b != c:
answer='scalene triangle'
print(answer)
'''
a,b,c=map(float,input().split())
tri=['no','regular','isoceles','scalene']
x=0
if (a+b)>c ... |
c72a7c50416babcb626f87f0ae90bca297642a32 | murali-kotakonda/PythonProgs | /PythonBasics1/functions/Prog11PassByValue.py | 566 | 4.125 | 4 |
"""
functions ----> reuse the code
code :- reused in diff places of ur project
solution: write code once and reuse any no of times ==> FUNTIONS
SYNATX
1. def keyword to write a function
2. after def specify funtion name
3. function can take any input and can return only one output
# use the indentati... |
0a3b9fdc4779260a83e05445e3383d430f7be4b0 | kainpets/Zelle-introduction-to-CS | /code/chapter11/c11ex19.py | 2,641 | 3.875 | 4 | # c11ex19.py
# Implementation of sets
# Note: Python has a built-in set type, so implementing this is just
# an interesting programming exercise.
# using dictionaries---efficient, but objects in set must be immutable
class DictSet:
def __init__(self, elements):
self.elements = {}
f... |
0b2ce5061785ef76d246a022f37af28a1e95030a | ChWeiking/PythonTutorial | /Python基础/day10(私有化、魔法方法del、类的继承)/demo/练习/day_10.py | 3,722 | 4.1875 | 4 | '''
#属性私有化
class D(object):
def __init__(self,name,address):
self.name = name
self.address = address
def __str__(self):
msg = '年龄:%s 地址:%s'%(self.name,self.address)
return msg
def get_age(self):
return self.__age
def set_age(self,age):
if 0 < age <110:
self.__age = age
else:
print('不符合常规!!!')
x... |
74b51d6b3863126c164d774e68b416424d6eb84f | ankit50/Python | /birthdayRemainde.py | 703 | 4.28125 | 4 | remainder = {}
while True:
print("**********Birthday Remainder*************")
print("1).Show BirthDay:\n2).Add BirthDay:\n3).Exit")
choice = int(input("Enter The Choice(1-3):"))
if choice == 1:
if len(remainder.keys()) == 0:
print("Noting To show!")
else:
name = i... |
7a97437b623118c5cf549926570c2c54b87f2e43 | tuananh8497/technical-interview-prep | /Python-Programming/Graph/Mininum-Spanning-Tree.py | 1,838 | 3.546875 | 4 | class vertex:
def __init__(self, id, visited):
self.id = id
self.visited = visited
class edge:
def __init__(self, weight, visited, src, dest):
self.weight = weight
self.visited = visited
self.src = src
self.dest = dest
class graph:
g = [] # vertices
e =... |
a5ef510b06d7d4aec288d48249c6d8d7af0e7adc | ZR-Huang/AlgorithmsPractices | /Leetcode/Basic/Linked List/19_Remove_Nth_Node_From_End_of_List.py | 1,461 | 3.9375 | 4 | '''
Given a linked list, remove the n-th node from the end of list and return its head.
Example:
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will always be valid.
'''
# Definition for singly-linked list.
# class ListNode:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.