blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7942e0b8ab102a3a2ae845dbd0c882a9c1a50580
ronaldfalcao/pythoncodes
/factorial/factorial_recursive.py
598
4.375
4
#coding: utf-8 def factorial_recursive(x): if x == 0: return 1 elif x == 1: # Base case return 1 else: return x * factorial_recursive(x-1) # Recursive expression #Exemplo de uso da função factorial() num = int(input("Entre com um número (inteiro e positivo): ")) if (factorial_rec...
false
b74c18f10daa14b813dff047f81d76fa6fef9edc
lyoness1/skills-cd-data-structures-2
/recursion.py
2,907
4.59375
5
# --------- # # Recursion # # --------- # # 1. Write a function that uses recursion to print each item in a list. def print_item(my_list): """Prints each item in a list recursively. >>> print_item([1, 2, 3]) 1 2 3 """ if not my_list: return print my_list[0] ...
true
5b95b484392c7e58a9bf5a98cb8db1cf91e400b4
jorgeaugusto01/DataCamp
/Data Scientist with Python/21_Supervised_Learning/Cap_2/Pratices4_5.py
2,944
4.21875
4
#Train/test split for regression #As you learned in Chapter 1, train and test sets are vital to ensure that your supervised learning model # is able to generalize well to new data. This was true for classification models, and is equally true for # linear regression models. #In this exercise, you will split the Gapminde...
true
0de409619de9e651b2508a9fae5009fa10fcf226
shailsoni44/pytrain20
/pyt1.py
1,835
4.125
4
print("Question 1\n") x= 1 ; y= 2.5 ; z='string' print("Type of x:",type(x) , "\nType of y:", type(y) , "\nType of z:", type(z)) print("\nQuestion 2\n") a=(1j+2) ; b = 3 print("Assigned value of a:", a,"\nAssigned value of b:",b) a,b = b,a print("After swapping value of a is:", a , "\nAfter swapping value of b is:",...
false
e56eb114b90742ca083d9812ce7e11e5d9504c2e
daniloaleixo/30DaysChallenge_HackerRank
/Day08_DictionairesAndMaps/dic_n_maps.py
2,134
4.3125
4
# Objective # Today, we're learning about Key-Value pair mappings using a Map or Dictionary data structure. Check out the Tutorial tab for learning materials and an instructional video! # Task # Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will...
true
b8c2b94be9e48ae10bf5c47817f6af19109ced0c
LouisTuft/RSA-Calculator-and-Theory
/1.RSAValues.py
2,147
4.25
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 30 02:13:03 2020 @author: Louis """ """ The theory behind RSA is explained in the Readme file in the repository. This python file is the first of three that form a complete RSA system. This file in particular will allow you to construct your own set of keys for RSA. The...
true
b14350b1729a7ad4dca30edae721cd6f82b04d42
anirudhagaikwad/Python10Aug21
/PythonWorkPlace/Python_DataTypes/Manipulations/PythonSetExmpl.py
709
4.1875
4
# initialize A and B A = {1, 2, 3, 4, 5} B = {4, 5, 6, 7, 8} # use | operator # Output: {1, 2, 3, 4, 5, 6, 7, 8} print(A | B)#Union is performed using | operator. print(A.union(B))#union using Function #Intersection of A and B is a set of elements that are common in both sets. print(A & B) #Intersection is performe...
true
f70aa44924847d48183279a297ef6cda93f1b3d0
anirudhagaikwad/Python10Aug21
/PythonWorkPlace/Python_DataTypes/Python_Tuple.py
1,153
4.6875
5
#tuples are immutable. #defined within parentheses () where items are separated by commas #Tuple Index starts form 0 in Python. x=('python',2020,2019,'django',2018,20.06,40j,'python') #Tuple # you can show tuple using diffrent way print('Tuple x : ',x[:]) # we can use the index with slice operator [] to access an ite...
true
c3f0fe5252715fd2df8084c40d654f73913977b7
anirudhagaikwad/Python10Aug21
/PythonWorkPlace/Python_DataTypes/Python_Dictionary.py
1,315
4.5625
5
"""" dictionaries are defined within braces {} with each item being a pair in the form key:value. Key and value can be of any type. """ #keys must be of immutable type and must be unique. d = {1:'value_of_key_1','key_2':2} #Dictionary print('d is instance of Dictionary : ',isinstance(d,type(d))) #To access values,...
true
ba925036cd692feb041c9305eba8a89b438a528e
pedronet28/curso-pyton-udemy
/06-list.py
1,451
4.5625
5
#En python los arreglos son llamados list #definiendo y cargando un ana list en python #Ejemplo1 lenguajes = ['Python','Kotlin','Java','JavaScrip'] numeros = [3,5,7,2] print(lenguajes) #Ejemplo2 Aplicando método de ordenamiento #acendente y alfabetico en list de python lenguajes.sort() print(lenguajes) numeros.so...
false
a0fe310c8be1f85b9fbeb61c83c833104ebdd6ef
morganhowell95/TheFundamentalGrowthPlan
/Data Structures & Algorithms/Queues & Stacks/LLImplOfStack.py
1,460
4.28125
4
#Stack is a Last In First Out (LIFO) data structure #Data is stored by building the list "backwards" and traversing forwards to return popped values class Stack: def __init__(self): self.tail = None def push(self, d): #create new node to store data node = Stack.Node(d) #link new node "behind" the old node ...
true
b39cba591c93f4c5b772479ce76828234f751fb0
gabrielsp20/Ex_Python
/004.py
493
4.25
4
'''Faça um programa que leia algo pelo teclado e mostre na tela o seu tipo primitivo e todas as informações possiveis sobre ele.''' a = input('Digite algo:') print('O tipo primitivo desse valor é', type(a)) print('Só tem espaço?',a.isspace()) print('É número', a.isnumeric()) print('É alfabético?', a.isalpha()) print...
false
1973b0884e9b91bc6d9678d3eb30bb30e7bd500d
gabrielsp20/Ex_Python
/039.py
833
4.125
4
''' Faça u programa que leia o ano de nascimento de um jovem e informe de acordo com sua idade, se ele ainda vai se alistar ao serviço militar, se é a hora de se alistar ou sejá passou do tempo de alistamento. seu programa também deverá mostrar o tempo que faltou ou que passou de prazo. ''' from datetime import date...
false
556b4d097c89b6b0761c4fb4e1850ed0f6f664fb
HansHuller/Python-Course
/ex010 Real para Dolar.py
302
4.1875
4
# Crie um programa que leia quanto dinheiro uma pessoa tem na carteira e mostre quantos Dólares ela pode comprar. Considere US$1.00 = R$3.27 wallet = float(input("Digite quanto dinheiro possue em sua carteira: R$")) print("Com esse dinheiro você poderia comprar US${:.2f} !!!!".format(wallet/3.27))
false
6e47aade01ffdbb8906585316b6f177517cd3df1
HansHuller/Python-Course
/ex097 Função Titulo.py
402
4.1875
4
''' Faça um programa que tenha uma função chamada escreva(), que receba um texto qualqer como parâmetro e mostre uma mensagem com tamanho adaptável. (linha = tamanho da frase) ''' def escreva(frase): frase = " " + frase + " " tam = len(frase) print("-" * tam) print(f"{frase.upper()}") print("-" * ...
false
df6e6fcf0d079f19b91fd44db367e3e521479cad
HansHuller/Python-Course
/ex085 LISTA COMP Dividir par e impar em duas listas em uma lista.py
831
4.1875
4
''' Crie um programa onde o usuário possa digitar sete valores númericos e cadastre-os em uma lista única que mantenha separados os valores pares e ímpares. No final, mostre os valores pares e ímpares em ordem crescente. ''' lista = [[], [], []] for i in range(1, 8): v = "" while not isinstance(v, int): ...
false
f261890f30cecd7c20b0cdcbb849879e346b1189
HansHuller/Python-Course
/ex074 TUPLA Sorteada Menor e Menor.py
650
4.21875
4
''' Crie um programa que vai gerar 5 números aleatórios e colocar em uma tupla. Depois disso, mostre a listagem de números gerados e também indique o menor e o maior valor que estão na tupla. Exibir sorteados, mostrar resultados de maior e menor ''' from random import randint tupla = (randint(0, 100), randint(0, 100), ...
false
83c040a380c738e171e118900d10ae4273101b9c
HansHuller/Python-Course
/ex018 Sen Cos Tang.py
376
4.125
4
#Faça um programa que leia um ângulo qualquer e mostre na tela o valor do seno, cosseno e tangente desse angulo. from math import radians, sin, cos, tan, degrees ang = (radians(float(input("Digite o ângulo: ")))) print("Para o ângulo de {:.2f} graus seu seno é: {:.2f}\nSeu cosseno é: {:.2f}\n E sua tangente é: {:.2f}"....
false
b0d77ccab453c03c5f53e254ebd3ee69a44ec84f
HansHuller/Python-Course
/ex105 FUNÇÃO C RETURN Análise de notas de alunos.py
1,075
4.125
4
''' Faça um programa que tenha uma função notas() que pode receber várias notas de alunos e vai retornar um dicionário com as seguintes informações: - Quantidade de notas - A maior nota - A menos nota - A média da turma - A situação (opcional) [média > 7 = BOA, >5 = RAZOAVEL, <5 = ruim] Fazer DOCSTRINGS ''' def notas...
false
505074bf8af967451a4d1524b4425e7e6db352db
navy-xin/Python
/黑马学习/while-02循环计数器的习惯写法.py
339
4.125
4
""" while 条件: 条件成立要重复执行的代码 。。。。。 """ # 需求:重复打印100次媳妇儿,您辛苦了 --- 1,2,3,4,5.。。100--数据表示循环的次数,依次 # 1+1+1+1.。。。。 i = 0 while i <5: print('媳妇儿,您辛苦了') i += 1 # i = i +1 print('你也辛苦了!')
false
33042110ed9758f6036bed0b925747afa5eeba5d
navy-xin/Python
/黑马学习/while-09-循环嵌套应用之打印星号(正方形).py
311
4.1875
4
""" 1、打印1个星星 2、一行5个:循环 --5个星星在一行显示 3、打印5行星星:循环-- 一行5个 """ j =0 while j < 5: # 一行星星开始 i = 0 while i < 5: print("*",end='') i += 1 # 一行星星结束:换行显示下一行 print() j += 1
false
14901244b9c06406fa9c8e721febc1108f2885c9
masterbpk4/matchmaker_bk
/matchmaker_bk.py
2,927
4.1875
4
##Brenden Kelley 2020 All Rights Reserved ##Just kidding this is all open source ##Just make sure you credit me if you realize that this is a marvel of coding genius and decide to use it in the future ##First we need to get our questions placed in an array and ready to be pulled on command, we'll also need an empty ...
true
d03dcebc6a6787440c5381f6df2d071ff86c6916
academia08-2019/n303-exercicios-resolucoes
/ex2.py
683
4.1875
4
'''Faça um programa que receba dois inputs, uma palavra/frase e uma letra. O programa deve retornar quantas vezes a letra apareceu na palavra/frase. Dica: contagem de valores .count('valor')''' def contar_letra(): palavra = input("Digite um palavra") letra = input("Digite a letra que deseja contar na palavra")...
false
d2b896e0dbd0dc25858882e9adc0379aef020fe3
vladimir4919/purpose
/borndayforewer.py
847
4.375
4
def bornyeardayforewer(year_birth,notability,day,month): print(year_birth) year = int(input(f'Введите год рождения {notability}:')) while int(year) != year_birth: print("Не верно") year = input(f'Введите год рождения {notability}:') day = input(f'В какой день {month} день рожден...
false
6bf9042e0c296379fbe1c557904bfc04c224f31f
rajatpanwar/python
/Dictonary/Dictionary.py
2,580
4.625
5
/// A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets <--------example1-------> thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) <-------example2---------> // how to access the element in dictionary de...
true
a0444ca1776cae4cc5a73af7e82a9dc4f4577080
mornville/Interview-solved
/LeetCode/September Challenge/word_pattern.py
950
4.21875
4
""" Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Example 1: Input: pattern = "abba", str = "dog cat cat dog" Output: true Example 2: Input:pattern = "abba", str = "dog cat...
true
0c359a7b16b7fbece29a96fa1b19e49aaddfed73
bluella/hackerrank-solutions-explained
/src/Arrays/Minimum Swaps 2.py
974
4.375
4
#!/usr/bin/env python3 """ https://www.hackerrank.com/challenges/minimum-swaps-2 You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. Find the minimum number of swaps required to sort the array in ascending order. """ im...
true
e477ab371361b476ded3fbeb89c663c253ee77a6
bluella/hackerrank-solutions-explained
/src/Warm-up Challenges/Jumping on the Clouds.py
1,623
4.1875
4
#!/usr/bin/env python3 """ https://www.hackerrank.com/challenges/jumping-on-the-clouds There is a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. The player can jump on any cumulus cloud having a number that is equal to the number of the curren...
true
98fa867c2dd374990ca6d8b682de24e796234d46
Romancerx/Lesson_01
/Task_1.py
2,567
4.3125
4
#1. Поработайте с переменными, #a) создайте несколько, выведите на экран, #б) запросите у пользователя несколько чисел и строк, сохраните в переменные, #в) выведите на экран. #a) Creating new variables number = 0 number_float = 2.14 string = "Hello!" error_flag_1 = 0 # Используем для проверки ввода правильного типа д...
false
2ca1392aa7be9fe4f7f7efbcd531459d4d40d538
Tigresska/learn_python_matthes
/6_1_3.py
468
4.125
4
famous_person1 = { 'first_name': 'Angelina', 'last_name': 'Joile', 'age': '50', 'city': 'New York', } famous_person2 = { 'first_name': 'Bred', 'last_name': 'Pitt', 'age': '52', 'city': 'Washington', } famous_person3 = { 'first_name': 'Lewis', 'last_name': 'Hamilton', 'age': '38', 'city': 'London', } pe...
false
a5259c0f1618344c5788637a406943352a01b5d9
anoubhav/Project-Euler
/problem_3.py
971
4.15625
4
from math import ceil def factorisation(n): factors = [] # 2 is the only even prime, so if we treat 2 separately we can increase factor with 2 every step. while n%2==0: n >>= 1 factors.append(2) # every number n can **at most** have one prime factor greater than sqrt(n). Thus...
true
97f21e92543f97bf7be3a7603c366c371fbbe0a8
luabras/Angulo-vetores
/AnguloEntreVetores.py
1,829
4.28125
4
import numpy as np import matplotlib.pyplot as plt def plotVectors(vecs, cols, alpha=1): """ Plot set of vectors. Parameters ---------- vecs : array-like Coordinates of the vectors to plot. Each vectors is in an array. For instance: [[1, 3], [2, 2]] can be used to plot 2 vectors. ...
true
31c247fdb56a75015b434f3721249b5711901b57
2pack94/CS50_Introduction_to_Artificial_Intelligence_2020
/1_Knowledge/0_lecture/0_harry.py
1,540
4.125
4
from logic import * # Create new classes, each having a name, or a symbol, representing each proposition. rain = Symbol("rain") # It is raining. hagrid = Symbol("hagrid") # Harry visited Hagrid. dumbledore = Symbol("dumbledore") # Harry visited Dumbledore. # Save sentences into the Knowledge...
true
213454dcd8c830d4752d7915b2b4f91b721485b5
vigneshsinha04/DSA
/Algorithms - Recursive/Fibonacci.py
370
4.21875
4
def FibonacciRecursive(number): #Big-O = 2^n Exponential if number < 2: return number return FibonacciRecursive(number-1) + FibonacciRecursive(number-2) def FibonacciIterative(number): num1 = 0 num2 = 1 num3 = 0 for i in range(0,number-1): num3 = num1 + num2 num1 = num2 num2 = num3 return num3 print(Fi...
false
182456c4be118753b0ca6ece47d81a041e3aa3db
zackkattack/-CS1411
/cs1411/Program_01-1.py
500
4.65625
5
# Calculate the area and the circumfrence of a circle from its radius. # Step 1: Prompt for radius. # Step 2: Apply the formulas. # Step 3: Print out the result. import math # Step 1 radius_str = input("Enter the radius of the circle: ") radius_int = int(radius_str) # Convert radius_str into a integer # Step 2 circ...
true
70de8dc6a37fd9e059bb23d8a96ec2139ffc8257
WinnyTroy/random-snippets
/4.py
670
4.1875
4
# # Order the list values = [1, 3, -20, -100, 200, 30, 201, -200, 9, 3, 4, 2, -9, 92, 99, -10] # # a.) In ascending Order values.sort() print values # # b.) In descending Order values.reverse() print(values) # # c.) Get the maximum number in the list print max(values) # # d.) Get the minimum number in the lis...
true
84397ef0767501c2754433972550e2ad3a180464
phnguyen-data/PythonHomework
/hwss2/BMI.py
333
4.15625
4
height = int(input("Your Height : ")) weight = int(input("Your Weight : ")) BMI = weight / ((height * height) / 10000) print(BMI) if BMI < 16: print("Severely underweight") elif BMI < 18.5: print("Underweight") elif BMI < 25: print("Normal") elif BMI < 30: print("Overweight") else: prin...
false
c3cae72e8baded407d00e9bd9ad6c50bfce2547e
nabin2nb2/Nabin-Bhandari
/introEx2.py
246
4.53125
5
#2.Gets the radius of a circle and computes the area. Radius = input("Enter given Radius: ") Area = (22/7)*int(Radius)**2 #Formula to calculate area of circle print ("The area of given radius is: "+ str(Area.__round__(3)))
true
7e75e47b78db23fcd088cc057f0357431d75f236
nomadsarychev/repo
/python/lesson_2/step_2.py
532
4.15625
4
# 3. Сформировать из введенного числа обратное по порядку входящих в него цифр и вывести на экран. Например, если введено число 3486, надо вывести 6843. num = input("Введите число") num_end = "" for i in num: num_end = i + num_end print(f"{int(num_end)}") # def num_end(num): # if len(num) == 0: # return...
false
d592b8d81d0e7c9bb31113d1b2b7b2fee352ddef
Mugdass/datastructures
/data structures example.py
1,512
4.125
4
#This is a 'List' type of data structure myList = [] myList.append(1) myList.append(2) myList.append(3) myList.append(4) print(myList) print(myList.index(3)) myList.remove(4) print(myList) print() print() #This is a 'Tuple' type of data structure numbers=(1,2,2,2,2,1,3) print(numbers.index...
false
4412e9ed8736bd3e3ccabbfd2e5f3cb380be6561
Alexsik76/Beetroot
/7_Functions/task2.py
318
4.1875
4
# Creating a dictionary dictionary = [] def make_country(name, capital): dictionary.append({'name': name, 'capital': capital}) make_country('USA', 'New York City') make_country('Україна', 'Київ') for i in dictionary: print(f"Країна: {(i['name']):10} Столиця: {(i['capital']):10}")
false
5067886008c47e705d0848903e77709ec99e811d
Alexsik76/Beetroot
/3_Booleans and control structures with while iteration/Classwork/work5.py
457
4.1875
4
text = 'Hello world' print('Колличество символов в строке: ' + str(len(text))) print('Колличество букв в строке: ' + str(len(text) - text.count(' '))) print('В верхнем регистре: ' + text.upper()) print('В нижнем регистре: ' + text.lower()) text_upper = text.upper() print('Текст с заглавными: ' + text_upper.capitalize()...
false
ace5e6c5659b45988cab23e38cefc5713d94161f
Alexsik76/Beetroot
/3_Booleans and control structures with while iteration/task2.py
414
4.28125
4
# The valid phone number program phone_num = input('Введите номер телефона: ') if phone_num.isnumeric() and len(phone_num) == 10: print('Спасибо за корректный номер') elif not phone_num.isnumeric(): print('Номер содержит не только цифры') elif not len(phone_num) == 10: print('Длина номера отличается от 10')...
false
ca18170a10f6b4ecfa367cdb6b90aa1b8c9b2efe
skalunge1/python-p
/DictPgm.py
1,004
4.71875
5
# How to access elements from a dictionary? # 1. with the help of key : # 2. using get() method : If the key has not found, instead of returning 'KeyError', it returns 'NONE' my_dict = {'name':'Jack', 'age': 26} # Output: Jack print(my_dict['name']) print(my_dict.get('name')) # Output: 26 print(my_dict.get('age')) pr...
true
b4e460797dcf9d15466f25559adcaa19b0cd86eb
skalunge1/python-p
/DemoDeleteDict.py
1,261
4.46875
4
# How to delete or remove elements from a dictionary? # 1. pop() : Remove particular item from list # : It removes particular item after providing key and returns removed value squares = {1:1, 2:4, 3:9, 4:16, 5:25} print(squares.pop(4)) print(squares.pop(2)) print(squares) print(squares.popitem()) print(squares)...
true
cce65666f67ef2fb7a33c9372f03cdacf67ac500
FabrizioFubelli/machine-learning
/05-regressor-training.py
1,269
4.25
4
#!/usr/bin/env python3 """ Machine Learning - Train a predictive model with regression Video: https://youtu.be/7YDWaTKtCdI LinearRegression: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html """ from sklearn.datasets import load_boston from sklearn.linear_model import Line...
true
754e26560f3768a87fc88f9f4ce9fbc2b9648d40
FabrizioFubelli/machine-learning
/01-hello-world.py
1,390
4.28125
4
#!/usr/bin/env python3 """ Machine Learning - Hello World Video: https://www.youtube.com/watch?v=hSZH6saoLBY 1) Analyze input data 2) Split features and target 3) Split learning data and test data 4) Execute learning with learning data 5) Predict result of learning data and test data 6) Compare the accuracy scores b...
true
0fce5a66b71ab421c5ff48b90bc5d13eb163d469
tapan2930/ds
/linked-list.py
677
4.25
4
# -------------------------Creating Linked List-------------------------# # Creating Node class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next # Printing Linkedlist items def ll_print(ll): if(ll == None): print("Empty LL") while (ll): prin...
false
d21287426535a76963e6a5dce8015f051b2f1f12
slviajero/number-theory
/numberfunctions.py
1,623
4.21875
4
from math import sqrt, factorial # # euklids algorithm to find the greatest common divisor of two integers # non recursive for a change # no optimization like for example handling situation where one factor is # much bigger than the other # def euklid(i,j): if (i<1 or j<1): return 0 while (i!=j): if (i>j): i...
false
950c0661c44ff43eaef662c124d1d3a9057122e1
EgorKolesnikov/YDS
/Python/Chapter 01/01. Basics/02. Shuffling the words.py
1,095
4.15625
4
## Egor Kolesnikov ## ## Shuffling letters in words. First and last letters are not changing their positiona. ## import sys import random import string import re def shuffle_one_word(word): if len(word) > 3: temp_list = list(word[1:-1]) random.shuffle(temp_list) word = word...
true
3127d121f6f06faa85a09de26f6879220b6fd00d
paarubhatt/Assignments
/Fibonacci series.py
634
4.34375
4
#Recursive function to display fibonacci series upto 8 terms def Fibonacci(n): #To check given term is negative number if n < 0: print("Invalid Input") #To check given term is 0 ,returns 0 elif n == 0: return 0 # To check given term is either 1 or 2 because series for ...
true
a48e9a490f51dbd08f9cec47f9de5bd6eab47712
megha-20/String_Practice_Problems
/Pattern_Matching.py
544
4.34375
4
# Function to find all occurrences of a pattern of length m # in given text of length n def find(text,pattern): t = len(text) p = len(pattern) i = 0 while i <= t-p: for j in range(len(p)): if text[i+j] is not pattern[j]: break if j == m-1: ...
true
95355c972888adfa97a5ce64afbb80effedfd3f4
pauleclifton/GP_Python210B_Winter_2019
/students/jeremy_m/lesson04_exercises/dict_lab.py
1,493
4.125
4
#!/usr/bin/env python3 # Lesson 04 Exercise: Dictionary and Set Lab # Jeremy Monroe dict_one = {"name": "Chris", "city": "Seattle", "cake": "Chocolate"} print("Dictionaries 1") print(dict_one) del dict_one['cake'] print(dict_one) dict_one['fruit'] = 'Mango' print('\n\nDict Keys:') for key in dict_one: print(...
false
8f70983510f211453fb51f8f9c396f58eaee33b7
pauleclifton/GP_Python210B_Winter_2019
/students/douglas_klos/session8/examples/sort_key.py
1,286
4.3125
4
#!/usr/bin/env python3 """ demonstration of defining a sort_key method for sorting """ import random import time class Simple: """ simple class to demonstrate a simple sorting key method """ def __init__(self, val): self.val = val def sort_key(self): """ sorting key func...
true
25755d77d073cc66284597e63283cd3f93b14fc3
pauleclifton/GP_Python210B_Winter_2019
/students/douglas_klos/extra/rot13/rot13.py
699
4.34375
4
#!/usr/bin/env python3 """ Function to convert rot13 'encrypt' """ # Douglas Klos # March 6th, 2019 # Python 210, Extra # rot13.py # a - z == 97 - 122 # A - Z == 65 - 90 # We'll ignore other characters such as punctuation def rot13(value): """ Function to perform rot13 on input """ output = '' for let...
false
0bd34168459f1da60426f683ac7ce4ffb5eebc4a
pauleclifton/GP_Python210B_Winter_2019
/students/jeremy_m/lesson03_exercises/slicing_lab.py
1,499
4.5
4
#!/usr/bin/env python3 # Lesson 03 - Slicing Lab # Jeremy Monroe def first_to_last(seq): """ Swaps the first and last items in a sequence. """ return seq[-1] + seq[1:-1] + seq[0] # print(first_to_last('hello')) assert first_to_last('dingle') == 'eingld' assert first_to_last('hello') == 'oellh' def every_oth...
true
4e71942f4dfb235107981620e653050980bd8f5d
pauleclifton/GP_Python210B_Winter_2019
/students/jesse_miller/session02/print_grid2-redux.py
931
4.375
4
#!/usr/local/bin/python3 # Asking for user input n = int(input("Enter a number for the size of the grid: ")) minus = (' -' * n) plus = '+' """Here, I'm defining the variables for printing. Made the math easier this way""" def print_line(): print(plus + minus + plus + minus + plus) """This defines the tops and bot...
true
a8f751f2df136d17415a32d53cf8ffe2d060b574
pauleclifton/GP_Python210B_Winter_2019
/students/ScottL/session02/fizzbuzz.py
468
4.1875
4
def FizzBuzz(): """Return a list of integers from 1 - 100 (inclusive) where numbers divisible by 3 return 'Fizz', integers divisible by 5 return 'Buzz' and integers divisible by both 3 & 5 return 'FizzBuzz' """ for i in range(1, 101): if i % 3 == 0 and i % 5 == 0: print("FizzBuzz") ...
false
883a6827c335dd475687f06cd829f20a12dc0010
pauleclifton/GP_Python210B_Winter_2019
/students/alex_whitty/session03/list_lab_series1.py
782
4.1875
4
#!/usr/bin/env python3 fruits = ['apples', 'pears', 'oranges', 'peaches'] print(fruits) new_fruit = input("Which fruit would you like to add? >>>") fruits.append(new_fruit) print(fruits) item_num = input("Which item number do you want to see? >>>") if item_num == "1": print("You chose 1," + " the fruit is " + frui...
false
d73861363b1723dc3aafade4529f5ed030429680
pauleclifton/GP_Python210B_Winter_2019
/students/jeremy_m/lesson03_exercises/string_formatting_lab.py
1,594
4.34375
4
#!/usr/bin/env python3 # lesson 03 Exercise - String Formatting Lab # Jeremy Monroe # TASK 1 first_tup = (2, 123.4567, 10000, 12345.67) print('Task one:') print('file_{:03d} : {:06.2f}, {:.2E}, {:.2E}'.format(*first_tup)) # TASK 2 print('\nTask Two:') print( f'file_{first_tup[0]:03d} : {first_tup[1]:06.2f}, {f...
false
4bad0ec8024dea5b25d678ea50a74313474066f5
pauleclifton/GP_Python210B_Winter_2019
/students/elaine_x/session03/slicinglab_ex.py
1,915
4.40625
4
''' ########################## #Python 210 #Session 03 - Slicing Lab #Elaine Xu #Jan 28,2019 ########################### ''' #Write some functions that take a sequence as an argument, and return a copy of that sequence: #with the first and last items exchanged. def exchange_first_last(seq): '''exchange the first ...
true
9e2062f46a32508373a55afb7fb110dda8579d4e
markuswesterlund/beetroot-lessons
/python_skola/rock_paper_scissor.py
651
4.28125
4
import random print("Let's play rock, paper, scissor") player = input("Choose rock, paper, scissor by typing r, p or s: ") if player == 'r' or player == 'p' or player == 's': computer = random.randint(1, 3) # 1 == r # 2 == p # 3 == s if (computer == 1 and player == 'r' or computer == 2 and player ...
true
d57b6adc5a6e62ce236f104c577c1329925b84ae
markuswesterlund/beetroot-lessons
/python_skola/Beetroot_Academy_Python/Lesson 4/guessing_game.py
557
4.25
4
import random print("Try to guess what number the computer will randomly select: ") numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] player = input("Choose a number between 1-10: ") if int(player) in numbers: computer = random.randint(1, 10) if player == computer: print("The computers number was:", computer,...
true
6e3ce3b082ca45aa478ee73fdc200b84f13e7b45
manuel-garcia-yuste/ICS3UR-Unit6-04-Python
/2d_list.py
1,456
4.46875
4
#!/usr/bin/env python3 # Created by: Manuel Garcia Yuste # Created on : December 2019 # This program finds the average of all elements in a 2d list import random def calculator(dimensional_list, rows, columns): # this finds the average of all elements in a 2d list total = 0 for row_value in dimensiona...
true
4e1a819c2a901470c8b7200035ce3dcb04e87c16
rbose4/Python-Learning
/hello.py
1,115
4.125
4
# My first python program print("Hello World") print("My favourite song is We will rock you") print("My favourite movie is Sound of Music") print("My favourite day for the year is November", 18) print() print("Hello") print("World!") print("Hello World") print() print('Good to see you') print("My favorite numbers are...
false
9981b9084b75157e002eeab791beda9a40af6555
Linh-T-Pham/Study-data-structures-and-algorithms-
/palindrome_recursion.py
1,326
4.34375
4
""" Write a function that takes a string as a parameter and returns True if the string is a palindrome, False otherwise. Remember that a string is a palindrome if it is spelled the same both forward and backward. For example: radar is a palindrome. for bonus points palindromes can also be phras...
true
012ab172576e4caa22fa0661ae304825a6e0f3a5
Linh-T-Pham/Study-data-structures-and-algorithms-
/merge_ll.py
2,625
4.15625
4
""" Merge Linked Lists Write a function that takes in the heads of two singly Ll that are in sorted order, respectively. The function should merge the lists in place(i.e, it should not create a brand new list and return the head of the merged list; the merged list should be in sorted order) Each l...
true
1cca158cb53fe6acf0e9c972240e43af6f30efe1
Linh-T-Pham/Study-data-structures-and-algorithms-
/recursion2.py
596
4.5
4
"""Write a function, reverseString(str), that takes in a string. The function should return the string with it's characters in reverse order. Solve this recursively! Examples: >>> reverseString("") '' >>> reverseString("c") 'c' >>> reverseString("internet") 'tenretni' >>> reverseString("fr...
true
b83be788e7f15af3f915632c37ea64314b4b12a8
mariormt17/Lenguajes-y-Automatas-2
/triangulo.py
805
4.1875
4
#Nombre: triangulo.py #Objetivo: identifica el tipo de triangulo de acuerdo al valor de sus lados #Autor: Mario Rubén Mancilla Tinoco #Fecha: 01 de julio 2019 #Función para identificar el tipo de triangulo def identificar(l1, l2, l3): if(l1 == l2 and l1 == l3): print("EL triangulo ingresado es Equilatero") elif(l1...
false
7cb17368d61a76b8bda586fdb12c656cf9f4f37f
Timothy-py/Python-Challenges
/Factorial.py
986
4.40625
4
# A Python program to print the factorial of a number # L1 - This line of code creates a variable named 'multiplier' which will # be used to save the successive multiplications and it # is initialized to 1 because it will be used to do the first multiplication # L3 - Prompt the user to enter a number and save the numb...
true
ca3c224af2531b5777378548a13d2cb2e980bd8a
aloysiogl/CES-22_solutions
/Bimester1/Class1/ex6/exercise6.py
1,316
4.40625
4
#!/usr/bin/python3 import turtle from time import sleep # Question # Use for loops to make a turtle draw these regular polygons (regular means all sides the same # lengths, all angles the same): # ◦ An equilateral triangle # ◦ A square # ◦ A hexagon (six sides) # ◦ An octagon (eight sides) # Function for drawing p...
true
7d7fe99aa3c635252af1a6d74b987fd0ec42c5ba
aloysiogl/CES-22_solutions
/Bimester1/Class6/decorators/decorators.py
1,014
4.3125
4
#!/usr/bin/python3 def round_area(func): """ This decorators rounds the area :param func: area function :return: the rounded area function """ def round_area_to_return(side): """ This function calculates the rounded area to 2 decimal digits :param side: the side of the...
true
f34db4522943068e6e25c0984a6bc52859e92c3a
kbalog/uis-dat630-fall2016
/practicum-1/tasks/task4.py
1,090
4.5625
5
# Finding k-nearest neighbors using Eucledian distance # ==================================================== # Task # ---- # - Generate n=100 random points in a two dimensional space. Let both # the x and y attributes be int values between 1 and 100. # - Display these points on a scatterplot. # - Select one of ...
true
dac2cb25d763900c9b477c0ec27f813b500e2d89
newbieeashish/datastructures_algo
/ds and algo/linkedlist,stack,queue/falttenLL.py
2,556
4.34375
4
'''Suppose you have a linked list where the value of each node is a sorted linked list (i.e., it is a nested list). Your task is to flatten this nested list—that is, to combine all nested lists into a single (sorted) linked list.''' #creating nodes and linked List class Node: def __init__(self,value): ...
true
a6412b37f0cbd97d812d04f6edb564fb43c19b31
newbieeashish/datastructures_algo
/ds and algo/Sorting_algos/counting_inversions.py
2,026
4.15625
4
'''Counting Inversions The number of inversions in a disordered list is the number of pairs of elements that are inverted (out of order) in the list. Here are some examples: [0,1] has 0 inversions [2,1] has 1 inversion (2,1) [3, 1, 2, 4] has 2 inversions (3, 2), (3, 1) [7, 5, 3, 1] has 6 inversions (7, 5), (3...
true
d25ae8395ca06e243b00f3041c19c90c9402377a
mahasahyoun/python-for-everybody
/ch-2/gross-pay.py
586
4.1875
4
""" Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking or bad user ...
true
6e161afe596049d1f120fbc2e8ad3f7cd41e411c
patrickForster/Sandbox
/password_entry.py
388
4.25
4
# password checker MIN_LENGTH = 4 print("Please enter a valid password") print("Your password must be at least", MIN_LENGTH, "characters long") password = input("> ") while len(password) < MIN_LENGTH: print("Not enough characters!") password = input("> ") hidden_password = len(password)*'*' print("Your {}-chara...
true
fd6140a6a5012f540e30db95bcb99baf6bd5dd78
sczhan/wode
/xitike(习题课)/xitike(第4章python高级语法)/xitike37.py
1,599
4.125
4
# 编写一个计算减法的方法, 当第一个数小于第二个数时, 抛出"被减数不能小于减数的异常" # def jianfa(a, b): # if int(a) < int(b): # raise BaseException("被减数不能小于减数") # else: # return int(a) - int(b) # # try: # jianfa(3, 7) # except BaseException as error: # print("好像出错了, 出错的内容是{}".format(error)) # 定义一个函数func(filename)filenam...
false
f7b19217b3ef9895ba0151e729e668e2f7e962cf
ericdong66/leetcode-50
/python/48.search_insert_position.py
1,101
4.1875
4
# Given a sorted array and a target value, return the index if the target is # found. If not, return the index where it would be if it were inserted in # order. # # You may assume no duplicates in the array. # # Here are few examples. # [1,3,5,6], 5 -> 2 # [1,3,5,6], 2 -> 1 # [1,3,5,6], 7 -> 4 # [1,3,5,6], 0 -> 0 # # T...
true
8678563bed00c089031a5522b26b6747e23f7859
victorwp288/kea_python
/misc/list.py
2,613
4.34375
4
# By using the slicing syntax change the following collections. # After slicing: # ['Hello', 'World', 'Huston', 'we', 'are', 'here'] should become -> ['World', 'Huston', 'we', 'are'] # ['Hello', 'World', 'Huston', 'we', 'are', 'here'] -> ['Hello', 'World'] # ['Hello', 'World', 'Huston', 'we', 'are', 'here'] -> ...
false
2b9172bdbc0e4eee3650c75033c6610faabfeecc
zentino/CVIS
/intro to python/Aufgabe2.py
1,754
4.21875
4
#Aufgabe 2: #Schreibe ein Python Programm, das #- Die Konvertierung von Temperaturangaben in Celsius nach Fahrenheit oder Kelvin ermöglicht #- Zuerst wird beim Benutzer abgefragt welche Konvertierung er machen möchte #- Danach muss der Benutzer eine Temperatur in Celsius angeben #- Es wir die Temperatur in Fahrenheit o...
false
222c0630766643a98e24c8218c8bf148fd2c514d
h3llopy/web-dev-learning
/Learn Python the Hard Way/exercises/ex03.py
812
4.53125
5
print "I will now count my chickens:" # These print out the answer after a string. # The numbers are turned into floating point numbers with a decimal point and zero at the end for accuracy. print "Hens", 25.0 + 30.0 / 6.0 print "Roosters", 100.0 - 25 * 3 % 4 print "Now I will count the eggs" # This prints out the a...
true
387d986223c06ade6346901334c275f70ae5b89f
xcobaltfury3000/baby-name-generator
/Baby_name_generator.py
2,466
4.40625
4
print ("Hello world") import string print(string.ascii_letters) print(string.ascii_lowercase) #since we want a random selection we import random import random #from random library we want to utilize choice method print(random.choice("pullaletterfromhere")) print(random.choice(string.ascii_lowercase)) letter_input_1...
true
d5507e8d1e4565bf343205fcf933096abeead382
AtharvaDahale/Python-BMI-Calculator
/Python BMI Calculator.py
529
4.34375
4
height = float(input("Enter your height in centimeters: ")) weight = float(input("Enter your weight in Kg: ")) height = height/100 BMI = weight/(height*height) print("Your BMI is: ",BMI) if (BMI > 0): if(BMI<=16): print("Your are severely underweight") elif(BMI<=18.5): print("you are un...
true
82f5c6de2568a82c08a8e6f17427b6478277309b
khanmaster/eng88_python_control_flow
/control_flow.py
1,721
4.3125
4
# Control Flow with if, elif and else - loops weather = "sunny" if weather == "thinking": # if this condition is False execute the next line of code print("Enjoy the weather ") # if true this line will get executed if weather != "sunny": print(" waiting for the sunshine") if weather == "cloudy": print("...
true
404d754f6ee9882e6eac12318f3847c3c46d2a9f
s-anusha/automatetheboringstuff
/Chapter 8/madLibs.py
1,814
4.78125
5
#! python3 # madLibs.py ''' Create a Mad Libs program that reads in text files and lets the user add their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB appears in the text file. For example, a text file may look like this: The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffecte...
true
85d73fc37042cddd112601a2f4a8f013bf569685
s-anusha/automatetheboringstuff
/Chapter 13/brute-forcePdfPasswordBreaker.py
1,721
4.5
4
#! python3 # brute-forcePdfPasswordBreaker ''' Say you have an encrypted PDF that you have forgotten the password to, but you remember it was a single English word. Trying to guess your forgotten password is quite a boring task. Instead you can write a program that will decrypt the PDF by trying every possible English ...
true
e242498ad2180dd426cb2aa1b4cdbe86586e96d6
s-anusha/automatetheboringstuff
/Chapter 6/tablePrinter.py
1,784
4.71875
5
#! python3 # tablePrinter.py ''' Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column right-justified. Assume that all the inner lists will contain the same number of strings. For example, the value could look like this: tableData = [['app...
true
e7c9434a33f704bdb6ff27104e5fd176536a338a
medifle/python_6.00.1x
/defTowerofHanoi.py
617
4.25
4
# recursive version of Towers of Hanoi # fr means 'from' # printMove print every step in order to complete the problem. def printMove(fr, to): print('Move from ' + str(fr) + ' to ' + str(to)) # 'fr', 'to', 'spare' are the three towers # 'fr' is the name of the tower you move stacks from # 'to' is the nam...
false
74f13e5d321d9c5195436d0a7bb8aa2011842144
Aplex2723/Introduccion-en-Python
/Scripts/Salidas.py
1,414
4.1875
4
v = "otro texto" n = 10 print("Un texto",v,"y un numero",n) c = "Un texto {} y un numro {}".format(v,n) # Lo mismo de arriba print(c) c = "Un texto {} y un numero {}".format(v,n) # Pasadno numeros print("Un texto {1} y un numero {0}".format(v,n))# Cambiando los valores donde 1 = n y 0 = v print("\tUn texto {te...
false
8bae9a502d852cc6497e804361ba331e80c0b82c
rafiulalam2112/Age-ganaretor
/age_generator.py
530
4.34375
4
print('Hello! I am Rafi Robin. This is my python project.') print('This tool genarate your age :)') now_year=2021 birth_year=int(input('Inter your birth year :')) #When a user input a number the value save as string. To make the input as number use int() . age=(now_year-birth_year) print(f'You are {age} years old...
true
5327adf41dc51315c97e8b473b5709acc6efa7c0
elacuesta/euler
/solutions/0004.py
620
4.28125
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ def is_palindrome(n): return list(str(n)) == list(reversed(str(n))) def palindrome(factor_lengt...
true
df764bedcfad60f653ecf19dee51a799f5021603
UthejReddy/Python
/Python_Basics_Codes/datetime_fun.py
818
4.125
4
import datetime from datetime import time from datetime import datetime #example 1 date_object1 = datetime.datetime.now() print(date_object1) #example 2 date_object2 = datetime.date.today() print(date_object2) #example 3 date_object3 = datetime.date(2019,4,10) print(date_object3) #example 4 timesta...
false
25a63aa2f53b0ffbde33f7bfc98300670294c5c1
DanteAkito/python_curse
/exercises.py
1,559
4.71875
5
#Exercise 1: Escribir un programa que pregunte el nombre del usuario en la consola y después de que el usuario lo introduzca muestre por pantalla la cadena ¡Hola <nombre>!, donde <nombre> es el nombre que el usuario haya introducido. '''name = input("What's your name?: ") print("Hi! " + name)''' #Exercise 2: Escribi...
false
f89825f484213cd71df1523936d71db182f4ae6b
DanteAkito/python_curse
/matrices_suma.py
1,520
4.21875
4
# Crear programa para introducir datos en la matriz x = int(input("Digita el numero de filas: ")) # se introduce el numero de filas z = int(input("Digita el numero de columnas: ")) # se introduce el numero de columnas a = int(input("Digita el numero de filas de la matriz 2: ")) b = int(input("Digita el numero de column...
false
1dca28f5e0ca90cba859c06beb9df4ca387a9557
DanteAkito/python_curse
/primarios.py
241
4.15625
4
x = int(input("Enter a number: ")) #if x % 2 == 0 : #print("The number is pair") #if x % 2 != 0 : #print("The number is odd") if x < 1 if x % 1 != 0 and x % x != 0 #if range(2, x) % == 0 and x != 1 : print("numero primo")
false
0f804f75088a1504d0365012cd9ab5e2ec4b16b3
jsonw99/Learning-Py-Beginner
/Lec04(ListAndTuple).py
1,482
4.40625
4
# list ################################################################ classmates = ['Micheal', 'Bob', 'Tracy'] print(classmates) type(classmates) len(classmates) print(classmates[0]) print(classmates[1]) print(classmates[2]) print(classmates[3]) print(classmates[-1]) print(classmates[-2]) print(classmates[-3]) prin...
true
3f693e3ac2a3ca646480defe121ca735abcf664e
jai-somai-lulla/Sem8
/Legacy/ML/LinearRegression/grad.py
1,201
4.1875
4
import numpy as np import pandas as pd #import matplotlib.pyplot as plt def cost_function(X, Y, B): if(type(Y) == np.int64): m=1 else: m = len(Y) J = np.sum((X.dot(B) - Y) ** 2)/(m*2) return J def gradient_descent(X, Y, B, alpha, iterations): cost_history = [0] * iterations m = len...
true
8d0778ee4429cf201fca2e368e9d8c07a1c0f25e
THE-SPARTANS10/Python-Very-Basics
/user_input.py
211
4.1875
4
#By default in python for user input we get everything as string name = input("Enter your name: ") value = input("Enter a number: ") print("your name is " + name + " and your favourite number is: " + value)
true
704954326faf5ad2e678d32dd237bf842130b52e
Gustavo1518/Python_InterfacesGraficas
/For.py
655
4.15625
4
#Metodo upper() convierte a mayusculas micadena = raw_input("ingresa un texto") for cadena in micadena: print(cadena.upper()) # metodo lower() convierte a minusculas micadena2 = raw_input("ingresa un segundo texto") for i in micadena2: print(i.lower()) #iteracion sobre un rango saludo = "HOLA MUNDO" for numero...
false