blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
02c31cd5ea0008ef8b9ad81479fcaf899e8de489 | swaldtmann/python-basic | /Kontrollstrukturen/Loesungen/temperatur_umwandler.py | 731 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf8 -*-
""" author: """
print("(1) Umrechnung von Celsius nach Kelvin")
print("(2) Umrechnung von Celsius nach Fahrenheit")
wahl = input("Bitte wählen: ")
if wahl == "1":
celsius = float(input("Temperatur in Celsius: "))
if celsius >= -273.15:
kelvin = celsius + ... | false |
4e7ba243fcdbaa3a8160da84fff10b8df6efc94d | Sam-Power/samples | /LC_1470. Shuffle the Array.py | 1,203 | 4.125 | 4 | # 1470.
# Shuffle
# the
# Array
# Easy
#
# 1064
#
# 120
#
# Add
# to
# List
#
# Share
# Given
# the
# array
# nums
# consisting
# of
# 2
# n
# elements in the
# form[x1, x2, ..., xn, y1, y2, ..., yn].
#
# Return
# the
# array in the
# form[x1, y1, x2, y2, ..., xn, yn].
#
# Example
# 1:
#
# Input: nums = [2, 5, 1, 3, 4,... | false |
9167320a70295970059c9001e352d41c596812a3 | leksiam/PythonCourse | /Practice/S.Mikheev/return_maximum.py | 472 | 4.15625 | 4 | def maximum(a, b):
return a if a > b else b
# если a == b, то в любом случае будет выведено максимальное число
a = int(input('enter the first integer: '))
b = int(input('enter the second integer: '))
print('The maximum number is {}'.format(maximum(a, b)))
# можно использовать float вместо int для того,
# что... | false |
65a396b28dd09da1ad26dc0a1fad0464e41beb73 | sirdesmond09/univel | /assignment_bank.py | 2,102 | 4.1875 | 4 | class Bank():
def __init__(self, name, bal = 0):
self.name = name
self.balance = bal
def cash_deposit(self):
money = float(input("Enter amount to deposit\n> $"))
self.balance = money + self.balance
print(f"Your account has been credited with ${money}\nCurrent balanc... | true |
d90e15aed6356f01189da8b4e916adcf04ef4e84 | SajinKowserSK/algorithms-practice | /mocks/skowser_session2_question2.py | 2,451 | 4.21875 | 4 | # PSEUDOCODE
'''get letters in string
form pairs
for pair in pairs
see the string with just the pairs
check if valid string
get length of string
return highest length'''
# ANSWER
def alternate(n, string):
string = string.lower()
pairs = helper_get_pairs(string)
max = 0
for pair in pairs:
alt_... | true |
e967bebd2f37df605f28464b65f9cac1e82f5677 | SajinKowserSK/algorithms-practice | /Grokking Coding Interview/P12 - Top 'K' Elements /Frequent Sort.py | 713 | 4.125 | 4 | from heapq import *
def sort_character_by_frequency(str):
maxHeap = []
hmap = {}
for char in str:
if char in hmap:
hmap[char] += 1
else:
hmap[char] = 1
for char, freq in hmap.items():
heappush(maxHeap, (-freq, char))
res = []
while maxHeap:
... | false |
c7739593536ff819851c58af470968eb4bec5ad5 | mcsquared2/peopleSorting | /quickSort.py | 2,154 | 4.15625 | 4 | import random
from debug import *
def quickSort(lst):
# call the recursive quicksort function passing in the the first and last indecies in the list
quickSortR(lst,0,len(lst))
def quickSortR(lst, startIndex, stopIndex):
# if you are only looking at one item in the list, return
if stopIndex-startIndex... | true |
d9e594b5f898515634c5e0bdcd6815d24e7e1484 | taylynne/Python-Exercises | /guessinggame.py | 870 | 4.125 | 4 | # Practise Python
# Project Guessing Game One, exercise 9
# 8 June 2018
# I think I've done this before with the lrn 2 automate w/ python stuff,
# so it'll be good review... If I can recall exactly what I've done.
import random
def guessingGame(x):
num = random.randint(1,10)
while True:
if x == num:
print("Awe... | true |
c1c0a41a8bfa94b7d6c17dc46fcd2738d2fe1167 | bestbestb/csca08_exercises | /untitled-4.py | 1,553 | 4.21875 | 4 | def transpose(strlist):
''' (list of str) -> list of str
Return a list of m strings, where m is the length of a longest string
in strlist, if strlist is not empty, and the i-th string returned
consists of the i-th symbol from each string in strlist, but only from
strings that have an i-th symbo... | true |
afda1d805e9585341f83960345682dae2fed70d8 | JacobGT/SQLite3PythonTutorial | /whereClause.py | 799 | 4.5 | 4 | import sqlite3
# Connect to database
conn = sqlite3.connect("customers.db")
# Create a cursor
c = conn.cursor()
# Query the database (db)
# We want to fetch only certain things from the db, so we use the where function
c.execute("SELECT * FROM customers WHERE first_name LIKE 'customer%' ")
# A comparison operator us... | true |
2ef909da6d645996e79bccb50c8d3246fb52f662 | one356/spyder2020 | /base/20201126-demo.py | 1,474 | 4.34375 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:Administrator
@file:20201126-demo.py
@time:2020/11/26
"""
# 列表 list
if __name__ == '__main__':
# 第一种
lst = ['hello','world',98]
# 第二种
lst2 = list(['hello',88,'world'])
print(lst,lst2)
#列表方法
# 定位列表元素位置
print(lst.index('... | false |
1cef3a92005e6f28ebb6e86ce851b2830861d91f | fadyboy/playground | /compress_string.py | 1,037 | 4.40625 | 4 | #!/usr/bin/env python3
"""
Given an input string 'aaabbdddda', write a function such that the output becomes 'a3bbd4a'
Looking at the output, if the count of the character sequence is >= 3, the character is compressed and displayed in the
format "{character}{count}, otherwise it is displayed the number of times it appe... | true |
2f03f7a5b3d9e474b9bab430cad6cea910cbd384 | ieferreira/algorithms | /PyBetter/2021-III/01-membership_test.py | 525 | 4.3125 | 4 | # %%
# Check if a variable is contained in some multiple values
# %%
c = 2
x, y, z = 12, 2, 3
if any(i == c for i in (x, y, z)):
print("exists")
else:
print("does not exist")
# %%
# Membership test with list
if c in [x, y, z]:
print("It exists!")
else:
print("It does not exist!")
# Membership test w... | true |
f3474d35fee19a6e4a94cc0a4da661e221013ff5 | wmartin007/ATBS | /passingReference.py | 310 | 4.21875 | 4 | # To display how arguments get passed to functions as references
def eggs(someParameter):
someParameter.append('Hello')
spam = [1, 2, 3]
eggs(spam)
print(spam)
"""Notice that when eggs is called, we don't have to assign it to a new
variable and print that variable. It modifies the list in place. """ | true |
77db19955ac0c1f8461b5a38f8d71f7b8b324311 | Jovan253/Year-12-Computer-Science | /programming techniques/Basics/rock-paper-scissors (2).py | 2,015 | 4.59375 | 5 | from random import randint
print("Lets play rock paper scissors, First to Three!!!")
print("Enter 1 for rock")
print("Enter 2 for paper")
print("Enter 3 for scissors")
player_score = 0
comp_score = 0
### SRC - You typically put import statements at the top of the file
while player_score != 3 or comp_score != 3: ##... | true |
5f440aa34297949a67e99a472fad682b1ae4fe46 | NJC-Spicy-Chef/Slide-2-Conditions-and-Loops | /Guessing number Exercise 4.py | 896 | 4.125 | 4 | # Exercise - 4 Guessing numbers. Write a program that chooses an integer between 0 and 100, inclusive.
# The program prompts the user to enter a number continuously until the number matches the chosen number.
# For each user input, the program tells the user whether the input is too low or too high, so the user... | true |
875f98bf03f353130270cec93b79f455f66b97e3 | sotomaque/Python-Coding-Interview-Questions | /firstRecurring.py | 896 | 4.125 | 4 | '''
problem:
given a string of N characters, return the first recurring character in a string
input: string
output: character
solution 1:
first look at character @ index 0
see if you can find it in subsequent string
i.e. Given "DBCABA" look for 'D' in "BCABA"
run complexity: N choose(2) -> (n)(n-1)/2 -... | true |
759ad5b9fb882ed28c10a2ae2abf0bd789e152dd | sotomaque/Python-Coding-Interview-Questions | /secondLargest.py | 662 | 4.25 | 4 | '''
problem: given an array, find and return the second largest number in the array
'''
def secondLargest(givenArray):
'''ideas:
1) sort array, delete largest element, return new max
'''
if len(givenArray) == 0 or len(givenArray) == 1: return
n = [None] * (len(givenArray) - 1)
for i in range(len(givenArr... | true |
b7a89ecee230f8b2f0859ecc07e6238a1911a8a3 | kyu21/Hunter-CS-Assignments | /127/05/cipher.py | 1,037 | 4.40625 | 4 | def encode_letter(c,r):
newVal = ord(c) + r # stores shifted value of letter
if c.islower(): # determines if letter is uppercase or lowercase
if newVal > ord('z'): # if shifted value is greater than z, loop it back to a
newVal -= 26
elif newVal < ord('a'): # if shifted value is less than a, loop back to ... | true |
0568592d619ce93f94507b01c61fa69ef315a1dd | sonukrishna/Anandh_python | /chapter_6/q1_product.py | 377 | 4.25 | 4 | """ multiply 2 numbers recursively using + and - operators only. """
def product(x,y):
if y==0 or x==0:
return 0
# if abs(y)==1:
# return 1
if x<0 and y<0:
return abs(x)+product(abs(x),abs(y)-1)
elif x<0 and y>0:
return x+product(x,abs(y)-1)
elif x>0 and y<0:
return -x+product((-x),abs(y)-1)
... | true |
8a5abbd68bad7dfe6fb09d9bad7031a22a05d797 | sonukrishna/Anandh_python | /chapter_6/flatten_list.py | 254 | 4.15625 | 4 | """flatten a nested list """
def flatten(a,result=None):
if result is None:
result=[]
for x in a:
if isinstance(x,list):
print x
flatten(x,result)
else:
result.append(x)
return result
print flatten([1,[2,3,4],[5,6],7])
| true |
8802412197dee90a1ae9577d557950133d11a6cf | malav-parikh/python-for-data-science | /sequence data types.py | 2,494 | 4.34375 | 4 | # python for data science
# sequence data types
# sequence object initialization
# STRING
strSample = 'Malav'
print(strSample)
# strings are immutable i.e. they cannot be changed or altered
# LISTS
lstNumbers = [1,2,3,3,3,4,5,6]
print(lstNumbers)
# this is a list containing only numbers basically a single data typ... | true |
875117d24de1cf904a89b84e28de2beb20e514f0 | SergioBonatto/Meus | /FizzBuzz.py | 651 | 4.1875 | 4 | # Refazendo exercícios do curso de programação em Python da USP
# Projeto FizzBuzz.py
# Todo número divisivel por 3 será substituído por "Fizz"
# e todo divisível por 5 será por "Buzz"
# os que são simultaneamente divisivel por 3 e 5 serão substituídos por "FizzBuzz"
print("FizzBuzz")
numero = int(input("Digite o núm... | false |
b88dbcbb26dca5161cc5a302d4d9ff3a6589b540 | ElijahBahm/CSE | /Elijah Bahm - Guessgame.py | 840 | 4.1875 | 4 | import random
# Elijah Bahm
# Initializing Variables
number = (random.randint(1, 50))
print("Guess a number 1-50.")
guess = "0"
guesses = 0
# Describes one turn. The while loop is the Game Controller.
while int(guess) != number and guesses < 5:
guess = input("What is your guess?")
if guess == str(number):
... | true |
22fac5fbea4918dcebbfee98f0d3cea8e13e2d5b | lvah/201903python | /day04/code/20_默认参数易错点.py | 415 | 4.1875 | 4 |
# 一定要注意: 默认参数的默认值一定是不可变参数;
def listOperator(li=None):
"""
对于原有的列表后面追加元素‘End’
:return:
"""
if li is None: # is, ==
li = []
li.append('End')
return li
# print(listOperator([1, 2, 3]))
# print(listOperator([]))
# print(listOperator([]))
print(listOperator())
print(listOperator())
... | false |
a54ce191689d1e79c80e1ed9ea6b3eb22d118864 | lvah/201903python | /day06/code/05_高级特性_列表生成式.py | 1,075 | 4.1875 | 4 | """
# 1). 老办法
# 定义一个空列表,用来存储生成的数据;
import random
nums = []
# 生成100个, 循环100次
for i in range(100):
num = random.randint(1, 100)
nums.append(num)
# 2). 列表生成式快速生成的办法
nums_quick = [random.randint(1, 100) for i in range(100)]
# i=0, 3
# i=1, 39
print(nums)
print(nums_quick)
"""
# 1). 求1-50所有数的平方
square = [(i + ... | false |
819267d4c8a4d5c3e30c038695f60e6c5091a59d | lvah/201903python | /day05/code/04_计算阶乘 factorial.py | 775 | 4.1875 | 4 | def factorial(num):
"""
0! = 1
1! = 1
2! = 2 * 1 = 2 * 1!
3! = 3*2*1 = 3*2!
4! = 4*3*2*1 = 4*3!
....
n! = n * n-1 *n-2 .....1 = n * (n-1)!
求num的阶乘
"""
result = 1
for item in range(1, num + 1):
result = result * item
return result
def recursive_factorial(nu... | false |
79af56545d63c63c203281a44517bb249c87e8bd | joshlaplante/TTA-Course-Work | /Python Drills/Python Drills/drill18.py | 342 | 4.125 | 4 | def weirdSum():
numstring1 = input("Enter 1st number: ")
numstring2 = input("Enter 2nd number: ")
numstring3 = input("Enter 3rd number: ")
num1 = int(numstring1)
num2 = int(numstring2)
num3 = int(numstring3)
if num1 == num2 and num2 == num3:
print(num1*9)
else:
print(num1... | false |
ad1f5916c1aaa15b30eaf9903aea9a0e37912745 | isaac-friedman/codecademy | /python/exercise-3_area_calculator.py | 1,085 | 4.28125 | 4 | """
This program calculates the area of a various shapes.
Author: Isaac Friedman
"""
print "We're running. I'd rather not be running."
option = raw_input("What shape are we calculating for today? Enter R for rhomboid (including squares, rectangles and parrallelograms), C for Circle and T for Triangle.")
i... | true |
db18f8dd4a4f492f85c6cd618659e77d6794dfe7 | Jaideep24/Projects | /Test Generator/TestTaker (4).py | 1,232 | 4.34375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
name=input("Enter name")
osnv=input(f"Hello {name}, this test has been made to see how much you have understood your chapter, it contains objective type questions from the notes you have and have to be answered in few words, your final marks will be displayed after your... | true |
cc549dd9d3f1d9fb8f761054cbc81f3cacd4701c | rc4gh2021/capstone_evaluation | /capstone_evaluation.py | 2,778 | 4.15625 | 4 | #capstone evaluation point calculator
#small light weight python to help you avoid headache calculate your points
#All you need is python3 on you machine
#Author: Rithea
#Date: 7/27/2021
P1 = input("enter your name: ")
P2 = input("enter your first teammate name: ")
P3 = input("enter your second teammate name: ... | true |
3fbb4531198059f81e3481cc838be41889c95fc6 | thiernodiallo222/Intro-Python-I | /src/13_file_io.py | 942 | 4.25 | 4 | """
Python makes performing file I/O simple. Take a look
at how to read and write to files here:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
"""
# Open up the "foo.txt" file (which already exists) for reading
# Print all the contents of the file, then close the file
# Note: pay close... | true |
619b2500643a3219307b4436266e80684609698b | abhishekkr/tutorials_as_code | /talks-articles/machine-learning/toolbox/numpy/simple-neural-net.py | 2,559 | 4.25 | 4 | #!/usr/bin/env python3
"""
Perceptron: with no inner layers
synapse(with weight)
(Input) -----------> (Neuron) ---> (output)
x {x1w1 + ... + xNwN}
### Training Process
* take inputs from training example and put through formula to get neuron's output
* calculate error which is difference betw... | true |
7dce1847df3c226b66b05086e5ebe489f76db05f | BodaleDenis/Codewars-challenges | /find_the_divisors.py | 1,262 | 4.34375 | 4 | """
Create a function named divisors/Divisors that takes an integer n > 1 and returns an array with all of the integer's divisors
(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prime'
(null in C#) (use Either String a in Haskell and Result<Vec<u32... | true |
e01a3efafba42cb555852b0e795f673958dc7d58 | Aussiroth/cpy5python | /Practical 01/q3_miles_to_kilometre.py | 257 | 4.5 | 4 | #File Name: q3_miles_to_kilometre
#Author: Alvin Yan
#Date Created: 21/3/2013
#Date Modified: 21/1/2013
#Description: Converts miles to kilometers
miles = float(input("Input the number of miles\n"))
area2=float(miles*1.60934)
print ("{0:<.3f}".format(area2))
| true |
79b47fdd7f8c7c3e15320491e21815bd2dd2f83a | Chris-M-Wagner/Hangman | /Hangman.py | 2,475 | 4.28125 | 4 | """
Creator: Chris Wagner
Created Date: 12/03/2015
Last Updated: 12/07/2015
Summary:
Hangman is a game that prompts the user to guess a word, letter by letter.
Word entries are contained in the Hangman.txt file.
"""
import random
def Party_Time():
guessUL = 3 #The amount of guesses the user has.
tries ... | true |
4b368aa8d05310815cf6caba91d16d0d261a62bb | MarianoMartinez25/Python | /1 - primeros pasos/ejercicio1.py | 1,300 | 4.4375 | 4 | # 1) Identifica el tipo de dato (int, float, string o list) de los siguientes
# valores literales.
"Hola Mundo" #String
[10, 1, 200] #Lista de int
-30 #int
1.0 #float
["Pedro", "Jorge"] #Lista de String
# 2) Determina sin programar el resultado que aparecera en la pantalla
# a partir de las siguientes var... | false |
85922ca99399f57013fa5dc24d97d0832f5a70d1 | rajcaptainindia/Assignments | /Assignment27.py | 782 | 4.34375 | 4 | import turtle # allows us to use the turtles library
wn = turtle.Screen() # creates a graphics window
wn.setup(500,500) # set window dimension
alex = turtle.Turtle() # create a turtle named alex
alex.shape("turtle") # alex looks like a turtle
alex.color("black") # alex has a color
alex.righ... | true |
be02033434d7c261c244b24e3f4c815a28b19448 | quirogas/MTH | /homework5.py | 1,030 | 4.15625 | 4 | # Homework 5
__author__ = "Santiago Quiroga"
__version__ = "6/Oct/2017"
# This function will return a list with the number of trees per backyard.
def binarytoanalogy(list):
# local variables for value tracking.
answer_list = []
counter = 0
# Iterates though the list.
for i in list:
# Che... | true |
7db286b323af4ebf1fd1a1a9cec125d93efd72b9 | JamesonSantos/Curso-Python-Exercicios-Praticados | /ExerciciosPythonMundo2/Aula13/Ex053.py | 558 | 4.25 | 4 | '''Crie um programa que leia uma frase qualquer e diga se ela é um palindromo,
desconsiderando os espaços. Ex:
- APOS A SOPA
- A SACADA DA CASA
- A TORRE DA DERROTA
- O LOBO AMA O BOLO
- ANOTARAM A DATA DA MARATONA'''
nome = str(input('Digite uma frase: ')).strip().upper().replace(' ', '')
inverso = nome[::-1]
if nome... | false |
ab348584cd635736299af77f484e9e9e73afe6c4 | JamesonSantos/Curso-Python-Exercicios-Praticados | /ExerciciosPythonMundo2/Aula12/Ex036.py | 834 | 4.25 | 4 | '''Escreva um programa para aprovar o emprestimo bancario para a compra de uma casa.
O programa vai perguntar o valor da casa, o salario do comprador e em quantos anos ele vai pagar.
Calcule o valor da prestacao mensal, sabendo que ela nao pode exceder 30% do salario ou entao o
emprestimo sera negado.'''
valor = float(... | false |
0421a6b111788a98458752bf87f552195c7c752f | JamesonSantos/Curso-Python-Exercicios-Praticados | /ExerciciosPythonMundo2/Aula14/Ex058.py | 877 | 4.1875 | 4 | ''' Melhore o jogo do DESAFIO 028 onde o computador vai "pensar" em uma numero entre 0 e 10.
Só que agora o jogadoir vai tentar adivinhar até acertar, mostrando no final quantos
palpites foram necessários para vencer.'''
from random import randint
from time import sleep
computador = randint(0, 10) # Faz o computador "... | false |
a0577cdbd35449837a62040915886fc72529aadf | JamesonSantos/Curso-Python-Exercicios-Praticados | /ExerciciosPythonMundo2/Aula12/Ex039.py | 1,291 | 4.15625 | 4 | '''Faça um programa que leia o ano de nascimento de um jovem e informe, de acordo com sua
idade:
-Se ele ainda vai se alistar ao serviço militar.
-Se é a hora de se alistar.
-Se já passou do tempo do alistamento.
Seu programa também deverá mostrar o tempo que falta ou que passou do prazo.'''
from datetime import date
a... | false |
4ec500ea5dadf0a43370063d0df3e1e46d94c112 | JamesonSantos/Curso-Python-Exercicios-Praticados | /ExerciciosPythonMundo2/Aula12/Ex044.py | 1,479 | 4.125 | 4 | '''Elabore um programa que calcule o valor a ser pago por um produto, considerando o seu:
preço normal e condições de pagamento.
-À vista dinheiro/cheque: 10% de desconto.
-À vista no cartão: 5% de desconto.
-Em até 2x no cartão: Preço normal.
-3x ou mais no cartão: 20% de juros'''
print('{:=^40}'.format(' LOJAS CHINES... | false |
afd7884ce39fa87c6ec614af7e050eb270ffa403 | geekslayer/python-udemy-blackjack | /game/deck.py | 1,611 | 4.125 | 4 | """
This deck object is at the middle of all
this and is a crucial part of the game.
"""
from random import shuffle
from game.card import Card, Suit
class Deck():
"""
This will hold 52 cards like a regular deck of cards.
One by one we will remove the cards from the deck until no more.
"... | true |
b23dc837b4a45412474a9eaa5a8c1793a8a06237 | VGallardo93/lerning_github | /Test.py | 854 | 4.4375 | 4 | # This is a test file in Python 3
print('Welcome to the new file... By vg.\n')
name_ = input('Hi. Insert your name: ')
while True:
if name_.isdigit():
print('\nInvalid name. Please try again.')
name_ = input('Insert your name: ')
continue
else:
print(f'\nHi {name_}! Nice to meet you.\n')
bre... | true |
c51d113ee49a6c1218de39f3a9affa41761f502f | liang1024/CrawlerDemo | /Python面试题/1.Python语言的特性——30例/3.@staticmethod和@classmethod.py | 1,431 | 4.21875 | 4 | # coding=utf-8
'''
3 @staticmethod和@classmethod
参考:
http://stackoverflow.com/questions/136097/what-is-the-difference-between-staticmethod-and-classmethod-in-python
Python其实有3个方法,即静态方法(staticmethod),类方法(classmethod)和实例方法,如下:
'''
def foo(x):
print "executing foo(%s)"%(x)
class A(object):
def foo(self,x):
... | false |
754b12d78bfb0cf9a8774f06c78bdad65b0f7e49 | mohithasan/mathematician | /mathematician.py | 1,755 | 4.25 | 4 |
#Welcome to mathematician.py
#Developers are Working on the file to improve the file more.
#View the terms of uses befor you start using this Module on your work.
#-----------------------------------------------------------------------
#The code starts here-
#To add nmbers, make list of the numbers and call the ... | true |
de931e528976d638c99dcad2f91babbc77518fda | jurrehageman/Informatica-1 | /Website/informatics1/seminars/solutions02/seminar2_solution/05_solution.py | 1,117 | 4.625 | 5 | # solution for excersize 05 from lecture1
# define a sequence and assign it to a variable
#seq = "ATGAGTAGGATAGGCTAGATGGCGATGAATT"
seq = "UCAUUAUCAGACGGCAGUUUAUUAUAUAUAU"
# convert to upper case:
seq_up = seq.upper()
# Always check variables by printing them to screen!
print("original sequence:", seq_up)
# check if ... | true |
a7ac8fc5a9f9225339b04e2806d5d4d4484f8582 | phqlong/Internship-Odoo | /Python-Exercise/iterator.py | 1,488 | 4.625 | 5 | # Iterable is an object, which one can iterate over. It generates an Iterator when passed to iter() method.
# Iterator is an object, which is used to iterate over an iterable object using __next__() method.
# Iterators have __next__() method, which returns the next item of the object.
# Note that every iterator is a... | true |
b60d519421c8f9d6bba79eee1a30385f5a41fa82 | ksr19/python_basics | /L3/4.py | 1,019 | 4.1875 | 4 | def my_func(x, y):
"""Возведение числа x в отрицательную степень y.
:param x: действительное положительное число
:param y: целое отрицательное число
:return:
"""
if x <= 0:
print("Основание степени должно быть положительным!")
else:
if y >= 0:
print("Степень до... | false |
8d5fa9ede1449711ea7213452274abe6b73a5af2 | slerpy/ilikepy | /part2/2.02-99problems.py | 2,266 | 4.375 | 4 | ###
# a procedure to add one day to a calendar, assuming all months are 30 days.
# a test run into building a full calendar.
###
###
# commenting out since we have a better method below.
###
# def nextDayMeh(year, month, day):
# if day == 30:
# day = 1
# if month == 12:
# month = 1
# ... | true |
393461a838e4e9e65c597e4e6df2d3845b5f1eff | CallumBrown/Assignment | /development exercise 3.py | 399 | 4.15625 | 4 | #Callum Brown
#16-09-14
#Exercise - Development 3
height_inches = float(input("Please enter your height in inches: "))
weight_stones = float(input("Please enter your weight in stones: "))
height_cm = (height_inches)*2.54
weight_kg = (weight_stones)*6.364
print("Your height in centremetres is: {0}".format(h... | true |
da215def7f73a10a97be2578231883a4c1292997 | Denimbeard/PycharmProjects | /Programs/Finite State Acceptors/ExampleSolution | 2,638 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This programs implements an FSA. It keeps track of the current FSA's state
# in a variable called "STATE". The algorithm traverses the given string and,
# depending on the current character, decides what the next state will be.
# The INITIAL state is S1, and the ONLY rec... | true |
9358e9544ef6fbf7bf12fbd828620b6a1481e79e | anishdhandore/Basic-operational-calculator | /Calculator.py | 1,162 | 4.15625 | 4 |
def calculate():
n1 = float(input("First number : "))
n2 = str(input("Operation : "))
n3 = float(input("Second number : "))
signs = ["+", "-", "*", "/"]
if signs[0] in n2:
print("\n")
print(n1)
print(n2+str(n3))
print("----------")
print(n1+n3)... | false |
08d0f5f3424b83750b1b35187df6ba8e653d0757 | jatinsinghnp/python-3-0-to-master-course | /2_stringformatting/code.py | 427 | 4.21875 | 4 | #f' string string formatting in python
#
name ="Bob"
greeting =f"hellow ,{name}"
print(greeting)
print(greeting)
# creating template
name="bob"
greeting="hloow,{}"
with_name=greeting.format()
with_name=greeting.format("nikhil")
with_name=greeting.format("jatin")
print(with_name)
# also kin a make long ... | true |
a1e8aefa37ec4814d1e95cd1d77d0a67f2614039 | nisabzahid/Analytics | /Programming/Python/Exercises-Basic/Basics/DateDiff.py | 583 | 4.21875 | 4 | '''Write a Python program to calculate number of days between two dates.
Sample dates : (2014, 7, 2), (2014, 7, 11)
Expected output : 9 days '''
import datetime
d1=int(input("Please enter the day of first date : "))
m1=int(input("Please enter the month of first date : "))
y1=int(input("Please enter the year of first ... | true |
e445a2d8823f76b4f6ea02661d7fa1b8a56e86eb | pogromcykodu/PogromcyPythona | /struktury_danych/listy/Zadanie2_Stacja_metorologiczna 💡/rozwiazanie.py | 1,516 | 4.40625 | 4 | """
Pracujesz w stacji meteorologicznej i dostałeś właśnie nowe zadanie.
Przed Tobą lista wahań temperatury z ostatniego tygodnia:
1.5, 3, 2, 0, -1 , 1.9, 0.1
Twoim zadaniem jest podanie następujących informacji:
a) najwyższa zanotowana temperatua
b) najniższa zanotowana temperatura
c) średnia temperatura
d) posortow... | false |
a752ed3288e1fadce812db8c219a4052ff0f0f3d | mchao409/python-algorithms | /algorithms/search/fibonacci_modulo.py | 1,329 | 4.46875 | 4 | """
Calculating (n-th Fibonacci number) mod m
"""
def _fib(number):
"""
Fibonacci number
Args:
number: number of sequence
Returns:
array of numbers
"""
init_array = [0, 1]
for idx in range(2, number + 1):
init_array.append(init_array[idx - 1] + init_array[idx - 2... | true |
d3c97bbecbae737716e1b0a84d38968f2db76c69 | aniaHrrera4/Python-Projects | /Python_Projects/ScavHunt1.py | 2,651 | 4.15625 | 4 | """
Pygame base template for opening a window
Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/
Explanation video: http://youtu.be/vRB_983kUMc
"""
import pygame
import random
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 2... | true |
f14ca98b0da2469335781ab0179e854ae0789565 | BenGilbert98/Python_Week_1 | /data_types_&_operators.py | 558 | 4.15625 | 4 | # What are data types and Operators
# Boolean gives us the outcome in True or False
# a = True
# b = False
#
# print(a == b) #False
# print(a != b) #True
# print(a >= b) #False
greetings = "Hello World!"
print(greetings.isalpha())
# Checks if letters in the string are letters
# How can we check if the string is low... | true |
329dcb06d8525d79fa27b0252b49d9395e98c4ff | tdnam/learncode | /Practice/CrackingAlgo/ArraysAndStrings/StringCompression.py | 1,053 | 4.75 | 5 | #!/usr/bin/env python3
# String Compression: Implement a method to perform basic string compression using the
# counts of repeated characters.
# For example, the string aabcccccaaa would become a2b1c5a3.
# If the "compressed" string would not become smaller than the original string,
# your method should return the or... | true |
9956cb6b7d201af6f796c95f2832a568115ba51e | ashcoder2020/Python-Practice-Code | /simple find factorial.py | 229 | 4.34375 | 4 | num=int(input("Enter a number which you want to find factorial : "))
fact=1
if num==0 or num==1:
print("Factorial is 1")
else:
for i in range(1,num+1):
fact=fact*i
print(f"factorial of {num} is {fact}") | true |
0d33a1a9223b7cdba089a38e43bf4a5c8df23c82 | HanYinnn/cp2019 | /p01/q1_fahreheit_to_celsius.py | 566 | 4.53125 | 5 | #Write a program q1_fahrenheit_to_celsius.py that reads a Fahrenheit degree in double (floating point / decimal) from standard input,
#then converts it to Celsius and displays the result in standard output.
#The formula for the conversion is as follows: celsius = (5/9) * (fahrenheit - 32)
#get input
Fahrenheit = int... | true |
35b70bf6ea050eae00e5784037e0d948d4ea29c4 | sadjunky/brainstorm | /queue/linkedlist.py | 885 | 4.15625 | 4 | # Queue using Linked List with front and rear pointers
class Node:
def __init__(self, data):
self.data = data
self.next = None
class Queue:
def __init__(self):
self.front = self.rear = None
def isEmpty(self):
return self.front == None
def enqueue(self, data):
... | false |
793d4b2846da7fa419afc67de85881accc271533 | aekempster/Pyber | /03-Python/3/Activities/Solved/05-Ins_List_comprehensions/comprehensions.py | 1,458 | 4.53125 | 5 | # -*- coding: UTF-8 -*-
"""Comprehensions"""
price_strings = ["24", "13", "16000", "1400"]
price_nums = [int(price) for price in price_strings]
fish = "halibut"
# Comprehensions give handles on each element of a collection
letters = [letter for letter in fish]
print(f"We iterate over a string, containing the world:... | true |
387a706a602f18376859886ddd974451360b1ef7 | izham-sugita/python3-tutorial | /python-container.py | 1,340 | 4.5625 | 5 | #List
xs = [3, 1, 2] # Create a list
print(xs, xs[2]) # Prints "[3, 1, 2] 2"
print(xs[-1]) # Negative indices count from the end of the list; prints "2"
xs[2] = 'foo' # Lists can contain elements of different types
print(xs) # Prints "[3, 1, 'foo']"
xs.append('bar') # Add a new element to the end o... | true |
738b0632eb0b8c29304b49fa612e38e5592bc3e8 | anishcr/iNeuron-Assignments | /MLD6thJune/Assignments/Python-Assignment-3/reduce_filter.py | 1,102 | 4.1875 | 4 | # 1.1 Write a Python Program to implement your own myreduce() function which works exactly
# like Python's built-in function reduce()
#
# 1.2 Write a Python program to implement your own myfilter() function which works exactly
# like Python's built-in function filter()
def myreduce(function, iterable, initiali... | true |
a7381d3830c02a342cb3588b14fa54b5e26d0b11 | insigh/Leetcode | /August_18/71. Simplify Path.py | 951 | 4.21875 | 4 | """
Given an absolute path for a file (Unix-style), simplify it.
For example,
path = "/home/", => "/home"
path = "/a/./b/../../c/", => "/c"
Corner Cases:
Did you consider the case where path = "/../"?
In this case, you should return "/".
Another corner case is the path might contain multiple slashes '/' together, su... | true |
ee955e71739318be9a4504d560b5ff9bf57dcd4b | UnKn0wn27/PyhonLearning-3.6.1 | /study14.py | 529 | 4.125 | 4 | def while_function():
i = 0
n = 9
numbers = []
while i < n:
print(f"At the top i is {i}")
numbers.append(i)
m = int(input("Nr > "))
i += m
print("Numbers now: ", numbers)
print("At the bottom i is {i}")
while_function()
def for_function():
numbers... | false |
58db5a0d25109bd5b5466b9cc5bb63bf8193ceb6 | Fbabsail/Learning-Python | /17.py | 533 | 4.125 | 4 |
#total faliure
command=input()
while command.upper() != 'QUIT':
if command.upper() == 'START':
print('Car started...')
elif command.upper() == 'STOP':
print('Car stopped.')
elif command.upper() == 'EXIT':
break
elif command.upper() == 'HELP':
print('Start - to start th... | true |
288f144096eb930c31c998beecc3fbb256ca68ae | Fbabsail/Learning-Python | /13.py | 245 | 4.40625 | 4 | Name=input("What's your name")
name_length=(len(Name))
if name_length<3:
print("Name must be at least 3 characters")
elif name_length>50:
print('Name can be a maximum of 25 characters')
else:
print('Name looks good')
| true |
c1219edb00ff71005e07698261215ca4b7dfba8f | hahahayden/CPE202 | /LAB1/Lab1.py | 793 | 4.25 | 4 | # Name:
# Section:
# must use iteration not recursion
def max_list_iter(tlist):
""" finds the max of a list of numbers and returns it, not the index"""
if (len(tlist) == 0):
raise ValueError('empty list')
""" finds the max of a list of numbers and returns it, not the index"""
elif (len(t... | true |
7aa9ed2f2be8cbf8d57491a366959ff5a08dd2ff | Meitsuki/testing | /python/miniProjects/diceRoll/diceRollSimulation.py | 1,415 | 4.375 | 4 | import dice
print("Welcome to the dice roll simulator program!")
validPrompt = False
while not validPrompt:
numDice = input("To get started, how many dice would you like to roll? ")
validInt = False
try:
numDice = int(numDice) + 0
validInt = True
except TypeError:
validInt = Fa... | true |
a8f5012bd3ed767a604d39d99d90201f275bf7c1 | 666syh/python_cookbook | /python_cookbook/1_data_structure_and_algorithm/1.11_命名切片.py | 612 | 4.125 | 4 | """
问题
你的程序已经出现一大堆已无法直视的硬编码切片下标,然后你想清理下代码。
"""
record = '....................100 .......513.25 ..........'
cost = int(record[20:23]) * float(record[31:37])
print(cost)
# 51325.0
# modify
SHARE = slice(20, 23)
PRICE = slice(31, 37)
cost = int(record[SHARE]) * float(record[PRICE])
print(cost)
# 51325.0
items = [0,1,2,... | false |
1b914b3aec24619f31d76e53b6c211fb810ec187 | patricelliG/hacker_rank | /python/classes/complex_numbers.py | 2,586 | 4.3125 | 4 | #!/bin/python
import math
# this script defines a class for imaginary numbers
# it can operate on two numbers with +,-,*,/
# it can also mod a single imaginary number
# INPUT: Two lines with two integers each
# 2 1
# 5 6
# so the first number is 2+1i and the second is 5+6i
# The program then outputs the numbers afte... | true |
00c1d5a513bf66ae0701f7b26dd57aa0cc7bc117 | CarltonK/PythonScripts | /Fizz Buzz/fizz_buzz.py | 302 | 4.28125 | 4 | def fizz_buzz(number):
number = int(number)
if number%3 == 0 and number%5 == 0:
print('FizzBuzz')
elif number%3 == 0:
print('Fizz')
elif number%5 == 0:
print('Buzz')
else:
print('This number is not divisible by either 3 or 5')
user_value = input('Enter a number: ')
fizz_buzz(user_value) | true |
4108a8843bc66211c7bd44bb701a16d8fe102a65 | CarltonK/PythonScripts | /Fibonacci Sequence/fibonacci_sequence.py | 547 | 4.53125 | 5 | def fibonacci_generator(number):
number = int(number)
num1 = 0
num2 = 1
num_count = 1
fib_list = [num2]
while num_count < number:
num_total = num1 + num2
#Switch second value to first value
num1 = num2
#Switch total value to second value
num2 = num_to... | true |
5bb0105cb178fa40a33feab048492a8599797b8f | yalothman97/Python | /functions_task.py | 703 | 4.1875 | 4 | def check_birthdate(year, month, day):
from datetime import date
if year > date.today().year and month > date.today().month and day > date.today().day:
return False
else:
return True
def calculate_age(year, month, day):
from datetime import date
calc_year = date.today().year - year
calc_month = date.today().... | true |
20d3080e9ede4e7070fc02d26049e795fc9a03fe | pulkitpahwa/Python-practice | /count_vowels.py | 1,181 | 4.21875 | 4 | # !usr/bin/python
import fileinput
def main():
print "This program will count the number of vowels in a string or in a file."
print "Press 1 if you want to enter a string. "
print "Press 2 if you want to open a file. "
a=raw_input("Enter your choice > ")
# 2 cases are possible according to the choice of user... | true |
a5a5b74a995c3f7393f8077b55a248693e9cefb5 | Ryanwolff14/validemail | /email.py | 281 | 4.28125 | 4 | import re
def validemail():
email= userInput = input("please enter an email: ");
match= re.search(r'[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+.[a-zA-Z]',email)
if match:
print("Valid Email")
else:
print("Invalid Email")
validemail() | false |
91942c8e37b9b847ecd5dffe41be3c53ee1e944c | nhouston/Ice-Core-Analysis | /ImageAnalysis.nosync/sliceImage.py | 1,231 | 4.125 | 4 | from PIL import Image
import os
import math
"""
image_slice is a function that is used to take the input image that the user defines
and split the image. The function takes the image and splits the image vertically
by 1500 pixels.
"""
def image_slice(image_path, outdir):
Image.MAX_IMAGE_PIXELS = None # Set the max... | true |
a8606407b754328ea7574e919ed6547853838709 | nwthomas/code-challenges | /src/codewars/7-kyu/least-larger/least_larger.py | 874 | 4.28125 | 4 | """
Task
Given an array of numbers and an index, return the index of the least number larger than the element at the given index, or -1 if there is no such index ( or, where applicable, Nothing or a similarly empty value ).
Notes
Multiple correct answers may be possible. In this case, return any one of them.
The given... | true |
17531a8d026adbf09e0c5262bfa6d097e21ad68e | nwthomas/code-challenges | /src/interview-cake/cake-thief/cake_thief.py | 1,914 | 4.25 | 4 | """
You are a renowned thief who has recently switched from stealing precious metals to stealing cakes because of the insane profit margins. You end up hitting the jackpot, breaking into the world's largest privately owned stock of cakes—the vault of the Queen of England.
While Queen Elizabeth has a limited number of ... | true |
27354066da9bace6280e4c7b6ff9864351c5f97b | nwthomas/code-challenges | /src/hacker-rank/medium/frequency-queries/frequency_queries.py | 2,475 | 4.3125 | 4 | """
You are given q queries. Each query is of the form two integers described below:
- 1:x Insert x in your data structure.
- 2:y Delete one occurence of y from your data structure, if present.
- 3:z Check if any integer is present whose frequency is exactly z. If yes, print 1 else 0.
The queries are given in the form... | true |
bd4b61c1dac3f7071e74c11b2ffa413e8d1e0dac | nwthomas/code-challenges | /src/daily-coding-problem/medium/time-map/time_map.py | 2,090 | 4.1875 | 4 | """
Good morning! Here's your coding interview problem for today.
This problem was asked by Stripe.
Write a map implementation with a get function that lets you retrieve the value of a key at a particular time.
It should contain the following methods:
set(key, value, time): sets key to value for t = time.
get(key, ... | true |
707c872f0d67bf4c04a063be36efbe496b3ef538 | nwthomas/code-challenges | /src/interview-cake/inflight-entertainment/inflight_entertainment.py | 1,538 | 4.46875 | 4 | """"
You've built an inflight entertainment system with on-demand movie streaming.
Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane usually lands before they can see the ending. So you're building a feature for choosing two movies whose total runtim... | true |
ddbde3d2dec3cf2c347a023d349475221443862d | nwthomas/code-challenges | /src/miscellaneous-code-challenges/stock-prices/stock_prices.py | 2,079 | 4.4375 | 4 | """
You want to write a bot that will automate the task of day-trading for you while you're going through Lambda. You decide to have your bot just focus on buying and selling Amazon stock.
Write a function `find_max_profit` that receives as input a list of stock prices. Your function should return the maximum profit t... | true |
3f19fa1bfb89903e80c56d69db765d3d02b63e59 | nwthomas/code-challenges | /src/leetcode/medium/daily-temperatures/daily_temperatures.py | 1,068 | 4.28125 | 4 | """
https://leetcode.com/problems/daily-temperatures
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep ans... | true |
66bbe03dbe57f996d3811e6eca4b290971c24039 | nwthomas/code-challenges | /src/leetcode/medium/word-search/word_search.py | 2,728 | 4.125 | 4 | """
https://leetcode.com/problems/word-search/
Given an m x n grid of characters board and a string word, return true if word exists in the grid.
The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be us... | true |
e33b5c0c12775a3991cbdb1c8cefe4b3c039a780 | nwthomas/code-challenges | /src/daily-coding-problem/medium/peekable-iterator/peekable_iterator.py | 2,532 | 4.28125 | 4 | """
Good morning! Here's your coding interview problem for today.
This problem was asked by Google.
Given an iterator with methods next() and hasNext(), create a wrapper iterator, PeekableInterface,
which also implements peek(). Peek shows the next element that would be returned on next().
Here is the interface:
cl... | true |
819373032f5ed9094e6d42a87c671f643dc9625f | nwthomas/code-challenges | /src/hacker-rank/hard/array-manipulation/array_manipulation.py | 1,634 | 4.3125 | 4 | """
Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array.
Example
n = 10
queries = [[1, 5, 3], [4, 8, 7], [6, 9, 1]]
Queries are i... | true |
8dcef8821671cead1528c3c36be66ad47cc45daa | nwthomas/code-challenges | /src/interview-cake/merge-sorted-lists/merge_sorted_lists.py | 1,581 | 4.28125 | 4 | """
In order to win the prize for most cookies sold, my friend Alice and I are going to merge our Girl Scout Cookies orders and enter as one unit.
Each order is represented by an "order id" (an integer).
We have our lists of orders sorted numerically already, in lists. Write a function to merge our lists of orders in... | true |
b866fa71fb76291c15d35103c1225afe11513b64 | nwthomas/code-challenges | /src/daily-coding-problem/easy/find-most-valuable-path/find_most_weighted_path.py | 1,499 | 4.25 | 4 | """
Good morning! Here's your coding interview problem for today.
This problem was asked by Google.
You are given an array of arrays of integers, where each array corresponds to a row in a triangle of numbers. For example, [[1], [2, 3], [1, 5, 1]] represents the triangle:
1
2 3
1 5 1
We define a path in the trian... | true |
1b1f9ff84258b71e0f4bd0f672d1683a83997705 | nwthomas/code-challenges | /src/leetcode/medium/maximum-product-subarray/maximum_product_subarray.py | 1,295 | 4.125 | 4 | """
https://leetcode.com/problems/maximum-product-subarray
Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product.
The test cases are generated so that the answer will fit in a 32-bit integer.
A subarray is a contiguous subsequence of t... | true |
a86cf51fd9e36f81a440708fe156aaa862121643 | nwthomas/code-challenges | /src/hacker-rank/easy/bubble-sort/bubble_sort.py | 1,468 | 4.3125 | 4 | """
Consider the following version of Bubble Sort:
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - 1; j++) {
// Swap adjacent elements if they are in decreasing order
if (a[j] > a[j + 1]) {
swap(a[j], a[j + 1]);
}
}
}
Given an array of integers, sort the arr... | true |
e611c91fdc57a31f9f64a9bfc4e9467478830730 | nwthomas/code-challenges | /src/interview-cake/highest-multiple-of-integers/highest_multiple_of_integers.py | 1,337 | 4.59375 | 5 | """
Given a list of integers, find the highest product you can get from three of the integers.
The input list_of_ints will always have at least three integers.
"""
def find_highest_multiple_of_three_ints(int_list):
"""Takes in a list of integers and finds the highest multiple of three of them"""
if type(int_... | true |
f5ff60b1380f794c8d19dc465f6e890e8f25becd | Avisikta-Majumdar/Campus-Placement-Coding-Question-And-Answers | /Accenture/FindCount.py | 716 | 4.3125 | 4 | #Question
'''You are given a function FindCount
The function accpets an int array 'arr'
The function will return the no of elements of 'arr' having absolute difference
of less than or equal to 'diff' with ' num'''
#Input:-
'''arr: 12 3 14 56 77 13
num:12
diff:2
'''
#Output : -
# 3
def FindCount(ar... | true |
092b662940b04da299d3bfa5a4acf9c1f2b41042 | Avisikta-Majumdar/Campus-Placement-Coding-Question-And-Answers | /TCS NQT Coding Questions and Answers/Check Palindrome.py | 241 | 4.25 | 4 | '''
Write a Python program to
check whether the given number is Palindrome or not using command line arguments.
'''
def PalinDrome(n):
return n==n[::-1]
for i in range(int(input("Test case:-"))):
print(PalinDrome(input()))
| true |
809196d5563f89ac9dd9a1be28dc4480b850017d | aarthymurugappan101/loops | /pract4_q2.py | 210 | 4.15625 | 4 |
total = 0
count = 0
while count < 5:
usrInput = int(input("Your number please"))
total += usrInput
count += 1 # to add so that it will not become an infinite loop
print("While: Total sum is",total) | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.