blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0c26e158842e1f3fcbd260a1115982c3a3303a6a
BenMarriott/1404
/prac_02/exceptions.py
1,036
4.28125
4
""" CP1404/CP5632 - Practical Answer the following questions: 1. When will a ValueError occur? When usings floating point numbers 2. When will a ZeroDivisionError occur? When attempting n/0 3. Could you change the code to avoid the possibility of a ZeroDivisionError? """ """"" try: numerator = int(input("En...
true
5a530c11bf9ff825ace09f85299d8ac1419ce7a3
nitishprabhu26/HackerRank
/Practice - Python/005_Loops.py
760
4.46875
4
if __name__ == '__main__': n = int(input()) for i in range(n): print(i**2) # The range() function # The range function is a built in function that returns a series of numbers. At a minimum, it needs one integer parameter. # Given one parameter, n, it returns integer values from 0 to n-1. For example...
true
219a8fe816e6bad703c55d6b75435fc761ace602
supriya1110vuradi/Python-Tasks-Supriyav
/task4.py
753
4.34375
4
# Write a program to create a list of n integer values and do the following # Add an item in to the list (using function) # Delete (using function) # Store the largest number from the list to a variable # Store the Smallest number from the list to a variable a = [1, 2, 3, 4, 5, 6] hi = max(a) lo = min(a) print(hi) pri...
true
8e488771b4e8aa522e9246dc9f50aec625dbd872
long2691/activities
/activity 5/comprehension.py
1,521
4.15625
4
prices = ["24", "13", "16000", "1400"] price_nums = [int(price) for price in prices] print(prices) print(price_nums) dog = "poodle" letters = [letter for letter in dog] print(letters) print(f"we iterate over a string into al ist : {letters}") capital_letters = [letter.upper() for letter in letters] #long version of s...
true
ccd5218382ffe23b84fffc1e0d137feb35b0ea18
andthenenteredalex/Allen-Downey-Think-Python
/thinkpy107.py
404
4.125
4
""" Allen Downey Think Python Exercise 10-7 This function checks if two words are anagrams and returns True if they are. """ def is_anagram(word_one, word_two): one = sorted(list(word_one)) two = sorted(list(word_two)) if one == two: return True elif one != two: return ...
true
aa0616170bc2dbbd2dca519e550437bb0365ac12
daviddlhz/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-write_file.py
403
4.25
4
#!/usr/bin/python3 """write to a text file""" def write_file(filename="", text=""): """writes to a file Keyword Arguments: filename {str} -- name of file (default: {""}) text {str} -- text beingwritten (default: {""}) Returns: int -- number of charaters """ with open(filena...
true
330654c09eb6cbb1f913f2734102f51b225c8bcd
oneyedananas/learning
/for Loops.py
553
4.5
4
# performs code on each item in a list i.e. iteration. loops are a construct which can iterate through a list. # uses a while loop and a counter variable words = ["milda", "petr", "karel", "pavel"] counter = 0 max_index = len(words) - 1 # python starts counting from 0 so -1 is needed # print(max_index) now returns 3...
true
0685f623b4f9cb897a13d09f537b410e4bf76868
apranav19/FP_With_Python
/map_example.py
499
4.40625
4
""" Some simple examples that make use of the map function """ def get_name_lengths(names): """ Returns a list of name lengths """ return list(map(len, names)) def get_hashed_names(names): """ Returns a list of hashed names """ return list(map(hash, names)) if __name__ == '__main__': people = ["Mary", "Isla", ...
true
7778dff5d30424e4f1b98c98fdddd1642f86dfe9
fangyuandoit/PythonLearnDemo
/菜鸟教程/Python3_05列表.py
2,271
4.3125
4
''' 序列是Python中最基本的数据结构。序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推。 Python有6个序列的内置类型,但最常见的是列表和元组。 序列都可以进行的操作包括索引,切片,加,乘,检查成员。 此外,Python已经内置确定序列的长度以及确定最大和最小的元素的方法。 列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现。 列表的数据项不需要具有相同的类型 ''' list1 = ['Google', 'Runoob', 1997, 2000]; list2 = [1, 2, 3, 4, 5 ]; list3 = ["a", "b", "c", "...
false
f09901aec3a56dbb7675a4131d01c97ff0173943
DanielDavid48/Exercicios-PY
/ex14.py
767
4.1875
4
import os print('Bem vindo ao convertor de temperaturas!') print(f'Escolha uma das opções abaixo:{os.linesep}A - para converter celsius para fahrenheit{os.linesep}B - para converter fahrenheit para celsius') opcao = input('Opção escolhida: ') # Celsius para fahrenheit # fahrenheit para celsius if opca...
false
662ba6e340e968f95adeebeb601083823e26d4ea
EstebanBrito/taller-basico-python
/basics.py
1,211
4.375
4
# VARIABLES EN PYTHON # No es necesario definir tipo (static, public, etc) # ni tipo (int, float, etc) mi_variable = 45 print(mi_variable) mi_variable = 3.9 print(mi_variable) mi_variable = True print(mi_variable) mi_variable = 'otro valor' print(mi_variable) mi_variable = [1, 6, 3, 3] print(mi_variable) # Operac...
false
fe4ba27c40751233f94c4468944fd300c65ac1f8
luizpericolo/PythonProjects
/Text/count_words.py
793
4.46875
4
# Count Words in a String - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary. string = '' while string.upper() != 'QUIT': string = raw_input("Enter a text to get a summary of strings or 'quit' to exit: ") if string.upper() != 'QUIT'...
true
54c7954e9b17b56aff806ec9f0ba48216e308f9a
IncapableFury/Triangle_Testing
/triangle.py
2,034
4.25
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 14 13:44:00 2016 Updated Jan 21, 2018 The primary goal of this file is to demonstrate a simple python program to classify triangles @author: jrr @author: rk @ """ def classify_triangle(side1: int, side2: int, side3: int) -> str: """ Your correct code goes here....
true
d0935a48ad03c078bcb50b9adef38fa64e53df8f
cdueltgen/markov_exercise
/markov.py
1,053
4.28125
4
""" markov.py Reference text: section 13.8, how to think like a computer scientist Do markov analysis of a text and produce mimic text based off the original. Markov analysis consists of taking a text, and producing a mapping of prefixes to suffixes. A prefix consists of one or more words, and the next word to follo...
true
d7c1582e72c291ced406a9a47731bae6cbf5cbd8
cassiorodrigo/python
/aula14.py
340
4.125
4
s = str(input('Digite seu sexo [M/F] ')).strip().upper()[0] while s not in 'MmFf': s = str(input('Entrada Invalida, por favor digite [M/F]: ')).strip().upper()[0] print('Você digitou {}.'.format(s)) '''r = 'S' while r == 'S': n = int(input('Digite um numero: ')) r = str(input('Quer continuar: [S/N ')).uppe...
false
e4e4d1aa65cca834a26d27edd85da4a0543a96f7
NYU-Python-Intermediate-Legacy/jarnold-ipy-solutions
/jarnold-2.2.py
2,270
4.15625
4
#usr/bin/python2.7 import os import sys def unique_cities(cities): # get rid of empty items if cities.has_key(''): del cities[''] unique_cities = sorted(set(cities.keys())) return unique_cities def top_ten_countries(countries): # get rid of empty items if countries.has_key(''): del countries[''] ...
true
424c14cc7e7547593ae9bf715e78108b363d2cc3
ZuzaRatajczyk/Zookeeper
/Problems/Lucky ticket/task.py
466
4.125
4
# Save the input in this variable ticket = (input()) first_digit = int(ticket[0]) second_digit = int(ticket[1]) third_digit = int(ticket[2]) fourth_digit = int(ticket[3]) fifth_digit = int(ticket[4]) sixth_digit = int(ticket[5]) # Add up the digits for each half half1 = first_digit + second_digit + third_digit half2 ...
true
8da21b78fd90a65b70bb461f0370564724ab1dc8
ckabuloglu/interview_prep
/levelOrder.py
939
4.15625
4
''' Level Order Traversal Given a binary tree, print the nodes in order of levels (left to right for same level) ''' # Define the Tree structure class BSTNode: def __init__(self, val): self.val = val self.left = None self.right = None # Define the add method to add nodes to the tree def ad...
true
2c50bed4074123edcc2f4feab539c300a65071be
Garrison50/unit-2-brid
/2.3 Vol/SA.py
279
4.15625
4
def main(): import math radius = float(input("Enter the radius of the sphere")) volume = ((4/3) * math.pi * (pow(radius,3))) sa = (4 * math.pi * (pow(radius,2))) print ("The volume is:", round(volume,2)) print ("The surface area is:", round(sa,2)) main()
true
643730d15360ecc6c8e59db671e489a17932fe08
shakyaruchina/100DaysOfCode
/dayTen/calculator.py
1,182
4.25
4
#Calculator from art import logo #add function def add(n1,n2): return n1+n2 #subtract functuon def subtract(n1,n2): return n1-n2 #divide function def divide(n1,n2): return n1/n2 #multiply function def multiply(n1,n2): return n1*n2 #operation dictionary{key:value} operations = { "+":add, "-":s...
true
827904d6c3c5dd080ce6b3b353967d2f1cc52131
rafaelzottesso/2019-ES-Algoritmos
/aula11-while.py
1,168
4.21875
4
""" -- Estrutura básica do laço de repetição while -- variável de controle iniciada while(condição): . . . incremento da variável de controle """ # # Variável de controle iniciada # cont = 1 # # Condição do while montada de acordo com a variável de controle # while( cont <= 1000 ): # # Código a s...
false
4f6d15c068cce2a7b00df861c2feea7d41a326cb
SamanehGhafouri/DataStructuresInPython
/doubly_linked_list.py
2,468
4.125
4
# Doubly Linked List # Advantages: over regular (singly) linked list # - Can iterate the list in either direction # - Can delete a node without iterating through the list (if given a pointer to the node) class Node: def __init__(self, d, n=None, p=None): self.data = d self.next_node = n ...
true
d16a5a86ee12545676d76241cf3a10d74e709455
Darkeran/Python3
/Exercicios/LoopW_Validação.py
1,289
4.28125
4
# Faça um programa que leia e valide as seguintes informações: # # Nome: maior que 3 caracteres; # Idade: entre 0 e 150; # Salário: maior que zero; # Sexo: 'f' ou 'm'; # Estado Civil: 's', 'c', 'v', 'd'; Nome = input("Digite seu nome: ") while len(Nome) < 3: Nome = input("Digite seu nome: ") Idade = int(...
false
66352731d8b952a633dea499c56cc58903051b4d
nikitakumar2017/Assignment-4
/assignment-4.py
1,450
4.3125
4
#Q.1- Reverse the whole list using list methods. list1=[] n=int(input("Enter number of elements you want to enter in the list ")) for i in range(n): n=int(input("Enter element ")) list1.append(n) print(list(reversed(list1))) #Q.2- Print all the uppercase letters from a string. str1=input("Enter string ") for...
true
413958b6351cf01a519968f52f16d73dffab40b8
fansOnly/Python-test
/learning/常用内建模块/itertools_.py
2,859
4.25
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- # itertools # itertools提供了非常有用的用于操作迭代对象的函数。 import itertools ######################################################################################### # count()会创建一个无限的迭代器 # natuals = itertools.count(1) # for n in natuals: # if n < 5: # print(n) # print('*'*...
false
33a7477b0c51e7f8a4750b3ba62a8902b52f9313
bsdharshini/Python-exercise
/5) While.py
1,837
4.125
4
''' Take 10 integers from keyboard using loop and print their average value on the screen. sum=0 for i in range(0,10): n=int(input()) sum=sum+n print(sum) ''' ''' Print the following patterns using loop : a. * ** *** **** n i star 4 0 1 4 1 2 n=int(input()) for i in range(0,n): ...
false
2abdecd0c2820f8db9ae2efc4252f9815c80d18d
bsdharshini/Python-exercise
/1)printprintprint.py
1,189
4.375
4
#https://www.codesdope.com/practice/python-printprintprint/ #1)Print anything you want on the screen. print("hello") # 2) Store three integers in x, y and z. Print their sum x=10 y=20 z=30 sum=x+y+z print(sum) #3) Store three integers in x, y and z. Print their product. x,y,z=10,20,30 print(x*y*z) #...
true
bf794f5e450f517f9aa56012b18298c471d68999
Kapiszko/Learn-Python
/ex11.py
426
4.15625
4
print("How old are you?", end=' ') age = int(input("Please give your age ")) print("How tall are you?", end=' ') height = int(input("Please give your height ")) print("How much do you weigh?", end=' ') weight = int(input("Please give your weight ")) print (f"So, you're {age} old, {height} tall and {weight} heavy.") s...
true
fc41dcd6953857498946355e64e58b32429fcc45
YashMistry1406/Competitve_Coding-
/sde problems/Array/sort color.py
1,119
4.15625
4
# Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, # with the colors in the order red, white, and blue. # We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. # You must solve this problem witho...
true
4a96f7c36e897f6af65eaa60077bd988d9b7e34b
serubirikenny/Shoppinlist2db
/shop.py
1,043
4.125
4
class ShoppingList(object): """class to represent a shopping list and CRUD methods""" def __init__(self, name): self.name = name self.items = {} def add_item(self, an_item): if an_item.name in self.items: self.items[an_item.name] += an_item.quantity else: ...
true
12682f41edb0a57e5774e5404b11b7a72c1698a8
aarushikool/CrypKool
/OTP.py
2,228
4.3125
4
from random import randint import matplotlib.pyplot as plt #string alphabet is declared here to convert ALPHABET into numerical values #ALPHABET[0] is a blank space ALPHABET = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' def encrypt(text, key): text= text.upper() cipher_text = '' for index, char in enumerate(text): ...
true
cc9caf4d73ee3d43b06d3698abc27888924ac923
garymorrissey/Programming-And-Scripting
/collatz.py
537
4.125
4
# Gary Morrissey, 11-02-2018 # The Collatz Conjecture program i = int(input("Please enter any integer:")) # Prompts you to choose a number, with the next term being obtained from the previous term while i > 1: if i % 2 == 0: i = i / 2 # If the previous term is even, the next term is one half the previo...
true
2b2bdc77c6e116371e56d5df4bb7699bc2dff31a
AmaanHUB/IntroPython
/variables_types/python_variables.py
847
4.34375
4
# How can we create a variable? # variable_name = value # creating a variable called name to store user name name = "Amaan" # declaring a String variable # creating a variable called age to store user age age = 23 # Integer # creating a variable called hourly_wage to store user hourly_wage hourly_wage = 15 # Intege...
true
19387eba9e667955c01c4fe19571af19b890c1d8
clowe88/Code_practicePy
/simple_cipher.py
277
4.15625
4
phrase = input("Enter a word or phrase to be encrypted: ") phrase_arr = [] finished_phrase = "" for i in phrase: phrase_arr.append(i) for x in phrase_arr: num = ord(x) cipher = chr(num + 12) finished_phrase += cipher print (finished_phrase)
true
087bc5cc5c04f905117e7950cfd64b1b927a01f9
manasmishracse/Selenium_WebDriver_With_Python
/PythonTesting/Demo Code/ReadFile.py
305
4.1875
4
# Reading a File Line by Line in Python and reverse it in o/p. lines = [] rev = "" file = open('File_Demo.txt', 'r') lines = file.readlines() print("{}{}".format("Content in File is ", lines)) for i in lines: rev = i + rev print("{}{}".format("Reversed Content of the File is:", rev)) file.close()
true
a7e708c106dc18cdd1b222f807dc6225cb2a2347
satyam-seth-learnings/machine_learning
/Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-3(Day-6)/4.Circle.py
428
4.25
4
# Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle. class Circle: def __init__(self,r): self.radius=r def area(self): return 3.14*self.radius**2 def perimeter(self): return 2*3.14*self.radius c...
true
14746feb3f6c2ef1b1487b1c772a1d17be4e8a8f
satyam-seth-learnings/machine_learning
/Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-1(Day-3)/5.Write a Python program to interchange first and last elements in a list.py
277
4.34375
4
# Write a Python program to interchange first and last elements in a list. # Logic-1 l=[1,2,3,4,5] print(f'List: {l}') l[0],l[-1]=l[-1],l[0] print(f'List: {l}') # Logic-2 # l=[1,2,3,4,5] # print(f'List: {l}') # l.insert(0,l.pop()) # l.append(l.pop(1)) # print(f'List: {l}')
false
5aa478055b9109df4e9b32ddf801473d80399148
satyam-seth-learnings/machine_learning
/Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-2(Day-4)/8.Find cube of all numbers of list and find minimum element and maximum element from resultant list.py
309
4.28125
4
# Using lambda and map calculate the cube of all numbers of a list and find minimum element and maximum element from the resultant list. l=[1,2,6,4,8,9,10] cubes=list(map(lambda x: x**3,l)) print(f'Cube of all numbers: {cubes}') print(f'Minimum element: {min(cubes)}') print(f'Maximum element: {max(cubes)}')
true
0afc2bd9622c2a0a32a3c369733d6df66d8284ce
roycrippen4/python_school
/Assignments/triangle.py
928
4.625
5
# Python Homework 1 - Triangles sides and angles # Roy Crippen # ENG 101 # Due 11/18/2019 # The goal of this code is to take three sides of a triangle from a user and to compute the angles of said triangle. from math import degrees from math import acos # First I will receive the sides of the triangle from the user s...
true
6b47c5254cee29f96045124913f14fee0f53b3c8
lazumbra/Educative-Data-Structures-in-Python-An-Interview-Refresher
/LinkedList/Doubly Linked Lists/main.py
1,673
4.125
4
from LinkedList import LinkedList from Node import Node def delete(lst, value): deleted = False if lst.is_empty(): print("List is Empty") return deleted current_node = lst.get_head() if current_node.data is value: # Point head to the next element of the first element ...
true
51f497fa15c6f77934f98cf1595b66cb7a455ae7
charleycodes/hb-code-challenges
/concatenate-lists-2-13.py
872
4.3125
4
# Whiteboard Easier # Concepts Lists def concat_lists(list1, list2): """Combine lists. >>> concat_lists([1, 2], [3, 4]) [1, 2, 3, 4] >>> concat_lists([], [1, 2]) [1, 2] >>> concat_lists([1, 2], []) [1, 2] >>> concat_lists([], []) [] """ ...
true
afaf0b4d56ec34e86b518d0b0f05a5b31c19e9dc
XiaoA/python-ds
/33_sum_range/sum_range.py
1,279
4.125
4
def sum_range(nums, start=0, end=None): """Return sum of numbers from start...end. - start: where to start (if not provided, start at list start) - end: where to stop (include this index) (if not provided, go through end) >>> nums = [1, 2, 3, 4] >>> sum_range(nums) 10 >>>...
true
2a5576f2f7f10af9f2f23ad68f7270d85e9ef6e3
Chaser/PythonHardWay
/Ex27/Ex27_MemorizingLogic.py
2,805
4.34375
4
def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') return words def sort_words(words): """Sorts the words.""" return sorted(words) def print_first_word(words): """Prints the first word after popping it off.""" word = words.pop(0) ...
true
45fd466c0cfd03262a9baad12133103943aa88c6
sanket-k/Assignment_py
/python-files/Question 3.py
2,008
4.4375
4
# coding: utf-8 # ### Question 3 # ### Note: problem similar to Question 2 # Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The # element value in the i-th row and j-th column of the array should be i*j. # # Note: i=0,1.., X-1; j=0,1,¡ Y-1. # # #### Example # # Suppose th...
true
ab4216252416679138e20fa13c9abdb37f7c73cc
KalinHar/OOP-Python-SoftUni
/workshop/hash_table.py
2,142
4.21875
4
class HashTable: """"The HashTable should have an attribute called array of type: list, where all the values will be stored. Upon initialization the default length of the array should be 4. After each addition of an element if the HashTable gets too populated, double the length of the array ...
true
2777acf9d2f2467191d3227386993968e22a57d7
everqiujuan/python
/day04/code/07_列表list的方法2.py
1,441
4.125
4
# index() : 找出指定元素在列表中第一次出现的下标 list1 = [11, 22, 33, 66, 22, 22, 33, 44] print(list1.index(33)) # 2 # print(list1.index(100)) # 报错, ValueError: 100 is not in list # 内置函数/内置方法 # max() : 找列表中的最大值 m = max(list1) print(m) # min() : 找最小值 print(min(list1)) # sum() : 求和 print(sum(list1)) # 排序 # sor...
false
e542c39b036173198db1d19f045a3959957d5d6f
everqiujuan/python
/day13/code/06_多重继承.py
1,265
4.1875
4
# 人 Person # 员工 Employee # 主管 Manager # 继承:从一般(父类)到特殊(子类) # 父类 class Person(object): def __init__(s, name): s.name = name print("Person,self:", id(s)) def run(self): print(self.name, "在跑步") # 子类 class Employee(Person): def __init__(self, name1, age): ...
false
f2d1cdcbd86af861339970878e3c4bcecd5bf9df
everqiujuan/python
/day09/code/07_迭代器&迭代器对象.py
1,326
4.3125
4
from collections import Iterator # 迭代器 from collections import Iterable # 可迭代对象,迭代器对象 # 迭代器 # 迭代器对象:可以使用for-in循环遍历的 # 迭代器对象:可以使用for-in循环的 # list, tuple, dict, set, str, generator对象 都是迭代器对象 print(isinstance([1, 2], Iterable)) # True print(isinstance((1, 2), Iterable)) # True print(isinstance({}, Iterab...
false
a352cb58f7c04e49769d48edab362c55e03a2142
karslio/PYCODERS
/Assignments-04-functions/11-equal_reverse.py
242
4.25
4
def equal_reverse(): word = input('enter a word') newString = word[::-1] if word == newString: return True else: return False print(equal_reverse()) # Ex: madam, tacocat, utrecht # Result: True, True, False
true
55aa5c2b12663d078a37ff58edcda05416d69f04
madisonstewart2018/quiz1
/main 6.py
1,184
4.46875
4
#this function uses the variables matrix and vector. def matVec(matrix, vector): ''' The function takes in a matrix with a vector, and for each element in one row multiplies by each number in the vector and then adds them together. Function returns a new vector. ''' new_x = [] for i in range(len(matrix)): ...
true
081346e448fc60eec12caf9bab5aca15080bb962
BrianClark1/Python-for-Everybody-Specialization
/Chapter 11/11.2.py
827
4.21875
4
#Looking inside of a file, Extracting numbers and summing them name = input("Enter file:") #Prompt User to input the file if len(name) < 1 : name = "RegexRealSum.txt" #Allows user to simply press enter to open specific file handle = open(name) #assigns the file to a variable name inp = handle.read() #Reads the entir...
true
f9ddc7d5c1236760550c5d868536c748d1769e88
nazhimkalam/Complete-Python-Crash-Couse-Tutorials-Available
/completed Tutorials/bubbleSort.py
706
4.28125
4
#The main difference between bubble sort and insertion sort is that #bubble sort performs sorting by checking the neighboring data elements and swapping them if they are in wrong order #while insertion sort performs sorting by transferring one element to a partially sorted array at a time. #BUBBLE SORT myList = [15,24...
true
b87526548062f13ae7e10e90185550b9c896cee5
nazhimkalam/Complete-Python-Crash-Couse-Tutorials-Available
/completed Tutorials/global, local, nonlocal scope variables.py
1,113
4.59375
5
#The nonlocal keyword is used to work with variables inside nested functions, #where the variable should not belong to the inner function. #Use the keyword nonlocal to declare that the variable is not local. #Example 01 (with nonlocal) def myfunc01(): x = "John" #x is 'John' def myfunc02(): nonlocal x ...
true
ee9e7af06d173872648edb0c4ae4ce925981a930
saketborse/Blink-to-Roll-Dice-with-Eye-Detection
/diceroll.py
648
4.15625
4
import random def dice(): # range of the values of a dice min_val = 1 max_val = 6 # to loop the rolling through user input roll_again = "yes" # loop while roll_again == "yes" or roll_again == "y": #print("Rolling The Dices...") #print("The Values are :") ...
true
56bfcf0cd7d2ffcca129085aa597ec7d19ca1b22
aandr26/Learning_Python
/Coursera/Week3/Week3b/Projects/format.py
1,239
4.21875
4
# Testing template for format function in "Stopwatch - The game" ################################################### # Student should add code for the format function here def format(t): ''' A = minutes, B = tens of seconds, C = seconds > tens of seconds D = remaining tens of seconds. A:BC:D '''...
true
20b6edc6c257810f00377bc18c4fb0c4d5fe7d3a
aandr26/Learning_Python
/Coursera/Week3/Week3b/Exercises/expanding_cricle.py
865
4.125
4
# Expanding circle by timer ################################################### # Student should add code where relevant to the following. import simplegui WIDTH = 200 HEIGHT = 200 radius = 1 # Timer handler def tick(): global radius global WIDTH radius += 2 # Draw handler def draw(canvas): ...
true
1da99068500ac43445324a856ac14ff1f7e1c626
rebel47/PythonInOneVideoByCodeWithHarry
/chapter2solutions.py
886
4.28125
4
# To add two numbers # a = int(input("Enter the first number: \n")) # b = int(input("Enter the second number: \n")) # print("Sum of first and second number is:",a+b) # To find the remainder # a = int(input("Enter the number whose remainder you want to know: \n")) # print("The reaminder of the given number is:", a%2) ...
true
a608c36a28981eb16358dfb74e1414d1b028aacb
rebel47/PythonInOneVideoByCodeWithHarry
/chapter3solutions.py
829
4.40625
4
# # Print user name with Good afternoon message # name = input("Enter your name:\n") # print("Good afternoon", name) # #Print the given name by adding user name # name = input("Enter the Candidate Name:\n") # date = input("Enter the Date:\n") # letter = '''Dear <|NAME|>, # You are selected!! # Date: <|DATE|>''' # le...
true
52deb61b876f65ec65d06c4285f7e34db66ccdec
arushss/Python_Task
/Task01.py
2,516
4.5
4
# Create three variables in a single line and assign different values to them and make sure their data types are different. # Like one is int, another one is float and the last one is a string. x, y, z = 10, 20.5, "Consultadd" print ("x is: ", x) print ("y is: ", y) print ("z is: ", z) # Create a variable of value ty...
true
2f60538072b1e817495b6a4df3036e4a06c72713
BoLindJensen/Reminder
/Python_Code/Snippets/Files/MoreFiles/Open.py
1,513
4.125
4
''' The function open() opens a file. file: path to file (required) mode: read/write/append, binary/text encoding: text encoding eg. utf-8. It is a good idea to always specify this, as you never know what other file systems use as their default Modes: 'r' Read 'w' Write 'x' eXclusive creation, fails if the file alre...
true
ec4d7456fbfaa7bef8bbe1244174b7c984ffd999
BoLindJensen/Reminder
/Python_Code/Snippets/Lists/List_Comprehension.py
225
4.59375
5
# https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions # L3 returns all elements of L1 not in L2. L1 = [1,2,6,8] L2 = [2,3,5,8] L3 = [x for x in L1 if x not in L2] print(L3) #L3 will contain [1, 6].
true
570d466855d3abeb761c3bb07e1f53628b2df264
BoLindJensen/Reminder
/Python_Code/Snippets/Lists/List_Comprehension2.py
950
4.34375
4
''' Python Comprehension works on list[], set{}, dictionaries{key:value} List Comprehension style is Declarative and Functional it is readable, expressive, and effective. [ expr(item) for item in items ] [ expr(item) for item in iterable ] [ expr(item) for item in iterable if predicate(item) ] ''' words = "What is ...
true
cbf441034155917915332a6323df036be5b2f1da
mdmasrurhossain/Learning_Python_Zulu
/quiz_1/Q5.py
567
4.375
4
### Q5: Write a list of of all the datatypes in pythons myList = [16, 'Icecream', [4, "hello"], (5, 10), {'age': 3}] print(myList) print("Number Datatype: ", myList[0]) print("String Datatype: ", myList[1]) print("List Datatype: ", myList[2]) print("Tuple Datatype: ", myList[3]) print("Dictionary Datatype: ...
false
dd428f0b5d9ab2b2a47a7882f75840f9d0dfcfde
jeyaprakash1/List_String_programs
/list_test.py
889
4.375
4
# append function to add element l=[10,20,30,10] l2=l.index(30) print(l2) # insert function to insert a element l1=['a','b','c'] l1.insert(3,'d') print(l1) # Extend one list to another list s1=["one","two","three"] print(len(s1)) s2=[4,5] s1.extend(s2) print(s1) print(len(s1)) # Remove function to remove particul...
false
d31d9c60357120583f0fb35784016b5d561aef81
sgttwld/tensorflow-2-simple-examples
/1b_gradientdescent_gradient.py
831
4.15625
4
""" Example of gradient descent to find the minimum of a function using tensorflow 2.1 with explicit gradient calculation that allows further processing Author: Sebastian Gottwald Project: https://github.com/sgttwld/tensorflow-2.0-simple-examples """ import tensorflow as tf import numpy as np import os os.environ['TF...
true
0a1c8843bdb901ced9951f32ad87bccab0c4e5cd
Marin-Tony/Calculator
/Basic.py
1,593
4.15625
4
def oprtn(a, b): print("1.Addition") print("2.Subtraction") print("3.Division") print("4.Multiplication") #print("5.Percentage") print("5.Remainder") print("Choose the Number specified before each operation to be performed:") oper_selectd = input(" ") if oper_selectd == "1...
false
22c04d4835001a9a7160a5be71e2395427a0f8b6
FernandoSka/Programing-works
/algorithms/forc.py
398
4.21875
4
arreglo = ["elemento1", 1, 2, 3, "hola", 1.8] for element in range(0, len(arreglo)): print(arreglo[element]) break for element in arreglo: print(element) break for element in range(0, len(arreglo)): print(element) break #1. mostrar elementos de la matriz matriz = [["hola ", 5, 8], ["mundo", ...
false
9ca4f40c2b05a7da51e640000c6a37ca88bf91a8
suvratjain18/CAP930Autum
/23AugPractical.py
1,078
4.59375
5
# What Is Sets #collection of well defined things or elements #or # Unorderd collection of distinct hashable elements #In First Create a set s={1,2,3} print(s) print(type(s)) t={'M','K','R'} print(t) print(type(t)) # How you can declare Empty Set using below here # empty_set=set() # it will convert list to string belo...
true
661fe7a34a439278c3830a9b13f4b5f6b8d0521e
AnatoliKosarev/Python-beginner-course--Teclado-
/filesPython/fileImports/user_interactions/myfile.py
1,138
4.21875
4
print(__name__) """ The file that we run always has a __name__ variable with a value of "__main__". That is simply how Python tells us that we ran that file. Running code only in script mode Sometimes we want to include some code in a file, but we only want that code to run if we executed that file directly—and not i...
true
b0410a2b46b734f18da31834065151d53cd37a41
AnatoliKosarev/Python-beginner-course--Teclado-
/advancedPythonDevelopment/itertoolsCombinatoricIterators.py
2,369
4.84375
5
# permutations """ permutations is concerned with finding all of the possible orderings for a given collection of items. For example, if we have the string "ABC", permutations will find all of the ways we can reorder the letters in this string, so that each order is unique. """ from itertools import permutations p_1 =...
true
cda9d69009f9846ad202a73821a95a31b7a0a404
AnatoliKosarev/Python-beginner-course--Teclado-
/pythonFundamentals/enumerateInLoop.py
1,488
4.375
4
friends = ["Rolf", "John", "Anna"] for counter, friend in enumerate(friends, start=1): print(counter, friend) # 1 Rolf # 2 John # 3 Anna friends = ["Rolf", "John", "Anna"] friends_dict = dict(enumerate(friends)) print(friends_dict) # {0: 'Rolf', 1: 'John', 2: 'Anna'} # если не переводить в другой тип (dict, list,...
false
3814a7116033ae2935d0ef09c8d7fae42f29c027
AnatoliKosarev/Python-beginner-course--Teclado-
/advancedPythonDevelopment/namedTuple.py
524
4.1875
4
from collections import namedtuple Student = namedtuple("Student", ["name", "age", "faculty"]) names = ["John", "Steve", "Mary"] ages = [19, 20, 18] faculties = ["Politics", "Economics", "Engineering"] students = [ Student(*student_data) for student_data in zip(names, ages, faculties) ] print(students) old...
true
bb7ba363b2297d7d57b85e3c9b2cd9ce71147235
AnatoliKosarev/Python-beginner-course--Teclado-
/pythonFundamentals/zipFunction.py
2,299
4.65625
5
""" Much like range, zip is lazy, which means it only calculates the next value when we request it. We therefore can't print it directly, but we can convert it to something like a list if we want to see the output """ from itertools import zip_longest student_ids = (112343, 134555, 113826, 124888) names = ("mary", "Ri...
true
36c9c7f2a4f0f955a46fd85c4116897bfbf61143
AnatoliKosarev/Python-beginner-course--Teclado-
/pythonFundamentals/input.py
239
4.15625
4
my_name = "Bob" your_name = input("Enter your name: ") # always returns string print(f"Hello, {your_name}. My name is {my_name}") print() age = int(input("enter your age: ")) months = age * 12 print(f"you have lived for {months} months")
true
0422da106ef0fb9b7e226007c4836aaf20985bc8
AnatoliKosarev/Python-beginner-course--Teclado-
/pythonTextBook/exercises/dictionary/ex-6.7.py
548
4.21875
4
person1 = { 'name': 'John', 'lastname': 'Lennon', 'age': '33', 'city': 'Liverpool' } person2 = { 'name': 'James', 'lastname': 'Hetfield', 'age': '45', 'city': 'San Francisco' } person3 = { 'name': 'Fat', 'lastname': 'Mike', 'age': '19', 'city': 'Los Angeles' } people =...
false
b012c287ee491ed19617ebc9ec1b5d82b89e3d10
AnatoliKosarev/Python-beginner-course--Teclado-
/pythonFundamentals/listComprehension.py
2,079
4.53125
5
# can be used with lists, tuples, sets, dictionaries numbers = [0, 1, 2, 3, 4] doubled_numbers1 = [] for number in numbers: doubled_numbers1.append(number * 2) print(doubled_numbers1) # same can be done with list comprehension which is much shorter doubled_numbers2 = [number2 * 2 for number2 in numbers] print(dou...
true
af12948c9b1f6161862ae5079d03bf8d3595e44e
jsdiuf/leetcode
/src/Powerful Integers.py
1,611
4.1875
4
""" @version: python3.5 @author: jsdiuf @contact: weichun713@foxmail.com @time: 2019/1/6 12:06 Given two non-negative integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0. Return a list of all powerful integers that have value less than or equal to bound. You may re...
true
c167226fbfec1a0ecbf43cfcda87b6e51317e656
jsdiuf/leetcode
/src/N-ary Tree Preorder Traversal.py
835
4.15625
4
""" @version: python3.5 @author: jsdiuf @contact: weichun713@foxmail.com @time: 2018-10-23 9:19 Given an n-ary tree, return the preorder traversal of its nodes' values. For example, given a 3-ary tree: Return its preorder traversal as: [1,3,5,6,2,4]. Note: Recursive solution is trivial, could you do it iteratively?...
true
80c0e24423aa62f932ec85bb6c172dfac5c9244b
jsdiuf/leetcode
/src/Valid Parentheses.py
2,026
4.125
4
""" @version: python3.5 @author: jsdiuf @contact: weichun713@foxmail.com @time: 2018-8-3 9:47 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets mus...
true
40d26a6f9730deb24c97e2793f492213daac4437
jsdiuf/leetcode
/src/Sort Array By Parity II.py
1,137
4.1875
4
""" @version: python3.5 @author: jsdiuf @contact: weichun713@foxmail.com @time: 2018-10-14 9:32 Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even. Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i is even. You may return a...
true
15def978d14ace9dc60ae954f9c18cb1184acff7
sauerseb/Week-Two-Assignment
/program3.py
439
4.34375
4
# __author__ = Evan Sauers (sauerseb) # CIS-125-82A # program3.py # # This program prompts the user for a distance measured in kilometers, converts it to miles, and prints out the results. # K= kilometers # M= miles # Ask user for a distance in kilometers # Convert to miles # (K * .62) K = eval(input("Please enter...
true
3381cbb4e997978ffa139b47868fdb282a00a7db
langestefan/pyluhn
/luhn/luhn.py
1,094
4.25
4
"""Calculate checksum digit from any given number using Luhn algorithm.""" def create_luhn_checksum(number): """ Generates luhn checksum from any given integer number. :param number: Number input. Any integer number. :return: Calculated checksum digit """ str_number = str(number) n_digits ...
true
c0c74fe14d6ff278ee0bc0396d298cf903aa505f
kingsleyndiewo/codex-pythonium
/simple_caesar_cipher.py
806
4.40625
4
# A simple Caesar cipher # Author: Kingsley Robertovich # Caesar cipher is a type of substitution cipher in which each letter in the plaintext is # 'shifted' a certain number of places down the alphabet. In this example we use the ASCII # character set as our alphabet def encipher(clearText, offset = 5): cipherTex...
true
d4cabe574a786147dba2fbb9cee912e24a4a120d
adam-barnett/LeetCode
/unique-paths-ii.py
1,689
4.125
4
""" Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the grid. For example, There is one obstacle in the middle of a 3x3 grid as illustrated below. [[0,0,0], [0,1,0], [0,0,0]] The...
true
71a1e30327e58b46a8851048359e520621d8f088
miaoranren/calculator-2-exercise
/calculator.py
1,411
4.375
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 * while True: response = input("> ") tokens = response.split(' ') if tokens[0] == 'q': print("You will exit!") break ...
true
896c5d1adeafa4ca6833465080583d18dc10dea3
gyuruza921/p139
/main2.py
1,489
4.15625
4
# coding : utf-8 # 文字コードの宣言 #買い物プログラム # 残金 money = 0 # 商品毎の単価 # りんご apple = {"name": "りんご", "price": 500} # = {"name": "", "price": } # バナナ banana = {"name": "バナナ", "price": 400} # ぶどう grape = {"name": "ぶどう", "price": 300} # 果物のリスト fruits = {"apple":apple, "banana":banana, "grape":grape} print(fruits) # 個数 cou...
false
e8860d7c2095fa654b7e6ed28f9a60ce73931491
ptg251294/DailyCodingProblems
/ParanthesesImbalance.py
801
4.3125
4
# This problem was asked by Google. # # Given a string of parentheses, write a function to compute the minimum number of parentheses to be removed to make # the string valid (i.e. each open parenthesis is eventually closed). # # For example, given the string "()())()", you should return 1. Given the string ")(", you sh...
true
c56e83834fe1e889bd985dd43b7d9d62976554d2
ptg251294/DailyCodingProblems
/One2OneCharMapping.py
770
4.125
4
# This problem was asked by Bloomberg. # # Determine whether there exists a one-to-one character mapping from one string s1 to another s2. # # For example, given s1 = abc and s2 = bcd, return true since we can map a to b, b to c, and c to d. # # Given s1 = foo and s2 = bar, return false since the o cannot map to two ch...
true
1a4c2d8a5ff279c6b64d15c8f91670a2f83f956c
Giuco/data-structures-and-algorithms
/course-1-algorithmic-toolbox/week-1/1-max-pairwise-product/max_pairwise_product.py
796
4.15625
4
# python3 from typing import List def max_pairwise_product_original(numbers: List[int]) -> int: n = len(numbers) max_product = 0 for first in range(n): for second in range(first + 1, n): max_product = max(max_product, numbers[first] * numbers[second]) return max_product def max_...
true
03e1f167ce7bf0212b7556e2bb5ef2615ada7488
longm89/Python_practice
/513_find_bottom_left_tree_value.py
1,010
4.125
4
""" Given the root of a binary tree, return the leftmost value in the last row of the tree. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def findB...
true
a18b926704febe19ac9cd70081b09b3ea583fc98
ppysjp93/Effective-Computation-in-Physics
/Functions/lambdas.py
852
4.4375
4
# a simple lambda lambda x: x**2 # a lambda that is called after it is defined (lambda x, y=10: 2*x +y)(42) # just because it isi anonymous doesn't mean we can't give it a name! f = lambda: [x**2 for x in range(10)] print(f()) # a lambda as a dict value d = {'null': lambda *args, **kwargs: None} # lambda as a keywo...
true
5c01549c5e88fef47d466803ace0862a8f2331c2
ppysjp93/Effective-Computation-in-Physics
/Functions/generators.py
1,482
4.4375
4
def countdown(): yield 3 yield 2 yield 1 yield 'Blast off!' # generator g = countdown() next(g) x = next(g) print(x) y, z = next(g), next(g) print(z) for t in countdown(): if isinstance(t, int): message = "T-" + str(t) else: message = t print(message) # A more complex exam...
true
edbb19417baa55c576dd4c029d3f475b060d9e64
computerMoMo/algorithm-python
/select_sort.py
558
4.25
4
# -*- coding:utf-8 -*- import sys def find_largest(sort_arr): res_index = 0 res = sort_arr[0] for i in range(0, len(sort_arr)): if sort_arr[i] > res: res = sort_arr[i] res_index = i return res_index def select_sort(sort_arr): new_arr = [] length = len(sort_arr...
false
2c7926ba3280dbee2c3bb85dd16100a607c5374a
SDSS-Computing-Studies/004-booleans-ssm-0123
/task1.py
602
4.5
4
#! python3 """ Have the user input a number. Determine if the number is larger than 100 If it is, the output should read "The number is larger than 100" (2 points) Inputs: number Outputs: "The number is larger than 100" "The number is smaller than 100" "The number is 100" Example: Enter a number: 100 The number is...
true
2ec3881522fe87180342c17ac80690cbc867112d
KateBilous/Python_Class
/Task_13.py
1,050
4.34375
4
# Пользователь вводит длины катетов прямоугольного треугольника. # Написать функцию, которая вычислит и выведет на экран площадь треугольника и его периметр. # Площадь прямоугольного треугольника S = 1/2 a*b import math class SquareAndPerimOfTriangle: @staticmethod def print_input(): a = int(input(...
false
02b0aeebab04235c4ebd3f1944e059e6faf581d2
kayartaya-vinod/2019_04_PYTHON_NXP
/examples/ex08.py
708
4.21875
4
''' More loop examples: Accept two numbers and print all primes between them ''' from ex07 import is_prime from ex06 import line def print_primes(start=1, end=100): while start <= end: if is_prime(start): print(start, end=', ') start += 1 print() line() # this function re-writes (overwrit...
true
058a01fa70d67c4322fa03dcb7b7ba1bfbf2d5b8
gabrielriqu3ti/GUI_Tkinter
/src/grid.py
381
4.15625
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 13 22:24:18 2020 @author: gabri """ from tkinter import * root = Tk() # Creating Label Widget myLabel1 = Label(root, text = "Hello World!") myLabel2 = Label(root, text = "My name is Gabriel H Riqueti") # Shoving it onto the screen myLabel1.grid(row = 0...
true
876187f5eba3156eeca16e965f281ff5a00a898d
StudentTechClubAsturias/TallerGitBasico
/esPrimo.py
843
4.125
4
""" Autor: X """ #Nota: los primos son: Naturales, > 1, divisibles entre ellos mismo y entre 1 def esPrimo(n): """ Metodo para comprobar si un numero n dado es primo o no params: un numero n return: True si es primo y False de no serlo """ #Si es menor que 2 no puede ser primo if n < 2: return False #El r...
false
8117eed08dbe2803db65510843a217ad1602808e
yhoang/rdm
/IRI/20170619_IRI.py
2,620
4.3125
4
#!/usr/bin/python3.5 ### printing methods # two ways to print in Python name = 'Florence' age = 73 print('%s is %d years old' % (name, age)) # common amongst many programming languages print('{} is {} years old'.format(name, age)) # perhaps more consistent with stardard Python syntax ### dictionary shopping_dict = {'...
true
fe7219d3dcbcb122404675c79678ec2aa46fec85
pascalmcme/myprogramming
/week5/lists.py
392
4.25
4
list = ["a","b","c"] #changeable and orderable collection tuple = (2,3) # not changeable print(type(list)) print(len(tuple)) list.append(99) print(list) newlist = list + [1] print(newlist) lista = [1,2,'a',True] # different data types in list print(lista[0]) print(lista[1:]) # 1 to end print(lista[::-1]) p...
true