blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
33f5c2d803562730098d3b4393d5843d9d2f9d4a
luthraG/ds-algo-war
/general-practice/14_09_2019/p18.py
1,586
4.34375
4
''' https://leetcode.com/problems/unique-email-addresses/ Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name. Besides lowercase letters, these emails may contain '.'s or '+'s....
true
2016817647c32c5e148437225c826b39f2ce8ee4
luthraG/ds-algo-war
/general-practice/10_09_2019/p3.py
2,228
4.125
4
class Node: def __init__(self, data = None): self.data = data self.next = None class LinkedList: def __init__(self): self.start_node = Node() def add_to_start(self, data): node = Node(data) node.next = self.start_node.next self.start_node.next = node ...
true
b3aaf2652c1cfda99a9c3b3c8e1d7d47b358abb4
luthraG/ds-algo-war
/general-practice/18_09_2019/p12.py
1,035
4.15625
4
''' Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","racecar","car"] Output: "" Explanation: There is...
true
6d53601a7fc6a0c2fb2e35f5685770bd5e771798
stollcode/GameDev
/game_dev_oop_ex1.py
2,829
4.34375
4
""" Game_dev_oop_ex1 Attributes: Each class below, has at least one attribute defined. They hold data for each object created from the class. The self keyword: The first parameter of each method created in a Python program must be "self". Self...
true
0f227ae102e644024608c93a33dac90b39f2dcb9
greenblues1190/Python-Algorithm
/LeetCode/14. 비트 조작/393-utf-8-validation.py
1,893
4.15625
4
# https://leetcode.com/problems/utf-8-validation/ # Given an integer array data representing the data, return whether it is a valid UTF-8 encoding. # A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: # For a 1-byte character, the first bit is a 0, followed by its Unicode code. # Fo...
true
bf67b98e1c8d67e03db25488893518e5fd2e3a36
GaiBaDan/GBD-GoodMan
/demo1.py
599
4.5625
5
#1.注释:代码中不会被编译执行的部分(不会起到任何程序作用,用来备注用的) #在说明性文字前加#键可以单行注释 ''' ''' """ A.对程序进行说明备注 B.关闭程序中的某项功能 """ #建议:写程序多写注释 print("HELLO world") ;print("hello python") #每条语句结束后可以没有分号r如果一行要写多条语句,那么每条语句之间用分号隔开 # print("hello world") print("hello world") # print("hello world") print('dandan') # print('hahahahahaha')\ list1 = [...
false
02bd64d1871d08a5ef5354e4962074dc01363b8e
darrenthiores/PythonTutor
/Learning Python/level_guessing.py
2,170
4.125
4
# membuat app number guessing dengan level berbeda import random def low_level() : number = random.randint(1,10) chances = 3 while (chances > 0) : guess = int(input('Your guess : ')) if (guess == number) : print ('Congratss you win the game!!') break elif (g...
true
9b39f95066e6bf5919683302f61adc5f40300a60
younism1/Checkio
/Password.py
1,673
4.15625
4
# Develop a password security check module. # The password will be considered strong enough if its length is greater than or equal to 10 symbols, it has at least # one digit, as well as containing one uppercase letter and one lowercase letter in it. # The password contains only ASCII latin letters or digits. # Input: ...
true
66b8c6815a588d9c9c1bfac47ce0e22d3ebb20f0
cytoly/data_structures
/implementations/LinkedList.py
2,755
4.125
4
from typing import Union class Node: def __init__(self, data=None): self.data = data self.next: Union[Node, ()] = None def has_next(self) -> bool: return self.next is not None class LinkedList: def __init__(self): self.head: Union[Node, ()] = None self.length = 0...
false
522385d08ccd855e401d141f9f4e8ccf1535f926
purwokang/learn-python-the-hard-way
/ex6.py
971
4.15625
4
# creating variable x that contains format character x = "There are %d types of people." % 10 # creating variable binary binary = "binary" # creating variable do_not do_not = "don't" # creating variable y, contains format character y = "Those who know %s and those who %s." % (binary, do_not) # printing content of v...
true
ea1e981b9a899e15fddce5b28d20ea97c05b5ccd
lovingstudy/Molecule-process
/point2Plane.py
1,296
4.15625
4
#--------------------------------------------------------------------------------------------------- # Name: point2Plane.py # Author: Yolanda # Instruction: To calculate the distance of a point to a plane, which is defined by 3 other points, # user should input the coordinates of 3 points in the plane into (x1,y1,z1...
true
8f06c97a2061ed6cdd62c6230d8bf5857210ea84
liu-yuxin98/Python
/chapter7/shape.py
1,033
4.125
4
#-*- coding=utf-8-*- import math class Circle: def __init__(self,radius=1): self.radius=radius def getPerimeter(self): return self.radius*2*math.pi def getArea(self): return self.radius*self.radius*math.pi def setRadius(self,radius): self.radius=radius class Rectangular:...
false
3c1219e7c7c57db39fc61e7551c9e3e8808fadb7
league-python-student/level1-module2-ezgi-b
/_01_writing_classes/_b_intro_to_writing_classes.py
2,725
4.3125
4
""" Introduction to writing classes """ import unittest # TODO Create a class called student with the member variables and # methods used in the test class below to make all the tests pass class Student: def __init__(self, name, grade): self.name = name self.grade = grade self.homework_d...
true
10b98f23aed7717f9648ea95aa78e7ab2790cb52
0t3b2017/CursoemVideo1
/aula06b.py
477
4.3125
4
""" Faça um programa que leia algo pelo teclado e mostre na tela o seu tipo primitivo e todas as informações possíveis sobre ele. """ x=input("Digite algo: ") print("O tipo do valor é {}".format(type(x))) print("O valor digitado é decimal? ",x.isdecimal()) print("O valor digitado é alfanum? ",x.isalnum()) print("O ...
false
4bfba7c91923794a62b17e796ea043d8f8afa543
0t3b2017/CursoemVideo1
/desafio #037.py
2,039
4.125
4
""" desafio #037 Escreva um programa que leia um número inteiro (em decimal) e peça para o usuário escolher qual será a base de conversão: 1 para binário 2 para octal 3 para hexadecimal """ """ num = int(input("Digite um número: ")) opc = int(input(\"""Selecione uma das base de conversão desejada: ...
false
1866eaa566cf7da42fad880204300044ed994fa4
0t3b2017/CursoemVideo1
/desafio #022.py
1,004
4.375
4
""" Crie um programa que leia o nome completo de uma pessoa e mostre: - O nome com todas as letras maiúsculas - O nome com todas as letras minusculas - Quantas letras ao todo (sem considerar espaços) - Quantas letras tem o primeiro nome. """ name = str(input("Type your name: ")).strip() print("Seu nome em letras maiú...
false
e897af19e5fdf1f6ab3568b14ae124c5971a2a57
Prabhjyot2/workshop-python
/L2/P2.py
235
4.40625
4
#wapp to read radius of circle & find the area & circumference r = float(input("Enter the radius ")) pi = 3.14 area = pi * r** 2 print("area=%.2f" %area) cir = 2 * pi * r print("cir=%.4f" %cir) print("area=", area, "cir=", cir )
true
44f9c71e161a2fddd66975520ca4b0444be0fefa
alexcarlos06/CEV_Python
/Mundo 2/Desafio 069.py
2,095
4.15625
4
'''Crie um programa que leia a idade e o sexo de várias pessoas. A cada pessoa cadastrada, o programa deverá perguntar se o usuário quer ou nao continuar. No final, mostre: a) Quantas pessoas tem mais de 18 anos. b) Qantos homens foram cadastrados. c)Quantas mulheres tem mais de 20 anos .''' print('\n{:^100}\n'.format...
false
337341d300ebe5397368e6ca19dcf2ae8c895d3e
alexcarlos06/CEV_Python
/Mundo 2/Desafio 071.py
2,201
4.15625
4
'''Crie um programa que simule o funcionamento de um caixa eletônico. No início, pergunte ao usuário qual será o valor a ser sacado (número inteiro) e o programa vai informar quantas cédulas de cada valor serão entregues. OBS: Considere que o caixa possui cédulas de R$50, R$20, R$10 e R$1''' print('\n{}{:^^100}{}\n'.f...
false
7adc48dd7da8cea5d02cbdc83ea6524f924fc037
alexcarlos06/CEV_Python
/Mundo 1/desafio 008.py
341
4.21875
4
#Escreva um programa que leia um valor em metros e o exiba convertido em centimentros e milimetros m=int(input('Informe a quantidade de metros que desja converter: ')) mm=int(1000) cm=int(100) mmconverte=m*mm cmconverte=m*cm print(' Em {} metros existem {} centimetros e {} milimetros.'.format(m, cmconverte, mmconverte)...
false
532793eb6901f35e2184ab5b510aea233c5a484b
Sher-Chowdhury/CentOS7-Python
/files/python_by_examples/loops/iterations/p02_generator.py
845
4.34375
4
# functions can return multiple values by using the: # return var1,var2....etc # syntax. # you can also do a similar thing using the 'yield' keyword. fruits = ['apple', 'oranges', 'banana', 'plum'] fruits_iterator = iter(fruits) # we now use the 'next' builtin function # https://docs.python.org/3.3/l...
true
8ee8bfee53f3b666a3cddd35bb85ddae2c52e6b8
tntterri615/Pdx-Code-Guild
/Python/lab10unitconverter.py
587
4.125
4
''' convert feet to meters ''' x = int(input('What distance do you want to convert?')) y = input('What are the input units?') z = input('What are the output units?') if y == 'ft': output = x * 0.3048 elif y == 'km': output = x * 1000 elif y == 'mi': output = x * 1609.34 elif y == 'yd': output = x * ...
false
f1497ee3c556984b0c9034b07687c2353046edb5
tntterri615/Pdx-Code-Guild
/Python/lab31atm.py
1,398
4.125
4
''' atm lab ''' class Atm: transaction_list = [] def __init__(self, balance = 0, interest_rate = 0.1): self.balance = balance self.interest_rate = interest_rate def check_balance(self): return self.balance def deposit(self, amount): self.balance += amount sel...
false
9cae7dd953a102a146fe23105b85c64746c2f834
YEJINLONGxy/shiyanlou-code
/matrixmul.py
1,735
4.25
4
#!/usr/bin/env python3 #这个例子里我们计算两个矩阵的 Hadamard 乘积。 #要求输入矩阵的行/列数(在这里假设我们使用的是 n × n 的矩阵)。 n = int(input("Enter the value of n: ")) print("Enter value for the Matrix A") a = [] for i in range(n): a.append([int(x) for x in input().split()]) #print(a) print("Enter value for the Matrix B") b = [] for i in range(n): b.ap...
false
f6cf5dd18f276acb2e83a3f7b2fb701a3b4528f3
YEJINLONGxy/shiyanlou-code
/palindrome_check.py
668
4.25
4
#!/usr/bin/env python3 #回文检查 #回文是一种无论从左还是从右读都一样的字符序列。比如 “madam” #在这个例子中,我们检查用户输入的字符串是否是回文,并输出结果 s = input("Please enter a string: ") z = s[::-1] #把输入的字符串 s 进行倒叙处理形成新的字符串 z if s == z: print("The string is a palindrome") else: print("The string is not a palindrome") #运行程序 #[root@dev1 python_code]# ./palindrome_che...
false
f9886344b8c61878d322680525f4f4afe8220042
abbi163/MachineLearning_Classification
/KNN Algorithms/CustomerCategory/teleCust_plots.py
873
4.125
4
import matplotlib.pyplot as plt import pandas as pd df = pd.read_csv('E:\Pythoncode\Coursera\Classification_Algorithms\KNN Algorithms\CustomerCategory/teleCust1000t.csv') # print(df.head()) # value_counts() function is used to count different value separately in column custcat # eg. # 3 281 # 1 ...
true
491ffe454bdd5161ea332eb5114561b1a56b8e36
sacheenanand/pythondatastructures
/ReverseLinkedList.py
557
4.1875
4
__author__ = 'sanand' # To implement reverse Linked we need 3 nodes(curr, prev and next) we are changing only the pointers here. class node: def __init__(self, value, nextNode=None): self.value = value self.nextNode = nextNode class LinkedList: def __init__(self, head): self.head = he...
true
04dce36f9f552216ea548da767dbf306fc2de8e9
mrvbrn/HB_challenges
/medium/code.py
1,162
4.1875
4
"""TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk. Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/decode algorithm should work. You jus...
true
289820dd78f4cf13538bde92149ae03d3e93784c
mrvbrn/HB_challenges
/hard/patternmatch.py
2,712
4.59375
5
"""Check if pattern matches. Given a "pattern string" starting with "a" and including only "a" and "b" characters, check to see if a provided string matches that pattern. For example, the pattern "aaba" matches the string "foofoogofoo" but not "foofoofoodog". Patterns can only contain a and b and must start with a: ...
true
560459ddf49384a758c3bcfde15517ba99e44077
shaikharshiya/python_demo
/fizzbuzzD3.py
278
4.15625
4
number=int(input("Enter number")) for fizzbuzz in range(1,number+1): if fizzbuzz % 3==0 and fizzbuzz%5==0: print("Fizz-Buzz") elif fizzbuzz % 3==0: print("Fizz") elif fizzbuzz % 5==0: print("Buzz") else: print(fizzbuzz)
true
814d9846600316450e097ef7ce0cb8f40d45efd1
2371406255/PythonLearn
/24_访问限制.py
1,728
4.125
4
#!/usr/bin/env python3 #coding:utf-8 #如果要让内部属性不被外部访问,可以在属性名称前加上两个下划线,这样就变成了私有变量,只能内部访问 class Student(object): def __init__(self, name, score): self.__name = name self.__score = score def print_score(self): print('%s : %s' % (self.__name, self.__score)) stu = Student('BOBO', 90) stu.pri...
false
c21f73253780164661997fa29d873dec5a4803ce
A7xSV/Algorithms-and-DS
/Codes/Py Docs/Zip.py
424
4.4375
4
""" zip() This function returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The returned list is truncated in length to the length of the shortest argument sequence. """ x = [1, 2, 3, 4] y = [5, 6, 7, 8] print x print y zipped = zip(x, y) ...
true
3edc817a68cc1bbf028c1594a2b9b9c78bb4a879
BruceHi/leetcode
/month1/MaxQueue.py
1,378
4.1875
4
# 剑指 offer 59-2:队列的最大值 from collections import deque # class MaxQueue: # # def __init__(self): # self.queue = deque() # # def max_value(self) -> int: # if not self.queue: # return -1 # return max(self.queue) # # def push_back(self, value: int) -> None: # self.qu...
false
44471df9935c1a87147214d0650e534373ed391d
arun-me/copy
/100DaysOfPython/test_bmi.py
424
4.375
4
#bmi calculator height = float(input('enter your height (cms)\n')) weight = float( input('enter your weight (kg)\n')) bmi = round(weight/(height/100)**2,2) if bmi < 18.5: bmi_type="Under Weight" elif bmi < 25 : bmi_type="Normal" elif bmi < 30 : bmi_type="Over Weight" elif bmi< 35 : bmi_type...
false
a194787f8f7e817bf3b7166bcb3b9bce96e024ef
ataylor1184/cse231
/Proj01/Project01.py
1,221
4.46875
4
####################################################### # Computer Project #1 # # Unit Converter # prompt for distance in rods # converts rods to different units as floats # Outputs the distance in multiple units # calculates time spent walking that distance #...
true
793b5d06a3a64bcc3eeefca9fee2e4785ab7295c
Damianpon/damianpondel96-gmail.com
/zjazd I/zadania domowe/zad_domowe_1.py
1,458
4.15625
4
print("Gdzie znajduje się gracz na planszy?") position_of_X = int(input("Podaj pozycję gracza X: ")) position_of_Y = int(input("Podaj pozycję gracza Y: ")) if position_of_X <= 0 or position_of_Y <= 0: print("Gracz znajduje się poza planszą") elif position_of_X <= 40: if position_of_Y <= 40: print("Gr...
false
7f3dc6666df5dbc8b2144dd22a4c175a299aa599
Princess-Katen/hello-Python
/13:10:2020_Rock_Paper_Scissors + Loop _v.4.py
1,696
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 21 13:18:18 2020 @author: tatyanamironova """ from random import randint player_wins = 0 computer_wins = 0 winning_score = 3 while player_wins < winning_score and computer_wins < winning_score: print (f'Player score: {player_wins} Computer sco...
true
556c8b35139d8948b0c218579785dd640b57acde
prateek-chawla/DailyCodingProblem
/Solutions/Problem_120.py
1,456
4.1875
4
''' Question --> This problem was asked by Microsoft. Implement the singleton pattern with a twist. First, instead of storing one instance, store two instances. And in every even call of getInstance(), return the first instance and in every odd call of getInstance(), return the second instance. Approach --> Create two...
true
94f45d00da655948c4efacef3f1918ee06fadc36
evmaksimenko/python_algorithms
/lesson1/ex9.py
480
4.4375
4
# Вводятся три разных числа. Найти, какое из них является средним (больше одного, но меньше другого). a = int(input("Введите первое число: ")) b = int(input("Введите второе число: ")) c = int(input("Введите третье число: ")) r = a if a < b < c or c < b < a: r = b if a < c < b or b < c < a: r = c print("Среднее ...
false
40c7b3a00d05e1618a7a9bc16543e28d8ca048d0
evmaksimenko/python_algorithms
/lesson1/ex7.py
1,096
4.40625
4
# По длинам трех отрезков, введенных пользователем, определить возможность существования треугольника, # составленного из этих отрезков. Если такой треугольник существует, то определить, # является ли он разносторонним, равнобедренным или равносторонним. a = int(input("Введите первую сторону: ")) b = int(input("Введите...
false
8e5c8f5ee8b8540d1c9d91dee38b44d67da57580
franky-codes/Py4E
/Ex6.1.py
433
4.375
4
#Example - use while loop to itterate thru string & print each character fruit = 'BANANA' index = 0 while index < len(fruit): letter = fruit[index] print(letter) index = index + 1 #Exercise - use while loop to itterate thru string backwards fruit = 'BANANA' index = -1 # because len(fruit) - 1 is the last i...
true
8e447141bae311f753957bbb453083c485694a0d
JoaoPauloPereirax/Python-Study
/Mundo2/WHILE/while003.py
1,146
4.25
4
'''Crie um programa que leia dois valores e mostre um menu na tela [1] Somar [2] Multiplicar [3] Maior [4] Novos números [5] Sair do programa Seu programa deverá realizar a operação solicitada em cada caso.''' valor1=int(input('Digite o valor1: ')) valor2=int(input('Digite o valor2: ')) escolha=0 while escolha!=5:...
false
e8309ecf0e484b9ffcffc02dda25e9af28c8cca1
JoaoPauloPereirax/Python-Study
/Mundo2/WHILE/while001.py
296
4.125
4
'''Faça um programa que leia o sexo de uma pessoa, mas só aceite os valores 'M' e 'F'. Caso esteja errado, peça a digitação novamente até ter um valor correto.''' sexo='a' while (sexo.upper()!='M' or sexo.upper()!='F'): sexo=str(input('Digite seu sexo(m/f): ')) print('Fim do programa')
false
a1d9320dd8b18e908293e154403bf4c631c49b21
Anushad4/Python-Deeplearning
/ICP1/reversing a string.py
374
4.15625
4
#def reverse(string): # string = string[::-1] # return string #s = "Anusha" #s = input() #print(s) #print(reverse(s[2::])) lst = [] n = int(input("Enter number of elements : ")) for i in range(0, n): ele = input() lst.append(ele) a = "" for j in lst: a += j print(a) def reverse(string): string = ...
false
43716fe322cd9e307b98cefa32a1e35a1d387b87
omvikram/python-ds-algo
/dynamic-programming/longest_increasing_subsequence.py
2,346
4.28125
4
# Dynamic programming Python implementation of LIS problem # lis returns length of the longest increasing subsequence in arr of size n def maxLIS(arr): n = len(arr) # Declare the list (array) for LIS and # initialize LIS values for all indexes lis = [1]*n # Compute optimized LIS values in bottom up manne...
true
b4c01ca063d09ba24aff1bfe44c719043d24d1c3
omvikram/python-ds-algo
/dynamic-programming/pattern_search_typo.py
1,035
4.28125
4
# Input is read from the standard input. On the first line will be the word W. # On the second line will be the text to search. # The result is written to the standard output. It must consist of one integer - # the number of occurrences of W in the text including the typos as defined above. # SAMPLE INPUT # banana...
true
a3ca34db407b81382afc3e61e6abbc74eed86c3a
omvikram/python-ds-algo
/dynamic-programming/bit_count.py
568
4.3125
4
# Function to get no of bits in binary representation of positive integer def countBits(n): count = 0 # using right shift operator while (n): count += 1 n >>= 1 return count # Driver program i = 65 print(countBits(i)) ########################################################################## # Pytho...
true
5fff518a9ffe783632b8d28920772fbc7ab54467
omvikram/python-ds-algo
/data-strucutres/linked_list.py
1,483
4.4375
4
# Python program to create linked list and its main functionality # push, pop and print the linked list # Node class class Node: # Constructor to initialize # the node object def __init__(self, data): self.data = data self.next = None # LinkedList class class LinkedList: # Function ...
true
8ac6c88830679c6fb29732e283ec1884d30fdaa8
omvikram/python-ds-algo
/data-strucutres/heap.py
742
4.125
4
import heapq ## heapify - This function converts a regular list to a heap. In the resulting heap the smallest element ## gets pushed to the index position 0. But rest of the data elements are not necessarily sorted. ## heappush – This function adds an element to the heap without altering the current heap. ## heappop ...
true
43486f405621613de5d973ecfa3dfed21356969f
Adil-Anzarul/VSC-codes-c-cpp-python
/python_language/W11p2.py
1,257
4.75
5
# Give a string, remove all the punctuations in it and print only the words # in it. # Input format : # the input string with punctuations # Output format : # the output string without punctuations # Example # input # “Wow!!! It’s a beautiful morning” # output # Wow Its a beautiful morning # # Pytho...
true
ddce169af5d2b344a2d3ce1e4e90a8c381f767af
Adil-Anzarul/VSC-codes-c-cpp-python
/python_language/W9p2.py
949
4.1875
4
# Panagrams # Given an English sentence, check whether it is a panagram or not. # A panagram is a sentence containing all 26 letters in the English alphabet. # Input Format # A single line of the input contains a stirng s. # Output Format # Print Yes or No # Example: # Input: # The quick brown fox jumps over a lazy ...
true
7e21b51ec88b79191088614971bbc325fff0fabf
AhhhHmmm/Programming-HTML-and-CSS-Generator
/exampleInput.py
266
4.15625
4
import turtle # This is a comment. turtle = Turtle() inputs = ["thing1", "thing2", "thing3"] for thing in inputs: print(thing) # comment!!! print(3 + 5) # little comment print('Hello world') # commmmmmmm 3 + 5 print("ahhhh") # ahhhh if x > 3: print(x ** 2)
true
851a08f4d1580cde6c19fb9dbc3dd939d0a7b6f3
vdmitriv15/DZ_Lesson_1
/DZ_5.py
1,604
4.125
4
# Запросите у пользователя значения выручки и издержек фирмы. # Определите, с каким финансовым результатом работает фирма (прибыль — выручка больше издержек, или убыток — издержки больше выручки). # Выведите соответствующее сообщение. Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношение прибы...
false
df7282d45332baf2d25d9ca1794b55cd802aac6c
evab19/verklegt1
/Source/models/Airplane.py
1,156
4.25
4
class Airplane: '''Module Airplane class Module classes are used by the logic layer classes to create new instances of Airplane gets an instance of a Airplane information list Returns parameters if successful --------------------------------- ''' ...
true
905df9bcdb837b6e0692e1b2033aff9f72619a45
DrakeDwornik/Data2-2Q1
/quiz1/palindrome.py
280
4.25
4
def palindrome(value: str) -> bool: """ This function determines if a word or phrase is a palindrome :param value: A string :return: A boolean """ result = True value_rev = value[::-1] if value != value_rev: result = False return result
true
15250c4e99d8133175c5956444b1473f70f194bb
Steven98788/Ch.03_Input_Output
/3.1_Temperature.py
446
4.5
4
''' TEMPERATURE PROGRAM ------------------- Create a program that asks the user for a temperature in Fahrenheit, and then prints the temperature in Celsius. Test with the following: In: 32 Out: 0 In: 212 Out: 100 In: 52 Out: 11.1 In: 25 Out: -3.9 In: -40 Out: -40 ''' print("Welcome to my Fahrenheit to Celsius ...
true
30cb2152ba61fdc70e20fde9f9b71daa05ffafa1
divyachandramouli/Data_structures_and_algorithms
/4_Searching_and_sorting/Bubble_sort/bubble_sort_v1.py
555
4.21875
4
# Implementation of bubble sort def bubble_sorter(arr): n=len(arr) i=0 for j in range(0,n): for i in range(0,n-j-1): #In the jth iteration, last j elements have bubbled up so leave them if (arr[i]>arr[i+1]): arr[i],arr[i+1]=arr[i+1],arr[i] return arr array1=[21,4,1,3,9,20,25,6,21,14] prin...
true
3f3205aea8dd64a69b9ed91f6aab600d63da9475
divyachandramouli/Data_structures_and_algorithms
/3_Queue/Queue_builtin.py
384
4.21875
4
# Queue using Python's built in functions # Append adds an element to the tail (newest element) :Enqueue # Popleft removes and returns the head (oldest element) : Dequeue from collections import deque queue=deque(["muffin","cake","pastry"]) print(queue.popleft()) # No operation called popright - you dequeue the head w...
true
1f265b5316c3cd5fd6f103c8cac60a75584e01b3
Lee8150951/Python-Learning
/day05/01-OperateDictionary.py
575
4.375
4
# P88练习 # 练习6-1 man = { 'first_name': 'Jacob', 'last_name': 'Lee', 'age': 22, 'city': 'Shanghai' } print(man) # 练习6-2 略 # 练习6-3 python = { 'dictionary': 'it can store many Key/value pairs', 'list': 'it can store many data, but they can be changed', 'tuple': 'it can store many data, and they ...
false
9ad344b78580699941bee4bf63239492d1b69d85
Lee8150951/Python-Learning
/day07/03-Return.py
835
4.15625
4
# P127练习 # 练习8-6 def city_country(city, country): conclusion = f"{city.title()}, {country.title()}" return conclusion info = city_country("Santiago", "Chie") print(info) info = city_country("Shanghai", "China") print(info) info = city_country("Tokyo", "Japan") print(info) # 练习8-7 def make_album(singer_name, alb...
false
3bed81d65c30f440ee3abd6106801608f9f7e72c
zhanghui0228/study
/python_Basics/memory/mem.py
1,145
4.21875
4
#内存管理机制 ----赋值语句内存分析 ''' 使用id()方法访问内存地址 ''' def extend_list(val, l=[]): print('----------------') print(l, id(l)) l.append(val) print(l, id(l)) return l list1 = extend_list(10) list2 = extend_list(12, []) list3 = extend_list('a') print(list1) print(list2) print(list3) """ 垃圾回收机制: ...
false
137defbc2fbc8cd308d1fb892bfcce9f2f99498a
ola-lola/Python-Projects
/Hangman.py
2,070
4.125
4
import random import time from termcolor import colored print("Hello there!") time.sleep(1) print("If you know some cities from Europe... ") time.sleep(1) print(colored("Let's play HANGMAN!", "green")) time.sleep(1) namey = input("What's your name?: ") time.sleep(1) print( "Hello " + namey + "!\n") time.sleep(1) pr...
false
f1922a5f7e6139b3909e0c804c6277d66e44f314
AliAldobyan/queues-data-structure
/queues.py
2,407
4.15625
4
class Node: def __init__(self, num_of_people, next = None): self.num_of_people = num_of_people self.next = next def get_num_of_people(self): return self.num_of_people def get_next(self): return self.next def set_next(self, next): self.next = next class Que...
false
cc349db0742aaebc7650af633e66bc10cb3f14b2
matheusjunqueiradasilva/Jogo-adivinhacao
/jogo da adivinhacao.py
561
4.15625
4
import random rand = random.randint(1, 200) tentiva = 10 print(" Bem vindo ao jogo da advinhacao!") print(" Tente advinhar o numero sorteado, e ele deve ser menor que 200!") while True: numero1 = int(input("digite o numero: ")) if numero1 == rand: print(" parabens voce acertou! ") break ...
false
5f25a0a9ad7ae81345007761fb6641542edcdd3b
GaoFan98/algorithms_and_ds
/Coursera/1_fibonacci_number.py
697
4.15625
4
# Recursive way # def calc_fib(n): # if n <= 1: # return n # return calc_fib(n-1)+calc_fib(n-2) # n = int(input()) # print(calc_fib(n)) # Faster way of fibonacci # def calc_fib(n): # arr_nums = [0, 1] # # if (n <= 1): # return n # # for i in range(2, n + 1): # arr_nums.append(arr_nums...
false
91a3b5ba76ba9b77775c981e048aec2cae7e8d9d
Fabulinux/Project-Cognizant
/Challenges/Brian-08302017.py
1,007
4.25
4
import sys def main(): # While loop to check if input is valid while(1): # Try/Except statement for raw_input return try: # Prompt to tell user to input value then break out of while val = int(raw_input("Please input a positive integer: ").strip()) break ...
true
78f333af2427a13909aa28b67c4be1675d3e81f7
AlexOKeeffe123/mastermind
/game/board.py
2,682
4.15625
4
import random from typing import Text #Chase class Board: def __init__(self, length): """The class constructor Args: self (Display): an instance of Display """ self._items = {} # this is an empty dictionary self._solutionLength = length def to_string(self): """Convert...
true
1f15da7c30ac1cc5651b23777bda357d6edb6b53
gaogao0504/gaogaoTest1
/homework/pytestagmnt/calculator1.py
818
4.28125
4
""" 1、补全计算器(加法,除法)的测试用例 2、使用数据驱动完成测试用例的自动生成 3、在调用测试方法之前打印【开始计算】,在调用测试方法之后打印【计算结束】 坑1:除数为0的情况 坑2: 自己发现 """ # 被测试代码 实现计算器功能 class Calculator: # 相加功能 def add(self, a, b): return a + b # 相减功能 def sub(self, a, b): return a - b # 相乘功能 def multi(self, a, b): return a * b ...
false
b614122fb0117d4dd5afb5f148f5f803013a3397
LeedsCodeDojo/Rosalind
/AndyB_Python/fibonacci.py
1,355
4.25
4
def fibonacci(n, multiplier=1): """ Generate Fibonacci Sequence fib(n) = fib(n-1) + fib(n-2)*multiplier NB Uses recursion rather than Dynamic programming """ if n <= 2: return 1 return fibonacci(n-1, multiplier) + fibonacci(n-2, multiplier) * multiplier def fibonacciDynamic(n,...
true
7258f76011bedbf7e28c7c9f9f0401e1a2b78f17
ly061/learn
/基础/JSON序列化和反序列化.py
543
4.21875
4
# 序列化:把python转化为json # 反序列化: 把json转为python数据类型 import json # data = {"name": "ly", "language": ("python", "java"), "age": 20} # data_json = json.dumps(data, sort_keys=True) # print(data) # print(data_json) class Man(object): def __init__(self, name, age): self.name = name self.age = age def obj2j...
false
65a0a9921a54d50b0e262cccf64d980c2762f2f7
edwinjosegeorge/pythonprogram
/longestPalindrome.py
838
4.125
4
def longestPalindrome(text): '''Prints the longest Palendrome substring from text''' palstring = set() #ensures that similar pattern is stored only once longest = 0 for i in range(len(text)-1): for j in range(i+2,len(text)+1): pattern = text[i:j] #generates words of min lenght 2 (s...
true
77ffe561d8ff2e08ce5aa7550b81091387ed4981
WellingtonTorres/Pythonteste
/aula10a.py
206
4.125
4
nome = str(input('Qual é o seu nome? ')) if nome == 'Wellington': print('Alem do nome ser bonito é nome da capital da NZ!') else: print('Seu nome é tão normal') print('Bom dia {}!'.format(nome))
false
c3e4d19ad6b650bd400a75799c512bb8eecad4c9
ldswaby/CMEECourseWork
/Week3/Code/get_TreeHeight.py
2,274
4.5
4
#!/usr/bin/env python3 """Calculate tree heights using Python and writes to csv. Accepts Two optional arguments: file name, and output directory path.""" ## Variables ## __author__ = 'Luke Swaby (lds20@ic.ac.uk), ' \ 'Jinkai Sun (jingkai.sun20@imperial.ac.uk), ' \ 'Acacia Tang (t.tang20@imp...
true
d9a442c886eb178e2fab6422e8a1ef44e7e9ab07
bizhan/pythontest3
/chapter_1/range_vs_enumerate.py
1,040
4.1875
4
#print("Hello world") def fizz_buzz(numbers): ''' Given a list of integers: 1. Replace all integers that are evenly divisible by 3 with "fizz" 2. Replace all integers divisble by 5 with "buzz" 3. Replace all integers divisible by both 3 and 5 with "fizzbuzz" >>> numbers = [45, 22,14,65, 97, 72] >>> ...
false
954c952dba2e72d6b70c9d345b96090b0a43b732
timmy61109/Introduction-to-Programming-Using-Python
/examples/TestSet.py
549
4.3125
4
from Set import Set set = Set() # Create an empty set set.add(45) set.add(13) set.add(43) set.add(43) set.add(1) set.add(2) print("Elements in set: " + str(set)) print("Number of elements in set: " + str(set.getSize())) print("Is 1 in set? " + str(set.contains(1))) print("Is 11 in set? " + str(set.contains(11)))...
true
f20df9950890ea3b43729837524065283366aa60
timmy61109/Introduction-to-Programming-Using-Python
/examples/ComputeFactorialTailRecursion.py
322
4.15625
4
# Return the factorial for a specified number def factorial(n): return factorialHelper(n, 1) # Call auxiliary function # Auxiliary tail-recursive function for factorial def factorialHelper(n, result): if n == 0: return result else: return factorialHelper(n - 1, n * result) # Recursive cal...
true
0ad23dca684097914370ac9f35a385b80ed74cc4
timmy61109/Introduction-to-Programming-Using-Python
/examples/ComputeLoan.py
687
4.21875
4
# Enter yearly interest rate annualInterestRate = eval(input( "Enter annual interest rate, e.g., 8.25: ")) monthlyInterestRate = annualInterestRate / 1200 # Enter number of years numberOfYears = eval(input( "Enter number of years as an integer, e.g., 5: ")) # Enter loan amount loanAmount = eval(input("Enter l...
true
97a050e009a2c1e53a1842a6c7de60a6d6148b90
timmy61109/Introduction-to-Programming-Using-Python
/examples/QuickSort.py
1,267
4.21875
4
def quickSort(list): quickSortHelper(list, 0, len(list) - 1) def quickSortHelper(list, first, last): if last > first: pivotIndex = partition(list, first, last) quickSortHelper(list, first, pivotIndex - 1) quickSortHelper(list, pivotIndex + 1, last) # Partition list[first..last] def pa...
true
2b6c63f938d13dc8103f3cb8d5f7261f04c4676c
timmy61109/Introduction-to-Programming-Using-Python
/examples/Decimal2HexConversion.py
745
4.375
4
# Convert a decimal to a hex as a string def decimalToHex(decimalValue): hex = "" while decimalValue != 0: hexValue = decimalValue % 16 hex = toHexChar(hexValue) + hex decimalValue = decimalValue // 16 return hex # Convert an integer to a single hex digit in a character ...
false
324bb0fd6f126c77d953ba9dc1096f8bdb0d9a50
timmy61109/Introduction-to-Programming-Using-Python
/examples/SierpinskiTriangle.py
2,218
4.25
4
from tkinter import * # Import tkinter class SierpinskiTriangle: def __init__(self): window = Tk() # Create a window window.title("Sierpinski Triangle") # Set a title self.width = 200 self.height = 200 self.canvas = Canvas(window, width = self.width...
true
bf8d3d46a74e9da8fe560231ceb161cd57a3316d
timmy61109/Introduction-to-Programming-Using-Python
/examples/MergeSort.py
1,246
4.21875
4
def mergeSort(list): if len(list) > 1: # Merge sort the first half firstHalf = list[ : len(list) // 2] mergeSort(firstHalf) # Merge sort the second half secondHalf = list[len(list) // 2 : ] mergeSort(secondHalf) # Merge firstHalf with secondHalf into list ...
true
674a0def98a2f37c3dae8cf1ce070c767431b66a
timmy61109/Introduction-to-Programming-Using-Python
/examples/EfficientPrimeNumbers.py
1,451
4.15625
4
def main(): n = eval(input("Find all prime numbers <= n, enter n: ")) # A list to hold prime numbers list = [] NUMBER_PER_LINE = 10 # Display 10 per line count = 0 # Count the number of prime numbers number = 2 # A number to be tested for primeness squareRoot = 1 # Check whether numbe...
true
3eea73798a4ddc9043f2123d5ba6f919ca239929
timmy61109/Introduction-to-Programming-Using-Python
/examples/DataAnalysis.py
496
4.15625
4
NUMBER_OF_ELEMENTS = 5 # For simplicity, use 5 instead of 100 numbers = [] # Create an empty list sum = 0 for i in range(NUMBER_OF_ELEMENTS): value = eval(input("Enter a new number: ")) numbers.append(value) sum += value average = sum / NUMBER_OF_ELEMENTS count = 0 # The number of elements above ave...
true
255e39ff64323b2afa0102ac92302511229317d6
timmy61109/Introduction-to-Programming-Using-Python
/examples/TwoChessBoard.py
1,263
4.15625
4
import turtle def main(): drawChessboard(-260, -20, -120, 120) # Draw first chess board drawChessboard(20, 260, -120, 120) # Draw second chess board turtle.hideturtle() turtle.done() # Draw one chess board def drawChessboard(startx, endx, starty, endy): # Draw chess board borders turtle.pens...
true
ec569b9b7975319724f3cc613fe4c45587fda197
peteasy/estrutura-de-dados
/AC 10 - Estrutura de dados - Merge sort.py
1,798
4.34375
4
# Estrutura de dados # Atividade Contínua 10 # Alunos: # André Niimi RA 1600736 # Caique Tuan RA 1600707 # Gustavo Andreotti RA 1600044 #Linguagem de programação utilizada: Python # inicio da função recursiva def mergeSort(lista): # Dividindo a lista em duas pa...
false
6bfb64ca94d7670bada63dfcd9229cba6baa3d25
wjr0102/Leetcode
/Easy/MinCostClimb.py
1,094
4.21875
4
#!/usr/local/bin # -*- coding: utf-8 -*- # @Author: Jingrou Wu # @Date: 2019-05-07 01:46:49 # @Last Modified by: Jingrou Wu # @Last Modified time: 2019-05-07 01:53:03 ''' On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two s...
true
f7a5fe592f5c42ffa1b5d8f6d63d11d588403556
ujjwalbaid0408/Python-Tutorial-with-Examples
/Ex22_StructuringElementForMorphological Transformations.py
697
4.15625
4
# Structuring element """ We manually created a structuring elements in the previous examples with help of Numpy. It is rectangular shape. But in some cases, you may need elliptical/ circular shaped kernels. So for this purpose, OpenCV has a function, cv2.getStructuringElement(). You just pass the shape and size...
true
da60d5b35c0c7be1a238dd303ce6ce1f07d9ae80
Max-Fu/MNISTPractice
/Digits_With_Neural_Network.py
1,035
4.21875
4
#!/usr/bin/python #Import data and functions from scikit-learn packets, import plotting function from matplotlib from sklearn.neural_network import MLPClassifier import matplotlib.pyplot as plt from sklearn import datasets from sklearn import svm #load the digits and asign it to digits digits = datasets.load_digits...
true
e070f5c318c6b44e4d5661509b855ff82f2621d7
Gabrihalls/Estudos-de-python
/desafios/dsf003.py
244
4.125
4
print('-----------------------TERCEIRO DESAFIO-----------------------') primeiro = int(input('Qual primeiro número de sua soma?')) segundo = int(input('Qual segundo número de sua soma?')) print('O resulta de sua soma é:',primeiro+segundo)
false
521f7092961eafb8ec49952366a9457e6549341f
HackerajOfficial/PythonExamples
/exercise1.py
348
4.3125
4
'''Given the following list of strings: names = ['alice', 'bertrand', 'charlene'] produce the following lists: (1) a list of all upper case names; (2) a list of capitalized (first letter upper case);''' names = ['alice', 'bertrand', 'charlene'] upNames =[x.upper() for x in names] print(upNames) cNames = [x.title() f...
true
fd9c99441cba0d403b6b880db4444f95874eeb0c
micriver/leetcode-solutions
/1684.py
2,376
4.3125
4
""" You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed. Return the number of consistent strings in the array words. Example 1: Input: allowed = "ab", words = ["ad","bd","aaab","baa","ba...
true
aab785831638f7e29f6ca68343eff9c5cdc29c0e
micriver/leetcode-solutions
/1470_Shuffle_Array.py
983
4.375
4
""" Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. Return the array in the form [x1,y1,x2,y2,...,xn,yn]. Example 1: Input: nums = [2,5,1,3,4,7], n = 3 Output: [2,3,5,4,1,7] Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7]. Example 2:...
true
26b569a159c98d69b9bdadbb2c8e498bacc41edf
sumibhatta/iwbootcamp-2
/Data-Types/26.py
348
4.3125
4
#Write a Python program to insert a given string at the beginning #of all items in a list. #Sample list : [1,2,3,4], string : emp #Expected output : ['emp1', 'emp2', 'emp3', 'emp4'] def addString(lis, str): newList = [] for item in lis: newList.append(str+"{}".format(item)) return newList print(a...
true
3151f1dd3c21b3603d8c616b643cdfb3f25d79a3
sumibhatta/iwbootcamp-2
/Data-Types/12.py
218
4.21875
4
#Write a Python script that takes input from the user and # displays that input back in upper and lower cases. string = "Hello Friends" upper = string.upper() lower = string.lower() print(string) print(upper) print(lower)
true
aa5cdbd2c62421ab8a68d3112e4703ff70504bff
KenFin/sarcasm
/sarcasm.py
1,715
4.25
4
while True: mainSentence = input("Enter your sentence here: ").lower() # making everything lowercase letters = "" isCapital = 0 # Re-initializing variables to reset the sarcastic creator for letter in mainSentence: if letter == " ": # If there's a space in the sentence, add it back into the final sentence...
true
f44e6b5789ee7c3d75a1891cb4df186016ff8d1a
tgm1314-sschwarz/csv
/csv_uebung.py
2,240
4.34375
4
import csv class CSVTest: """ Class that can be used to read, append and write csv files. """ @staticmethod def open_file(name, like): """ Method for opening a csv file """ return open(name, like) @staticmethod def get_dialect(file): """ Me...
true
c1249eca315f652960a09c2b903c93121c8a19c4
saiso12/ds_algo
/study/OOP/Employee.py
452
4.21875
4
''' There are two ways to assign values to properties of a class. Assign values when defining the class. Assign values in the main code. ''' class Employee: #defining initializer def __init__(self, ID=None, salary=None, department=None): self.ID = ID self.salary = salary self.departme...
true
60f24bde8f1acd6637010627b439584eb8d08f32
mosesobeng/Lab_Python_04
/Lab04_2_3.py
1,048
4.3125
4
print 'Question 2' ##2a. They will use the dictionary Data Structure cause they will need a key and value ## where stock is the key and price is the value shopStock ={'Apples ' : '7.3' , 'Bananas ' : '5.5' , 'Bread ' : '1.0' , 'Carrots ':'10.0','Champagne ':'20.90','Strawberries':'32.6'}...
true
f63bd219bb89d94f41d8aecea52d6b87ab0ab3a7
rafaelfneves/ULS-WEB-III
/aula03/aula3.py
2,116
4.34375
4
# -*- coding: utf-8 -*- print('==============================[INICIO]==============================') #String frase=('Aula Online') #upper() - para colocar em letra maiuscula print(frase.upper()) print(frase.upper().count('O')) #lower() - para colocar em letra minúscula print(frase.lower()) #capi...
false
863c76edceb3d1e98acd52d7b45b114153532a1f
PreetiChandrakar/Letsupgrade_Assignment
/Day1.py
634
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[4]: num=int(input("Enter Number to check prime or not:")) m=0 i=0 flag=0 m=int(num/2) for i in range(2,m+1): if(num%i==0) : print("Number is not prime") flag=1 break if(flag==0) : print("Number is prime") # In[3]: ...
true