blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
0f4d4cb8f7f45575b5ba4d04757db25a09d0c79e | DrFeederino/python_scripts | /password_randomizer.py | 2,820 | 4.28125 | 4 | """
This module to randomize passwords for your own or user's usages.
Supports for custom or default (8-16) lengths of passwords. Can be used
both as a standalone program or imported to your project.
Example:
For default length:
$ python3 password_randomizer.py
For a variable length:
$ python3 pass... | true |
8a4dcdb0d69d1c5ef779637dab859e3c68bde45f | Ameliarate16/python-programming | /unit-2/homework/highest.py | 220 | 4.28125 | 4 | #Given a list of numbers, find the largest number in the list
num_list = [1, 2, 3, 17, 5, 9, 13, 12, 11, 4]
highest = num_list[0]
for number in num_list:
if number > highest:
highest = number
print(highest) | true |
180727f1c1ed8730bcf31e95b5b36409fe7da25d | Ameliarate16/python-programming | /unit-2/functions.py | 905 | 4.15625 | 4 | '''
def add_two():
result = 5 + 5
print(result)
#passing arguments
def add_two(a, b):
result = a + b
print(result)
#returning the value
def add_two(a, b):
result = a + b
return result
print(add_two(3, 10))
'''
#write a function that returns the sum of the integers in a list
def sum_list(a_li... | true |
3a4c0903706acf84bb11dbea0ee1fa1b4074c2d1 | MNikov/Python-Advanced-September-2020 | /Lists_as_Stacks_and_Queues/06E_balanced_parentheses.py | 849 | 4.15625 | 4 | def check_balanced_parentheses(expression):
stack = []
is_valid = True
opening_parentheses = ['(', '[', '{']
closing_parentheses = [')', ']', '}']
for char in expression:
if char in opening_parentheses:
stack.append(char)
elif char in closing_parentheses:
if l... | false |
72e333744b418ea8cb9202e32544bcea68db4c0e | MNikov/Python-Advanced-September-2020 | /Old/Python-Advanced-Preliminary-Homeworks/Exams/Python Advanced Exam Preparation - 18 February 2020/03. Magic Triangle.py | 460 | 4.125 | 4 | # ВЗЕТ КОД ОТ СТАРО УПРАЖНЕНИЕ, В STACKOVERFLOW ИМА РАЗЛИЧНИ РЕШЕНИЯ(PASCAL/BINOMIAL TRIANGLE), НО СА С ПО-СЛОЖЕН ПОДХОД
def get_magic_triangle(rows):
triangle = [[1] * i for i in range(1, rows + 1)]
for row in range(2, rows):
for col in range(1, row):
triangle[row][col] = triangle[row - 1][... | false |
7c5f074599d8e75323b73f52097d1fdc3ef90c18 | nathanaelchun/code-is-awesome | /2020-07-30/Calculator_V1.py | 430 | 4.1875 | 4 | number1 = input("Enter a random number:")
operation = input("Enter a operation:")
number2 = input("Enter a random number:")
number1a = int(number1)
number2a = int(number2)
if operation == "+":
answer = number1a+number2a
elif operation == "-":
answer = number1a-number2a
elif operation == "*":
answer = number... | false |
bd947bf7410ca64c210a42e5a278aada8b949131 | HEroKuma/leetcode | /1005-univalued-binary-tree/univalued-binary-tree.py | 1,029 | 4.21875 | 4 | # A binary tree is univalued if every node in the tree has the same value.
#
# Return true if and only if the given tree is univalued.
#
#
#
# Example 1:
#
#
# Input: [1,1,1,1,1,null,1]
# Output: true
#
#
#
# Example 2:
#
#
# Input: [2,2,2,5,2]
# Output: false
#
#
#
#
#
# Note:
#
#
# The number of nodes... | true |
fbc4ac57f264a917f6b57f50991be8360191af16 | euggrie/w3resources_python_exercises | /Strings/exercise14.py | 822 | 4.25 | 4 | ###############################
# #
# Exercise 14 #
# www.w3resource.com #
###############################
... | true |
e0d3ed27dd48792145a724db61e2ecb9ab9c66a6 | euggrie/w3resources_python_exercises | /Basic/exercise12.py | 794 | 4.25 | 4 | ###############################
# #
# Exercise 12 #
# www.w3resource.com #
###############################
... | true |
7e0c0e825e7db2e8d1f4d6690d5def4791b288b5 | euggrie/w3resources_python_exercises | /Strings/exercise10.py | 816 | 4.25 | 4 | ###############################
# #
# Exercise 10 #
# www.w3resource.com #
###############################
... | true |
0962e1e56e5f9eb01a86f2fdf8d34dac129c65f2 | euggrie/w3resources_python_exercises | /Strings/exercise11.py | 685 | 4.34375 | 4 | ###############################
# #
# Exercise 11 #
# www.w3resource.com #
###############################
... | true |
608e1f2ebe4482e6bffbd075df0b6f6725fd361c | nedssoft/Graphs | /projects/ancestor/ancestor.py | 1,823 | 4.125 | 4 |
from queue import Queue
from graph import Graph
def earliest_ancestor(ancestors, starting_node):
# Initialize a graph
graph = Graph()
# build a graph of the parents and children
# Iterate over ancestors' tuple (parent, child)
for parent, child in ancestors:
# check if the parent is not in... | true |
7094a2cb97ee65161af28d73c8610185cd91c752 | avin82/Python_foundation_with_data_structures | /swap_alternate.py | 1,095 | 4.59375 | 5 | # PROGRAM swap_alternate:
'''
Given an array of length N, swap every pair of alternate elements in the array.
You don't need to print or return anything, just change in the input array itself.
Input Format:
Line 1 : An Integer N i.e. size of array
Line 2 : N integers which are elements of the array, separated by spa... | true |
f3950dd5cf075f54278cd721781cceec557ac1fc | avin82/Python_foundation_with_data_structures | /bubble_sort.py | 1,020 | 4.5625 | 5 | # PROGRAM bubble_sort:
'''
Given a random integer array. Sort this array using bubble sort.
Change in the input array itself. You don't need to return or print elements.
Input format:
Line 1 : Integer N, Array Size
Line 2 : Array elements (separated by space)
Constraints :
1 <= N <= 10^3
Sample Input 1:
7
2 13 4 1 ... | true |
edfee79b2601268c1de74fbfbd9e40a7260451b4 | avin82/Python_foundation_with_data_structures | /array_intersection.py | 1,456 | 4.28125 | 4 | # PROGRAM array_intersection:
'''
Given two random integer arrays of size m and n, print their intersection. That is, print all the elements that are present in both the given arrays.
Input arrays can contain duplicate elements.
Note : Order of elements are not important
Input format:
Line 1 : Array 1 Size
Line 2 : ... | true |
9e7978f32832e2912c2136be6adb0de6c81f2ad3 | avin82/Python_foundation_with_data_structures | /find_reverse_of_num.py | 754 | 4.5 | 4 | # PROGRAM find_reverse_of_num:
'''
Write a program to generate the reverse of a given number N. Print the corresponding reverse number.
Input format:
Integer N
Constraints:
Time Limit: 1 second
Output format:
Corresponding reverse number
Sample Input 1:
1234
Sample Output 1:
4321
Sample Input 2:
1980
Sample Out... | true |
620d32a561fcd99b33134b584c98fe048b986389 | avin82/Python_foundation_with_data_structures | /find_nth_fibonacci_recursive.py | 683 | 4.65625 | 5 | # PROGRAM find_nth_fibonacci_recursive:
'''
Given a number n, find the nth fibonacci number.
Input Format:
A natural number n
Output Format:
nth fibonacci number
Sample Input:
4
Sample Output:
3
'''
#######################################
# Find nth Fibonacci Recursive Module #
###################################... | false |
4611752ec19471a7bb892b4c32c689e2ae4f8977 | avin82/Python_foundation_with_data_structures | /check_num_in_array_recursive.py | 1,183 | 4.15625 | 4 | # PROGRAM check_num_in_array_recursive:
'''
Given an array of length N and an integer x, you need to find if x is present in the array or not. Return true or false.
Do this recursively.
Input Format:
Line 1 : An Integer N i.e. size of array
Line 2 : N integers which are elements of the array, separated by spaces
Lin... | true |
ec10db1087d697597551771bc74c157018212c46 | avin82/Python_foundation_with_data_structures | /largest_column_sum_2d_array.py | 1,204 | 4.125 | 4 | # PROGRAM largest_column_sum_2d_array:
'''
Find the column id of the column in a 2D array with largest sum of elements.
Note: Assume that all columns are of equal length.
Input Format:
Line 1: Two integers m and n (separated by space)
Line 2: Matrix elements of each row (separated by space)
Output Format:
Column id... | true |
2bd0589eef540f182bc9e1018e0d2294a2aba576 | avin82/Python_foundation_with_data_structures | /row_wise_sum_2d_array.py | 971 | 4.21875 | 4 | # PROGRAM row_wise_sum_2d_array:
'''
Given a 2D integer array of size M*N, find and print the sum of ith row elements separated by space.
Input Format:
Line 1 : Two integers M and N (separated by space)
Line 2 : Matrix elements of each row (separated by space)
Output Format:
Sum of every ith row elements (separated ... | true |
a8b5f7ee0be1f8e6e198857a2951b86d4eb20a19 | avin82/Python_foundation_with_data_structures | /rotate_array.py | 1,129 | 4.53125 | 5 | # PROGRAM rotate_array:
'''
Given a random integer array of size n, write a function that rotates the given array by d elements (towards left).
Change in the input array itself. You don't need to return or print elements.
Input format:
Line 1 : Integer n (Array Size)
Line 2 : Array elements (separated by space)
Line... | true |
6848e1f8170f7c654e3c39b3abc276a8b13d0cde | avin82/Python_foundation_with_data_structures | /print_1_to_n.py | 381 | 4.1875 | 4 | # PROGRAM print_1_to_n:
################
# Print Module #
################
def print_till_num():
num = int(input("Input number till which you want to print all numbers starting from 1: \n"))
count = 1
while count <= num:
# DO
print(count)
count = count + 1
# ENDWHILE;
# END print_till_num.
###############... | true |
4ff603e25d455dd4a034739c41b4e11bcc982449 | avin82/Python_foundation_with_data_structures | /print_even_between_1_to_n.py | 517 | 4.375 | 4 | # PROGRAM print_even_between_1_to_n:
#####################
# Print Even Module #
#####################
def print_even_till_num_inclusive():
num = int(input("Input number to print all the even numbers between 1 and the entered number both inclusive: \n"))
start = 1
while start <= num:
# DO
if start % 2 == 0:
... | true |
55b84355e66a06f831fc6d7b251f9d41aea28824 | avin82/Python_foundation_with_data_structures | /num_pattern_four.py | 738 | 4.34375 | 4 | # PROGRAM num_pattern_four:
'''
Print the following pattern for the given N number of rows.
Pattern for N = 4
1234
123
12
1
Input format:
Integer N (Total no. of rows)
Output format:
Pattern in N lines
Sample Input:
5
Sample Output:
12345
1234
123
12
1
'''
###############################
# Print Number Pattern ... | true |
2e1812fbdb754cded3d1fb2ac9d6f99abb692947 | miaviles/Python-Fundamentals | /demo/e2.py | 490 | 4.125 | 4 | #1st SOLUTION
MIN_CRITERIA = 1
MAX_CRITERIA = 100
while True: # Infinite while loop
number = float(input("Please enter a number between 1 and 100: "))
if MIN_CRITERIA <= number <= MAX_CRITERIA:
break
print(f'The number {number} is between 1 and 100')
#SECOND SOLUTION
# MIN_CRITERIA = 1
# MAX_CRITERIA ... | false |
5ae50bd68d0f3bb83b1d800afd6985f79c7a5ca3 | evanlamberson/Get-Programming-Python | /Unit 2/Lesson10Q1.py | 1,148 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 1 11:49:04 2020
@author: evanlamberson
"""
### Lesson 10 Q10.1
# Write a program that initializes the string word = "echo", the empty tuple
# t = (), and the integer count = 3. Then, write a sequence of commands by
# using the commands you learn... | true |
a2f3c7b051cf59c45e4cbe607bcd6b36738d29e4 | djrgit/coursework | /talkpython/100-days-of-code-in-python/my_progress/day_001_datetime_module_nye_countdown.py | 794 | 4.4375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import date
from datetime import datetime
from datetime import timedelta
# datetime
today = datetime.today()
print()
print("Today: ", today)
print()
# date
todaydate = date.today()
year = todaydate.year
month = todaydate.month
day = todaydate.day
print("Tod... | false |
23275c80bbc961da2e0a3ae055aef01dfd8aa970 | KitsuneNoctus/test_cases_apr15 | /problem_one.py | 1,508 | 4.28125 | 4 | '''
Determine if a word or phrase is an isogram.
An isogram (also known as a "nonpattern word") is a word or phrase without a
repeating letter, however spaces and hyphens are allowed to appear multiple times.
Examples of isograms:
lumberjacks
background
downstream
six-year-old
The word isograms, how... | true |
13299a205c42b6ed08901a237056e38d6927d6ed | cecilmalone/lista_de_exercicios_pybr | /4_exercicios_listas/07_soma_multiplicacao.py | 464 | 4.28125 | 4 | """
7. Faça um Programa que leia um vetor de 5 números inteiros, mostre a soma, a
multiplicação e os números.
"""
count = 1
numeros = []
soma = 0
multiplicacao = 1
while count <= 5:
numero = int(input("Informe as notas: "))
numeros.append(numero)
count += 1
for numero in numeros:
soma += numero
multipl... | false |
92915ae523567d8f8b3ce1b53d3d1a8b879cdc3c | cecilmalone/lista_de_exercicios_pybr | /3_estrutura_de_repeticao/25_turma.py | 697 | 4.125 | 4 | """
25. Faça um programa que peça para n pessoas a sua idade, ao final o programa
devera verificar se a média de idade da turma varia entre 0 e 25,26 e 60 e
maior que 60; e então, dizer se a turma é jovem, adulta ou idosa, conforme a
média calculada.
"""
idades = []
idades.append(int(input("Informe a idade: ")))
w... | false |
82ccbd81e2731115a696f4befa225120274de59e | cecilmalone/lista_de_exercicios_pybr | /2_estrutura_de_decisao/20_media_tres_notas.py | 871 | 4.375 | 4 | """
20. Faça um Programa para leitura de três notas parciais de um aluno. O programa
deve calcular a média alcançada por aluno e presentar:
a. A mensagem "Aprovado", se a média for maior ou igual a 7, com a respectiva
média alcançada;
b. A mensagem "Reprovado", se a média for menor do que 7, com a respect... | false |
31cdd9f82986db34c1f9e108a2e0e95ba89d2945 | cecilmalone/lista_de_exercicios_pybr | /3_estrutura_de_repeticao/46_salto_distancia.py | 2,039 | 4.15625 | 4 | """
46. Em uma competição de salto em distância cada atleta tem direito a cinco
saltos. No final da série de saltos de cada atleta, o melhor e o pior
resultados são eliminados. O seu resultado fica sendo a média dos três
valores restantes. Você deve fazer um programa que receba o nome e as cinco
distâncias alcançad... | false |
cd5ffbdc46848cf58c13146f5d0cb0b510d7b30c | cecilmalone/lista_de_exercicios_pybr | /4_exercicios_listas/16_comissoes_vendas.py | 1,547 | 4.3125 | 4 | """
16. Utilize uma lista para resolver o problema a seguir.
Uma empresa paga seus vendedores com base em comissões. O vendedor recebe $200
por semana mais 9 por cento de suas vendas brutas daquela semana.
Por exemplo, um vendedor que teve vendas brutas de $3000 em uma semana recebe
$200 mais 9 por cento de $3000, ... | false |
e843204b28588578d284e08e901284295d73b6db | cecilmalone/lista_de_exercicios_pybr | /2_estrutura_de_decisao/16_equacao_segundo_grau.py | 1,327 | 4.25 | 4 | """
16. Faça um programa que calcule as raízes de uma equação do segundo grau, na
forma ax2 + bx + c. O programa deverá pedir os valores de a, b e c e fazer as
consistências, informando ao usuário nas seguintes situações:
a. Se o usuário informar o valor de A igual a zero, a equação não é do
segundo grau e o... | false |
21a26951cef5a26ec8a74a8ab0c5a639b1c835a0 | ChiragPatelGit/PythonLearningProjects | /Numbers_Processor.py | 416 | 4.1875 | 4 | # Numbers Processor
line = input("Enter a line of numbers - separate them with spaces:")
strings = line.split()
total = 0
substr =''
# print("strings is: ", strings)
try:
for substr in strings:
total += float(substr)
if len(strings) <= 0:
print("There was nothing to total")
els... | true |
a4fd41d397324487c11c4ec571e6d3aabdf8b6d8 | remusezequiel/Python | /paso_a_paso/diccionarios/diccionarios.py | 656 | 4.15625 | 4 | #diccionario = {"clave":valor}, donde el valor puede ser de cualquier tipo.
#Las claves seran inmutables
dic = {
'a': 55,
'b': "Roberto",
3 : 'Tres',
}
print(dic)
#Los diccionarios pueden crecer o decrecer
dic['c'] = 'nuevo string'
dic['d'] = 2
print(dic)
#Modificar
dic['a'] = 48
print(dic)
#Obtener l... | false |
cca406321cb796e6005f923529ecee0767706d8e | remusezequiel/Python | /interesanteee/Curiosidades/split-join/split.py | 922 | 4.15625 | 4 | """
Consideremos la siguiente Cadena:
"""
cadena = "Mi nombre es Ezequiel"
"""
Al utilizar la funcion split, podemos separar palabra por palabra de dicha
cadena de la siguiente forma:
"""
lista_de_la_cadena = cadena.split()
print(lista_de_la_cadena)
"""
Asi como en join, tambien podemos identificar un separador p... | false |
3111413e51ed01b45493d87f3902179ab7ca7a33 | remusezequiel/Python | /paso_a_paso/Bucles/for.py | 1,341 | 4.28125 | 4 | #Permite iterar objetos iterables, ejemplo tuplas, diccionarios, listas y strings
list = [0,1,2,3,4,5,6,7,8,9]
#Iteracion de los elementos de la lista
for i in list:
print(i)
print("----------------------------------")
new_range = range(0,10)
for i in new_range:
print(i)
print("-----------------------------... | false |
9124584d7f6f5c623c88fc14a60c1c457ed73839 | Nejel/coursera-python-specialization-repository | /1-getting-started/define function with parameter.py | 2,680 | 4.1875 | 4 | def hello(name): # в случае вызова функции без параметра hello() функция вернет ошибку
print("Hello,", name)
hello("Sashka") # "Sashka" -- фактический параметр
def hello(name = "World"): # задан параметр по умолчанию
print("Hello,", name)
hello("Sashka") # "Sashka" -- фактический параметр
# Нормальная функц... | false |
619ac5304b44679e1a044e8a7bae17fff9c5bbb0 | offenanil/introduction | /practice.py | 997 | 4.15625 | 4 | # # print("hi \n Anil")
# # print("hi \nAnil")
# # print("hello \t sir")
# # print("hello \tmam")
# name = 'abcdefghijk'
# print(name[2:])
# print(name[:3])
# print(name[3:6])
# print(name[::2])
# # slicing syntax:[start:stop:step] start is slice start number n stop is where to slice stop n step is size of jump
# print... | false |
893a41c7e43a09215a51fd1e2f5e62b55d402d89 | sanatanghosh/python-programs | /basic/nestedifelse.py | 208 | 4.28125 | 4 | x =int(input("enter a number"))
if x>=0:
if x == 0:
print("the number is neither positive nor negative")
else:
print("the number is positive")
else:
print("the number is negative") | true |
b013b4f7ccebcbaa707ed670c8e78583632e2242 | martinleeq/python-100 | /day-05/question-041.py | 516 | 4.15625 | 4 | """
问题41
有一个列表[1,2,3,4,5,6,7,8,9,10],使用map()生成一个新的列表,新的列表的元素为原来列表元素的平方
"""
def print_map():
"""
两个知识点:
1. map()函数,对传入的可迭代对象的每个元素进行迭代,对其执行传入的操作
2. labmda表达式,也就是其他语言的匿名函数,显使地使用lambda字符串
"""
pre_list = [x for x in range(1, 11)]
new_list = list(map(lambda x: x**2, pre_list))
print(new_list)... | false |
730539abaef3b6ecfadccbae63215d5f95419082 | urma/euler-project | /problem_09.py | 578 | 4.375 | 4 | #!/usr/bin/env python
# A Pythagorean triplet is a set of three natural numbers, a < b < c,
# for which, a^2 + b^2 = c^2
# For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
# There exists exactly one Pythagorean triplet for which
# a + b + c = 1000. Find the product abc.
def is_pythagorean_triplet(a, b, c):
return (a < b... | false |
75b4368dce79e4beebd0fd3771ac7bcaa1aadfbf | albertogeniola/Corso-Python-2019 | /Lecture 6/0. Simple adder.py | 365 | 4.125 | 4 | print("I am a nice adder. Please input two numbers and I will sum them")
addend_1 = input("First number:")
addend_2 = input("Second number:")
if not addend_1.isdigit() or not addend_2.isdigit():
print("Sorry: one of the inputs does not seem to be a valid integer number.")
else:
result = int(addend_1) + int(adde... | true |
a874557ed91313e3f4737e4c268e57053c771675 | AyanUpadhaya/Basic-Maths | /primenumber.py | 426 | 4.15625 | 4 | #Python Program to Find Prime Number using For Loop
#Any natural number that is not divisible by any other number except 1 and itself
#called Prime Number.
user_num=int(input("Enter a number:"))
def is_prime(num):
count=0
for i in range(2,(num//2+1)):
if num%i==0:
count+=1
break
if count==0 and num!=1:
... | true |
0418a7679705377379b20f6364f66a708b530126 | Kireetinayak/Python_programs | /Programs/Map/Find length.py | 404 | 4.25 | 4 | #The map() function applies a given function to each item of an iterable
def myfunc(n):
return len(n)
x = map(myfunc, ('apple', 'banana', 'cherry'))
print((list(x)))
def myfunc(a, b):
return a + b
x = map(myfunc, ('apple', 'banana', 'cherry'), ('orange', 'lemon', 'pineapple'))
print(list(x))
def myfunc(n):
... | true |
ec1a3f80df71a70088ab4833f709f0d842d43e8a | lalit97/DSA | /graph/topological-practice.py | 993 | 4.1875 | 4 | '''
https://www.youtube.com/watch?v=n_yl2a6n7nM
https://www.geeksforgeeks.org/topological-sorting/
https://practice.geeksforgeeks.org/problems/topological-sort/1
https://medium.com/@yasufumy/algorithm-depth-first-search-76928c065692
'''
def topoSort(n, graph):
visited = set()
stack = []
# given that no... | true |
b5bfa4b54a727951f0428316e5ffde1ba31fb80d | Priclend/Homework | /homework1/hi! I'm calculator.py | 2,926 | 4.28125 | 4 | print ("Пожалуйста, введите действие, которое вы хотите выполнить."
" Я могу производить: сложение (+), вычитание (-), умножение (*),"
" деление (/) и вычленять корни."
" Чтобы прекратить работу со мной, введите слово 'стоп'")
act = input ()
if act == "+" or act == "сложение" :
while 1:
... | false |
8bd16d3f97ebb6f3a9de5f29f5e4f52699148c71 | olcostafilipe/cracking_the_coding | /chapter02/question_02.py | 511 | 4.125 | 4 | """
Question 02: Return Kth to Last
Implement an algorithm to find the kth to last element of a list.
"""
import random
def kth_to_last(my_list: list, kth_index: int) -> list:
""" Return the kth to last element of a list """
return my_list[(kth_index - 1):]
def main():
# Example of input
my_list = ... | false |
c6f22a8617bdb7a869f72691c2b2902cb3daf719 | lgomezm/daily-coding-problem | /python/problem02.py | 640 | 4.15625 | 4 | # This problem was asked by Uber.
# Given an array of integers, return a new array such that each element
# at index i of the new array is the product of all the numbers in the
# original array except the one at i.
# For example, if our input was [1, 2, 3, 4, 5], the expected output
# would be [120, 60, 40, 30, 24].... | true |
2d5b885fd31a1e2761d76751b70ce097a49c59f7 | lgomezm/daily-coding-problem | /python/problem08.py | 1,412 | 4.28125 | 4 | # This problem was asked by Google.
# A unival tree (which stands for "universal value") is a tree where
# all nodes under it have the same value.
# Given the root to a binary tree, count the number of unival subtrees.
# For example, the following tree has 5 unival subtrees:
# 0
# / \
# 1 0
# / \
# 1 0
# ... | true |
f65d2fe7a0fcc787c5855868307afdba3df0d8b6 | vishalpatil0/Python-cwh- | /operaotr overloading and dunder method.py | 737 | 4.15625 | 4 | class Student:
def __init__(self,name,age,addr): #__init__(self)==constructor in python
self.name=name
self.age=age
self.addr=addr
def printdetails(self):
print(f"{self.name}\n{self.age}\n{self.addr}\n{self.year}")
def __add__(self, other): # dunder method overrid... | false |
e53d9addeb038d020ce876f0cf59e0c2aa8fe5df | vishalpatil0/Python-cwh- | /class in python.py | 845 | 4.21875 | 4 | #class is nothing but a template to store data
#object is the instance of the class by using object we can acces the elemnt of the class
class student:
no_of_leaves=9
pass #pass means nothing
vishal=student() #this is the way to create object in python
namrata=student()
print(f"memory location of object = ... | true |
5b68dc3a91c48e21326c8f06f5e5c7b5b1290a3a | wangyendt/LeetCode | /Contests/101-200/week 185/1418. Display Table of Food Orders in a Restaurant/Display Table of Food Orders in a Restaurant.py | 1,641 | 4.15625 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 2020/4/19 10:43
@Author: wang121ye
@File: Display Table of Food Orders in a Restaurant.py
@Software: PyCharm
"""
class Solution:
def displayTable(self, orders: list(list())) -> list(list()):
menus = sorted(list(set(a[2] for a in orders)))
... | false |
0c052658817903571506e47e54de3ee109626501 | noelleirvin/PythonProblems | /Self-taught Programmer/Ch7/Ch7_challenges.py | 1,121 | 4.28125 | 4 | #CHAPTER 7
# 1. Print each item in the following list
listOfItems = ["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"]
for show in listOfItems:
print(show)
# 2. Print all numbers from 25 to 50
# for i in range(25, 51):
# print(i)
# 3. Print each item in the list from the first challenge... | true |
2ddccd4ce17f2f4ae285d0a83396516e4e8cb8c9 | PriyankaJoshi001/DSandA | /KeyboardRow.py | 565 | 4.15625 | 4 | def findWords(words):
set1 = {'q','w','e','r','t','y','u','i','o','p'}
set2 = {'a','s','d','f','g','h','j','k','l'}
set3 = {'z','x','c','v','b','n','m'}
res = []
for i in words:
wordset = set(i.lower())
if (wordset&set1 == wordset) or (wordset&set2 == wordset) or (wo... | false |
f1468cee8de26ee04f98e0d0678ed42f69ce97a3 | dabideee13/exercises-python | /mod3_act3.py | 851 | 4.46875 | 4 | # mod3_act3.py
"""
Tasks
1. Write a word bank program.
2. The program will ask to enter a word.
3. The program will store the word in a list.
4. The program will ask if the user wants to try again. The user will
input Y/y if Yes and N/n if No.
5. If Yes, refer to step 2.
6. If No, display the total number of words... | true |
c42892dd50b96c6463b899870b52fd9ffb868bc0 | sagar412/Python-Crah-Course | /Chapter_8/greet.py | 533 | 4.1875 | 4 | # Program for greeter example using while loop, Chapter 8
def greet(first_name,last_name):
person = f"{first_name} {last_name}"
return person
while True:
print("Please enter your name and enter quit when you are done.")
f_name = input("\n Please enter your first name.")
if f_name == 'quit':
b... | true |
6e94da1bcafeb70de4cdaab83ae5f5281cdd3182 | rahulbhatia023/python | /08_Operators.py | 1,090 | 4.375 | 4 | # Arithmetic Operators
print(2 + 3)
# 5
print(9 - 8)
# 1
print(4 * 6)
# 24
print(8 / 4)
# 2.0
print(5 // 2)
# Floor Division (also called Integer Division) : Quotient when a is divided by b, rounded to the next smallest whole
# number
# 2
print(2 ** 3) # Exponentiation : a raised to the power of b
# 8
print(10 ... | true |
2cab37f6a7ea4fab967566286837d961b28a5a1a | MattAllen92/Data-Science-Basics | /Practice and Notes/The Self-Taught Programmer/Second Script.py | 2,479 | 4.21875 | 4 | # 1) Basic Functions
#def square(x, y=5):
# """
# Returns the square of the input
# :param x: int
# """
# return (x ** 2) + y
#
#print square(3)
#print square(4,2)
#print square.__doc__
#def str_to_float(x):
# try:
# return float(x)
# except:
# print("Cannot convert i... | true |
6066100934e59f803128f3415a1e9a25db9889cd | arahaanarya/PythonCrashCourse2ndEdition.6-1.Person.py | /Main.py | 472 | 4.40625 | 4 | # Use a dictionary to store information about a person
# you know. Store their first name, last name, age, and
# the city in which they live. You should have keys
# such as first_name, last_name, age, and city. Print
# each piece of information stored in your dictionary.
parents = {
"first_name": "Bruce",
"las... | true |
4d565237f40c1ce06df822757f7c5d83dc562dc9 | ShaneyMantri/Algorithms | /Heaps/Super_Ugly_Number.py | 762 | 4.1875 | 4 | """
Write a program to find the nth super ugly number.
Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k.
Example:
Input: n = 12, primes = [2,7,13,19]
Output: 32
Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12
sup... | false |
0f5dccdaad1d56be596c2b18b6c89d9a8933e940 | ShaneyMantri/Algorithms | /Heaps/Ugly_Numbers_II.py | 837 | 4.125 | 4 | """
Write a program to find the n-th ugly number.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.
Example:
Input: n = 10
Output: 12
Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers.
"""
import heapq
class Solution:
def find(self, heap, n):
... | false |
ad58c95139fd4a8c5da75c239dcbc5d38290312e | ShaneyMantri/Algorithms | /Binary Search/Minimum_Number_of_Days_to_Make_m_Bouquets.py | 2,421 | 4.15625 | 4 | """
Given an integer array bloomDay, an integer m and an integer k.
We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.
The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.
Return the minimum number ... | true |
34f5402cc1b168addfa13ad134b74f1f5c2955fd | a1403893559/rg201python | /杂物间/python基础/day07/函数参数一.py | 458 | 4.1875 | 4 | '''
思考一个问题,如下:
现在需要定义一个函数,这个函数能够完成2个数的加法运算,并且吧结果打印出来,该怎么设计?下面代码有什么缺陷?
'''
# 无参数函数
#def add2num():
# a = 11
# b = 22
# c = a + b
# print(c)
#
#add2num()
#
# 带有参数的函数
def add2num(a,b):
c = a+b
print(c)
add2num(11,22)#调用带有参数的函数时,需要在小括号中传递数据
| false |
72944d7d675e602473924b94ed270d85f0c208f2 | a1403893559/rg201python | /杂物间/python基础/day06/作业1.py | 1,162 | 4.34375 | 4 | # 创建一个字符 字符串是python 基本的数据类型之一 可以用''或者""括起来 我们需要掌握什么? 对字符串的基本增删改查的操作
#1、作业 创建一个字符串
pstr = '人生苦短,我用python,life is short,you need python'
print('该字符串的内容是%s'%pstr)
#第一个小问题是 统计字符串里面 p的个数和i的个数
# count函数 count() 统计字符串字符出现的个数
p_counts = pstr.count('p')
i_counts = pstr.count('i')
print('该字符串里面P的个数%s'%p_counts)
print('该字符串里面i的个... | false |
7be9816c8fdb2e9c859b119dc729eb525b2e861f | danielbrenden/Learning-Python | /RemoveDuplicatesFromList.py | 290 | 4.34375 | 4 | # This program removes duplicates from a list of numbers via the append method and prints the result.
numbers = [2, 4, 5, 6, 5, 7, 8, 9, 9]
unique_numbers = []
for number in numbers:
if number not in unique_numbers:
unique_numbers.append(number)
print (unique_numbers)
| true |
f9b1a50f006459852fb2bc4314a8f23ba191b37b | bhavik89/CourseraPython | /CourseEra_Python/Rock_Paper_Scissors.py | 2,301 | 4.1875 | 4 | #Mini Project 2:
# Rock-paper-scissors-lizard-Spock program
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
# library function random is imported to generate random numbe... | true |
001932fff07cf23900f82da599f858f4045951f1 | Shubhamrawat5/Python | /iterator-generator.py | 643 | 4.1875 | 4 | #ITERATOR : gives values one by one by next(iterator_object)
l=[6,4,7,9,0]
it = iter(l) #creating iterator object of list
print(next(it)) #next is function to go to next element
print(next(it))
for i in it: #loop with iterator object
print(i)
'''output:- (6 and 4 printed only once)
6
4
7
9
0
[Program finished]'''... | true |
f64f2cb09a7d6381ec1eb735d210f686d02eccb7 | decolnz/HS_higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 581 | 4.34375 | 4 | #!/usr/bin/python3
"""
print_square - prints a square with #
size: size of the square
"""
def print_square(size):
"""
Method to print a square
"""
error1 = "size must be an integer"
error2 = "size must be >= 0"
if not (isinstance(size, int)):
raise TypeError(error1)
if size < 0:
... | true |
eb2b3310bf51435dd8120f3d878bea9f1ac588e2 | vishal-1codes/python | /PYTHON LISTS_AND_DICTIONARIES/Maintaining_Order.py | 392 | 4.40625 | 4 | #In this code we find out index of any element
#using .index("name")
#also we insert element using index and value
#eg - animals.insert(2,"cobra")
animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]
duck_index = animals.index("duck")# Use index() to find "duck"
# Your code here!
animals.insert(duck_index,"... | true |
1aadd3ce06ed65bb043a63c94fde435c90cd98e5 | vishal-1codes/python | /PRACTICE_MAKES_PERFECT/digit_sum.py | 436 | 4.1875 | 4 | #In below example we first get input as a string then we apply for loop for each element in that can be join with + and also convert string element to int then return total.
def digit_sum(n):
total = 0
string_n = str(n)
for char in string_n:
total += int(char)
return total
#Alternate Solution:
#def digit_... | true |
d829d4b8c7a6f701ce066d40df1ad2f870b78e88 | sachins0023/tarzanskills | /day-2.py | 1,929 | 4.5 | 4 | print("I will now count my chickens: ") #I will now count my chickens:
print("Hens", 25+30/6) #Hens 30.0
print("Roosters",100-25*3%4) #Roosters 97
print("Now I will count the eggs: ") #Now I will count the eggs:
print(3+2+1-5+4%2-1/4+6) #6.75
print("Is it true that 3+2<5-7?... | true |
1a28f0d4d473cf62088c578f425f40619ecf838c | wtakang/class_2 | /projects/alarm_clock/alarm_clock.py | 973 | 4.1875 | 4 | #!/home/tanyi/development/pythonclass/class_2/projects/alarm_clock/bin/python3
from time import sleep
from datetime import datetime
import winsound
def set_alarm():
print('your current time is:',datetime.now().strftime('%H:%M')) # print the current time to the user before the alarm
min = int(input("Enter... | true |
eba00dc827e5fdf4bd5098872802f18decbbdf7d | kennyestrellaworks/100-days-of-code-the-complete-python-pro-bootcamp-for-2021 | /Day 3/Day-3-4-Exercise- Pizza Order/day-3-4-exercise-pizza-order.py | 1,308 | 4.25 | 4 | # 🚨 Don't change the code below 👇
print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L\n")
add_pepperoni = input("Do you want pepperoni? Y or N\n")
extra_cheese = input("Do you want extra cheese? Y or N\n")
# 🚨 Don't change the code above 👆
#Write your code below this ... | true |
a5f6ff9d546893c2b6552aaaddb324a1bf33b7d9 | kennyestrellaworks/100-days-of-code-the-complete-python-pro-bootcamp-for-2021 | /Day 4/Day-4-3-Exercise- Treasure Map/day-4-3-exercise-treasure-map.py | 781 | 4.28125 | 4 | # 🚨 Don't change the code below 👇
row1 = ["⬜️","⬜️","⬜️"]
row2 = ["⬜️","⬜️","⬜️"]
row3 = ["⬜️","⬜️","⬜️"]
map = [row1, row2, row3]
print(f"{row1}\n{row2}\n{row3}")
position = input("Where do you want to put the treasure?\n")
# 🚨 Don't change the code above 👆
#Write your code below this row 👇
empty = []
for x in ... | true |
7d92cd6287d39e641878f860c4b17b0b6d6c3048 | GarciaCS2/CSE | /GABRIELLA - GAMES/Beginner Programs/Gabriella - Hangperson, Shorter program (Beginner).py | 2,452 | 4.21875 | 4 | import random
setup = [0, 1, 2, 3]
counted_letters = [] # 0 = right_letter_count, 1 = guesses, 2 = doubles, 3 = letters_required
word_bank = ["cat", "edison", "donut", "zebra", "travel", "humor", "python", "computer", "number", "aerobic",
"math", "cow", "dog", "snow", "cake", "cough", "list", "binary", "c... | true |
f4433e3e99a94d3843f29b63463c1368bd85db17 | clash402/turtle-race | /main.py | 1,161 | 4.25 | 4 | from turtle import Turtle, Screen
import random
# PROPERTIES
screen = Screen()
screen.setup(width=500, height=400)
colors = ["red", "orange", "yellow", "green", "blue", "purple"]
random.shuffle(colors)
turtles = []
pos_y = -145
for color in colors:
turtle = Turtle("turtle")
turtle.shapesize(2)
turtle.c... | true |
53a5767fd1c27c87a91f94bfb7a42ae802ec4136 | Jacquelinediaznieto/PythonCourse | /final-project/final-project.py | 1,531 | 4.15625 | 4 | #Ask tJhe player name and store
player_name = input('What is your name? ')
#This is a list made up of questions and answers dictionaries
questions = [
{"question": "What is the capital of Germany? ",
"answer": "berlin"},
{"question": "What is the capital of Spain? ",
"answer": "madr... | true |
eaa246a72872b0f43a823f09db327c69202a9ad6 | sarkarChanchal105/Coding | /Leetcode/python/Medium/minimum-lines-to-represent-a-line-chart.py | 2,995 | 4.3125 | 4 | """
https://leetcode.com/problems/minimum-lines-to-represent-a-line-chart/
2280. Minimum Lines to Represent a Line Chart
Medium
185
368
Add to List
Share
You are given a 2D integer array stockPrices where stockPrices[i] = [dayi, pricei] indicates the price of the stock on day dayi is pricei. A line chart is create... | true |
7475f1052d034bb82d231b1bc45659bf391b9cc5 | sarkarChanchal105/Coding | /Leetcode/python/Easy/matrix-diagonal-sum.py | 1,521 | 4.40625 | 4 | """
https://leetcode.com/problems/matrix-diagonal-sum/submissions/
1572. Matrix Diagonal Sum
Easy
1204
22
Add to List
Share
Given a square matrix mat, return the sum of the matrix diagonals.
Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are no... | true |
09cf7d97cc71fa4aba589b07f418609f2a3cd354 | sarkarChanchal105/Coding | /Leetcode/python/Medium/validate-binary-search-tree.py | 1,552 | 4.1875 | 4 | """
https://leetcode.com/problems/validate-binary-search-tree/
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key.
The right subtree of a node contains only nodes with keys gre... | true |
50a0a350fb3aa861a4227044e5ac5e498847875a | Jokers01/Code_Wars | /8kyu/Beginner - Lost Without a Map.py | 391 | 4.1875 | 4 | """
Given and array of integers (x), return the array with each value doubled.
For example:
[1, 2, 3] --> [2, 4, 6]
For the beginner, try to use the map method - it comes in very handy quite a lot so is a good one to know.
"""
#answer
def maps(a):
return [ x * 2 for x in a ]
#or
def maps(a):
new_list = []... | true |
2a70ca3ca3b053c4ba4eacaffe2717522934c096 | baihaki06/py | /KelasTerbuka/Python Dasar/list.py | 772 | 4.125 | 4 | Data = [1,4,9,14,25,36,49,64]
#mengakses data
subdata = Data[3]
subdata2 = Data[-3]
subdata3 = Data[2:4]
subdata4 = Data[:4]
subdata5 = Data[:]
#cetak data
print(subdata)
print(subdata2)
print(subdata3)
print(subdata4)
print('subdata5')
print(subdata5)
#mengabungkan list
Data2 = [100,200,300,400,500,600,700,800]
Dat... | false |
c59add8de30bcc385145236694d7ec330cf386d3 | KristofferFJ/PE | /problems/unsolved_problems/test_196_prime_triplets.py | 1,058 | 4.125 | 4 | import unittest
"""
Prime triplets
Build a triangle from all positive integers in the following way:
1
2 3
4 5 6
7 8 9 1011 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 2829 30 31 32 33 34 35 3637 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
. . .
Each positive in... | true |
e3b20e979229a6f595e54a66003687e9e9de1ea3 | KristofferFJ/PE | /problems/unsolved_problems/test_309_integer_ladders.py | 873 | 4.1875 | 4 | import unittest
"""
Integer Ladders
In the classic "Crossing Ladders" problem, we are given the lengths x and y of two ladders resting on the opposite walls of a narrow, level street. We are also given the height h above the street where the two ladders cross and we are asked to find the width of the street (w).
Here... | true |
9058eb2ad8a06f152b4e292796b776bc132594af | KristofferFJ/PE | /problems/unsolved_problems/test_152_writing_1slash2_as_a_sum_of_inverse_squares.py | 854 | 4.3125 | 4 | import unittest
"""
Writing 1/2 as a sum of inverse squares
There are several ways to write the number 1/2 as a sum of inverse squares using distinct integers.
For instance, the numbers {2,3,4,5,7,12,15,20,28,35} can be used:
$$\begin{align}\dfrac{1}{2} &= \dfrac{1}{2^2} + \dfrac{1}{3^2} + \dfrac{1}{4^2} + \dfrac{1}{... | true |
0ff6187cf73b4e3ce59cea63123d4d5e5941bbac | KristofferFJ/PE | /problems/unsolved_problems/test_797_cyclogenic_polynomials.py | 928 | 4.15625 | 4 | import unittest
"""
Cyclogenic Polynomials
A monic polynomial is a single-variable polynomial in which the coefficient of highest degree is equal to 1.
Define $\mathcal{F}$ to be the set of all monic polynomials with integer coefficients (including the constant polynomial $p(x)=1$). A polynomial $p(x)\in\mathcal{F}$ ... | true |
ae296ed1c5ef3b45bc2997780d61aae7376ab3ee | KristofferFJ/PE | /problems/unsolved_problems/test_726_falling_bottles.py | 1,191 | 4.15625 | 4 | import unittest
"""
Falling bottles
Consider a stack of bottles of wine. There are $n$ layers in the stack with the top layer containing only one bottle and the bottom layer containing $n$ bottles. For $n=4$ the stack looks like the picture below.
The collapsing process happens every time a bottle is taken. A spac... | true |
75942c440659f556135d1b93074f464bd88cdc1b | KristofferFJ/PE | /problems/unsolved_problems/test_155_counting_capacitor_circuits.py | 1,148 | 4.21875 | 4 | import unittest
"""
Counting Capacitor Circuits
An electric circuit uses exclusively identical capacitors of the same value C.
The capacitors can be connected in series or in parallel to form sub-units, which can then be connected in series or in parallel with other capacitors or other sub-units to form larger sub-u... | true |
60ade4195efa8fbd6cce3ea80f0c9f512b711906 | KristofferFJ/PE | /problems/unsolved_problems/test_796_a_grand_shuffle.py | 790 | 4.125 | 4 | import unittest
"""
A Grand Shuffle
A standard $52$ card deck comprises thirteen ranks in four suits. However, modern decks have two additional Jokers, which neither have a suit nor a rank, for a total of $54$ cards. If we shuffle such a deck and draw cards without replacement, then we would need, on average, approxi... | true |
fd5834f002062fe02f75d86178696cd7886491c6 | KristofferFJ/PE | /problems/unsolved_problems/test_750_optimal_card_stacking.py | 930 | 4.1875 | 4 | import unittest
"""
Optimal Card Stacking
Card Stacking is a game on a computer starting with an array of $N$ cards labelled $1,2,\ldots,N$.
A stack of cards can be moved by dragging horizontally with the mouse to another stack but only when the resulting stack is in sequence. The goal of the game is to combine the ... | true |
3a6bc780036eba832c5c0d23bf007f45aaf47a57 | KristofferFJ/PE | /problems/archived_old_tries/test_059_xor_decryption.py | 2,606 | 4.28125 | 4 | # Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107.
# A modern encryption method is to take a text file, convert the bytes to ASCII, then XOR each byte ... | true |
7598bda86f1d88a5b10fb952862ccbe35f1336db | KristofferFJ/PE | /problems/unsolved_problems/test_066_diophantine_equation.py | 706 | 4.125 | 4 | import unittest
"""
Diophantine equation
Consider quadratic Diophantine equations of the form:
x2 – Dy2 = 1
For example, when D=13, the minimal solution in x is 6492 – 13×1802 = 1.
It can be assumed that there are no solutions in positive integers when D is square.
By finding minimal solutions in x for D = {2, 3, 5, ... | true |
1fa8ba3ddfd53d736b9699fce9c7e0ad2be30e7c | GeneKao/ita19-assignment | /02/task1.py | 767 | 4.21875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Task 1: Given two vectors, use the cross product to create a set of three orthonormal vectors.
"""
__author__ = "Gene Ting-Chun Kao"
__email__ = "kao@arch.ethz.ch"
__date__ = "29.10.2019"
def orthonormal_bases(u, v):
"""
Generate three base vectors from two ... | true |
7aa3fe452d24ed804948b6e161d6d972099c3446 | nerthul11/PythonTutorial | /_13_Funciones.py | 757 | 4.21875 | 4 | """
Aquí veremos cómo definir, estructurar y llamar una función.
En general, conviene ubicar las funciones en las primeras líneas del código, porque para poder utilizarlas
primero deben estar definidas.
Primero, vamos a definir una función que no tome parámetros:
"""
def hola_mundo():
print("Hola, mundo")
# Lue... | false |
7b419d44fa9686983dc3ebf2a9003b764d25e228 | nikadam/HangmanGamePython | /pythonGame.py | 1,938 | 4.15625 | 4 | import random
class HangmanGame(object):
words = ["guessing","apple","television","earphones",'mobile',
"apple","macbook","python","sunset",'sunrise','winter',
"opensource",'rainbow','computer','programming','science',
'python','datascience','mathematics','player','conditio... | true |
d60a229a041d8aac66662cdcb651fb9f67c3fa31 | shuoshuoge/system-development | /stuent-grade.py | 2,539 | 4.28125 | 4 |
class Student:
'''
Student(学号、姓名、性别、专业)
'''
def __init__(self, id, name, gender, major):
self.id = id
self.name = name
self.gender = gender
self.major = major
self.stuCourseGrade = dict()
self.getCredit = 0
def addCourseGrade(self, cou... | false |
4b263f6d53b6a0a58611c8ef8765f309144b2454 | cami20/calculator-2 | /calculator.py | 2,907 | 4.28125 | 4 | """A prefix-notation calculator.
Using the arithmetic.py file from Calculator Part 1, create the
calculator program yourself in this file.
"""
from arithmetic import *
# Your code goes here
# No setup
# repeat forever:
while True:
# read input
input = raw_input("> ")
# tokenize input
input_string = i... | true |
049a449464258ae55d7f8d6311de2e86ff987ced | fatimaalheeh/python_stack | /_python/assignments/Bubble_sort.py | 557 | 4.125 | 4 | def bubble_sort (List):
print("Current values are: ",List)
countswaps=0
for i in range(0,len(List)-1):
for j in range(0,len(List)-1):
if List[i] > List[j+1]:
List[j],List[j+1]=List[j+1],List[j]
countswaps +=1
print("swap",countswaps,"is: ",... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.