blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
e42d4f49f2f0cc19432a798ebacfd1c1a4ca76b0 | aronminn/max-int | /max_int.py | 463 | 4.15625 | 4 |
num_int = int(input("Input a number: ")) # Do not change this line
# Fill in the missing code
# Ef num int er stærri heldur en seinasta tala þá geymum við hana.
# Þegar num int er ekki negative þá hættum við að spurja um input og prentum stærstu töluna.
max_int = 0
while num_int > 0:
if num_int > max_int:
... | false |
bdabcfa9637cae527536ec5494d73f5191afe09c | itsvinayak/labs | /python_algo_lab/insertion_sort.py | 347 | 4.25 | 4 | def insertion_sort(array):
for i in range(len(array)):
cursor = array[i]
pos = i
while pos > 0 and array[pos - 1] > cursor:
array[pos] = array[pos - 1]
pos = pos - 1
array[pos] = cursor
return array
if __name__ == "__main__":
print(insertion_sort(... | false |
eac8dadba99e51df25d45a2a66659bdeb62ec473 | whung1/PythonExercises | /fibonacci.py | 1,570 | 4.1875 | 4 | # Need to increase recursion limit even when memoization is used if n is too large
# e.g. sys.setrecursionlimit(100000)
def fibonacci_recursive_memo(n, fib_cache={0: 0, 1: 1}):
"""Top-down implementation (recursive) with memoization, O(n^2)"""
if n < 0:
return -1
if n not in fib_cache:
f... | true |
93ef926c3ebafaf36e991d7d381f9b189e70bfea | whung1/PythonExercises | /Leetcode/Algorithms/453_minimum_moves_to_equal_array_elements.py | 1,424 | 4.15625 | 4 | """
https://leetcode.com/problems/minimum-moves-to-equal-array-elements
Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.
Example:
Input:
[1,2,3]
Output:
3
Explanation:... | true |
0fe354cb21928d0aebc186e074b6483b8aa2d00b | trinadasgupta/BASIC-PROGRAMS-OF-PYTHON | /diamond using numbers.py | 841 | 4.3125 | 4 | # Python3 program to print diamond pattern
def display(n):
# sp stands for space
# st stands for number
sp = n // 2
st = 1
# Outer for loop for number of lines
for i in range(1, n + 1):
# Inner for loop for printing space
for j in range(1, sp + 1):
print (" ", end = ' ')
#... | true |
be4656e837e37f53b06ba2ab89701926afcaa8e1 | dejikadri/comprehensions | /dict_comp.py | 410 | 4.25 | 4 | """
This program uses a dictionary comprehension to turn 2 lists of countries and captials
into a dictionary with countries as keys and the capitals as values
"""
list_country = ['Nigeria', 'Ghana', 'Cameroun', 'Togo', 'Egypt', 'Kenya']
list_capital = ['Abuja', 'Akra','Yaunde', 'Lome', 'Cairo', 'Nairobi']
def countr... | false |
59a2c8d4cd1e6c619d8906546af9bc25bb6e6141 | fominykhgreg/Python-DZ4 | /dz4.6.py | 1,476 | 4.21875 | 4 | """
Реализовать два небольших скрипта:
а) итератор, генерирующий целые числа, начиная с указанного,
б) итератор, повторяющий элементы некоторого списка, определенного заранее.
Подсказка: использовать функцию count() и cycle() модуля itertools. Обратите внимание,
что создаваемый цикл не должен быть бесконечным.
Не... | false |
a74e1b0117319af55c10e7c7952a07228664481b | S-EmreCat/GlobalAIHubPythonHomework | /HomeWork2.py | 500 | 4.125 | 4 | # -*- coding: utf-8 -*-
first_name=input("Please enter your FirstName: ")
last_name=input("Please enter your last name: ")
age=int(input("Please enter your age: "))
date_of_birth=int(input("Please enter date of birth year: "))
User_Info=[first_name,last_name,age,date_of_birth]
if User_Info[2]<18:
print("You cant ... | true |
33cd38c311bb5dba896c277d08500cac2c435e38 | wmaterna/Python-Zestawy | /Zestaw3/zadanie3.6.py | 505 | 4.125 | 4 | x = input("Enter length: ")
y = input("Enter hight: ")
horizontal = '+---'
wholeString = ''
for i in range(0,int(y)):
for i in range(0, int(x)):
wholeString = wholeString + horizontal
wholeString = wholeString + '+' + '\n'
for i in range(0, int(x)):
wholeString = wholeString + '|' + ''.ljus... | false |
004d7e7459f43bf5ac8f37d56342df192e1a862e | Susaposa/Homwork_game- | /solutions/2_functions.py | 1,202 | 4.125 | 4 | # REMINDER: Only do one challenge at a time! Save and test after every one.
print('Challenge 1 -------------')
# Challenge 1:
# Write the code to "invoke" the function named challenge_1
def challenge_1():
print('Hello Functional World!')
challenge_1()
print('Challenge 2 -------------')
# Challenge 3:
# Uncommen... | true |
4513babc8ea339c4ba1b9d02fe360b9ad431cb3a | kszabova/lyrics-analysis | /lyrics_analysis/song.py | 939 | 4.34375 | 4 | class Song:
"""
Object containing the data about a single song.
"""
def __init__(self,
lyrics,
genre,
artist,
title):
self._lyrics = lyrics
self._genre = genre
self._artist = artist
self._title = title
... | true |
eafd2e749b9261a9c78f78e6459846a19094a786 | VedantK2007/Turtle-Events | /main.py | 2,842 | 4.34375 | 4 | print("In this project, there are 4 different patterns which can be drawn, and all can be drawn by the click of one key on a keyboard. If you press the 'a' key on your keyboard, a white pattern consisting of triangles will be drawn. Or, if you press the 'b' key on your keyboard, an orange pattern consisting of squares ... | true |
1f7713bf7c0b3b7a20a8071ba8e388c53ba12cca | Pu-Blic/PruebasPython | /Strings.py | 928 | 4.1875 | 4 | myStr ="hola oJEtes"
#print(dir(myStr))
print(myStr.upper())
print(myStr.title())
print(myStr.swapcase())
print(myStr.capitalize())
print(myStr.replace("o","0"))
oes= myStr.count("o")
print (oes)
print("El texto tiene" , oes , "oes")
print(myStr.split()) #Por defecto Lo separa usando los caracteres en blanco
myA... | false |
d0fa02395a310d16e0bdc650420396fb01f83509 | Pallmal111/Pythonkurs1 | /hw_1_1.py | 1,542 | 4.15625 | 4 | # Задача №1
# filename: hw_1_1.py
#
# Запросить у пользователя имя и фамилию.
# Поприветсвовать пользователя с использованием его имени и фамилии.
# Запросить День даты рождения (цело число).
# Запросить Месяц даты рождения (цело число).
# Запросить Год даты рождения (цело число).
# Вывести количество прожитых ... | false |
5eb61a6e224d6a447c211b2561f8fa07b1864c38 | lyh71709/03_Rock_Paper_Scissors | /03_RPS_comparisons.py | 1,742 | 4.1875 | 4 | # RPS Component 3 - Compare the user's action to the computer's randomly generated action and see if the user won or not
valid = False
action = ["Rock", "Paper", "Scissors"]
while valid == False:
chosen_action = input("What are you going to do (Rock/Paper/Scissors)? ").lower()
cpu_action = "rock"
# Rock ... | true |
ced55ee757f946247dfa6712bd1357c303fbc8e1 | jayanta-banik/prep | /python/queuestack.py | 703 | 4.125 | 4 | import Queue
'''
# Using Array to form a QUEUE
>>> from collections import deque
>>> queue = deque(["Eric", "John", "Michael"])
>>> queue.append("Terry") # Terry arrives
>>> queue.append("Graham") # Graham arrives
>>> queue.popleft() # The first to arrive now leaves
'Eric'
>>> queue.... | true |
5bce167313c249ba3ae12cb62787711b2d42d07c | dsrlabs/PCC | /CH 5/5_1_ConditionalTests.py | 775 | 4.34375 | 4 | print()
color = 'black' #The color black is assigned to variable named color
print("Is color == 'black'? I predict True.") #Here, the equality sign is used to determine if the value on each side of the operator matches.
print(color == 'black') #Here the result of the equality prediction is printed
print("\nIs color =... | true |
1228d627795969c4325f56aec74d589468da8e51 | dsrlabs/PCC | /CH 8/8_8_UserAlbum.py | 615 | 4.15625 | 4 | print()
def make_album(artist_name, album_title):
"""Return a dictionary with the album information"""
album_info = {'artist_name' : artist_name.title(), 'album' : album_title.title()}
return album_info
print("\nPlease enter the artist name:")
print("Please enter the album title:")
print("[enter 'q' at any... | true |
1d86f145ce68ca28fb615b990f72b4ddde489415 | dsrlabs/PCC | /CH 8/8_7_album.py | 540 | 4.1875 | 4 | # Thus block of code calls a function using a default
# an f-string is used.
print()
def make_album(name, album_title, tracks =''):
"""Return a dictionary with the album information"""
album_info = {'artist_name' : name.title(), 'album' : album_title.title()}
if tracks:
album_info['tracks'] = tracks... | true |
3d177f31578123ad01d5733c178fbd81d89adcdd | PMiskew/Coding_Activities_Python | /Activity 1 - Console Activity/ConsoleFormulaStage1.py | 621 | 4.625 | 5 | #In this stage we will make a simple program that takes in
#values from the user and outputs the resulting calculation
#Some chnage
print("Volume of a Cylinder Formula: ")
name = input("Please input your name: ")
print("The volume of a cylinder is")
print("V = (1/3)*pi*r\u00b2")
#Input
radius = input("Input radius(... | true |
7e19a423206e308f45ad04f64a1729141cd2739d | monicador/Python | /while_num_negat.py | 302 | 4.34375 | 4 | '''
Diseñe un algoritmo que reciba numeros digitados por el usuario
y los imprima en pantalla, el programa debe terminar cuando el
usuario digite un numero negativo '''
n = 0
while n>= 0:
n = float(input("Digite un numero: "))
if n >= 0:
print("El numero digitado es: ", n)
| false |
b10fa5a4ad2f1e305a9e60146e7512a51971a5ad | monicador/Python | /funcion_Orden_Superior-04-filter-lamdda.py | 1,339 | 4.6875 | 5 | # FUNCIONES ANONIMAS
'''
Habrá ocasiones en las cuales necesitemos crear
funciones de manera rápida, en tiempo de
ejecución.
Funciones, las cuales realizan una tarea en
concreto, regularmente pequeña.
En estos casos haremos uso de funciones lambda.
-------------------------------------------------
lambda argumento : ... | false |
33fce5ec3e134a4f888e5c077dc04a822b132a8e | avryjms7/Resume | /gradeCon.py | 329 | 4.28125 | 4 | # grade converter
grade = int(input("Enter Student's Grade from 0-100?"))
if grade >= 90:
print("A")
elif grade >= 80 and grade <= 89:
print("B")
elif grade >= 70 and grade <= 79:
print("C")
elif grade >= 65 and grade <= 69:
print("D")
else:
print("F")
... | false |
93deaa3d236efa015c0525e1328be94642630492 | edunzer/MIS285_PYTHON_PROGRAMMING | /WEEK 3/3.5.py | 1,278 | 4.21875 | 4 | # Shipping charges
def lbs(weight):
if weight <= 2:
cost = weight * 1.50
print("Your package will cost: $",cost)
elif weight >= 2 and weight <= 6:
cost = weight * 3.00
print("Your package will cost: $",cost)
elif weight >= 6 and weight <= 10:
cost = weight * 4.00
... | true |
8294cf5fb457523f714f4bfd345756d282ed54f6 | svetlmorozova/typing_distance | /typing_distance/distance.py | 1,094 | 4.3125 | 4 | from math import sqrt
import click
from typing_distance.utils import KEYBOARDS
@click.command()
@click.option('-s', '--string', help='Input string', prompt='string')
@click.option('-kb', '--keyboard', help='What keyboard to use',
type=click.Choice(['MAC'], case_sensitive=False), default='MAC')
@click.... | true |
c5ec72ce973a8d01a9986a383f9978aed833dd23 | uirasiqueira/Exercicios_Python | /Mundo 3/Aula23.Ex115.py | 859 | 4.21875 | 4 | '''Crie um pequeno sistema modularizado que permita cadastrar pessoas
pelo seu nome e idade em um arquivo de texto simples.
O sistema só vai ter 2 opções: cadastear uma nova pessoa e
listar todas as pessoas cadastradas.'''
from Aula23 import Ex15p1
dic = {'nome': 'uira', 'idade':23}
print('-'* 40)
print(f'{"MENU PRI... | false |
65c1438f9b6dabb0f04c318cd7b45308b705ff2a | uirasiqueira/Exercicios_Python | /Mundo 3/Aula20.Ex98.py | 1,341 | 4.15625 | 4 | '''Faça um programa que tenha uma função chamada contador(), que receba
três parâmetos: início, fim e passo e realize a contagem.
Seu programa tem que realizar três contagens através da função criada:
A) De 1 até 10, de 1 em 1
B) De 10 até 0, de 2 em 2
C) Uma contagem personalizada'''
from time import sleep
'''def co... | false |
01427273398f798472c768bd752dd685697d28e2 | uirasiqueira/Exercicios_Python | /Mundo 3/Aula16.Ex73.py | 1,072 | 4.15625 | 4 | '''Cire uma tupla preenchida com os 20 primeiros colocados da tabela do Capeonato Bresileiro de Futebol,
na ordem de colocação. Depois mostre:
A) Apenas os 5 primeiros colocados;
B) Os últimos 4 colocados;
C) Uma lista com os times em ordem alfabética;
D) Em que posição na tabela está o time da Chapecoense'''
cbf = (... | false |
4f18517bdd33ee8d60828b8f517de83bc6b8627d | uirasiqueira/Exercicios_Python | /Mundo 1/Aula09.Ex22.py | 506 | 4.28125 | 4 | '''Crie um programa que leia o nome completa da pessoa:
1. O nome com todas as letras maiusculas
2. O nome com todas as letras minusculas
3. Quantas letras ao todo (sem considerar espaços)
3. Quantas letras tem o primeiro nome'''
nome = input('Digite seu nome completo:')
nome1 = nome.split()
#print (nome.upper())
#pr... | false |
bfe78aeedb4f2c471e2d8f1d42dc1fcb8439e4f1 | uirasiqueira/Exercicios_Python | /Mundo 2/Aula14.Ex57.py | 597 | 4.1875 | 4 | ''''Faça um programa que leia o sexo de uma pessoa, mas so aceite os valores 'M' ou 'F'.
Caso esteja errado, peça a digitalização novamente ate ter um valor correto.'''
#nome = str(input('Qual o nome da pessoa? ')).strip()
#s = str(input('Qual o sexo da pessoa? ')).strip()
#while s not in 'MmFf':
# s = str(input('... | false |
bd32a444828fd6006a8a9b72c724b8696054090f | uirasiqueira/Exercicios_Python | /Mundo 2/Aula15.Ex69.py | 923 | 4.25 | 4 | '''Crie um programa que leia a idade e o sexo de várias pessoas. A cada pessoa cadastrada o programa deverá
perguntar se o usuário quer ou não continuar. No final mostra:
A) Quantas pessoas tem mais de 18 anos;
B) Quantos homens foram cadastrados;
C) Quantas mulheres tem menos de 20 anos'''
midade = homens = menorid... | false |
4ffe1b31fbdc21fc2dec484ff36470b9ac842e0f | NisAdkar/Python_progs | /Python Programs/WhileLoop.py | 1,724 | 4.4375 | 4 | """
1.While Loop Basics
a.create a while loop that prints out a string 5 times (should not use a break statement)
b.create a while loop that appends 1, 2, and 3 to an empty string and prints that string
c.print the list you created in step 1.b.
2.while/else and break statements
a.create a while loop that does the... | true |
fabcc057a34fa2f6b99f87d400b4e2a8124fd65f | sonisparky/Ride-in-Python-3 | /4.2 Python 3_Loops_for loop_examples.py | 1,186 | 4.3125 | 4 | #1. for loop with strings
'''for letter in "banana":
print(letter)
print("done")'''
#1.1 for loop using a variable as collection:
'''fruit = "banana"
for letter in fruit:
print(letter)
print( "Done" )'''
#1.2 use if condition:
'''fruit = "banana"
for letter in fruit:
print(letter)
... | false |
51bf1f588e2230dbf128dba5439dfd7ff0ac4680 | sonisparky/Ride-in-Python-3 | /4.1 Decision Making.py | 1,824 | 4.4375 | 4 | #Python 3 - Decision Making
#3.1 Python If Statements
'''if test expression:
statement(s)'''
'''a = 10
if a == 10:
print("hello Python")
# If the number is positive, we print an appropriate message
num = 3
if num > 0:
print(num, "is a positive number.")
print("This is always printed.")
... | true |
0b701cf8b1945f9b0a29cf2398776368a2919c03 | Aravindkumar-Rajendran/Python-codebook | /Fibonacci series check.py | 1,123 | 4.25 | 4 | ```python
''' It's a python program to find a list of integers is a part of fibonacci series'''
#Function to Check the first number in Fibonacci sequence
def chkFib(n):
a=0;b=1;c=a+b
while (c<=n):
if(n==c):
return True
a=b;b=c;c=a+b
return False
#Function to check the list in ... | true |
8ba50e3abc4f884b876a4ddd9c7a216d33fb443e | AbelWeldaregay/CPU-Temperatures | /piecewise_linear_interpolation.py | 2,286 | 4.34375 | 4 | import sys
from typing import (List, TextIO)
def compute_slope(x1: int, y1: int, x2: int, y2: int) -> float:
"""
Computes the slope of two given points
Formula:
m = rise / run -> change in y / change in x
Args:
x1: X value of the first point
y1: Y value of the first point
x2: X value of second point
y2: ... | true |
e1dd2e0f656d266fb8d469943a169daa11f8bbc6 | Jtoliveira/Codewars | /Python/listFiltering.py | 557 | 4.25 | 4 | """
In this kata you will create a function that takes a list of non-negative integers and
strings and returns a new list with the strings filtered out.
"""
def filter_list(l):
result = []
#letters = "abcdefghijklmnopqrstuwvxyz"
for item in l:
if type(item) == int or type(item) == float:
... | true |
d92355f8065ef618216326ef8da15cd5d5d171b2 | omariba/Python_Stff | /oop/gar.py | 2,875 | 4.1875 | 4 | """
THE REMOTE GARAGE DOOR
You just got a new garage door installed.
Your son (obviously when you are not home) is having a lot of fun playing with the remote clicker,
opening and closing the door, scaring your pet dog Siba and annoying the neighbors.
The clicker is a one-button remote that works like this:
If the door... | true |
a32e9f1ed7b0de2069df756e27bf264763f66f89 | Ntare-Katarebe/ICS3U-Unit4-07-Python-Loop_If_Statement | /loop_if_statement.py | 392 | 4.28125 | 4 | #!/usr/bin/env python3
# Created by: Ntare Katarebe
# Created on: May 2021
# This program prints the RGB
# with numbers inputted from the user
def main():
# This function prints the RGB
# process & output
for num in range(1001, 2000 + 2):
if num % 5 == 0:
print(num - 1)
el... | true |
3ca1d41b36d422e81a1c8d012cae44234d350b50 | vprasad46/DataStructuresAlgorithms | /Arrays/Search/Search in Sorted Rotated Array.py | 1,215 | 4.34375 | 4 | # Search Algorithm for Sorted Rotated Array
def search(arr, start, end, len, searchElement):
middle = int((start + end) / 2)
if end > 0 and middle < len and start != end:
if arr[middle] == searchElement:
return middle
elif arr[middle] < searchElement:
return search(arr,... | false |
6ddaba1a37e239c325bfd313d4f20ef5f0079c9a | pranay573-dev/PythonScripting | /Python_Lists.py | 1,447 | 4.3125 | 4 | '''
#################################Python Collections (Arrays)###############################################
There are four collection data types in the Python programming language:
bytes and bytearray: bytes are immutable(Unchangable) and bytearray is mutable(changable):::::[]
List is a collection which is ordered... | true |
29b440e1130521cb7fdc12a381a215b2725c90fa | aggiewb/scc-web-dev-f19 | /ict110/3.5_coffee_shop_order.py | 578 | 4.21875 | 4 | '''
This is a program that calculates the cost of an order at a coffee shop.
Aggie Wheeler Bateman
10/10/19
'''
COFFEE_PER_POUND = 10.50 #dollars
def main():
print("Welcome to Coffee Inc. order calculation system. This system will calcute the cost of an order.")
print()
orderAmount = f... | true |
000fec743dd12b9254000e20af4d3b38f6d4e28c | aggiewb/scc-web-dev-f19 | /ict110/itc110_midterm_gas_mileage.py | 600 | 4.28125 | 4 | '''
This is a program to calculate the gas mileage for your car based off of the
total miles traveled and the gallons of gas used for that distance.
Aggie Wheeler Bateman
11/6/19
'''
def getMiles():
miles = int(input("Please enter the total amount of miles traveled: "))
return miles
def getGas():
gas = ... | true |
930cd2911cb85cb7036434b242538e75a3f6e9ac | aggiewb/scc-web-dev-f19 | /ict110/enter_read_file.py | 607 | 4.125 | 4 | '''
This is a program a program that allows a user to enter data that is
written to a text file and will read the file.
Aggie Wheeler Bateman
10/17/19
'''
from tkinter.filedialog import askopenfilename
def main():
print("Hi! I am Text, and I will allow you to enter a text file, and I will read the file.")
p... | true |
44d93bddb7c00d2cc12e9203f52083a25cf05bb8 | ryanyb/Charlotte_CS | /gettingStarted.py | 1,952 | 4.6875 | 5 |
# This is a python file! Woo! It'll introduce printing and variable declaration.
# If you open it in a text editor like VS Code it should look nifty and like
# well, a bunch of text.
# As you can see, all of this stuff is written without the computer doing anything about it
# These are things called comme... | true |
32b051aab1979bdbfebd0a416184a735eb8e298a | ProngleBot/my-stuff | /Python/scripts/Weird calculator.py | 849 | 4.21875 | 4 | try:
x = int(input('enter first number here: '))
y = int(input('enter second number here: '))
operators = ['+','-','*', '/']
operator = input(f'Do you want to add, multiply, subtract or divide these numbers? use {operators}')
def add(x, y):
result = x + y
return result
def subtr... | true |
dc2a08d86e16079ae334445d83ce45fa77c27c79 | TareqJudehGithub/higher-lower-game | /main.py | 2,274 | 4.125 | 4 | from replit import clear
from random import choice
from time import sleep
from art import logo, vs, game_over_logo
from game_data import data
def restart_game():
game_over = False
while game_over == False:
restart = input("Restart game? (y/n) ")
if restart == "y":
# Clear screen between rounds:
... | true |
60c9b68333f9a33ca526e156e0947db767f69892 | ianneyens/Ch.03_Input_Output | /3.0_Jedi_Training.py | 1,461 | 4.65625 | 5 | # Sign your name:Ian Neyens
# In all the short programs below, do a good job communicating with your end user!
# 1.) Write a program that asks someone for their name and then prints a greeting that uses their name.
"""
print()
name = str(input("What is your name?:"))
print()
print("Hello", name)
'''
# 2. Write a prog... | true |
d30a8339678effc870e6dc5ad82917d1282acff9 | Laikovski/codewars_lessons | /6kyu/Convert_string_to_camel_case.py | 796 | 4.625 | 5 | """
Complete the method/function so that it converts dash/underscore delimited words into camel casing.
The first word within the output should be capitalized only if the original word was capitalized
(known as Upper Camel Case, also often referred to as Pascal case).
Examples
"the-stealth-warrior" gets converted to "... | true |
eaa974e6367967cadc5b6faa9944fbaaa760557f | Laikovski/codewars_lessons | /6kyu/Longest_Palindrome.py | 511 | 4.28125 | 4 | # Longest Palindrome
#
# Find the length of the longest substring in the given string s that is the same in reverse.
#
# As an example, if the input was “I like racecars that go fast”, the substring (racecar) length would be 7.
#
# If the length of the input string is 0, the return value must be 0.
# Example:
#
# "a" -... | true |
cd4a14aa502abbcba0519428a684b01be17c0427 | Laikovski/codewars_lessons | /6kyu/New_Cashier_Does_Not_Know.py | 1,292 | 4.28125 | 4 | # Some new cashiers started to work at your restaurant.
#
# They are good at taking orders, but they don't know how to capitalize words, or use a space bar!
#
# All the orders they create look something like this:
#
# "milkshakepizzachickenfriescokeburgerpizzasandwichmilkshakepizza"
#
# The kitchen staff are threatenin... | true |
90bf50fee8f6d1940bada5add8a4335a0d6462dd | kxu12348760/PythonPractice | /sort.py | 1,293 | 4.28125 | 4 | # Simple insertion sort
def insertion_sort(array):
arrayLength = len(array)
for i in range(1, arrayLength):
item = array[i]
j = i - 1
while j >= 0 and array[j] > item:
array[j + 1] = array[j]
j = j - 1
array[j + 1] = item
return array
# Iterative bottom-up mergesort
def merge_sort(array):
mergeLength... | false |
aecd95cb9a29890136688bffeb3d378dc70574fd | bryandeagle/practice-python | /03 Less Than Ten.py | 648 | 4.34375 | 4 | """
Take a list, say for example this one:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
and write a program that prints out all the elements of the list
that areless than 5.
Extras:
1. Instead of printing the elements one by one, make a new list that has all
the elements less than 5 from this list in it and print o... | true |
6f9a10bbf9d0064cc111e7be3a9ed458fc615e46 | bryandeagle/practice-python | /18 Cows And Bulls.py | 1,358 | 4.375 | 4 | """
Create a program that will play the “cows and bulls” game with the user.
The game works like this:
Randomly generate a 4-digit number. Ask the user to guess a 4-digit number.
For every digit that the user guessed correctly in the correct place, they
have a “cow”. For every digit the user guessed correctly in the w... | true |
2fec0f04fce0558c8f4a2d9ff8ced1f36c8b2c14 | bryandeagle/practice-python | /06 String Lists.py | 406 | 4.4375 | 4 | """
Ask the user for a string and print out whether this string is a palindrome or
not. (A palindrome is a string that reads the same forwards and backwards.)
"""
string = input('Give me a string:').lower()
palindrome = True
for i in range(int(len(string)/2)):
if string[i] != string[-i-1]:
palindrome = Fa... | true |
2f12138956586c72818de4c13b73eb04e0e0d9fb | stybik/python_hundred | /programs/27_print_dict.py | 309 | 4.21875 | 4 | # Define a function which can generate a dictionary where the keys are numbers
# between 1 and 20 (both included) and the values are square of keys.
# The function should just print the values only.
numbers = int(raw_input("Enter a number: "))
dic = {n: n**2 for n in range(1, numbers)}
print dic.values()
| true |
646f89a757e6406543bec77dab04d9f61f97308d | stybik/python_hundred | /programs/10_whitespace.py | 342 | 4.125 | 4 | # Write a program that accepts a sequence of whitespace
# separated words as input and prints the words after
# removing all duplicate words and sorting them
# alphanumerically.
string = "Hello world, I am the boss boss the world should fear!"
words = string.split(" ")
print ("The answer is: ")
print (" ".join(sorte... | true |
ddcc1201c4fdd399c98f67689fc6a90cc5677069 | stybik/python_hundred | /programs/6_formula.py | 480 | 4.15625 | 4 | # Write a program that calculates and prints the value according to the given formula:
# Q = Square root of [(2 * C * D)/H]
# Following are the fixed values of C and H:
# C is 50. H is 30.
# D is the variable whose values should be input to your program in a comma-separated sequence.
import math
c = 50
h = 30
val = [... | true |
2f86621b953186c71e491a3fd164c96deca3b7f2 | stybik/python_hundred | /programs/21_robot.py | 1,045 | 4.53125 | 5 | # A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following:
# UP 5
# DOWN 3
# LEFT 3
# RIGHT 2
# ¡
# The numbers after the direction are steps. Please write a program to compute the dist... | true |
61585cbf2848306932b35664530ba2ba925d1f22 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_3/jparshle@bu.edu_hw_3_8_1.py | 1,687 | 4.3125 | 4 | """
Joey Parshley
MET CS 521 O2
30 MAR 2018
hw_3_8_1
Description: Write a program that prompts the user to enter a Social Security
number in the format ddd-dd-dddd, where d is a digit. The program displays
Valid SSN for a correct Social Security number or Invalid SSN otherwise.
"""
def ssn_val... | true |
30b1452a33dc76783e68a00f0a2a329acb1402a9 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_2/jparshle@bu.edu_hw_2_2_3.py | 774 | 4.40625 | 4 | """
Joey Parshley
MET CS 521 O2
26 MAR 2018
hw_2_2_3
Write a program that reads a number in feet, converts it to meters, and
displays the result.
One foot is 0.305 meters.
"""
# Greet the user and prompt them for a measurement in feet
print("\nThis program will read a measurement in feet from ... | true |
2a4854737b37f2659e6b11ca4dd1e91fd0162448 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_2/jparshle@bu.edu_hw_2_3_1.py | 2,292 | 4.53125 | 5 | """
Joey Parshley
MET CS 521 O2
26 MAR 2018
hw_2_3_1
Write a program that prompts the user to enter the length from the center of
a pentagon to a vertex and computes the area of the pentagon
"""
# import the math module to use sin and pi
import math
# Contstants to be used in functions
# used to c... | true |
a9c76ec6572eb8027ce6ebd169c50a8b63f105dc | puneet4840/Data-Structure-and-Algorithms | /Queue in Python/5 - Double Ended Queue.py | 2,380 | 4.46875 | 4 | # Double Ended Queue: When insertion and Deletion can be done on both (rear and front) ends.
# It is called Double Ended Queue or Deque.
print()
class Dequeue():
def __init__(self):
self.size=int(input("Enter the szie of Dequque: "))
self.Deque=list()
def Insert_from_rear_side(self,item):
... | false |
be808b86dd30bf6983fa13f28a5feba15ef6efce | puneet4840/Data-Structure-and-Algorithms | /Queue in Python/1 - Creating Queue using python List.py | 1,889 | 4.25 | 4 | # Queue is the ordered collection of items which follows the FIFO (First In First Out) rule.
## Insertion is done at rear end of the queue and Deletion is done at front end of the queue.
print()
class Queue():
def __init__(self):
self.size=int(input("\nEnter the size of the Queue: "))
self.que=lis... | true |
9467799833a6c78fc4097870f8ec7c917f45ca68 | puneet4840/Data-Structure-and-Algorithms | /Stack in Python/3 - Reverse a string using stack.py | 571 | 4.1875 | 4 | # Reverse a string using stack.
# We first push the string into stack and pop the string from the stack.
# Hence, string would be reversed.
print()
class Stack():
def __init__(self):
self.stk=list()
self.str=input("Enter a string: ")
def Push(self):
for chr in self.str:
se... | true |
79b5b14d8006fc6ee9598d4bfc46518289510fe4 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/2 - Doubly Linked List/4 - Insertion before specific node.py | 2,390 | 4.25 | 4 | # Inserting a node before a specific node in the linked list.
print()
class Node():
def __init__(self,data):
self.prev=None
self.data=data
self.next=None
class Linked_list():
def __init__(self):
self.start=None
def insert_node(self,data):
temp=Node(data)
if... | true |
1292d9ae7544923786c98b67c4c2c426314f3cac | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Binary Search using python.py | 798 | 4.125 | 4 | # Binary Search using Python.
# It takes o(logn) time to execute the algorithm.
l1=list()
size=int(input("Enter the size of list: "))
for i in range(size):
l1.append(int(input(f"\nEnter element {i+1}: ")))
l1.sort()
def Binary_Search(l1,data,low,high):
if(low>high):
return False
else:
... | true |
d03538d4dca196e6fda1d7508233a8f9ce2852a6 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/5 - Queue using Linked LIst/12 - Queue using Linked lIst.py | 1,436 | 4.1875 | 4 | # Implementing Queue using Linked list.
print()
class Node():
def __init__(self,data):
self.data=data
self.next=None
class Linkd_list():
def __init__(self):
self.start=None
def Insert_at_end(self,data):
temp=Node(data)
if self.start==None:
self.start=te... | true |
9a46984cc1655739334a16a11f1f252dc20cdd91 | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Print numbers from 1 to 10 in a way when number is odd add 1 ,when even subtract 1.py | 393 | 4.3125 | 4 | # Program to print the numbers from 1 to 10 in such a way that when number is odd add 1 to it and,
# when number is even subtract 1 from it.
print()
def even(n):
if n<=10:
if n%2==0:
print(n-1,end=' ')
n+=1
odd(n)
def odd(n):
if n<=10:
if n%2!=0:
... | true |
fa0bf4de5631301d3ee23a655a62980dde419eab | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/1 - Singly Linked List/2 - Creating linked list.py | 1,266 | 4.21875 | 4 | # Linked List is the collection of nodes which randomly stores in the memory.
print()
class Node():
def __init__(self,data):
self.data=data
self.next=None
class Linked_List():
def __init__(self):
self.start=None
def Insert_Node(self,data):
temp=Node(data)
if self.s... | true |
d0cab036eb084c555f428a868e594328e6761b47 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/2 - Doubly Linked List/6 - Delete Last Node.py | 1,560 | 4.15625 | 4 | # Delete Last Node
print()
class Node():
def __init__(self,data):
self.prev=None
self.data=data
self.next=None
class Linked_List():
def __init__(self):
self.start=None
def Insert_Node(self,data):
temp=Node(data)
if self.start==None:
... | false |
570ce4c7be39132e0170b9554316315f562ed5db | TKorshikova/PythonQA | /3.1.py | 802 | 4.15625 | 4 | # импорт всегда первый
import random
# Создаем список с заданными параметрами
def create_list(count, maximum):
# возвращаем список от 1 до заданного числа с заданным количеством элементов
return [random.randint(1, maximum) for i in range(count)]
# пользователь вводит количество элементов
inputCount = int(in... | false |
e565859face5705525c10fe91e6e9e5111088773 | stuartses/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/2-matrix_divided.py | 1,552 | 4.53125 | 5 | #!/usr/bin/python3
"""1. Divide a matrix
This module divides all elements of a matrix in a number
Corresponds to Task 1.
Holberton School
Foundations - Higher-level programming - Python
By Stuart Echeverry
"""
def matrix_divided(matrix, div):
"""Function that divides all elements of a matrix in a number
Args... | true |
b00edcdc40657f72d82766fd72da4de8d4b7c8cc | stuartses/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 699 | 4.125 | 4 | #!/usr/bin/python3
"""0. Integers addition
This module adds two input integer numbers.
Corresponds to Task 0.
Holberton School
Foundations - Higher-level programming - Python
By Stuart Echeverry
"""
def add_integer(a, b=98):
"""Functions that adds two integers
Args:
a (int): first argument. Could ... | true |
4ff3c3cd3009d5a9984928b54a89748b7792bec5 | MyrPasko/python-test-course | /lesson11.py | 567 | 4.25 | 4 | # String formatting
name = 'Johny'
age = 32
title = 'Sony'
price = 100
print('My name is ' + name + ' and I\'m ' + str(age) + ' old.')
print('My name is %(name)s and I\'m %(age)d old.' % {'name': name, 'age': age})
print('My name is %s and I\'m %d old. %s' % (name, age, name))
print('Title: %s, price: %.2f' % ('Sony'... | true |
0d45281fe80cd884293a01bdae66bca566e8f614 | deniskidagi/100-days-of-code-with-python | /day10-functions-with-inputs.py | 1,755 | 4.21875 | 4 | #functions with outputs
# def format_name(f_name, l_name):
# print(f_name.title())
# l_name.title()
#
#
# format_name("denis", "DENIS")
#challenge days in months
#
# def is_leap(year):
# if year % 4 == 0:
# if year % 100 == 0:
# if year % 400 == 0:
# return True
# ... | false |
bbe9f6139741eac1dc594da7526f2bf812833270 | tinahong94/python_homework | /primality.py | 825 | 4.15625 | 4 | number = int(input("Give me a number: "))
divisor = [x for x in range(1, number + 1) if number % x == 0]
print(divisor)
def get_primality(n):
divisor.remove(1)
# divisor.remove(number)
if not divisor:
print("This number " + str(number) + " is prime number")
else:
print("This number " +... | false |
04324df563ff3d83864d012ba0fb435761ccaf17 | Asano-H/Hana | /strip.py | 407 | 4.1875 | 4 | a="abcabca"
print(a)
print(a.strip("a")) #両端の削除
print(a.lstrip("a")) #左端の削除
print(a.rstrip("a")) #右端の削除
print(" abc".strip()) #空白を削除
"""
strip関数
.strip(削除したい文字列)
厳密には、削除ではなく特定の文字を取り除いた新しい文字列を返す処理
削除する文字列を指定しない場合、空白を削除
""" | false |
e23e20632d635370cf05b8e1f6c0079cf1e173c3 | FedoseevAlex/algorithms | /tests/insert_sorting_test.py | 1,750 | 4.1875 | 4 | #!/usr/bin/env python3.8
from unittest import TestCase
from random import shuffle
from algorithms.insert_sorting import increase_sort, decrease_sort
class InsertionSortTest(TestCase):
"""
Test for insertion sorting functions
"""
def test_increasing_sort_static(self):
"""
Testing ins... | true |
29847749ede6139ce34c257e2aed969f03a0bd13 | srikanthpragada/PYTHON_03_AUG_2021 | /demo/libdemo/list_customers_2.py | 1,097 | 4.125 | 4 | def isvalidmobile(s):
"""
Checks whether the given string is a valid mobile number.
A valid mobile number is consisting of 10 digits
:param s: String to test
:return: True or False
"""
return s.isdigit() and len(s) == 10
def isvalidname(s):
"""
Checks whether the given name contai... | true |
559a526cf95fd9089410172044a19491e55a77db | AvishDhirawat/Python_Practice | /bmi_calc using funcn.py | 412 | 4.125 | 4 | #Author - Avish Dhirawat
def bmi_calc(name,weight,height):
bmi=weight/(height**2)
print ("BMI : ")
print (bmi)
if bmi<25:
print (name + " is Under Weighed")
elif bmi>25:
print (name + " is Overweighed")
else :
print (name + " is Equally Weighed")
a = input("Ent... | false |
b7b7820e346c7aa3d8909f86d62edd469aee4324 | Dilaxn/Hacktoberfest2021-2 | /Fibonacci_sequence.py | 312 | 4.1875 | 4 | n = int(input("Number of terms? "))
a,b = 0, 1
c = 0
if n <= 0:
print("Only positive integers are allowed")
elif n == 1:
print("Fibonacci sequence till",n,":")
print(a)
else:
print("Fibonacci sequence is:")
while c < n:
print(a)
nth = a + b
a = b
b = nth
c += 1
| false |
3da59a6ef09ad69ad0197d877961e6521add726f | Obichukwu/linkedin-python-data-structure | /run_deque.py | 478 | 4.15625 | 4 | from deque import Deque
def is_palindrome(word):
deq = Deque()
for ch in word:
deq.add_rear(ch)
#deq.items = word.split()
while deq.size() >= 2:
front = deq.remove_front()
rear = deq.remove_rear()
if (front != rear):
return False
return True
def test_... | false |
11a93dee71081247fa8b62a48fc4ccbcfbc5563f | RubennCastilloo/master-python | /06-bucles/bucle-for.py | 884 | 4.3125 | 4 | """
# FOR
for variable in elemento_iterable (lista, rango, etc)
BLOQUE DE INSTRUCCIONES
"""
numeros = [1, 2, 3, 4, 5]
for numero in numeros:
print(f"El número iterado es {numero}")
contador = 0
resultado = 0
for contador in range(0, 10):
print(f"Voy por el {contador}")
resultado += contador
prin... | false |
095d7d713c0fa69ca663e4bfac17b09d9d1f97c7 | leledada/LearnPython | /test_code/20180327-6-11test.py | 401 | 4.125 | 4 | # 用符号的组合在控制台输出不同大小的矩形图案。
# 要求:写一个输出矩形的函数,该函数拥有三个默认参数,矩形的长5、宽5和组成图形的点的符号“*”,为函数添加不同的参数,输出三个不同类型的矩形;
def myRact(l=5, h=5, p='*'):
for i in range(l):
print(p * h)
myRact()
myRact(4, 3, '#')
myRact(2, 6, "!")
| false |
30e0997cb7359cd6f14b98717c68d409c6f68aec | dalexach/holbertonschool-machine_learning | /supervised_learning/0x04-error_analysis/1-sensitivity.py | 684 | 4.3125 | 4 | #!/usr/bin/env python3
"""
Sensitivity
"""
import numpy as np
def sensitivity(confusion):
"""
Function that calculates the sensitivity for each class
in a confusion matrix
Arguments:
- confusion: is a confusion numpy.ndarray of shape (classes, classes)
where row indices represe... | true |
e62b085add02d42761f087761eeccfe1c55b53d4 | dalexach/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/4-moving_average.py | 608 | 4.1875 | 4 | #!/usr/bin/env python3
"""
Moving average
"""
def moving_average(data, beta):
"""
Function that calculates the weighted moving average of a data set:
Arguments:
- data (list): is the list of data to calculate the moving average of
- beta (list): is the weight used for the moving average
Retu... | true |
b01b43fb042dd2345fd2778fd4c75418b95b7a97 | dalexach/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/1-normalize.py | 621 | 4.28125 | 4 | #!/usr/bin/env python3
"""
Normalize
"""
import numpy as np
def normalize(X, m, s):
"""
Function that normalizes (standardizes) a matrix
Arguments:
- X: is the numpy.ndarray of shape (d, nx) to normalize
* d is the number of data points
* nx is the number of features
- m: is a ... | true |
2e7755488ee4f5f74d8120d2d10ef04b0446c37b | Wet1988/ds-algo | /algorithms/sorting/quick_sort.py | 1,132 | 4.21875 | 4 | import random
def quick_sort(s, lower=0, upper=None):
"""Sorts a list of numbers in-place using quick-sort.
Args:
s: A list containing numbers.
lower: lower bound (inclusive) of s to be sorted.
upper: upper bound (inclusive) of s to be sorted.
Returns:
s
"""
if upper is... | true |
6d5fa9841aaed33cade266f564debefbd97e82a0 | JustinCee/tkinter-handout | /handout exercise.py | 1,103 | 4.375 | 4 | # this is to import the tkinter module
from tkinter import *
# this function is to add the numbers
def add_numbers():
r = int(e1.get())+int(e2.get())
label_text.set(r)
def clear():
e1.delete(0)
e2.delete(0)
root = Tk()
# the below is the size of the window
root.geometry("600x200")
root.title("Justin... | true |
c1a165174ddc6f5dc927a5855a109b647e920cdf | antony10291029/lxfpyanswer | /20oop_program.py | 706 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#设计一个计算学生成绩的类,并且用实例表现出来
class Student(object):
def __init__(self,name,score):
self.name = name
self.score = score
def print_score(self):
print('%s: %s' % (self.name, self.score))
#这里直接定义print方法的意义在于,调用这个类的实例的时候,可以直接输出内容
#否则的话要print一次内容
std1 ... | false |
7bbc137569534407c0994ff34dc78bcc63b2b5cc | gui-csilva/python | /Python/Sétimo_programa.py | 1,013 | 4.3125 | 4 | #nessa linha criamos a variavel par
par = []
#nessa linha criamos a variavel a
a = [1,2,3,4,5,6,7,8,9,10]
#nessa linha criamos a variavel impar
impar = []
#nessa linha iniciamos um loop
for v in a:
#nessa linha imprimimos a string par
print("par")
#nessa linha mostra os números pares
print(par)
#nessa... | false |
c96975836d9fc7e0fe4c1b99f93ad192622faf8c | gui-csilva/python | /Python/Anotações.py.py | 2,379 | 4.21875 | 4 | #IDE (programa que nos ajuda a escarever códigos)
#String ou str (qualquer coisa escrita entre duas aspas)
#single quote = apostrofe = 1 aspa; quote = aspas = " "
#"conversa";#string
#'F'; #caracter
#-10 até 10 int = Integer = numero inteiro
#10;
#-10;
#Float= número decimal= 10.9
#3.4;
#String"10"
#Variav... | false |
84e78624aa3c0171d05b430576946cad18360fdf | BC-CSCI-1102-S19-TTh3/example_code | /week10/dictionarydemo.py | 507 | 4.40625 | 4 | # instantiating a dictionary
mydictionary = {}
# adding key-value pairs to a dictionary
mydictionary["dog"] = 2
mydictionary["cat"] = 17
mydictionary["hamster"] = 1
mydictionary["houseplant"] = 5
# getting a value using a key
mycatcount = mydictionary["cat"]
# looping through keys in a dictionary
for k in mydiction... | true |
3df5c17e536ddf072745ff1dca3aae6a7f265c51 | llamington/COSC121 | /lab_8_5.py | 1,783 | 4.34375 | 4 | """A program to read a CSV file of rainfalls and print the totals
for each month.
"""
from os.path import isfile as is_valid_file
def sum_rainfall(month, num_days, columns):
"""sums rainfall"""
total_rainfall = 0
for col in columns[2:2 + num_days]:
total_rainfall += float(col)
return month... | true |
e3f75b248da72151068bf8707e1216e33ec03f57 | AnandCodeX/Beginner-to-Advanced-python-List-of-Programs | /Python/L8/pr2.py | 480 | 4.21875 | 4 | #waoopp class circle
#radius
#display()
#area()
#circumference()
class circle:
def __init__(self,r):
self.radius=r
def show(self):
print("radius = ",self.radius)
def area(self):
ans=3.14159*self.radius**2
print("radius = ",round(ans,2))
def circumference(self):
a... | false |
cdf618d95d1d4e99aeccf6e67df08a96a7f812a7 | RSnoad/Python-Problems | /Problem 7.py | 588 | 4.125 | 4 | # Find the 10,001st prime number
from math import sqrt
# Function to find the nth prime in list using the isPrime function below.
def nthPrime(n):
i = 2
primeList = []
while len(primeList) < n:
if isPrime(i):
primeList.append(i)
i += 1
print(primeList[-1])
# Brute force m... | true |
685452c53ea915107f3f2a2ec2ef020a1702f132 | isaac-friedman/lphw | /ex20-2.py | 1,661 | 4.6875 | 5 | ####
#This file combines what we've learned about functionwas with what we've
#learned about files to show you how they can work together. It also
#sneaks in some more info about files which you may or may not know depending
#on if you did the study drills.
####
from sys import argv
#In some of my versions of the stud... | true |
21e7a38cfa5194e6b321693cbe24008421ff0974 | isaac-friedman/lphw | /ex13-3_calc.py | 1,129 | 4.6875 | 5 | ####
#More work with argv
#This time we will use argv to collect two operands and then use raw input to
#ask for an arithmetic operation to perform on them. Effectively, we've just
#made a basic calculator
####
from sys import argv
####
#See how we aren't checking to make sure the arguments are numbers? That is a
... | true |
d1c8dbc2a8c9ba6edff5ff330a826997c5c019dc | isaac-friedman/lphw | /ex15.py | 1,390 | 4.5 | 4 | ####
#This script prints a specified file to the screen. More specifically, it
#prints to something called "standard output" which is almost always the screen
#but could be something else. For now, think of 'print' as 'printing to the
#screen' and 'standard output' or 'stdio' etc as "the screen." It's easier and
#pret... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.