blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1c53c34020a44ea95474c71168179987913b4bcd
lvncnt/Leetcode-OJ
/Dynamic-Programming/python/Unique-Paths.py
1,069
4.1875
4
""" Problem: A robot is located at the top-left corner of a m x n grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? Note: m and n will be at most 1...
true
782bd10d6cad1e6f4893e311078968e191bc236b
dktlee/university_projects
/intro_to_comp_sci_in_python/bar_chart.py
2,705
4.53125
5
## ## Dylan Lee ## Introduction to Computer Science (2015) ## # bar_label_length(data, max_label_length, index) produces the length # of the largest bar label that will be created from data, which is # max_bar_length, by checking to see if the label in data at index is bigger # than the max_bar_length so far # requi...
true
e7953f05fcd5ee001e04a473e1ed6b315c9a304e
akhitab-acharya/Mchine-learning
/Python.py
1,981
4.34375
4
ERROR: type should be string, got "https://cs231n.github.io/python-numpy-tutorial/\nPython & Numpy Tutorial by Stanford - It's really great and covers things from the ground up.\n\n#Quicksort\n\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quicksort(left) + middle + quicksort(right)\n\nprint(quicksort([3,6,8,10,1,2,1]))\n\n\n# Prints \"[1, 1, 2, 3, 6, 8, 10]\"\n\n-----------------------------------------\n\n#LIST COMPREHENSION:\n\nnums = [1, 2, 3, 4]\nnum_squares = [x**2 for x in nums]\nprint(num_squares)\n\n\n# list comprehension with conditions:\n\nnum_even_square = [x**2 for x in nums if x % 2 == 0]\nprint(num_even_square)\n\n------------------------------------------------------------\n\n# DICTIONARY COMPREHENSION:\n\nnums = [0, 1, 2, 3, 4]\neven_num_to_square = {x: x ** 2 for x in nums if x % 2 == 0}\nprint(even_num_to_square) # Prints \"{0: 0, 2: 4, 4: 16}\"\n\n--------------------------------------------------------------------------------------\ns = \"hello\"\nprint(s.capitalize()) # Capitalize a string; prints \"Hello\"\nprint(s.upper()) # Convert a string to uppercase; prints \"HELLO\"\nprint(s.rjust(7)) # Right-justify a string, padding with spaces; prints \" hello\"\nprint(s.center(7)) # Center a string, padding with spaces; prints \" hello \"\nprint(s.replace('l', '(ell)')) # Replace all instances of one substring with another;\n # prints \"he(ell)(ell)o\"\nprint(' world '.strip()) # Strip leading and trailing whitespace; prints \"world\"\n------------------------------------------------------------------------------------------\n\n# EX. OF ENUMERATE:\n\nanimals = {'cat', 'dog', 'cow'}\nfor idx, animal in enumerate(animals):\n print('#%d %s' % (idx + 1, animal))\n\n# Prints \"#1: cat\", \"#2: dog\", \"#3: monkey\", each on its own line\n\n-------------------------------------------------------------------\n\n\n"
true
320fec5ea73f27447974d41dbcf7b80251e4bc88
Viheershah12/python-
/Practice_Projects/odd-even.py
656
4.21875
4
num = int(input("Enter a number of your choice: ")) check = 2 dev = num % 2 if dev > 0: print("The number ",num," is a odd number") else: print("The number ",num," is a even number") # more complex function to see if the number is divisible by 4 num = int(input("give me a number to check: ")) check = int(i...
true
9cbbed20321eab76d4f326fc164df529b8b64b88
Viheershah12/python-
/FutureLearn/conditional/IFSTATEMENTS.py
295
4.34375
4
x = 5 if x == 5: print("this number is ",x) else: print("this number is not",x) if x > 5 : print("this number is greater than ",x) else: print("this number is less than or equal to ",x) if x != 5: print("this number is not equal to ",x) else: print("this number is ",x)
true
a88fa735ad3cccfca126e03b4005848c88fd569d
Viheershah12/python-
/Lessons/calculatorfunc.py
371
4.25
4
#define a function to return the square of a given number #define anathor function to add up the numbers #use the functions created to solve the equation # x = a + b^2 def add(x,y): return x + y def square(x): return x * x num1 = int(input("Enter number 1: ")) num2 = int(input("Enter number 2: ")) x = add(nu...
true
a1342fca4f28ec604cc73abfc1e7372ed1eb86c9
vamotest/yandex_algorithms
/12_01_typical_interview_tasks/E. Convert to binary system.py
273
4.1875
4
def binary_convert(number): binary_number = '' while number > 0: binary_number = str(number % 2) + binary_number number = number // 2 return binary_number if __name__ == '__main__': binary = binary_convert(int(input())) print(binary)
false
54af20a4223a7fce77f976c6063056318656c59a
vamotest/yandex_algorithms
/12_01_typical_interview_tasks/L. Extra letter.py
427
4.125
4
from itertools import zip_longest def define_anagrams(first, second): li = list(zip_longest(first, second)) for letter in li: if letter[0] != letter[1]: return letter[1] if __name__ == '__main__': first_word = ''.join(sorted(list(str(input())))) second_word = ''.joi...
true
414441654abcc71a08ba8a04f1d38f17f5c26184
mtavecchio/Other_Primer
/Python/lab4/circle.py
1,075
4.40625
4
#!/usr/local/bin/python3 #FILE: circle.py #DESC: A circle class that subclasses Shape, with is_collision(), distance(), and __str__() methods from shape import Shape from math import sqrt class Circle(Shape): """Circle Class: inherits from Shape and has method area""" pi = 3.14159 def __init__(self, r = 1...
true
1a468b1e78271d168daf89fadb04ea212bd91b50
foobar167/junkyard
/simple_scripts/longest_increasing_subsequence.py
2,000
4.25
4
l = [3,4,5,9,8,1,2,7,7,7,7,7,7,7,6,0,1] empty = [] one = [1] two = [2,1] three = [1,0,2,3] tricky = [1,2,3,0,-2,-1] ring = [3,4,5,0,1,2] internal = [9,1,2,3,4,5,0] # consider your list as a ring, continuous and infinite def longest_increasing_subsequence(l): length = len(l) if length == 0: return 0 # list is ...
true
7554a545e73e15f55208072f9e28dc3d10bb53ee
MaxwellGBrown/tom_swift
/tom_swift.py
1,895
4.1875
4
"""Trigrams application to mutate text into new, surreal, forms. http://codekata.com/kata/kata14-tom-swift-under-the-milkwood/ """ from collections import defaultdict import random def read_trigrams(text): """Return a trigrams dictionary from text.""" trigrams = defaultdict(list) split_text = text.split...
true
b96368a791ee9de9a605eee3634de0482ad08643
ashwani99/dgplug-python-exercises
/4-pick-fruits-from-basket/solution.py
315
4.1875
4
"""Given a list basket = ["apple", "banana", "pineapple", "mango"] pick out the fruits whose name starts with a vowel.""" basket = ["apple", "banana", "pineapple", "mango"] print('Fruits whose name start with a vowel are:') for fruit in basket: if fruit[0] in ('a', 'e', 'i', 'o', 'u'): print(fruit)
false
a672c36493d46e20be291214640e0fbe11f2162f
Devfasttt/Tkinker
/Positioning With Tkinter's Grid System.py
469
4.375
4
#import tkinter from tkinter import * #main window root=Tk() #create a label widget myLabel1=Label(root, text="hello i am a good, really good person")#.grid(row=0, column=0) myLabel2=Label(root, text="Who are you?")#.grid(row=3, column=7) myLabel3=Label(root, text=" ")#.grid(row=8, column=5) #shovi...
true
527fc33c42c57314783a3c73ba753bc37cde9a36
vishaltanwar96/DSA
/problems/mathematics/integer_to_roman.py
1,698
4.375
4
def int_to_roman(num: int) -> str: """ number is represented as its place value i.e. 5469 = 5000 + 400 + 60 + 9 Conversion is supported till 9999. A helper hashmap is needed to map values to a string representation of that number in roman. For converting a number to roman number we follow a simple s...
true
872fa237b31821e8cc70700017314d2273a9ea9f
jaejun1679-cmis/jaejun1679-cmis-cs2
/startotend.py
946
4.15625
4
import time def find(start, end, attempt): if start > end: countdownfrom(start, end, attempt) elif end > start: countupfrom(start, end, attempt) def countdownfrom(start, end, attempt): if start == end: print "We made it to " + str(end) + "!" else: time.sleep(1) ...
true
f93622696104e20e2079975a9cd6b98ce5a75a2d
gk90731/100-questions-practice
/16.py
234
4.25
4
#Please complete the script so that it prints out the value of key b . #d = {"a": 1, "b": 2} #Expected output: 2 d = {"a": 1, "b": 2} print(d["b"]) # lists have indexes, while dictionaries have keys which you create by yourself.
true
07d6bdf68d139c030ecb46a0a789146621671217
matttu120/Python
/HackerRank/WhatsYourName.py
724
4.1875
4
''' Problem Statement Let's learn the basics of Python! You are given the first name and the last name of a person. Your task is to read them and print the following: Hello firstname lastname! You just delved into python. It's that simple! In Python you can read a line as a string using s = raw_input() #here s read...
true
ff0ffeeacbb85ffa4b38a14951aa7856a8baba1c
jmizquierdovaldes/hwtest
/Basico2.py
2,203
4.53125
5
# Se utiliza para comentarios #Crear un string #Se puede crear sting con comillas dobles o simples. El programa es sensible a #el uso de mayusculas "Hello Word" 'Hola Mundo' print("Hello Word") print('Hola Mundo') #Para saber que tipo de dato se utiliza el comando type #Va a entregar como salida class string ya qie ...
false
eb9f909b5f7c13edf72d05b8554dd8608f21acd7
Eliacim/Checkio.org
/Python/Home/Sun-angle.py
1,503
4.46875
4
''' https://py.checkio.org/en/mission/sun-angle/ Every true traveler must know how to do 3 things: fix the fire, find the water and extract useful information from the nature around him. Programming won't help you with the fire and water, but when it comes to the information extraction - it might be just the thing you...
true
3baebfc0fe2aa3a56263a967dcb288b2fd88b6da
Eliacim/Checkio.org
/Python/Electronic-Station/All-upper-ii.py
769
4.5
4
''' https://py.checkio.org/en/mission/all-upper-ii/ Check if a given string has all symbols in upper case. If the string is empty or doesn't have any letter in it - function should return False. Input: A string. Output: a boolean. Precondition: a-z, A-Z, 1-9 and spaces ''' def is_all_upper(text: str) -> bool: ...
true
59c8a0575f9a59348cfcb6a0fb8029f9c3b32366
Eliacim/Checkio.org
/Python/Mine/Fizz-buzz.py
1,125
4.46875
4
''' https://py.checkio.org/en/mission/fizz-buzz/ Fizz Buzz Elementary "Fizz buzz" is a word game we will use to teach the robots about division. Let's learn computers. You should write a function that will receive a positive integer and return: "Fizz Buzz" if the number is divisible by 3 and by 5; "Fizz" if the numb...
true
b8b26c1d753a8c1511d2243bb31a373790e6ce0a
ITorres20/week2-hello-world
/helloworld.py
626
4.46875
4
#Ivetteliz Torres # this program is suppose to display the hello world greeting in three different languages language1= 'Hola Mundo!' language2= 'Ola Mundo!' language3= 'Bonjour le monde!' print 'Hello World!' # greeting print 'Please select one of the following languages.' # ask the user for language selection #lan...
true
ee36f0aec25efa6feee970b78f9abc5195d15f68
zsx29/python
/Ch04/4_3_Set.py
543
4.1875
4
""" 날짜 : 2021/04/27 이름 : 박재형 내용 : 파이썬 자료구조 Set 실습 교재 p96 """ # Set = 집합주머니, 순서X, 중복X # Set 생성 # set1 = {1, 2, 3, 4, 5, 3} print(type(set1)) print(set1) # 3은 중복값이라 출력되지 않음. set2 = set("hello world!") print(type(set1)) print(set2) # 개별적인 문자로 출력, 스페이스도 문자로 취급 = " ", 순서도 없음 # Set 출력 = List 변환 후 출력 # list1 = list(set1)...
false
95386897bf9f6d390f26631923c86c1feef34507
zsx29/python
/Book/Exam_2/ex2_7.py
893
4.40625
4
""" 날짜 : 2021-05-13 이름 : 박재형 내용 : 파이썬 클래스 상속 연습문제. """ class Person: def __init__(self, name, age): self.name = name self.age = age def hello(self): print("~~~~~~~~~~~~~") print("이름 :", self.name) print("나이 :", self.age) class Student(Person): def...
false
167b769fa204a94e3d31747b0bee0962c13f6c68
Speg937/python-practice
/madlibs.py
1,024
4.28125
4
# #for example # someone = "Harry" # #few ways to do ===> # print("Say hi to " + someone) # print("Say hi to {}".format(someone)) # print(f"Say hi to {someone}") Season = input("Enter a Season: ") auxiliary_verb = input("Enter a auxiliary verb: ") print(auxiliary_verb + " I compare thee to a " + Season +"'s day?\n Th...
false
5b0002f4992b9cd73d114d3cc2fe02735a473e36
anchaubey/pythonscripts
/file_read_write_operations/file1.py
2,790
4.71875
5
There are three ways to read data from a text file. read() : Returns the read bytes in form of a string. Reads n bytes, if no n specified, reads the entire file. File_object.read([n]) readline() : Reads a line of the file and returns in form of a string.For specified n, reads at most n bytes. However, does not reads ...
true
7fb04b986773cf7a002ceb8078dc11f6b3f9b6b5
learnMyHobby/list_HW
/sets.py
586
4.5625
5
# A = [‘a’,’b’,’c’,’d’] B = [‘1’,’a’,’2’,’b’] # Find a intersection b and a union b import math # declaring the function def Union(A,B): result = list(set(A) | set(B)) # | it is or operator it adds the list since we cannot return result # add the sets # finding the intersection of li...
true
b2358665ea9f13f35c00143fdb19b89cb52959cb
jhhalls/machine_learning_templates
/Clustering/k-means.py
1,926
4.34375
4
""" @author : jhhalls K - MEANS 1. Import the libraries 2. Import the data 3. Find Optimal number of clusters 4. Build K-means Clustering model with optimal number of clusters 5. Predict the Result 6. Visualize the clusters """ import numpy as np import matplotlib.pyplot as plt import pandas as pd #import mall dat...
true
f13f34892527aea07186b8785b0d083bb9fed5ef
SJChou88/dsp
/python/q8_parsing.py
915
4.3125
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
true
9a12200c5d3af09cc03550fb4f3449cd5be6dfdd
susunini/leetcode
/110_Balanced_Binary_Tree.py
2,508
4.15625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): """ Wrong. Different fromt this problem, another definition of height balanced tree. -> max depth of leaf node - min...
true
fc81d349674608957642b6ef0663e1a1c6433370
susunini/leetcode
/143_Reorder_List.py
1,109
4.125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): """ Linked List. Classic problem. It is composed of three steps which are commonly used for different linked list problems. step ...
true
b98bd948a6cf84a855a21a9912242964ff285ea3
RonKang1994/Practicals_CP1404
/Practical 4/Lecture 4.py
779
4.21875
4
VOWELS_CHECK = 'aeiou' def check_vowel(): name = str(input("Name: ")) letter = 0 vowel = 0 for char in name: letter += 1 for v_check in VOWELS_CHECK: if char.lower() == v_check.lower(): vowel += 1 print("Out of {} letters {} has {} vowels".format(letter,...
true
d7fe636964234deb552b42b3ee84fd2e5e67d486
scorp6969/Python-Tutorial
/math/indexing.py
462
4.28125
4
# slicing = create substring by extracting elements from another string # indexing[] or slice() # [start:stop:step] name = 'Rocky Rambo' first_name = name[0:5] last_name = name[6:11] print('method 1') print(first_name) print(last_name) f_name = name[:5] l_name = name[6:] print('') print('method...
false
cea319acb2704979a43663448216e9cc322e3feb
LizhangX/DojoAssignments
/PythonFun/pyFun/Multiples_Sum_Average.py
690
4.4375
4
# Multiples # Part I - Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do this exercise. for i in range(0,1000): if i % 2 != 0: print i # Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000. for i in range(5,1000000):...
true
180f640a3db8b9ba5ec1dba6d8c0605968ac0fa1
xdisna2/4FunctCalc
/test.py
876
4.4375
4
# Testing type conversions # Entering an int x = float(input("Number 1:")) # Convert to float # So matter its a string it will include the .0 to make it a float print(x) # Change from float to int x = 11.0 print(type(x)) x = round(11.0) print(type(x)) # Test out is_integer function # Note to self you must declare it...
true
757e96688c44e4f4994e151c5b664878d2a2c8d7
RAMYA-CP/PESU-IO-SUMMER
/coding_assignment_module1/one.py
348
4.3125
4
#Write a Python program which accepts a sequence of comma-separated numbers from the user and generate a list and a tuple with those numbers. l=input().split(',') list_n=[] for i in l: list_n.append(int(i)) tuple_n=tuple(list_n) print("THIS IS A LIST OF ELEMENTS:") print(list_n) print("THIS IS A TUPLE OF E...
true
2b47157048a4e30580e6c7f12626c69902421128
biomathcode/Rosalind_solutions
/Variables_and_some_arithmetic.py
415
4.21875
4
a = int(input('this is the a length of triangle : ')) b = int(input('this is the b length of triangle : ')) def square_hypotenuse(a = 3, b = 5): a_square = a * a b_square = b * b hypotenuse = a_square + b_square return print("The hypotenuse is ", hypotenuse) square_hypotenuse(a ,b) """ this is the a...
false
c063891b5f3f8ad713ca6a22416235e38553b7e4
biomathcode/Rosalind_solutions
/Bioinformatics Stronghold/IEN.py
1,081
4.15625
4
## Calculating Expected offspring """ Given: Six nonnegative integers, each of which does not exceed 20,000. The integers correspond to the number of couples in a population possessing each genotype pairing for a given factor. In order, the six given integers represent the number of couples having the following genotyp...
true
f180736db7b68d0c12b796a04106660f5ed1a28b
PurityControl/uchi-komi-python
/problems/euler/0008-largest-product-in-series/ichi/largest_product_in_series.py
893
4.40625
4
def largest_product(length, str_of_digits): """ returns the largest product of contiguous digits of length length in a string of digits args: length: the length of contiguous digits to be calculated str_of_digits: the string of digits to calculate the products from """ return max(produc...
true
702d0eea27aa14c1d522ac6c06673dc0cecd0778
PurityControl/uchi-komi-python
/problems/euler/0009-special-pythagorean-triplet/ichi/pythagorean_triplet.py
596
4.25
4
def pythagorean_triplet(sum): """ returns the first pythagorean triplet whose lengths total sums args: sum: the amount the lengths of the triangle must total """ return first(a * b * c for (a, b, c) in triplets_summing(sum)) def triplet_p(a, b, c): return (a * a) + (b * b) == (c * c) def fi...
true
0f0e9e32d6e713aee7024dfd4f1e94eac8ee1f34
DheerajKN/Python-with-pygame
/SolAssignment1.py
1,109
4.1875
4
def Multiply(x,y): z = x * y print("Answer: ",z) def Divide(x,y): if y != 0: z = x / y print("Answer: ",z) else: print("Division by 0 is not defined") def Add(x,y): z = x + y print("Answer: ",z) def Subtract(x,y): z = x - y print("Answer: ",z) ch = "...
false
0f76d1582d68ace6e5b7d92e07ec84805220ae92
ktops/SI-206-HW04-ktops
/magic_eight.py
843
4.125
4
def user_question(): user_input = input("What is your quesiton? ") return user_input user_input = "" while user_input is not "quit": user_input = user_question() if user_input[-1] is not "?": print("I'm sorry, I can only answer questions.") else: break import random possible_answe...
true
e3487062e8ae883c7c7e77df308fef5291821f2f
kedarjk44/basic_python
/lambda_map_filter_reduce.py
485
4.21875
4
# lambda can be used instead of writing a function add_two_inputs = lambda x, y: x + y print(add_two_inputs(8, 5)) print(add_two_inputs("this", " that")) # map can be used to apply a function to each element of a list list1 = [1, 2, 3, 4] print(*list(map(lambda x: x**2, list1))) # or can be done as print(*[x**2 for x...
true
053d241010b90a67fecff40454dc3e178b4b9aba
marsel1323/Python-Fast-start
/ДЗ№1.py
421
4.25
4
#1 - Установить Python #2 - Выполнить в интерактивном режиме действия: # 1. 10/3 (деление); 10//3 (целая часть от деления); 10%3 (остаток от деления); 10**3 (возведение в квадрат) # 2. 10*3+1 и 10*(3+1) - объяснить почему разные ответы (лол, потому что математика)
false
f1e43c1f7195269a40c8b2e4e9c721f062c5f617
canadian-coding/posts
/2019/August/21st - Basic Logging in python/logging_demo.py
1,777
4.21875
4
import logging # Module that allows you to create logs; Logs are very helpful for down the road debugging import datetime # Used in formatting strings to identify date and time def print_num(): """Takes user input, and if it's an int or float prints it.""" logging.debug("Starting print_int") # Only gets logged...
true
0f7e7f6a8fd56a5a5e7c50ae78a0662050735c7e
canadian-coding/posts
/2019/July/8th - Optional boolean arguments in argparse/optional_boolean_arguments.py
949
4.3125
4
"""A demo of optional boolean arguments using argparse.""" import argparse # Module used to set up argument parser # Setting up Main Argument Parser main_parser = argparse.ArgumentParser(description="A demo of optional boolean arguments") # Adding optional boolean argument main_parser.add_argument("-r", '--run', help...
true
1d3124d8e22793e7cb0a9abc4d1e4a9005e2bad4
lastcanti/learnPython
/review2.py
555
4.15625
4
# python variables and collections print("I am a print statement") # use input to get data from console #someData = input("Enter some data: ") #print(someData) # lists are used to store data a = [] a.append(1) a.append("a") a.pop() b = [2] print a print a + b c = (1,"a",True) print(type(c)) print(len(c)) # tuples a...
true
5a55f549fc08b77283d8bfc80204219839ddd237
erdemirbehiye/ceng391-comp-graphics
/BehiyeErdemir_assignment1/BehiyeErdemir/vec3d.py
1,819
4.34375
4
# CENG 487 Assignment1 by # Erdem Taylan # StudentId: 240206013 # 11 2020 import math #Vector class for initializing vector and vector operations class Vec3d: #initialization of a vector, and its element def __init__(self, x: float, y: float, z: float, w: float = 0): #w is 0 to be ineffective self.x ...
false
85527d167d7805f2f402da1c2f59e03178e3043a
Todai88/me
/kmom01/plane/plane1.py
445
4.5
4
""" Height converter """ height = format(1100 * 3.28084, '.2f') speed = format(1000 * 0.62137, '.2f') temperature = format(-50 * (9/5) + 32, '.2f') print("""\r\n########### OUTPUT ###########\r\n\r\nThe elevation is {feet} above the sea level, \r\n you are going {miles} miles/h, \r\n finally the temperature outs...
true
d6a5422996f26970b11e5a756af66c7e0d33ca0e
Todai88/me
/kmom01/hello/hello.py
681
4.4375
4
""" Height converter """ height = float(input("What is the plane's elevation in metres? \r\n")) height = format(height * 3.28084, '.2f') speed = float(input("What is the plane's speed in km/h? \r\n")) speed = format(speed * 0.62137, '.2f') temperature = float(input("Finally, what is the temperature (in celsius) outs...
true
b0b67c197c66734915eef38b4d00787eda45e06c
cabbageGG/play_with_algorithm
/LeetCode/125_isPalindrome.py
1,034
4.25
4
#-*- coding: utf-8 -*- ''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. Note: Have you consider that the string might be empty? This is a good question to ...
true
9949c12df71be1f193ee8de7427701ec75d6b4b7
DoneWithWork/Number-Guessing-Game
/Number Guessing Game.py
1,547
4.53125
5
# Import random module import random # Number of guesses is 3 guesses = 3 # Getting a random number between and including 1 and 10 number = random.randint(1,10) # Some basic print statements print("Welcome to guess the number") print("You have to guess a number from 1-10") print("You have 3 guesses") ...
true
ee6da142b0010ee7cd926b9f55da2b6eaaa31763
CauePinheiro-2001/PythonComputacao1
/aulas_extras/funções.py
1,059
4.125
4
'''Funções são tem diferentes finalidades para que programador decida qual seja:''' #Estrutura da função: def ola_mundo(): '''Diz olá mundo''' print('Olá mundo!') ola_mundo() def saudacao(nome='caue'): '''Exibe uma saudação simples ao usuário''' print(f'Olá {nome.title()}!') saudacao('Gabriela') def...
false
31285f3d75b27e60dfb4da5af6a168e90b486d46
CauePinheiro-2001/PythonComputacao1
/estrutura_repetição/6.py
274
4.25
4
'''6.Faça um programa que leia 5 números e informe a soma e a média dos números''' numeros = [] for i in range(1, 6): numeros.append(int(input(f'Digite o {i}º numero: '))) print(f'A soma dos numeros é: {sum(numeros)} \nA média dos numeros é: {sum(numeros)/5} ')
false
cd9e6c4bc8970786f367bf0d0f4fbc7a5ea7f39f
CauePinheiro-2001/PythonComputacao1
/exercicios_semana3/8.py
438
4.28125
4
'''8.Escreva um programa que lê um número inteiro. Informe se o mesmo é par ou ímpar, positivo ou negativo.''' print('Programa 8') x = int(input('Informe um valor inteiro: ')) if (x % 2) == 0 and x >= 0: print("Numero Par e Positivo") elif (x % 2) == 0 and x < 0: print('Numero Par e Negativo'...
false
d711494581335922181d6ffdb616410354c28d6e
CauePinheiro-2001/PythonComputacao1
/estrutura_repetição/1.py
352
4.28125
4
'''1.Faça um programa que peça uma nota, entre zero e dez. Mostre uma mensagem caso o valor seja inválido e continue pedindo até que o usuário informe um valor válido.''' nota = float(input('Escreva uma nota de zero a dez: ')) while nota < 0 or nota > 10: print('Numero Inválido') nota = float(input('Escreva um...
false
e6f5138437f07b82860fdcf709097a9d963e8df0
CauePinheiro-2001/PythonComputacao1
/estrutura_repetição/8.py
1,180
4.1875
4
'''8.Faça um programa que leia e valide as seguintes informações: a.Idade: entre 0 e 100; b.Salário: maior que zero; c.Sexo: 'f' ou 'm'; d.Estado Civil: 's', 'c', 'v', 'd' ''' idade = int(input('Idade (entre 0 e 100): ')) while 0 > idade or 100 < idade: idade = int(input('Idade inválida, insira a idade novamente: ...
false
73692164f112b92a5786c10df1691a17aca9b38f
BolajiOlajide/python_learning
/beyond_basics/map_filter_reduce.py
616
4.15625
4
from functools import reduce import operator mul = lambda x: x * 2 items = [1, 2, 4, 5, 6, 8, 9, 10] print(map(mul, items)) # [4, 8, 12, 16, 20] # if you are using python3 then the result of map and filter will # be lazy loaded so you have to manually convert to a list first_names = ["John", "Jane", "James", "Jacob...
true
bc9d9e40d1206fb53e22c9a1b1a8f019e6f67884
BolajiOlajide/python_learning
/beyond_basics/inheritance.py
399
4.15625
4
class Base: def __init__(self): print("Base initializer") def f(self): print("Base.f()") class Sub(Base): def __init__(self): super().__init__() # we have to explicitly call the base class's initializer print("Sub initializer") def f(self): super().f() # sam...
false
b0aebff67ff52cefe76ff542e07666ed58a8f39b
parallexTanatep/python
/week3_1.py
780
4.125
4
print('\nเลือกเมนูเพื่อทำรายการ') print('กด 1 เลือกเหมาจ่าย') print('กด 2 เลือกจ่ายเพิ่ม') x = int(input(':')) y = int(input('กรุณากรอกระยะทาง :')) if x==1 : if y >=25: print('ค่าใช้จ่ายรวมทั้งหมด : 55 บาท') else : print('ค่าใช้จ่ายทั้งหมด : 25 บาท') elif x==2 : if y<=25: print('ค่าใ...
false
43c0bc0302ce5d541f29de7c3cac24a926b21209
jm-avila/REST-APIs-Python
/Refresher/09_the_in_keyword/code.py
299
4.125
4
movies_watched = {"The Matrix", "Green Book", "Her"} user_movie = input("Enter something you've watched recently: ") print("in movies_watched", user_movie in movies_watched) vowels = "aeiou" user_letter = input("Enter a letter and see if it's a vowel: ") print("in vowels", user_letter in vowels)
true
a9dd82154e83621eeed02e814449067c4720e2a4
jm-avila/REST-APIs-Python
/Refresher/22_unpacking_keyword_arguments/code.py
924
4.15625
4
# colect keyword arguments into a dictionary def example_1(**kwargs): print("example_1", kwargs) example_1(name="Bob", age=25) print() # unpack dictionary into keyword arguments def example_2(name, age): print("example_2", name, age) details = {"name": "Bob", "age": 25} example_1(**details) example_2(**deta...
false
92988d12250b0d14e4a4a6d5e688f33f973b8b2d
DavidCorzo/EstructuraDeDatos
/#SearchingAndSorting/Sorting.py
1,159
4.125
4
def selection_sort(unsorted: list) -> list: for i in range(0, len(unsorted) - 1): min = i for j in range(i + 1, len(unsorted)): if unsorted[j] < unsorted[min]: min = j if min != i: unsorted[i], unsorted[min] = unsorted[min], unsorted[i] return ...
true
6e1c537e147eeccb2c51a55c25900c4f0c7fa19f
PriyanshuChatterjee/30-Days-of-Python
/day_6/06_tuples.py
1,847
4.25
4
emptyTuple = () brothers = ('Arijit','Debrath') sisters = ('Apurba',) siblings = brothers+sisters noofSiblings = len(siblings) parents = ('Ma','Papa') family_members = siblings+parents (firstSibling, secondSibling, thirdSibling, firstparent, secondParent) = family_members fruits = ('apples','mangoes','bananas'...
true
3034f8af8cb037de81db93f3c283ffbb8cb48116
karthikkbaalaji/CorePython
/loops.py
399
4.28125
4
# Have the user enter a string, then loop through the # string to generate a new string in which every character # is duplicated, e.g., "hello" => "hheelllloo" #import print function from python3 from __future__ import print_function #get the input from the user print("Enter a string:", end='') inputString = raw_inp...
true
f18d0ba8eeb0dad5a1b4bad385ade4d88fa8f5fa
karthikkbaalaji/CorePython
/lists.py
2,279
4.5625
5
#write a Python program to maintain two lists and loop #until the user wants to quit #your program should offer the user the following options: # add an item to list 1 or 2 # remove an item from list 1 or 2 by value or index # reverse list 1 or list 2 # display both lists #EXTRA: add an option to check if lists...
true
7d3b5f3503d8a454cb36408d04d577981bac76c9
MaoGreenDou/MyPythonStudyOne
/demo01.py
1,545
4.21875
4
# -*- coding:utf-8 -* #注意开头 # 1 first program print('Hello World!') # float data PI = 3.14159 pi = 3.14159 PI is pi id(PI) id(pi) # 2 integer data p = 3 q = 3 q is p id(q) id(p) # 3 big integer data a = 257 b = 257 a is b id(a) id(b) # 4 string data x = 'Hello World!' y = 'Hello World' x is y id(x) id(y)...
false
987d0755225cb89e923d22b48d212ca75cfcf9c0
mcfaddeb4311/cti110
/M5T1_KilometerConverter_BobbyMcFadden.py
515
4.4375
4
# Convert kilometer to miles. # 6-28-2017 # CTI-110 M5T1_KilometerConverter # Bobby McFadden CONVERSION_FACTOR = 0.6214 def main (): # Get the distance in kilometers. kilometers = float (input('Enter a distance in kilometers: ')) #Display the distance converted to miles. show_miles (kilometers) ...
true
cad19fd15b16c7a8494fd52bece96ff572d86487
csbridge/csbridge2020
/docs/starter/lectures/Lecture6/school_day.py
544
4.28125
4
""" This program tells whether go to school or not for a particular day. """ MONDAY = 1 TUESDAY = 2 WEDNESDAY = 3 THURSDAY = 4 FRIDAY = 5 SATURDAY = 6 SUNDAY = 7 def main(): print("Should I go to school?") day = int(input("Enter a day: ")) if MONDAY <= day <= FRIDAY: # day is between Monday and Friday ...
true
f5252fb223ae9632eda4a7126d4e5f66b62085c3
caotritran/Python_Pymi
/Exercises_5/ex5_3.py
2,473
4.21875
4
#!/usr/bin/env python3 import string data = '''Dictionaries are sometimes found in other languages as “associative memories” or “associative arrays”. Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, which can be any immutable type; strings and numbers can always be keys. Tup...
false
3b0e7cd368a3f121c67b9a20c75f67e532de6ae3
Cova14/PythonCourse
/dicts_exercise_1.py
518
4.3125
4
# We need to receive the basic info of a user # (first_name, last_name, age, email) # and save them as keys into a dict call user. # After receive the data, show the info in the console user = {} user['first_name'] = input('Hey bro, cual es tu nombre?: ') user['last_name'] = input('Como dices que se apellidan tus gfe...
true
d51332be4193aa4fb7b71219d96f363de8376044
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/xuef code/xuef_code_python/fluent python/8 对象引用、可变性和垃圾/8.3 深复制与浅复制.py
598
4.15625
4
""" 我强烈建议你在 Python Tutor 网站 http://www.pythontutor.com/visualize.html#mode=edit 中查看示例的交互式动画。 """ l1 = [3, [55, 44], (7, 8, 9)] l2 = list(l1) # l1 is l2 #False l1==l2 #True l1[1] is l2[1] #True """ 然而,构造方法或 [:] 做的是浅复制(即复制了最外层容器,副本中 的元素是源容器中元素的引用)。如果所有元素都是不可变的,那么这 样没有问题,还能节省内存。但是,如果有可变的元素,可能就会导致 意想不到的问题。 """ # 深复制 ...
false
5a97ae18e7319001e3eb66d4a7e55bc0f642fc48
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/想研究的/python-further/metaclass1.py
2,426
4.96875
5
#http://blog.jobbole.com/21351/ #http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python """ Secondly, metaclasses are complicated. You may not want to use them for very simple class alterations. You can change classes by using two different techniques: ·monkey patching ·class decorators 99% of the ti...
true
5ba5d87ad6527bf35a1b1c51134babbca21e1b04
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/Fun_Projects/EOPL/1.code-induction.py
434
4.28125
4
## (nth-element '(a b c d e) 3) ##= (nth-element '(b c d e) 2) ##= (nth-element '(c d e) 1) ##= (nth-element '(d e) 0) ##= d #> (invert '((a 1) (a 2) (1 b) (2 b))) ## ((1 a) (2 a) (b 1) (b 2)) def invert(lst): # lst is a list of 2-lists (lists of length two) for ele in lst: e1,e2 = ele yield (...
false
0d89796e96912a5add194eaf2e60f0487219920e
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/xuef code/xuef_code_python/python_base/元类_类也是对象.py
872
4.1875
4
""" 类(Person,Province)本就是个模板。模板当然是对象。它属于模板(class)类型 人模板(Person), 省模板(Province) """ # 解释器在遇到 class A 时会做什么? # 类是对象意味着我们可将它看作一个实体,进而可以对它进行审视和操作,施加影响。 ## 你可以在运行时创建它 class Province(): country = "China" def __init__(self, name): self.name = name print(type(10)) # <class 'int'> 意味着10是用int类(型)创建出来的对象 p=Pro...
false
72ccad5f29e9918974a57e7ccc14b85935d52afb
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/xuef code/xuef_code_python/composing_programs/4. Data Processing/4.2.6 Python Streams.py
2,460
4.3125
4
""" Streams offer another way to represent sequential data implicitly. A stream is a lazily computed linked list. Like an Link, the rest of a Stream is itself a Stream. Unlike an Link, the rest of a stream is only computed when it is looked up, rather than being stored in advance. That is, the rest of a stream is comp...
true
ea486935f6eb853ec567831155935518d9407807
itrevex/ProgrammingLogicAndela
/coffee.py
2,024
4.46875
4
''' Andela Making Coffee App ''' #Make my coffee INGREDIENTS = ['coffee', 'hot water'] print('Started making coffee...') print('Getting cup') print('Adding {}'.format(' and '.join(INGREDIENTS))) print('Stir the mix') print('Finished making coffeee...') MY_COFFEE = 'Tasty Coffee' print("--Here's your {}, Enjoy!!-- Mr....
true
d75b2ad3ccccbbc64101c9d69749f14ac09e7ef1
N-eeraj/code_website
/Code/py/queue_ds.py
929
4.21875
4
def isEmpty(): return True if end == 0 else False def isFull(): return True if end == size else False queue = [] size = int(input("Enter Queue Size: ")) while True: print("Queue:", queue) end = len(queue) option = input("\nSelect Queue Operation\n1. Is Empty?\n2. Is Full?\n3. Enqueue\n4. Dequeu...
true
bb633be4035a92e7f9e9ad8b99dad90a0871484a
Arrowarcher/Python_Concise_Handbook
/07-条件判断.py
841
4.28125
4
#if xxx:\nelse:xxx age=3 if age >= 60: print('old man') elif age >=18: print('adult') elif age >=6: print('teenager') else: print('kid') print('练习:') ''' bmi = float(weight/height**2) print('bmi=',bmi) if bmi > 32: print('严重肥胖') elif bmi >28 and bmi <=32: print('肥胖') elif bmi...
false
ee36f2aa49982e1926fc9859ea52987fd598bc7a
jscelza/PythonKnightsSG
/week01/funWithSys.py
868
4.1875
4
"""Playing with sys by using examples from Chapter 1. http://www.diveintopython3.net/your-first-python-program.html Available Functions printSyspath() Print value of sys.path addDirToSyspath(string) Adds string to sys.path """ import sys def display_syspath(): """Print sys.path value.""" print("sys.p...
true
13f76295927ed7cef99d759a3d4a39afaf7c47da
Pjmcnally/algo
/strings/reverse_string/reverse_string_patrick.py
874
4.46875
4
# Authored by Patrick McNally # Created on 09/15/15 # Requests a string and prints it reversed def reverse_string(chars): """Takes in a string and returns it reversed. Parameters ---------- Input: chars: string Any string or list Output: chars: string A reversed version of t...
true
1dd422098c2b504fef437676c9895036a45ada70
Pjmcnally/algo
/sort_visualized/bubble_sort.py
2,950
4.28125
4
"""Visualization of the bubble sort algorithm. For reference: https://matplotlib.org/2.1.2/gallery/animation/basic_example_writer_sgskip.html https://github.com/snorthway/algo-viz/blob/master/bubble_sort.py """ from random import shuffle import matplotlib.pyplot as plt import matplotlib.animation as ani # Create a l...
true
7b83ce10efb3bf9da2f9650cc1718327bf462193
Pjmcnally/algo
/math/primes/primes_old.py
2,206
4.34375
4
# Authored by Patrick McNally # Created on 09/15/15 # Requests a number from the user and generates a list of all primes # upto and including that number. import datetime def list_primes(n): """Return a list of all primes up to "n"(inclusive). Parameters ---------- Input: n: int or float ...
true
e887c0efe28523e4de25a523684cea8e1e1b2d92
Neha-kumari31/Sprint-Challenge--Data-Structures-Python
/names/bst.py
1,456
4.125
4
''' Binary search trees are a data structure that enforce an ordering over the data they store. That ordering in turn makes it a lot more efficient at searching for a particular piece of data in the tree. ''' class BSTNode: def __init__(self, value): self.value = value self.left = None se...
true
3483d89da70d27855bc0854d531361b2f17b10fa
TanbirulM/Rock-Paper-Scissors
/rps.py
1,551
4.125
4
import random def play_game(): print('Welcome to Rock Paper Scissors!') player_score = 0 bot_score = 0 while True: print('Make your choice:') choice = str(input()).lower() print("My choice is", choice) choices = ['rock', 'paper', 'scissor', 'end'] bot_choices = ['rock', 'paper', 'scissor'] bot_ch...
true
1cbbe648adf947a8c230a15578b1117c3a523064
jitensinha98/Python-Practice-Programs
/ex32_2.py
433
4.15625
4
y=int(raw_input("Enter the starting element:")) z=int(raw_input("Enter the ending element:")) element=[] for i in range(y,z+1): element.append(i) print "All elements are stored in the list." print "Do you want to veiw the list :" raw_input() print "All elements in the list are :" for numbers in element: pr...
true
f911f45e6505a6a3916aa7a900bcaa2379a00075
garycunningham89/pands-problem-set
/solution1sumupto.py
657
4.4375
4
#Gary Cunningham. 03/03/19 #My program intends to show the sum of all the numbers for, and including, the inputted integer from number 1. #Adaptation from python tutorials @www.docs.python.org and class tutorials. n = input("Please enter a positive integer: ") # Inputting the first line of the program as per the reques...
true
251f9d376aefb865fffdbba56b6d4c9bbe0b305c
shawnTever/documentAnalysis
/week1/PythonBasicsTutorial.py
2,480
4.28125
4
my_list2 = [i * i for i in range(10)] # Creates a list of the first 10 square integers. my_set2 = {i for i in range(10)} my_dict2 = {i: i * 3 + 1 for i in range(10)} print(my_list2) print(my_set2) print(my_dict2) # Comprehensions can also range over the elements in a data structure. my_list3 = [my_list2[i] * i for i...
true
8982047e06eceb6dd3a530bc09584d55cf734e25
aa-fahim/practice-python
/OddOrEven.py
846
4.21875
4
## The programs asks the user to input an integer. The program will then ## determine if the number is odd or even and also if it is a multiple of 4. ## The second part of program will ask for two numbers and then check ## if they are divisble or not. number = int(input('Please enter a number:\n')) a = number...
true
b8abc55567a07dcd99e00d752a3790ab409f6858
aa-fahim/practice-python
/ListEnds.py
213
4.1875
4
## List Ends # Takes first and last element of input list a and places into new list and # prints it. def list_ends(a): a = [5, 10, 15 ,20 ,25] new_list = [a[0], a[len(a)-1]] print(new_list)
true
c3ecd3b01a046af4f3e6c203878b0864d85a0317
bio-chris/Python
/Courses/PythonBootcamp/Project_3_Pi.py
517
4.21875
4
# Project 3: Find PI to the Nth Digit # Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program # will go. """ Using the Bailey-Borwein-Plouffe formula """ from decimal import * def pi(i): pi_value = 0 getcontext().prec = i for n in range(i...
true
d3a9f412143fd1304fe4e657bd476263ebec69d4
beade88/ejercicios_python_principiantes
/sentence_manage.py
526
4.34375
4
""" Mira, toma este : supón la cadena ‘esta es una cadena de texto’ conviértela a ‘Esta Es Una Cadena De Texto’ todas la letra inicial mayúscula. Simple pero usarás tres funciones básicas para procesar strings :) Q son split, join, list comprehension y capitalice """ sentence_1 = 'this is a text string' def sentence...
false
4e98356bdc6f0df8b2715536dacf8f55a792f5a9
Nayan-Chimariya/Guess-the-number
/app.py
2,562
4.15625
4
#game game from random import randint import time import os guess_count = 5 hint_count = 3 def end_screen(): print("\nSee ya later loser! \n") time.sleep(1) exit() def counters(guess_count, hint_count): print(f"\nNumber of guess left = {guess_count}") print(f"Number of hints left = {hint_count}") def hi...
true
e351e2fb38e050f759a81de0879297623723ffea
amir-jafari/Data-Mining
/01-Pyhton-Programming/3- Lecture_3(Python Adavnce)/Lecture Code/2-String_Objects-Example.py
290
4.25
4
word1 = 'Wow' word2 = 'Wow' print('Equal:',word1 == word2, ' Alias:',word1 is word2) name = input("Please enter your name: ") print("Hello " + name.upper() + ", how are you?") word = "ABCD" print(word.rjust(15, "*")) print(word.rjust(15, ">")) print(word.rjust(10)); print('#',50*"-")
false
4cd731424693d2ae3287132de455cd2a75c1e59f
taismassaro/stunning-engine
/anagram-finder/anagram_finder.py
559
4.125
4
with open('anagram_finder/2of4brif.txt') as in_file: words = in_file.read().strip().split('\n') words = [word.lower() for word in words] lookup_word = 'charming' anagrams = [lookup_word] for word in words: if word != lookup_word: # to find out if a word is an anagram of another, we can convert th...
true
9605f705daf53c27cd8292df1a5b0c6cba86604f
TimurTimergalin/natural_selection
/simulation/app.py
2,141
4.15625
4
import pygame class App: """ Methods: set_variables create_sprite_groups main_loop run set_variables: Args: None Returns: None Set constant variables to use it in the simulation create_sprite_groups: Args: None Returns: None ...
true
9aa2b9c5089a3af7d75c3a1bd61af6c544efc00c
NagiReddyPadala/python_programs
/Python_Scripting/Pycharm_projects/DataStructures/Stack/IntToBinary.py
574
4.125
4
""" Use a stack data structure to convert integer values to binary 242 / 2 = 121 -> 0 121 / 2 = 60 -> 1 60 / 2 = 30 -> 0 30 / 2 = 15 -> 0 15/ 2 = 7 -> 1 7 / 2 = 3 -> 1 3 / 2 = 1 -> 1 1 / 2 = 0 -> 1 """ from DataStructures.Stack.stack import Stack def get_binary(dec_num): s = Stack() whi...
false
927b69be4111dd0b12631e59cd8d42c3bb0e9074
gygergely/Python
/Misc/FizzBuzz/fizzbuzz.py
1,237
4.1875
4
def welcome(): """ Simple welcome message to the user. :return: None """ print('Welcome to the \'fizzbuzz\' game') def user_number_input(): """ Request a number from the user. :return: int """ while True: try: nr = int(input('Please enter a number between 1 ...
true
4163960e911dc1a91fed505e1a348d5ffb6e9d25
AndreaCossio/PoliTo-Projects
/AmI-Labs/lab_1/e02.py
277
4.375
4
# Lab 01 - Exercise 02 # Retrieving the string string = input("Insert a string: ") # Checking length and printing if len(string) > 2: print("'" + string + "' yields '" + string[0] + string[1] + string[len(string) - 2] + string[len(string) - 1] + "'") else: print("")
true
e73464eaff804a0128456f9c37ad348b08856049
AndreaCossio/PoliTo-Projects
/AmI-Labs/lab_2/e01.py
1,214
4.25
4
# Lab 02 - Exercise 01 # List of tasks tasks = [] num = -1 # Main loop while num != 4: # Printing menu print("""Insert the number corresponding to the action you want to perform: 1. Insert a new task 2. Remove a task (by typing its content exactly) 3. Show all existing tas...
true