blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ed1decde6fc97b53b1ab2026b61be047f22125ca
rajeshsvv/Lenovo_Back
/1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/1_Dataflair/Beginner/4_tuple_functions.py
1,416
4.28125
4
# Python Tuples Packing b=1,2.0,"three", x,y,z=b print(b) print(type(b)) percentages=(99,95,90,89,93,96) a,b,c,d,e,f=percentages # print(a,b,d,e,f,c) # print(type(percentages)) # print(percentages[1]) # print(percentages[2:-1]) # print(percentages) # print(percentages[:-2]) # print(percentages[2:-3]) # prin...
true
3e1029de5c6d8dd891f5b0265d6f9bd28a2ee562
rajeshsvv/Lenovo_Back
/1 PYTHON/7 PROGRAMMING KNOWLEDGE/11_If_else_if.py
603
4.125
4
''' x=100 if x!=100: print("x value is=",x) else: print("you entered wrong value") ''' ''' x=100 if x==100: print("x is =") print(x) if x>0: print("x is positive") else: print("finish") ''' name=input("Enter Name:") if name=="Arjun": print("The Name is",name) elif name=="Ashok": pri...
true
4ee34cde27b1028f5965db21d5adcd3311859a62
rajeshsvv/Lenovo_Back
/1 PYTHON/2 COREY SCHAFER/PART 1/25_File Objects Reading and Writing.py
2,058
4.59375
5
# File Object How to read and write File in Python using COntext manager # Reading(r) Writing(w) Appending(a) or Reading and Writing(r+) Operations on File Default is Reading if we dont mention anything # context manager use is no need to mention the close the file it automatically take care about that. # with open("t...
true
1c068daa9bc712bd4ce6d49ed728da8666c080a9
rajeshsvv/Lenovo_Back
/1 PYTHON/3 TELUSKO/42_Filter_Map_Reduce.py
1,155
4.34375
4
# program to find even numbers in the list with basic function # def is_even(a): # return a%2==0 # # nums=[2,3,4,5,6,8,9] # # evens=list(filter(is_even,nums)) # print(evens) # program to find even numbers in the list with lambda function # nums=[2,3,4,5,6,8,9] # # evens=list(filter(lambda n:n%2==0,nums)) # prin...
true
0d88ba61da25a2c6cbec00a3b2df6a25a339d8e0
rajeshsvv/Lenovo_Back
/1 PYTHON/3 TELUSKO/12_operators.py
327
4.125
4
# Assignment Operators: x = 2 x += 3 print(x) x *= 5 print(x) x /= 5 print(x) a, b, c = 1, 5, 6.3 print(a, b) # Unary Operator n = 4 n = -n print(n) # Relational Operators a = 20 b = 20.1 print(a == b) print(a != b) # Logical Operators a, v = 3, 9 print(a < 5 and v < 10) print(a < 5 or v < 10) print(not a) print(...
false
efd5cdb227947d02ae194e4c1100bfbf1f8097db
rajeshsvv/Lenovo_Back
/1 PYTHON/7 PROGRAMMING KNOWLEDGE/45_Python_Generator.py
1,064
4.125
4
''' def my_func(): yield "a" yield "b" yield "c" yield "d" x=my_func() print(next(x)) print(next(x)) print(next(x)) print(next(x)) print(next(x)) # this is extra print statement it raises stop iteration exception. #using for loop we did not stopiteration exception. # for i in x: # p...
false
3c0c21e334d161aa174acd2875a8b8bf9afdc56d
rajeshsvv/Lenovo_Back
/1 PYTHON/2 COREY SCHAFER/PART 1/4.2_Sets.py
689
4.25
4
# sets are unorder list of items and no duplicates in it means it throws the duplicate values and in output it gives unique values k #strange when we execute each time set its output order will be change strnage right cs_courses={"History","Math","Physics","ComputerScience"} print(cs_courses) cs_courses={"History","...
true
f6e317ef55d8b358a5b2a97a8366375d876d1afd
rajeshsvv/Lenovo_Back
/1 PYTHON/2 COREY SCHAFER/PART 2/33_Generators.py
1,324
4.5
4
# Generators have advantages over Lists # Actual way to find the square root of the numbers # def sqaure_numbers(nums): # result = [] # for i in nums: # result.append(i * i) # return result # my_numbers = sqaure_numbers([1, 2, 3, 4, 5]) # print(my_numbers) # through Generator we can find the s...
true
fea628a45ae7f13a0b7fcf46dec0a17cea59ec74
rajeshsvv/Lenovo_Back
/1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/Techbeamers/ds tuples techbeam2.py
1,397
4.3125
4
# https://www.techbeamers.com/python-programming-questions-list-tuple-dictionary/ # Tuples ''' init_tuple = (1,.2,3) print(init_tuple.__len__()) # answer:0 ''' """ init_tuple_a = 'a', 'b', init_tuple_b = ('a', 'b') print (init_tuple_a == init_tuple_b) # answer:True """ ''' init...
false
9f919efc97f5d420ac4e5fe9bcc7894ae34bb20d
dehvCurtis/Fortnight-Choose-Your-Own-Adventure
/game.py
754
4.1875
4
print ("Welcome to Fortnite - Battle Royal") #When the gamer first starts the game print ("Your above Tilted Towers do you jump?.") print('Do you want to jump') ## raw_input gets input from the user ## Here, we take the input, and *assign* it to a variable called 'ans' answer = input("please type yes or no ") ## con...
true
0afd492ae8246c953c088cf735ae1a525d2d49b9
sidneyalex/Desafios-do-Curso
/Desafio075.py
756
4.125
4
#Desenvolva um pgm que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: #A)Quantas vezes apareceu o numero 9. #B)Em que posição foi digitado o primeiro 3. #C)Quais foram os numeros pares. print(f'O Programa coleta 4 numeros inteiros e os guarda em uma tupla.') num = (int(input('1º numero: ')...
false
2122beb8f83cb24f1c617d9fb388abdf42becd63
Laurentlsb/Leetcode
/leetcode/editor/en/[101]Symmetric Tree.py
2,992
4.375
4
#Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). # # For example, this binary tree [1,2,2,3,4,4,3] is symmetric: # # # 1 # / \ # 2 2 # / \ / \ #3 4 4 3 # # # # # But the following [1,2,2,null,3,null,3] is not: # # # 1 # / \ # 2 2 # \ \ # 3 ...
true
b27939b3a840c30900ec11f6c41372108c8a78d0
njenga5/python-problems-and-solutions
/Solutions/problem62.py
224
4.46875
4
''' Question 62: Write a program to read an ASCII string and to convert it to a unicode string encoded by utf-8. Hints: Use unicode() function to convert. ''' word = 'Hello world' word2 = unicode(word, 'utf-8') # print(word2)
true
b8b8639b7244a36bce240fd61986e799027c1c4e
njenga5/python-problems-and-solutions
/Solutions/problem47.py
396
4.15625
4
''' Question 47: Write a program which can map() and filter() to make a list whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10]. Hints: Use map() to generate a list. Use filter() to filter elements of a list. Use lambda to define anonymous functions. ''' nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] nums3 =...
true
cd526869d4d51b2b674b9335c89ad71efddde994
njenga5/python-problems-and-solutions
/Solutions/problem59.py
621
4.34375
4
''' Question 59: Assuming that we have some email addresses in the "username@companyname.com" format, please write program to print the company name of a given email address. Both user names and company names are composed of letters only. Example: If the following email address is given as input to the program: john...
true
4eac214e15a3d21aef858726865d0e633c8e799d
njenga5/python-problems-and-solutions
/Solutions/problem49.py
293
4.15625
4
''' Question 49: Write a program which can map() to make a list whose elements are square of numbers between 1 and 20 (both included). Hints: Use map() to generate a list. Use lambda to define anonymous functions. ''' nums = [i for i in range(1, 21)] print(list(map(lambda x: x**2, nums)))
true
878e52902b63ed79cd80fd9ceefe909528bc7abd
njenga5/python-problems-and-solutions
/Solutions/problem28.py
210
4.1875
4
''' Question 28: Define a function that can convert a integer into a string and print it in console. Hints: Use str() to convert a number to string. ''' def convert(n): return str(n) print(convert(5))
true
84c639d15de0b7af4d3bcc57c6363de03c15d018
narendragnv/test
/2_datatypes.py
937
4.25
4
# list == array # tuple # dict ## LIST a = ["somestring", 2, 4.0] print(a) b = [2.3, a] b = [2.3, ["somestring", 2, 4.0]] # same as above line print(b) print(2 in a) print(3 not in a) print("somestring" in a) print("string" in a) a = ["somestring", 2, 4.0] print(a) print(a[1]) a[1] = 32 # list is mutable print(a) ...
false
62ed099d5b99fafc9fa44d21f696402333524451
romitheguru/ProjectEuler
/4.py
821
4.125
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ def num_reverse(n): reverse = 0 while n: r = n % 10 n = n // 10 revers...
true
230f3b9c7735deadb877274b1dfc9c6203f407c7
umahato/pythonDemos
/4_MethodAndFunctions/7_argsAndKwargs.py
1,279
4.1875
4
''' def myfunc(a,b): #Return 5% of the sum of a and b return sum((a,b)) * 0.05 print(myfunc(40,60)) def myfunc(*args): return sum(args) * 0.05 print(myfunc(34,53,53)) def myfunc (**kwargs): print(kwargs) if 'fruit' in kwargs: print('My fruit of choise is {}'.format(kwargs['fruit'])) ...
true
cf4bf78e08205d21f77080dc552247a94a3283e4
umahato/pythonDemos
/3_PythonStatements/3_whileLoops.py
909
4.375
4
# While loops will continue to execute a block of code while some condition remain true. # For example , while my pool is not full , keep filling my pool with water. # Or While my dogs are still hungry, keep feeding my dogs. ''' x = 0 while x < 5: print(f'The current value of x is {x}') #x = x +1 x += 1 el...
true
b7f0c53ae0215250ecf91d5f59489c8fd1f8793c
SilviaVazSua/Python
/Basics/coding_life.py
376
4.15625
4
# a program about something in real life :D number_of_stairs_1_2 = int(input("Tell me how many stairs from floor 1 to floor 2, please: ")) floor = int(input("In which floor you live? ")) total_stairs = number_of_stairs_1_2 * floor print("Then, if the elevator doesn\'t work, you will have ", total_stairs, "until you...
true
247b7c1a9aba17644415a90f117b4d327e3f332d
SilviaVazSua/Python
/Basics/leap_years.py
719
4.25
4
# This program asks for a starting year and an ending year and then puts all the leap years between them (and including them, if they are also leap years). Leap years are years divisible by 4 (like 1984 and 2004). However, years divisible by 100 are not leap years (such as 1800 and 1900) unless they are also divisible ...
true
43c40e8eb46f891023aea282aa8fff1e081581fc
razvanalex30/Exercitiul3
/test_input_old.py
1,138
4.21875
4
print("Hi! Please choose 1 of these 3 inputs") print("1 - Random joke, 2 - 10 Random jokes, 3 - Random jokes by type") while True: try: inputus = int(input("Enter your choice: ")) if inputus == 1: print("You have chosen a random joke!") break elif inputus == 2: print("You have chos...
true
a70be84406ab8fdf4944f6030533fbda0297b11e
ashishp0894/CS50
/Test folder/Classes.py
910
4.125
4
"""class point(): #Create a new class of type point def __init__(self,x_coord,y_coord): #initialize values of class self.x = x_coord self.y = y_coord p = point(10,20) q = point (30,22) print(f"{p.x},{p.y} ") """ class flight(): def __init__(self,capacity): self.capacity = capacity ...
true
eec8d6944bf8b9bf6eeaa515fd1ca7a8e0896328
ashishp0894/CS50
/Test folder/Conditions.py
213
4.125
4
Number_to_test = int(input("Number")) if Number_to_test>0: print(f"{Number_to_test} is Positive") elif Number_to_test<0: print (f"{Number_to_test} is Negative") else: print(f"{Number_to_test} is Zero")
false
23f6a8643e06ed18a73c9bf1519b9719e0a3283c
christophe12/RaspberryPython
/codeSamples/fileManipulation/functions.py
933
4.25
4
#----handy functions---- #The os() function #os.chdir('directory_name') -> changes your present working directory to directory_name #os.getcwd() -> provides the present working directory's absolute directory reference #os.listdir('directory_name') -> provides the files and subdirectories located in directory_name. if...
true
ff0e7cbbf0cff9dd00e60a14d1382e52aac4331f
SuryakantKumar/Data-Structures-Algorithms
/Functions/Check_Prime.py
554
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 24 05:36:47 2019 @author: suryakantkumar """ ''' Problem : Write a function to check whether the number N is prime or not. Sample Input 1 : 5 Sample output 1 : prime Sample input 2 : 4 Sample output 2: Not Prime ''' def IsPrime(n): if n...
true
1c4ccd633778efae1e6d402385ff2eb10a509c91
SuryakantKumar/Data-Structures-Algorithms
/Exception Handling/Else-And-Finally-Block.py
1,101
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 7 14:42:20 2020 @author: suryakantkumar """ while True: try: numerator = int(input('Enter numerator : ')) denominator = int(input('Enter denominator : ')) division = numerator / denominator except Valu...
true
649b45e5fb2fe8b50542cbab310a8cc2d22b511d
SuryakantKumar/Data-Structures-Algorithms
/Miscellaneous Problems/Chessboard-Game.py
629
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 22 13:32:07 2020 @author: suryakantkumar """ from functools import lru_cache @lru_cache def chessboardGame(x, y): print(x, y) if x <= 2 or y <= 2: return 'Second' if chessboardGame(x - 2, y + 1) == True or chessboardGame(x ...
false
b895e3cd708cd102baaf7f4126f4d1a13c32e889
SuryakantKumar/Data-Structures-Algorithms
/Object Oriented Programming/Class-Method.py
1,374
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 6 06:20:20 2020 @author: suryakantkumar """ from datetime import date class Student: def __init__(self, name, age, percentage = 80): # Init method self.name = name self.age = age self.percentage = percentage ...
true
0beb688b4af8803550204cf01f8879b8f327050e
SuryakantKumar/Data-Structures-Algorithms
/Functions/Fahrenheit_To_Celcius.py
878
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 24 07:44:35 2019 @author: suryakantkumar """ ''' Problem : Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their correspo...
true
2450c7cccafa7d66157ef16b35ced3b903ee0b60
SuryakantKumar/Data-Structures-Algorithms
/Searching & Sorting/Insertion-Sort.py
1,120
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 1 08:42:58 2020 @author: suryakantkumar """ ''' Problem : Given a random integer array. Sort this array using insertion sort. Change in the input array itself. You don't need to return or print elements. Input format : Line 1 : Integer N, Array S...
true
574b565c7bc5fecb11693ef0b7e7687437ae429d
SuryakantKumar/Data-Structures-Algorithms
/Miscellaneous Problems/Bishop-Move.py
1,112
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 27 11:57:07 2020 @author: suryakantkumar """ ''' Find out number of positions on chess where bishop can attack. Bishop position is given as (x, y) coordinates and chess dimension is n * n. ''' def bishopMove(chess, position): count = 0 x, ...
false
b50a873c8d0d45fd4ebac22fdeaa92097cdea731
rakshithsingh55/Clg_project
/FoodSearch/webapp/test.py
550
4.5
4
# Python3 code to demonstrate working of # Common words among tuple strings # Using join() + set() + & operator + split() # Initializing tuple test_tup = ('gfg is best', 'gfg is for geeks', 'gfg is for all') # printing original tuple print("The original tuple is : " + str(test_tup)) # Common words among tuple...
true
20ce051e440910c78ca5b3c409ff8ebb566520c0
am3030/IPT
/data/HW5/hw5_182.py
1,171
4.28125
4
def main(): num1 = int(input("Please enter the width of the box: ")) num2 = int(input("Please enter the height of the box: ")) symbol1 = input("Please enter a symbol for the box outline: ") symbol2 = input("Please enter a symbol for the box fill: ") boxTop = "" insideBox = "" for i in range...
true
5de5d8d3bedb628d5dfd81a6d4f1df396678c98c
am3030/IPT
/data/HW5/hw5_453.py
747
4.3125
4
def main(): width = int(input("Please enter the width of the box: ")) # Prompt user for the width of the box height = int(input("Please enter the height of the box: ")) # Prompt user for the height of the box outline = input("Please enter a symbol for the box outline: ") # Prompt user for the symbol that w...
true
7c2eb614d8ed545815425e6181dc9b77cd285d16
am3030/IPT
/data/HW4/hw4_340.py
451
4.21875
4
flavorText = "Hail is currently at height" def main(): height = 0 # 0 is not a valid input because it is not "positive" while height < 1: height = int(input("Please enter the starting height of the hailstone: ")) while height != 1: print(flavorText, height) if (height % 2) == 0:...
true
203e316cac71640f97fb1cc26ecf2eac7d3e76ae
matheusb432/hello-world
/Learning Python/loops2.py
1,060
4.1875
4
car_started = False while True: command = input('>') if command.lower() == 'start': # Utilizando o metodo lower() para tornar o input case insensitive if car_started: # Mesmo que if car_started == True: print('The car is already started!') else: prin...
false
853882de1ef0c0ac6ddc0c41cbfd480fdcaabfef
agatakaraskiewicz/magic-pencil
/eveningsWithPython/stonePaperScissorsGame.py
1,229
4.1875
4
from random import randint """ 1 - Paper 2 - Stone 3 - Scissors 1 beats 2 2 beats 3 3 beats 1 """ points = 0 userPoints = 0 howManyWins = int(input('How many wins?')) def userWins(currentUserScore): print(f'You won!') return currentUserScore + 1 def compWins(currentCompScore): print(f'You loose!') return curre...
true
1fe6cd8e407ae44133b561e4c885bc0ef4904560
kaceyabbott/intro-python
/while_loop.py
489
4.28125
4
""" Learn conditional repetition two loops: for loops and while loops """ counter = 5 while counter != 0: print(counter) # augmented operators counter -= 1 print("outside while loop") counter = 5 while counter: print(counter) counter -= 1 print("outside while loop") # run forever while Tru...
true
b5efc5698eac40c55d378f100337a8e52f9936fa
Nihadkp/python
/co1/16_swap_charecter.py
396
4.1875
4
# create a single string seperated with space from two strings by swapping the charecter at position 1 str1 = "apple" str2 = "orange" str1_list = list(str1) str2_list = list(str2) temp = str1_list[1] str1_list[1] = str2_list[1] str2_list[1] = temp print("Before exchanging elements:", str1, str2) print("string after ex...
true
65efd951f0153acbaee277e256b3e891376ab64a
Nihadkp/python
/co1/4_occurance_of_words.py
211
4.3125
4
#Count the occurrences of each word in a line of text. text=input("Enter the line : ") for i in text.strip().split(): print("Number of occurence of word ","\"",i,"\""," is :",text.strip().split().count(i))
true
97b16a9798970f1f2d734ed16a60187ae7f3f7e1
sudhanthiran/Python_Practice
/Competitive Coding/RegEx matching.py
1,621
4.5625
5
""" Given a pattern string and a test string, Your task is to implement RegEx substring matching. If the pattern is preceded by a ^, the pattern(excluding the ^) will be matched with the starting position of the text string. Similarly, if it is preceded by a $, the pattern(excluding the ^) will be matched with the endi...
true
dd5e52323d02710e902a1bb7ca8615a18ecfb258
RockMurdock/Python-Book-1-Tuples
/zoo.py
1,703
4.46875
4
# Create a tuple named zoo that contains 10 of your favorite animals. zoo = ( "elephant", "giraffe", "hippopotamus", "monkey", "otter", "peacock", "panther", "rhino", "alligator", "lama" ) # Find one of your animals using the tuple.index(value) syntax on the tuple. print(zoo.i...
true
a610e27f93578dff94bf13b4d8c1a213f2997af0
kmollee/2014_fall_cp
/7/other/isPalindrome.py
919
4.25
4
# palindrome # remove all white space # and don;t care about capitalization, all character should be lowercase # base case # a string of length 0 or 1 is a palindrome # recursive case # if first character matches last character, # then is a palindrome if middle section is palindrome # http://www.palindromelist.net/ ...
false
c95d54e49c03fc707c8081fb3fa6f67bb27a8046
kmollee/2014_fall_cp
/7/other/quiz/McNuggets.py
1,336
4.34375
4
''' McDonald’s sells Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is possible, for example, to buy exactly 15 McNuggets (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 McNuggets, since no non- negative integer combination of 6's, 9's and 20's add up to 16. ...
true
deaaf816ff3deab54b62b699d53b417ad3cbb3f1
MehdiNV/programming-challenges
/challenges/Staircase
1,216
4.34375
4
#!/bin/python3 """ Problem: Consider a staircase of size (n=4): # ## ### #### Observe that its base and height are both equal to n and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size n """ import math import os impor...
true
c957f654ddb5d6c2fa6353ad749a7dbbb151bc44
MehdiNV/programming-challenges
/challenges/Diagonal Difference
1,576
4.5
4
#!/bin/python3 """ Problem: Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix (arr) is shown below: 1 2 3 4 5 6 9 8 9 Looking at the above, you can see that... The left-to-right diagonal = 1 +...
true
586bd4a6b6ec0a7d844531448285fab1499f10bd
NontandoMathebula/AI-futuristic
/Python functions.py
1,492
4.53125
5
import math #define a basic function #def function1(): # print("I am a cute function") #function that takes arguments #def function2(arg1, arg2): #print(arg1, " ", arg2) #funcion that returns a value #def cube(x): #return x*x*x #function with default value for an argument def power(num, x = 1)...
true
cf8e3546673231056cd11c663e0dfde3b158fb9c
albertisfu/devz-community
/stacks-queues/stacks-queues-2.py
2,013
4.21875
4
#Node Class class Node: def __init__(self, data): self.data = data self.next_node = None #LinkedList Class class Stack: def __init__(self): self.head = None #append new elements to linked list method def push(self, data): new_node = Node(data) if self.head =...
true
796196c624f370d5237a3f5102e900e534adc4e7
sandeepmendiratta/python-stuff
/pi_value_to_digit.py
1,004
4.28125
4
#!/usr/bin/env python3 """"Find PI to the Nth Digit - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go.""" import math def getValueOfPi(k): return '%.*f' % (k, math.pi) def main(): """ Console Function to create the interactiv...
true
092a3fd97569804c742af907c3279274384885fa
333TRS-CWO/scripting_challenge_questions
/draw_box.py
545
4.25
4
from typing import List ''' Complete the draw_box function so that given a non-negative integer that represents the height and width of a box, the function should create an ASCII art box for returning a list of strings. Then wall of the box should be made up of the "X" character The interior of the box should be ma...
true
4698e65f6b47edcf78afa0b583ccc0bb873df5a3
shouryaraj/Artificial_Intelligence
/uniformed_search_technique/uniform-cost-search.py
1,787
4.21875
4
""" Implementation of the uniform cost search, better version of the BFS. Instead of expanding the shallowest node, uniform-cost search expands the node n with the lowest path cost """ from queue import PriorityQueue # Graph function implementation class Graph: def __init__(self): self.edges = {} ...
true
2e5e44ba73492ca11a60fc193f088a191b7fd91f
akdutt/simple-programs
/193negative.py
202
4.1875
4
a=raw_input("Enter a no which you want to finf Negative , Positive or Zero. ") if int(a)>0: print ("No is Positive. ") elif int(a)<0: print("No is Negative. ") else : print ("No is Zero. ")
false
d9c92cbd819418374239d8e0915c76926a994e13
Pavithralakshmi/corekata
/poer.py
207
4.125
4
print(" power of input") y=0 while y==0: number1 = int(input('Enter First number : ')) number2 = int(input('Enter Second number : ')) o=number1**number2 print(o) y=int(input("0 to continue"))
false
5f40dec210d36c3114c1d66a8c2c63371e93fa88
Pavithralakshmi/corekata
/m7.py
356
4.1875
4
print("cheack the given input is mulitiple by 7"); y=0 while y==0: num=int(input("enter ur first input")) if num>1: for i in range(1,num): if num%7==0: print (num,"this number is multiple by 7") break else: print(num,"this number is not multiple by 7") y=int(input("ë...
true
581c8b441de9dcafd76d98cfc6841f3b95bdf2c2
Pavithralakshmi/corekata
/sec.py
290
4.1875
4
print("calculate amounts of seconds ") days =int(input("Inputdays: ")) * 3600* 24 hours = int(input("Input hours: ")) * 3600 minutes = int(input("Input minutes: ")) * 60 seconds = int(input("Input seconds: ")) time = days + hours + minutes + seconds print("The amounts of seconds ", time)
true
886e48bc59c4e8c424270e8491c16569ed458dd8
faisalmoinuddin99/python
/python/chapter1/complexType.py
879
4.15625
4
def __main__(): tuple = (2,5,6) #tuples are fixed print(tuple) #List list = [4,1,9,3,2,0,45] list.sort() print(list) #Dictionary dict1 = {'one':1,'two':2} print(dict1) dict2 = dict([('one',1),('two',2)]) print(dict2) dict3 = dict(one=1,two=2) p...
false
da849e60a9415fcab68301964185eec25d87a179
ExerciseAndrew/Algorithms
/python/Stack.py
1,271
4.25
4
### Implementation of a stack using python list class Stack: def __init__(self, items): #creates empty stack self._theItems = list() def isEmpty(self) #returns True if stack is empty return len(self) == 0 def __len__(self): #returns number of items in...
true
eea7f7d0ba7898a1710816682b1aa4fad7ca2731
Surfsol/Intro-Python-I
/src/12_scopes.py
1,019
4.375
4
# Experiment with scopes in Python. # Good reading: https://www.programiz.com/python-programming/global-local-nonlocal-variables # When you use a variable in a function, it's local in scope to the function. x = 12 def change_x(): x = 99 change_x() x = 99 # This prints 12. What do we have to modify in chang...
true
609f758927e1418796543ffde2c9dc366c38bc59
MuhammadEhtisham60/dev-code2
/string.py
723
4.1875
4
""" print('Hello') print("Hello") a="Hello World" print(a) """ #string are array """ a="Hello_World" print(a[9]) """ #b="hello,world" #print(b[-5:-3]) #c="Hello, shami" #print(len(c)) #print(c.strip()) #print(c.lower()) #print(c.upper()) #print(c.replace("shami","world")) #print(c.split(",")) """ txt="The rain i...
false
6576d205ded2eb55bb61f325c12e4c57926e3961
Chaudhari-Chirag/sippython
/exercise/ex2.py
256
4.1875
4
# -*- coding: utf-8 -*- def max_of_three(num1, num2, num3): if num1 > num2 > num3: return num1 elif num1 < num2 < num3: return num3 else: return num2 print (max_of_three(2, 3, 4)) print (max_of_three(4, 3, 2)) print (max_of_three(2, 4, 3))
false
4fd91d5b414a5268ea4baceed3e5a36a65e289a4
Chaudhari-Chirag/sippython
/sip/sipA24_revloops.py
458
4.21875
4
# -*- coding: utf-8 -*- #loops #for loop for i in range(1,5): print(i, end=' ') for i in range(1, 20): if i%2==0: print(i, 'is even number') for i in range(1, 100): if i%i==0 and i%2>0 and i%3>0 and i%5>0: print(i, 'is prime number') #while while True: s = input("Enter ...
false
beaeb644f8fe8229b68743dd33a8c898fa70a701
Nathiington/COMP322
/Lab03/greatest.py
279
4.1875
4
num1 = int(input('Enter the first number: ')) num2 = int(input('Enter the second number: ')) if num1 > num2: print('{0} is greater than {1}'.format(num1,num2)) if num2 > num1: print('{0} is greater than {1}'.format(num2, num1)) else: print('Both numbers are equal')
true
15c333a2098d819b9a27780609d683801c0e8643
Btrenary/Module6
/basic_function_assignment.py
737
4.15625
4
""" Author: Brady Trenary Program: basic_function_assignment.py Program takes an employee's name, hours worked, hourly wage and prints them. """ def hourly_employee_input(): try: name = input('Enter employee name: ') hours_worked = int(input('Enter hours worked: ')) hourly_pay_rate = floa...
true
b247074ec75f920382e80eeae0f68a123d8e15d0
mathe-codecian/Collatz-Conjecture-check
/Collatz Conjecture.py
743
4.3125
4
""" The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half the previous term. If the previous term is odd, the next term i...
true
1f77b65cded382e0c1c0b149edf94e02c67f5bb5
farremireia/len-slice
/script.py
375
4.15625
4
toppings = ['pepperoni', 'pineapple', 'cheese', 'sausage', 'olives', 'anchovies', 'mushrooms'] prices = [2,6,1,3,2,7,2] num_pizzas = len(toppings) print('We sell ' + str(num_pizzas) + ' different kinds of pizzas!') pizzas = list(zip(prices, toppings)) print(pizzas) pizzas.sort() print(pizzas) cheapest_pizza = pizza...
true
87d31fe1d670b7c6dc43441b6eefc8f578cadc52
truevines/GenericExercise
/isomorphic_strings.py
1,115
4.1875
4
''' Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but ...
true
d46999e4c6dd96a8edeac232fa3a989160530596
alexzinoviev/itea_c
/advance/advance_04_3.py
1,234
4.15625
4
# class A: # def __init__(self): # self.x = 0 # public переменная # self._x = 0 # private - не использовать! # self.__x = 0 # hidden # # # a = A() # print(a.x) # print(a._x) # #print(a.__x) # # print(vars(a)) # # print(a._A__x) # class A: # def __init__(self): #...
false
3d8460e71d08dfd3446437d5ac6904822c59f6a2
gavinchen523/learning_python
/part2.py
2,046
4.21875
4
#!/usr/bin/env python #DATA type # 1. Number num1=3 num2=2 num3=num1/num2 print(type(num1)) print(type(num2)) print(type(num3)) # 2. String str = 'abcdefasdsfa' print('string len: ', len(str)) es_str=r'\t' print('string len: ', len(es_str)) es2_str=""" a ab abc """ print('string len: ', len(es2_str)) # 3. Boolean # ...
false
2087c9753aaa8e60bd2add3256f03431a538d185
HarleyRogers51295/PYTHON-LEARNING
/1.1 PYTHON/1.4 pythong-numbers.py
1,445
4.21875
4
import math import random print("-------------BASICS & MATH--------------") #integer is a whole number ex. 4, 500, 67, 2........ no decimals #float has a decimal point ex. 1.521346584 ..... #python auto changes these for you if you do 1 + 1.5 it will be 2.5. #you can use +, -, /, *, %, **(to the power of!) print(abs(-...
true
ade8f044c63fbfac40e25b851ded70da30ab1533
the-potato-man/lc
/2018/21-merge-two-sorted-lists.py
776
4.125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ # Creating pointers ...
true
87cee9d43718c10c989e16c6c993abd82d40d4ef
uit-inf-1400-2017/uit-inf-1400-2017.github.io
/lectures/05-summary-and-examples/code/PointRobust.py
1,947
4.34375
4
# Program: RobustPoint.py # Authors: Michael H. Goldwasser # David Letscher # # This example is discussed in Chapter 6 of the book # Object-Oriented Programming in Python # from math import sqrt # needed for computing distances class Point: def __init__(self, initialX=0, init...
true
afec1e0f73187993bcccc19b708eca0234b959f1
merileewheelock/python-basics
/objects/Person.py
1,904
4.21875
4
class Person(object): #have to pass the object right away in Python def __init__(self, name, gender, number_of_arms, cell): #always pass self, name is optional self.name = name self.gender = gender #these don't have to be the same but often make the same self.species = "Human" #all Persons are automatically set...
true
9a16c86ce7f42e1d826b67de35c866885e79c9b6
merileewheelock/python-basics
/dc_challenge.py
2,153
4.5
4
# 1) Declare two variables, a strig and an integer # named "fullName" and "age". Set them equal to your name and age. full_name = "Merilee Wheelock" age = 27 #There are no arrays, but there are lists. Not push, append. my_array = [] my_array.append(full_name) my_array.append(age) print my_array def say_hello():...
true
d18cc25296b06719cefe2efa1c9c836a6689b982
Orcha02/Mock_Interviews
/Python/No_c.py
309
4.15625
4
#!/usr/bin/env python3 def no_c(my_string): the_new_string = '' for char in my_string: if char == 'C' or char == 'c': continue the_new_string = the_new_string + char return the_new_string print(no_c("Holberton School")) print(no_c("Chicago")) print(no_c("C is fun!"))
false
fa07c4342580abebebeb3107c1a642a5fdc3d580
manaya078/Python_base
/0Deep/ReLU.py
413
4.21875
4
""" ReLU関数(Rectified Linear Unit) 入力が0より大きいなら入力をそのまま出力し、0以下なら0を出力する def relu(x): return np.maximum(0, x) """ import numpy as np import matplotlib.pylab as plt def relu(x):#ReLU関数 return np.maximum(0, x) x = np.arange(-5.0, 5.0, 0.1)#-5.0から5.0まで0.1刻み y = relu(x) plt.plot(x, y) plt.ylim(-0.1, 5.0)#y軸の範囲 plt.s...
false
737f4b4ac58e7c1cd65b096b1f93db0fccfdfaa6
Zubair-Ali61997/learnOOPspring2020
/main1.py
1,752
4.3125
4
#Taking the range of number from the user to find even and odd using for loop startNum = int(input("Enter starting value: ")) endNum = int(input("Enter end value: ")) for eachNumber in range(startNum,endNum+1): modeValue = eachNumber % 2 if modeValue == 0: print(eachNumber, "is an even") else...
true
6e892b4f6d70d5c79be4b157697d474eb6ebd5cb
G00387847/Bonny2020
/second_string.py
279
4.25
4
# Bonny Nwosu # This program takes asks a user to input a string # And output every second letter in reverse order. # Using Loop num1 = input("Please enter a sentence") def reverse(num1): str = "" for i in num1: str = i + str return str print(end="") print(num1[::-2])
true
f5c751a2014f66acb82280c0ae522afd590fd8fd
yanethvg/Python_stuff
/concepts/entrada.py
407
4.15625
4
#print("¿Cual es tu nombre?") nombre = input("¿Cual es tu nombre?\n") #print("¿Cual es tu edad?") edad = int(input("¿Cual es tu edad?\n")) #print("¿Cual es tu peso?") peso = float(input("¿Cual es tu peso?\n")) #print("Estas autorizado?(si/no)") autorizado = input("Estas autorizado?(si/no)\n") == "si" print("Hola",n...
false
da72a6c6f6470375671f399c4118d57d0346938c
yanethvg/Python_stuff
/class/herencia_multiple.py
1,330
4.21875
4
# como se lee de arriba hacia abajo # se deben definir las clases antes que las clases hijas class Animal: def __init__(self,nombre): self.nombre = nombre def comer(self): print("Comiendo") def dormir(self): print("Durmiendo") def comun(self): print("Este es un...
false
fb2bb0a3eaab6f9cdc2cc9d35b0d23b992d21e41
skolte/python
/python2.7/largest.py
825
4.1875
4
# Write a program that repeatedly prompts a user for integer numbers until # the user enters 'done'. Once 'done' is entered, print out the largest and # smallest of the numbers. If the user enters anything other than a valid number # catch it with a try/except and put out an appropriate message and ignore the number....
true
d0e11c937aed44b865d184c98db570bfb5d522d5
jegarciaor/Python-Object-Oriented-Programming---4th-edition
/ch_14/src/threads_1.py
587
4.1875
4
""" Python 3 Object-Oriented Programming Chapter 14. Concurrency """ from threading import Thread class InputReader(Thread): def run(self) -> None: self.line_of_text = input() if __name__ == "__main__": print("Enter some text and press enter: ") thread = InputReader() # thread.start() # C...
true
531389502dac8cacf8f628a76453a2760f6d51d7
ningshengit/small_spider
/PythonExample/PythonExample/菜鸟编程网站基础实例/Python 翻转列表.py
410
4.1875
4
实例 1 def Reverse(lst): return [ele for ele in reversed(lst)] lst = [10, 11, 12, 13, 14, 15] print(Reverse(lst)) 实例 2 def Reverse(lst): lst.reverse() return lst lst = [10, 11, 12, 13, 14, 15] print(Reverse(lst)) 实例 3 def Reverse(lst): new_lst = lst[::-1] re...
false
42912022fbc9cb00f9ee3721a18434e955d46f69
ningshengit/small_spider
/PythonExample/PythonExample/菜鸟编程网站基础实例/Python 将列表中的指定位置的两个元素对调.py
822
4.125
4
实例 1 def swapPositions(list, pos1, pos2): list[pos1], list[pos2] = list[pos2], list[pos1] return list List = [23, 65, 19, 90] pos1, pos2 = 1, 3 print(swapPositions(List, pos1-1, pos2-1)) 实例 2 def swapPositions(list, pos1, pos2): first_ele = list.pop(pos1) se...
false
0c98aecf543889b9c73f73b014508a184b0507e2
Tower5954/Instagram-higher-lower-game
/main.py
1,790
4.21875
4
# Display art # Generate a random account from the game data. # Format account data into printable format. # Ask user for a guess. # Check if user is correct. ## Get follower count. ## If Statement # Feedback. # Score Keeping. # Make game repeatable. # Make B become the next A. # Add art. # Clear screen between rounds....
true
80ac17949c445619dda20aa217ae6a7158b014ce
wz33/MagicNumber
/magic_number.py
1,761
4.3125
4
from builtins import input # for handling user input gracefully in Python 2 & 3 #!/usr/bin/env Python3 # Python 2 & 3 """ Program generates a random number between 1 and 100, inclusive. User has five attempts to correctly guess the number. """ # Import Python module import random # for "magic" number generatio...
true
8d56284d45480737b0b2cd79d8c2358355828f8b
zahidkhawaja/cs-module-project-iterative-sorting
/src/iterative_sorting/iterative_sorting.py
1,989
4.375
4
# Runtime complexity: O(n ^ 2) - Quadratic # Nested for-loop def selection_sort(arr): # loop through n-1 elements for i in range(0, len(arr) - 1): cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 loc) for x in range(cur_ind...
true
54dde7561bb2c3ef7fab4db446088c997c168037
ZhaohanJackWang/me
/week3/exercise3.py
2,448
4.40625
4
"""Week 3, Exercise 3. Steps on the way to making your own guessing game. """ import random def check_number(number): while True: try: number = int(number) return number except Exception: number = input("it is not number plz enter again: ") def check_upper(upper, low): upper = check_n...
true
69d705b017380b3127c4c7cfda8636c3d8c16e3d
SOURADEEP-DONNY/PYTHON-3-PROGRAMMING
/week 4/ALIASING.py
636
4.21875
4
list1=[10,20,30] list2=[10,20,30] #CHECKING WHETHER THE TWO LISTS ARE SAME OR NOT. print(list1 is list2) #CHECKING THE IDS OF THE TWO LISTS. print('THE ID OF list1 is',id(list1)) print('THE ID OF list2 is',id(list2)) #CHECKING WHETHER THE LISTS ARE EQUIVALENT OR NOT. print(list1==list2) #--------AL...
true
b5278bb8872dd0ad65f8cc46180085c42e9fcdc0
SOURADEEP-DONNY/PYTHON-3-PROGRAMMING
/week 2/indexing.py
204
4.46875
4
#STRING AND LIST INDEXING st="SMARTPHONE" list1=['moto','mi','nokia','samsung'] #PRINTING THE LIST IN REVERSE ORDER print(list1[-1::-1]) #PRINTING THE STRING IN REVERSE ORDER print(st[-1::-1])
false
b259e685aef03dabe48233184d84bd228beac2a9
SOURADEEP-DONNY/PYTHON-3-PROGRAMMING
/PYTHON FUNCTIONS FILES AND DICTIONARIES/week 4/ADDITION OF AS MANY NUMBERS AS POSSIBLE.py
263
4.5
4
#PROGRAM TO ADD AS MANY NUMBERS AS POSSIBLE. TO STOP THE ADDITION ENTER ZERO. #THIS KIND OF LOOP IS ALSO KNOWN AS LISTENER'S LOOP. SUM=0 number=1 while number!=0: number=int(input('Enter a number to add-')) SUM=SUM+number print('The sum =',SUM)
true
ca0a7ee0294a77402a773cd3e928cdf7d2e075b6
SOURADEEP-DONNY/PYTHON-3-PROGRAMMING
/week 4/NON MUTATING METHODS OF STRINGS.py
499
4.1875
4
#NON MUTATING METHODS OF STRINGS # 1.UPPER METHOD s=' souradeep is an engineer ' print(s.upper()) # 2.LOWER METHOD s2=' SOURADEEP IS AN ENGINEER. ' SS=s2.lower() print(SS) #3. COUNT METHOD c=s.count('e') print('THE TOTAL NUMBER OF "e"',c) #4. STRIP METHOD print('***'+s.strip()+"***") ...
false
53d6f8a3a438037857021c5d2264c6817c7406a1
olgarozhdestvina/pands-problems-2020
/Labs/Topic09-errors/check_input.py
417
4.28125
4
# Olga Rozhdestvina # a program that takes in a number as an input and subtracts 10% # prints the result, # the program should throw a value error of the input is less than 0 # input number num = int(input("Please enter a number: ")) # calculate 90% percent = 0.90 # (1- 0.10) ans = num * percent if num < 0: rai...
true
ad6d93d3e1a7f72bf3749244698bf8dbaa7b4399
jrbublitz/Aulas-python
/material/0 Primeiros passos/apoio.py
998
4.28125
4
# Declaração de variável x = 1 y = "Teste" _nome = "Gustavo" Altura = 1.8 # Eclusão de uma variável del x del y del _nome del Altura # Declarando várias variaveis com o mesmo valor x = y = z = "Um valor aí" # Declarando várias variaveis com o vários valores x, y, z = "Valor1", 2, True # ou x, y, z = ("Valor1", 2,...
false
85bb1fe7789199c56764cc8e42c056066c4fbbe2
hay/codecourse
/solutions/erwin/opdracht06.py
421
4.21875
4
# -*- coding: utf-8 -*- names = [] for name in range(3): print name name = raw_input("Noem een naam: ") names.append(name) fruit = raw_input("Vertel me je lievelingsvrucht: ") for name in names: if name[0].isupper(): print "Aangenaam, " + name else: print "Hoi " + name print "De lettercombinatie '...
false
a142e7901d6517a5f203c3a42783d22fc744fd40
hay/codecourse
/examples/lists1.py
559
4.21875
4
names = ["Bert", "Ernie", "Pino"] for name in names: print "Aangenaam, " + name print names[1] # "Bert" print names[-1] # "Pino" hellos = [] for name in names: hellos.append("Hallo " + name) for hello in hellos: print hello years = [1983, 1980, 1993] for year in years: print year print 1983 in y...
false
326f824c5da9e3238e310bf849ed90f06c35cf90
RaOneG/CS106A-Completionist-Files
/Section-5/stringconstruction.py
1,964
4.28125
4
def only_one_first_char_new(s): """This function builds up a new string adding all characters in the input string except those that are the same as the first char >>> only_one_first_char_new('abba abba abba') 'abb bb bb' >>> only_one_first_char_new('Stanford') 'Stanford' >>> o...
false
524e98dfa7805b3c42ff0c3c021510afdabeaf0a
SirMatix/Python
/MITx 6.00.1x Introduction to Computer Science using Python/week 1/Problem set 1/Problem 3.py
1,413
4.15625
4
""" Problem 3 15.0/15.0 points (graded) Assume s is a string of lower case characters. Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print Longest substring in alphabetical order is: beggh In th...
true