blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ba6de8d63f90c93405f2d699c674dfc6faca22c4
DinakarBijili/Python-Preparation
/Problem Solving/HARDER_LEVEL/Simple_calculator.py
769
4.25
4
""" Simple Calculator """ def add(num1,num2): return num1 + num2 def sub(num1,num2): return num1 - num2 def mul(num1,num2): return num1 * num2 def div(num1,num2): return num1 / num2 def mod(num1,num2): return num1 % num2 #Taking input from the User num1 = int(input("Enter 1st Number : ")) operation...
false
224fc51576ce0320b8b78210fde376cf4aba4b37
S411m4/very_simple_python_database
/very_simple_python_database.py
1,386
4.21875
4
class School: def __init__(self, firstName, lastName, email, money, job): self.firstName = firstName self.lastName = lastName self.email = email self.money = money self.job = job def __str__(self): data = [self.firstName, self.lastName, self.email, sel...
true
9492b53ff84e6463ca659d5ade4c4b6be287501a
michalmaj90/basic_python_exercises
/ex1.py
346
4.21875
4
'''Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.''' name = input("What's your name?? ") age = input("What's your age?? ") year = str((100 - int(age)) + 2018) print("Hello " + name + "! You'll be 1...
true
dc7a57d761082468346561bfa10083e4e5b80e56
mohammedjasam/Coding-Interview-Practice
/LeetCode/LongestSubstring.py
850
4.125
4
"""Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1. Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "...
true
0d7d6aa9fdf8aaed45bb449a8e6ada38cc252118
RustemSult/a-byte-of-python
/03_Operators_String.py
1,750
4.28125
4
# -*- coding: utf-8 -*- print("--- Операции со строками ---\n") ## Операции со строками a = 'What\'s ' b = 'your name?' print(a + b) a = 'Вывод 1.' b = '\tВывод 2 c отступом(табуляцией).' print(a + b) a = '\tВывод 1 c отступом.' b = '\tВывод 2 c отступом.' print(a + b) a = 'Строка 1' b = '\nСтрока 2' print(a +...
false
aff69fc6ff8b5b58c30305febf4d384b4e68d9d4
jesicaduarte-test/code_challenge
/palindromeTest.py
673
4.34375
4
def palindrome(e): if type(e) != str: return False else: e = e.replace(" ", "") if len(e) <= 0: return False else: if str.lower(e) == str.lower(e)[::-1]: return True else: return False # In this array we define the values that we want to use in our function dataSet = [3, 2.3,' ','999'...
false
0e8f5383d8e33592ec5f1b0ebb18c7f9bfe9f7dc
Shashankhs17/Hackereath-problems_python
/Basic/palindrome_string.py
461
4.15625
4
''' You have been given a String S. You need to find and print whether this string is a palindrome or not. If yes, print "YES" (without quotes), else print "NO" (without quotes). ''' string = input("Enter the string:") lenght = len(string) flag = 0 i = 0 while i<lenght/2: if string[i] == string[lenght - 1]: ...
true
247bf8d334045c2af71b90ee7dd9be4a67dc1941
mmore500/hstrat
/hstrat/_auxiliary_lib/_capitalize_n.py
454
4.1875
4
def capitalize_n(string: str, n: int) -> str: """Create a copy of `string` with the first `n` characers capitalized. If `n` is negative, the last `n` characters will be capitalized. Examples -------- >>> capitalize_n('hello world', 2) 'HEllo world' >>> capitalize_n('goodbye', 4) 'GOODb...
true
4adec0efa3c15a3ab80eb6ec7706f4dfc51cb015
mmore500/hstrat
/hstrat/_auxiliary_lib/_render_to_numeral_system.py
1,278
4.21875
4
# adapted from https://cs.stackexchange.com/a/65744 def render_to_numeral_system(n: int, alphabet: str) -> str: """Convert an integer to its digit representation in a custom base. Parameters ---------- n : int The non-negative integer to be converted to a custom base representation. ...
true
02901ed5551932dcd71f9c33e75361f815bc963c
Isaac12x/codeexamples
/split_list.py
1,858
4.40625
4
def sub_split_list_by_reminder(list, splitter): """ Function to create a nested list with length equal to the reminder of division This function splites the list into an amount of nested lists equally sized to the second parameter. It also spreads the contents of the first list in nested lists equal...
true
2ceb823659761ef5050ccbbd95fda076be548c7f
Joycici/Coding
/Python/Exercise/ex3.py
893
4.15625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """ __author='Joycici' __version__='1.0' """ print "I will now count my chickens:" # 输出hens的数量 print "Hens",25.0 - 30 / 6 # 输出Roosters数量 print "Roosters", 100.0 - 25 * 3 % 4 # 输出鸡蛋的数量 print "Now I will count the eggs:" print 3.0 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 # 比较3+2和5-...
false
a1c3b7af2265f6c2ff76ff7d9e32be78236487af
Joycici/Coding
/Python/Exercise/ex29.py
959
4.125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' Exercise 29: What If ''' """ __author='Joycici' __version__='1.0' """ people = 20 cats = 30 dogs = 15 if people < cats: print "Too many cats! The world is doomed!" if people > cats: print "Not many cats! The world is saved!" if people < dogs: print "The ...
false
787d8c98b29972ac759a8e13175dccb84f1dd69a
paulopimenta6/ph_codes
/python/edx_loop_for_3.py
263
4.34375
4
#Using a for loop, write a program which asks the user to type an integer, n, and then prints the sum of all numbers from 1 to n (including both 1 and n). number = int(input("write a number: ")) sum=0 for i in range(1,number+1): sum = sum + (i**2) print(sum)
true
856d53f1392e78d169f0f4bf1d557a1b05930bf4
mai-mad/PythonLearning
/june/18.06.py
1,630
4.125
4
import re txt = "Ilya hates windows" print(txt) x = txt.replace("hates", "loves") print(x) x = x.replace("windows", "MACos") print(x) x = x.upper() print(x) x = x.lower() print(x) # Phonde code -> City phone = "(8422) 41-23-93" # krasnodar perm ulyanovsk x = phone.find("(495)") if x >= 0: print("Moscow") x = pho...
false
52c9228ae50befb9f2080031dc823750fde2b954
mai-mad/PythonLearning
/july/11.07.2020.py
844
4.125
4
fruits = ["apple", "banana", "cherry", "pear", "persimmon", "date", "peach"] i = 1 for x in fruits: print (str(i)+" "+ x) i=i+1 # print all even positions: i = 1 for x in fruits: if i % 2 == 0: print (str(i)+" "+ x) i=i+1 # print all odd positions: i = 1 for x in fruits: if i % 2 == 1: print (...
false
90b9a6ed8f46b120764be142824d76cac1f88a2f
sssandesh9918/Python-Basics
/Functions/11.py
291
4.28125
4
'''Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result.''' add= lambda a: a+15 mul =lambda x,y: x*y r=add(10) s=mul(15,10) print(r) print(s)
true
ff1908e083e96ca7f60b802cf1ff4549a789fde2
sssandesh9918/Python-Basics
/Data Types/7.py
373
4.21875
4
'''Write a Python function that takes a list of words and returns the length of the longest one.''' def func(a): b=[] for i in range(a): words=list(input("Enter words")) b.append(words) print(b) c=[] for j in range(len(b)): c.append(len(b[j])) print(max(c)) a=int(input("E...
true
a8434f61ab39cdab8ba3622b7b0f0456bcd424de
sssandesh9918/Python-Basics
/Functions/1.py
254
4.28125
4
'''Write a Python function to find the Max of three numbers.''' def highest(x,y,z): return(max(x,y,z)) a=input("Enter first number") b=input("Enter second number") c=input("Enter third number") m=highest(a,b,c) print("The max of three numbers is ",m)
true
9d3fdd56d2421bbaf118afaa03bbba63f2c39382
ArthurMelo9/100daysofCode
/examples.py
955
4.15625
4
#A rollercoaster ride #print("Welcome to Rollercoaster!") #height= int(input("Enter your height in cm: ")) #if height > 120: # print("You can ride the rollercoaster!") #else: # print("Sorry, you have to grow taller before you can ride.") print("Welcome to rollercoaster!") height=int(input("What is your height...
true
0c7efc52a64526e2c9fb5c3dbc7495bb479908b7
omvikram/python-advance
/decorators.py
661
4.125
4
#Return a function def myfunc1(name=""): print("This is myfunc1()") def welcome(): print("\t This is welcome()") def greet(): print("\t This is greet()") if(name == "Om"): return welcome else: return greet f = myfunc1() f() f= myfunc1("Om") f() #Pass a function a...
true
8436a1dc91a3328e45aba2a4b8e9c8192561aef8
mingyuea/pythonScriptingProblems
/routeCircle.py
821
4.125
4
class Solution: def judgeCircle(self, moves): """ Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place. The move sequence is represented by a string. And each move is represent by a character. The ...
true
10c0939b7af758a843a5e4d654e1758f6058ca7d
shoaib30/SE-Lab
/Triangle.py
352
4.34375
4
a = input("Enter First side : ") b = input("Enter Second side : ") c = input("Enter Third Side : ") if((a+b) < c or (b+c) < a or (c+a) < b): print "Not a triangle" else: if(a == b or b == c or c == a): if(a == b and b == c): print "Equilateral" else: print "Isosceles" ...
false
52353fc78521cb3723dc76db40f354eb873d3bf4
costagguilherme/python-desafios
/exercicios/laço-while/desafio63.py
272
4.125
4
num = int(input('Digite um número de termo para sequência Fibonacci: ')) cont = 1 anterior = 0 proxima = 1 soma = 1 while cont <= num: print(anterior, end='-') cont += 1 soma = proxima + anterior anterior = proxima proxima = soma print('Fim')
false
9d84d6e4962d69d5e3bd6fc9e5d3d1f2b06ce5ef
nickk2021/python
/master-python/10-sets-diccionarios/diccionarios.py
828
4.3125
4
""" Diccionario: un tipo de dato que almacena un conjunto de datos. en formato clave > valor. Es parecido aun array asociativo o un objeto json. """ persona = { "nombre": "Pablo", "apellido": "Rojas", "web":"Pablorojas.ar" } print(persona["apellido"]) # LISTAS CON DICCIONARIOS contactos ...
false
1234197b9ea59d5b5004b2cd424e6e9b38417df0
cskamil/PcExParser
/python/py_trees_insert_binarytree/insert_binarytree.py
2,602
4.3125
4
''' @goalDescription(In a BinaryTree, adding new nodes to the tree is an important capability to have.\nConstruct a simple implementation of a BinaryTree consisting of an __init__ method and an insertLeft method, which adds new nodes to the tree to the left of the root. ) @name(Inserting binary tree) ''' # Define a...
true
502ce16f0984b5d247561afe4fe2ef29f9a4bd72
paulatumwine/andelabs
/Day 2/OOP/oop_concepts.py
1,944
4.625
5
from abc import ABCMeta class Product(object): """ An abstract class """ __metaclass__ = ABCMeta unit_price = 0 def __init__(self, name, maker): self.__name = name self.__maker = maker self._quantity = 0 self._total_stock_price = 0 def add_stock(self, qu...
true
fda3cec9a0c0ce2ff34e75e8b2f1707e44c18570
saqibsidd67/CIS2348
/Homework 1/CodingProblem1_main.py
1,051
4.3125
4
# Saqib Siddiqui # PSID: 1495537 print('Birthday Calculator') print('Current Day') current_month = int(input('Month:')) current_day = int(input('Day:')) current_year = int(input('Year:')) print('Birthday') birth_month = int(input('Month:')) birth_day = int(input('Day:')) birth_year = int(input('Year:')) if current_m...
false
836a489eaa421947cd9e5bfe255897c9ba835def
julio-segura/python-calculator
/main.py
834
4.34375
4
# programa para hacer operaciones matemáticas sencillas (suma, resta, multiplicación, división) some_text = "Welcome to the Calculatora Magnifique." print(some_text) # valor igual a variable (info introducida por el usario (llamada a la acción)) x = int(input("Enter the value for x: ")) y = int(input("Now enter the v...
false
17207416f919bca290c26a5d09e370225ec6c4ba
debasissil-python/debasissil-python
/str_formatting.py
824
4.21875
4
name = input("What's Your Name: ") surname = input ("And Your surname please: ") age = input('May we know your age: ') address = input("Where do you live: ") work = input("What do You do: ") move = input ("Do you want to relocate to Canada: ") where = input('Which Province: ') when = input("When can You reloca...
false
08199d5030d91da6c6ec701b5e4d1fb76f97c591
debasissil-python/debasissil-python
/sec9_list_comprehensions.py
2,281
4.25
4
# ALWAYS REMEMBER ----> # For list comprehension with or without if statement, the code should be - # [a for a in list if a>10] ---> It'll iterate through the list and give the output # For list comprehension with if else statement, the code should be - ...
false
1c6a50a9e56712b4d1500ed489a876408d0075fd
cyrsis/TensorflowPY36CPU
/_15_Crawler/showTuple.py
1,165
4.375
4
#!/usr/bin/env python #-*- coding: utf-8 -*- __author__ = 'hstking hstking@hotmail.com' class ShowTuple(object): def __init__(self): self.T1 = () self.createTuple() self.subTuple(self.T1) self.tuple2List(self.T1) def createTuple(self): print(u"建立tuple:") print(u"T1 = (1,2,3,4,5,6,7,8,9,10)") self.T1 =...
false
39c5f391e9016907762f2465f47b5251316bfd8c
Emile-Dadou-EPSI/EulerProject
/problem1.py
501
4.15625
4
## Euler Project problem 1 : ## If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. ## The sum of these multiples is 23. ## Find the sum of all the multiples of 3 and 5 below 1000. def findMultiples(nbMax): res = 0 for x in range(nbMax): if x % 3 == 0 or x % ...
true
7d3a72a7c767addcf1320b785bedd3b5e61f95ea
padmini06/pythonExamples
/example.py
486
4.1875
4
#!/usr/bin/python3 print("hello") x="" x=input("enter your name \n") print("Hello",x) x=input("enter number 1 \n") y=input("enter number 2 \n ") if x>y: print("x is greater than y"); print("anscscdsafasf") else: print("y is greater than x"); def MaxNumber(a,b,c): "This function will return th...
true
deb17862f7715aca87c07a2b0a74571da13bbfc7
padmini06/pythonExamples
/Example5.py
970
4.21875
4
#!/usr/bin/python3 """ Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your progra...
true
a8170f6055aac917f096ce057feba9015c713bed
padmini06/pythonExamples
/example1.py
396
4.375
4
""" Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.""" _name= input("Enter your name\n") _age = int(input("Enter you age \n")) if _age > 100 : print("your age is greater than 100") el...
true
0e12c929ff4cbb6a9b263a4bbe074edeea8546f1
rogerwoods99/UCDLessons
/UCDLessons/DataCampDictionary.py
2,374
4.4375
4
# find the capital based on index of the country, a slow method # Definition of countries and capital countries = ['spain', 'france', 'germany', 'norway'] capitals = ['madrid', 'paris', 'berlin', 'oslo'] # Get index of 'germany': ind_ger ind_ger=countries.index("germany") # Use ind_ger to print out capital of Germany...
true
444283f159d5fc198a4bb0a990968fd321c18e87
planktonlex55/ajs
/basics/rough_works/2_iterators.py
841
4.8125
5
#for can be used to iterate over many data structures in python. #ex. 1 list1 = [10, 20, 30] for x in list1: print x string1 = "python" for x in string1: print x dict1 = {"key1": "value1", "key2": "value2", "key3": 10} print dict1 #order of printing seems to be from last to first for x in di...
true
c9a7d17b5534f997709ab430eb851262b4e06a5d
Shivani-Y/assignment-3-prime-factors-Shivani-Y
/prime.py
785
4.28125
4
""" prime.py -- Write the application code here """ def generate_prime_factors(number): """ Code to generate prime factors """ prime_list = [] i = 2 if not isinstance(number, int): #raises an error of function called for any type but integer raise ValueError("Only integers can be used in the fun...
true
9511d38e439478be9b7166629091ba87f9652836
YoungWenMing/gifmaze
/examples/example4.py
1,793
4.375
4
# -*- coding: utf-8 -*- """ This script shows how to run an animation on a maze. """ import gifmaze as gm from gifmaze.algorithms import prim # size of the image. width, height = 605, 405 # 1. define a surface to draw on. surface = gm.GIFSurface(width, height, bg_color=0) # define the colors of the walls and tree. ...
true
5f4c8a6d164228395c8aaecd4893ee887de0034b
Lingrui/Learn-Python
/Beginner/tuple.py
390
4.21875
4
#!/usr/bin/python #define an empty tuple tuple = () #a comma is required for a tuple with one item tuple = (3,) personInfo = ("Diana",32,"New York") #data access print(personInfo[0]) print(personInfo[1]) #assign multiple variables at once name,age,country,career = ('Diana',32,'Canada','CompSci') print(country) #...
true
b9a63cdacea35210a3952f4ca597399e1fc2cb87
Lingrui/Learn-Python
/Beginner/objects_classes.py
1,078
4.5
4
#!/usr/bin/python ###class###### ## The __init__() method is called the constructor and is always called when creating an object. class User: name = "" def __init__(self,name): self.name = name def sayHello(self): print "Hello, my name is " + self.name #creat virtual objects james = User("James") david = Us...
true
88073a7b852e94d8fcbf21de3b0c9b1ac0447563
ChiDrummer/CodingDojoPythonStack
/PythonFundamentals/math.py
504
4.53125
5
"""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. Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000.""" for number in range(1,101,2): print number for number in range(5,100): if num...
true
54afcc3930bfaf9e2c5afa953cbcdd0438dd1e35
smahs/euler-py
/20.py
767
4.15625
4
#!/usr/bin/python2 """ Statement: n! means n x (n - 1) x ... x 3 x 2 x 1 For example, 10! = 10 x 9 x ... x 3 x 2 x 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! """ from unittest import TestCase, main class Problem20(obj...
true
5c54b1cc7380b8069d74bbb105d682e8d3f851e2
RamSinha/MyCode_Practices
/python_codes/sorting/bubbleSort.py
602
4.125
4
#!/usr/bin/python def bubbleSort(array): swapped = True for i in range(len(array))[::-1]: if swapped is False: break swapped = False for j in range(0,i): if array[j] >= array[j + 1 ]: swap(array, j , j + 1) swapped = True def swap...
false
a7b980f2e78b2720dbb60ca9ba2ef8c242a8e38b
jakubowskaD/Rock_Papper_Scissors-TEAM_ONE
/Rock_paper_scissors_game.py
1,947
4.15625
4
import random scoretable = [0,0] def computer_choice(): choices = ['rock', 'paper', 'scissors'] return random.choice(choices) def player_choice(player): if player == "1": player_choice = "rock" elif player == "2": player_choice = "paper" else: player_choice =...
true
bd73fb30e905df4c30601a00e541c9eaab9ac50a
tashfiahasan/calculator-project
/calc.py
2,153
4.21875
4
# #addition # def add(x, y): # return x + y # #subtraction # def subtract(x, y): # return x - y # #multiplication # def multiply(x, y): # return x * y # #division # def divide(x, y): # return x / y # while True: # # Take input from the user # choice = input("Enter choice(+/-/*//): ") # # C...
false
df08c1c86d29e0187566b66bd0e0cb8a8d7813a5
RakhshandaMujib/The-test-game
/Test_game.py
1,992
4.1875
4
import math def single_digits_only (list_is): ''' This method checks a list of number for any number that has more than 2 digits. If there is any, it splits the digits of the same. Argument: list_is - List. The list of numbers to check. Returns: list_is - Revised list. ''' index = 0 while...
true
2b2989045ce3fbf972faf3653e8ea9f65ac45e71
CadetPD/Kodilla_4_2
/zad_4-2_palindrom_.py
391
4.1875
4
def palindrome(word): """ Palindrome(word) checks if a word is palindrome or not Parameter: word Argument: 'word' Sollution: compare lists for argument ([normal] vs [reversed]) Func result: returns after func execution """ if list(word.lower()) == list(reversed(word.lower())): ...
true
2b7329ca49a053e7bb0392d43233c360a8344de3
caitinggui/leetcode
/zigzag_conversion.py
2,099
4.28125
4
#!usr/bin/python # coding:utf-8 ''' The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the co...
true
566fa1ae85da1c75006ff57a27e582a1290b1047
caitinggui/leetcode
/189_rotate_array.py
1,410
4.34375
4
# coding: utf-8 ''' Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem. [show hint] Hint: Could you do it in-pl...
true
d8c7134b884879119809e2d4d9073df88fd472fe
romperstomper/petshop
/arrayflatten.py
705
4.25
4
"""Flatten an array of arbitrarily nested arrays. Array elements will be integers and nested arrays. Result in a flat array. E.g. [[1,2,[3]],4] -> [1,2,3,4].""" def flatten(target_list): """Flattens a nested list. Args: target_list: (int|list|tuple) Yields: (int) Raises: TypeError: Error if t...
true
f435655c8e051070c5672f122d0d6af36d29f28e
Anoopsmohan/Project-Euler-solutions-in-Python
/project_euler/pjt_euler_pbm_9.py
406
4.1875
4
'''A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. ''' def pythagorean(): for a in xrange(1, 501): for b in xrange(a+1, 501): c ...
true
acb00c5ece15950069d9a074de30b7b5e8e634d9
onyinyealadiume/Count-Primes
/main.py
523
4.15625
4
# Determine if the input number is prime def isPrime(n): for current_number in range(2,n): # if the input number is evenly divisible by the current number? if n % current_number == 0: return False return True # Determine how many prime numbers are UNDER the input number def countPrimes(n)...
true
6314aca8cc2d6e3df75c95a095d9c2fdd816a55f
sxdegithub/myPythonStudy
/Study/oob_objvar.py
1,257
4.15625
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # Author: sx class Robot: """表示一个带有名字的机器人.""" # 一个类变量,用来统计机器人的数量 population = 0 def __init__(self, name): self.name = name print('(Initializing {})'.format(self.name)) # 当有人被创建时,机器人数量加1 Robot.population += 1 def die(se...
false
fe2db7b0d45f4bb358389c68557d21680f618b31
sxdegithub/myPythonStudy
/Study/ds_str_methods.py
497
4.375
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # Author: sx # 这是一个字符串对象 name = 'Swaroop' if name.startswith('Swar'): print('Yes,the string starts with Swar') if name.startswith(('a', 's')): print("yes there is a 'S'") if 'a' in name: print("Yes ,the string contains character 'a'") if name.find('war') != -1...
true
f1e8831044ec44f2cae9076789715eb5682934f5
prossellob/CodeWars
/duplicate_encoder.py
721
4.15625
4
''' The goal of this exercise is to convert a string to a new string where each character in the new string is '(' if that character appears only once in the original string, or ')' if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate. Ex...
true
b36649f74f78e09023d0a9db48c12cbd2a4f769a
anoopch/PythonExperiments
/print_test.py
832
4.28125
4
# Pass it as a tuple: name = "Anoop CH" score = 9.0 print("Total score for %s is %s" % (name, score)) # Pass it as a dictionary: print("Total score for %(n)s is %(s)s" % {'n': name, 's': score}) # There's also new-style string formatting, which might be a little easier to read: # Use new-style string formatting: pri...
true
b74d7bd074117eac432209dd90ec6117e890b53d
anoopch/PythonExperiments
/Lab_Ex_23_Factorial_Of_Number_while.py
509
4.4375
4
# Program to Factorial of a number number = int(input('Enter an Integer number : ')) if number < 0: print("Sorry, factorial does not exist for negative numbers") elif number == 0 or number == 1: print("The factorial of {0} is {1}".format(number, number)) else: i = 1 factorial = 1 while i < number + ...
true
5ca09128a7e6200bc5df8a766fa1f86f739c8db4
anoopch/PythonExperiments
/Lab_Ex_16_celcius_to_farenheit.py
223
4.40625
4
# Convert celcius to farenheit celcius=float(input('Enter the temperature in Celcius : ')) farenheit=(celcius*(9/5)) + 32 print('The temperature equivalent of {} Celcius is {} Farenheit'.format(celcius, farenheit))
true
d1f09f88680f085e6666fefee0f6304430579d42
MeghaGajare/Algorithms
/String/reverse a string.py
247
4.3125
4
#reverse a string string = input() a = string[::-1] print('reverse string: ',a) # or b = '' for i in string: b=i+b print(b) #check palindrome string if(a == string): print("It is a palindrome.") else: print("It is not palindrome.")
true
bafb73885ef959997ef30080692ab47a8ebc7ecf
Chenfc2019/python-data-structure
/linkedlist_stack.py
1,633
4.28125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @File : linkedlist_stack.py # @Author: Small-orange # @Date : 2020-12-07 # @Desc : 栈结构的链表实现 class Node(object): """节点定义""" def __init__(self, data): self.data = data self.next = None class Stack(object): """链表实现栈""" def __init__(sel...
false
ac34b15de951625480c670d0ce60bd3586b77931
ddh/leetcode
/python/perform_string_shifts.py
1,958
4.1875
4
""" You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left shift) or 1 (for right shift). amount is the amount by which string s is to be shifted. A left shift by 1 means remove the first character of s and append it to the ...
true
d72c8326f3567ad955f46f848e232247bf1b573a
ddh/leetcode
/python/shortest_word_distance.py
1,834
4.125
4
""" Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. Example: Assume that words = ["practice", "makes", "perfect", "coding", "makes"]. Input: word1 = “coding”, word2 = “practice” Output: 3 Input: word1 = "makes", word2 = "coding" Output: 1 Note: Yo...
true
7c43bb2aa58e7787c6b36e405cad2d56e2a44f79
xexugarcia95/LearningPython
/CodigoFran/ListasTuplas/Ejercicio8.py
384
4.28125
4
"""Escribir un programa que pida al usuario una palabra y muestre por pantalla si es un palíndromo.""" palabra = input("Introduzca una palabra: ") letras = [] for i in range(len(palabra)): letras.append(palabra[i]) inversion = letras[::-1] if inversion == letras: print(f"{palabra} ES una palabra palindrom...
false
4a84ecbe814a8c31be787739dcca41c5e1ee5ab8
xexugarcia95/LearningPython
/CodigoJesus/SintaxisBasica/Ejercicio5.py
463
4.5
4
"""Escribir un programa que pregunte el nombre del usuario en la consola y después de que el usuario lo introduzca muestre por pantalla <NOMBRE> tiene <n> letras, donde <NOMBRE> es el nombre de usuario en mayúsculas y <n> es el número de letras que tienen el nombre.""" mi_nombre = input("Introduce tu nombre: ") # La ...
false
b3b1d5f2aca03f3c70376bf7a4d712ff5989a1a4
xexugarcia95/LearningPython
/CodigoJesus/Bucles/Ejercicio4.py
316
4.125
4
"""Escribir un programa que pida al usuario un número entero positivo y muestre por pantalla la cuenta atrás desde ese número hasta cero separados por comas.""" num = int(input("Introduce un numero entero positivo: ")) for i in range(num, -1, -1): print(i, end="") if i != 0: print(",", end="")
false
bceef65db35644a54d700d1e63218801157572e4
xexugarcia95/LearningPython
/CodigoJesus/Bucles/Ejercicio6.py
268
4.375
4
"""Escribir un programa que pida al usuario un número entero y muestre por pantalla un triángulo rectángulo como el de más abajo, de altura el número introducido.""" num = int(input("Introduce un numero entero: ")) for i in range(1, num+1, 1): print("*"*i)
false
222154c4bd26e4470820e0d722d0be03538900bd
xexugarcia95/LearningPython
/CodigoJesus/Listas/Ejercicio7.py
502
4.28125
4
"""Escribir un programa que almacene el abecedario en una lista, elimine de la lista las letras que ocupen posiciones múltiplos de 3, y muestre por pantalla la lista resultante.""" lista = [] lista2 = [] # chr() te convierte el numero en caracter de la tabla ascii correspondiente for i in range(97, 123, 1): lista....
false
aa3b7b494722c78588acd89948b556ca329733c7
xexugarcia95/LearningPython
/CodigoJesus/Listas/Ejercicio3.py
715
4.3125
4
"""Escribir un programa que almacene las asignaturas de un curso (por ejemplo Matemáticas, Física, Química, Historia y Lengua) en una lista, pregunte al usuario la nota que ha sacado en cada asignatura, y después las muestre por pantalla con el mensaje En <asignatura> has sacado <nota> donde <asignatura> es cada una d...
false
a0157e9d059f448f30af6ddb873b9eef438ec171
CalebKnight10/CS_260_4
/factorial_recursive.py
276
4.34375
4
# A factorial is multiplying our num by the numbers before it # Ex, 5 would be 5x4x3x2x1 def factorial(num): if num <= 1: return num else: return factorial(num - 1) * num def main(): print(factorial(9)) if __name__ == '__main__': main()
true
010fb27996b2a30bffb70755ba9c86266215f4b2
Tradd-Schmidt/CSC236-Data-Structures
/T/T12/count_evens.py
2,009
4.34375
4
# ------------------------------------------------------------------------------- # Name: count_evens.py # Purpose: This program is designed to use recursion to count the number of # even numbers are read from a file. This sequence is stored in a # linked list. # # Created: 08/10/2...
true
e8e7d5b2eac6d3937b518a55d0219d2951b2a784
Tradd-Schmidt/CSC236-Data-Structures
/A/A08/LinkedLIst_smdriver.py
2,037
4.125
4
# ------------------------------------------------------------------------------- # Name: LinkedList_smdriver.py # Purpose: Rudimentary driver for the LinkedList class. # # Edited by: Tradd Schmidt on 9/21/17 # ------------------------------------------------------------------------------- from LList impor...
true
92fb30404522bc211979ebf91b8c33d55c91be96
gayatri-p/python-stuff
/challenge/games/guess.py
541
4.21875
4
import random start = 0 end = 100 n = random.randint(start, end) tries = 1 print('-----Guessing Game-----') print(f'The computer has guessed an integer between {start} and {end}.') guess = int(input('Guess the number: ')) while guess != n: tries += 1 if n > guess: print('The number is larger than you...
true
8fcc321aa45145737d6343a0387637a586a20d01
ramiro-arias/HeadPython
/HeadPython/Chapter02/p56.py
732
4.15625
4
# Source: Chapter01/The Basics/p56.py # Book: Head First Python (2nd Edition) - Paul Barry # Name in the book: Working with lists # Eclipse project: HeadFirstPython ''' Created on May 2, 2019 @author: ramiro ''' # We will use the shell to first define a list called vowels, then check to see if # each letter in a wor...
true
6e3542bf51343ab56329a32dfc76cbe504f55bf0
dhking1/PHY494
/03_python/heavisidefunc.py
414
4.1875
4
# Heaviside step function def heaviside(x): """Heaviside step function Arguments --------- x = float input value Returns --------- Theta : float value of heaviside """ theta = None if x < 0: theta = 0. elif x == 0: theta = 0.5 else: theta = 1. r...
true
e1a778777bd164df6a46519e74ee6f35d84fc22b
missingcharacter/janky-stuff
/python/rename_trim_multiple_spaces.py
515
4.21875
4
#!/usr/bin/env python3 # Python3 code to rename multiple # files in a directory or folder # importing os module import os import re # Function to rename multiple files def main(): for filename in os.listdir("./"): src = filename dst = re.sub(' +', ' ', filename) # rename() function will ...
true
b16e84881f252e7bb69cae559e249d524284c599
FabianCaceresH/ejercicios_profundizaci-n_sesion_2
/profundización/ejercicio_profundización_2.py
1,461
4.15625
4
# Tipos de variables [Python] # Ejercicios de profundización # Autor: Inove Coding School # Version: 2.0 # NOTA: # Estos ejercicios son de mayor dificultad que los de clase y práctica. # Están pensados para aquellos con conocimientos previo o que dispongan # de mucho más tiempo para abordar estos temas por ...
false
9908b618ce802c2f87b408d13a66a92cf43cb8db
marinavicenteartiaga/KeepCodingModernProgrammingWithPython
/module0/e0.py
708
4.125
4
name = input("What's your name?\n") print("Hello " + name + "!") strAge = input("How old are you?\n") strYear = input("What year is it?\n") strBirthdayYet = input("Has it already been your birthday? (YES/NO)\n") age = int(strAge) year = int(strYear) while strBirthdayYet != "YES" or strBirthdayYet != "NO": strBi...
false
1fc26b0beb9013585a58985916541dcc1b95f3e1
Tanges/assignment5_1-python
/sequence.py
746
4.25
4
n = int(input("Enter the length of the sequence: ")) # Do not change this line #The sequence for the algorythm is 1, 2, 3, 6, 11, 20, 37, ___, ___, ___, … #Idea: i + 2 power of i #Algorithm adds up last 3 inputs and returns the sum of it #Make a list with first 3 inputs which are already determined #Print out the first...
true
a37ffbff5331c3c7e1741073bec9c177ec4ac244
Sean-Stretch/CP1404_Pracs
/Prac_01/shop_calculator.py
876
4.34375
4
""" The program allows the user to enter the number of items and the price of each different item. Then the program computes and displays the total price of those items. If the total price is over $100, then a 10% discount is applied to that total before the amount is displayed on the screen. """ total_cost = 0 valid...
true
e1acc07b442cc2063ba350d51f7e865cca49f6d3
brunopesmac/Python
/Python/curso/ex33.py
984
4.21875
4
numero1 = float(input ("Digite o 1 numero: ")) numero2 = float(input ("Digite o 2 numero: ")) numero3 = float(input ("Digite o 3 numero: ")) if numero1 > numero2 and numero1 > numero3: if numero2>numero3: print("O maior numero é o {:.2f} e o menor é o {:.2f}".format(numero1,numero3)) if numero3>nu...
false
327197a5ee25edcae773ad77af22eca04e35495b
nikhilbagde/Grokking-The-Coding-Interview
/topological-sort/examples/tasks-scheduling/python/MainApp/app/mainApp.py
2,454
4.125
4
from collections import defaultdict class MainApp: def __init__(self): pass ''' There are ‘N’ tasks, labeled from ‘0’ to ‘N-1’. Each task can have some prerequisite tasks which need to be completed before it can be scheduled. Given the number of tasks and a list of prerequisite pairs, f...
true
ca140ef57f7b1a6616faf90660071bf1e276fa9a
nikhilbagde/Grokking-The-Coding-Interview
/sliding-window/examples/no_repeat_substring/python/MainApp/app/mainApp.py
1,272
4.15625
4
import sys class MainApp: def __init__(self): pass ''' Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb...
true
aac73ba75af9ca633c06abf6d78725b838e55bfc
nikhilbagde/Grokking-The-Coding-Interview
/two-pointers/examples/subarrays-with-products-less-than-k/python/MainApp/app/mainApp.py
1,235
4.125
4
class MainApp: def __init__(self): pass ''' Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k. Example 1: Input: nums = [10, 5, 2, 6], k = 100 Output: 8 ...
true
c957a225ec65cf3aad4a51a334f7d241f51c866d
nikhilbagde/Grokking-The-Coding-Interview
/tree-bfs/examples/reverse-level-order-traversal/python/MainApp/app/mainApp.py
1,853
4.1875
4
from queue import Queue class FifoDataStructure: def __init__(self): self.stack = list() def push(self, e): self.stack.insert(0, e) def get(self): if len(self.stack) == 0: return None self.stack.pop(0) def get_stack(self): return self.stack clas...
true
957472acc148e3088ae2dc0a453c783065ff0dd4
nikhilbagde/Grokking-The-Coding-Interview
/fast-and-slow-pointers/examples/middle-of-linked-list/python/MainApp/app/mainApp.py
1,085
4.125
4
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class MainApp: def __init__(self): pass ''' Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the secon...
true
82e2a58a20f4e9896cc97e34af2074e55baf6ccb
imtiazraqib/Tutor-CompSci-UAlberta
/CMPUT-174-Fa19/guess-the-word/Guess_The_Word_V1.py
1,410
4.28125
4
#WordPuzzle V1 #This version plans to implement the ability for the program to select a word from a limited word list #The program will then remove the first letter and replace it with an _ and the player can make a guess #if correct, the program congratulates. if not then condolensces are sent #Functions such as multi...
true
15a6ed0d48f867c9163defbe6f25428091c0e2cd
Nandi22/hardway3
/ex18.py
697
4.3125
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 2 18:45:33 2019 @author: ferna """ # this one is like your scripts with argv def print_two(*args):# defines what function does arg1, arg2 = args # asks for arguments print (f"arg1: {arg1}, arg2: {arg2}") # ok, that *args is actually pointless, ...
true
e28857ed5e13136e51a95d8991451371504aa2ae
zengyongsun/python_study
/变量与数据类型/name_case.py
625
4.5
4
# 个性化消息: 将用户的姓名存到一个变量中,并向该用户显示一条消息。 # 显示的消息应非常简单,如“Hello Eric, would you like to learn some Python today?”。 name = 'eric' print('Hello ' + name.title() + ',' + 'would you like to learn some Python today ?') #调整名字的大小写: 将一个人名存储到一个变量中,再以小写、大写和首字母大写的方式显示这个人名。 name = 'he zheng xiang' print(name.lower()) print(name.upper(...
false
80ab3308aae777be47cadae6a97ca30c2a192e42
airaider/python_algo_study
/16장_트라이/트라이 구현.py
1,047
4.15625
4
class TrieNode: def __init__(self): self.word = False self.children = {} class Trie: def __init__(self): self.root = TrieNode() def insert(self, word:str) -> None: node = self.root for char in word: if char not in node.children: node.chi...
false
dac7d2d70f4736f453f5b446453120568896df33
jitendrabhamare/Problems-vs-Algorithms
/Sort_012.py
1,364
4.25
4
# Dutch National Flag Problem # Author: Jitendra Bhamare def sort_012(list_012): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: list_012(list): List to be sorted """ next_pos_0 = 0 next_pos_2 = len(list_012) - 1 front_index = 0 whi...
true
10e5e22683d76cd7f02845a05047643950bfa2d2
Vivekagent47/data_structure
/Python/doubly_linked_list.py
2,923
4.3125
4
''' In this program wi impliment the Doubly LinkedList here we can do 4 differnt operations: 1- Insert Node at Beginning 2- Insert Node at End 3- Delete the node you want 4- Print List ''' class Node: def __init__(self, data, next = None, previous = None): self.data = data self.nex...
true
41da7c31e33c98cb1a8aeb8443920252c16d8312
Jaynath1992/Python_Automation
/Python_Classes/Python_Day5_To_9/Python_Day5_To_9/Python day_9/myCar.py
1,912
4.3125
4
class Car(object): no_of_tyres = 6 def __init__(self, no_of_tyres =5): self.no_of_tyres = no_of_tyres def __del__(self): # destructor : destroying objects print 'Destroying an object of the class' def move_car(self, direction): print 'car is moving towards {} direction'.f...
false
0636c88fef8fc6340db92c5c000ef166ab482543
Jaynath1992/Python_Automation
/Python_Classes/Python_Day5_To_9/Python_Day5_To_9/Python_Assignment_Exercise _1/14_Leap_Year.py
577
4.21875
4
# 14) WAP to find out the leap year. # (Except a year from the user using raw_input) # A leap year is exactly divisible by 4 except for century years # (years ending with 00). The century year is a leap year only if # it is perfectly divisible by 400. For example def Check_LeapYear(year): if year % 4 == 0 and (y...
false
6da9eac046121212d554fa6500eb2da6cd2be4b0
Rhornberger/Python
/python_folder/roll_dice.py
1,235
4.125
4
''' Rolling dice with gui interface using tkinter written by Rhornberger last updated nov 12 2019 ''' # import library from tkinter import * # create the window size and welcome text window = Tk() window.title('Welcome to the D20 roller!') lbl = Label(window, text = 'Welcome!', font =('arial', 20)) lbl.grid(column = ...
true
02e0f413935a045783423ee27aa57c71acb3551c
JaredBigelow/Python-Projects
/Nesting, Div, and Mod/Star.py
2,516
4.1875
4
#Author: Jared Bigelow #Date: February 27 2015 #Purpose: To create star patterns based on inputted type and size #Input: Type, size #Output: Star Pattern #Star Patterns ################################################################################ import math repeat = "Y" while repeat == "Y" or repeat == "y": ...
true
ff9baf913c50c07d3b7805702505cbf78d01bde7
chelseavalentine/Courses
/Intro-Programming/[10]AnotherSortOfSort.py
647
4.1875
4
""" Assignment Name: Another Sort of Sort Student Name: Chelsea Valentine (cv851) """ import random #ask for input & keep the user in a loop until they type 'done' while True: n = int(input("Enter an integer to create a random list, or type 'done' to finish: ")) #check whether user entered 'done' & define th...
true
4602412de2c9a2a876149e9ed2fb249a789b3413
ShazamZX/Data-Structure-and-Algorithm
/Array Questions/PalinMerge.py
1,084
4.3125
4
""" Given an array of positive integers. We need to make the given array a ‘Palindrome’. The only allowed operation is”merging” (of two adjacent elements). Merging two adjacent elements means replacing them with their sum. The task is to find the minimum number of merge operations required to make the given array a ‘Pa...
true
8cc89bb11638aa49abdcfd1c52b5e8b983bd0131
ShazamZX/Data-Structure-and-Algorithm
/Array Questions/ZeroSumSubA.py
609
4.125
4
#check if an array has a any subarray whose sum is zero (Prefix sum method) #the idea is that we calculate prefix sum at every index, if two prefix sum are same then the subarray between those two index have sum as zero def subSum(arr): prefix_sum = set() prefix_sum_till_i = 0 for i in range(len(arr)): ...
true
9cfd7b4f89b93e5af2765e5c60e3eb0fb58db748
Mehedi-Bin-Hafiz/Python-OOP
/classes/creating_a_class.py
2,156
4.8125
5
# Making an object from a class is called instantiation, and you work with # instances of a class. #### when we write function in a class then it called method # ((Methods are associated with the objects of the class they belong to. # Functions are not associated with any object. We can invoke a function just by its n...
true