blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
b5b8ad763c493b7e79cd419bdc08170b1a11dd58
TranshumanSoft/quotient-and-rest
/modulexercises.py
268
4.15625
4
fstnumber = float(input("Introduce a number:")) scndnumber = float(input("Introduce another number:")) quotient = fstnumber//scndnumber rest = fstnumber%scndnumber print(f"Between {fstnumber} and {scndnumber} there's a quotient of {quotient} and a rest of {rest}")
true
b227542479f4396cb317fbb2a42e79ad0d90da31
JhonattanDev/Exercicios-Phyton-29-07
/ex7.py
586
4.28125
4
import math # Pra explicar o programa print("Digite um valor abaixo para ver seu dobro, triplo, e raíz quadrada dele! \n") # Input para o usuário inserir o valor valor = int(input("Digite o valor: ")) # Aqui será realizados os cálculos que definirão as variáveis dobro = valor * 2 triplo = valor * 3 raizQu...
false
bd6b8a39bd376c6bcf9a3a56a4a70453159e05f4
baixianghuang/algorithm
/python3/merge_linked_lists.py
2,215
4.3125
4
class ListNode: def __init__(self, val): self.val = val self.next = None def merge_linked_lists_recursively(node1, node2): """"merge 2 sorted linked list into a sorted list (ascending)""" if node1 == None: return node2 elif node2 == None: return node1 new_h...
true
56bb2d591702c721ed9891e9c60e2fabb0cf80ff
danmorales/Python-Pandas
/pandas-ex19.py
358
4.125
4
import pandas as pd array = {'A' : [1,2,3,4,5,4,3,2,1], 'B' : [5,4,3,2,1,2,3,4,5], 'C' : [2,4,6,8,10,12,14,16,18]} df_array = pd.DataFrame(data=array) print("Arranjo original") print(df_array) print("\n") print("Removendo linhas cuja coluna B tenha valores iguais a 3") df_array_new = df_array[df_array.B != 3] prin...
false
96133f56fdadf80059d2b548a3ae485dee91f770
suhaslucia/Pythagoras-Theorem-in-Python
/Pythagoras Theorem.py
1,114
4.40625
4
from math import sqrt #importing math package print(" ----------Pythagoras Theorem to Find the sides of the Triangle---------- ") print(" ------------ Enter any one side as 0 to obtain the result -------------- ") # Taking the inputs as a integer value from the user base = int(input("Enter the base of the Trian...
true
68e32356ee24ab2bbfc87c4ca3508e89eacd3a0b
Kumar1998/github-upload
/scratch_4.py
397
4.25
4
d1={'Canada':100,'Japan':200,'Germany':300,'Italy':400} #Example 1 Print only keys print("*"*10) for x in d1: print(x) #Example 2 Print only values print ("*"*10) for x in d1: print(d1[x]) #Example 3 Print only values print ("*"*10) for x in d1.values(): print(x) #Example 4 Print only key...
true
f38bd5b4882bd3787e78bcb653ca07d48b1f7093
Kumar1998/github-upload
/python1.py
573
4.3125
4
height=float(input("Enter height of the person:")) weight=float(input("Enter weight of the person:")) # the formula for calculating bmi bmi=weight/(height**2) print("Your BMI IS:{0} and you are:".format(bmi),end='') #conditions if(bmi<16): print("severly underweight") elif(bmi>=16 and bmi<18.5): print(...
true
98f763bd336731f8fa0bd853d06c059dd88d8ca7
septhiono/redesigned-meme
/Day 2 Tip Calculator.py
316
4.1875
4
print('Welcome to the tip calculator') bill = float(input('What was the total bill? $')) tip= float(input('What percentage tip would you like to give? ')) people = float(input("How many people split the bill? ")) pay= bill*(1+tip/100)/people pay=float(pay) print("Each person should pay: $",round(pay,2))
true
fea4e23725b61f8dd4024b2c52065870bbba6da1
rugbyprof/4443-2D-PyGame
/Resources/R02/Python_Introduction/PyIntro_05.py
548
4.15625
4
# import sys # import os # PyInto Lesson 05 # Strings # - Functions # - Input from terminal # - Formatted Strings name = "NIKOLA TESLA" quote = "The only mystery in life is: why did Kamikaze pilots wear helmets?" print(name.lower()) print(name.upper()) print(name.capitalize()) print(name.title()) print(name.isalpha...
true
79d70dca2e86013310ae0691b9a8e731d26e2e75
nidhinp/Anand-Chapter2
/problem36.py
672
4.21875
4
""" Write a program to find anagrams in a given list of words. Two words are called anagrams if one word can be formed by rearranging letters to another. For example 'eat', 'ate' and 'tea' are anagrams. """ def sorted_characters_of_word(word): b = sorted(word) c = '' for character in b: c += character re...
true
a1b103fb6e85e3549090449e71ab3908a46b2e9c
nidhinp/Anand-Chapter2
/problem29.py
371
4.25
4
""" Write a function array to create an 2-dimensional array. The function should take both dimensions as arguments. Value of element can be initialized to None: """ def array(oneD, twoD): return [[None for x in range(twoD)] for x in range(oneD)] a = array(2, 3) print 'None initialized array' prin...
true
4cbcb6d66ee4b0712d064c9ad4053456e515b14b
SandipanKhanra/Sentiment-Analysis
/tweet.py
2,539
4.25
4
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@'] #This function is used to strip down the unnecessary characters def strip_punctuation(s): for i in s: if i in punctuation_chars: s=s.replace(i,"") return s # lists of words to use #As part of the project this hypothetical .t...
true
8c79d7caeb39a173173de7e743a8e2186e2cfc0a
osirisgclark/python-interview-questions
/TCS-tataconsultancyservices2.py
344
4.46875
4
""" For this list [1, 2, 3] return [[1, 2, 3], [2, 4, 6], [3, 6, 9]] """ list = [1, 2, 3] list1 = [] list2 = [] list3 = [] for x in range(1, len(list)+1): list1.append(x) list2.append(2*x) list3.append(3*x) print([list1, list2, list3]) """ Using List Comprehensions """ print([[x, 2*x, 3*x] for x in r...
true
7cc58e0ee75580bc78c260832e940d0fd07b9e2a
minerbra/Temperature-converter
/main.py
574
4.46875
4
""" @Author: Brady Miner This program will display a temperature conversion table for degrees Celsius to Fahrenheit from 0-100 degrees in multiples of 10. """ # Title and structure for for table output print("\nCelsius to Fahrenheit") print("Conversion Table\n") print("Celsius\t Fahrenheit") for celsius in rang...
true
ec2ffda93473b99c06258761740065801e017162
saimkhan92/data_structures_python
/llfolder1/linked_list_implementation.py
1,445
4.28125
4
# add new node in the front (at thr root's side) import sys class node(): def __init__(self,d=None,n=None): self.data=d self.next=n class linked_list(node): def __init__(self,r=None,l=0): self.length=l self.root=r def add(self,d): new_node=node() ...
true
d7fb7ba1b47eb9787dc45de53dd221d75d52a05f
catterson/python-fundamentals
/challenges/02-Strings/C_interpolation.py
1,063
4.78125
5
# Lastly, we'll see how we can put some data into our strings # Interpolation ## There are several ways python lets you stick data into strings, or combine ## them. A simple, but very powerful approach is to us the % operator. Strings ## can be set up this way to present a value we didn't know when we defined the ## s...
true
7d2beba8951d3f799ebd1bdfce8cc7fc5dceac65
NataliVynnychuk/Python_Hillel_Vynnychuk
/Lesson/Lesson 9 - 17.07.py
1,655
4.25
4
# Стандартные библиотеки python # Функции, область видимости, параметры, параметры по умолчанию, типизация import string import random # import random as rnd # print(string.ascii_lowercase) value = random.randint(10, 20) my_list = [1, 2, 3, 10, 20, 30] # my_list = [True, False] my_str = 'qwerty' choice_from_list = r...
false
dc0755a55ce75ca7b9b98acb9d32c4c04663b834
glennlopez/Python.Playground
/SANDBOX/python3/5_loops_branches/break_continue.py
332
4.28125
4
starting = 0 ending = 20 current = starting step = 6 while current < ending: if current + step > ending: # breaks out of loop if current next step is larger than ending break if current % 2: # skips the while loop if number is divisible by 2 continue current += step pri...
true
4f619614442506f1567eb9ecc0de6c989f0c2c21
ashburnere/data-science-with-python
/python-for-data-science/1-2-Strings.py
2,344
4.28125
4
'''Table of Contents What are Strings? Indexing Negative Indexing Slicing Stride Concatenate Strings Escape Sequences String Operations ''' # Use quotation marks for defining string "Michael Jackson" # Use single quotation marks for defining string 'Michael Jackson' # Digitals and spaces in string '1 2...
true
d86edccc25b0e5e6aebddb9f876afd3219c58a65
ashburnere/data-science-with-python
/python-for-data-science/4-3-Loading_Data_and_Viewing_Data_with_Pandas.py
2,038
4.25
4
'''Table of Contents About the Dataset Viewing Data and Accessing Data with pandas ''' '''About the Dataset The table has one row for each album and several columns artist - Name of the artist album - Name of the album released_year - Year the album was released length_min_sec - Length of the album (hours,...
true
29383e08c12d57b53c61ae628026cb065957f9b7
anucoder/Python-Codes
/04_dictionaries.py
513
4.34375
4
my_stuff = {"key1" : "value1", "key2" : "value2"} print(my_stuff["key2"]) print(my_stuff) #maintains no order #multiple datatype with nested dictionaries and lists my_dict = {"key1" : 123, "key2" : "value2", "key3" : {'123' : [1,2,"grabme"]}} print(my_dict["key3"]['123'][2]) #accessing grabme print((my_dict["key3"]...
false
a016c597b8fc5f70e2ab5d861b756d347282289d
jourdy345/2016spring
/dataStructure/2016_03_08/fibonacci.py
686
4.125
4
def fib(n): if n <= 2: return 1 else: return fib(n - 1) + fib(n - 2) # In python, the start of a statement is marked by a colon along with an indentation in the next line. def fastFib(n): a, b = 0, 1 for k in range(n): a, b = b, a+b # the 'a' in the RHS is not the one in the RHS. Python distinguis...
true
be9b1b682cc8b1f6190fead9c3441ce72f512cf4
Nathan-Dunne/Twitter-Data-Sentiment-Analysis
/DataFrameDisplayFormat.py
2,605
4.34375
4
""" Author: Nathan Dunne Date last modified: 16/11/2018 Purpose: Create a data frame from a data set, format and sort said data frame and display data frame as a table. """ import pandas # The pandas library is used to create, format and sort a data frame. # ...
true
8eba1f38d3e13306076467af0694dc65f7d6ed7f
englernicolas/ADS
/python/aula3-extra.py
1,934
4.1875
4
def pesquisar(nome) : if(nome in listaNome) : posicao = listaNome.index(nome) print("------------------------------") print("Nome: ", listaNome[posicao], listaSobrenome[posicao]) print("Teefone: ",listaFone[posicao]) print("-------------------------") else: print(...
false
aa5511e07cc866babfcd2ee3c7f7d6149ba1b740
520Coder/Python-Programming-for-Beginners-Hands-on-Online-Lab-
/Section 6/Student Resources/Assignment Solution Scripts/assignment_lists_02_solution_min_max.py
308
4.21875
4
# Lists # Assignment 2 numbers = [10, 8, 4, 5, 6, 9, 2, 3, 0, 7, 2, 6, 6] min_item = numbers[0] max_item = numbers[0] for num in numbers: if min_item > num: min_item = num if max_item < num: max_item = num print("Minimum Number : ", min_item) print("Maximum Number : ", max_item)
false
bfd6a6a1ce1a215bd6e698e732194b26fd0ec7b4
tjnelson5/Learn-Python-The-Hard-Way
/ex15.py
666
4.1875
4
from sys import argv # Take input from command line and create two string variables script, filename = argv # Open the file and create a file object txt = open(filename) print "Here's your file %r:" % filename # read out the contents of the file to stdout. This will read the whole # file, because the command ends a...
true
6b9281109f10fd0d69dfc54ce0aa807f9592109a
xy008areshsu/Leetcode_complete
/python_version/intervals_insert.py
1,267
4.125
4
""" Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1: Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]. Example 2: Given [1,2],[3,5],[6,7],[8,...
true
7e3a1b29b321ff31e6e635d825ddcfb1668aeb5c
xy008areshsu/Leetcode_complete
/python_version/dp_unique_path.py
1,531
4.15625
4
""" A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? A...
true
c20802ed076df2adc4c4b430f6761742487d37a7
samluyk/Python
/GHP17.py
900
4.46875
4
# Step 1: Ask for weight in pounds # Step 2: Record user’s response weight = input('Enter your weight in pounds: ') # Step 3: Ask for height in inches # Step 4: Record user’s input height = input('Enter your height in inches: ') # Step 5: Change “string” inputs into a data type float weight_float = float(weight) height...
true
0448e9274de805b9dec8ae7689071327677a6abb
wxhheian/hpip
/ch7/ex7_1.py
641
4.25
4
# message = input("Tell me something, and I will repeat it back to you: ") # print(message) # # name = input("Please enter your name: ") # print("Hello, " + name + "!") # prompt = "If you tell us who you are,we can personalize the messages you see." # prompt += "\nWhat is your first name? " # # name = input(prompt) # ...
true
856461a845a16813718ace33b8d2d5782b0d7914
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_3.py
1,891
4.40625
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.3 Description: A palindrome is a word that is spelled the same backward and forward, like “noon” and “redivider”. Recursively, a word is a palindrome if the first and last letters are the same and the middle is a palindrome. The following are functions that take a...
true
6ffba84aafcdb3a4491c8268cba8ea1e2adfdf1e
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_2.py
951
4.3125
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.2 Description: The Ackermann function, A(m,n), is defined: n + 1 if m = 0 A(m,n) = A(m-1, 1) if m > 0 and n = 0 A(m-1, A(m,n-1)) if m > 0 and n > 0 See http://en.wikipedia.org/wiki/Ackermann_function. Write a function named ac...
true
508a885f71292a801877616a7e8132902d1af6c5
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_4.py
643
4.3125
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.4 Description: A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power that takes parameters a and b and returns True if a is a power of b. Note: you will have to think about the base case. """ def is_power(a...
true
8c5faf13fe2952f33dd45000bf56e87bd1a0747e
Shubham1304/Semester6
/ClassPython/4.py
711
4.21875
4
#31st January class #string operations s='hello' print (s.index('o')) #exception if not found #s.find('a') return -1 if not found #------------------check valid name------------------------------------------------------------------------------------- s='' s=input("Enter the string") if(s.isalpha()): print ("Valid ...
true
b896f3577f80daaf46e56a70b046aecacf2288cb
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/17.py
718
4.375
4
''' Write a version of a palindrome recognizer that also accepts phrase palindromes such as "Go hang a salami I'm a lasagna hog.", "Was it a rat I saw?", "Step on no pets", "Sit on a potato pan, Otis", "Lisa Bonet ate no basil", "Satan, oscillate my metallic sonatas", "I roamed under it as a tired nude Maori", "Rise t...
true
f18204d3dab48280b29808613a3e039eab72ec4b
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/22.py
2,488
4.125
4
''' In cryptography, a Caesar cipher is a very simple encryption techniques in which each letter in the plain text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 3, A would be replaced by D, B would become E, and so on. The method is named after Julius Caesar, who...
false
40589034a276810b9b22c31ca519399df66bd712
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/02.py
277
4.125
4
''' Define a function max_of_three() that takes three numbers as arguments and returns the largest of them. ''' def max_of_three(a,b,c): if a>b and a>c: print a elif b>c and b>a: print b else: print c print max_of_three(0,15,2)
true
fc24e9ff6df3c2d766e719892fae9426e33f81f6
Isonzo/100-day-python-challenge
/Day 8/prime_number_checker.py
460
4.15625
4
def prime_checker(number): if number == 0 or number == 1: print("This number is neither prime nor composite") return prime = True for integer in range(2, number): if number % integer == 0: prime = False break if prime: print("It's a...
true
133c061729e061076793a84878ad0cb4347fc016
M0673N/Programming-Fundamentals-with-Python
/exam_preparation/final_exam/05_mock_exam/03_problem_solution.py
1,713
4.15625
4
command = input() map_of_the_seas = {} while not command == "Sail": city, population, gold = command.split("||") if city not in map_of_the_seas: map_of_the_seas[city] = [int(population), int(gold)] else: map_of_the_seas[city][0] += int(population) map_of_the_seas[city][1] += int(gold...
false
ba8907050af53baa67dcbbaba314ab151ea20d41
M0673N/Programming-Fundamentals-with-Python
/04_functions/exercise/04_odd_and_even_sum.py
261
4.28125
4
def odd_even_sum(num): odd = 0 even = 0 for digit in num: if int(digit) % 2 == 0: even += int(digit) else: odd += int(digit) print(f"Odd sum = {odd}, Even sum = {even}") num = input() odd_even_sum(num)
false
6e8ac25e465a4c45f63af8334094049c0b660c4b
IrisCSX/LeetCode-algorithm
/476. Number Complement.py
1,309
4.125
4
""" Promblem: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero bit in the integer’s binary representation. Example...
true
124f02540d0b7712a73b5d2e2e03868ac809b791
anikaator/CodingPractice
/Datastructures/HashMap/Basic/Python/main.py
687
4.15625
4
def main(): # Use of dict contacts = {} contacts['abc'] = 81 contacts['pqr'] = 21 contacts['xyz'] = 99 def print_dict(): for k,v in contacts.items(): print 'dict[', k, '] = ', v print("Length of dict is %s" % len(contacts)) print("Dict contains:") print_dic...
true
e2350657520b17cc90a0fb9406a4cc6f99cee53a
CookieComputing/MusicMaze
/MusicMaze/model/data_structures/Queue.py
1,532
4.21875
4
from model.data_structures.Deque import Deque class Queue: """This class represents a queue data structure, reinvented out of the wheel purely for the sake of novelty.""" def __init__(self): """Constructs an empty queue.""" self._deque = Deque() def peek(self): """Peek at the...
true
9bc3ae714f881fd44890ed63429dc9bc4de89b5c
codewithgauri/HacktoberFest
/python/Learning Files/10-List Data Type , Indexing ,Slicing,Append-Extend-Insert-Closer look at python data types.py
1,129
4.28125
4
l=[10,20,22,30,40,50,55] # print(type(l)) # 1 Lists are mutable = add update and delete # 2 Ordered = indexing and slicing # 3 Hetrogenous # indexing and slicing: # print(l[-1]) # print(l[1:3]) #end is not inclusive # reverse a Lists # print(l[::-1]) # if you want to iterate over alternate characters # for value in l...
true
453eb80f8c7d3c8353c7288f4beea8e3f7e0c1c5
codewithgauri/HacktoberFest
/python/Cryptography/Prime Numbers/naive_primality_test.py
576
4.21875
4
##Make sure to run with Python3 . Python2 will show issues from math import sqrt from math import floor def is_prime(num): #numbers smaller than 2 can not be primes if num<=2: return False #even numbers can not be primes if num%2==0: return False #we have already checked numbers < 3 #finding primes up to N we...
true
51d1cb5a523fa102734d50143a3b9eab17faf2cb
codewithgauri/HacktoberFest
/python/Learning Files/13-Dictionary Data Types , Storing and Accessing the data in dictionary , Closer look at python data types.py.py
1,580
4.3125
4
# dict: # 1. mutable # 2.unordered= no indexing and slicing # 3.key must be unque # 4.keys should be immutable # 5. the only allowed data type for key is int , string , tuple # reason mutable data type is not allowed # for example # d={"emp_id":101 , [10,20,30]:100,[10,20]:200} # if we add an element into [10,20] of 30...
true
2725b85849ce224e97685919f148cc9807e60d83
bdngo/math-algs
/python/checksum.py
1,155
4.21875
4
from typing import List def digit_root(n: int, base: int=10) -> int: """Returns the digital root for an integer N.""" assert type(n) == 'int' total = 0 while n: total += n % base n //= base return digit_root(total) if total >= base else total def int_to_list(n: int, base: int=10) ...
true
e64687b9baaa75ae481ea65ed9e2cd26a203e41a
kimoror/python-practice
/practice1_extra/main.py
2,722
4.25
4
# Ответы на теоретические вопросы находятся в файле AnswersOnQuestions.md """ Попробуйте составить код для решения следующих задач. Из арифметических операций можно использовать только явно указанные и в указанном количестве. Входным аргументом является переменная x. """ def no_multiply(x): if x == 12: r...
false
52c44bf0aa15ba0bfcc1abda81fffefba6be075c
DistantThunder/learn-python
/ex33.py
450
4.125
4
numbers = [] # while i < 6: # print("At the top i is {}".format(i)) # numbers.append(i) # # i = i + 1 # print("Numbers now: ", numbers) # print("At the bottom i is {}\n{}".format(i, '-')) def count_numbers(count): count += 1 for i in range(0, count): numbers.append(i) return 0...
true
1fe48d3656b9437f43b79afa4ba5d9f2ffe13c2f
adamfitzhugh/python
/kirk-byers/Scripts/Week 1/exercise3.py
942
4.375
4
#!/usr/bin/env python """Create three different variables: the first variable should use all lower case characters with underscore ( _ ) as the word separator. The second variable should use all upper case characters with underscore as the word separator. The third variable should use numbers, letters, and undersco...
true
d925d4b637199ad159b36b33dcb0438ccca0f95a
adamfitzhugh/python
/kirk-byers/Scripts/Week 5/exercise3.py
1,788
4.15625
4
""" Similar to lesson3, exercise4 write a function that normalizes a MAC address to the following format: 01:23:45:67:89:AB This function should handle the lower-case to upper-case conversion. It should also handle converting from '0000.aaaa.bbbb' and from '00-00-aa-aa-bb-bb' formats. The function should have one...
true
2c9a6858ef76026d57e96ce85724e7c062e657d5
nileshmahale03/Python
/Python/PythonProject/5 Dictionary.py
1,487
4.21875
4
""" Dictionary: 1. Normal variable holds 1 value; dictionary holds collection of key-value pairs; all keys must be distinct but values may be repeated 2. {} - curly bracket 3. Unordered 4. Mutable 5. uses Hashing internally 6. Functions: 1. dict[] : returns value at specified index 2. len() ...
true
e3f5d349f45c8d01cd939727a9bbd644ddaa0bdd
changjunxia/auto_test_example1
/test1.py
228
4.125
4
def is_plalindrome(string): string = list(string) length = len(string) left = 0 right = length - 1 while left < right: if string[left] != string[right]: return False left += 1 right -= 1 return True
true
a1a7e5faad35847f22301b117952e223857d951a
nestorsgarzonc/leetcode_problems
/6.zigzag_convertion.py
1,459
4.375
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conve...
true
e2349b63116bb7f3e83aa436c41175efda4a8d9d
llNeeleshll/Python
/section_3/string_play.py
290
4.15625
4
text = "This is awesome." # Getting the substring print(text[8:]) print(text[0:4]) # text[start:end:step] print(text[0:14:2]) print(text[0::2]) # Reversing the string print(text[::-1]) # Print a word 10 times? print("Hello " * 10) print("Hello " * 10 + "World!") print("awe" in text)
true
2690856645451099474cbed49d688a0fecd653f4
KaviyaMadheswaran/laser
/infytq prev question.py
408
4.15625
4
Ex 20) 1:special string reverse Input Format: b@rd output Format: d@rb Explanation: We should reverse the alphabets of the string by keeping the special characters in the same position s=input() alp=[] #index of char ind=[] for i in range(0,len(s)): if(s[i].isalpha()): alp.append(s[i]) else: ind.append(i) rev=alp...
true
50e3bc5493956708bf1897a74600cd9639777bf8
KaviyaMadheswaran/laser
/w3 resource.py
403
4.1875
4
Write a Python program to split a given list into two parts where the length of the first part of the list is given. Go to the editor Original list: [1, 1, 2, 3, 4, 4, 5, 1] Length of the first part of the list: 3 Splited the said list into two parts: ([1, 1, 2], [3, 4, 4, 5, 1]) n=int(input()) l=list(map(int,input().s...
true
fbcf1c36b34a8565e0153b403fbcb185782890ba
KaviyaMadheswaran/laser
/w3 resource6.py
392
4.15625
4
Write a Python program to flatten a given nested list structure. Go to the editor Original list: [0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]] Flatten list: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120] l=[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]] l1=[] for i in l: if(isinstan...
false
5539d4170fa7ecc1a9a97ba4aa3ed2f23650bd1a
KaviyaMadheswaran/laser
/Birthday Cake candle(Hackerrank).py
490
4.125
4
Output Format Return the number of candles that can be blown out on a new line. Sample Input 0 4 3 2 1 3 Sample Output 0 2 Explanation 0 We have one candle of height 1, one candle of height 2, and two candles of height 3. Your niece only blows out the tallest candles, meaning the candles where height = 3. ...
true
a5ed73ac78f673fa965b551bef169860cd38a658
timclaussen/Python-Examples
/OOPexample.py
441
4.25
4
#OOP Example #From the simple critter example, but with dogs class Dog(object): """A virtual Dog""" total = 0 def _init_(self, name): print("A new floof approaches!") Dog.total += 1 #each new instance adds 1 to the class att' total self.name = name #sets the constructor inp...
true
7ca7a468dcc8aea1cc45757f9430b5fa0c0d736f
JuanHernandez2/Ormuco_Test
/Ormuco/Strings comparator/comparator.py
1,188
4.25
4
import os import sys class String_comparator: """ Class String comparator to compare two strings and return which is greater, less or equal than the other one. Attributes: string_1: String 1 string_2: String 2 """ def __init__(self, s1, s2): """ Class constr...
true
1ed4ea179560b5feec261b094bdbe5b2848b4e03
Sharmaanuj10/Phase1-basics-code
/python book/book projects 1/4-7/input while loop/flag.py
321
4.1875
4
active = True print("if you want to quit type quit") while active: message = input("Enter your message: ") if message == 'quit': # break # to break the loop here active = False #comtinue # to execute left over code exiting the if else: print(message) ...
true
0227e6263035a7b7e6cf67dadde3eb91576afc0b
Sharmaanuj10/Phase1-basics-code
/python book/book projects 1/4-7/input while loop/deli.py
710
4.28125
4
user_want = {} # fistly define a dictonairy empty poll_active = True while poll_active: name = input('Enter your name: ') want = input('if you visit one place in the world where you visit? ') repeat = input('waant to know others wnats (yes,no)? ') # after input store the data at dictionar...
true
8592b3147c28ef1b09589c048dfa30e0eb87aa5a
Sharmaanuj10/Phase1-basics-code
/python book/Python/password.py/password 1.5.py/password1.5.py
1,287
4.28125
4
name = input("Enter your username: ") passcode = input("Enter you password: ") # upper is used to capatilize the latter name = name.upper() # all the password saved def webdata(): webdata= input("Enter the key word : ") user_passwords = { 'youtube' : 'subscribe', # here now you can save...
true
213ebf4489f815cf959de836a11e2339ca8bcfaa
rsleeper1/Week-3-Programs
/Finding Max and Min Values Recursively.py
2,148
4.21875
4
#Finding Max and Min Values #Ryan Sleeper def findMaxAndMin(sequence): #This method finds the max and min values of a sequence of numbers. if len(sequence) < 2: #This catches a sequence that doesn't have enough numbers to compare (less than 2) and returns the invalid sequence. print("Ple...
true
d075b9df570b98066efa80959ee3d102bca91614
chigozieokoroafor/DSA
/one for you/code.py
259
4.28125
4
while True: name = input("Name: ") if name == "" or name==" ": print("one for you, one for me") raise Exception("meaningful message required, you need to put a name") else: print(f"{name} : one for {name}, one for me")
true
28e8f771a7968081d3ced6b85ddec657163ad7d1
avi527/Tuple
/different_number_arrgument.py
248
4.125
4
#write a program that accepts different number of argument and return sum #of only the positive values passed to it. def sum(*arg): tot=0 for i in arg: if i>0: tot +=i return tot print(sum(1,2,3,-4,-5,9))
true
711646003de502ae59915ebcd3fff47b56b0144d
Wh1te-Crow/algorithms
/sorting.py
1,318
4.21875
4
def insertion_sorting(array): for index in range(1,len(array)): sorting_part=array[0:index+1] unsorting_part=array[index+1:] temp=array[index] i=index-1 while(((i>0 or i==0) and array[i]>temp)): sorting_part[i+1]=sorting_part[i] sorting_part[i]=temp ...
true
315bc09a11f42cd7b010bee38ac8fa52d06e172c
calazans10/algorithms.py
/basic/var.py
242
4.125
4
# -*- coding: utf-8 -*- i = 5 print(i) i = i + 1 print(i) s = '''Esta é uma string de múltiplas linhas. Esta é a segunda linha.''' print(s) string = 'Isto é uma string. \ Isto continua a string.' print(string) print('O valor é', i)
false
34ae06f5fea1a3886a7208998a729c3900280424
gugry/FogStreamEdu
/lesson1_numbers_and_strings/string_tusk.py
261
4.125
4
#5.Дана строка. Удалите из нее все символы, чьи индексы делятся на 3. input_str = input() new_str = input_str[0:3]; for i in range(4,len(input_str), 3): new_str = new_str + input_str[i:i+2] print (new_str)
false
358cd42a66be05b4606d01bcb525afa140181ccc
PRASADGITS/shallowcopyvsdeepcopy
/shallow_vs_deep_copy.py
979
4.5
4
import copy ''' SHALLOW COPY METHOD ''' old_list = [[1,2,3],[4,5,6],[7,8,9]] new_list=copy.copy(old_list) print ("old_list",old_list) print ("new_list",new_list,"\n") old_list.append([999]) print ("old_list",old_list) print ("new_list",new_list,"\n") old_list[1][0]="x" # both changes Bec...
false
ba0bf77d3202493747e94c0a686c739d6cb98e9f
srisreedhar/Mizuho-Python-Programming
/Session-18-NestedConditionals/nestedif.py
510
4.1875
4
# ask user to enter a number between 1-5 and print the number in words number=input("Enter a number between 1-5 :") number=int(number) # if number == 1: # print("the number is one") # else: # print("its not one") # Nested conditions if number==1: print("number is one") elif number==2: print("num...
true
04c4b07e6e7e980e7d759aff14ce51d38fa89413
davelpat/Fundamentals_of_Python
/Ch2 exercises/employeepay.py
843
4.21875
4
""" An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours, plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours, and total overtime hours an...
true
d5367ee9332da2c450505cb454e4e8dac87b2bf8
davelpat/Fundamentals_of_Python
/Student_Files/ch_11_student_files/Ch_11_Student_Files/testquicksort.py
1,817
4.15625
4
""" File: testquicksort.py Tests the quicksort algorithm """ def quicksort(lyst): """Sorts the items in lyst in ascending order.""" quicksortHelper(lyst, 0, len(lyst) - 1) def quicksortHelper(lyst, left, right): """Partition lyst, then sort the left segment and sort the right segment.""" if left ...
true
1a7183d7758f27abb21426e84019a9ceeb5da7c7
davelpat/Fundamentals_of_Python
/Ch3 exercises/right.py
1,344
4.75
5
""" Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square of one side equals the sum of the squares of the other two sides. Use "The t...
true
82808ac569c685a2b864fd668edebbb7264cd07d
davelpat/Fundamentals_of_Python
/Ch9 exercises/testshapes.py
772
4.375
4
""" Instructions for programming Exercise 9.10 Geometric shapes can be modeled as classes. Develop classes for line segments, circles, and rectangles in the shapes.py file. Each shape object should contain a Turtle object and a color that allow the shape to be drawn in a Turtle graphics window (see Chapter 7 for detai...
true
f9a84cff7e4e9c4a92167506a09fcf09726ecfc1
davelpat/Fundamentals_of_Python
/Ch3 exercises/salary.py
1,387
4.34375
4
""" Instructions Teachers in most school districts are paid on a schedule that provides a salary based on their number of years of teaching experience. For example, a beginning teacher in the Lexington School District might be paid $30,000 the first year. For each year of experience after this first year, up to 10 ye...
true
2ee467b7f70e740bce32e857df97bd311034e494
davelpat/Fundamentals_of_Python
/Ch4 exercises/decrrypt-str.py
1,106
4.5625
5
""" Instructions for programming Exercise 4.7 Write a script that decrypts a message coded by the method used in Project 6. Method used in project 6: Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypt...
true
5b3f98828c1aa52309d9450094ecb3ab990bae91
davelpat/Fundamentals_of_Python
/Ch4 exercises/encrypt-str.py
1,246
4.53125
5
""" Instructions for programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string on...
true
8b70613ee7350c54156a4eb076f11b82356055f7
davelpat/Fundamentals_of_Python
/Ch3 exercises/population.py
1,828
4.65625
5
""" Instructions A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms The rate of growth (a real number greater than 1) The number of hours it takes to achieve this rate A number of hours during which the population grows For example, one might start wi...
true
a18806eeb1213b7fae5c963fdbf08a307d7d3fc2
palomaYPR/Introduction-to-Python
/CP_P21-1_TipoOperadores.py
418
4.125
4
# EUP que permita ingresar dos números y un operador, de acuerdo al operador ingresado se realizara la debida # operacion. num1 = int(input('Ingresa el 1er número: ')) num2 = int(input('Ingresa el 2do número: ')) ope = str(input('Ingresa el operador: ')) if ope == '*': res = num1 + num2 elif ope == '/': ...
false
f9c25e2e6239587a86696c5e868feca3ab8beac0
palomaYPR/Introduction-to-Python
/CP_P14_AreaCirculo.py
282
4.125
4
# Elabora un programa que calcule el area de un circulo # Nota: Tome en cuenta que la formula es A = (pi * r^2) import math message = input('Ingresa el radio del circulo: ') r = int(message) area = math.pi * r**2 #area = math.pi * math.pow(r,2) print('El area es: ',area)
false
d4a8cd543636b4375918bfe64430df051604c4da
nachoaz/Data_Structures_and_Algorithms
/Stacks/balanced_brackets.py
745
4.15625
4
# balanced_brackets.py """ https://www.hackerrank.com/challenges/balanced-brackets """ from stack import Stack def is_balanced(s): if len(s) % 2 == 1: return 'NO' else: stack = Stack() counterparts = {'{':'}', '[':']', '(':')'} for char in s: if char in c...
true
71e18ee05051d083fa00285c9fbc116eca7fb3f3
bayl0n/Projects
/stack.py
794
4.25
4
# create a stack using a list class Stack: def __init__(self): self.__stack = list() def __str__(self): return str(self.__stack) def push(self, value): self.__stack.append(value) return self.__stack[len(self.__stack) -1] def pop(self): if len(self.__stack) > 0...
false
15198370140d3b04074d6647eda200767cc2479d
rahulpawargit/UdemyCoursePractice
/Tuples.py
290
4.1875
4
""" Tuples are same as list. The diffferance between list and tuples. Tuples are unmutalble. Tuples add using parenthesis """ my_tuple=(1, 2, 3, 4,3, 3, 3) print(my_tuple) print(my_tuple[1]) print(my_tuple[1:]) print(my_tuple[::-1 ]) print(my_tuple.index(3)) print((my_tuple.count(3)))
true
186ea3c70994726a8b6fe9ea2d00c44e116cbc16
zaochnik555/Python_1_lessons-1
/lesson_02/home_work/hw02_easy.py
2,044
4.125
4
# Задача-1: # Дан список фруктов. # Напишите программу, выводящую фрукты в виде нумерованного списка, # выровненного по правой стороне. # Пример: # Дано: ["яблоко", "банан", "киви", "арбуз"] # Вывод: # 1. яблоко # 2. банан # 3. киви # 4. арбуз # Подсказка: воспользоваться методом .format() print("Задача 1") frui...
false
f7ec1c0eca2e27e733473040f284640f75c37a80
flahlee/Coding-Dojo
/pythonFundamentals/string_list.py
586
4.125
4
#find and replace words = "It's thanksgiving day. It's my birthday, too!" day = 'day' print words.find(day) print words.replace(day, "month") #min and max x = [2,54,-2,7,12,98] print min(x) print max(x) #first and last x = ["hello", 2, 54, -2, 7, 12, 98, "world"] newX= [x[0],x[7]] print newX #new list '''sort list f...
true
75f2c8f77f19883b41af604e0bb70318243efcd5
Sameer19A/Python-Basics
/HelloWorld.py
243
4.28125
4
#Compulsory Task 3 name = input("Enter your name: ") age = input("Enter your age: ") print(name) #prints user entered name print(age) #prints user entered age print("") #prints a new empty line print("Hello World!")
true
286cb30b15f984cb922dc229773e6e2eda569ddd
Shreyasi2002/CODE_IN_PLACE_experience
/Section2-Welcome to python/8ball.py
954
4.1875
4
""" Simulates a magic eight ball. Prompts the user to type a yes or no question and gives a random answer from a set of prefabricated responses. """ import random RESPONSES = ["As I see it, yes.", "Ask again later.", "Better not to tell you now." , "Cannot predict now.", "Concentrate and ask again.", "Don't count on i...
true
91cc4ff7b8e7e275ba61d799d81c8eecb7587b7c
Shreyasi2002/CODE_IN_PLACE_experience
/CoreComplete/leap.py
930
4.4375
4
""" Example of using the index variable of a for loop """ def main(): pass def is_divisible(a, b): """ >>> is_divisible(20, 4) True >>> is_divisible(12, 7) False >>> is_divisible(10, 10) True """ return a % b == 0 def is_leap_year(year): """ Returns Boolean indicating ...
true
d3c9754c8666e8bf95f191e7e4bba9249a10df59
Maryam200600/Task2.2
/4.py
299
4.21875
4
# Заполнить список ста нулями, кроме первого и последнего элементов, которые должны быть равны единице for i in range(0,101): if i==0 or i==100: i='1' else: i='0' print(i, end=' ')
false
edf4a58d87d2c5cef9a6e06e2ace05ad5096268d
djoo1028/Euler
/euler01.py
1,636
4.3125
4
''' 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. ''' def findSum(arg1): a = arg1 # input value will be range for the summation arr3 = [] # multip...
true
f0b39ddce7802ef09e39599f494c3461fc18007f
rati90/mjeraarmjera
/service/trustorNot.py
2,590
4.15625
4
def hands_table_clear(table, said_cards): """ for some decisions clears table and say lists :param tuple player_hands_table_say not cleared table and say :return tuple player_hands_table_say cleared table and say """ table.clear() said_cards.clear() return table, said_cards def do_yo...
true
573ed22b1e142cdb4e136d7b6c39e697bfe6b917
dosdarwin/BMI
/bmi.py
410
4.21875
4
height = (float(input('what is your height(in cm):')))/100 weight = float(input('what is your weight(in kg):')) BMI = float(weight/(height*height)) if BMI < 18.4: print('your BMI is',BMI, ',too light!') elif 18.5 <= BMI <= 23.9: print('your BMI is', BMI, ',perfect!') elif 24 <= BMI <= 26.9: print('your BMI ...
false
d999688c971c11599747b52a8f1630c1f56e3542
Ryandalion/Python
/Repetition Structures/Distance Travelled/Distance Travelled/Distance_Travelled.py
777
4.4375
4
# Function that asks the user to input the number of hours they have driven and the speed at which they were driving, the program will then calculate the total distance travelled per hour distanceTravelled = 0; numHours = int(input("Please enter the number of hours you drove: ")); speed = int(input("Please enter the ...
true
3d9f49a20ba365934e8a47255bde04df1db32495
Ryandalion/Python
/Dictionaries and Sets/File Analysis/File Analysis/File_Analysis.py
1,525
4.1875
4
# Program will read the contents of two text files and determine a series of results between the two, such as mutual elements, exclusive elements, etc. def main(): setA = set(open("file1.txt").read().split()); # Load data from file1.txt into setA setB = set(open("file2.txt").read().split()); # Load data from f...
true
564b68912dd8b44e4001a22d92ff18471a55fbe4
Ryandalion/Python
/Decision Structures and Boolean Logic/Age Calculator/Age Calculator/Age_Calculator.py
568
4.4375
4
# Function takes user's age and tells them if they are an infant, child, teen, or adult # 1 year old or less = INFANT # 1 ~ 13 year old = CHILD # 13 ~ 20 = TEEN # 20+ = ADULT userAge = int(input('Please enter your age: ')); if userAge < 0 or userAge > 135: print('Please enter a valid age'); else: if userAge <...
true
8a4d3456f828edb3893db4e6dd836873344b91e9
Ryandalion/Python
/Functions/Future Value/Future Value/Future_Value.py
1,862
4.59375
5
# Program calculates the future value of one's savings account def calculateInterest(principal, interestRate, months): # Function calculates the interest accumulated for the savings account given the arguments from the user interestRate /= 100; # Convert the interest rate into a decimal futureValue = principal...
true
39cd605853421bafc6abaeda2b905e3bf06b6c6e
Ryandalion/Python
/Functions/Rock, Paper, Scissors!/Rock, Paper, Scissors!/Rock__Paper__Scissors_.py
2,151
4.46875
4
# Program is a simple rock paper scissors game versus the computer. The computer's hand will be randomly generated and the user will input theirs. Then the program will determine the winner. If it is a tie, a rematch will execute import random; # Import random module to use randint def generate_random(): # Generate a...
true
c19b84caf9895177da8ccbcbd845ef5f03653e4d
Ryandalion/Python
/Functions/Fat and Carb Calorie Calculator/Fat and Carb Calorie Calculator/Fat_and_Carb_Calorie_Calculator.py
1,465
4.34375
4
# Function that gathers the carbohyrdates and fat the user has consumed and displays the amount of calories gained from each def fatCalorie(fat): # Function calculates the calories gained from fat calFat = fat * 9; print("The total calories from",fat,"grams of fat is", calFat,"calories"); def carbCalorie(car...
true