blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ea84d83db6a672ef7a015ef0fec2f0af48368284
sukhvir786/Python-DAY-4
/fun12.py
525
4.25
4
""" Problem: Heron's formula a,b,c are length of sides of a triangle s = semi circumference s = (a+b+c)/2 area = sqroot(s(s-a)(s-b)(s-c)) """ # %% def FUN(): """ computes area of triangle using Heron's formula. """ a = float(input("Enter length of side one: ")) b = float(inp...
false
c097917a104b8d1fbb1614c90c7af19d0a2ce64b
TrinityChristiana/py-functions
/cash-to-coins.py
938
4.125
4
# **************************** Challenge: Cash to Coins **************************** """ Author: Trinity Terry pyrun: python cash-to-coins.py """ import math # Now do the reverse. Convert the dollar amount into the coins that make up that dollar amount. The final result is an object with the correct number of quarters,...
false
6d63f96591f210049407b3930d131435727b2dfa
nicodlv99/100-days-of-code
/basics/sequence-types.py
1,657
4.59375
5
#Creating a string s = "Hello World, how are you doing!" #Creating a string to print print(s) s1 = """This is a line of code with multiple ines""" print(s1) #defining a string that contains multiple lines print(s[0]) #indexing to find the first letter in a word using dictionaries ...
true
621c0d35b6e0a2ff8fad1f30b74164b30c09115b
kicksmackbyte/project_euler
/p004.py
589
4.3125
4
""" Find the largest palindrome made from the product of two 3-digit numbers. """ def is_palindrome(i): str_ = str(i) if str_ == str_[::-1]: return True else: return False def main(): num_1 = 999 num_2 = 999 palindromes = [] for i in range(900): a = 999 - i ...
true
8faa9ef69ed763164ec130d4a91088df7d30030d
satishraut/inter-prep
/oops/methodOverLoadingAndRiding.py
799
4.125
4
''' Override means having two methods with the same name but doing different tasks. It means that one of the methods overrides the other. Like other languages (for example method overloading in C++) do, python does not supports method overloading. We may overload the methods but can only use the latest defined meth...
true
0bf5883db8abc4f19b9fa91778012fc4a0faa28d
pkiuna/CS490-MachineLearning-Python
/ICP2/ICP2.py
1,350
4.15625
4
class employee: # Members to count employees and find average salary counter = 0 salary = 0 #contructor to initialize family, salary, department using self def _init_(self, name, family, salary_num, department): self.name = name self.family = family self.salary_num = salary_...
true
f162ad816fd042b77c190a314d018ae4f489d12a
ansariimran/small-python-programs
/pattern.py
1,061
4.5
4
def pattern(n): # for i in range(1, n+1): # # print i number of * s in # # each line # print("*" * i) for i in range(1, n+1): li = [ ] # print("INCREMENTED FOR LOOP") for j in range(1, i+1): li.append(j) #print("\n DECREMENTED FOR L...
false
5493eddc6e37f078d9ec50b0ded6d3efaf5e0847
Lynn-Lau/Algorithm-Toolbox
/2nd week/01_Codes/fibonacci_last_digit/fibonacci_last_digit .py
893
4.40625
4
#Uses python2 """ A Simple Program for Coursera Algorithmic Toolbox & The Last Digit of a Large Fibonacci Number & Given an integer n, find the last digit of the nth Fibonacci number Fn. Author: Lynn Lau Date: 2016/07/27 """ ''' Naive Algorithm ''' def Calc_Fib_Lst(n): FibList = [0, 1] #print FibList if n == ...
false
7e24870e885624f70f0532f545823d73e3a16a1a
annamnatsakanyan/HTI-1-Practical-Group-1-Anna-Mnatsakanyan
/Lecture_6/insertion_sort.py
345
4.15625
4
def insertion_sort(num): for i in range(1, len(num)): value_to_insert = num[i] j = i - 1 while j >= 0 and value_to_insert < num[j]: num[j + 1], num[j] = num[j], num[j + 1] j -= 1 numbers = [int(elem) for elem in input("enter the numbers: ").split()] insertion_sort(n...
true
46ca0cc0de67bcc58430952e78505260f4b383f4
colinvsyolanda/python
/study/list_tuple_dictionary/python010.py
359
4.125
4
""" 题目:暂停一秒输出,并格式化当前时间。 程序分析:无。 """ import time print(time.localtime()) print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) time.sleep(2) print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) time.sleep(2) print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
false
26eb512c18e30d70e0a383ca748302bfef9a3681
samarthgowda96/pycharprojects
/pal.py
493
4.15625
4
string= input("enter the input"+" ") def isPalindrome(str): length = len(str) first = 0 last = length - 1 palindrome = 1 while first < last: if(str[first] == str[last]): first = first + 1 last = last - 1 continue else: palindrome= 0 ...
true
37f7995cd0bdebf46e1a3a4776885ea94c301713
poojarkpatel/Testing_Triangle_Classification
/HW01_Pooja_Patel.py
1,702
4.25
4
""" HW01 Triangle classification """ import math class Triangle: """ The class takes length of three sides of triangle and return the type of triangle. """ def __init__(self, side1, side2, side3) -> None: """ init function of class """ self.side1 = float(side1) ...
false
8b89a4b42869fb143357174fcf98e5c0d50170e8
srujanprophet/PythonPractice
/11 - Unit 4/4.1.12.py
407
4.1875
4
str = "Global Warming" print str[-4:] print str[4:9] if str.isalpha() == True: print "It has alphanumeric characters" else: print "It does not have alphanumeric characters" print str.strip("ming") print str.strip("Glob") print str.index('Wa') print str.swapcase() if str.istitle() == True: print "It i...
true
b7856076678d3ee518d06ed63acdd113f195715b
srujanprophet/PythonPractice
/11 - Unit 3/3.3.6.py
203
4.15625
4
def fibonacci(): n = int(input("Enter no. of terms : ")) pre = 0 cur = 1 for i in range(1,n+1): print cur nxt = pre + cur pre = cur cur = nxt fibonacci()
false
f02ac49567bc1f4089fcc75e4307c397ffc9cdf0
saurabhpati/python.beginner
/OperatorsAndConditionals/elif.py
535
4.40625
4
# elif keyword is used to make the else if statement in python # Requirement for this example: User gives the amount. # 1. If amount is less than 1000, discount is 5% # 2. If amount is less than (or equal to) 5000, discount is 10% # 3. If amount is more than 5000, discount is 15% amount = input('Enter the amount: '); ...
true
fe5b725a5760c7c55a3aeff33b85cce2aaa6aa5a
saurabhpati/python.beginner
/Lists/list-operations.py
1,426
4.5
4
# iterating over a list. testList = [1, 2, 3] ; for x in testList: print(x, end='\n'); # extend will the given list to the list on which extend is called. languagesKnownList = ['c#', 'javascript','python']; languagesKnownList.extend(testList) print('Languages known and extended:', languagesKnownList); # appe...
true
3ec9c0250c484d50af12a557650e415956c1303f
saurabhpati/python.beginner
/OperatorsAndConditionals/arithmetic.py
287
4.3125
4
# This programs intends to highlight between the differences of '/' and '//' operators. x = input('Enter the dividend: '); y = input('Enter the divisor: '); x = int(x); y = int(y); print('x/y = ', x/y); print('x//y = ', x//y); print('divident raised to the power of divisor = ', x**y);
true
a0050a3c5375653743e52283756fbe648cb01e62
kazmanbanj/Practice_on_Python
/file io/script.py
953
4.1875
4
# my_file = open('test.txt') # print(my_file.read()) # my_file.seek(0) # print(my_file.read()) # my_file.seek(0) # print(my_file.read()) # print(my_file.readlines()) # my_file.close() # Standard way to Read, write, append in python # with open('test.txt', mode='r+') as my_file: # print(my_file.readlines()...
true
c666e839c06a7dcb299706f8fb77bbccf29d1e70
kb9zzw/arcpy_scripts
/distanceTry.py
1,012
4.1875
4
#Name: distanceTry.py #Purpose: converts miles to kilometers or vice-versa #Usage: distanceTry.py <numerical_distance> <distance_unit> #Example: distanceTry.py 5 miles #Author: Jon Burroughs (jdburrou) #Date: 2/16/2012 import sys # get distance value from user (assume they'll provide it correctly) dist...
true
6f3d2881cdd2ab5cf54ab085d11b69be44cf38f9
DvidGs/Python-A-Z
/9 - Funciones en Python/ejercicio 6.py
1,515
4.5
4
# Ejercicio 6 # Crea una función que devuelva el MCM (mínimo común múltiplo) de 2 números proporcionados por # parámetro. # PISTA: Aprovecha la función que calcula el MCD de dos números del ejercicio anterior y la función que # calcula el valor absoluto de un número. def bigger(a, b): """ Devuelve el mayor num...
false
e4c25314eaab9261336eeff4f0160a3ba72ecea6
DvidGs/Python-A-Z
/3 - Operadores de decisión/ejercicio 5.py
1,016
4.3125
4
# Ejercicio 5 # Haz que un usuario introduzca dos números enteros positivos. Suponiendo que el primer número introducido # por el usuario es mayor o igual al segundo número introducido por el usuario, comprueba que la división del # primer número entre el segundo número es entera. # En caso de la división ser entera, d...
false
2fbb31d6ea051260551205126fac7c5532ce22e7
qpwoeirut/python_book_work
/book_work/21_Dictionary.py
468
4.34375
4
stanley = {'age': '11', 'birthday': 'August 24, 2005','school': 'Bowman School', 'grade': '6th', 'activities': 'soccer, coding, and video games', 'family': 'Nan Zhong(Father), Yun Luo(Mother), Randy Zhong(Brother)'} print(stanley['school']) today = {'year': '2017', 'month': 'June', 'day': '13'} today['weekday']= 'Tues...
false
8713d7b1db28ea750666376aecce9231393655bf
PromytheasN/Project_Euler_Solutions_1-10
/Task 5 Solution.py
1,201
4.1875
4
import numpy def small_divident(): """ This is a function that calculates the smallest divident number, evenly divisable by all numbers between 1 to 20. """ #If our number is evenly divisable with the list bellow, it should be evenly divisable with #1 to 10 as well as all the numbers bell...
true
afa0a8a76248a73be56eec3d388a23ec11945f96
anandtakawale/classcodes
/optimizations_sem8/fibonacci.py
2,787
4.15625
4
import texttable import math def fibonacciMethod(f, a, b, epsilon): """ Returns minima of the function """ #calculating number of iterations fn = (b - a) / epsilon n = fibFinder(fn) print n k = 0 table = texttable.Texttable() table.add_row(["Iteration", "a", "b", "x1", "x2", "f(...
true
35cd0814bb7aaedc923c533943637886830c0593
AshVijay/Leetcode_Python
/496.py
2,433
4.125
4
""" 496. Next Greater Element I Easy 1103 1685 Add to List Share You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. The Next Greater Number of a number x in nums1 is t...
true
70ac588cf1ba0c9fd8db5fe5688ed44730e73efe
Tadrop/30_days_of_code
/day9.py
484
4.21875
4
def fibSum(number): if not isinstance(number,int): return 'Invalid input, number must be positive integer' if number == 0 : return 0 elif number < 0: return "Invalid, number can't be negative" elif number > 0: pass num =0 a,c=0,1 while c>=number: ...
true
80c70ddc2a5f144314acc68f929a2ef70418c90d
EstherAmponsaa/cssi
/week3/test.py
1,309
4.28125
4
#print('Hello CSSI') #name ='Bill' #name = 55 #print(name) #name = raw_input('Enter your name:') #print('Hi there..') #print(name) #print('na'*16) # print('BATMAN!') #print('Pow!'*3) #user_input = raw_input('Enter anything:') #print('You entered a ', (type(user_input)) #print('raw_input gives us strings') #num1 = raw...
false
8aabefe65e37fd1b223d5910875332a193e9ce02
EkaterinaBazhanova/Python
/Les3Ex4_2.py
1,059
4.25
4
def my_func_2(x, y): """Выволняет возведение действительного положительного числа в отрицательную целую степень циклом с помощью *.""" power = 1 n = abs(y) + 1 for i in range(1, n): power = power * (1/x) return round(power, 4) def check(): """Проверяет правильность ввода данных пользова...
false
69c2bc890089754abd6ca0021ba726b2ebe7844b
Abinesh1991/Numpy-tutorial
/NumpyTutorial8.py
755
4.28125
4
""" Python, Numpy and Probability Random using numpy """ import numpy as np outcome = np.random.randint(1, 7, size=10) print(outcome) # generated 5*4 matrix using the random number range from 1 - 7 """ output: [[4 4 5 4] [4 4 5 2] [3 3 3 4] [3 5 4 5] [6 1 2 6]] """ print(np.random.randint(1, 7, size=(5, 4))) #...
true
409cb01cecf4af685af65480648c49c8efaf57c0
Abinesh1991/Numpy-tutorial
/NumpyTutorial5.py
2,239
4.1875
4
""" Data type object 'dtype' is an instance of numpy.dtype class. It can be created with numpy.dtype. """ import numpy as np # sample example with int16 data type i16 = np.dtype(np.int16) print(i16) lst = [[3.4, 8.7, 9.9], [1.1, -7.8, -0.7], [4.1, 12.3, 4.8]] A = np.array(lst, dtype=i16) print(A) "...
true
8b57cdcbba3d3c0f7d0203ec3be8e29167c11a8d
Helianus/Python-Exercises
/src/SumOfNumbers.py
452
4.25
4
#Given two integers a and b, which can be positive or negative, # find the sum of all the numbers between including them too and return it. # If the two numbers are equal return a or b. # Note: a and b are not ordered! def get_sum(a, b): sum = 0 if a == b: return a elif a > b: for i in ra...
true
0dd8bda64e43cea077ab8a390b1f58b1fe75d101
Helianus/Python-Exercises
/src/PairRoot.py
238
4.15625
4
# 0 < pwr < 6 and root^pwr = user input n = int(input("Enter an integer: ")) root, pwd = 0, 0 while root <= n: pwd += 1 if pwd == 6: pwd = 1 root += 1 if root ** pwd == n: print(root, "^", pwd, "is", n)
false
11ef074543b310af32ce9d0b43a2a23111422650
mor16fsu/bch5884
/tempconversion.py
286
4.25
4
#!/usr/bin/env python3 #github.com/mor16fsu/bch5884 import math x=float(input("Please enter a value in degrees Farenheit to convert to degrees Kelvin:")) print (type (x)) x=float(x) y=math.floor(x-32)*5/9+273.15 print (y) print ("The calculation is complete: Degrees Kelvin")
true
6db4d82f13ebcf3bb99365d2b8af9ff458ca5961
puhelan/150
/1. DS/1.1.py
1,364
4.3125
4
''' 1.1 _______________________________________________________________________________ Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures? _______________________________________________________________________________ Notes: 1. with hash map...
true
cdacc8f0adeea4aab139c8bb9d714415fc294c9a
BryceBoley/PythonExercises
/Exercise_2.py
1,059
4.28125
4
# getting user input and checking that it is a number and not zero gas = input("\nWelcome to the fun conversion tool!\n\nPlease enter a number to represent gallons of gasoline: ") while not gas.isdigit() or int(gas) == 0: gas = input("A number you numskull, not a letter or zero!\nEnter your number") # math for con...
true
c93dc777cf687fa36d79db956d9cf9292eaff5f8
pphubgit/python-2110101
/clique-clip-lecture/final/52-get-key-value-item-from-dicy.py
440
4.3125
4
#key value item in python s.keys() #--> คืน list ของ key ออกมา s.values()#--> list ของ values ออกมา s.items() #--> list ของ [(key,value),(key2,value2)] ออกมา #ประโยชน์ for key in s.keys(): # ถ้าไม่ได้ใส่ เป็น for a in s เหมือน for a in s.keys() print(key) for (k,v) in s.items(): print('key=',k,'value=...
false
1429b690d10a055ef3dfcdb7fd855470b5c4a310
Teldrin89/DBPythonTut
/LtP11_custom_exception.py
991
4.15625
4
# it is possible to create a custom exception - it has to be # inherited from the exception class # create a new class for handling custom made exception - use # inheritance of exception build in class class DogNameError(Exception): # initialize the class with init function def __init__(self, *args, **kwargs)...
true
50b4bc46338d0e7ff766988ea9ed05f565aaa7a0
Teldrin89/DBPythonTut
/Problem_23.py
1,445
4.28125
4
import re # Problem 23: # Use regular expressions to match email addresses # from the list with set rules for what is an email # address (just find how many there are): # 1. 1 to 20 lowercase and uppercase letters, numbers, # plus ._%+- symbols # 2. An @ symbol # 3. 2 to 20 lower case and uppercase letters, numbers...
true
21c8f84e8b76eff91026f0c155d2a552952b8edb
Teldrin89/DBPythonTut
/LtP13_list_comprehension.py
1,970
4.8125
5
# list comprehension is going to execute an expression # against an iterable - much as "map" and "filter" # while a list comprehension is powerful it has to be used # with cautious to not get overcomplicated # use different methods to obtain the same list # of values: multiplication by 2 using map and lc # a) map prin...
true
bc22d61afc37ca167a7550f922397c394f9c4d9a
Teldrin89/DBPythonTut
/Problem17.py
1,317
4.375
4
# Problem 17: # - create a file named "mydata2.txt" - put any type of data # - use methods from LtP8 how to open a file without "with" # (open in "try" block) # - catch FileNotFoundError # - in "else" print contents of the file # - in finally print out some msg that will always be on screen # - try to open nonexisten...
true
58684c61c8d6dcecc16fb15542f46ef9a6dcffe0
Teldrin89/DBPythonTut
/LtP14_threads_example.py
2,750
4.40625
4
# example of threads usage: whenever threads are used # it is possible to block one of the threads - the # real world script that can utilize this option # will cover a modeling of bank account: let's say # that there is 100$ in the account but there are 3 # different people that can withdraw money from that # account,...
true
56ecd290945ebaceecad8e9ea69386558474eb74
Teldrin89/DBPythonTut
/LtP1.py
999
4.25
4
# Ask the user to input their name and assign # it to a variable named name name = input('What is your name ') # Print out hello followed by the name they entered print('Hello ', name) # Ask the user to input 2 values and store them in variables # num1 and num2 num1, num2 = input('Enter 2 numbers: ').split() # Co...
true
45f2072b3cf0ab1858f85048ebf2c1672e904e6c
Teldrin89/DBPythonTut
/LtP6_lists.py
1,900
4.21875
4
import random import math # list generated similar as to in problem 11 num_list = [] for i in range(5): num_list.append(random.randrange(1, 10)) # sorting list num_list.sort() # reverse sorting num_list.reverse() # change value at specific index -in this example it inserts # number "10" at index 5 num_list.inser...
true
33ba04c4c59b0e51ef8f8e5acd62f2cffb9e05bb
AricA05/Python_OOP
/encapsulation.py
1,480
4.34375
4
#4.Encapsulation '''It is the concept of wrapping data such that the outer world has access only to exposed properties. Some properties can be hidden to reduce vulnerability. This is an implementation of data hiding. For example, you want buy a pair of trousers from an online site. The data that you want is its cos...
true
f7c22e308aa4f6903129e8b7d76842ff5c830e14
dansackett/learning-playground
/project-euler/problem_1.py
321
4.25
4
#!/usr/bin/python """ Multiples of 3 and 5 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 or 5 below 1000. """ limit = 1000 print sum(x for x in xrange(limit) if not x % 3 or not x % 5)...
true
d01b142a983b9c682f5412d7c504b642fd847cd3
adimukh1234/python_projects
/hangman1.py
871
4.125
4
import random name = input("What is your name?\n") print("Hello ", name) print("Welcome to the Hangman Game \nBest of luck") words = ["balloon", "hook", "octopus", "communication", "piano", "honey", "playstation"] guesses = '' word = random.choice(words) print("Guess the characters!") turns = 6 # main ...
true
ca8a612e654795d55625e199997945549b713a1c
untalinfo/holbertonschool-web_back_end
/0x00-python_variable_annotations/3-to_str.py
296
4.34375
4
#!/usr/bin/env python3 """ Basic annotations - to string """ def to_str(n: float) -> str: """takes a float n as argument and returns the string representation of the float Args: n (float): number Returns: str: convert float to string """ return str(n)
true
a16d910dad34c229805ed9875e638a077216b788
StarTux/DailyCodingProblem
/003-2019-03-07-TreeSerialize.py
1,154
4.125
4
#!/usr/bin/python3 # Problem #3 [Medium] # Given the root to a binary tree, implement serialize(root), # which serializes the tree into a string, and deserialize(s), # which deserializes the string back into the tree. # # For example, given the following Node class class Node: def __init__(self, val, left=None,...
true
0aebab530dfa54a10e1d98bd2ba6ad0458f85b2b
jp117/codesignal
/Arcade/Intro/010 - commonCharacterCount.py
804
4.125
4
''' https://app.codesignal.com/arcade/intro/level-3/JKKuHJknZNj4YGL32 Given two strings, find the number of common characters between them. Example For s1 = "aabcc" and s2 = "adcaa", the output should be commonCharacterCount(s1, s2) = 3. Strings have 3 common characters - 2 "a"s and 1 "c". Input/Output [execution...
true
14c11a27484edf19581bca75d54f84ad101b16c0
emmanavarro/holbertonschool-machine_learning
/supervised_learning/0x04-error_analysis/1-sensitivity.py
736
4.21875
4
#!/usr/bin/env python3 """ Calculates sensitivity in a confusion matrix """ import numpy as np def sensitivity(confusion): """ Calculates the sensitivity for each class in a confusion matrix Args: - confusion: is a confusion numpy.ndarray of shape (classes, classes) where row indices...
true
30f5b94defb435a4bb6d98c51b865b46446ef48c
deepika-13-alt/Python-Assignment
/assignment2/second_smallest.py
1,087
4.34375
4
''' Program: WAP to input 3 numbers and find the second smallest. ''' import re # Declarations regex_float = '[+-]?[0-9]+\.[0-9]+' regex_int = "[-+]?[0-9]+$" small_list = [] small_1 = 0 small_2 = 0 # Taking input from users print("Enter 3 numbers for finding smallest among them") for i in range(3): inp = input("...
true
248b398e2d84d812ab7dea2614e296faeeae20cd
deepika-13-alt/Python-Assignment
/assignment5/two_list.py
305
4.125
4
''' Concatenate two lists in the following order Input: L1=[1,2]L2=[4,5] Output: L3=[(1,4),(1,5),(2,4),(2,5)] ''' l1 = [1,2] l2 = [4,5] print("Original list 1: ", l1) print("Original list 2: ", l2) l3 = [] for i in l1: for j in l2: tup = (i,j) l3.append(tup) print("Output: ", l3)
false
726db70c7cca49422f9edeefc1edf51d3b09cc1d
dbms-ops/hello-Python
/1-PythonLearning/3-Python-基础知识/10-数据结构-集合.py
2,009
4.125
4
# !/data1/Python2.7/bin/python2.7 # -*-coding:utf-8-*- # date: 2020-1-16 16:57 # user: Administrator # description: set 的常见操作 # # set: # 无序和无重复的list # 1、set的对象不能够是可变对象,字典、列表是不能够添加的,但是元组是可以的 def create_set(): # 创建set # 创建set 通过list或者tuple或者dict作为输入集合 # set 可以用于 list tuple,dict元素的去重操作 num = set([1,...
false
973d55a382f5a2c127655e4f672f6b7c2743ee1c
dbms-ops/hello-Python
/1-PythonLearning/7-面向对象/7-多继承.py
1,104
4.40625
4
# coding=utf-8 # # # !/data1/Python2.7/bin/python27 # # # 多继承:表示子类继承自多个父类 # Father <<<------- Child # Mother <<<------- Child # 声明 Fahter class Father(object): def __init__(self, pocket): self.pocket = pocket def play(self): print "play son" def func(self): print "func" # ...
false
e0bca1e1bf571a39dad643ccd0485b6be44fa473
ZamoraAlexey/hillel_lessons
/lesson7.py
1,123
4.1875
4
def calculate_of_numbers(): first_number = int(input('Enter your first number: ')) second_number = int(input('Enter your second number: ')) choice_function = input('Choice your function (+, -, /, //, *, **, %): ') if choice_function == '+': print(f'{first_number} + {second_number} =', first_nu...
false
9ea111f75ba5c9ceb956b78c3ac9f70fdf69540d
tachyonlabs/raspberry_pi_pyladies_presentation
/hello_world_blink.py
1,566
4.28125
4
# See https://github.com/tachyonlabs/raspberry_pi_pyladies_presentation # for information on the wiring and the presentation in general # The Rpi.GPIO library makes it easy for your programs to read from and write to # the Raspberry Pi's GPIO (General Purpose Input/Output) pins import RPi.GPIO as GPIO import time # G...
true
f4a1d0b9f4725cbb845088e97bf460d1931dc301
mdeakyne/IT150
/Blank Class Activities/0119Blank.py
2,694
4.90625
5
""" This assignment is worth 10 points and you should be able to answer the following questions after completing it: What is the difference between a variable and a literal? How do you assign variables in python? How do you deal with errors in python? What are different types of python variables? How do you make a mult...
true
5108d71e4a691970e833836e65983895f2325fb5
shubhangisiddhapure/DSA_hypervergeq
/step 5/interunion.py
777
4.25
4
# Find the union and intersection of two sorted arrays. def union(list1,list2,len1,len2): union1=[] for i in range(len1): if list1[i] not in union1: union1.append(list1[i]) for j in range(len2): if list2[j] not in union1: union1.append(list2[j]) print(union1) def...
false
f5e89265b44ab3fc30230ea0a692a23fd91d30b9
shubhangisiddhapure/DSA_hypervergeq
/step 5/leftshift.py
598
4.125
4
def leftshift(arr1,m,n): dictionary={} for i in range(m): key=m+i-n if key < m: dictionary[key]=arr1[i] elif key>=m: dictionary[key-m]=arr1[i] len2=len(dictionary) for j in range(m): arr1[j]=dictionary[j] return print("left shift ",arr1) ...
false
8b0222d0314beb0a3ceb76d601ff1dd7803b8834
jazywica/Computing
/_01_Interactive_Programming_1/_01_Rock-paper-scissors-lizard-Spock.py
2,086
4.3125
4
""" ROCK-PAPER-SCISSORS-LIZARD-SPOCK - simple game: player vs random computer choice """ # use following link to test the program in 'codeskulptor': http://www.codeskulptor.org/#user45_uPVHROOe6b_2.py # The key idea of this program is to equate the strings "rock", "paper", "scissors", "lizard", "Spock" to numbers a...
true
6658a147827c0582c57c8c2cfb644a1342ef51ef
arnaudmiribel/streamlit-extras
/src/streamlit_extras/word_importances/__init__.py
2,050
4.15625
4
from typing import List import streamlit as st from .. import extra @extra def format_word_importances(words: List[str], importances: List[float]) -> str: """Adds a background color to each word based on its importance (float from -1 to 1) Args: words (list): List of words importances (list...
true
d9760fcbe2c615552887a271c707beb0bc7018b3
sonyarpita/ptrain
/function_recursive.py
260
4.53125
5
def calc_factorial(x): """This is recursive function to find the factorial of an integer""" # return(x*calc_factorial(x-1)) if x == 1: return 1 else: return (x*calc_factorial(x-1)) num=5 fact=calc_factorial(num) print("Factorial of",num,"=",fact)
true
662ed97b3d686b28c2345a53425b37ffd871055d
sonyarpita/ptrain
/ReModule/Metacharacters/alternation.py
222
4.34375
4
import re str = "The stays rain in Spain maui falls mainly in the plain!" #Check if the string contains "falls" or "stays" x=re.findall("falls|stays",str) print(x) if (x): print("match") else: print("No Match")
true
8f167f28002b91f926c295843a0131fa194c04b9
sonyarpita/ptrain
/Advanced_Functions/unzip_1.py
570
4.25
4
#Python code to demonstrate zip() #initialize lists name=["Sony","Arpita", "Das","Susmita"] roll_no=[4,3,6,7] marks=[90,98,89,99] #using zip() to map values mapped=zip(name,roll_no,marks) #converting values to print as set mapped=list(mapped) #printing result values print("Zipped result is: ",end=" ") print(mapped) pri...
true
f63386a5b3cb3c829f318691f3e87fb878d4a56a
sonyarpita/ptrain
/ReModule/Metacharacters/Period.py
235
4.125
4
import re str = "hello world helo" # search for a sequence that starts with "he", followed by two (any)characters, and an "o" x=re.findall("he..o", str) print(x) x=re.findall("he...o", str) print(x) x=re.findall("he.o", str) print(x)
true
3a9d2e9ddcb4ded42e2df4130db0cb1b87e5cf35
sonyarpita/ptrain
/Advanced_Functions/zip_1.py
317
4.28125
4
#Python code to demonstrate zip() #initialize lists name=["Sony","Arpita", "Das","Susmita"] roll_no=[4,3,6,7] marks=[90,98,89,99] #using zip() to map values mapped=zip(name,roll_no,marks) #converting values to print as set mapped=list(mapped) #printing result values print("Zipped result is: ",end=" ") print(mapped)
true
4a709ced79a10b6617a2250456839a61b374f3c8
bezzzon/python-basics
/home_work1/task5.py
1,370
4.125
4
""" - Запросите у пользователя значения выручки и издержек фирмы. - Определите, с каким финансовым результатом работает фирма (прибыль — выручка больше издержек, или убыток — издержки больше выручки). - Выведите соответствующее сообщение. - Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношение...
false
1d406ac301ee070563197fb69a6f7d9c7702b6f5
bezzzon/python-basics
/home_work5/task3.py
956
4.21875
4
""" Создать текстовый файл (не программно), построчно записать фамилии сотрудников и величину их окладов. Определить, кто из сотрудников имеет оклад менее 20 тыс., вывести фамилии этих сотрудников. Выполнить подсчет средней величины дохода сотрудников. """ threshold_amount = 20000 def get_salary(record): return ...
false
fa584d09f53a69bc362b3c614455df709e181ed4
bezzzon/python-basics
/home_work2/task2.py
1,953
4.34375
4
""" Для списка реализовать обмен значений соседних элементов, т.е. Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д. При нечетном количестве элементов последний сохранить на своем месте. Для заполнения списка элементов необходимо использовать функцию input(). """ arr = [] while True: el = input('Pl...
false
4398675df657c5a010f5af7f2400a99a29086809
olijng7/PersonalPracticeVS
/Hangman/Hangman.py
693
4.15625
4
print("Welcome to hangman! V") print('-----------------------') import getpass word = getpass.getpass("What's the word? ") for character in word: answer = word print('_ ', end='') print("") print("Ok, let's go!") print('-------') print('| |') print('|') print('|') print('|') print('|') print('-------') d...
false
bb699c692c649f5a3a6a2a5df0a2ff6b598eb0f2
dubirajara/learning_python
/add_length.py
274
4.125
4
''' write a function that takes a String and returns an list with the length of each word added to each element. ''' def add_length(words): return [f'{i} {str(len(i))}' for i in words.split()] assert add_length('carrot cake') == ['carrot 6', 'cake 4'] # testcase
true
580d495c9f7cf284d7a1bea54e695168e2d29167
WayneChen1994/Python1805
/day02/作业.py
1,182
4.125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # author:Wayne.Chen ''' 闰年: year = int(input("请输入一个年份:")) if (year % 100 != 0 and year % 4 == 0) or (year % 100 == 0 and year % 400 == 0): print(str(year) + "年是闰年") else: print(str(year) + "年不是闰年") ''' ''' 水仙花数: num = int(input("请输入一个三位数:")) a =...
false
43f7d762fc70feba4edd50dc23c8f08ea6525849
aurorazl/math
/sort/单链表排序.py
2,660
4.15625
4
# 给你链表的头结点 head ,请将其按 升序 排列并返回 排序后的链表 。 # 思想: 二分、归并排序 # 技巧:快慢指针 """ 1、判定链表中是否含有环 用两个指针,一个跑得快(每次跑两步),一个跑得慢。如果不含有环,跑得快的那个指针最终会遇到 null,说明链表不含环;如果含有环,快指针最终会超慢指针一圈,和慢指针相遇,说明链表含有环。 if (fast == slow) return true; 2.寻找链表的中点 让快指针一次前进两步,慢指针一次前进一步,当快指针到达链表尽头时,慢指针就处于链表的中间位置。 当链表的长度是奇数时,slow 恰巧停在中点位置;如果长度是偶数,slow 最终的位置是中间偏右: while...
false
66d50bc8acfe3e1a4a3997170fa10f6f00302f07
kamat-o/MasteringPython
/27_08_2019/AddTwoNumbers.py
239
4.1875
4
# get the input from user num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) #compute the addition result = num1 + num2 #print the result print ("The sum of {0} and {1} is {2}".format(num1,num2,result))
true
a65c5f2d60e78fda18111cbf5498d5855d49bfc7
hina-murdhani/python-project
/pythonProject3/demo/set.py
1,391
4.375
4
# set has no duplicate elements, mutabable set1 = set() print(set1) set1 = set("geeksforgeeks") print(set1) string = 'geeksforgeeks' set1 = set(string) print(set1) set1 = set(["geeks", "for", "geeks"]) print(set1) set1 = set(['1', '2', '3', '4']) print(set1) set1 = set([1, 2, 'geeks', 'for', 3, 3]) # add() method is u...
true
2f4b40b0b435a50c8a59dbb0d3d3eb93cb772e86
hina-murdhani/python-project
/pythonProject3/demo/array.py
1,710
4.3125
4
import array as arr # by importing array module we can generate the array a = arr.array('i', [1, 2, 3]) for i in range(0, 3): print(a[i]) a = arr.array('d', [1.3, 4.5, 6.7]) for i in range(0, 3): print(a[i]) # can add element in array using insert():- at any index ,method and append() method : at the end of ...
true
9dcd641e1b18997ab78e66fdde81c400eecfce7f
DahlitzFlorian/python-training-beginners
/code/solutions/solution_04.py
263
4.40625
4
# This is a possible solution for exercise_04.py word = input("Enter a word (possible palindrom): ") reversed_word = word[::-1] if word == reversed_word: print("Your submitted word is a palindrom.") else: print("Your submitted word is not a palindrom.")
true
1a020f32b2a6b3a72571371ca42c2534f816c579
mr-parikshith/Python
/S05Q02_MaxMinNumber.py
1,366
4.1875
4
""" S05Q02 - Ask the user to enter a number till he enters 0. Print the maximum and minimum values among all entered numbers. Print the number of single, two and three digit numbers entered. """ def print_CurrentMaxMin(Max, Min): print("Current Maximum Number is ", Max) prin...
true
1163df1cb6c0cad5800a2f74913a90e5d9bbc9d4
mr-parikshith/Python
/S08Q03_NumberAsString.py
610
4.1875
4
""" S08Q03 Ask the user to enter a number. - If the user enters a number as 5, then generate the following string : - 00001111222233334444 - If the user enters the number as 3, then generate the following string : - 001122 """ def enterNumber(): Number = int(input("Enter Number : ")) while Numbe...
true
b54cf1a931e8fa7a9da186d7934fb6e54d1ac9ca
nikitatarasenko17/homework
/Lesson_2/hw_2_task_1.py
1,278
4.21875
4
# Задача №1 # Набрать все примеры посимвольно и заставить их работать, разобраться в их работе # Оператор условия if print ("Give it to me!") number = int(input()) if (number >= 100): print ("Thanks, man!) \n") elif ((number > 10) and (number < 100)): print ("OK :( \n") else: print ("WHAAAAT????") if (nu...
false
575f17a57fbf571f6c130a71bcac51fbe3071f74
vladlemos/lets-code-python
/Aula_1/11_calculo.py
681
4.4375
4
''' Faça um programa que peça 2 números inteiros e um número real, calcule e mostre: a)o produto do dobro do primeiro com metade do segundo. b)a soma do triplo do primeiro com o terceiro. c)o terceiro elevado ao cubo. ''' primeiro_numero = int(input('digite um número inteiro: ')) segundo_numero = int(input('d...
false
4c11ef1533db7dc7f2dfebe2239878e69d9ec9c4
mattlorme/python
/coursera/list_8.4.py
823
4.34375
4
#!/usr/bin/python2.7 # 8.4 Open the file romeo.txt and read it line by line. # For each line, split the line into a list of words # using the split() function. # The program should build a list of words. # For each word on each line # check to see if the word is already in the list # and if not append it to the list. ...
true
1dfb0524838174c5f8e91741b8c8d9c8438b5164
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/4_Comprehensions/02. No Vowels.py
232
4.15625
4
def check_for_vowels(character: chr): if character.lower() in ['a', 'o', 'u', 'e', 'i']: return True return False text = input() no_vowels = [ch for ch in text if not check_for_vowels(ch)] print("".join(no_vowels))
false
b012df090d7ebf8145287d26c3e88410313fd42a
eantaev/problem-solving
/rec_to_iter/simple_method_factorial.py
1,060
4.1875
4
def factorial(n): if n < 2: return 1 return n * factorial(n - 1) # 1 Study the function. # 2 Convert all recursive calls into tail calls. (If you can’t, stop. Try another method.) # 3 Introduce a one-shot loop around the function body. # 4 Convert tail calls into continue statements. # 5 Tidy up. def...
false
21164843eccf32ab55d740847f8990ec306255de
OmniaSalah/CompilerProject
/regex.py
652
4.3125
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 4 23:00:55 2021 @author: LENOVO """ import rstr import re # ask the user to input the regular expression regex=input("Enter regex :\n") # print examples for strings that accepted print("Examples for regex :\n",rstr.xeger(regex)) # ask the user to input if he want to ...
true
ac937e2d1d61950723beddbbd3ed6f4f2d5466db
rohegde7/competitive_programming_codes
/Interview-TestPress-Reverse_of_number.py
839
4.1875
4
''' Given a number N, print reverse of number N. Note: Do not print leading zeros in output. For example N = 100 Reverse of N will be 1 not 001. Input: Input contains a single integer N. Output: Print reverse of integer N. Constraints: 1<=N<=10000 ''' number = input() #storing the numeber in string fo...
true
79cba5c7d8c031964a6648c34191448a774f373a
shenoyrahul444/CS-Fundamentals
/Trees/Flatten Binary Trees.py
1,033
4.25
4
""" Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 """ # Definition for a binary tree node. # class TreeNode: # ...
true
13a9a16ed598e6b2f79f666ad34ae0012064e9dd
ashwin-5g/LPTHW
/ex3.py
704
4.375
4
#prompt for chicken count print "I will now count my chickens:" #display hens' count print "Hens", 25 + 30 / 6 #display roosters' count print "Roosters", 100 - 25 * 3 % 4 #display eggs' count print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #comparison operation in use print "Is it true tha...
true
e5f554a4ed8abecc6aa1801f68adfdfcf3738593
xiaoyangren6514/python_imooc
/oop/test_object.py
950
4.25
4
class User(object): """ 成员变量,可以通过类名饮用,所有对象共有 如果对象修改了成员变量的值,不会影响其他对象的值 如果通过类名调用直接修改了成员变量的值,那么所有对象对应的值都发生变化,除非对象之前修改过此值 """ address = 'bj' def __init__(self, name, age, weight): self.name = name self._age = age self.__weight = weight def get_weight(self): ...
false
90012c431612c0221318d69ee94b8bed263a9736
Garvit-32/Opencv_code
/15_adaptive_thresholding.py
775
4.125
4
import cv2 as cv import numpy as np # Adaptive Thresholding algorithm provide the image in which Threshold values vary over the image as a function of local image characteristics. So Adaptive Thresholding involves two following steps # (i) Divide image into strips # (ii) Apply global threshold method to each strip...
true
a8dbc4ead47024aaae3146f4860fd8930a4f21b4
cromptonhouse/examplesPi
/hiworld.py
750
4.53125
5
# This is a comment! If we type a # we can type what we want and the computer ignores it! print "hello world" # prints words, know in code as a string - "Hello World" # We are going to learn about variables" # A variable is somewhere (memory) where we can store information" x = 6 # we have assigned the ...
true
53d6443c954e116282e4048a560cc1e0650a9df7
dannydiaz92/MIT_IntroToCS
/Pset2/ps2_hangman.py
2,974
4.375
4
# 6.00 Problem Set 3 # # Hangman # # ----------------------------------- # Helper code # (you don't need to understand this helper code) import random import string WORDLIST_FILENAME = "words.txt" def load_words(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending...
true
801f87165fd8036da1aece5348751af8a68dd685
Frootloop11/lectures
/week 10/warm_up.py
576
4.28125
4
""" Take in a file Find and return the longest line in that file print the line number and length character """ def main(): line_number, length = find_longest_line("warm_up.py") print(line_number, length) def find_longest_line(file_name): max_line_number, max_length = -1, 0 with open(file_name, 'r')...
true
a6b1d841e0a1ea165b268add0056a77c35164611
kradziko/python
/10_11/wytworniki.py
1,837
4.15625
4
# -*- coding: utf-8 -*- ''' wytworniki (list comprehensions) ''' l = range(1, 21, 2) print l # postac prosta # podwojenie wartosci print[2 * x for x in l] # para x, kwadrat x print [(x, x * x) for x in range(1, 5)] # tabela kodowa ASCII print[(x, ord(x)) for x in "ABCDEF"] # lista zawierajaca 10 pustych list prin...
false
06e6492146dc1e08ca2aa72428d72cb2c59431be
nick-lehmann/SnakeCharmerGuide
/games/ninjas.py
744
4.21875
4
""" The wall has been breached and cobras are attacking the castle 🏰 We see that there are 50 cobras approaching 🐍 Fortunately we have special ninjas that can defeat the cobras 🥷 Every ninja can defeat 3 cobras. Can we defeat all the cobras with the ninjas we have? 1. Define a variable "ninjas" and one "cobras" and...
true
78ec49439d956378c5f414bf673cc92f3c3bccda
nick-lehmann/SnakeCharmerGuide
/games/pizza.py
687
4.28125
4
""" Mario is eating a pizza. The pizza is so tasty that every time he eats a slice he wants to say "Mhhhhhh". Every time he eats a slice his hunger gets lowered by 1. If he is full, he stops eating and says "I'm full 🤤" When he is finished he says "Mamma mia! Buonissima! 😋" Say if he is still hungry after eating all ...
true
f93c3a294a435212eceb18e67c5e7c5f86a7e403
nick-lehmann/SnakeCharmerGuide
/games/rock_paper_scissors.py
1,841
4.40625
4
""" You want to play rock-paper-scissors against the computer. 1. Define a dictionary for each player that stores its name and current score. 2. Ask the player about his or her name and ask how many round should be played. 3. Each round, ask the player for his or her choice. The computer should pick a random choice. 4...
true
88d46bf4694d95c6f9e62726f88cc21871ccbea6
Greensahil/CS697
/Playground/listAndTuples.py
2,067
4.4375
4
#sequence an object that contains multiple items of data #list is mutable can be changed in place in memory #tuple cannot be modified unless you are reassigining to a different place in memory list = [1,2] print(list) #list is similar to array list in java #list is dynamic and we can change the size #list can be h...
true
8401ef69843234d30758eecc923f15296cc9b1a3
Greensahil/CS697
/Playground/passwordchecker.py
757
4.3125
4
password = input("Enter a string for password:") validPassword = True #A password must have at least eight characters. if len(password) < 8: validPassword = False #A password consists of only letters and digits if not password.isalnum(): validPassword = False #A password must contain at least two digits #A p...
true
5a9cae303fbc660ac7566063f5593a78c263dabf
half-rice/daily_programmer
/easy_challenge_1.py
699
4.21875
4
# create a program that will ask the users name, age, and username. have it # tell them the information back, in the format: # your name is (blank), you are (blank) years old, and your username is (blank) # for extra credit, have the program log this information in a file to be # accessed later. file = open("easy_ch...
true