blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
3b922b231dd58ac97104bb606bd44afae63e2393
noozip2241993/homework4
/task1.py
671
4.34375
4
import random def generating_defining_prime_number(): """Checking whether the argument is a prime number or not""" for j in range(6): #generating six random numbers num = random.randrange(1,101) if num > 1: #prime numbers are greater than 1 for i in range(2,num): #check for factors ...
true
ab4612f127ea1205fddf615ea520a2dbab9821dc
cishocksr/cs-module-project-algorithms-cspt9
/moving_zeroes/moving_zeroes.py
566
4.1875
4
''' Input: a List of integers Returns: a List of integers ''' def moving_zeroes(arr): positive = [] negative = [] zero = [] for i in range(len(arr)): if arr[i] > 0: positive.append(arr[i]) elif arr[i] < 0: negative.append(arr[i]) else: zero....
true
29da3a12725b989dea553c04e0493371cdbc57ff
strivehub/conventional-algorithm-
/quick_sort.py
861
4.34375
4
#这是一个利用python实现的快速排序算法 def quick_sort(arr): if len(arr)<2: #判断数组长度,如果数组里面只有一个元素,则不需要排序,直接返回 return arr else: #如果长度大于2个及以上,则需要排序 value = arr[0] #设定一个基准值,这里我们每次都取数组第一个,也阔以取数组其他值 min_value = [i for i in arr[1:] if i <=value] #将数组中小于等于基准值放在这个数组中 max_value = [i for i in arr[1:] if i>value] #将数组中大于基...
false
1a7a5c3a0b5b5cd2858ce8c186ff63af040ed238
ashnashahgrover/CodeWarsSolutions
/practiceForPythonInterview/pythonEx6.py
519
4.34375
4
# Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched. # # Examples # pig_it('Pig latin is cool') # igPay atinlay siay oolcay # pig_it('Hello world !') # elloHay orldway ! def pig_it(text): text = text.split(" ") new_text = [] for...
true
7f238c4217229748ef202dc4361832fa3211f331
ThapaKazii/Myproject
/test19.py
416
4.1875
4
# From a list separate the integers, stings and floats elements into three different lists. list=["bibek",44,'puri',288.8,'gaida',33,12.0,] list2=[] list3=[] list4=[] for x in list: if type(x)==int: list2.append(x) elif type(x)==float: list3.append(x) elif type(x)==str: list4.appen...
true
c449b076d13c203c8b3012cdc2909eac3008662b
nerugattiraju/interview-questions
/generator.py
277
4.40625
4
#generators are used to creating the iterators with the different approches from time import sleep n=int(input("enter the number")) print("contdown start") def countdown(n): while n>0: yield n n=n-1 sleep(0.3) x=countdown(n) for i in x: print(i)
true
7939224df96eb3ca863d0a6372dabed86ee25436
nerugattiraju/interview-questions
/class functions.py
448
4.125
4
class Employee: def __init__(self,name,id,age): self.name=name self.id=id self.age=age x=Employee("raju",100,24) print(getattr(x,'name'))#get the attribute of the object. setattr(x,'age',34)#set the perticular attribute of the object. print(getattr(x,'age')) #delattr(x,'id')#delete the peric...
true
808e78714e7cafbc102de51be052bd3d737c20e8
avi202020/sailpointbank
/Bank.py
358
4.125
4
from typing import Dict import Account """ Bank keeps track of users by keeping a map of user name to Account instance. Every time a new Account is created, it will add it to its map. """ class Bank: def __init__(self): self.accounts: Dict[str, Account] = {} def add_account(self, name, account): ...
true
e1a8475f8e89deecb8de69b1fc8205635c08cbdf
lamessk/CPSC-217
/Assignment2/Assignment2.py
2,143
4.25
4
#Lamess Kharfan, Student Number: 10150607. CPSC 217. #Draw a climograph displaying temperature and precipitation data for all #12 months of the year using 24 input statements, 12 for temperature and 12 for #precipitation. Line graph will be repersenative of temperature data and Bar #graph is representative of the preci...
true
206225b6030be7c606ca115d31b0b4e8804fa4b4
asen1995/Python-Learning
/basic/dataStructures.py
2,604
4.28125
4
import collections # list example from basic.Stack import Stack def list(): list = ["apple", "banana", "cherry"] print(list) print("len is ", len(list)) print(type(list)) list.append("orange") print(list) list.insert(0, "Asen") print(list) list.remove("Asen") print(list) ...
false
2bf5f4ead2ab7718b6849f03e90f852e462d8e74
pi6220na/CapLab1
/guess.py
596
4.125
4
#Lab1 Jeremy Wolfe # Guess a number import random random_pick = random.randint(1,10) print('computer random number is : ' + str(random_pick)) guessed_number = input('Guess a number between 1 and 10: ') guessed_number = int(guessed_number) while True: if random_pick == guessed_number: prin...
true
ac72560db9c6fb4aa2861c059245eeaa979b6808
jpchato/a-common-sense-guide-to-data-structures-and-algorithms
/binary_search.py
1,471
4.375
4
def binary_search(arr, val): # first , we establish the lower and upper bounds of where the value we're searching for can be. To start, the lower boudn is the first value in the array, while the upper bound is the last value lower_bound_index = 0 upper_bound_index = len(arr) - 1 # we begin a loop i...
true
1e46263668a98a2dceeb41f653dc22354597e323
manojkotte/gunturClasses
/classTenOnline.py
2,303
4.3125
4
Derived data types ------------------- collections ------------ lists tuples dictionaries -------------------------------------- Lists [ ] ----- --> MUTABLE objects --> Iterable objects --> collection --> stores heterogenous elements --> indexed --> sliced --> concatenated --> operated by using functions --> Nes...
false
34555e8f777b09f08c25d1b4e13f693010b41064
lcsm29/MIT6.0001
/lecture_code/in_class_questions/lec2_in-class.questions.py
1,165
4.15625
4
# 1. Strings # What is the value of variable `u` from the code below? once = "umbr" repeat = "ella" u = once + (repeat+" ")*4 #umbrella ella ella ella # 2. Comparisons # What does the code below print? pset_time = 15 sleep_time = 8 print(sleep_time > pset_time) # False derive = True drink = False both = drink and deri...
true
9704dbce6358c457c123d424f1b11b89cad08452
zois-tasoulas/ThinkPython
/chapter8/exercise8_4.py
849
4.1875
4
#This will return True for the first lower case character of s def any_lowercase1(s): for c in s: if c.islower(): return True else: return False #This will alsways return True as islower() is invoked on the character 'c' def any_lowercase2(s): for c in s: if 'c'.islower(): return 'True' else: ret...
true
32c9dd2e13bf06dfc108a5cbd9d3b874f6ad54d8
zois-tasoulas/ThinkPython
/chapter6/exercise6_3.py
434
4.125
4
def first(word): return word[0] def last(word): return word[-1] def middle(word): return word[1:-1] def is_palindrome(word): if len(word) == 0 or len(word) == 1: return True elif len(word) == 2: return first(word) == last(word) else: return first(word) == last(word) and is_palindrome(middle(word)) retu...
true
5a49c755e899791e44508020c26bd00dd37f299c
drewvlaz/CODE2RACE
/SOLUTIONS/reverse_aword.py
301
4.125
4
from __future__ import print_function try: raw_input # Python 2 except NameError: raw_input = input # Python 3 def reverse_string(string): return " ".join(string.split(" ")[::-1]) string = raw_input('Enter a string containing multiple words:') print(reverse_string(string))
false
04d85f17c4b854dc6822b1f33ea7993daceb38b4
drewvlaz/CODE2RACE
/SOLUTIONS/reverse-Word-Python.py
212
4.40625
4
#Get User word user_input= raw_input("Please input your word ") #reverse the user input reverse_user_input =user_input[::-1] #Print the reverse word print ("This is reverse of your word : " + reverse_user_input)
true
21663c061e8a16c3c9e56129ed778358c7625f00
annieshenca/LeetCode
/98. Validate Binary Search Tree.py
947
4.125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isValidBST(self, root): """ :type root: TreeNode :rtype: bool """ # Set upper...
true
47598a547fe44cea7968834b2d4c110a99cd96d8
prachichikshe12/HelloWorld
/Arithmatic.py
348
4.375
4
print(10 + 3) print(10 - 3) print(10 * 3) print(10 / 3) print(10 // 3) # print division calculation ans in Integer print(10 % 3) # prints remainder print(10 ** 3) # 10 to the power 3 #Augmented Assignment Operator x = 10 #x = x +3 #x +=3 x -= 3 print(x) # operator precedence #x= (2+3)* 10 -3 x = 2+6*2*2 print(x) ...
true
2fe7e7a8758a9a89632d255c8813a2eb2e128125
Shariarbup/Shariar_Python_Algorithm
/find_a_first_uppercase_character/find_a_first_uppercase_character.py
921
4.15625
4
#Given a String, find a first uppercase character #Solve both an iterative and recursive solution input_str_1 = 'lucidProgramming' input_str_2 = 'LucidProgramming' input_str_3 = 'lucidprogramming' def find_uppercase_iterative(input_str): for i in range(len(input_str)): if input_str[i].isupper(): ...
true
e68d56d6766a20bfec980011ce9619996315c089
AbdelOuaffar/python_work
/November_11/convert_binary.py
774
4.15625
4
def break_binary_single_digit(string): list_binary_digits = [] for char in string: list_binary_digits.append(int(char)) return list_binary_digits def convert_binary_decimal(binary_list): decimal = 0 rev_list = [] rev_list += reversed(binary_list) for i in range(len(binary_list)): ...
false
a2073aece1c27ba4c3e57612ac3fe1ab9a5913b8
shimoleejhaveri/Solutions
/solution16.py
1,475
4.4375
4
""" Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a string by these rules: 1. Any left parenthesis '(' must have a corresponding right parenthesis ')'. 2. Any right parenthesis ')' must have a correspondin...
true
8f45b136ac4be56e56f786576ad8151c1856925b
giladse19-meet/meet2017y1lab4
/fruit_sorter.py
206
4.1875
4
fruit = 'water' if fruit == 'apples': print('go to bin 1') elif fruit == 'oranges': print('go to bin 2') elif fruit == 'olives': print('go to bin 3') else : print('what is this fruit')
false
0aedbb6c0ea2871be312b08786599e814757f6c5
AdenRao3/Unit-6-03-Python
/movie.py
533
4.1875
4
# Created by: Aden Rao # Created on: April 7, 2019 # This program lets the user enter age and based on that it tells them what movies they can see. # imports math function import math #Input fot the user to enter their age and it tells them to myAge = int(input("Type your age: ")) # If statment to determin...
true
12d562efccfa120bf7658aa958d8d23b8e56cc44
Nate2019/python-basics
/camel.py
2,427
4.375
4
import random #Camel BASIC Game in python from 'Program Arcade Games with Python' Chapter 4: Lab exercise! #Written by Iago Augusto - plunter.com print """ Welcome to camel! You have stolen a camel to make your way across the great Mobi desert. The natives want their camel back and are chasing you down! Survive your d...
true
85ab9c2e85e5830c1671f481f828a0ab5daf1909
sneakyweasel/DNA
/FIB/FIB.py
1,049
4.15625
4
import os import sys file = open(os.path.join(os.path.dirname(sys.argv[0]), 'rosalind_fib.txt')) dna = file.read() print(dna) # dna = "5 3" n = int(dna.split(' ')[0]) k = int(dna.split(' ')[1]) population = [1, 1] def next_generation(population, k): current = population[-1] # reproductor_pairs = (population -...
true
b65a3596d0a9ab4e62564e25ce0d7e6e7debc54e
jfcarocota/python-course
/Strings.py
1,604
4.28125
4
myStr = 'Hi Friend' # restusn all options for string object #print(dir(myStr)) print(myStr) # converts strings in uppercase print(myStr.upper()) #converts string in lowercase print(myStr.lower()) #change lower to upper an viceverse print(myStr.swapcase()) # convert the first character in strings to uppercase and ...
true
2c33a2630ab625d76ac59e7a2c376c1c76f80ca6
NyntoFive/Python-Is-Easy
/03_main.py
1,197
4.34375
4
""" Homework Assignment #3: "If" Statements Details: Create a function that accepts 3 parameters and checks for equality between any two of them. Your function should return True if 2 or more of the parameters are equal, and false is none of them are equal to any of the others. Extra Credit: Modify your f...
true
2ac7a2f65c84ed64006361e1b6c3d92bd9acb2fc
shaheryarshaikh1011/HacktoberFest2020
/Algorithms/Python/sorting/bubble sort.py
406
4.375
4
#Python Implementation of bubble Sort Algorithm #Using data available in Python List temperature=[45,10,14,77,-3,22,0] #ascending Order Sort def bubble(data): n=len(data) for i in range(n-1): for j in range(i+1,n): if data[i]>data[j]: temp=data[j] data[j]=data[i] data[i]=temp print("Data Before Sor...
true
7bada2bc40f499a7e4df7809b9f5e01844224af3
rishabhnagraj02/rishabh
/PEP8.PY
458
4.125
4
#Program to show use of constuctor and destructor class Person: def __init__(self,fname,lname): self.fname=fname self.lname=lname def getFullName(self): print(fname,lname) def __del__(self): print("Destroying instance of person class") p1=Person("Emraan","Hashm...
true
a2bf5e8dea0ba645dba3f1b4425eaf2b6af7279b
vdonoladev/aprendendo-programacao
/Python/Programação_em_Python_Essencial/5- Coleções/counter.py
1,817
4.1875
4
""" Módulo Collections - Counter (Contador) https://docs.python.org/3/library/collections.html#collections.Counter Collections -> High-performance Container Datetypes Counter -> Recebe um interável como parâmetro e cria um objeto do tipo Collection Counter que é parecido com um dicionário, contendo como chave o ele...
false
45076d538b6ef92f733093861d65cc159abefbac
davidevaleriani/python
/ball.py
1,925
4.15625
4
####################################################################### # Bouncing ball v1.0 # # This program is a first introduction to PyGame library, adapted # from the PyGame first tutorial. # It simply draw a ball on the screen and move it around. # If the ball bounce to the border, the background change c...
true
34e5e6e7d7f787c615ef1f7ceb9a72a5c3d39d0d
LorienOlive/python-fundamentals
/paper-rock-scissors.py
1,205
4.21875
4
import random choices = ['paper', 'rock', 'scissors'] computer_score = 0 player_score = 0 while computer_score < 2 and player_score < 2: computer_choice = random.choice(choices) player_choice = input('What do you choose: paper, rock, or scissors? ') if computer_choice == player_choice: print('Tie...
true
d7cf2b029976585f7be464cf911046e1946e9fc0
Aditya8821/Python
/Python/Daily Challenges/Searching And Sorting/Bubble_Sort.py
365
4.15625
4
def BubbleSort(arr): n=len(arr) for i in range(n): for j in range(n-i-1): #Here n-i-1 Bcoz largest element is reached to its pos(top) previous pass if arr[j]>arr[j+1]: arr[j],arr[j+1]=arr[j+1],arr[j] arr=[64,34,25,12,22,11,90] BubbleSort(arr) print("Sorted Array: "+st...
false
7d0c08ca7c6e4e45ccf852bda6db201391a71f92
Aditya8821/Python
/Python/Daily Challenges/Searching And Sorting/Insertion_Sort.py
278
4.25
4
def InsertionSort(arr): for i in range(1,len(arr)): key=arr[i] j=i-1 while j>=0 and key<arr[j]: arr[j+1]=arr[j] j-=1 arr[j+1]=key arr = [12, 11, 13, 5, 6] InsertionSort(arr) print("Sorted Array: "+str(arr))
false
22b4c505efcf84030192e3f6708d68c823fce03b
Ashish313/Python-Programs
/algorithms/Sorting/mergesort.py
1,074
4.1875
4
def mergesort(arr): if len(arr) > 1: # find the middle point and divide the array into two parts mid = len(arr)//2 L = arr[:mid] R = arr[mid:] # repeat the same procedure for left array and right array mergesort(L) mergesort(R) i = j = k = 0 ...
false
07d3ce76ec05f6b1bfc4d1bdee287552e0c06aab
ledurks/my-first-portfolio
/shpurtle.py
604
4.15625
4
from turtle import * import math # Name your Turtle. t = Turtle() t.pencolor("white") # Set Up your screen and starting position. penup() setup(500,300) x_pos = -250 y_pos = -150 t.setposition(x_pos, y_pos) ### Write your code below: t.goto(500,600) pendown() begin_fill() fillcolor("LightSalmon") for sides in range(...
true
a4b554f80bca1935d4685c39c1222d486f23ddbb
aniketguptaa/python
/Strings.py
1,493
4.375
4
#strings are immutable # Different method of writing string x = "Hello My name is Carry" y = 'Hello My name is Carry' z = '''Hello My name is carry and i read in class 10 and I am smart''' print(type(x)) # TypeViewing print(type(y)) # TypeViewing print(type(z)) # TypeViewing print(x) print(y) print(z) # I...
true
e5c6517652c80dd958f26cb072055e255ce1967a
aniketguptaa/python
/Dictionary.py
966
4.1875
4
dict = {1 : "spam", 2: "spamming"} print(dict) dict1= {'name': 'Carry', 'age': 26} print(dict1['name']) print(dict1['age']) # Adding keys and value in preesxising dictionary dict1['address'] = 'Silicon valley' print(dict1['address']) print(dict1) squares = {1:1, 2:4, 3:9, 4:16, 5:25, 6:36, 7:49, 8:64, 9:...
true
677d3f159cff2060f8116447d319ffe0ff39e3a4
duncanmurray/Python2-Training-Practicals
/takepin.py
659
4.3125
4
#!/usr/local/bin/python # Page 13 of exercise quide # Emulate a bank machine # Set the correct pin correct_pin = "1234" # Set number of chances and counter chances = 3 counter = 0 # While counter is less than chances keep going while counter < chances: # Ask for user input supplied_pin = raw_input("Please ...
true
355e20ddaff58320b195720f29272a5c093b66ca
swachchand/Py_exercise
/python_small_examples/pythonSnippets/frontThreeCharacters.py
700
4.1875
4
''' Given a string, we'll say that the front is the first 3 chars of the string. . If the string length is less than 3, the front is whatever is there. Return a new string which is 3 copies of the front. front3('Java') 'JavJavJav' front3('Chocolate') 'ChoChoCho' front3('abc') -- 'abcabcabc' front3('abcXYZ'...
true
886bdc4ecade0c75feae27d9205511a5377818c2
swachchand/Py_exercise
/python_small_examples/pythonSnippets/revStringSimple.py
362
4.40625
4
''' Print entire character stream in reverse without ---> List Comprehension Technique (simple traditional for loop) example: hello world olleh dlrow ''' word = input('Enter: ') ##The split() method splits a string into a list. w = word.split(' ') re =[] for i in w: re=i[::-1] #re.append...
true
5e63cb5efb36f2a1765446b6f9591594bf45cd4c
kevinsjung/mixAndMatchSentence
/mixAndMatchSentence.py
1,389
4.125
4
def mixAndMatchSentences(sentence): """ Given a sentence (sequence of words), return a list of all "mix and matched" sentences. We define these sentences to: - have the same number of words, and - each pair of adjacent words in the new sentence also occurs in the original sentence Example:...
true
84a5cf98811446097102aa2f93bdb0ee5b1afe2d
ReginaAkhm/Python-Adv
/day_4/anagrams.py
731
4.1875
4
# Анаграммы* # Задается словарь (список слов). # Найти в нем все анаграммы (слова, составленные из одних и тех же букв). # Пример: 'hello' <-> 'ollhe' import itertools from pprint import pprint def make_anagram_dict(line): d = {} for word in line: word = word.lower() key = ''.join(sorted(word)...
false
09696fc8ccfcfad1e74b6dea56b5a067770f2549
jermailiff/python
/ex37.py
1,573
4.15625
4
import os # from math import sqrt # # # print "Hello World" # # while True: # # feelings = input("How are you feeling this morning on a scale of 1 - 10?") # # if feelings in range(1,5): # print "Pretty shitty then!" # break # elif feelings in range(6,10): # print "Pretty damn good eh" # break # else: ...
true
0cc636d346719e4c433d91254f053d451c52d9c2
ljyadbefgh/python_test
/test2/test2_1_lambda.py
1,621
4.3125
4
'''lambda函数的练习 lambda表达式,通常是在需要一个函数,但是又不想费神去命名一个函数的场合下使用,也就是指匿名函数。 lambda所表示的匿名函数的内容应该是很简单的,如果复杂的话,干脆就重新定义一个函数了,使用lambda就有点过于执拗了。 lambda就是用来定义一个匿名函数的,如果还要给他绑定一个名字的话,就会显得有点画蛇添足,通常是直接使用lambda函数。 如下所示: add = lambda x, y : x+y add(1,2) # 结果为3 ''' ''' 练习1: 1.以下lambda等同于以下函数 def func(x): return(x+1) ''' func1=lambda x:...
false
0090d97141e758c65615795888ee1b999d28431c
iiit-nirmal/pyhton_prac
/loops/loopControl.py
458
4.15625
4
## continue returns control the begining of loop for letteres in 'geeksgeeks': if letteres == "e" or letteres == "s": continue print('character:',letteres) ## break returns control to the end of loop for letteres in 'geeksforgkees': if letteres == "e" or letteres == "s": break print(...
true
da2d37c8ceebc6e7ac03eb30f5d472d0e7c7e1f3
joshmreesjones/algorithms
/interviews/n-possible-balanced-parentheses.py
755
4.21875
4
""" Print all possible n pairs of balanced parentheses. For example, for n = 2: (()) ()() """ def balanced_parentheses(n): if n == 0: return [""] elif n == 1: return ["()"] else: previous = balanced_parentheses(n - 1) result = [] for i in range(len(previous)...
true
e9b507e0c053a2990f82f4a9fecc0b63d17349e1
gmn7/aep2
/TrabalhoPilha/main.py
766
4.125
4
from pilha import Pilha def menu(): print ('Entre com a opcao: \n', \ '1 para inserir na pilha \n', \ '2 para retirar na pilha\n', \ '3 para mostra o proximo valor a ser retirado da pilha \n', \ '4 verificar se esta vazia \n', \ '5 para finalizar ...
false
3e331573d4214f4302f4124c42e74dd8f6d2c691
glennandreph/learnpython
/thirtysix.py
213
4.15625
4
name = "Glenn" age = 24 if name == "Glenn" and age == 24: print("Your name is Glenn, and you are 24 years old.") if name == "Glenn" or name == "Rick": print("Your name is either Glenn or Rick.")
true
b0edb28c2f7c9c69361b8d5121d0e7372c50f93e
savadev/Leetcode-practice
/122 Sum and average.py
501
4.1875
4
Sum and Average from a List Given a list of integers, write a method that returns the sum and average of only the 1st, 3rd, 5th, 7th etc, element. For example, [1, 2, 3] should return 4 and 2. The average returned should always be an integer number, rounded to the floor. (3.6 becomes 3.) def sumavg(arr): sum = 0 ...
true
9d6d5ac4882ae9213f56d729cf98c531f3a0f180
jc328/CodeWars-1
/7kyu_MostCommonFirst.py
1,192
4.25
4
// 7kyu - Most Common First // Given a string, s, return a new string that orders the characters in order of // frequency. // The returned string should have the same number of characters as the original // string. // Make your transformation stable, meaning characters that compare equal should // stay in their o...
true
46fae30e099f6a6047c7628e24b03b0157946a1e
chronosvv/pythonAdvanced
/myiterable.py
1,072
4.3125
4
# 1.可迭代对象 # 以直接作用于for循环的数据类型有以下几种: # 一类是集合数据类型,如list,tuple,dict,set,str等; # 一类是generator,包括生成器和带yield的generator function。 # 这些可以直接作用于for循环的对象统称为可迭代队象:Iterable # 2.判断是否可以迭代 from collections import Iterable print(isinstance([], Iterable)) #列表是不是Iterable的实例 print(isinstance(100, Iterable)) # 3.迭代器 # 可以被next()函数调用并不断返回下一...
false
f0cb0daab6662ac4862f4ce2b06b4976cced1e45
youngcardinal/MFTI-Labs
/002_grafik.py
801
4.34375
4
# Каскадные условные функции: # по данным ненулевым числам x и y определяет, # в какой из четвертей координатной плоскости находится точка (x,y) print("Задача:\nОпределить какой четверти принадлежит точка с введенными координатами\nВведите число x:") x = int(input()) print("Введите число y:") y = int(input()) if x > 0 ...
false
30ad4e8bf69f6407bd388987245d39c368ee0bed
lavisha752/Python-
/LCM.py
889
4.125
4
# User input and storing data in variables var1=int(input("Enter the first number:")) var2=int(input("Enter the second number:")) # Using an if statement to find the smallest number and storing in a variable called smallest if(var1 > var2): smallest=var1 else: smallest=var2 # A while loop is used to te...
true
373d68168b0589221d4e0548104c737bd52ecf4d
mrech/LearnPython_TheHardWay
/shark.py
741
4.15625
4
#define a class with is methods (functions) class Shark: def swim(self): print("The shark is swimming.") def be_awesome(self): print("The shark is being awesome.") # function object # create a variable called main that point the function object def main(): sammy = Shark() # ...
true
05ed02a2c46f709e7769d0eec1333fbcec83c517
Sever80/Zadachi
/11.py
455
4.34375
4
# Даны два списка одинаковой длины. # Необходимо создать из них словарь таким образом, # чтобы элементы первого списка были ключами, # а элементы второго — соответственно значениями нашего словаря. a=[1,2,3,4,5] b=['one','two','three','four','five'] my_dict=dict(zip(a,b)) print(my_dict)
false
ba0a8b6acbfcc9f03f99db2f0d7ac145a5090f68
madhav9691/python
/matrix_mul.py
1,148
4.34375
4
def create_matrix(m,row,col): for i in range(row): m.append([]) # adding rows for i in range(row): for j in range(col): m[i].append(0) #adding columns to each row def enter_elements(n,r1,c1): for i in range(r1): for j in range(c1): n[i][j]=...
false
e427482ec1b80a52fc2919c61d32fb16d8c4e794
xKolodziej/02
/06/Zad11.py
473
4.125
4
array1=["water","book","sky"] array2=["water","book","sky"] def compare(array1,array2): print("Array1: ", end="") for i in array1: print(i, end=" ") print() print("Array2: ", end="") for j in array2: print(j, end=" ") print() if array1==array2: prin...
false
f2bd85b263adf608ccda9023189d9a0b84f3f1ae
raonineri/curso_em_video_python
/ex008.py
451
4.21875
4
# Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros. distancia_m = float(input("Digite uma distância em metros: ")) print('-=' * 10) print(f'{distancia_m}m corresponde a:') print('-=' * 10) print(f'{distancia_m/1000} Km\n' f'{distancia_m/100} Hm\n' f'{distanc...
false
904a4c613bb872548cfcb721e3c4453c4758076f
TheBlocks-CN/PoHaiFriends
/PoHai (Version 1.2).py
1,258
4.125
4
Language = input("What language r u use?zh-CN(zh-SG) , zh-TW(zh-HK,zh-MO) or en-UK (en-US)?If u use Chinese(Simplified) type 1,use Chinese(Tranditional) type 2, use English type 3.") Language = int(Language) if Language == 1: digital = input("Please type the digital") digital = int(digital) if digital == 99...
false
f6bc7d44457f10f177f97fd6fba284923262ab3d
MTset/Python-Programming-Coursework
/Python 01: Beginning Python/Lesson 11: Defining and Calling Your Own Functions/three_param.py
640
4.1875
4
#!/usr/local/bin/python3 def my_func(a, b="b was not entered", c="c was not entered" ): """ right triangle check """ result = "Values entered: a - {0}, b - {1}, c - {2}\n".format(a, b, c) if type(c) is int: d = sorted([a, b, c]) if abs(complex(d[0], d[1])) == d[2]: result += "Y...
true
427ab151f21bdd3fbd09e2fce7dddcdbdac5eb5d
purcellconsult/jsr-training
/day_2_files/secret_number_game.py
1,014
4.25
4
# Secret Number Game # ------------------- # A text based game written in python. # The user gets to take an arbitrary number of guesse. # They will be provided feedback on if their guess # is less than, greater than, or equal to the secret num. # If equal, the secret number should be revealed, and # then the lo...
true
bd1c05cbe4e34d9a8b3f5d9f65d0ac89ec5145a6
zxcv-zxcv-zxcv/python_mega_course
/textpro_mysolution.py
875
4.21875
4
# 1. Output "Say Something" # 2. take an input, store it into a list # 3. end if user inputs /end # 4. Capitalise first letter. End in a question mark if it starts with who, # what , when, where, why, how # 5. Print out each input. inputs = [] word = '' fullstop = '.' sentence = '' while True: if w...
true
74df3681854c0447bd341b5cb42ae5f2fcbfe544
min0201ji/Pyhthon_Programming_Basic
/Exam2/2_5.py
615
4.5625
5
""" 이름 : 박민지 날짜 : 2021/04/15 내용 : 파이썬 클래쓰 연습문제 """ class King: def __init__(self,#name(M) #name=태조, #year(M) #year=1392): self.name = name self.year = year def show(self): print('-------------') print('name :', self.name) print('year :', self.year) if...
false
cf5f292acb3d3bfd6f306cb80d49a31b9a194533
nankyoku/nankyokusPython
/ex6.py
1,262
4.375
4
# Exercise 6: Strings and Text # The below 4 statements set up variables and their values x = "There are %d types of people." % 10 binary = "binary" do_not = "don't" y = "Those who know %s and those who %s." % (binary, do_not) # The below 2 statements print out the values of the variables x and y. print x print y #...
true
698a372fd9c7e4b717d593c2d5f9196f320d89d1
PET-Comp-UFMA/Monitoria_Alg1_Python
/03 - Laços de repetição/q13.py
1,411
4.1875
4
""" Faça um programa que funcione como uma loja. Esse programa deverá mostrar os itens que estão a venda e o preço de cada um e então receberá como entrada o item a ser comprado e a quantidade, ele deverá então perguntar se o usuário deseja continuar comprando ou encerrar a compra. Ao final, o programa deverá most...
false
808a95bb776910cbb22c0baeb85c30a83a5e08ec
PET-Comp-UFMA/Monitoria_Alg1_Python
/04 - Strings/q04.py
515
4.21875
4
#Leia uma String e retorne na tela mostrando se é uma palíndroma. #Um palíndromo é uma palavra ou frase que pode ser lida no seu sentido normal, da esquerda para a direita, bem como no sentido contrário, da direita para a esquerda, sem que haja mudança nas palavras que a formam e no seu significado. palavra = input() ...
false
8505e1201ac2c84644d9546bc8fee4c1489b9fb9
PET-Comp-UFMA/Monitoria_Alg1_Python
/03 - Laços de repetição/q15.py
550
4.40625
4
""" Faça um programa que receba uma string e imprima ela de volta com a formatação trocada, ou seja, todas as letras que estiverem em minúsculo serão imprimidas em maiúsculo e todas as letras em maiúsculo serão impressas em minúsculo. Exemplo: Entrada Saída Sino sINO InVeJa...
false
45a868005faa26f5eaaee0eda5f2fa03926ca8ea
PET-Comp-UFMA/Monitoria_Alg1_Python
/03 - Laços de repetição/q10.py
309
4.1875
4
#Questão 10 #Faça um código que peça um número natural N ao usuário e printe um triângulo de #asteriscos de N linhas na tela. Exemplo: #N = 5 #* #** #*** #**** #***** n = int(input("Digite um número natural: ")) for i in range(n): for j in range(i+1): print("*", end = "") print("")
false
551c8929a594c2eea91e8dac5f2ef39bb359106f
PET-Comp-UFMA/Monitoria_Alg1_Python
/01 - Variáveis/q06.py
604
4.1875
4
#Questão 6 #Dado uma variável A que receba qualquer informação de entrada do usuário, escreva um programa #que imprima em tela o tipo de dado dessa variável, seguindo o formato: “O tipo da variável é TIPO.”, #onde TIPO é um dos tipos de variáveis definidos na linguagem utilizada. #(ex: em linguagens da família C, temos...
false
8b1c96315b8a255f0902b513ac699bf2bc973288
Anishukla/50-Days-of-Code
/Day-14/HackerRank/Recursion: Davis' Staircase.py
435
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 25 23:59:26 2020 @author: anishukla """ #Level: Medium # Complete the stepPerms function below. def stepPerms(n): A = [1, 2, 4] for i in range(3, n): A.append(A[i-3]+A[i-2]+A[i-1]) return A[n-1] if __name__ == '__main__': ...
false
b6ce6f9b3a313926e6cc0e1e38cdf78c4c133456
linneakarlstrom/Notes
/Notes/something.py
2,847
4.15625
4
# anteckningar # en operator är + - osv. Det finns olika sorters operatorer. # Aritmetiska (arithmetic) + - / % // * ** # Jämförelse (comparision) == (ifall de är lika) < > <= => != (ej lika med) # logiska (logical) and, or , not # if, else är villkorsatser. När ett villkor ska avögra (conditional statement - vill...
false
a925aacc4744ec91d54bdd345e471dc9af142bf2
Eqliphex/python-crash-course
/chapter08 - Functions/exercise8.8_user_albums.py
1,269
4.375
4
def make_album(album_artist, album_title, album_song_num=None): """Creates an album. Args: album_artist (str): Name of the artist. album_title (str): Title of the album. album_song_num (:obj:`str`, optional): The second parameter. Defaults to None. Returns: bool:...
true
11a0b9c55f4e24347745c648bd8ca2ccc8f34e97
omkar-21/Python_Programs
/Que_34.py
645
4.1875
4
""" Write a procedure char_freq_table() that, when run in a terminal, accepts a file name from the user, builds a frequency listing of the characters contained in the file, and prints a sorted and nicely formatted character frequency table to the screen. """ from collections import Counter import os def main(): ...
true
04e02bb6cbe311c3ad31150ad5816489651edcf3
omkar-21/Python_Programs
/Que_37.py
836
4.34375
4
""" Write a program that given a text file will create a new text file in which all the lines from the original file are numbered from 1 to n (where n is the number of lines in the file). """ import os def number_lines(file_path, path_for_new_file): try: with open(file_path,'r') as input_file, open(pa...
true
1cb69c0e9b56b34d446dd27338c94dbb8d424439
omkar-21/Python_Programs
/Que_36.py
888
4.1875
4
""" A hapax legomenon (often abbreviated to hapax) is a word which occurs only once in either the written record of a language, the works of an author, or in a single text. Define a function that given the file name of a text will return all its hapaxes. Make sure your program ignores capitalization. """ import os im...
true
7fd8a9449de8ae605918a93e43925901f0794604
omkar-21/Python_Programs
/Que_3.py
425
4.125
4
''' Define a function that computes the length of a given list or string. (It is true that Python has the len() function built in, but writing it yourself is nevertheless a good exercise.) ''' def findLen(str1): counter = 0 for i in str1: counter += 1 print("Length of string is",counter) ...
true
d6171f54ce5fade36bd8eddf7ca3e20f270016ff
omkar-21/Python_Programs
/Que_32.py
658
4.28125
4
""" Write a version of a palindrome recogniser that accepts a file name from the user, reads each line, and prints the line to the screen if it is a palindrome. """ import re import os def main(): try: with open(input("Enter the file path to read\n>>"),'r') as input_file: lines=in...
true
8f5b0188b57f4db2e84ebc8d798465340f299e5a
omkar-21/Python_Programs
/Que_27.py
871
4.46875
4
""" Write a program that maps a list of words into a list of integers representing the lengths of the corresponding words. Write it in three different ways: 1) using a for-loop, 2) using the higher order function map(), and 3) using list comprehensions. """ def lengths_using_loop(words): lengths = [] for word...
true
c1f275be9c454a9542991878f85be18a0b03e516
apoorvakashi/launchpad-Assignments
/problem3.py
230
4.125
4
numbers = [1, 3, 4, 6, 4, 35, 5, 43, 3, 4, 18, 3, 1, 1] numlist= [] element = int(input("Enter a number: ")) for index, value in enumerate(numbers): if value==element: numlist.append(index) print(numlist)
true
ba0f7783481d57ca633b50240f40f0fc2a6516cc
raulzc3/MastermindPython
/primerPrograma/primerPrograma.py
603
4.25
4
# Mi primer programa en Python! # Este programa recibe tres números como input por parte del usuario e indica los números mayor y menor num1 = int(input("Introduce un número: ")) num2 = int(input("Introduce otro número: ")) num3 = int(input("Introduce otro número (este será el último): ")) maxNum = max(num1, num2, nu...
false
4ae99f08a25243205420fc508e86b53a86d2d032
roger-mayer/python-practice
/crash_course/input_and_while_loops/greeter.py
580
4.28125
4
# # single line # name = input("please enter your name: ") # print(f"Hello, {name}!") # # # multi line prompt # prompt = "If you tell us you name, we can personalize messages." # prompt += "\nWhat is your name? " # # name = input(prompt) # print(f"\nHello, {name}!") # using int to accept numerical input age = input("H...
true
348d80458e3fa747a0693fc3aa826a5fbf8c3ff7
roger-mayer/python-practice
/crash_course/dictionaries/many_users.py
566
4.28125
4
# dictionary in a dictionary users = { 'rmayer': { 'first': 'roger', 'last': 'mayer', 'age': 35 }, 'kwest': { 'first': 'katie', 'last': 'west', 'age': 28 }, 'amayer': { 'first': 'asher', 'last': 'mayer', 'age': 1 } } for...
false
5d7d95edc99927d94276b4c44b0904fed9f9b5af
iam-abbas/cs-algorithms
/Searching and Sorting/Selection Sort/PYTHON/SelectionSort.py
945
4.28125
4
#Call 'main()' in the terminal/console to run Selection Sort on desired unsorted sequence. #This algorithm returns the sorted sequence of the unsorted one and works for positive values. def SelectionSort(arr): pos = 0 min_num = 0 for i in range(0, len(arr)): min_num = arr[i] pos = i ...
true
b7d9ab7dd8f30d06e51e1f8c9e73c797e5d62aa3
iam-abbas/cs-algorithms
/Searching and Sorting/Linear Search/Python/linear search.py
460
4.125
4
# Python3 code to linearly search x in arr[]. # If x is present then return its location, # otherwise return -1 def search(arr, n, x): for i in range (0, n): if (arr[i] == x): return i; return -1; # Driver Code arr = [ 2, 3, 4, 10, 40 ]; x = 10; n = len(arr); result = s...
true
10219c8538c18b8955068ffb124244e2990603f0
iam-abbas/cs-algorithms
/Floyd Cycle Loop Detection/floyd_cycle_loop_detection.py
1,272
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None # Push value to the end of the list def push(self, data): new_node = Node(data) if self.head is None: self.head...
true
aa94cde42819d8cbbf072da6da479e0312534a25
santibaamonde/prueba
/juego_adivinar.py
321
4.15625
4
numero_adivinar = int(input("Dime un numero que quieras que otro trate de adinivar: ")) numero_adivinador = int(input("Intenta adivinar el numero que ha pensado la otra persona: ")) while numero_adivinar != numero_adivinador: numero_adivinador = int(input("Has fallado, prueba otro numero: ")) print("Has ganado")...
false
eb62010da78c62f30e81952970bb2d33f62db4b6
santibaamonde/prueba
/clase10_parte3_ej3.py
1,303
4.15625
4
""" Crear un programa que guarde e imprima varias listas con todos los números que estén dentro de una lista proporcionada por el usuario y sean múltiplos de 2, de 3, de 5 y de 7. Ejemplo: input = [1, 10, 70, 30, 50, 55] multiplos_dos = [10, 70, 30, 50] multiplos_tres = [30] multiplos_cinco = [10, 70, 30, 60, 55] mult...
false
96da3374de0f73da3bc5de499917b3f0427e4f80
wandeg/fun
/pascals.py
2,117
4.28125
4
from utils import func_timer import math @func_timer def factorial_loop(n, until=1): """Get the nth factorial using a loop""" fact = 1 i = until while i<=n: fact *= i i+=1 return fact @func_timer def factorial_rec(n): """Returns the nth factorial using recursion""" if n == 1 or n == 0: return 1 else...
false
7359a38cffa8a37405a0f7be60eefdae3685436a
TimTheFiend/Automate-the-Boring-Stuff-with-Python
/_Finished/Ch15/time_module.py
1,489
4.1875
4
import time def intro(): print(time.time()) # 1574066563.5332215 """Explanation: Here I'm calling time.time() on 18th of November, 09:43. The value is how many seconds have passed between the Unix epoch and the moment time.time() was called. Epoch timestamps can be used to profile code, that is, t...
true
0e9c5822ad15fa0fe196d6a7c1f072720e8c9c0f
JKam123/homework1
/PrimeNumbersCode.py
394
4.1875
4
# Check if the number is a prime number Int = 5 IsPrime = True if Int != 0: for x in range(2, Int / 2): if Int%x == 0: IsPrime = False break if IsPrime: print "Its a prime number" else: print "Its not a prime number" else: ...
true
890e202babb89001a51ad8f813e708fbaffc2c55
yushenshashen/hello-python
/classic-100-scripts/JCP017.py
666
4.1875
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- #题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。 #程序分析:利用while语句,条件为输入的字符不为'\n'。 import string #text = raw_input('please input a string: ') text = '34fdgds hrd77&*' letters = 0 space = 0 digits = 0 others = 0 #for i in range(len(text)): for i in text: if i.isalpha(): ...
false
e4d7f983cdcf0101b5e9d0a382c12ec23e48d74a
aaron-goshine/python-scratch-pad
/workout/note_11.7.py
468
4.15625
4
## # Compute the greatest common divisor of two # positive integer using a while loop # # Read two positive from the user n = int(input("Enter a positive integer: ")) m = int(input("Enter a positive integer: ")) # Initialize d to the smaller of n and m d = min(n, m) # Use a while loop to find the greatest common div...
false
9ddb24b957201560c1491cf5333e453280648689
aaron-goshine/python-scratch-pad
/workout/note_11.5.py
648
4.46875
4
## # Determine whether or not a string is a palindrome. # # Read the input from the user line = raw_input("Enter a string: ") # Assume that the string is a palindrome until # we can prove otherwise is_palindrome = True # Check the characters, starting from the end until # the middle is reached for i in range(0, len(...
true
3e2f558efe5f67fcf73a15fa759c3d488e074062
aaron-goshine/python-scratch-pad
/workout/note_11.1.py
1,394
4.5
4
## # Compute the perimeter of a polygon. # The user will enter a blank line for the x-coordinates # that all of the points have been entered. # from math import sqrt # Store the perimeter of the polygon perimeter = 0 # Read the coordinates of the first point first_x = float(raw_input("Enter the x part of the coordin...
true
4507f6384a59dd92167050449c52ba68e0c9f624
aaron-goshine/python-scratch-pad
/workout/shuffle_deck.py
1,341
4.1875
4
## # Create deck for cards and shuffle it # from random import randrange # Construct a standard deck of cards with 4 # suits and 13 value per suit # @return a list of card, with each represented by two characters def createDeck (): # Create a list to store the card in cards = [] # For each suit and each v...
true
a88d040a8ffb05efeefc349a1dd1d8dc54187075
aaron-goshine/python-scratch-pad
/workout/reduce_measure.py
2,453
4.34375
4
## # Reduce an imperial measurement so that it is expressed using # the largest possible unit of measure. For example, 59 teaspoon # to 1 cup... # TSP_PER_TBSP = 3 TSP_PER_CUP = 48 ## Reduce an imperial measurement to that it is expressed using # the largest unit of measure. # @param num the number of units that need...
true
abbfbf2e681ac34c9d6c666a1ae5d11c2a83b19f
AnilSonix/CSPySolutions
/sol2.py
727
4.46875
4
# bubble sort numbers = [] def bubble_sort(numbers): n = len(numbers) # Traverse through all array elements for i in range(n - 1): # range(n) also work but outer loop will repeat one time more than needed. # Last i elements are already in place for j in range(0, n - i - 1): ...
true