blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
ee3615b1612d3340005a8b07a6e93bc130153591 | JanJochemProgramming/basic_track_answers | /week3/session/dicts.py | 338 | 4.25 | 4 | capitals = {"The Netherlands": "Amsterdam", "France": "Paris"}
capitals["Japan"] = "Tokyo"
for country in reversed(sorted(capitals)):
print(country, capitals[country])
fruit_basket = {"Apple": 3}
fruit_to_add = input("Which fruit to add? ")
fruit_basket[fruit_to_add] = fruit_basket.get(fruit_to_add, 0) + 1
pr... | true |
b3911866de644fab92a2c061c2a8a7d4535d3820 | JanJochemProgramming/basic_track_answers | /week1/exercises/exercise_1_7_1-5.py | 724 | 4.5 | 4 | # I don't expect you to put in all the extra print statement
# they are there to help follow my train of though
print(9 * "*", " + ", 9 * "*")
print(3 + 5)
print("Hello " + "world!")
print(9 * "*", " - ", 9 * "*")
print(5 - 3)
print(9 * "*", " * ", 9 * "*")
print(3 * 5)
print(3 * "Hallo")
print(9 * "*", " / ", 9 * "... | false |
8ec7c46f57e44354f3479ea02e8e0cf34aaec352 | oreqizer/pv248 | /04/book_export.py | 1,691 | 4.1875 | 4 | # In the second exercise, we will take the database created in the
# previous exercise (‹books.dat›) and generate the original JSON.
# You may want to use a join or two.
# First write a function which will produce a ‹list› of ‹dict›'s
# that represent the books, starting from an open sqlite connection.
import sqlite3... | true |
a0151ddb3bc4c2d393abbd431826393e46063b89 | zachacaria/DiscreteMath-II | /q2.py | 1,356 | 4.15625 | 4 | import itertools
import random
def random_permutation(iterable, r):
"Random selection from itertools.permutations(iterable, r)"
pool = tuple(iterable)
r = len(pool) if r is None else r
return tuple(random.sample(pool, r))
# Function to do insertion sort
def insertionSort(arr):
# Traverse through... | true |
49a02e54c4e4d95e4fb06ef8a85ecc4c0534c2f7 | Ianashh/Python-Testes | /Curso em vídeo/Ex060.py | 665 | 4.34375 | 4 | # Obs.: usar # nas linhas do "for" (Passo 2.1) ou nas linhas do "while" (Passo 2.2) para anular um ou outro programa e obter o resultado correto.
# Passo 1: Criar variáveis
n = int(input('Digite um número para descobrir seu fatorial: '))
cont = n
esc = n
# Passo 2.1: Usar o "for" para o fatorial
for n in range(n,1,-1... | false |
115b477fb7b86d34e9df784d43bfe29b2dcbf06a | tanyastropheus/holbertonschool-higher_level_programming | /0x0B-python-input_output/1-number_of_lines.py | 364 | 4.28125 | 4 | #!/usr/bin/python3
def number_of_lines(filename=""):
"""count the number of lines in a text file
Args:
filename (str): file to be counted
Returns:
line_num (int): number of lines in the file.
"""
line_num = 0
with open(filename, encoding="UTF8") as f:
for line in f:
... | true |
b892044a6357a29a857857ffb37c5b438a9ef785 | AYamaui/Practice | /sort/insertion_sort.py | 414 | 4.21875 | 4 |
# Complexity: O(n^2) for swaps / O(n^2) for comparisons
def insertion_sort(array):
for i in range(1, len(array)):
j = i
while j >= 1 and array[j-1] > array[j]:
aux = array[j-1]
array[j-1] = array[j]
array[j] = aux
j -= 1
return array
if __nam... | false |
fafd561f1c3020231747a3480278bcf91c457a82 | AYamaui/Practice | /exercises/cyclic_rotation.py | 1,998 | 4.3125 | 4 | """
An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved ... | true |
5f404ca2db9ce87abe64ba7fd1dd111b1ceeb022 | matt969696/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/100-matrix_mul.py | 1,965 | 4.25 | 4 | #!/usr/bin/python3
"""
2-matrix_mul module - Contains simple function matrix_mul
"""
def matrix_mul(m_a, m_b):
"""
Multiplies 2 matrices
Return the new matrix
The 2 matrix must be non null list of list
The 2 matrix must be multiable
All elements of the 2 matrix must be integers or floats
"... | true |
6aef4c2a49e81fe1fe83dacb7e246acee51ab11c | Floozutter/silly | /python/montyhallsim.py | 2,038 | 4.15625 | 4 | """
A loose simulation of the Monty Hall problem in Python.
"""
from random import randrange, sample
from typing import Tuple
Prize = bool
GOAT = False
CAR = True
def make_doors(doorcount: int, car_index: int) -> Tuple[Prize]:
"""Returns a representation of the doors in the Monty Hall Problem."""
return tup... | true |
c7e11b86d21975a2afda2485194161106cadf3b3 | ariquintal/StructuredProgramming2A | /unit1/activity_04.py | 338 | 4.1875 | 4 | print("Start Program")
##### DECLARE VARIABLES ######
num1 = 0
num2 = 0
result_add = 0
result_m = 0
num1 = int(input("Enter number1\n"))
num2 = int(input("Enter number2\n"))
result_add = num1 + num2
result_m = num1 * num2
print("This is the add", result_add)
print("This is the multiplication", result_m)
print ("P... | true |
df10e17b0e13a965b32fda8db67bcaba3743938a | candacewilliams/Intro-to-Computer-Science | /kind_of_a_big_deal.py | 403 | 4.125 | 4 | minutes = float(input('Minutes: '))
num_hours = float(minutes / 60)
num_hours = int(num_hours)
#print(num_hours)
num_minutes = float(minutes % 60)
whole_minutes = int(num_minutes)
#print(num_minutes)
num_seconds = minutes - int(minutes)
num_seconds = num_seconds * 60
num_seconds = round(num_seconds)
p... | false |
c5239b303a99370ab99df458f758eaef7af3cbac | candacewilliams/Intro-to-Computer-Science | /day_of_year.py | 840 | 4.25 | 4 | month = input('Insert Month: ')
day = int(input('Insert Day: '))
def GetDayOfYear(month,day):
if month == 'January':
print(day)
if month == 'February':
print(day + 31)
if month == 'March':
print(day +(31 + 28))
if month == 'April':
print(day + ((31*2) + 28))
... | false |
b9c3c868e064818e27304573dec01cc97a4c3ab1 | candacewilliams/Intro-to-Computer-Science | /moon_earths_moon.py | 299 | 4.15625 | 4 | first_name = input('What is your first name?')
last_name = input('What is your last name?')
weight = float(input('What is your weight?'))
moon_weight = str(weight* .17)
print('My name is ' + last_name + '. ' + first_name + last_name + '. And I weigh ' + moon_weight + ' pounds on the moon.')
| true |
3b3e87f7f11e3287516bf4fec945004c1e608a91 | candacewilliams/Intro-to-Computer-Science | /math.py | 537 | 4.21875 | 4 | val_1 = input('First Number: ')
val_1 = float(val_1)
val_2 = input('Second Number: ')
val_2 = float(val_2)
sum_val = val_1 + val_2
print('The sum of ' , val_1 , ' and ' , val_2 , ' is ' , sum_val)
minus_val = val_1 - val_2
print('The difference of ' , val_1 , ' and ' , val_2 , ' is ' , minus_val)
... | false |
4b62f2f35aa1a6b85155351a1793559a1113ee69 | Jailsonmc/projects-python | /Geral/ConverterB10Bn.py | 372 | 4.125 | 4 | print("Digite o número a ser convertido para base 10:")
valor = int(input())
print("Digite a base:")
baseN = int(input())
continuar = True
aux = valor
while continuar:
quociente = int(aux / baseN)
resto = int(aux % baseN)
print(str(resto),end="")
aux = quociente
if quociente < baseN:
conti... | false |
dba9eac804e3cc991ee8c2baeb17f180d2876414 | jdvpl/Python | /7 funciones/7variablelocalesgloabales.py | 732 | 4.25 | 4 | """
variables locales:se defines dentro de la funcion y no se puede usar fuera de ella
solo estan disponibles dentro
a no ser que hagamos un retunr
variables globales: son las que se declaran fuera de una funcion
y estan disponibles dentro y fuera de ellas
"""
frase="jiren es un marica y no pudo vencer a kakaroto" #v... | false |
06f79676ec85258798bd5fd5c7520ca9c040080d | jdvpl/Python | /9 sets-diccionarios/2diccionarios.py | 1,236 | 4.1875 | 4 | """
es un tipo de dato que almacena un conjunto de datos
formato clave > valor
es lo mismo que un array con en json
"""
# persona={
# "nombre":"Juan",
# "apellidos":"Suarez",
# "web":"jdvpl.com"
# }
# print(type(persona)) #tipo de dato
# print(persona) #imprime todo
# print(f" la Web: {persona['web']}") #s... | false |
33dfb3e016da6665ab1e7ef47a89344f5a1c70ad | jdvpl/Python | /4 condicionales/elif.py | 1,669 | 4.125 | 4 | # print(f"########################## elif ####################")
# dia=int(input("Introduce el dia de la semana "))
# if dia==1:
# print(f"es lunes")
# elif dia==2:
# print(f"es martes")
# elif dia==3:
# print(f"es miercoles")
# elif dia==4:
# print(f"es jueves")
# elif dia==5:
# print(f"es viernes"... | false |
ed89b53b3082f608adb2f612cf856d87d1f51c78 | SandySingh/Code-for-fun | /name_without_vowels.py | 359 | 4.5 | 4 | print "Enter a name"
name = raw_input()
#Defining all vowels in a list
vowels = ['a', 'e', 'i', 'o', 'u']
name_without_vowels = ''
#Removing the vowels or rather forming a name with only consonants
for i in name:
if i in vowels:
continue
name_without_vowels += i
print "The name without v... | true |
8fbcb251349fe18342d92c4d91433b7ab6ca9d53 | gsaikarthik/python-assignment7 | /assignment7_sum_and_average_of_n_numbers.py | 330 | 4.21875 | 4 | print("Input some integers to calculate their sum and average. Input 0 to exit.")
count = 0
sum = 0.0
number = 1
while number != 0:
number = int(input(""))
sum = sum + number
count += 1
if count == 0:
print("Input some numbers")
else:
print("Average and Sum of the above numbers are: ", sum / (coun... | true |
4731e40b41f073544f2edf67fb02b6d93396cd7b | hbomb222/ICTPRG-Python | /week3q4 new.py | 819 | 4.40625 | 4 | username = input("enter username ") # ask user for username
user_dict = {"bob":"password1234", "fred":"happypass122", "lock":"passwithlock144"} # create dictionary of username password pairs
if (username == "bob" or username == "fred" or username == "lock"): # check if the entered username matches any of the known val... | true |
5e3d41c1d7e1d49566416dced623ae593b58c079 | nickwerner-hub/WhirlwindTourOfPython | /Scripting/03_RangeFunctionExample.py | 270 | 4.34375 | 4 | #RangeFunctionExample.py
# This example demonstrates the range function for generating
# a sequence of values that can be used in a for loop.
pi = 3.1415
for r in range(0,100,20):
area = (r ** 2) * pi
print "The area of a circle with radius ", r, "is ", area | true |
313925e1c6edb9d16bc921aff0c8897ee1d2bdf5 | nickwerner-hub/WhirlwindTourOfPython | /Scripting/07_WriteDataExample.py | 1,620 | 4.34375 | 4 | #WriteDataExample.py
# This script demonstrates how a file object is used to both write to a new text file and
# append to an existing text file.In it we will read the contents of the EnoNearDurham.txt
# file and write selected data records to the output file.
# First, create some variables. "dataFileName" will po... | true |
1fc51bc3ec116ee0663399bffae6825020d33801 | abdbaddude/codeval | /python/jolly_jumper.py3 | 2,166 | 4.1875 | 4 | #!/usr/bin/env python3
"""
JOLLY JUMPERS
CHALLENGE DESCRIPTION:
Credits: Programming Challenges by Steven S. Skiena and Miguel A. Revilla
A sequence of n > 0 integers is called a jolly jumper if the absolute values of the
differences between successive elements take on all possible values 1 through n - 1.
eg.
1 4... | true |
87c2fcfcaa140e8971926f8da3098c5abe781271 | Nadeem-Doc/210CT-Labsheet | /Labsheet 5 - Task 2.py | 1,542 | 4.21875 | 4 | class Node():
def __init__(self, value):
self.value=value
self.next=None # node pointing to next
self.prev=None # node pointing to prev
class List():
def __init__(self):
self.head=None
self.tail=None
def insert(self,n,x):
#Not actually perfe... | true |
f0664f2b9a826598dc873e8c27d53b6623f67b5b | Vanagand/Data-Structures | /queue/queue.py | 1,520 | 4.21875 | 4 | #>>> Check <PASS>
"""
A queue is a data structure whose primary purpose is to store and
return elements in First In First Out order.
1. Implement the Queue class using an array as the underlying storage structure.
Make sure the Queue tests pass.
2. Re-implement the Queue class, this time using the linked list imp... | true |
6f1fbad0e294f9d9c800c84b72e915938b7a1c33 | javicercasi/um-programacion-i-2020 | /58004-Cercasi-Javier/tp1/Orientado a Objetos/Ejercicio2OPP.py | 1,471 | 4.5625 | 5 | '''La pizzería Bella Napoli ofrece pizzas vegetarianas y no vegetarianas a
sus clientes. Los ingredientes para cada tipo de pizza aparecen a continuación.
* Ingredientes vegetarianos: Pimiento y tofu.
* Ingredientes no vegetarianos: Peperoni, Jamón y Salmón.
Escribir un programa que pregunte al usuario si quiere una pi... | false |
43029ca4a4a757e2c1aa177b9addca9c7c3157f0 | Amrut-17/python_programs | /Selection_Sort.py | 620 | 4.15625 | 4 | def selection_sort(n):
for i in range (n):
min = i
for j in range(i+1 , n):
if (a[j] < a[min]):
min = j
temp = a[i]
a[i] = a[min]
a[min] = temp
print('\nAFTER sorting')
for i in range(n):
print (a[i], end = " ")
... | false |
de5f1ae3bae6d0744cd18ded1ec0631d48fbb559 | TanvirKaur17/Greedy-4 | /shortestwayToFormString.py | 912 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 29 08:30:10 2019
@author: tanvirkaur
implemented on spyder
Time Complexity = O(m*n)
Space Complexity = O(1)
we maintain two pointers one for source and one for target
Then we compare the first element of source with the target
If we iterate through ... | true |
0f8df2bb7f0ca56f34737d85faa3aeb5d4c8a300 | emmanuelagubata/Wheel-of-Fortune | /student_starter/main.py | 1,188 | 4.15625 | 4 | # Rules
print('Guess one letter at a time. If you want to buy a vowel, you must have at least $500, otherwise, you cannot buy a vowel. If you think you know the word or phrase, type \'guess\' to guess the word or phrase. You will earn each letter at a set amount and vowels will not cost anything.')
from random import ... | true |
355df5e645f38513d4581c5f3f08ed41568c59e2 | zaincbs/PYTECH | /reverseOfString.py | 375 | 4.375 | 4 | #!/usr/bin/env python
"""
Define a function reverse, that computes the reversal of a string. For example, reverse("I am testing") should return the string "gnitset ma I".
"""
def reverse(s):
k= ""
for i in range (len(s)-1, -1, -1):
k = k + s[i]
return k
def main():
v = reverse("This is testing... | true |
af771a30f93a4382dacfb04e423ad01dd96b3160 | zaincbs/PYTECH | /filter_long_words_using_filter.py | 561 | 4.25 | 4 | #!/usr/bin/env python
"""
Using the higher order function filter(), define a function
filter_long_words() that takes a list of words and an
integer n and returns the list of words that are longer
than n.
"""
def filter_long_words(l,n):
return filter(lambda word: len(word) > n, l)
def main():
list_with_len_of... | true |
528bb5e90b48a7b741e96c7df0ffe0905534df39 | zaincbs/PYTECH | /readlines.py | 1,420 | 4.125 | 4 | #!/usr/bin/env python
"""
I am making a function that prints file in reverse order and then reverses
the order of the words
"""
import sys
def readFile(filename):
rorder = ''
opposed = ''
finale= ''
inline = ''
#reading file line by line
#with open(filename) as f:
# lines = f.readline... | true |
cddf97c1866cda863176a775e141a2ce53cbcbff | zaincbs/PYTECH | /palindrome_recog.py | 2,595 | 4.3125 | 4 | #!/usr/bin/env python
"""
Write a version of a palindrome recognizer that also accepts phrase palindromes such as "Go hang a salami I'm a lasagna hog.", "Was it a rat I saw?", "Step on no pets", "Sit on a potato pan, Otis", "Lisa Bonet ate no basil", "Satan, oscillate my metallic sonatas", "I roamed under it as a tire... | false |
597368b52b65f2cf0b6a61a78ec076f6ff925432 | AlanFermat/leetcode | /linkedList/707 designList.py | 2,691 | 4.53125 | 5 | """
Design your implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly linked list should have two attributes: val and next. val is the value of the current node, and next is a pointer/reference to the next node. If you want to use the doubly linked... | true |
dcde21722a7a1ffac43bede4f9ebefefeca4a668 | AlanFermat/leetcode | /PYTHONNOTE/arg.py | 632 | 4.28125 | 4 | # *args is used to send a non-keyworded variable length argument list to the function
def test_var_args(f_arg, *argv):
print("first normal arg:", f_arg)
for arg in argv:
print("another arg through *argv:", arg)
test_var_args('yasoob', 'python', 'eggs', 'test')
def greet_me(**kwargs):
for key, value in kwargs.it... | false |
8f967f1220a5b1dbf211c5360d99c479fb522383 | tskillian/Programming-Challenges | /N-divisible digits.py | 939 | 4.21875 | 4 | #Write a program that takes two integers, N and M,
#and find the largest integer composed of N-digits
#that is evenly divisible by M. N will always be 1
#or greater, with M being 2 or greater. Note that
#some combinations of N and M will not have a solution.
#Example: if you are given an N of 3 and M of 2, t... | true |
d02456321853b7ea2b7a0bd80678647c6c0d8c21 | karakazeviewview/PythonTraining | /20210201/listlesson.py | 453 | 4.125 | 4 | list1=[] #からのリスト
list2=list() #からのリスト
list1.append(3)
print(list1)
list1.append(5)
print(list1[0])
list2.append(10)
list2.append(20)
print(list2)
list3=list1+list2
print(list3)
list4=list3*3
print(list4)
print(len(list4)) #12
print(sum(list4)) #合計114
del list4[0]
print(list4)
list4.remove(5) #見つけた最初の要素
print(lis... | false |
ea96f8e8e0c7a7e1bde8a01c47098036d10799f2 | usmanmalik6364/PythonTextAnalysisFundamentals | /ReadWriteTextFiles.py | 1,111 | 4.5 | 4 | # python has a built in function called open which can be used to open files.
myfile = open('test.txt')
content = myfile.read() # this function will read the file.
# resets the cursor back to beginning of text file so we can read it again.
myfile.seek(0)
print(content)
content = myfile.readlines()
myfile.seek(0)
fo... | true |
26d1023d423f31e9ddaccfcedaae9c82896dbe89 | viniciusvilarads/codigos-p1 | /Lista 3 - FIP/Lista 3 - Ex008.py | 816 | 4.3125 | 4 | """
Vinícius Vilar - ADS UNIFIP - Programação 1 - Lista 3 Estrutura de Decisão
Patos - PB | 2020
8 - Faça um programa que pergunte o preço de três produtos e informe qual
produto você deve comprar, sabendo que a decisão é sempre pelo mais barato.
"""
prod1 = float(input("Informe o preço do produto 1: "))
prod2 = flo... | false |
7f2ab64632cbed0280942876ddbee9e92827375b | viniciusvilarads/codigos-p1 | /Lista 4 - FIP/Lista 4 - Ex003.py | 649 | 4.1875 | 4 | """
Vinícius Vilar - ADS UNIFIP - Programação 1 - Lista 4 Estrutura de Decisão
Patos - PB | 2020
3 - Faça um Programa que leia um número e exiba o dia correspondente da semana.
(1-Domingo, 2- Segunda, etc.), se digitar outro valor deve aparecer valor
inválido.
"""
numero = int(input("Informe um número inteiro: "))
i... | false |
9d2b79e92b1441856c645e3a34eb9a062dd6a5cd | marcinlaskowski/szkolenieZDDATA | /Zadania2/obiektowo_zad4.py | 2,153 | 4.40625 | 4 | """
Stwórz klasę Pojazd z atrybutami: kolor, cena. Klasę Samochód i Rower, obie dziedziczące po klasie Pojazd.
Stwórz kilka obiektów klasy Samochód i Rower. Stwórz listę pojazdy, w której znajdą się stworzone obiekty.
Wśród wszystkich pojazdów znajdź najdroższy pojazd, wypisz średnią cenę samochodu.
"""
class Vehic... | false |
745672e96a8d12e6f20f7d696c675c90f06761eb | lvraikkonen/GoodCode | /leetcode/232_implement_queue_using_stacks.py | 1,989 | 4.40625 | 4 | # Stack implementation by list
class MyStack:
"""
栈的说明
栈是一个线性的数据结构
栈遵循LIFO的原则,Last In First Out , 即后进先出
栈顶为top,栈底为base
"""
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
... | false |
ce51c27893b378bd6abb314ad4926e17637c6228 | SmischenkoB/campus_2018_python | /Dmytro_Shalimov/1/9.py | 2,110 | 4.3125 | 4 | <<<<<<< HEAD
print("Convert a 24-hour time to a 12-hour time.")
print("Time must be validated.")
user_input = input("Enter time: ")
formatted_time = str()
if len(user_input) != 5:
print("not valid time")
hours = user_input[:2]
minutes = user_input[3:]
if hours.isnumeric() and minutes.isnumeric():
hou... | true |
425c4137611ae13aee9d24a486040bc9e565edd8 | SmischenkoB/campus_2018_python | /Dmytro_Skorobohatskyi/batch_3/verify_brackets.py | 1,004 | 4.3125 | 4 | def verify_brackets(string):
""" Function verify closing of brackets, parentheses, braces.
Args:
string(str): a string containing brackets [], braces {},
parentheses (), or any combination thereof
Returns:
bool: Return True if all brackets are closed, otherwise... | true |
92cbac43042872e865e36942ce164e1d5fdb0d40 | SmischenkoB/campus_2018_python | /Kyrylo_Yeremenko/2/task7.py | 2,517 | 4.21875 | 4 | """
This script solves task 2.7 from Coding Campus 2018 Python course
(Run length encoding)
"""
def write_char_to_list(last_character, character_count):
"""
Convenience function to form character and count pairs for RLE encode
:param last_character: Character occurred on previous iteration
:... | true |
c1ea2fc8c755e9ca87fb78c8938a01c82d1e302c | SmischenkoB/campus_2018_python | /Kyrylo_Yeremenko/3/task1.py | 2,019 | 4.1875 | 4 | """
This script solves task 3.1 from Coding Campus 2018 Python course
(Spell number)
"""
NUM_POWS_OF_TEN = {100: 'Hundred', 1000: 'Thousand', 1000000: 'Million'}
NUMS = \
{
0: "Zero",
1: "One",
2: "Two",
3: "Three",
4: "Four",
5: "Five",
6: "Six... | false |
c955386992b1cf118dd6b8c1ffb792c98a12012e | SmischenkoB/campus_2018_python | /Dmytro_Shalimov/1/8.py | 1,062 | 4.125 | 4 | <<<<<<< HEAD
print("Validate a 24 hours time string.")
user_input = input("Enter time: ")
if len(user_input) != 5:
print(False)
hours = user_input[:2]
minutes = user_input[3:]
if hours.isnumeric() and minutes.isnumeric():
hours_in_int = int(hours)
minutes_in_int = int(minutes)
if hours_in_... | true |
92295f2ad2b0ed8ff4d35474780dba9dc88e16e5 | SmischenkoB/campus_2018_python | /Kateryna_Liukina/3/3.5 Verify brackets.py | 766 | 4.25 | 4 | def verify_brackets(string):
"""
Function verify brackets
Args:
string(str): string to verify brackets
Returns:
bool: return true if all brackets are closed and are in right order
"""
brackets_opening = ('(', '[', '{')
brackets_closing = (')', ']', '}')
brackets_dict = di... | true |
2d9d5ecb3a53c62da62052da5f849c71384a0300 | SmischenkoB/campus_2018_python | /Mykola_Horetskyi/3/Crypto Square.py | 1,074 | 4.125 | 4 | import math
def encode(string):
"""
Encodes string with crypto square method
Args:
string (str) string to be encoded
Returns:
(str) encoded string
"""
encoded_string = "".join([character.lower() for character in string
if character.isalpha()])
... | true |
e63105840c53f6e3ea05835cb8a67afe38e741cc | SmischenkoB/campus_2018_python | /Lilia_Panchenko/1/Task7.py | 643 | 4.25 | 4 | import string
input_str = input('Your message: ')
for_question = 'Sure.'
for_yelling = 'Whoa, chill out!'
for_yelling_question = "Calm down, I know what I'm doing!"
for_saying_anything = 'Fine. Be that way!'
whatever = 'Whatever.'
is_question = False
if ('?' in input_str):
is_question = True
is_yelling = True
ha... | true |
3f2039d4698f8b153ef13deaee6ec80e266dae3c | SmischenkoB/campus_2018_python | /Yurii_Smazhnyi/2/FindTheOddInt.py | 402 | 4.21875 | 4 | def find_odd_int(sequence):
"""
Finds and returns first number that entries odd count of times
@param sequence: sequnce to search in
@returns: first number that entries odd count of times
"""
for i in sequence:
int_count = sequence.count(i)
if int_count % 2:
retu... | true |
5fbf80dd6b1bc1268272eb9e79c6c6e792dcc680 | SmischenkoB/campus_2018_python | /Tihran_Katolikian/2/CustomMap.py | 606 | 4.3125 | 4 | def custom_map(func, *iterables):
"""
Invokes func passing as arguments tuples made from *iterables argument.
:param func: a function which expects len(*iterables) number of arguments
:param *iterables: any number of iterables
:return: list filled with results returned by func argument. length of l... | true |
8b4e88df052850d51cc6541535b0d4dddcdf2a0a | SmischenkoB/campus_2018_python | /Lilia_Panchenko/2/Allergies.py | 1,075 | 4.21875 | 4 | def two_pow(pow):
"""
two_pow(pow)
This function returns 2 in pow 'pow'
Args:
pow (int): pow to perform
Returns:
int: result of performing pow 'pow' on base 2
"""
return 2**pow
def allergies(score):
"""
allergies(score)
This function returns list of person's allergies
Args:
... | false |
03cd271429808ad9cf1ca520f8463a99e91c9321 | SmischenkoB/campus_2018_python | /Tihran_Katolikian/2/FindTheOddInt.py | 1,183 | 4.375 | 4 | def find_odd_in_one_way(list_of_numbers):
"""
Finds an integer that present in the list_of_number odd number of times
This function works as efficient as possible for this task
:param list_of_numbers: a list of integers in which must be at least one integer
which has odd number of copies there
... | true |
a19c8d2bf61250e9789f95a202f86dafbe371166 | SmischenkoB/campus_2018_python | /Ruslan_Neshta/3/VerifyBrackets.py | 897 | 4.3125 | 4 | def verify(string):
"""
Verifies brackets, braces and parentheses
:param string: text
:return: is brackets/braces/parentheses matched
:rtype: bool
"""
stack = []
is_valid = True
for ch in string:
if ch == '(' or ch == '[' or ch == '{':
stack.append(ch)
... | true |
6855d88767abbe577f76e8263f5b1ec6aa9a6dee | SmischenkoB/campus_2018_python | /Dmytro_Skorobohatskyi/2/armstrong_numbers.py | 917 | 4.125 | 4 | def amount_digits(number):
""" Function recognize amount of digit in number.
Args:
number(int): specified number
Returns:
int: amount of digits in number
"""
counter = 0
while number != 0:
counter += 1
number //= 10
return counter
def chec... | true |
05cbb9c991b61b3ad9fbe22fff411cb2ff6bba81 | SmischenkoB/campus_2018_python | /Mykola_Horetskyi/2/Run length encoding.py | 1,459 | 4.4375 | 4 | def rle_encode(original_string):
"""
Encodes string using run-length encoding
Args:
original_string (str) string to encode
Returns:
(str) encoded string
"""
encoded_string = ''
current_character = ''
character_count = 0
for character in original_string:
if char... | false |
9879e700bccb8329e9a1b5e5ddca71abfb0aa7ba | SmischenkoB/campus_2018_python | /Dmytro_Shalimov/2/1.py | 1,338 | 4.4375 | 4 | from collections import Counter
print("Given an array, find the int that appears an odd number of times.")
print("There will always be only one integer that appears an odd number of times.")
print("Do it in 3 different ways (create a separate function for each solution).")
def find_odd_number_1(sequence):
... | true |
3c2510888352bd0867e04bf557b473af4b4ecfa9 | SmischenkoB/campus_2018_python | /Kyrylo_Yeremenko/3/task5.py | 858 | 4.46875 | 4 | """
This script solves task 3.5 from Coding Campus 2018 Python course
(Verify brackets)
"""
brackets = \
{
'{': '}',
'[': ']',
'(': ')'
}
def verify_brackets(string):
"""
Verify that all brackets in string are paired and matched correctly
:param string: Inp... | true |
c45867f3199dbb730ae4764ece11d7a4742af826 | walton0193/cti110 | /P3HW2_BasicMath_WaltonKenneth.py | 1,198 | 4.1875 | 4 | #This program is a calculator
#It performs basic math operations
#CTI - 110
#P3HW2 - BasicMath
#Kenneth Walton
#17 March 2020
def add(number1, number2):
return number1 + number2
def subtract(number1, number2):
return number1 - number2
def multiply(number1, number2):
return number1 * number2
pr... | true |
b0c99ad473d14d8488a904db839ca328c1cceb1d | Patricia-Henry/tip-calculator-in-python- | /tip_calculator_final.py | 440 | 4.28125 | 4 | print("Welcome to the Tip Calculator")
bill_total = float(input("What was the bill total? $"))
print(bill_total)
tip = int(input("How much of a tip do you wish to leave? 10, 12, 15 \n"))
people_eating = int(input("How many people are splitting the bill?"))
percentage_tip = tip / 100
tip_amount = bill_total * ... | true |
28fcd79f93af5e8516506dcb1402152ff26b9cfb | samdoty/smor-gas-bord | /morty.py | 995 | 4.28125 | 4 | # If you run this there is a bunch of intro stuff that will print
a = 10
print(a + a)
my_income = 100
tax_rate = 0.1
my_taxes = my_income * tax_rate
print(my_taxes)
print('hello \nworld')
print('hello \tworld')
print(len('hello'))
print(len('I am'))
mystring = "Hello World"
print(mystring[2])
print(mystrin... | true |
d928744c32bde2b1aa046090a2fac343b2faf10d | SallyM/implemented_algorithms | /merge_sort.py | 1,458 | 4.1875 | 4 | def merge_sort(input_list):
# splitting original list in half, then each part in half thru recursion
# until left and right are each one-element lists
if len(input_list) > 1:
# print 'len(input_list)= {}'.format(len(input_list))
split = len(input_list)//2
left = input_list[: split]
... | true |
6f74a09eb4b76315055d796874feeb993514e8f7 | USFMumaAnalyticsTeam/Kattis | /Autori.py | 590 | 4.1875 | 4 | # This python code is meant to take a single string that is in a
# long naming variation (ex. Apple-Boy-Cat) and change it
# to a short variation (ex. ABC)
import sys
# Receive user input as string
long_var = input()
# Verify user input is no more than 100 characters
if (long_var.count('') > 100):
sys.e... | true |
e9c7187e3f56e6bd0dd46ac18c0ff70b879eb0b0 | sahilshah1/algorithm-impls | /course_schedule_ii.py | 2,497 | 4.15625 | 4 | # There are a total of n courses you have to take, labeled from 0 to n - 1.
#
# Some courses may have prerequisites, for example to take course 0 you have
# to first take course 1, which is expressed as a pair: [0,1]
#
# Given the total number of courses and a list of prerequisite pairs,
# return the ordering of course... | true |
81f3c89de7aebd1d982e710bdf87ad9e62334f5e | heyese/python_jumpstart | /birthday.py | 1,973 | 4.34375 | 4 | import datetime
def get_birth_date():
print('Please tell me when you were born:')
year = int(input('Year [YYYY]: '))
month = int(input('Month [mm]: '))
day = int(input('Day [dd]: '))
print('\n')
bdate = datetime.date(year, month, day)
return bdate
def is_a_leap_year(year):
leap_year ... | false |
52d0586ed3cdbe18346e70d45883b74ec929e6c7 | pavankalyannv/Python3-Problems | /HackerRank.py | 1,718 | 4.34375 | 4 | Problme: @HackerRank
==========
Given the names and grades for each student in a Physics class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.
Note: If there are multiple students with the same grade, order their names alphabetically and print each name... | true |
944f2a67f38f40370b64c9e97914e355009b9c6b | lixuanhong/LeetCode | /LongestSubstring.py | 979 | 4.15625 | 4 | """
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substri... | true |
6a9652efd51c9215b6a00cc5b1a626c971d2313a | lixuanhong/LeetCode | /IntegerToEnglishWords.py | 1,974 | 4.125 | 4 | """
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.
Example 1:
Input: 123
Output: "One Hundred Twenty Three"
Example 2:
Input: 12345
Output: "Twelve Thousand Three Hundred Forty Five"
Example 3:
Input: 1234567
Output: "One Million Two Hundred Th... | false |
73cc42b9f05f5b83b6e81cee8f3aa2ad1ac786b8 | bo-boka/python-tools | /NumberTools/iterate.py | 1,265 | 4.1875 | 4 | def print_multiples(n, high):
i = 1
while i <= high:
print n*i, '\t',
i += 1
print
def print_mult_table(high):
i = 1
while i <= high:
print_multiples(i, high)
i += 1
def print_digits(n):
"""
>>> print_digits(13789)
9 8 7 3 1
>>> print_digits(39... | false |
df7978f0c6a2f0959ecf5ead00a2d05f18325b10 | gauravdhmj/Project | /if programfile.py | 2,761 | 4.1875 | 4 | name = input("please enter your name:")
age = input("How old are you, {0}".format(name))
age = int(input("how old are you, {0}".format(name)))
print(age)
# USE OF IF SYNTAX
if age >= 18:
print("you are old enough to vote")
print("please put an x in the ballot box")
else:
print("please come back aft... | true |
bdf2b0fe68c75b4e9c5fe1c1173ebd19fa8cf5ff | CHS-computer-science-2/python2ChatBot | /chatBot1.py | 808 | 4.40625 | 4 | #This is the starter code for the Chatbot
# <Your Name Here>
#This is a chatbot and this is a comment, not executed by the program
#Extend it to make the computer ask for your favorite movie and respond accordingly!
def main():
print('Hello this is your computer...what is your favorite number?')
#Declaring our... | true |
a66ee557c0557d6dfe61852771995e3143b74022 | thatdruth/Drew-Lewis-FinalCode | /ExponentFunction.py | 247 | 4.40625 | 4 |
print(3**3) #Easy exponent
def raise_to_power(base_num, pow_num):
result = 1
for index in range(pow_num):
result = result * base_num
return result
print(raise_to_power(4,3)) #A coded loop exponent function
| true |
f97a33df94c0b8bf5424a74bef1d7cc584b7bfb7 | GabrielDaKing/Amateur_ML | /amateur_ml/regression/linear.py | 1,448 | 4.34375 | 4 | class Linear:
"""
A class to handle the basic training and pridiction capability
of a Linear Regression model while storing the slope and intercept.
"""
def __init__(self):
self.slope = 0
self.intercept = 0
def fit(self, x, y):
"""
A function to set the slope a... | true |
6cbb8bcbc7196063a08f9c9caf5b13433aa1ba05 | kiranrraj/100Days_Of_Coding | /Day_62/zip_in_python.py | 698 | 4.15625 | 4 | # Title : Zip function in python
# Author : Kiran Raj R.
# Date : 11:11:2020
languages = ["Malayalam", "tamil", "hindi", "english", "spanish"]
popularity = [10, 20, 50, 100, 40]
area = ['kerala', 'tamil nadu', 'north india', 'world', 'spain']
name =['kiran', 'vishnu', 'manu', 'sivan']
age = [32, 25,24]
first_zip ... | false |
ef7fc6de72d7f28fe6dacb3ad4c2edfcebce3d3d | kiranrraj/100Days_Of_Coding | /Day_59/delete_elemt_linked_list_frnt_back.py | 1,971 | 4.375 | 4 | # Title : Linked list :- delete element at front and back of a list
# Author : Kiran raj R.
# Date : 30:10:2020
class Node:
"""Create a node with value provided, the pointer to next is set to None"""
def __init__(self, value):
self.value = value
self.next = None
class Simply_linked_list:
... | true |
854616d109a06681b8765657cb5ba0e47689484f | kiranrraj/100Days_Of_Coding | /Day_12/dict_into_list.py | 537 | 4.15625 | 4 | # Title : Convert dictionary key and values into a new list
# Author : Kiran raj R.
# Date : 26:10:2020
# method 1 using dict.keys() and dict.values()
main_dict = {'a': 'apple', 'b': 'ball',
'c': 'cat', 'd': 'dog', 'e': 'elephant'}
list_keys = list(main_dict.keys())
list_values = list(main_dict.values... | true |
19ea68c556c52b616ab33e76b24e779a21a8bc08 | kiranrraj/100Days_Of_Coding | /Day_7/count_items_string.py | 998 | 4.1875 | 4 | # Title : Find the number of upper, lower, numbers in a string
# Author : Kiran raj R.
# Date : 21:10:2020
import string
def count_items(words):
word_list = words.split()
upper_count = lower_count = num_count = special_count = 0
length_wo_space = 0
for word in words:
word = word.rstrip()... | true |
ec074f7136a4a786840144495d61960430c61c1c | kiranrraj/100Days_Of_Coding | /Day_26/linked_list_insert.py | 1,340 | 4.125 | 4 | # Title : Linked list insert element
# Author : Kiran Raj R.
# Date : 09:11:2020
class Node:
def __init__(self,data):
self.next = None
self.data = data
class LinkedList:
def __init__(self):
self.head = None
def print_list(self):
start = self.head
while start:
... | true |
25ee94661cc1cce075df1356cbd9e9c76c9eb2be | kiranrraj/100Days_Of_Coding | /Day_47/check_tri_angle.py | 402 | 4.21875 | 4 | # Title : Triangle or not
# Author : Kiran Raj R.
# Date : 30/11/2020
angles = []
total = 0
for i in range(3):
val = float(input(f"Enter the angle of side {i}: "))
angles.append(val)
total = sum(angles);
# print(total)
if total == 180 and angles[0] != 0 and angles[1] != 0 and angles[2] != 0:
print("Va... | true |
037d537dcac93a71179b8e44f66441384778bc4e | kiranrraj/100Days_Of_Coding | /Day_52/palindrome.py | 442 | 4.125 | 4 | # Title : Palindrome
# Author : Kiran raj R.
# Date : 19:10:2020
userInput = input("Enter a number or word to check whether it is palinfrome or note :").strip()
reverse_ui = userInput[-1::-1]
# if userInput == reverse_ui:
# print(f"'{userInput}' is a palindrome")
# else:
# print(f"'{userInput}' is not a pa... | false |
13917f87c5fd24ee4f0f90bc0d5152aa2dccce83 | priyankaVi/Python | /challenge 3 #strings.py | 1,983 | 4.4375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
###challenge3 STRINGSabs
# In[ ]:
020
## Ask the user to enter their first name
##and then display the length of their name
# In[2]:
user=input("nter the first name")
len(user)
# In[ ]:
021
#Ask the user to enter their first name
#and then ask t... | true |
4e78133f183038327019c656f1671b0c0c04d38c | dimaswahabp/Kumpulan-Catatan-Fundamental | /KumpulanCatatan/Daynote10.py | 2,614 | 4.25 | 4 | #10.1.1 How to make class
class Mobil:
warna = 'merah'
tahun = 2010
mobil1 = Mobil()
print(mobil1.warna)
print(vars(mobil1))
#10.1.2 How to make class properties
class MobilCustom():
def __init__(self, warna, tahun):
self.color = warna
self.year = tahun
mobil1 = MobilCust... | false |
51f346a94b5b7df4ae2b093dabfd75fe076b2624 | andrefabricio-f/mateapp-clase-03 | /operaciones incrementadas.py | 234 | 4.125 | 4 | #Operaciones con Incremento
a = 23
print("a=23 -->", a)
a=a+1
print("a=a+1 -->", a)
a+=1
print("a+=1 -->", a)
#a++ -> ERROR
a*=2
print("a*=2 -->", a)
a/=2
print("a/=2 -->", a)
a-=2
print("a-=1 -->", a)
a**=2
print("a**=1 -->", a)
| false |
04ae203c5141337886d98e9902d3f91a09213988 | arturblch/game_patterns | /result/command.py | 1,848 | 4.34375 | 4 | # TODO: Улучшить обработчик ввода (InputHandler) описанный ниже.
# 1. Необходимо добавить возможность измение настройки кнопок. (Например поставить выстрел на ПКМ.)
# 2* Добавить возможность передавать в метод параметр(ы). (Например можно передавать юнит, который будет выполнять, команду)
# 3* Для возможности реализова... | false |
8ebf60db3e82ed6276dadbf80487e09d5006f397 | zhongziqi/python_study | /python_cases/case_9.py | 246 | 4.15625 | 4 | # -*- coding: UTF-8 -*-
# 等三秒打印我爱你
import time
obj = {'a':'i like you','b':'i love you'}
# print dict.values(obj)
# print dict.keys(obj)
# print dict.values(obj)
for key,value in dict.items(obj):
print value
time.sleep(3)
| false |
dfa353728f27230e57cde4ea7d3ed84d0746527a | ramlaxman/Interview_Practice | /Strings/reverse_string.py | 548 | 4.21875 | 4 | # Reverse a String iteratively and recursively
def reverse_iteratively(string):
new_string = str()
for char in reversed(string):
new_string += char
return new_string
def test_reverse_iteratively():
assert reverse_iteratively('whats up') == 'pu stahw'
def reverse_recursively(string):
prin... | true |
799e14b86ce12ec280138c525258ffb8094bd399 | nickLuk/python_home | /16_1home2.py | 803 | 4.125 | 4 | # Програма пошуку святкових днів
day = int(input("Введіть день місяця: "))
mount = int(input("Введіть місяць: "))
def holy(day, mount):
if day == 1 and mount == 1:
print("<<<Новий рік>>")
elif day == 7 and mount == 1:
print("<<<Різдво>>>")
elif day == 8 and mount == 3:
print("<<<Мі... | false |
d516b1c2b45bf8145759ba5ae676f24c1c7384ce | ahmad-elkhawaldeh/ICS3U-Unit-4-03-python | /loop3.py | 779 | 4.5 | 4 | #!/usr/bin/env python3
# Created by: Ahmad El-khawaldeh
# Created on: Dec 2020
# a program that accepts a positive integer;
# then calculates the square (power of 2) of each integer from 0 to this number
def main():
# input
positive_integer = print(" Enter how many times to repeat ")
positive_string = ... | true |
88e33f77320d763870cd15d893ca18866b8daa3d | carlosmgc2003/guia1paradigmas5 | /ejercicio4.py | 876 | 4.15625 | 4 | #Escribir un programa que reciba como parametro un string de elementtos separados por coma y retorne
#una lista conteniendo cada elemento.
def formatear_lista(lista : list) -> list:
return list(map(lista_from_string, lista))
#Modificar la funcion anterior pero obteniendo correctamente cada dato segun su tipo, da... | false |
93e6f42a043dccbdee8a819d44eb6e5367f7ff1d | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/funções/desafio 104.py | 600 | 4.15625 | 4 | # Crie um programa que tenha a função leiaInt(),
# que vai funcionar de forma semelhante ‘
# a função input() do Python, só que fazendo a
# validação para aceitar apenas um valor numérico. Ex: n = leiaInt(‘Digite um n: ‘)
def leiaint(msg):
ok = False
v = 0
while True:
n = str(input(msg))
if... | false |
8d4ece54c9eec19652392378331799d49966efe3 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 14/desafio 059.py | 1,245 | 4.125 | 4 | #Crie um programa que leia dois valores e mostre um menu na tela:
'''[ 1 ] somar
[ 2 ] multiplicar
[ 3 ] maior
[ 4 ] novos números
[ 5 ] sair do programa'''
#Seu programa deverá realizar a operação solicitada em cada caso.
from time import sleep
print('MENU')
v1 = float(input('Digite um valor:'))
v2 = float(input('Digi... | false |
baf5351dc7f66539d19f62e1fa9069fa5faca834 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 9/desafio 022.py | 966 | 4.28125 | 4 | #crie um programa que leia o nome completo de uma pessoa e mostre na tela:
#o nome com todas as letras maiusculas
#o nome com todas as letras minusculas
#quantas letras tem ao todo sem comsiderar os espaços
#quantas letras tem o primeiro nome
nome = str(input('Digite seu nome completo:')).strip()
print('Seu nome em mai... | false |
beb1c1a8624e6f434571c831c831b82f247921b6 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 12/desafio 041.py | 905 | 4.28125 | 4 | #A Confederação Nacional de Natação precisa de um programa que leia o ano de nascimento de um atleta
#E mostre sua categoria, de acordo com a idade:
'''Até 9 anos: MIRIM ;Até 14 anos: INFANTIL; Até 19 anos: JÚNIOR; Até 25 anos: SÊNIOR; Acima de 25 anos: MASTER'''
from datetime import date
ano = int(input('Qual ano voce... | false |
c0c7507d3d351d1cdd4dff4624acef7f54b4b52f | bikash-das/pythonprograms | /practice/check_list.py | 1,293 | 4.21875 | 4 | def is_part_of_series(lst):
'''
:param: lst - input is the set of integers (list)
:output: returns true if the list is a part of the series defined by the following.
f(0) = 0 f(1) = 1 f(n) = 2*f(n-1) - 2*f(n-2) for all n > 1.
'''
assert(len(lst) > 0)
if(lst[0] != 0):... | true |
3ad3950e0d0b1cef1791b7563714f3ffec93d4ac | bikash-das/pythonprograms | /tkinter/ch-1/clickEvent2.py | 761 | 4.3125 | 4 | import tkinter as tk
from tkinter import ttk
# create an instance of window (tk)
win = tk.Tk() # creates an empty window
# action for button click
def click():
btn.configure(text = "Hello " + name.get()) # get() to retrive the name from the text field
# create a Label
ttk.Label(win, text = "Enter a name: ").... | true |
5e9c092473f6f2e780979df5f11b74d30db9d346 | bikash-das/pythonprograms | /ds/linkedlist.py | 1,233 | 4.15625 | 4 | class node:
def __init__(self,data):
self.value = data
self.next=None;
class LinkedList:
def __init__(self):
self.start = None;
def insert_last(self,value):
newNode = node(value)
if(self.start == None):
self.start = newNode;
else:
... | true |
b1578b627b3cd2f2f6675c4cab839c7665211440 | ToxicMushroom/bvp-python | /oefensessie 1/oefening4.py | 366 | 4.28125 | 4 | # first vector
x1 = float(input("Enter x-coordinate of the first vector: "))
y1 = float(input("Enter y-coordinate of the first vector: "))
# second vector
x2 = float(input("Enter x-coordinate of the second vector: "))
y2 = float(input("Enter y-coordinate of the second vector: "))
inwendig_product = x1 * x2 + y1 * y2
... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.