blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
133cae86497cf23f3b6c68beb291b0840b269b23
rickbr6/dojo
/python_stack/python/radix_sort.py
2,227
4.28125
4
def get_digit(num, place): """ :param num: A single or multi digit number :param place: A number representing the place value of the number to return. i.e, 1 would represent the ones position and 2 would represent the 10s position :return: the number in the position requested with the place par...
true
74351ecf55a4f7c986f556f42856455dc8ec7808
niktechnopro/linux101
/algorithm2.py
750
4.125
4
#Fibonacci #make the fib function which returns the value of the fib number if you put an argument in it def fib(position): if(position ==0 or position ==1): return 1; else: return fib(position-2) + fib(position-1); #loop through the fib function to find the sum from 1 to when sum of fib number...
true
46660183744daeeed73374ab15d4a671be887753
dpdahal/python7pm
/function.py
2,420
4.125
4
# A function is a block of code that only runes when it is called # Types of function: # 1. Inbuilt function: print(), len(),int() # 2. User define function or custom function # define function # def course(): # # function body part # print("Online python class") # # # # calling # course() # def add(x, y): # ...
true
cc437d93c07cdf8eafe3f66fd46d19cd401367a5
Athul-R/ds-algo
/python_code/arrays/array.py
1,528
4.28125
4
""" This file has the array implemention using Python Class. """ class ArrayWithDict(object): """ This is the array implementation with data as the Dict Object """ def __init__(self, arg): self.data = {} self.length = 0 def get(self, index): return self.data.get(index) def push(self, item): self.da...
true
128dd012fb956d2aaa29b4c962020e7e96da43cd
ghills3620/csce093
/python/03PyBasicOperators.py
1,898
4.4375
4
#Basic Operators #http://www.learnpython.org/en/Basic_Operators #Just as any other programming languages, the addition, subtraction, # multiplication, and division operators can be used with numbers. number = 1 + 2 * 3 / 4.0 print( number ) #Another operator available is the modulo (%) operator, # which retu...
true
5eac0415e9ab36961d78765856320e6f91b41754
gyratory/NPTfP3
/12 - Boolean Expressions/exercise01.py
486
4.21875
4
# Write a program that has a user guess your name, but they only get 3 # chances to do so until the program quits. print("=========") print("You will now try to guess my name!\nYou have 3 tries.") print("=========") attempt = 0 while attempt != 3: attempt += 1 guess = input("Take a guess: ") if guess == "g...
true
143b9e148598f400c67f35b97ee68489364980e1
zf2169/Pythons
/primefactors.py
920
4.15625
4
# -*- coding: utf-8 -*- """ @title: Prime Factorization @function: Enter a number and find all Prime Factors (if there are any) and display them @author: Zhilin """ def findprime(n): ''' find all the prime numbers smaller than n ''' num= list(range(2,n+1)) pnum= list() while True: a= nu...
true
bdf5689c233e9206f60057dcdff2e4c8ff06903c
duybui2905/C4T-13
/session5/season.py
279
4.375
4
month = int(input("Insert month: ")) if month <= 3 and month > 0: print("this is winter") elif month <= 6: print("this is spring") elif month <= 9: print("this is summer") elif month <= 12: print("this is fall") else: print("THIS IS NOT A MONTH !!!!!!!")
true
80eb6d3e3ee146c3fd8026058a25f1637f7e031c
duybui2905/C4T-13
/session10/read_dict.py
220
4.21875
4
person = { "name" : "Felix", "nickname" : "Pewdiepie", "job" : "youtuber", } print(person) # print(person["name"]) key_of_value = input("enter the key of value you wanna find: ") print(person[key_of_value])
false
1fadb4adbdb5e74712ef45c9ef8bb9f321073a11
vaishnavisaindane/Hacktoberfest2021-4
/Scripts/smallest_and_largest_of_n_different_numbers.py
353
4.3125
4
#python program to display smallest and largest of n different numbers n=int(input("Enter a limit")) m=int(input("Enter first number")) min=m max=m print("Enter next",n-1,"numbers") for i in range(2,n+1): m=int(input()) if m>max: max=m elif m<min: min=m print("\nlargest number is",max) ...
true
3741df1d5e4b3388d4134057edc43889e6a16886
danielrincon-m/AYED
/Arenas/Arena 1/11220 - Decoding the message.py
1,735
4.125
4
# Algoritmo: # 1. Leer la entrada, una lista de oraciones en donde cada oración es una lista de palabras. # 2. Para cada lista de oraciones, definir una variable para la posición de letra, una lista de palabras de salida y una variable para la palabra de salida, recorrer la lista. # 2.1. Verificar si la posición d...
false
800801cbdeb294ab5d70f3f6e5a625d8f377343f
chimaihueze/EDD-calculator
/EDD 2.py
1,223
4.21875
4
""" This promgram computes the Expected Date of Delivery (EDD) when a user enters the date of their Last Menstrual Period (LMP). """ from datetime import timedelta, date try: #getting LMP from the user lmp = input("Enter the date of your last period in DD-MM-YYYY format: ") lst = lmp.split("-...
true
394ca88761791dcf488c19a06d0a85c424c28f46
rup3sh/leetcode
/src/101_symmetricTree
766
4.25
4
#!/bin/python3 #101. Symmetric Tree class TreeNode: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isSymmetric(self, root): def _isSym(l,r): if not l and not r: return True if l and r and l.val==r.val and _isS...
false
24953a25857a31fb6d41955aa7d0e8774bfb5235
CristofferJakobsson/sepm-team-a
/src/user_interface/centeredtext.py
1,770
4.125
4
class centeredtext(object): """ centeredtext extends the object class and centers text within an object """ def __init__(self, text, x,y,w,h, pygame, fontsize, color=(0,0,0)): """ Construct a new centeredtext object. :param self: A reference to the centeredtext object itself :param text: The te...
true
1d280bcb97fb37bd9f3e77a8e9031a2d59226277
Stephanie-Spears/LC101-Complete
/Unit1/aFraction.py
1,523
4.15625
4
#helper function--a function outside a class that is used by a method #A mutator method -- a method with no return which modifies the object itself def gcd(m, n): while m % n != 0: oldm = m oldn = n m = oldn n = oldm % oldn return n class aFraction: def __init__(self, num, ...
false
011964435a3b4ba0046bebb406f45eababcf886f
Stephanie-Spears/LC101-Complete
/Unit1/Crypto/caesar.py
1,010
4.21875
4
"""caesar shift module""" from helpers import rotate_character, validate #, alphabet_position def encrypt(text, rot): """shift string rot positions""" new_text = "" for char in text: new_text += rotate_character(char, rot) return new_text def main(): """encapsuate execution main""" fro...
true
911bf7bae8aefb880ffa09b7268665f002bb2fa8
Ainnop/PYTHON-LEARNING
/nested_function.py
425
4.1875
4
def outer_function(x): """ enclosing function """ def inner_function(): """ nested function """ # nonlocal x x = 5 print("The x value inside inner function is: {}".format(x)) x_local = x * 2 print("The x local value inside inner function is {}...
true
b10d6dff6edd5f5e8da586f0a7ad4b51bb1b8c05
patterson-dtaylor/100_Days_Of_Python
/Day_10/calculator.py
1,842
4.3125
4
calculator_power = True first_calculation = True total = 0 def add(num1, num2): return num1 + num2 def subtract(num1, num2): return num1 - num2 def multiply(num1, num2): return num1 * num2 def divide(num1, num2): return num1 / num2 def calculator(function=None, num1=0, num2=0): if function == "...
true
58f684be09fc2c363841b1f2696cdb472de70121
Sheldonan2142/backup
/practice3.py
411
4.375
4
day = input("hey what day of the week is it? im mega lost ") if day == "Monday" or day == "monday": print("ah the weekend is over; it's monday") if day == "Friday" or day == "friday": print("friday !! the weekend is close friends") if day == "Saturday" or day == "saturday" or day == "Sunday" or day == "sunday"...
true
25faa2b23248280b65d4924bfce16e8ed4559e5f
Sheldonan2142/backup
/list.py
1,300
4.40625
4
# how to make a list favMovies = ["Dora the Explorer", "The Emoji Movie", "High School Musical"] # print the whole list print(favMovies) # print individuals print(favMovies[2]) # to add you can append or insert # append adds to the end favMovies.append("High School Musical 2") print(favMovies) # insert will...
true
3078b5dae76dd8e48600fca851c334639314d919
irandjelovic/data-parser
/string_parser/remove_adjacent_same_letters.py
2,124
4.21875
4
#!/usr/bin/env python ''' Simple string parser module with function(s): - Remove adjacent pairs of same letters for an input string ''' # standard lib import argparse arg_parser = argparse.ArgumentParser(description="Argument parser") arg_parser.add_argument('-i', dest="input", help="Input string") ...
true
781a2697af4973290bf7e988189430de4616a97d
KuldipSharma/hacktober2020
/fizzBuzz.py
270
4.15625
4
def fizzbuzz(number): if(number%3 == 0 and number%5 == 0): print("fizzbuzz") elif(number%3 == 0): print("fizz") elif(number%5 == 0): print("buzz") else: print(number) number = int(input("Enter Number: ")) fizzbuzz(number)
false
569fe91d22e2487d6db5136ff8a5fde2e829ff16
hu22333/git
/python learn/应用基础/Python入门/week_L2/ex3.py
1,209
4.40625
4
# 分支循环操作小练习 if 0: print("Hello") if 1: print("hello") if "": print("Hello") if []: print("Hello") if {}: print("Hello") if "Not Empty": print("Hello") if [10, "101"]: print("hello") if True: print("Hello") if False: print("Hello") if 0 == 1: print("hello") a = 10 if a > 10 or ...
false
951b5cfbb9d28aa1547c077ddac0b0d5fcfd146b
Jiaweihu08/EPI
/4 - Primitive types/4.0 - count_bits.py
567
4.1875
4
def count_bits_naive(x): """ x is a 64-bits integer, so the number of iterations here is 64. for each bit from the right, we check if it's 1 and then remove it. """ num_bits = 0 while x: num_bits += x & 1 x >>= 1 return num_bits def count_bits_wegner(x): """ x & (x - 1) returns x with its last set bit...
true
7bed948376991aa597310ec4fd65fefae91a431c
Jiaweihu08/EPI
/9 - Binary Trees/9.10 - inorder_traversal_no_recursion_with_parent_field.py
511
4.1875
4
""" Implement inorder traversal for binary trees without using recursion. Hint: Analize cases depending on what the previous node is. """ def inorder_traversal(tree): prev, results = None, [] while tree: if prev is tree.parent: if tree.left: next = tree.left else: results.append(tree.data) next =...
true
4eab229f75cc28e91230150e4525b5e9bd567471
Jiaweihu08/EPI
/12 - Hash Tables/12.3 - ISBN_cache.py
2,681
4.40625
4
""" Create a cache for looking up prices of books identified by their ISBN. Implement lookup, insert, and erase methods. Use the LRU policy for cache eviction - If the number of books exceeds the capacity of the cache when inserting a new book, replace the oldest operated book with the new one Use a hash table to stor...
true
f8ce17590dcc54d24997126e3c75d39a732fc8ea
Jiaweihu08/EPI
/7 - Linked Lists/7.12 - is_palindromic_list.py
1,873
4.3125
4
""" Given a singly linked list, test is the data stored in the list for a palindrom """ class Node: def __init__(self, data=0, next_=None): self.data = data self.next = next_ def __repr__(self): return f'Node: {self.data}' def build_list(l): L = [Node(l[0])] for i in range(1, len(l)): L.append(Node(l[i])...
true
4e76efbcb5bba05f25fe376b11ee5b94ea7a2535
Jiaweihu08/EPI
/9 - Binary Trees/9.2 - is_symmetric.py
540
4.3125
4
""" Check if a given binary tree is symmetric. If we draw a vertical line through the root node, is the left tree the mirror image of the right tree? """ def is_symmetric(tree): def check_symmetric(subtree_0, subtree_1): if not subtree_0 and not subtree_1: return True elif subtree_1 and subtree_1: return (su...
true
2be38ddf8b258931a9052e73c74e2f983de93ef5
prince5609/Implementation_DataStructure
/Bubble_Sort.py
413
4.125
4
def bubble_sort(array): n = len(array) - 1 for j in range(n): swapped = False for i in range(n - j): if array[i] > array[i + 1]: temp = array[i] array[i] = array[i + 1] array[i + 1] = temp swapped = True if not s...
false
feea036966d71a2225f6c8510207b95c8d3a10e4
DevBveasey/Code
/Python/extra/functions practice.py
265
4.25
4
#Brandon Veasey def sqrMe(num1): print("the number squared is", num1 * num1) num1 = int(input('Enter a number to be squared:(negative number to end) ')) while (num1 > 0): sqrMe(num1) num1 = int(input('Enter a number to be squared: (negative number to end)'))
false
94a22acddb2b2197e8949ae301af4f0330156cb9
wonju5332/source
/PythonClass/Chap_11_oBject_cLass/6_1_overriding.py
512
4.25
4
""" Overriding :짓밟다. 무효로 하다. ~에 우선하다. :부모 클래스로부터 상속받은 메소드를 다시 정의하다 """ class grandfather: def __init__(self): print("튼튼한 두 다리") class father2(grandfather): def __init__(self): super().__init__() print("지혜") father1 = father2() #지혜만 출력되게 된다. 즉, 오버라이드 되었기 때문이다. 할아버지의 튼튼한 두 다리도 물려받고 싶...
false
b38e80672246acac1f15ecbd209edde5980e1be1
aml-spring-19/homework-1-nanshanli
/task1/task12.py
420
4.125
4
"""Spring 2019 COMSW 4995: Applied Machine Learning. UNI: nl2643 Homework 1 Task 1.2 Contains function that computes fibonacci sequence """ def fib(n): """Find fibonacci sequence for a given value n.""" prev = 1 curr = 1 if n == 1: return 1 elif n == 2: return 1 for i in r...
true
2fa075710a19cd2db6c9704d6733665b9f568a19
wajdm/ICS3UR-2-05-Python
/global_variables.py
886
4.4375
4
#!/usr/bin/env python 3 # Created by: Wajd Mariam # Created on: Sept 2019 # This program shows how local and global variables works # global variable variable_X = 25 def local_variable(): # This variable shows what's happening with local_variable variable_X = 10 variable_Y = 30 variable_A = variabl...
true
5d66d36221fa71d445d5e9baf2968441591020a5
FBecerra2/MachineLearning-Data
/python/python recetas/5 receta - Objetos/13-Iterar-un-dataframe.py
434
4.28125
4
#Iterar un DataFrame import pandas as pd import numpy as np datos = {'col1':[1,2,3], 'col2':[4,5,6], 'col3':[7,8,9]} df = pd.DataFrame(data=datos) # iteracion por columnas for columna in df: #obtener columnas de un DataFrame print(columna) for columna in df: #ver columnas y sus datos print(df[columna]) #I...
false
cbee5a85ad921f68d1e925cf70cec15eb0afb788
Aarom5/python-newbie
/dictionary.py
275
4.28125
4
classmates={'Tony':' cool but smells','Zack':' Sits at the front','Lucy': ' Weird'} # creates a set with key and values print(classmates) print(classmates['Zack']) # info about specific object for k,v in classmates.items():# iterates through every item print(k+v)
true
b49e59a06330afe5676d7a172b232948700d6b7b
YannisSchmutz/PythonTipsAndTricks
/generators/compute1.py
981
4.1875
4
""" Just the fundamental principe. """ from time import sleep # Bad example def compute(): """ We would have to wait for the whole list, even though we might just need the first few element of it. - takes a lot of time (for the first element being returned) - needs much more memory than using an it...
true
b5ed67afcf55f697d277aa0f714bf6ee7f091d12
sarathrajkottamthodiyil/python
/Practise/list1.py
299
4.125
4
numbers = [] strings = [] names = ["sarath", "ajay", "arun"] numbers.append(1) numbers.append(2) numbers.append(3) strings.append("hello") strings.append("friends") second_name = names[1] print(numbers) print(strings) print("the second name on the name list is !! %s !!" % second_name)
true
7a7728a8c8b413ec8fcd0225b47bef6a6b40d61e
Khalu/ROT135_decoder
/rot13.py
1,506
4.3125
4
import string def shift_digit(digit): """Shifts the number 5 positions forward or if the sum is over 9, 5 positions backward""" if int(digit) + 5 > 9: return(str(int(digit) - 5)) else: return(str(int(digit) + 5)) def shift_letter(letter): """this shifts the letter 13 positions forward...
false
5fb2dfa1d6d4d29f761d1e1593f0c5aa3b5de8d5
RawandKurdy/snippets
/5_functions/function.py
600
4.3125
4
# Functions in Python # 1- Traditional function # also used to demonstrate how an anonymous func can be useful # It runs a function passed as a param then prints its result def traditionalFunc(anotherFunc): text_with_duplicates = anotherFunc("NYC!", 3) print(text_with_duplicates) # 2- Anonymous Function # I ...
true
2f382b4e09e87038478b6fe8f6de67f0ddc50c0c
bcongdon/leetcode
/200-299/232-implement-queue-with-stacks.py
1,164
4.28125
4
class Queue(object): def swap(self): while self.inStack: self.outStack.append(self.inStack.pop()) def __init__(self): """ initialize your data structure here. """ self.inStack = list() self.outStack = list() def push(self, x): """ ...
false
a6d6943be5220151308566d706edaf7a2e7e23ed
zcesur/algo
/tree_diam.py
2,727
4.3125
4
#!/usr/bin/env python # A script that finds the diameter of a tree, which is defined as the # maximum length of a shortest path. It runs in O(n+m) time, i.e., in # time linear in the number of vertices and edges, which is equivalent # to O(n) for trees. # # The main idea used in the algorithm is that the longest path ...
true
c6ee234dcb13924182c3c0691b125481233bd68d
bliutwo/bliutwo_project_euler
/DigitFactorials/digitfactorials.py
1,182
4.375
4
# Filename: digitfactorials.py # Description: https://projecteuler.net/problem=34 def factorial(num): total = 1 while num > 0: total *= num num -= 1 return total def lengthOfNum(num): string = str(num) return len(string) def sumOfFactorialOfDigits(num): total = 0 string = str(num) for char in string: d...
true
0abfa75272a8d4c9f57030830718f4cd8b54ca91
angelaTv/Luminar-Python
/languagefundamentals/functions/function basics.py
476
4.125
4
#cube of a number # def cub(): # n= int(input("enter number")) # res=n**3 # print(res) # cub() #is even or not # def isevenodd(): # # if(n%2!=0): # print("even") # else: # print("odd") # isevenodd(21) #fibonocii series up to nth term def fibonocii(): n1=0 n2=1 count=0 te...
false
12dcf665f4e0edf0299a3254854ce72d5d7ae9b6
briwyatt/MITcomputerScience101
/lecture03/lecture03.py
1,261
4.15625
4
# find the square root of a perfect square # x = 16 # ans = 0 #counter variable # while ans*ans <= x: # ans = ans + 1 # print(ans) # Is the number Even or Odd? # # if (x/2)*2 == x: # print("Even") # else: # print("Odd") # x = 150 #the number we are testing in this case # ans = 0 #counter variable...
true
5842de32ce5fc0fba622d0d07b63eea91cd7471f
Panmax/codewars-python
/look_and_say.py
1,524
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: 'Panmax' """ There exists a sequence of numbers that follows the pattern 1 11 21 1211 111221 312211 13112221 1113213211 . . . Starting with "1" the following lines are ...
true
7b2e29ff849736e653137cc107b14d8eb58bc9bb
hwei-cs/leetcode-training
/solutions/greedy/solution123.py
1,126
4.25
4
""" 给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你最多可以完成两笔交易。 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 """ from typing import List class Solution: def maxProfit(self, prices: List[int]) -> int: buy1 = prices[0] buy2 = prices[0] profit1 = 0 profit2 = 0 for price in price...
false
1a955c47291f3a2c6e22549649a25957c431c2f4
naray89k/Python
/DeepDive_1/4_Numeric_Types/Comparison_Operators.py
1,584
4.34375
4
#!/usr/bin/env python # coding: utf-8 # ### Comparison Operators # #### Identity and Membership Operators # The **is** and **is not** operators will work with any data type since they are comparing the memory addresses of the objects (which are integers) 0.1 is (3+4j) 'a' is [1, 2, 3] # The **in** and **not in** ope...
true
457e4e90bda9e53e8554ca1064e184f4d4e4b841
naray89k/Python
/DeepDive_1/4_Numeric_Types/Floats_Equality_Testing.py
2,478
4.3125
4
#!/usr/bin/env python # coding: utf-8 # ## Floats - Equality Testing # Because not all real numbers have an exact ``float`` representation, equality testing can be tricky. x = 0.1 + 0.1 + 0.1 y = 0.3 x == y # This is because ``0.1`` and ``0.3`` do not have exact representations: print('0.1 --> {0:.25f}'.format(0.1)...
true
fd9e35d12f169d1abb5a971360db723c511f390f
naray89k/Python
/DeepDive_1/4_Numeric_Types/Booleans_Boolean_Operators.py
1,833
4.375
4
#!/usr/bin/env python # coding: utf-8 # ### Booleans: Boolean Operators # The way the Boolean operators ``and``, ``or`` actually work is a littel different in Python: # #### or # ``X or Y``: If X is falsy, returns Y, otherwise evaluates and returns X '' or 'abc' 0 or 100 [] or [1, 2, 3] [1, 2] or [1, 2, 3] # You sh...
true
121a2e796782216cde5bc857209565ce5e79738d
naray89k/Python
/DeepDive_1/2_A_Quick_Refresher_Basics_Review/Break_Continue_and_Try_Statements.py
2,400
4.28125
4
#!/usr/bin/env python # coding: utf-8 # ### Loop Break and Continue inside a Try...Except...Finally # Recall that in a ``try`` statement, the ``finally`` clause always runs: a = 10 b = 1 try: a / b except ZeroDivisionError: print('division by 0') finally: print('this always executes') # ----------------- ...
true
4332748d486b75a1b82e17d59a71e6fdfb89bf02
naray89k/Python
/OOPS_Concepts/cls_VarsEx.py
1,188
4.21875
4
#! /usr/bin/python #class Employee Starts Here class Employee(object): num_of_emps = 0 raise_amount = 1.04 #constructor def __init__(self,first,second,pay): self.first = first self.second = second self.pay = pay self.email = '{}.{}@company.com'.format(self.first.lower(),...
false
a8cd1fc49ca32a6a798216109975e0f68c8a4e25
jatiinyadav/Python
/Class/Abstract.py
957
4.1875
4
# Abstract class # Abstract Method, in a method where we have nothing in the method and we use pass from abc import ABC, abstractmethod class Computer(ABC): @abstractmethod def process(self): pass class Laptop(Computer): def process(self): print("Its running: ") class Programmer: ...
true
59fa82d39490e6c10e8fc7a9b0c1ee04ef1838f2
KevinFTD/python_presentation
/exmaples/example8_cls_field.py
371
4.125
4
#!/usr/bin/env python2.7 #encoding=utf-8 ''' Created on 2015年4月7日 @author: kevinftd ''' class MyClass(object): key1 = 10 key2 = [] def __init__(self): ''' Constructor ''' self.key1 = 20 self.key2.append(30) instance = MyClass() print instance.key1 print MyClass....
true
e71d5f773f5f8236534832b40d2ddca0ad1b412b
KevinFTD/python_presentation
/exmaples/example_new_init.py
740
4.28125
4
#!/usr/bin/env python2.7 #encoding=utf-8 ''' Created on 2015年3月23日 @author: kevinftd __new__创建类实例,__init__做初始化 ''' class base(object): def __init__(self, arg="base"): self.str = arg def __str__(self): return self.str class strings(base): def __init__(self, arg=""): base.__init__(...
true
9cee8bf4cf6ad3288a806267e0db89fd027533dc
Phillip215/digitalcrafts
/week1/day3/calculator.py
488
4.125
4
calc = int(input("I'm just your everyday calculator put in a number ")) opp = input("Now put in a operand please ") calc2 = int(input("Now the other number ")) # Subtract if opp == "-": ans = calc - calc2 print("Your answer is %s" % (ans)) # Multiply if opp == "*": wer = calc * calc2 print("Your answer is %s"...
false
eb375ea245384001f96c4f74b6da6e266f97477a
Phillip215/digitalcrafts
/week1/day3/inputPython.py
1,255
4.25
4
# name_of_user = input("What is your name?") nameOfUser = input("What is your first name?") # Store the users first name into a number value that we can use lengthOfUserName = len(nameOfUser) # While loop # A condition has to be true to keep your loop running while (lengthOfUserName < 1): nameOfUser = input("What is...
true
9574c844cad27b40ae97235b8ce79510c9f814b8
Hadirback/python
/Lesson9_Lists/main.py
503
4.21875
4
# Пустой список empty_list = [] friends = ['Max', 'Leo', 'Kate'] # тип данных print(type(friends)) print(friends[1]) # С конца print(friends[-1]) # срезы print(friends[1:3]) print(friends[:2]) print(friends[1:]) print(len(friends)) friends.append('Ron') friend = friends.pop(3) print(friend) friends.remove('Leo') p...
false
3fd11843ed03b30a3a694dd9508262418fa645f3
nagask/python-essentials
/basic_collections/lists/sorting.py
1,890
4.25
4
import operator # Sort a List Alphabetically my_list = ['mango', 'apple', 'pear', 'orange'] my_list.sort() for item in my_list: print (item) """ Outputs: apple mango orange pear """ # Return a Copy of a List, Sorted Alphabetically my_list = ['mango', 'apple', 'pear', 'orange'] my_sorted_list = sor...
true
94790c09de2d538a75765223a3db2f7d6e98fad8
nagask/python-essentials
/advanced_collections/defaultdict.py
1,672
4.4375
4
""" The collections module has a handy tool called defaultdict. The defaultdict is a subclass of Python’s dict that accepts a default_factory as its primary argument. The default_factory is usually a Python type, such as int or list, but you can also use a function or a lambda too. It’s basically impossible to cause a...
true
c4f40fb2866513f5e3fa663147cf4f6e17d317f0
nancymukuiya14/Password-Locker
/user_test.py
1,458
4.21875
4
import unittest from user import User class TestClass(unittest.TestCase): """ A Test class that defines test cases for the User class. Args: unittest.TestCase: TestCase class that helps in creating test cases """ def setUp(self): """ Method that runs before eac...
true
dc038c84242c9fc216880224a46dfc8f38a81607
sxlongwork/pythonPro
/列表-字符串/str4.py
455
4.125
4
# str的切片,倒序 str1 = "abcdefg" # 切片 print(str1[2:5]) # cde print(str1[0:2]) # ab print(str1[0:-1]) # abcdef print(str1[2:-2]) # cde print(str1[:]) # abcdefg print(str1[:3]) # abc print(str1[3:]) # defg print(str1[1:5:2]) # bd print(str1[:3:-1]) # gfe print(str...
false
ec21e14cb1657634773d982f6f64c3b6ecd5a5be
sxlongwork/pythonPro
/列表-字符串/str_practice4.py
548
4.21875
4
# 字符串的常见操作 str1 = "abcdefg" # 字符串的长度 str1.__len__() len(str1) # 固定10个字符,不够的补* str1.center(10, '*') # 一共10个字符,str1居中,不够位补"*" str1.ljust(10, '*') # 一共10个字符,str1居左,不够位补"*" str1.rjust(10, '*') # 一共10个字符,str1居右,不够位补"*" # 判断字符串是否以"xxx"结尾或开头,"xxx"表示任务字符串 str1.startswith("abc") str1.endswith("bbc") # 判断字符'a'在字符串...
false
75de2db9f2329d1b80d8321495e658f8d56e017c
sxlongwork/pythonPro
/if-for-while/for_practice2.py
250
4.28125
4
# for与range 使用 for i in range(3): print(i, end=" ") print() for i in range(1, 5): print(i, end=" ") print() for i in range(3, 10): print(i, end=" ") print() # help(range) for i in range(100, 0, -2): print(i, end=" ") print()
false
ac01d9f5773e53964b0e28aec3bafdf1a3a33860
sxlongwork/pythonPro
/if-for-while/tuple.py
1,925
4.375
4
# tuple 使用 # 元组tuple一旦定义,就不能改变,这里的不能改变指的是指向不变改变 classmates = ("zhangsan", "lisi", "wangwu", "xiaoming") print(len(classmates)) print(classmates) for i in range(len(classmates)): print(classmates[i]) # 在定义tuple时,元素就必须确定下来 aa = (1, "ok") # aa[0] = 2 tuple元素不能修改 print(aa) # 在定义只有一个元素的tuple时,注意要在第一个元素后加上",",aa=(2,)...
false
64ec88ce1f194a7fc7d630deedd6208f10be0482
teganbroderick/Calculator2
/calculator.py
1,929
4.25
4
"""A prefix-notation calculator.""" from arithmetic import * def greet_player(): """greets player""" print("Hi Player! Welcome to the calculator.") def turn_str_into_int(l): """takes list and turns string numbers into integers""" operator_list = ["+", "-", "*", "/", "**", "squares", "cubes", "pows", ...
true
9156f4bdcf549e4820910cacc8b25ddf53068652
vennie1988/python_ref_code
/lambda.py
680
4.34375
4
""" lambdas: lambda expressions (sometimes is called lambda forms) are used to create anonymous functions. The expression lambda arguments: expression yields a function object. The unnamed object behaves like a function object defined with the following. """ lambda_expr ::= "lambda" [parameter_list]: expression lambda...
true
475bded227f8ec6730ecececc165173b0e98bdf0
HKang42/Sprint-Challenge--Data-Structures-Python
/reverse/reverse.py
2,158
4.28125
4
""" reverse the contents of the list using recursion, *not a loop.* For example, ``` 1->2->3->None ``` would become... ``` 3->2->1->None ``` # CORRECITON: Loops are okay. Recursion is optional. """ class Node: def __init__(self, value=None, next_node=None): self.value = value self.next_node = ne...
true
b6d2aea38715a7ae5bf511a1bef05c1b45df0e4c
Ksheekey/RBootcamp
/cw/03-Python/2/Activities/02-Stu_KidInCandyStore-LoopsRecap/Unsolved/kid_in_candy_store.py
672
4.34375
4
# The list of candies to print to the screen candy_list = ["Snickers", "Kit Kat", "Sour Patch Kids", "Juicy Fruit", "Swedish Fish", "Skittles", "Hershey Bar", "Starbursts", "M&Ms"] # The amount of candy the user will be allowed to choose allowance = 5 # The list used to store all of the candies selected inside of can...
true
29cf7ea6745659950bcee0725ee5a8a6556c37ce
Ksheekey/RBootcamp
/cw/03-Python/1/Activities/04-Stu_DownToInput/Unsolved/DownToInput.py
1,016
4.125
4
# Take input of you and your neighbor me = input("What is your name? ") neighbor = input("What is your neighbors name? ") # Take how long each of you have been coding me_coding = int(input("How many years have you been coding? ")) neighbor_coding = int(input("How long has your neighbor been coding? ")) # Add total ye...
true
248837d55a72ce380e091e8995212ebd1d3d5570
Alapont/PythonConBetsy
/main.py
645
4.125
4
#!/c/Users/pablo/AppData/Local/Programs/Python/Python38/python import math print("Hola Pablo") # función para ver funciones # nombre: persona a la que saludo # años: años de la persona que saludo def my_function(nombre, años): print("Holiii " + nombre + ", tienes ") print(años) if (años > 1): # then ...
false
3a41cfe8aba9d9aa2daea650cc8a9f44121e3f1f
dupjpr/Hacker_Rank_challenge
/Agenda_while.py
1,586
4.125
4
print("Small Calculator") print(""" Menu Options 1. Sum. 2. Weight Converter. 3. Guess Game. 4. Quit. """) command="" while command != 4: command=int(input("Opcin:")) if command == 1: print("__"*20) print("You are in the space to sum two numbers") a=int(input("First number: ")) b...
true
d4f70cd8f154b59e562344c4525f2ae83884cce5
ensarerturk/globalAiHubPythonHomework
/homework_1.py
1,348
4.25
4
#create an list info=[] #5 values received from the user and added to the list name = input("Please enter your name : ") info.append(name) lastname = input("Please enter your lastname : ") info.append(lastname) #control was done. If the expected value is not entered, it has been requested to be re-entered. try: ...
true
051ab9274fa7a781326199086077b05fecba8a88
cdebruyn/PackageName
/PackageName/sorting.py
1,251
4.5625
5
def bubble_sort(items): '''Return array of items, sorted in ascending order. Argument: items (array): an array of numbers. Returns: array: items sorted in ascending order. Examples: >>> bubble_sort([5,4,3,2,1]) [1,2,3,4,5] >>> bubble_sort([1,3,2]) [1,2,...
true
8ee588750f32ad7ddad6a68f9c64252b94489913
ChRiStIaN3421/programacion
/unidad_3.1/ejercicio24.py
1,447
4.125
4
flag1 = True while flag1: primer_color=input("ingrese el 1° color (rojo o azul): ") if not primer_color.isalpha(): # verificamos q se haya escrito un string print("ingrese un string") elif primer_color=="rojo": while flag1: segundo_color=input(f"ingrese el 2° color (azul o verde) para mezclar el {pr...
false
027032a9ec3d0051dcf62620aa102d540d7d1b15
ChRiStIaN3421/programacion
/unidad_3.1/ejercicio27.py
210
4.21875
4
while True: palabra=input("ingrese una palabra:") if palabra == "salir": print(palabra) break elif palabra == "hola" or "chau": continue else: print(palabra)
false
9c06c1861d4e166d45e81c23111cfd09e8faa314
wfields1/MIS3545
/Assignments/assignment_1/palindrome.py
646
4.25
4
def isPalindrome(s): """ Write a recursive function isPalindrome(string) that returns True if string is a palindrome, that is, a word that is the same when reversed. Examples of palindromes are “deed”, “rotor”, or “aibohphobia”. Hint: A word is a palindrome if the first and last letters match and the ...
true
b07940d23f4b7feec4b29662d117dece7090d68a
kristjanleifur4/forritun-2020
/timaverk7.py
2,675
4.125
4
# The function definition goes here def output_string(input_str): for i in input_str: return input_str[::2] input_str = input("Enter a string: ") # You call the function here print("Every other character:",output_string(input_str)) # Your function definition goes here def digit_count(input_str)...
true
2eacfb81be308feccf1097b2bda36a780eb61dd2
mandalpawan/Data-Stucture
/Stack/Stack.py
782
4.125
4
''' Stack In Data Stucture ''' class Stack: def __init__(self): self.item = [] "PUSH method is use for insert element in TOP of the STACK" def push(self,item): self.item.append(item) "POP method is use to remove element from top of the stack" def pop(self): ret...
true
e009e166a5260accd340fe69ad86e01f74fa589e
mandalpawan/Data-Stucture
/Stack/binary.py
392
4.15625
4
"Use Stack and Convert Decimal Number To Binary Number" from Stack import Stack def binary_Convertor(number): s = Stack() while number > 0: remainder = number %2 s.push(remainder) number = number //2 binary_number = "" while not s.is_empty(): binary_number += str(s.p...
true
80cb7a60563bcd2b1a9f0a9554b237c7b6ebd978
GoogolDKhan/Student-Library
/main.py
2,592
4.15625
4
class Library: # Constructor def __init__(self, list_of_books): self.books = list_of_books # Method to display the books available in the library def display_available_books(self): print("Books available in this library are: ") for index, book in enumerate(self.books): ...
true
87fee067b223e967327ac784b0234073b5d8e04c
monumk/How-to-add-elements-in-list.
/appe.py
848
4.15625
4
'''how to add elements in list''' '''append method add only 1 element at a time at the end of the list''' l1=[10,20,30,40] l1.append(50) print(l1) #output [10,20,30,40,50] l1.append(60) print(l1) #output [10,20,30,40,50,60] '''insert method of the list add one element on the specific position index...
false
17c0758cf196d5916becaaffad5383fea3827536
MohitMehta257/Show-me-the-Data-Structures
/problem_2.py
879
4.375
4
import os def find_files(suffix, path): """ Find all files beneath path with file name suffix. Note that a path may contain further subdirectories and those subdirectories may also contain further subdirectories. There are no limit to the depth of the subdirectories can be. Args: suffix...
true
76fc2fc987ac8afe42719e3d9563dc02f11d81e7
VasBu/lrn_python3
/src/Variables.py
2,526
4.1875
4
def basics(): print("\n****** Create and Delete Variables ******") x = 42 # assigning integer variable print("x = ", x) print("id(x) = ", id(x)) # get reference (identifier) of the variable y = x ...
true
86f1796d0be666e3fd5a97530d548cd5bfd2c988
ashirbad1212/Python-Task-1-by-Ashirbad
/main.py
413
4.25
4
#Accept two integer numbers from a user and return their product and if the product is greater than 1000, then return their sum def product_sum(num1, num2): product = num1 *num2 if(product <= 1000): return product else: return num1 +num2 num1 = int(input("Please enter first number ")) num2 = int(input("...
true
727d9728527d23e8a3dce0f49fadeef06c5a8b3e
AntonioCenteno/Miscelanea_002_Python
/Ejercicios progra.usm.cl/Parte 1/4- Patrones Comunes/productos-especiales_4.py
931
4.15625
4
from math import * #Productos especiales: Numero de Stirling del Segundo tipo #Pedimos los numeros n = int(raw_input("Ingrese n: ")) k = int(raw_input("Ingrese k: ")) #Iremos calculando el Numero de Stirling por partes. stirling = 0 #Primero, el factorial factorial_k = 1 for i in range(1,k+1): factorial_k *= i ...
false
849fd5ed0c0a94f43c7b30a5bac23ee2105e5d73
raghukhanal/Python3
/Conditions.py
313
4.15625
4
age = 22 if age < 21: print("No beer for you") elif age == 21: print("Yes, right on!") else: print("You definetely can!") name = "Lucy" if name is "Raghu": print("Hey there Raghu") elif name is "Lucy": print("Hey hey, LUCEYYYYY") else: print("Hey there! please sign up for the site")
true
43e62b2fadbfe103f8bbc74c6084691e5a89b542
JennaDalgety/coding-dojo
/algorithms/chapter_0/birthday.py
691
4.15625
4
#If 2 given numbers represent your birth month and day in either order, log "How did you know?", else log "Just another day....", #Example: given yourBirthday(4,19) or yourBirthday(19,4) # def birthday(num1, num2): # full_birthday = [4, 19] # for i in full_birthday: # if (i[0], i[1]) == (num1, num2) or (i[...
false
5b87abe1523ed4403a73e19aa65520ab731d6e4d
israeljgarcia/OOP-Data-Structures
/encapsulation/_gpa.py
2,445
4.375
4
class GPA: """ The GPA class stores a student's GPA within the range of 0.0 and 4.0. member variables: gpa methods: __init__(), get_gpa(), set_gpa(value(float)) """ def __init__(self): """ Initializes the gpa variable to 0. return: none """ self._g...
true
82a50c3979827e141f5f78904ca55cd355900534
parasjitaliya/DataStructurePrograms
/stack.py
1,672
4.125
4
class Node: # create a node def __init__(self, data = None): # initialize the first part of node is data self.data = data # initialize the second part of node is point address of next node self.next = None class Stack: # head is default Null def __init__(self): s...
true
8de9a315962e4c95ff00a876073dc450e520b43f
parasjitaliya/DataStructurePrograms
/queue.py
1,571
4.15625
4
class Node: # create a node def __init__(self, data = None): # initialize the first part of node is data self.data = data # initialize the second part of node is point address of next node self.next = None class Queue: # declaring the front,rare,count variables and initiali...
true
1585c7c0468c3e8d710ebc3ec4c9e6b3ad9989bd
NSangita/Machine-Learning
/numpy-tutorial/ex01.py
381
4.1875
4
# Exercise 01: Extract elements from an array # Declare and initialize an array as done below # arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) # Then, extract all odd numbers from arr to achieve the desired output. # Desired output: # #> [1 3 5 7 9] import numpy as np arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9...
true
ac40c43ff5057cf0b8a8c4eb67d1e68ba4b4f9cf
Ncalo19/general_python_practice
/Python_tutorial/14_classes_slash_objects.py
1,418
4.34375
4
# class is an object blueprint # create an object blueprint class class1: name = 'Nick' # object: item inside a class age = 23 print(class1) # print an object print(class1.name) print(class1.age) # use a period when extracting info about a class or performing an action on a script or array # assign values to ...
true
e689b9ebb684f88f2764418b6ea033216b88f2a4
jainsimran/python-exercises
/strings.py
802
4.28125
4
#Strings are Arrays str = "happy" #loop for x in str: print(x) # to check length print(len(str)) # to check if a certain phrase or character is present in a string, if "app" in str: print("app is present in " + str) if "tap" not in str: print("tap is not present in " + str) #Slicing Strings print(st...
true
30b54f8a93a3ccf721d40444cca9a1e1f6bae9e5
aync19/InteractivePythonCoursera
/circle.py
1,013
4.1875
4
#Use buttons to increase and decrease the size of the circle #Change color with input field import simplegui # Define globals - Constants are capitalized in Python HEIGHT = 400 WIDTH = 400 RADIUS_INCREMENT = 5 ball_radius = 20 color = "Orange" # Draw handler def draw(canvas): global ball_radius canvas.draw_c...
true
5e986e6230bae6882a92744b52f6b8102a3e9cde
deepali1232/divya-coding-classes
/basic_programs/program11.py
573
4.28125
4
#dictionary(key-value-pair) d1={'apple':50,'mango':100,'guava':200,'banana':300} print(d1) print(type(d1)) #extracting keys print(d1.keys()) #extracting values print(d1.values()) #add new element in dict d1['bag']=400 print(d1) #change existing element or modify d...
true
b5d5ad2fd8f2eb6425d2684eb49b47ca4ed02d66
deepali1232/divya-coding-classes
/basic_programs/basic32.py
815
4.125
4
#Python program to check if the given number is Happy Number #Number = 32 #3^2+ 2^2 = 13 #1^2 + 3^2 = 10 #1^2 + 0^2 = 1 #isHappyNumber() will determine whether a number is happy or not def isHappyNumber(num): rem = sum = 0; #Calculates the sum of squares of digits while(num > 0): ...
true
f969ad05d1ea8646a031ef1788c2d75075e1f627
J-asy/Algorithms-and-Data-Structures
/boyer_moore/z_algo.py
2,197
4.15625
4
def z_algorithm(string): """ Returns a z_array, such that for all i, z_array[i] contains the length of the longest substring starting at position i of the string that matches its prefix :time complexity: O(n) :space complexity: O(n), where n is the length of the string """ z_array =...
true
4559c4687e3ac3c5ec8ad6c257a5fbbbb21a257d
GitBulk/datacamp
/marketing analytics with python/01 analyzing marketing campaigns with pandas/11_grouping_and_counting_by_multiple_columns.py
1,189
4.1875
4
''' INTRODUCTION: Grouping and counting by multiple columns Stakeholders have begun competing to see whose channel had the best retention rate from the campaign. You must first determine how many subscribers came from the campaign and how many of those subscribers have stayed on the service. It's important to identify...
true
08e5788255b2234ea69ddcc5b38aec34e27706ef
exfrioss/python_projects_for_beginners
/0_beginners_path/03_email_slicer.py
1,002
4.40625
4
""" Email slicer: An email slicer is a very useful program for separating the username and domain name of an email address. To create an email slicer with Python, our task is to write a program that can retrive the username and the domain name of the email. For example: 'frioss@domain.com'. So we need to divide the e...
true
a9f563b4837e8cc91791bc8bc0b03a3cbea4d5c0
johnwatterlond/playground
/matrix_printer.py
2,290
4.6875
5
""" Module for printing a matrix. Matrix can be of any size and can contain numbers or words of any length. Matrix should be a list of rows where each row is a list. Examples: --------- Example 1: In : matrix = [[2, 4, 6], [8, 10, 12], [14, 16, 18]] print_matrix(matrix) Out : 2 4 6 8 10 12 14 16 18 Exam...
true