blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
d25a7275e8e4a7f781eb11338cf94af0b4c1f154 | VitorNovaisV/Algoritmos-em-Python | /ex051.py | 116 | 3.765625 | 4 | pt = int(input('1° termo: '))
r = int(input('Razão: '))
for c in range(pt , pt + 10 * r, r):
print(c, end=' ') |
bc66af92b4d0a9f4010a2c1cef930d94872c3da2 | DoyKim-20/DoyKim-20.github.io | /Practice01.py | 208 | 3.6875 | 4 | num=int(input('자릿수를 알고싶은 숫자를 입력해주세요!'))
print(type(num))
a = 0
while num > 1:
num = num / 10
a = a + 1
print('num은', a, '자리 수 입니다.')
#60192164 김도영 |
50f0681d50727e828ad899d10fb403b930b90b75 | markgroner/data_dev | /3_python/list_comprehensions/comprehensions.py | 531 | 4.1875 | 4 | def comprehensions():
name_list = []
for _ in range(5):
name_list.append(input('Enter a name: '))
print(name_list)
lower_name_list = [name.lower() for name in name_list]
print(lower_name_list)
title_name_list = [name.title() for name in name_list]
print(title_name_list)
wedding_n... |
e868b2857057fc1728eac31057e509136c517456 | arerickson28/python-challenge | /PyBank/main.py | 2,420 | 3.71875 | 4 | #Imports
import os
import csv
#csv to read
csvpath = os.path.join( 'Resources', 'budget_data.csv')
#textfile to write
file_to_join = os.path.join('Analysis', "budget_analysis.txt")
#Variables to use
number_of_months = 0
current_amount = 0
prev_amount = 0
change_in_profit = 0
net_total = 0
avg_change = 0
sum_of_prof... |
2810613f3c73aab2e084f131078b0ee6f552277a | RGMishan/py4e | /dailyPractice/pra2.py | 354 | 4.0625 | 4 | #Question 2: Given a range of first 10 numbers, Iterate from start number to
#the end number and print the sum of the current number and previous number
num = 10
prev = 0
print("Printing current and previous number sum in a given range(10)")
for i in range(num):
tot = i + prev
print("Current num =", i,"Previous num... |
b0c3e59d13d87ce6fa876301623c193e8f67ce03 | RiddhiDamani/Python | /PythonExamples.py | 205 | 4.0625 | 4 | def cheer(n):
'return a string with a silly cheer based on n'
if n <= 1:
return "Hurrah!"
else:
return "Hip " + cheer(n - 1)
#if __name__ == '__main__':
x = cheer(5)
print(x)
|
b986aee3692255fdd53c6b7ee5e42b3dcfa41e4c | testmywork77/WorkspaceAbhi | /Year 8/Random_Quiz.py | 708 | 3.875 | 4 | q1 = input("What letter is the first letter of the alphabet?").lower()
if q1 == "a":
print("LOL, I tricked u")
else:
print("WOW, u did not get tricked!!!")
q2 = input("What is the meaning of the universe?").lower()
if q2 == "ur mum":
print("Umm... HOW did u get that correct!!!")
else:
print("LOL, the... |
f7520ad3ac8be3110d4d71870f8cf844653dc573 | gskranjan/dugwell-analysis | /code/dbscan_clustering.py | 4,877 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 23:11:52 2020
@author: KW0495
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
def DBSCAN(x, eps, MinPts):
#This variable has the final list of assigned labels.Initially they're all
#set to ze... |
78ee55e9cf50188ca4847de015976bf86e945643 | Jaden5672/Python_Coding | /function.py | 292 | 3.53125 | 4 | def relayname(name,amount):
for i in range(amount):
print(name)
relayname("Jaden",2)
relayname("Jeremy",3)
relayname("Sara",4)
def sum(number1,number2,op):
if(op=="+"):
print(number1+number2)
else:
print("invalid operation")
sum(1075,3250,"+")
|
073b83ac0f028a5c40564d79ba031609b690d1a1 | JoaumGabriel/cad-terminal | /app.py | 462 | 3.625 | 4 | import time
from messages import *
msg = Messages()
msg.introduction()
while msg.escolha != msg.cont:
print("- - - - MENU DE CADASTRO - - - -")
print("1 - Criar cadastro")
print("2 - Editar cadastro")
print("3 - Visualizar cadastro salvo")
print("4 - Deletar cadastro salvo")
print("5 - Ajuda com o programa")... |
c063edf6ee7ceeb3316db48145511a2d73d34dfa | antrijuzar/DDU-sem-4-programs | /SP/Lab 2/Exercise Based on data Structures/P1.py | 229 | 4.34375 | 4 | # Write a program that stores following names in a list.Also write instruction
# to iteratively print names from the list.
list = ["ramu", "shyamu", "kanu", "manu", "ramu", "radha", "manu"]
for i in range(0,7):
print(list[i]) |
6b4d7e3c5220eac16d118d448acb0b188b18cd68 | YuchinP/TTA-Python | /agedrill.py | 685 | 4.03125 | 4 | <<<<<<< HEAD
print ("Let's see how long you have lived in days, minutes and seconds.")
name = input("name: ")
age = int(input("age: "))
days = age * 365
minutes = (age * 525948) - (days * 24 * 60)
seconds = (age * 31556926) - (days * 86400)
print(name, "has been alive for", days, "days", minutes, "minutes and", seconds... |
46dad9af1c85f1b76278f107b4404e71ac9f827f | mdrame/Python_Pratices | /RockPaperScissors.py | 704 | 3.671875 | 4 | #---- Instruction --------
# Make a two-player Rock-Paper-Scissors game.
# (Hint: Ask for player plays (using input),
# compare them, print out a message of congratulations
# to the winner, and ask if the players want to start a new game)
#
# Remember the rules:
#
# Rock beats scissors
# Scissors beats paper
# Pape... |
3ec69bb3a0c97588d57854232dc93be3b5f86dc4 | Vloon/ProjectEuler | /problem9.py | 429 | 4.1875 | 4 | import math
def get_triplet(n,m):
"""
Returns the tuple (a,b,c) for input n and m based on Euclids formula.
"""
return (m**2 - n**2, 2*m*n, m**2 + n**2)
def get_pythagorean_triplet(number):
for n in range(0, number):
for m in range(n+1,number):
a,b,c = get_triplet(n,m)
... |
5ee1f6a7d25a4876d140edc65063bd3929c95b5d | zLordelo/pythonExercise | /ex054.py | 494 | 3.515625 | 4 | import datetime
print('=' * 50)
print('\033[1;31mGRUPO DA MAIORIDADE\033[m'.center(60))
print('=' * 50)
ano = datetime.datetime.now().year
maiores = 0
menores = 0
for c in range(1, 8):
nasc = int(input('Em que ano a {}º nasceu? '.format(c)))
idade = ano - nasc
if idade >= 18:
maiores += ... |
cdd1508314d513582225c48560a4afe0aa6ecde0 | LabSocialAffectNeuro/lsan_tools | /lsan_tools/utils.py | 527 | 3.5 | 4 | from glob import glob
import os
__all__ = ['add_file_prefix'
]
__author__ = ["Shawn Rhoads"]
def add_file_prefix(files_dir, prefix):
# adds prefix to every file in specified directory
assert type(files_dir) == str, "files_dir should be type(str)"
assert type(prefix) == str, "prefix should be t... |
6c70f544118ced05a9928312d3070f77cafa3fe5 | yhoi/AtCoderBeginnerContest | /198/A.py | 82 | 3.828125 | 4 | a = int(input())
if a == 0 or a == 1:
print('0')
else:
print(str(a-1)) |
55c379793f52e14f157767bd7b45940b687490e1 | harshitpoddar09/HackerRank-Solutions | /Python/Alphabet Rangoli.py | 563 | 3.765625 | 4 | def print_rangoli(size):
# your code goes here
width=(((size*2)-1)*2)-1
arr=[]
for i in range(size):
ascii=96+size
a=chr(ascii)
for j in range(i):
ascii-=1
a+='-'+chr(ascii)
for k in range(i):
ascii+=1
a+='-'+chr... |
93751ba9051ce119be7763d30fae694ae37a78f9 | dmitry-pechersky/algorithms | /hackerearth/The Parking Slot.py | 1,326 | 3.640625 | 4 | import heapq
def dijkstra(adj_list, n, capacities, k):
heap = [(0, 0)]
distances = [None] * n
nodes_order = []
while heap and k > 0:
distance, u = heapq.heappop(heap)
if distances[u] is None:
distances[u] = distance
nodes_order.append(u)
k -= capacit... |
cc039fcd4b4187c7b2861bb8a75df18afc16953b | boyer-code/pynet_ansible | /Coursera-UMich/8_4-romeo-reading.py | 747 | 4.59375 | 5 | #8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() function. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort an... |
ee1fb4933fd0760b6da479d00a009ef51401cb9c | brightcode-k/python_homework | /Laboratory2/lab2task2.py | 667 | 3.78125 | 4 | """
Написати програму, в результаті виконання якої з'ясується, чи входить цифра 2 в запис даного цілого числа n.
"""
import re
def checker(text):
return bool(re.match("^[-+]?\d+\.{0,1}\d*$", text))
def get_number(prompt):
text = input(prompt)
while not checker(text):
text = input(prompt)
... |
50ec63a74c980d4e14ed178362d7c3491ba696b2 | TomKemperNL/hu-prog-uitwerkingen | /5_6.py | 936 | 3.65625 | 4 | # Schrijf (en test) de functie wijzig() met één parameter: letterlijst.
# Zorg dat de functie de lijst leegt en de letters [ ‘d’, ‘e’, ‘f’ ] toevoegt.
# Er is geen return-waarde! Test je programma als volgt:
def wijzig(letterlijst):
letterlijst.clear()
letterlijst.append('d')
letterlijst.append('e')
le... |
88256dd7da88070a3f5885adb547a66e68245144 | tarunsimon/CodeKata | /ts1pronew.py | 201 | 3.640625 | 4 | var1=int(input())
var2=[]
var3=[]
for i in range(var1):
var3=input()
var2.append(var3)
d=[]
for i in zip(*var2):
if(i.count(i[0])==len(i)):
d.append(i[0])
else:
break
print(''.join(d))
|
ce25a062c5463e4a0434aac4c973b148f08d68fd | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_200/4146.py | 706 | 3.640625 | 4 | def checkNum(num):
num=str(num)
num=list(num)
num.sort()
return num
def removeDup(num2):
for s in range(1,len(num2)-1):
num2=list(num2)
if num2[s]==num2[s+1]:
num2[s]="0"
num2[s+1]="0"
return num2
ANS=[]
a=raw_input()
a=int(a)
for i in range(a):
b=ra... |
b086c91130b134e7e87446984d4fb653f4bcbdf3 | iampkuhz/OnlineJudge_cpp | /leetcode/python/passedProblems/58-length-of-last-word.py | 990 | 4.09375 | 4 | #!/usr/bin/env python
# encoding: utf-8
"""
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space characters only.
For exam... |
c89bc5eb624b019876ca96979935a66365986117 | ankyy307000/Helloworld | /reverse.py | 69 | 3.75 | 4 | n=input("Enter a string::")
print("Reverse of array is::",n[-1::-1]) |
2a21dca69c4f9123cf786f1dc63ef4532693e5e7 | mindful-ai/oracle | /amstar-01/day02/examples/generator_yield.py | 762 | 3.984375 | 4 | def nextSquare():
print('INitializing')
i = 1;
# An Infinite loop to generate squares
while True:
print('Before Yield')
yield i*i
print('After Yield')
i += 1 # Next execution resumes
# from this point
# Driver code to test abo... |
abba68d01e8f19380adab04e2e7fae650a48d58a | pratyushgarg15/CodingPractice | /nthPrimeNumber.py | 915 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 28 23:12:03 2019
@author: HP
"""
def isPrime(n):
if(n<=1):
return False
if(n<=3):
return True
if(n%2 == 0 or n%3 == 0):
return False
i = 5
while(i*i <= n):
if(n%i == 0 or n%(i+2) == 0):
return Fals... |
7aa65ef6a3f7f2b3417ad0b1ff17f5670bb70256 | earl706/codewars-solutions-python | /Vowel Count.py | 592 | 3.984375 | 4 | """
7 KYU
Return the number (count) of vowels in the given string.
We will consider a, e, i, o, u as vowels for this Kata (but not y).
The input string will only consist of lower case letters and/or spaces.
LINK: https://www.codewars.com/kata/54ff3102c1bad923760001f3/train/python
"""
def get_count(input_str):
... |
597db28285bd267024b4512e563770655541aba6 | 111989/vlsi_tsp_comparison | /pso_tsp.py | 25,690 | 3.984375 | 4 | # COURSE PROJECT - Comparison of collective intelligence techniques performances
# Multiagent Systems - MUIA 2020/21
#
# (DISCRETE) PARTICLE SWARM OPTIMIZATION
#
# Author: Luna Jimenez Fernandez
#
# This file contains the implementation for a Particle Swarm Optimization Algorithm used
# to solve the Travelling Salesman... |
234f5f4b0655c980a5a8394e9aa4d55566de4e5b | aayushi7695/Python | /print pattern 1.py | 177 | 3.84375 | 4 | # print the following pattern
# 1 2 3 4
# 2 3 4
# 3 4
# 4
for i in range(4):
print(i + 1, end="")
for j in range(3 - i):
print(j + i + 2, end="")
print()
|
4eb516cdb74e39ccb5f53809473941f27da932b6 | Best0fme/RPG-Journey | /environment.py | 1,719 | 3.515625 | 4 | import random
from objects import Creature, Hero
creature_dictionary = ["health","mana","dmg","absorb"]
hero_dictionary = creature_dictionary + ["stamina"]
_creatures = {}
_hero = Hero()
def create_creatures(value_dict):
health, mana, dmg, absorb = value_dict["health"], value_dict["mana"],\
value_dict["dmg"],... |
db9f40dbad218c347ab195aafe5935f60908813c | ankitbanerjee0211/Python_Programming | /40 Challenging Python Programs/13_factorial_calculator.py | 695 | 4.40625 | 4 | import math
print("||| Welcome to the Factorial Calculator App |||\n")
num = int(input("What number would you like to compute the factorial of? "))
factorial = 1
print(str(num) + "! = ", end = "")
for i in range(1, num+1):
print(str(i), end="")
if i != num:
print("*", end="")
print("\n\nHere is the ... |
a27bee26906b6c9e210e94140f0d7582607901b3 | landlab/landlab | /landlab/utils/add_halo.py | 1,173 | 4.1875 | 4 | import numpy as np
def add_halo(data, halo=1, halo_value=None):
"""Add a halo of no data value to data.
Parameters
----------
data : array-like
Array to add the halo to.
halo : int, optional
The size of the halo.
halo_value : float, optional
Value to fill the halo with... |
ccccf3dcffb02638c4c3b835e85962671da157f7 | J2112O/Fab_Py_Post | /explore_functions.py | 2,148 | 3.984375 | 4 | #!/usr/bin/python3.6
import datetime
from datetime import date, time
while True:
try:
trekking_poles = str(input("Trekking Poles Used? (True or False): ")).title()
if trekking_poles == "True":
trekking_poles = True
else:
trekking_poles = False
except Exception a... |
66f6d3594091738cb813952cdd113c2c6a4d53cd | Beanj10/CP1404pracs | /prac_02/files.py | 724 | 3.578125 | 4 | #Question 1
name = input('Please enter your name: ')
file_name = open('name.txt', 'w')
file_name.write(name + '\n')
#Question 2
file_name = open('name.txt', 'r')
fname = file_name.readline(1)
print('Your name is', name)
#Question 3
file_name = open('numbers.txt', 'w')
file_name.write('17\n42\n400\n')
f... |
9b9bf5db0780bd47ff810218dbe7ead09d17511e | tonper19/PythonDemos | /beyond_the_basics/02.beyond_the_basic_functions/transposing_tables.py | 1,466 | 4.6875 | 5 | """how to transpose a table in Python,
called pivoting a table in Excel."""
from pprint import pprint as pp
print("*** Almiryda hourly temperatures from 28/07/2019 to 31/07/2019")
sun = [20, 20, 19, 19, 19, 20, 20, 22, 23, 24, 27, 30, 33, 35, 38, 41, 40, 38, 35, 30, 28, 25, 23, 22]
mon = [21, 19, 18, 18, 19, 20, 21, 2... |
e3cbc534e8c0972aa245997609b20ae70404b632 | lucasbenazzi/math-equation | /test_function.py | 17,557 | 3.703125 | 4 | import unittest
from function import functionClass
function = functionClass()
class TestFunctionClass(unittest.TestCase):
def test_simple_character_check(self):
type_list = [
20, 20.5, 1j, ["apple", "banana", "cherry"], ("apple", "banana", "cherry"),
range(6), {"n... |
95f02c56774432f30365d504faa70837d9bd7f76 | Archer-Fang/algorithm | /python/Temp/leetcode/editor/cn/[707]设计链表.py | 3,691 | 3.515625 | 4 | # 设计链表的实现。您可以选择使用单链表或双链表。单链表中的节点应该具有两个属性:val 和 next。val 是当前节点的值,next 是指向下一个节点的指针
# /引用。如果要使用双向链表,则还需要一个属性 prev 以指示链表中的上一个节点。假设链表中的所有节点都是 0-index 的。
#
# 在链表类中实现这些功能:
#
#
# get(index):获取链表中第 index 个节点的值。如果索引无效,则返回-1。
# addAtHead(val):在链表的第一个元素之前添加一个值为 val 的节点。插入后,新节点将成为链表的第一个节点。
# addAtTail(val):将值为 val 的节点追加... |
42a3bf90136d020ed319667d93d0b72194db74ca | wherculano/wikiPython | /02_Estrutura_de_Decisao/21-CaixaEletronico.py | 945 | 4.125 | 4 | """
Faça um Programa para um caixa eletrônico. O programa deverá perguntar ao usuário a valor do saque e depois informar quantas notas de cada valor serão fornecidas. As notas disponíveis serão as de 1, 5, 10, 50 e 100 reais. O valor mínimo é de 10 reais e o máximo de 600 reais. O programa não deve se preocupar com a q... |
b493e27cfa8cebe1564932b902a245ac8f699805 | aggeor/CryptographyCourseProjects | /AffineDecryption.py | 993 | 3.84375 | 4 | #!/usr/bin/python
import string
alphabet = string.ascii_uppercase
ciphertext = "Hflyy Lqtuw jel hfy Yxdyt-mqtuw stnyl hfy wmk, Wydyt jel hfy Noglj-xelnw qt hfyql fgxxw ej whety, Tqty jel Ielhgx Iyt neeiyn he nqy, Ety jel hfy Nglm Xeln et fqw nglm hflety Qt hfy Xgtn ej Ielnel ofyly hfy Wfgneow xqy. Ety Lqtu he ls... |
383de15c4133a492abd6351422c1942b024e7e33 | SeunghyeunBaek/TIL | /02_머신러닝이론/1_Linear Regression/linear_regression.py | 1,143 | 3.515625 | 4 | import numpy
def compute_error_for_given_points(b,m,points):
totalError = 0
for i in range(0,len(points)):
x = points[i,0]
y = points[i,1]
totalError += (y-(m*x+b))**2
return totalError/float(len(points))
def step_gradient(currents_b, current_m, points, learning_rate):
#gradient descent
b_gradient = 0
m_... |
101dbd404a00bd37c548a80c5d2656313edfd038 | TeknikhogskolanGothenburg/Python20_Python_Programming | /30sep/fileread.py | 391 | 3.828125 | 4 | def main():
with open("textfile.txt", "r") as file:
text = file.readlines()
with open("textfile.txt", "r") as file:
line = file.readline()
print(line.strip())
line = file.readline()
print(line.strip())
print("-------------")
for line in open("textfile.txt", "r"... |
877ad381c9639dcdd32acb5c380ccd8e70225381 | soyalextreme/python-course-intermediate | /lambda.py | 140 | 3.515625 | 4 | palindrome = lambda string: string == string[::-1]
if __name__ == "__main__":
print(palindrome('ana'))
print(palindrome('chuchu'))
|
6a4e49227e0348a4a084965d53a0475f94083d04 | ThomasAlakopsa/encryption_programs | /old/HexToB64.py | 359 | 3.578125 | 4 | import codecs
hexString = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"
b64Example = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
#decode the hex String to UTF-8
hexString = codecs.decode(hexString, 'hex');
String= hexString.decode();
print("d... |
b4eff7443c5cb818219c8a55215ef926e646383f | Dod-Annie/Python-Learning | /lesson1/tuple_name.py | 435 | 4.1875 | 4 | # 为tuple中每个元素命名
## 定义一系列数值常量
NAME,AGE,SEX,EMAIL = range(4)
student = ('Jim',16,'male','jime@gmail.com')
print(student[EMAIL])
## 使用namedtuple代替tuple
from collections import namedtuple
Student = namedtuple('Student',['name','age','sex','email'])
s = Student('Jim',16,'male','jime@gmail.com')
print(s.name) # 可以直接用... |
2b34da786640e16e91438010577ed5c5e6b56799 | kkfaisal/coding-test-python | /timer_decorator.py | 496 | 3.65625 | 4 | """
Answer for question 7.
"""
import time
import random
def timer(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
print("Time taken for execution in millisecond", (te - ts) * 1000)
return result
return timed
@timer
def r... |
261be4324763f4b7af756a9d5995437cca29d228 | alanbeavan/impractical_python_problems | /2/projects/dictionary_cleanup/dictionary_cleanup.py | 373 | 4.21875 | 4 | #!/usr/bin/env python3.6
"""Remove all the single letter words from the dictionary.
Arguments:
Dictionary list
Returns:
Modified dictionary
"""
def single_letters_removed(words):
"""Return dictionary that doesn't contain sinlge letter words."""
copy = words.copy()
for word in words:
if len(word) ... |
64ddb5b8b2b92211b042482c690e211c646e392f | MLunov/Python-programming-basics-HSE | /Week 2: Conditional statement and while loop/2 (18).py | 847 | 3.84375 | 4 | a1, b1, c1 = int(input()), int(input()), int(input())
a2, b2, c2 = int(input()), int(input()), int(input())
if b1 >= c1:
b1, c1 = c1, b1
if a1 >= b1:
a1, b1 = b1, a1
if b1 >= c1:
b1, c1 = c1, b1
elif a1 >= b1:
a1, b1 = b1, a1
if b1 >= c1:
b1, c1 = c1, b1
... |
4d5be16891a6239125a898c8bea25ff10d709763 | inki-hong/python-oop | /e101_mul_table.py | 385 | 3.796875 | 4 | my_list = []
for n1 in range(20):
inner = []
for n2 in range(20):
inner.append(n1 * n2)
my_list.append(inner)
# print(my_list)
print(my_list[5][6])
print(my_list[4][8])
print(my_list[2][3])
my_list = [[n1 * n2 for n2 in range(20)]
for n1 in range(20)]
print(my_list)
print(my_lis... |
100a3856385fbff9a864dc7ea7a536c74575da89 | MPTGits/DungeonsAndPythons | /Tests/test_enemy.py | 1,597 | 3.578125 | 4 | import unittest
import enemy
class testEnemyChars(unittest.TestCase):
def test_name_generator(self):
self.assertEqual(len(enemy.generate_word(5)),5)
self.assertEqual(type(enemy.generate_word(5)),type(''))
def test_negative_inputs_for_enemy_mob(self):
#Digits at the end are (healt... |
83dffd813564a7938c4c0243bad39225ad53c9a4 | NateOwl1108/assignments | /Assignments_10-19/completed_assignment_18/linked_list.py | 653 | 4.0625 | 4 | class Node():
def __init__(self, data):
self.data = data
self.next = None
A = Node(4)
print(A.data)
print(A.next)
B = Node(8)
A.next = B
print(A.next.data)
class LinkedList():
def __init__(self, head):
self.head = head
self.data = Node(head)
def print_data(self):
print(self.data)
... |
b99c63efa3bd46d616a1ca32092f0f2c0094b338 | jaganseshadri/coursera | /python-for-everybody_umich/python-data-structures/week-3/assignment_7.2.py | 334 | 3.5625 | 4 | # Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
zop = 0.0
count = 0
for line in fh:
if not line.startswith("X-DSPAM-Confidence:") : continue
pos = line.find('0')
zop = zop + float(line[pos:].strip())
count = count + 1
print("Average spam confidence... |
6413fce65ab2e9bb783a52824657fdfb103df8a5 | DanilXO/computer_science | /chapter1/task_3sum.py | 881 | 3.921875 | 4 | """
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
The solution set must not contain duplicate triplets.
Example:
Given array nums = [-1, 0, 1, 2, -1, -4],
A solution set is:
[
[-1, 0, 1],
[... |
a56e69b6c894f60574d1e00fb537f2fc40588ba7 | MarekKarmelski/python-oop | /src/bmi.py | 2,013 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""BMI class."""
class BMI:
__weight = None
__height = None
__bmi = None
__perfect_bmi = 21.75
__rate = 1
def __init__(self, weight=None, height=None):
"""Init BMI class."""
if weight is not None and isinstance(weight, (float, in... |
c0ae64154acc42c9a0ca332273aa4306c5684a60 | gabrielgamer136/aula-git-gabriel | /Documentos/lista de exercicios 1 python gabriel/exercicios 06.py | 324 | 3.8125 | 4 | #GabrielMaurilio
#solicite o preço de uma mercadoria e o percentual de desconto.exiba o valor do desconto e o preço a pagar.
mercadoria = int(input("qual e o preço da mercadoria:"))
desconto = int(input("valor desconto:"))
soma = ( mercadoria / 100 * desconto )
print(soma)
soma = (mercadoria - soma )
print (soma)... |
4b0d335e7291dc7fbf40d1f990b83604df580177 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2329/60605/302758.py | 59 | 3.6875 | 4 | x = input()
if x == "1,2,3,4,5,6": print(4);
else: print(x) |
2d1caf9ed4c4697a0fbd0af8272bbd1e52806add | rpgraham84/euler | /problem_0024.py | 1,376 | 3.71875 | 4 | """
Robert Graham (rpgraham84@gmail.com)
Project Euler
Lexicographic permutations
Problem 24
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order... |
d751cc122d86f3c37968965658801d3c5b397e80 | msinghartinger/pyipn | /pyipn/io/plotting/angle.py | 714 | 3.546875 | 4 | import numpy as np
__all__ = ('reference_angle', 'reference_angle_deg',
'wrapped_angle', 'wrapped_angle_deg')
def reference_angle(a):
"""Convert an angle to a reference angle between -pi and pi."""
a = np.mod(a, 2 * np.pi)
return np.where(a <= np.pi, a, a - 2 * np.pi)
def reference_angle_deg... |
0668f705c1cfbc6944eada27c04544a09f24d8ad | pythonvietnam/pbc032015 | /NguyenGiaHa/3.2.pythoncalculator_exception.py | 1,713 | 3.96875 | 4 | #Python Calculator
print "Xin chao, day la chuong trinh Python Calculator"
running = True
while running:
print "----------------------------"
print "1.Cong(+)"
print "2.Tru(-)"
print "3.Nhan(*)"
print "4.Chia(/)"
print "5.Fibonacci(f)"
print "6.Quit(q)"
answer = raw_input('Chon (1-6): '... |
a7f9645dbf666a8fa0acfcec64eedf0d8b851a18 | drew-loukusa/DrewLang | /modules/locate_file.py | 2,921 | 4.03125 | 4 | import os
def find(file_name, start_dir) -> str:
""" Searches for file named 'file_name' starting in directory 'dir'.
Will search current directory and all directories under current directory for file.
Does not follow symbolic links.
@Return:
Absolute path to file -> If file e... |
3e95a08ffa9d44bb85614b23a4fa68e5b25c0a1b | RoSapia/Python-curso-em-video | /curso-python/cursoemvideo/ex24aula9.py | 228 | 3.9375 | 4 | '''Leia o nome de uma cidade e diga se ela começa ou não com o nome Santo.'''
cidade = str(input('Digite o nome da sua cidade:\n')).strip()
temsanto = cidade.upper().split()
temsanto1 = temsanto[0]
print(temsanto1 == 'SANTO')
|
817c87c72cfce2b32e1f2666136f1cf318d303e3 | iianarmas/small_projects | /binary_search_1.py | 563 | 3.703125 | 4 | def search(lst, n):
lst.sort()
global low, high
if low <= high:
mid = (low + high) // 2
if lst[mid] > n:
high = mid - 1
return search(lst, n)
elif lst[mid] < n:
low = mid + 1
return search(lst, n)
return mid
return -1
my_... |
d6b583009e97d5886f0b11c066426c29bf56c802 | JacobMason83/python_challenges | /strings/substr.py | 335 | 3.765625 | 4 | sentence = 'The quick brown fox jumped over the lazy dog.'
# query = sentence.find('oops')
# query_two = sentence.index('oops')
# # new_query = sentence.find(input("enter search term")) you can have a user input what they are looking for in your list or dict
# print(query)
# print(query_two)
query = 'oops' in sentenc... |
d8d828a49c9f3de22d7a3fc2635528a2c26139a4 | CCSt130/SP_Online_PY210 | /students/anthony_mckeever/lesson5/assignment_1/mailroom.py | 13,643 | 4.0625 | 4 | #!/usr/bin/env python3
"""
Programming In Python - Lesson 5 Assignment 1: Mailroom Part 3
Code Poet: Anthony McKeever
Start Date: 08/13/2019
End Date: 08/15/2019
"""
import os
import sys
import tempfile
def main():
"""
The main loop of the script. Prompts user with a main menu.
"""
print("\nStudio S... |
b0a3d247c7a4a409203e96dbbd2dc90b438e7045 | faustfu/hello_python | /file03.py | 877 | 3.90625 | 4 | # 1. Module:csv is for CSV files.
import csv
filename = 'a.csv'
a = [
['ab', 'cd'],
['ok', 'not ok'],
['aqw', 'p02']
]
b = [
{'first': 'ab', 'last': 'cd'},
{'first': 'ok', 'last': 'not ok'},
{'first': 'aqw', 'last': 'p02'}
]
with open(filename, 'wt') as fout:
csvout = csv.writer(fout)
... |
a01d7da9f91e9f847dba8ad7d028f942c9ebd457 | ApexTone/PCA-TA-KMITL64 | /Lab04/algo_analysis.py | 3,209 | 3.5 | 4 | import time
# use this decorator to time the execution time
# https://medium.com/pythonhive/python-decorator-to-measure-the-execution-time-of-methods-fa04cb6bb36d
def timer(method):
def timed(*args, **kwargs):
start_time = time.time()
result = method(*args, **kwargs)
end_time = time.time()... |
849fffdf0578be9841190d71f87d2f94ba5af36c | Young-cpu/Color_Pallets_image_filter | /run_k_means.py | 894 | 3.890625 | 4 | """
Younghyun Jung
This file is making a new file with the number of "k" which is input from the user.
As it goes through k-means algorithm, it will replace pixels of original image.
In the end, it will recreate image file only with number of "k"
"""
from k_means import *
from image_utils import *
if __name__ == "__ma... |
a3eeb9a5070fa74310749ed75c85de607dbb6374 | byeongal/KMUCP | /week05/code02.py | 189 | 3.8125 | 4 | number_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print("리스트에 있는 숫자 출력 시작!")
for number in number_list:
print(number)
print("리스트에 있는 숫자 출력 끝!") |
b9cd30655695e6e92354a2e5c62bf7a8557242fd | GiovanneMika/Homeworks | /Professor Lúcio/Exercicios de Python While/Exercicio de while com altura.py | 356 | 3.796875 | 4 | c=0
altme=0
altma=0
altmeio=0
while(c<5):
alt=float(input("Digite a sua altura, em cm: "))
c+=1
if alt>180:
altma+=1
if alt<160:
altme+=1
if alt>160 and alt<180:
altmeio+=1
print(f"Das {c} alturas informadas, {altma} são maiores que 180cm e {altme} são menores que 160cm. {alt... |
ac8bd064a077ecb80ba9da69c7088a3c81090237 | cosmicRover/algoGrind | /linked-list/SLLDetectLoopIndex.py | 856 | 3.65625 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def detectCycle(self, head):
# init vars to the head
slow = fast = head
# loop the two pointers
whi... |
32efcb2bf32f06c9f9e19c06cf68de8133910d58 | saurabh-pandey/AlgoAndDS | /leetcode/dp/tribonacci_numbers.py | 908 | 3.78125 | 4 | #URL: https://leetcode.com/problems/n-th-tribonacci-number/
#Description
"""
The Tribonacci sequence Tn is defined as follows:
T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.
Given n, return the value of Tn.
Example 1:
Input: n = 4
Output: 4
Explanation:
T_3 = 0 + 1 + 1 = 2
T_4 = 1 + 1 + 2 = 4
Exa... |
7c744c08c400bad6406ca3c0a84e853873ab18bf | danganhvu1998/myINIAD | /code/PythonINIAD/speechToTextTesting1.py | 571 | 3.828125 | 4 | import speech_recognition as sr
# Collect speech from microphone
r = sr.Recognizer()
# We will learn with syntax next week.
# It is used here to start and finish the use of the microphone.
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
# Recognize speech
try:
message = r.recogn... |
879cace9fd91068669551b2dd6ddc32b690270d2 | jolesinski/bo-project | /gfx/create_palette.py | 755 | 3.609375 | 4 | import PyColor
import pickle
import random
def main():
'''
When script is launched from terminal it creates list of triples of colors to use in plot and saves it to pickle file
'''
# load colors
squares_colors = PyColor.get_colors()
# create labels colors by inverting colors of squares
... |
389ba93ea3e402de25c15f981f4de6458bc865a1 | Firkraag/algorithm | /tests/test_queue.py | 840 | 3.53125 | 4 | from unittest import TestCase
from Queue import Queue, EmptyException, FullException
class TestQueue(TestCase):
def test_enqueue_and_dequeue(self):
queue = Queue(3)
queue.enqueue(1)
queue.enqueue(2)
with self.assertRaises(FullException):
queue.enqueue(3)
self.as... |
8dfdd540e9043e9958118a0ff95a612bc40b5bc1 | rgjikokaj/Git_fundamentals | /python_funde1_2_3.py | 6,423 | 3.921875 | 4 | print("Hello World!")
input("'data science'")
# answer if you put data science like that without qoutes theb it will give you an error a synatx error:invalid syntax easily to remedy by adding qoutes to data science.
a = 5
if a == 5:
# 4 indented spaces to this block of code
print("a equals 5")
myString = 'hello ... |
870885cfd7f26bcf9416edb905e0251c3043f292 | facup94/project-euler | /Scripts/30.py | 544 | 3.609375 | 4 | #!/usr/bin/python
import time
def main():
cantNumeros = int(input("Cant Numeros: "))
numeros = []
n = 2
nTime = time.time()
while True:
suma = sum([int(x)**5 for x in list(str(n))])
if n == suma:
numeros.append(n)
nTime = time.time()
n += 1
... |
8eb22e9ecab169f02a9fbbfe70836432ca15e706 | koko1123/basic-algorithms | /Algorithms/search-divide-conquer/CountInversions.py | 1,273 | 3.9375 | 4 | """
Script to count inversions
using mergeSort routine in this directory as the skeleton
"""
def merge_sort(arr):
if len(arr) <= 1:
return arr, 0
half = int(len(arr) / 2)
first_sorted_half = merge_sort(arr[:half])[0]
second_sorted_half = merge_sort(arr[half:])[0]
merged_halves, z = merge(f... |
9b5b08a6ddd595cbc0c32aba42cf6907e8d79bc5 | catchmedonald/Python | /Odd or Even.py | 136 | 3.859375 | 4 | def OddEven(x):
if x%2==0:
print('The given number is even')
else:
print('The given number is Odd')
OddEven(12)
|
3cbb0a039c0254583ca745756fbed68db55bd9c6 | vishipayyallore/LearningPython_2019 | /Intermediate/Day2/practice.py | 862 | 4.15625 | 4 | """This File is used for practice the programs daily
"""
class Employee:
def __init__(self, associate):
self.associate = associate
def display_details(self):
print(f'Name: {self.associate.name} | Age: {self.associate.age}')
def __str__(self):
return f'Name: {self.associate.nam... |
0ec2a264f39990c4c2dc9b98f5723764cf29730d | wmacevoy/metabrainwallet | /memoable.py | 3,216 | 3.796875 | 4 | import copy
class Memoable:
"""
Memoable objects have a simple type/update structure. They accept memos (dictionaries) with type
restrictions to create/update themselves, and can produce a memo of themselves. Memoable objects
are connected to a database table. The TYPES dictionary defines allowed na... |
a2a21e8bde60e28772eaf4155ddbf7644084af63 | vivsiv/code | /dig_clock.py | 3,899 | 4.15625 | 4 | #!/usr/bin/python
from graphics import *
#Digital Clock Class
class DigitalClock() :
#Digital Clock Constructor
def __init__(self, hour, min, sec) :
#Store the inputted time
self._hour = hour
self._min = min
self._sec = sec
#store the time string currently drawn
... |
735b0f965f7b84456a4992ac2685d31cbec715c0 | yosoydead/exercises | /find missing element/var1.py | 490 | 3.984375 | 4 | #this is not the best solution but it gets the job done
#the down side is that i sort both arrays and i traverse the first array
#comparing values with the second array at the given indexes until i find the missing element
def bla(array1, array2):
array1.sort()
array2.sort()
for index in range(0, len(arra... |
489793e5b0522dc9cd0580466631c33c621cbc4f | longjiawei/plane | /demo/money.py | 141 | 3.609375 | 4 | money = float(input("欢迎使用电信充值业务,请输入充值金额:"))
print("充值成功,您本次充值为:" + str(money))
|
182f79a496001f38632c4b47115086d9e53fd322 | Linh-T-Pham/Games | /game3.py | 3,427 | 3.859375 | 4 | # - Create 3 separate files:
# 1) ChessPiece.py
# - Chess pieces are what I will add to the squares on the board
# - Chess pieces can move in L-shape(Knight), can move straight or diagonally
# - Chess pieces have a name and the number of squares it traverse per move
#ChessPiece.py ***********************
Color = N... |
cb5e33291a85183b0763bd5375c34a7d1cdf33df | standiki/alx-higher_level_programming | /0x01-python-if_else_loops_functions/8-uppercase.py | 195 | 4.15625 | 4 | #!/usr/bin/python3
def uppercase(str):
for ch in str:
if ord(ch) >= 97 and ord(ch) <= 122:
ch = chr(ord(ch) - 32)
print("{:s}".format(ch), end="")
print("")
|
cf0f5c9480a90b2694f438e12e07b125c455e8f9 | gsilva1108/scripting | /Python/string_check.py | 180 | 3.703125 | 4 | list = ['a1', 'b2', 'c3']
types = ['a2.large', 'b2.medium', 'c4.small']
for l in list:
if any(l in s for s in types):
print("good")
else:
print("no good")
|
ce67359d30149afc4094511796b7d1bd08b62ace | wang264/JiuZhangLintcode | /Algorithm/L5/optional/533_two-sum-closest-to-target.py | 1,812 | 3.78125 | 4 | # 533. Two Sum - Closest to target
# 中文English
# Given an array nums of n integers, find two integers in nums such that the sum is closest to a given number, target.
#
# Return the absolute value of difference between the sum of the two integers and the target.
#
# Example
# Example1
#
# Input: nums = [-1, 2, 1, -4] a... |
9945c7755eff2e087fa08847276536a2489c2221 | miguelr22/Lab-Activity-4 | /M4P3.py | 740 | 3.953125 | 4 | #This code returns some mad libs text based on the user input
#Is the code always returnin the correct input?
#What do you think I did to write this code that I shouldn't have done?
def change_name(adjective):
if adjective == 'red':
return "The quick brown fox jumps over the red dog"
elif adjective == ... |
7d3e0d37e546a44a568a73c13b80cc2bac88db8d | Ogawa1406/Ogawa1406 | /exercicio21.py | 246 | 3.65625 | 4 | nom=str(input("Digite seu nome:"))
prof=str(input("Digite sua profissão:"))
i=int(input("Digite sua idade:"))
sal=float(input("Digite seu salário:"))
print("Seu nome é",nom,"sua profissão é",prof,"sua idade é",i,"seu salário é",sal)
|
3813ba2f96640d85756d60b307f309f5ec2ce4f7 | git04112019/tic-tac-toe | /board.py | 2,903 | 3.703125 | 4 | import numpy as np
import copy
class Board(object):
'''
A board for a game of TicTacToe.
'''
def __init__(self):
self.PLAYER_1 = "O"
self.PLAYER_2 = "X"
self.BLANK = "-"
self.new_game()
def new_game(self):
'''
Resets the board.
'''
self._cur_player = self.PLAYER_1
self.... |
406931670206a5306f271c56cfb9a667f71508ee | rishavGupta0910/algos | /removeDuplicate.py | 821 | 3.703125 | 4 | class LinkeList:
def __init__(self):
self.head=None
def push(self,data):
new_node=Node(data)
new_node.next=self.head
self.head=new_node
def remove_duplicate(self):
d={}
temp=self.head
prev=None
while temp:
if temp.data in d.keys(... |
4d29c3d61857ba4a28334f404beffa4cb30295fd | tiffanyrossi/python-projects | /PythonBrasil/EstruturaDeDecisao/04-letras.py | 241 | 4.15625 | 4 | letra = input("Digite uma letra: ")
letra = (letra.upper())
if (letra == "A") or (letra == "E") or (letra == "I") or (letra == "O") or (letra == "U"):
print(f"{letra} é uma vogal.")
else:
print(f"{letra} é uma consoante.")
|
d231eb6b40aa0a55f3f15ca43ef3b02037a4dd21 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2775/60770/282099.py | 218 | 3.71875 | 4 | def solve():
n=int(input())
t=int(n/3)
if t*3==n:
print(t-1,t,t+1)
else:
print(-1)
if __name__ == '__main__' :
total=int(input())
for _ in range(total):
solve() |
3a39cc00cab55e9d9cfab7fac7b141bd3267152c | M-Jawad-Malik/Python | /Python_Fundamentals/26.Filter()_function.py | 329 | 3.921875 | 4 | def filtervowel(alpha):
v=['a','e','i','o','u']
if alpha in v:
return True
else:
return False
alpha=['a','b','c','d','e','f','g','h','i']
filtered=filter(filtervowel,alpha)
print('Vowels after filteration are: ')
for v in filtered:
print(v)
# To see more consult EX3.Filter_fun... |
b4864a78ced969e80d61ecb31acc8aa41ac920c7 | TaeKyoungKim/masanai | /sum_with_return1.py | 561 | 3.890625 | 4 | #위치인자
def get_sum(a, b): # 두 수의 합을 반환하는 함수
result = a + b
return result # return 문을 사용하여 result를 반환
# 키워드인자
def get_sum_1(a=1, b=2): # 두 수의 합을 반환하는 함수
result = a + b
return result
def get_sum_2( b,d,a=1, c=3 ):
result_1 = a + b
result_2 = c-d
return result_1 , result_2
n4 = get_sum_2(5,9,... |
1306f0ab5626e590d16af6c3d8cb7f0759aea944 | Romulandiy/OTUS_Base_Python_FromMay2021 | /homework_02/plane.py | 799 | 3.8125 | 4 | """
создайте класс `Plane`, наследник `Vehicle`
"""
from homework_02.base import Vehicle
from homework_02.exceptions import CargoOverload
class Plane(Vehicle):
cargo = 0
def __init__(self, weight, fuel, fuel_consumption, max_cargo):
super().__init__(weight, fuel, fuel_consumption)
self.max_ca... |
25cc6b258c7df1721229f11dc5d530bb771249af | fermihacker/ProjectEuler100 | /Problem074.py | 715 | 3.546875 | 4 | from math import factorial
from time import time
digit_fact_sum = lambda n : sum( factorial( int( i ) ) for i in str(n) )
def check_chain(n):
temp_list,temp_var = [n], n
count = 0
if n == digit_fact_sum(n):
return 1
while True:
temp_var = digit_fact_sum(temp_var)
temp... |
3bfd223b27689dbaa90ecb0efa695c9c20a7d23f | AlexWilliam/PythonUdemy | /excript/app-comerciais-kivy/exerciciosPraticos/exercicio2/ex13.py | 179 | 4.09375 | 4 | num1 = float(input("Digite o primeiro numero: "))
num2 = float(input("Digite o segundo numero: "))
num3 = float(input("Digite o terceiro numero: "))
print(max(num1, num2, num3)) |
45cc6f66dadebdfde7c0baf8c2a13ca9d78e69cd | SimonKocurek/Algorithms-and-Fun | /python/aoc-2017-7-bonus.py | 1,545 | 3.65625 | 4 | import sys
from collections import namedtuple, Counter
from typing import Dict
Node = namedtuple('Node', ['value', 'children'])
def load_tree() -> Dict[str, Node]:
nodes = {}
line = input()
while line != "":
name, value, *children = line.split()
nodes[name] = Node(int(value[1:-1]), ''.jo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.