blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ad5f7bd7652559a42904eee699f9f3b0238689c8
soniccc/regexp
/regexp2.py
386
4.53125
5
# Example: To verify a string contans a particular word import re paragraph = ''' The regular expression isolates the document's namespace value, which is then used to compose findable values for tag names ''' word = 'namespace' if re.search(word, paragraph): print(f"The paragraph contains the word : '{word}'")...
true
c50996345949e25f2bc5e6ab451e8a22f6a0c5fb
DanielFleming11/Name
/AverageScores.py
551
4.28125
4
#Initialize all variables to 0 numberOfScores = 0 score = 0 total = 0 scoreCount = 0 average = 0.0 #Accept the number of scores to average numberOfScores = int(input("Please enter the number of scores you want to input: ")) #Add a loop to make this code repeat until scoreCount = numberOfScores while(scoreCount != n...
true
221a661ba52f4393d984a377511f87f7ca1e285d
iwasnevergivenaname/recursion_rocks
/factorial.py
328
4.40625
4
# You will have to figure out what parameters to include # 🚨 All functions must use recursion 🚨 # This function returns the factorial of a given number. def factorial(n, result = 1): # Write code here result *= n n -= 1 if n == 1: return result return factorial(n, result) print(factorial...
true
b2e6d5d485409a42c565292fa84db602445778a4
eugenesamozdran/lits-homework
/homework8_in_progress.py
1,178
4.3125
4
from collections.abc import Iterable def bubble_sort(iter_obj, key=None, reverse=False): # first, we check if argument is iterable # if yes and if it is not 'list', we convert the argument to a list if isinstance(iter_obj, Iterable): # here we check if some function was passed a...
true
7acc25c12d7f688d0b428849de5b3015086c2644
Diego-18/python-algorithmic-exercises
/1. PROGRAMACION ESTRUCTURADA/NUMEROS/par y primo.py
704
4.125
4
#!/usr/bin/env python #-*- coding: cp1252 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de verificar si un numero es par y primo lsseguir="s" licont=0 while lsseguir=="s" or lsseguir=="S": linumero=int(raw_input("Introduzca el numero: ")...
false
12ca3949ce6f3d218ed13f58ee0ab0a0e06f4ab4
geyunxiang/mmdps
/mmdps/util/clock.py
1,760
4.34375
4
""" Clock and time related utils. """ import datetime from datetime import date def add_years(d, years): """ Return a date that's `years` years after the date (or datetime) object `d`. Return the same calendar date (month and day) in the destination year, if it exists, otherwise use the following day ...
true
522bc730e6d05cc957a853f5d667e553229474ff
Bigbys-Hand/crash_course_git
/functions.py
2,909
4.4375
4
def greet_nerds(): """Display a simple greeting""" print("Live long and prosper") def better_greeting(username): """Display a simple greeting, pass name to function""" print(f"Live long and prosper, {username.title()}!") #This function is similar to the first one, but we created the PARAMETER 'usernam...
true
48f0d4132919cdae29fe3591b01b235869c65af6
HenrikSamuelsson/python-crash-course
/exercises/chapter_03/exercise_03_07/exercise_03_07.py
2,758
4.21875
4
# 3-7 Guest List guest_list = ["Albert Einstein", "Isac Newton", "Marie Curie", "Galileo Galilei"] message = "Hi " + guest_list[0] + " you are invited to dinner at 7 on saturday." print(message) message = "Hi " + guest_list[1] + " you are invited to dinner at 7 on saturday." print(message) message = "Hi " + guest_l...
false
b06fe113e6b7c496cca988987f4f4c56f8931766
ovnny/HarvardCS50-Intr2CS
/6python/exercicios/teste.py
312
4.21875
4
x = int(input("x: "), 2) #Tipagem como função int() y = int(input("y: "), 8) #Escolha do modelo de base z = int(input("z: "), 16) #numérica no fim da função. print(f"x is: {x}\ny is: {y}\nz is: {z}\n") #Binário, Octal e Hexadecimal
false
2c388e95f7a92ac05d468d9d5ce8e927915dce10
InnocentSuta/PythonChallenges
/04_Leap Year.py
316
4.28125
4
#Program to check wether a year is a leap year or not. year = int(input("Please Enter a year : ")) #check if the year is divisible by 4 and 400 and not by 100 if year % 4 == 0 and (year % 400 == 0 or year % 100 != 0): print(year, "is a leap year ") else: print(year, "is not a leap year ")
false
5d40801b679cd7469773a11535c56ec1efb8c63e
weixuanteo/cs_foundation
/string_splosion.py
474
4.28125
4
# Given a non-empty string like "Code" return a string like "CCoCodCode". # Sample input s = "Code" def string_splosion(str): result = "" # On each iteration, add the substring of the chars for i in range(len(str)): print("str[:i+1]: ", str[:i+1]) # [Python slicing] Returns from begining o...
true
0e9bbd1aef2f920e35ead4e7b969504cb63d04b1
happyAyun/MSA_TIL
/python_workspace/basic_grammer/13_classv_test.py
790
4.125
4
class ClassTest: class_v = 10 # 클래스 변수 : 클래스 타입의 모든 instance 공유하는 변수 클래스 이름으로 참조. def __init__(self,instance_v): self.instance_v = instance_v c1 = ClassTest(10) c2 = ClassTest(10) c1.instance_v += 1 c2.instance_v += 1 c3 = ClassTest.class_v c3 += 1 c4 = ClassTest.class_v c4 += 1 ClassTest.class_v ...
false
c72327d594362697ad1b65db7530a19d564b74da
saintsavon/PortfolioProjects
/Interview_Code/Palindrome.py
1,434
4.21875
4
import re import sys # Used to get the word list file from command line # Example command: 'python Palindrome.py test_words.txt' input_file = sys.argv[1] def palindrome(word): """ Checks if word is a palindrome :param word: :return Boolean: """ return word == word[::-1] palindrome_dict = {}...
true
11a39da4784ff32c31419d5bb891893ec22f810e
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/14. Dictionaries/125. iterating_dict.py
1,365
4.25
4
instructor = { "name":"Cosmic", "num_courses":'4', "favorite_language" :"Python", "is_hillarious": False, 44 : "is my favorite number" } # Accessing all values in a dictionary # We'll loop through keys, loop through values, loop through both keys and values # Values Print .values() ...
true
a9b3cedf7ae1dae5eb5ce3246552c15df6bf59eb
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/12. Lists/104. list_methods.py
1,127
4.1875
4
first_list = [1,2,3,4] first_list.insert(2,'Hi..!') print(first_list) items = ["socks", 'mug', "tea pot", "cat food"] # items.clear() #Lets the items list to be a list but clears everything within it. items = ["socks", 'mug', "tea pot", "cat food"] first_list.pop() # Remove the last element first_list.pop(1...
true
f4724113c5118d7bd8a03d862cf6010ba588539f
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/08. and 09. ConditionalLogic and RPS/game_of_thrones.py
1,970
4.15625
4
print("Heyy there! Welcome to GOT quotes machine.") print("What is your name human ?") user_name = input() print("\n Select from numbers 1 through 5 and we will give a quote (or two) based on your name. e.g. 1 or Tyrion or TL (case sensitive)\n \n") # or First Name or Initials print("What's your character's name?\...
true
aaaf8d5decbabeede4a42c2630fc1f31ec387a58
abhatia05/Udemy---Colt-Steele-Modern-Python-Bootcamp-Codebook
/08. and 09. ConditionalLogic and RPS/bouncer.py
1,367
4.375
4
#Psuedo Code: Ask for age # 18-21 Wristband and No Drinks # Method1 # age = input("How old are you: ") # age = int(age) # if age != "": # if age >= 18 and age < 21: # print("You can enter, but need a wristband ! Also no drinks for you ese!") # # 21+ Normal Entry and Drinks # elif a...
true
f96111974debd6f8a56e9eb3d964bcf2d40517d7
iroshan/python_practice
/recursive_sum.py
588
4.28125
4
def recursive_sum(n=0): ''' recursively add the input to n and print the total when the input is blank''' try: i = input('enter a number: ') # base case if not i: print(f'total = {n}') # check if a number elif not i.isnumeric(): print("not a number...
true
65fb533a490dfcaf5ed1462f217047f7a8ae5f74
iroshan/python_practice
/guess_the_number.py
783
4.125
4
from random import randint def guess_num(): ''' guess a random number between 0 and 100. while users guess is equal to the number provide clues''' num = randint(0,100) while True: try: # get the number and check guess = int(input('enter your guess: ')) if num > g...
true
ebfcfd2080c938b2f842bebf1e0e21a2a75b8cd6
jayfro/Lab_Python_04
/Minimum Cost.py
866
4.3125
4
# Question 4 c groceries = [ 'bananas', 'strawberries', 'apples', 'champagne' ] # sample grocery list items_to_price_dict = { 'apples': [ 1.1, 1.3, 3.1 ], 'bananas': [ 2.1, 1.4, 1.6, 4.2 ], 'oranges': [ 2.2, 4.3, 1.7, 2.1, 4.2 ], 'pineapples': [ 2.2, 1.95, 2.5 ]...
true
a3b6a12ec18d72801bf0ee0bb8a348313ddb62fa
AZSilver/Python
/PycharmProjects/test/Homework 05.py
2,286
4.4375
4
# ------------------------------------------------------------------------------- # Name: Homework 05 # Purpose: Complete Homework 5 # Author: AZSilverman # Created: 10/21/2014 # Desc: Asks the user for the name of a household item and its estimated value. # then stores both pieces of data in a text file called HomeInv...
true
6c64f1505db0b69276f2212bc96e8ec89ef81734
u4ece10128/Problem_Solving
/DataStructures_Algorithms/10_FactorialofAnyNumber.py
719
4.5
4
# Find the factorial of a given number n def factorial_iterative(n): """ Calculates the factorial of a given number Complexity: O(N) :param n: <int> :return: <int> """ result = 1 for num in range(2, n+1): result *= num return result def factorial_recursive(n): """ ...
true
de2e1abde37e6fd696a8f50d6143d491d8fb5d05
if412030/Programming
/Python/HackerRank/Introduction/Division.py
1,658
4.40625
4
""" In Python, there are two kinds of division: integer division and float division. During the time of Python 2, when you divided one integer by another integer, no matter what, the result would always be an integer. For example: >>> 4/3 1 In order to make this a float division, you would need to convert one of t...
true
0fdb20e59477fd96d05f5c3d2ed9abcbb0201e39
if412030/Programming
/Python/HackerRank/Introduction/ModDivmod.py
1,002
4.5
4
""" One of the built-in functions of Python is divmod, which takes two arguments aa and bb and returns a tuple containing the quotient of a/ba/b first and then the remainder aa. For example: >>> print divmod(177,10) (17, 7) Here, the integer division is 177/10 => 17 and the modulo operator is 177%10 => 7. Task Read...
true
762121b1d623ce8b5fc62b6234b333c67187131e
Ro7nak/python
/basics/Encryption_Decryption/module.py
621
4.625
5
# encrypt user_input = input("Enter string: ") cipher_text = '' # add all values to string for char in user_input: # for every character in input cipher_num = (ord(char)) + 3 % 26 # using ordinal to find the number # cipher = '' cipher = chr(cipher_num) # using chr to convert back to a letter cipher...
true
d85a139d910c67059507c6c73d49be723f3faa56
bugmark-trial/funder1
/Python/sum_of_digits_25001039.py
349
4.25
4
# Question: # Write a Python program that computes the value of a+aa+aaa+aaaa with a given # digit as the value of a. # # Suppose the following input is supplied to the program: # 9 # Then, the output should be: # 11106 # # Hints: # In case of input data being supplied to the question, it should be # # assumed to be a ...
true
e10eae47d7a19efb93d76caeb2f6a2752cdd6666
dichen001/CodeOn
/HWs/Week 5/S5_valid_anagram.py
1,626
4.125
4
""" Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. """ def isAnagram(s, t): """ :type s: str :type t: str :rtype: bool """ ### Please start your code here### le...
true
bd90689da08ce04c428fdf4781e06e935bce3243
vinaypathak07/codezilla
/Sorting/Merge Sort/Python/merge_sort.py
1,107
4.25
4
def merge_sort(array_list, start, end): '''Sorts the list from indexe start to end - 1 inclusive.''' if end - start > 1: mid = (start + end)//2 merge_sort(array_list, start, mid) merge_sort(array_list, mid, end) merge_list(array_list, start, mid, end) '''Merges each sorted l...
false
3e73ef211d9d20808bad316e3d1f8493a386abd7
joeyyu10/leetcode
/Array/56. Merge Intervals.py
731
4.21875
4
""" Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] and [4,5] are ...
true
886bcb3990f524a5495b4254f71d6f6d03986a9f
reemanaqvi/HW06
/HW06_ex09_06.py
939
4.34375
4
#!/usr/bin/env python # HW06_ex09_05.py # (1) # Write a function called is_abecedarian that returns True if the letters in a # word appear in alphabetical order (double letters are ok). # - write is_abecedarian # (2) # How many abecedarian words are there? # - write function(s) to assist you # - number of abeced...
true
3b4ac26a260e4a0118d90637899ee3755c975a97
aburmd/leetcode
/Regular_Practice/easy/17_371_Sum_of_Two_Integers.py
1,883
4.125
4
""" Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = -2, b = 3 Output: 1 """ class Solution: def getPositivesum(self,a,b): while b!=0: bitcommon=a&b #Example: 4(100),5(101) bit commo...
true
9eba98a92942adeb3cffc9bab950d03c384e56c0
MarthaSamuel/simplecodes
/OOPexpt.py
1,142
4.46875
4
#experimenting with Object Orienting Programming #defining our first class called apple class Apple: pass #we define 2 attributes of the class and initialize as strings class Apple: color = '' flavor = '' # we define an instance of the apple class(object) jonagold = Apple() # attributes of the object jonago...
true
4ac5b4a4d773a73aa6768d57afd9e44a3482cb86
AllenWang314/python-test-scaffolding
/interview.py
275
4.3125
4
""" returns square of a number x raises exception if x is not of type int or float """ def square(x): if type(x) != int and type(x) != float: raise Exception("Invalid input type: type must be int or float") print(f"the square is {x**2}") return x**2
true
84ed875a37f483f8acfa592c24bd6c9dd5b4cbf7
RuchirChawdhry/Python
/all_capital.py
1,163
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # script by Ruchir Chawdhry # released under MIT License # github.com/RuchirChawdhry/Python # ruchirchawdhry.com # linkedin.com/in/RuchirChawdhry """ Write a program that accept a sequence of lines* and prints the lines as input and prints the lines after making all the ...
true
656ae9779498767407dfbec47689c6aaf15907d3
RuchirChawdhry/Python
/circle_class.py
984
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # script by Ruchir Chawdhry # released under MIT License # github.com/RuchirChawdhry/Python # ruchirchawdhry.com # linkedin.com/in/RuchirChawdhry """ Define a class 'Circle' which can be constructed by either radius or diameter. The 'Circle' class has a method which can ...
true
f3c2abbab1697397006113c42c1fc03568d17719
Sanchi02/Dojo
/LeetCode/Strings/ValidPalindrome.py
742
4.125
4
# Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. # Note: For the purpose of this problem, we define empty string as valid palindrome. # Example 1: # Input: "A man, a plan, a canal: Panama" # Output: true # Example 2: # Input: "race a car" # Output: fals...
true
768e42c29a97bcf3c2d6ec5992d33b9458fb56e8
ujjwalshiva/pythonprograms
/Check whether Alphabet is a Vowel.py
256
4.40625
4
# Check if the alphabet is vowel/consonant letter=input("Enter any letter from a-z (small-caps): ") if letter == 'a' or letter =='e' or letter =='i' or letter =='o' or letter =='u': print(letter, "is a Vowel") else: print(letter, "is a Consonant")
true
9c8c2d07f6bd60fbcadebf7d533a6e3124fef4ae
davidwang0829/Python
/小甲鱼课后习题/43/习题2.py
705
4.125
4
# 定义一个单词(Word)类继承自字符串,重写比较操作符,当两个Word类对象进行比较时 # 根据单词的长度来进行比较大小(若字符串带空格,则取第一个空格前的单词作为参数) class Word(str): def __new__(cls, args): if ' ' in args: args = args[:args.index(' ')] return str.__new__(cls, args) # 将去掉括号的字符串作为新的参数初始化 def __lt__(self, other): return len(self) < le...
false
16e13a2f6042e3deae198df89a2956f6648edfb4
davidwang0829/Python
/小甲鱼课后习题/34/习题2.py
1,464
4.15625
4
# 使用try…except语句改写第25课习题3 print('''--- Welcome to the address book program --- --- 1:Query contact information --- --- 2:Insert a new contact --- --- 3:Delete existing contacts --- --- 4:Exit the address book program ---''') dic = dict() while 1: IC = input('\nPlease enter the relevant instruction code:') if I...
true
e2ff4a0f6df1717d29370cb9ce43fb6741aa9632
davidwang0829/Python
/小甲鱼课后习题/45/属性访问.py
775
4.1875
4
# 写一个矩形类,默认有宽和高两个属性 # 如果为一个叫square的属性赋值,那么说明这是一个正方形 # 值就是正方形的边长,此时宽和高都应该等于边长 class Rectangle: def __init__(self, width=0, height=0): self.width = width self.height = height def __setattr__(self, name, value): if name == 'square': self.width = self.height = value el...
false
be23213891eb1945990bd61cec32c986a29fba49
matvelius/Selection-Sort
/selection_sort.py
1,825
4.3125
4
# The algorithm divides the input list into two parts: # the sublist of items already sorted, which is built up from left # to right at the front (left) of the list, and the sublist of items # remaining to be sorted that occupy the rest of the list. # Initially, the sorted sublist is empty and the unsorted sublist ...
true
52ae48b48dd9f7c9a60970dab786b3a02a7f76b0
abhi15sep/Python-Course
/introduction/loops/Loop_Example/exercise.py
637
4.125
4
# Use a for loop to add up every odd number from 10 to 20 (inclusive) and store the result in the variable x. # Add up all odd numbers between 10 and 20 # Store the result in x: x = 0 # YOUR CODE GOES HERE: #Solution Using a Conditional for n in range(10, 21): #remember range is exclusive, so we have to go up to 21...
true
684a6a2571adb3bb17ea97230600d5ae76ed6570
abhi15sep/Python-Course
/collection/Dictionaries/examples/Dictionary.py
1,581
4.5625
5
""" A dictionary is very similar to a set, except instead of storing single values like numbers or strings, it associates those values to something else. This is normally a key-value pair. For example, we could create a dictionary that associates each of our friends' names with a number describing how long ago we la...
true
52432f6633d264b1f53d9c6e8a9bb834e4532d7b
abhi15sep/Python-Course
/introduction/example/lucky.py
502
4.15625
4
#At the top of the file is some starter code that randomly picks a number between 1 and 10, and saves it to a variable called choice. Don't touch those lines! (please). #Your job is to write a simple conditional to check if choice is 7, print out "lucky". Otherwise, print out "unlucky". # NO TOUCHING PLEASE-------...
true
2eab7e313a1104ca9384d3c73f8e3d3b10ff4491
abhi15sep/Python-Course
/Functions/examples/exercise4.py
600
4.4375
4
#Implement a function yell which accepts a single string argument. It should return(not print) an uppercased version of the string with an exclamation point aded at the end. For example: # yell("go away") # "GO AWAY!" #yell("leave me alone") # "LEAVE ME ALONE!" #You do not need to call the function to pass the ...
true
b8c247b00db447a205409067aad84ea853ad2040
abhi15sep/Python-Course
/introduction/example/positive_negative_check.py
970
4.46875
4
# In this exercise x and y are two random variables. The code at the top of the file randomly assigns them. #1) If both are positive numbers, print "both positive". #2) If both are negative, print "both negative". #3) Otherwise, tell us which one is positive and which one is negative, e.g. "x is positive and y is ne...
true
df9627b825c32214c312f45d1518e7d70c6485e8
OhOverLord/loft-Python
/Изучение numpy/6.py
678
4.1875
4
""" Считайте 2 числа: n - размер Numpy вектора x - координата элемента вектора, который должен быть равен 1. Остальные элементы вектора должны быть равны 0. Сохраните вектор в переменную Z. Примечание. В этой задаче не нужно ничего выводить на печать. Только создать вектор Z. Sample Input: 10 4 Sample Output: ...
false
9d18ab098eb2d59fbba6595cbc157dd3b629d87a
yogabull/LPTHW
/ex14.py
789
4.15625
4
# Exercise 14: Prompting and Passing from sys import argv script, user_name, last_name, Day = argv #prompt is a string. Changing the variable here, changes every instance when it is called. prompt = 'ENTER: ' #the 'f' inside the parenthesis is a function or method to place the argv arguements into the sentence. prin...
true
b7f1467fbb432ee2765720bc0b13744e7783f367
shangpf1/python_homework
/2019-6-13.py
919
4.1875
4
""" 我的练习作业03- python 高级排序-字符长度相同进行排序 """ # 正序(关于正序排序,首先会按字符的长度排序,如果一样的话,会按字符正序的首字母的ASCII码大小排序) strs = ['study','happy','thing'] print('s==>',ord('s'),'h===>',ord('h'),'t===>',ord('t')) strs.sort() print("正序排序为:",strs) """ 倒序(关于倒序排序,和上面的正序刚好相反,从字符的末尾的字符大小进行排序,如果末尾字符相同, 会按倒数第二位的字符大小排序,如此类推) """ print('g====',or...
false
9b42a6f0b8fe9d7ebca325e29b0f1695c24df199
mxcat1/Curso_python3
/Curso Python37 Avanzado/tuplas/tuplas.py
643
4.28125
4
tupla1=("cinco",4,"hola",34) print(tupla1) # convertir una tupla en lista lista1=list(tupla1) print(lista1) #convertir una lista en tupla tupla2=tuple(lista1) print(tupla2) #metodo in print("cinco" in tupla2) # metodo para saber la cantidad de elementos print(tupla2.count(4)) # metodo len para saber la logitud ...
false
ef8d22e8ab44d0a3cad96db2c94779ab98c2d11c
Catrinici/Python_OOP
/bike_assignement.py
1,177
4.28125
4
class Bike: def __init__(self, price, max_speed, miles): self.price = price self.max_speed = max_speed self.miles = abs(0) def ride(self): print("Riding!") self.miles += 10 print(f"Total miles : {self.miles}") return self def reverse(self): pr...
true
459bbf3c436621c0b769c07740b44261bb84ff3d
Abeilles14/Java_exercises
/6.32_IfThenElseChallenge/IfThenElseChallenge.py
274
4.15625
4
#isabelle andre #14-07/18 #if challenge name = input("Enter your name: ") age = int(input("Enter your age: ")) #if age >= 18 and age <= 30: if 18 >= age <= 30: print("Welcome to the 18-30 holiday, {}".format(name)) else: print ("You are not eligible to enter the holiday")
true
8d69bd1f68bd1dfe19adb1909d0ed541fdef7b7c
mmsamiei/Learning
/python/dictionary_examples/create_grade_dictionary.py
532
4.1875
4
grades = {} while(True): print("Enter a name: (blank to quit):") name = raw_input() if name == '': break if name in grades: print(' {grade} is the grade of {name} ').format(grade=grades[name],name=name) else: print("we have not the grade of {name}").format(name=name) ...
true
6a07533146042655f2780ff329ecaff3089cedd6
ziyuanrao11/Leetcode
/Sum of 1d array.py
2,483
4.15625
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 26 14:41:32 2021 @author: rao """ '''Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is o...
true
6b20a2136e8449a61778778b4799211c391e4952
pandiarajan-src/PyWorks
/Learn/ceaser_ciper.py
2,026
4.1875
4
'''Implement Ceaser Cipher encryption and decryption https://en.wikipedia.org/wiki/Caesar_cipher.''' def ceaser_ciper_encryption(input_to_encode, key_length): """Ceaser Encryption method""" enc_output = chech_char = "" for letter in input_to_encode: if letter.isalpha(): n_uni_char = ord...
false
ee1fdb8b1af9f44ce15f191c158abebf1e4a2fbd
pandiarajan-src/PyWorks
/Learn/date.py
1,685
4.3125
4
'''Experiment on date, time and year fields''' from datetime import datetime, timedelta #, date def print_today_yesterday_lw_date(): """Print today's date, yesterday;s date and last week this day""" print(f"Today's date is {str(datetime.now())}") print(f"Yesterday's date is {str(datetime.now() - time...
false
eb5b36fd683ead2eb4205f18ab6897eb76327aa0
pandiarajan-src/PyWorks
/educative_examples/benchmarking_ex3.py
1,192
4.15625
4
# Benchmarking # Create a Timing Context Manager """ Some programmers like to use context managers to time small pieces of code. So let’s create our own timer context manager class! """ import random import time class MyTimer(): def __init__(self): self.start = time.time() def __enter__(self): ...
true
e86df3f56dc9ca95f6a2018b41e19aa3fc7f8e5b
pandiarajan-src/PyWorks
/Learn/converters_sample.py
1,108
4.28125
4
'''This example script shows how to convert different units - excercise for variables''' MILES_TO_KILO_CONST = 1.609344 RESOLUTION_CONST = 2 def miles_to_kilometers(miles): """Convert given input miles to kilometers""" return round((miles * MILES_TO_KILO_CONST), RESOLUTION_CONST) def kilometers_to_miles(kilo...
true
58ef0063ab66182a98cfeb82a2173be41952ac75
chigginss/guessing-game
/game.py
1,870
4.21875
4
"""A number-guessing game.""" from random import randint def guessing_game(): # pick random number repeat = "Y" scores = [] #Greet player and get the player name rawinput print("Hello!") name = raw_input("What is your name? ") while repeat == "Y": start = int(raw_input("Choose a star...
true
fd6d45ba6fecb3605e025a74ed5f56abc63e6625
slayer6409/foobar
/unsolved/solar_doomsday.py
1,692
4.4375
4
""" Solar Doomsday ============== Who would've guessed? Doomsday devices take a LOT of power. Commander Lambda wants to supplement the LAMBCHOP's quantum antimatter reactor core with solar arrays, and she's tasked you with setting up the solar panels. Due to the nature of the space station's outer paneling, all of it...
true
e77a9e0ab70fbb5916f12e1b864f5f5b7211ba48
gauravkunwar/PyPractice
/PyExamples/factorials.py
248
4.3125
4
num=int(input("Enter the value :")) if(num<0): print("Cannot be factorized:") elif (num==0): print("the factorial of 0 is 1:") else : for i in range(0 to num+1): factorial=factorial*i print"the factorial of a given number is:",factorial
true
48d1eeffbf97cdf144e0f8f1fb6305da1141b5be
gauravkunwar/PyPractice
/PyExamples/largestnum.py
352
4.3125
4
num1=float(input("Enter the first num:")) num2=float(input("Enter the second num:")) num3=float(input("Enter the third num:")) if: (num1>num2) and(num1>num3) print("largest=num1") elif: (num2>num3) and(num2>num1) print("largest=num2") else print("largest=num3") #print("The largest number among,"num...
true
f1ac7ce434862b7b26f5225810e65f539ec38838
Nike0601/Python-programs
/km_cm_m.py
322
4.3125
4
print "Enter distance/length in km: " l_km=float(input()) print "Do you want to convert to cm/m: " unit=raw_input() if unit=="cm": l_cm=(10**5)*l_km print "Length in cm is: "+str(l_cm) elif unit=="m": l_m=(10**3)*l_km print "Length in m is: "+str(l_m) else: print "Invalid input. Enter only cm or m"...
true
f104a63a96199414da32eeb718326ecea5b4df7e
nithen-ac/Algorithm_Templates
/algorithm/bit_manipulation.py
980
4.15625
4
# Bit manipulation is the act of algorithmically manipulating bits or other pieces of data shorter than a word. # # common bit-wise operation # # operations priority: # {}[]() -> ** -> ~ -> -x -> *,/,% -> +,- -> <<,>> -> & -> ^ -> | -> <>!= -> is -> in -> not x -> and -> or def bit_wise_operations(a, b): # not ...
false
073e62dd7605358faa87c85820aa8f0ebb19f9af
Julian0912/Book_DSA
/Chapter_8/BaseTree.py
2,785
4.1875
4
# -*- coding:utf8 -*- # Author: Julian Black # Function: # from abc import ABCMeta, abstractmethod class Tree(metaclass=ABCMeta): """树的基类""" class Position(metaclass=ABCMeta): """一个表示元素位置的基类""" @abstractmethod def element(self): """返回该位置的元素""" @abstractmethod ...
false
5b1b2cf0dbd3a182ce8605a29c41fd441a951ffe
Bricegnanago/elliptique_courbe
/main.py
873
4.15625
4
# Algorithme # de x3+ax+b class Point: def __init__(self, abs=4, ord=9): self.abs = abs self.ord = ord def setpoint(self, newabs, neword): self.abs = newabs self.ord = neword # print(point.ord) def elliptiquecourbe(a, b, point): return point.ord * point.ord - (point.abs...
false
f31a2f8ae56690da86253aed017a2dfa91a83343
okdonga/algorithms
/find_matches_both_prefix_and_suffix.py
2,873
4.15625
4
################ # Given a string of characters, find a series of letters starting from the left of the string that is repeated at the end of the string. # For example, given a string 'jablebjab', 'jab' is found at the start of the string, and the same set of characters is also found at the end of the string. # This i...
true
0a9bda6adc975f8526710ef07c49d9d9f2577759
ne1son172/GB2-algo-and-data-structures
/HW2/task1.py
1,813
4.21875
4
""" Написать программу, которая будет складывать, вычитать, умножать или делить два числа. Числа и знак операции вводятся пользователем. После выполнения вычисления программа не должна завершаться, а должна запрашивать новые данные для вычислений. Завершение программы должно выполняться при вводе символа '0' в качестве...
false
6d0745071e38ee8949a6392e51d8f036faef9dcc
arnillacej/calculator
/calculator.py
397
4.34375
4
num1 = float(input("Please enter the first number: ")) operation = input("Please choose an arithmetical operation '+,-,*,/': ") num2 = float(input("Please enter the second number: ")) if operation == "+": print(num1+num2) elif operation == "-": print(num1-num2) elif operation == "*": print(num1*num2) elif o...
true
74fd1b9071853159dbed349504f704be01534532
EricE-Freelancer/Learning-Python
/the power of two.py
426
4.40625
4
print("Hi! what is your name? ") name = input() anything = float(input("Hi " + name + ", Enter a number: ")) something = anything ** 2.0 print("nice to meet you " + name +"!") print(anything, "to the power of 2 is", something) #the float() function takes one argument (e.g., a string: float(string))and tries...
true
a902a904c37effe53c9459ac554ca8ee39a90877
raghuprasadks/pythoncrashcourse
/1-GettingStarted.py
592
4.125
4
print("Hello.Welcome to Python") course = "Python" print(course) print(type(course)) ''' Data Types 1. String - str 2. Integer - int 3. Boolean - bool 4. Float - float 5. List 6. Tuple 7. Dictionary 8. Set ''' age = 35 print(age) print(type(age)) amount = 100.5 print(type(amount)) isActive = True print(type(isActive)) ...
false
be5e00cd27adb53a3e3c6f873ffdfc91acf1463f
Nayan356/Python_DataStructures-Functions
/Functions/pgm9.py
676
4.3125
4
# Write a function called showNumbers that takes a parameter called limit. # It should print all the numbers between 0 and limit with a label to # identify the even and odd numbers. def showNumbers(limit): count_odd = 0 count_even = 0 for x in range(1,limit): if not x % 2...
true
b88b8781aff585532384232fae3028ec7ce2d82d
Nayan356/Python_DataStructures-Functions
/DataStructures_2/pgm7.py
472
4.4375
4
# # Write a program in Python to reverse a string and # # print only the vowel alphabet if exist in the string with their index. def reverse_string(str1): return ''.join(reversed(str1)) print() print(reverse_string("random")) print(reverse_string("consultadd")) print() # def vowel(text): # vowels = "aeiuoAEI...
true
c5a78bcae376bba759a179839b6eba037ecd6988
Nayan356/Python_DataStructures-Functions
/DataStructures/pgm7.py
232
4.375
4
# Write a program to replace the last element in a list with another list. # Sample data: [[1,3,5,7,9,10],[2,4,6,8]] # Expected output: [1,3,5,7,9,2,4,6,8] num1 = [1, 3, 5, 7, 9, 10] num2 = [2, 4, 6, 8] num1[-1:] = num2 print(num1)
true
84e673227276da95fa1bc8e4cf0801c5c77080a4
Nayan356/Python_DataStructures-Functions
/Functions/pgm7.py
519
4.4375
4
# Define a function that can accept two strings as input and print the string # with maximum length in console. If two strings have the same length, # then the function should print all strings line by line. def length_of_string(str1, str2): if (len(str1) == len(str2)): print(str1) #print("\n") print(str2) ...
true
12a117ecc823e95e01caa32c3687afc1009e38ea
sidson1/hacktoberfest2021-3
/bmiCALCULATOR.py
905
4.40625
4
# A simple BMI calculator Using python print("\n******-----MALNUTRATE!******------HEALTHY!******-------OVERWEIGHT!") print("\nWELCOME TO FULLY AUTOMATED BMI CALCULATOR ARE YOU INTRESTED TO KNOW WHO YOU ARE\n\t\t\t *press Y* ") var=input() print("----------------------------------------------------------------------...
false
4f708d85e2be8dba03ad84c944f1192f7fb9c961
perryl/daftpython
/calc.py
846
4.15625
4
while True: try: x = int(raw_input('Enter a value: ')) break except: print "Integer values only, please!" continue while True: try: y = int(raw_input('Enter a second value: ')) break except: print "Integer values only, please!" continue add = x+y dif = abs(x-y) mul = x*y quo = x/y rem = x%y print 'T...
true
c8c98a63020ff5971183ce90bd3d4a43d95f0b95
karayount/study-hall
/string_compression.py
1,012
4.53125
5
""" Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the string has only u...
true
6190823da69071ca54625f541a5e90463c9876b7
karayount/study-hall
/highest_product.py
1,388
4.34375
4
"""Given a list_of_ints, find the highest_product you can get from three of the integers. The input list_of_ints will always have at least three integers. >>> find_highest_product([1, 2, 3, 4, 5]) 60 >>> find_highest_product([1, 2, 3, 2, 3, 2, 3, 4]) 36 >>> find_highest_product([0, 1, 2]) 0 >>> find_highest_produc...
true
52cffd996c81e097f71bec337c2dce3d69faecac
Potatology/algo_design_manual
/algorist/data_structure/linked_list.py
1,947
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Linked list-based container implementation. Translate from list-demo.c, list.h, item.h. Add iterator implementation. """ __author__ = "csong2022" class Node: """List node.""" def __init__(self, item, _next=None): self.item = item # data item ...
true
af76bb19fcfa690fa49ea0390ef6ea6e9716f133
Potatology/algo_design_manual
/algorist/data_structure/linked_queue.py
1,773
4.375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Implementation of a FIFO queue abstract data type. Translate from queue.h, queue.c. Implement with singly linked list. Add iterator implementation. """ __author__ = "csong2022" class Node: """Queue node.""" def __init__(self, item, _next=None): self...
true
fd96bd483b82593170856bc0d62ccab97ad33036
abriggs914/CS2043
/Lab2/palindrome.py
466
4.125
4
def palcheck(line, revline): half = (len(line) / 2) x = 0 while(half > x): if(line[x] == revline[x]): x += 1 else: return False return True class palindrome : line = raw_input("Please enter a string:") print(line) print(line[::-1]) revline = (line...
true
85d156b95da272ad1d9cdb86cde272cd842e0fa0
imclab/introduction-to-algorithms
/2-1-insertion-sort/insertion_sort.py
728
4.34375
4
#!/usr/bin/env python # # insertion sort implementation in python # import unittest def insertion_sort(input): """ function which performs insertion sort Input: input -> array of integer keys Returns: the sorted array """ for j in xrange(len(input)): key = inp...
true
51932bdfca69073d247dba1ebc7fa1d6de942a48
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 02/capitulo 02/capitulo 02/exercicio-02-02.py
1,576
4.21875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpres...
false
f58629ab3b18436da63c83b0a14bd1427aaba1a9
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 04/04.04 - Programa 4.3 Calculo do Imposto de Renda.py
995
4.4375
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
false
effd68bbed996738bcdf997fe5a8297adf24edef
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 05/capitulo 05/capitulo 05/exercicio-05-25.py
1,330
4.1875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpres...
false
b467d3cd5637fd886eae302be0fd728110e006a5
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 04/04.05 - Programa 4.4 - Carro novo ou velho, dependendo da idade com else.py
874
4.4375
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
false
49d9a01af9e9b47089bc0923ce444d07d5a558b5
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 02/02.21 - Programa 2.2 Calculo de aumento de salario.py
763
4.3125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
false
f350339f0416e4933dc04243e192d2fa2a994bea
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 08/08.35 - Programa 8.15 Funcao imprime_maior com numero indeterminado de parametros.py
1,028
4.15625
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
false
463ba46cad291a2eae8fb8ffe0b9ddb1491d71c2
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 08/08.41.py
828
4.1875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
false
5e53080b0af272b0d9f0aa69e542bbaaa9af09f5
Azeem-Q/Py4e
/ex84.py
711
4.28125
4
""" 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() method. 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. When the program completes, sort a...
true
4877cfe0219914090f0eb38fec32a4cdafb780ec
mehnazchyadila/Python_Practice
/program45.py
512
4.15625
4
""" Exception Handling """ try: num1 = int(input("Enter Any Integer number : ")) num2 = int(input("Enter any integer number : ")) result = num1 / num2 print(result) except (ValueError,ZeroDivisionError,IndexError): print("You have to insert any integer number ") finally: print("Thanks") def voter...
true
87c7fa65332cd453521fbc957b430fd2878e2eb8
antoniougit/aByteOfPython
/str_format.py
916
4.34375
4
age = 20 name = 'Swaroop' # numbers (indexes) for variables inside {} are optional print '{} was {} years old when he wrote this book'.format(name, age) print 'Why is {} playing with that python?'.format(name) # decimal (.) precision of 3 for float '0.333' print '{0:.3f}'.format(1.0/3) # fill with underscores (_) with...
true
f0816e433a5c7e300f913c571a6fa1145a272706
kangyul/Python
/list.py
1,182
4.5625
5
# List - use "[]"" subway = ["Terry", "Sebastian", "Dylan"] print(subway) # ['John', 'Tim', 'Dylan'] # .index finds an index of an element print(subway.index("Dylan")) # 0 # .append inserts a new element at the end of the list subway.append("Justin") print(subway) # ['John', 'Tim', 'Dylan', 'Justin'] # inserting a...
false
bd2d7b5e14cfcd1afdee8400f7eeadfa24cb13a7
MarkHXB/Python
/Day_02/project.py
688
4.28125
4
""" Tip calculator """ bill = float(input("What was the total bill? $")) tip = int(input("What percentage tip would you like to give? 10, 12 or 15 ")) people = int(input("How many people to split the bill? ")) #my own derivation bill_people = bill/people tip_per_person = bill_people * (tip/100) total_amount_of_tip_per...
false
56a8b63c88b9eb29967cdbbf520db18e443f4ce9
borko81/Algorithms-Data-Structures-Python
/arrays/reverse_array_in_list.py
346
4.1875
4
def reversed_array(nums): start_index = 0 end_index = len(nums) - 1 while end_index > start_index: nums[start_index], nums[end_index] = nums[end_index], nums[start_index] start_index += 1 end_index -= 1 return nums if __name__ == '__main__': n = [1, 2, 3, 4, 5, 6, 7, 8] ...
false
2dfb298dcdf0fe21871ae65949518515a088d7dd
kubos777/cursoSemestralPython
/CodigosClase/Objetos/Abstraccion-Clases-objetos-MetodosY-funcionesdeClase/Persona3.py
1,494
4.125
4
#*-* coding:utf-8*.* class Persona3: #Definimos el constructor def __init__(self,nombre1,apellido1,edad1,estatura1,dinero): self.nombre=nombre1 self.apellido=apellido1 self.edad=edad1 self.estatura=estatura1 self.dinero=dinero print("Hola soy ",self.nombre," ",self.apellido,",tengo",self.edad,"años y mido...
false
28d19efe095993d7b436dddf318ce5f6dd7d2c04
kubos777/cursoSemestralPython
/CodigosClase/TiposDeDatos/conjuntos.py
698
4.125
4
########### # Conjuntos ########### conjunto={1,2,2,3,4,5} print("Tipo de dato: ",type(conjunto)) print(conjunto) conjunto2=set([1,"A","B",2,1]) print(conjunto2) print("Tipo de dato: ",type(cadena)) print("Indexacion: ",cadena[0]) print("Indexacion negativa: ",cadena[-1]) print("Tamaño: ",len(cadena)) print("Conca...
false
8f590bec22c64d0c9d89bfcc765f042883955a02
tprhat/codewarspy
/valid_parentheses.py
807
4.34375
4
# Write a function that takes a string of parentheses, and determines if the order of the parentheses is valid. The # function should return true if the string is valid, and false if it's invalid. # Constraints # 0 <= input.length <= 100 # # Along with opening (() and closing ()) parenthesis, input may contain any vali...
true
657dd462815393c877709d5dcdef2485ec6d8763
lidorelias3/Lidor_Elias_Answers
/python - Advenced/Pirates of the Biss‏/PiratesOfTheBiss‏.py
678
4.3125
4
import re def dejumble(scramble_word, list_of_correct_words): """ Function take scramble word and a list of a words and check what word in the list the scramble word can be :param scramble_word: word in pirate language :param list_of_correct_words: a list of words in our language :return: the ...
true