blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a856fb36597912de35ac0cbce90aadb781d63599
bria051/Game
/Tic_tac_toe/choose.py
345
4.21875
4
def choosing(): print("Choose O or X to play the Game:") while (True): user = input() if (user == 'O'): computer = 'X' break elif (user == 'X'): computer = 'O' break else: print("You chose the wrong one. Choose again") ...
true
881c561f1e8ca930a70a4c7a35be7df48b8bbc04
jiuash/python-lessons-cny
/code-exercises-etc/section_04_(lists)/ajm.lists01_attendees.20170218.py
983
4.125
4
##things = [] ##print things attendees = ['Alison', 'Belen', 'Rebecca', 'Nura'] #print attendees print attendees[0] ##name = 'Alison' ##print name[0] print attendees[1:3] print attendees[:3] #print attendees[4] #print len(attendees) number_of_attendees = len(attendees) print number_of_attendees attendees.append(...
true
495f7f47477d142d149095c3c84906575ab22bdd
Austin306/Python-Assessment
/prob2.py
704
4.3125
4
def comparator( tupleElem ) : '''This function returns last element of tuple''' return tupleElem[1] def main(): '''This function takes the tuple as input and sorts it''' final_list = [] lines = input('Enter the list of tuples separated by , : ') for tup in lines.split('),('):#This For Loop is us...
true
bcf6cc01615591b36df9c3822ae51821c684d6ff
nicholaskarlson/Object-Oriented-Programming-in-Python
/off day.py
2,170
4.125
4
# creating a class of my class. class Science: form ="c" num_student=0 def __init__(self,name,college_num,fav_sub): self.name=name self.college_num=college_num self.fav_sub=fav_sub Science.num_student+=1 def introduce(self): print(f"Hey! I am {self.name}.My...
true
537a10b2964afb6cbecdce161536769f24eb410f
sokuro/PythonBFH
/03_Exercises/Stings/06_SplitStringDelimiter.py
278
4.28125
4
""" split a string on the last occurrence of the delimiter """ str_input = input('Enter a String: ') # create a list from the string temp_list = list(str_input) int_input = int(input('Enter a Number of split Characters: ')) print(str(temp_list).rsplit(',', int_input))
true
3fc66aa0b3bde5ee6a7d3bafdeb6bab46f0c926e
sokuro/PythonBFH
/01_Fundamentals/Strings/Exercises/04_IsString.py
344
4.40625
4
""" get a new string from a given string where "Is" has been added to the front. If the given string already begins with "Is" then return the string unchanged. """ def IsString(str): if len(str) >= 2 and str[:2] == 'Is': return str else: return 'Is' + str print(IsString("Testing")) print...
true
c8c32cfec48b1307d4b5156bbe8881d0303063d0
sokuro/PythonBFH
/01_Fundamentals/Lists/Lists.py
477
4.125
4
""" * Lists are MUTABLE ordered sequence of items * Lists may be of different type * [] brackets * Expressions separated by a comma """ list1 = [1, 2.14, 'test'] list2 = [42] list3 = [] # empty list list4 = list() # empty list # ERROR # list5 = list(1, 2, 3) # Solving list6 = list((1, 2, 3)) # List out o...
true
286f659c944c2744440dcdf9b3ffba55d4e4b1c1
sokuro/PythonBFH
/01_Fundamentals/Sort/01_Sort.py
414
4.21875
4
""" sort(...) L.sort(key=None, reverse=False) """ # List of Names names = ["Karol", "Rebeca", "Daniel", "Michael", "Patrik", "Richard"] # sort alphabetically names.sort() print(names) # sort reversed names.sort(reverse=True) print(names) # Tuple of Names names_tuple = ("Karol", "Rebeca", "Daniel", ...
true
da46590dcb44a879d75f9ebe34eeb043545760c8
nithin-kumar/urban-waffle
/LucidProgramming/paranthesis_balance_stack.py
551
4.15625
4
from stack import Stack def is_balanced(expression): stack = Stack() for item in expression: if item in ['(', '[', '{']: stack.push(item) else: if is_matching_paranthesis(stack.peek(), item): stack.pop() else: return False if not stack.is_empty(): return False return True def is_matching_p...
true
abcbb6f7a02de5de2d19df7a96a2fa018d2d1985
nithin-kumar/urban-waffle
/InterviewCake/max_product_3.py
699
4.125
4
import math def highest_product_of_3(list_of_ints): # Calculate the highest product of three numbers if len(list_of_ints) < 3: raise Exception return window = [list_of_ints[0], list_of_ints[1], list_of_ints[2]] min_number = min(window) min_index = window.index(min_number) prod =...
true
a8798d0623136431334ef7e791b6b5cd2a81e187
nachobh/python_calculator
/main.py
1,064
4.1875
4
def compute(number1, operation, number2): if is_number(number1) and "+-*/^".__contains__(operation) and is_number(number2): result = 0 if operation == "+": result = float(number1) + float(number2) elif operation == "-": result = float(number1) - float(number2) ...
true
a1b1b2983bf4721f26de6b1cf85468509703bc46
SjorsVanGelderen/Graduation
/python_3/features/classes.py
1,010
4.125
4
"""Classes example Copyright 2016, Sjors van Gelderen """ from enum import Enum # Enumeration for different book editions class Edition(Enum): hardcover = 0 paperback = 1 # Simple class for a book class Book: def __init__(self, _title, _author, _edition): self.title = _title self.author =...
true
6a33fc24a8ebcbae955ef6e91e6cd5f6d918596c
ankit1765/Hangman-and-other-fundamental-programs
/HIghScores.py
700
4.15625
4
#This program asks is a high score displayer. #It asks the user how many entries they would like to input #and how many top scores it should display scores = [] numentries = int(raw_input("How many entries would you like to Enter? ")) numtop = int(raw_input("How many top scores would you like to display? ")) count =...
true
0ee0d2873e2aec1ab8e74319127281ac81eb79c6
Arween/PythonMIT-lessons
/Lecture-test/lect2_t2.py
753
4.25
4
outstandingBalance = float(raw_input("Enter the outstanding balance on your credit card: ")); interestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: ")); monthlyPayment = 0; monthlyInterestRate = interestRate/12; balance = outstandingBalance; while balance > 0: monthlyPayment +=...
true
646d6816429c5dac188fd8693ffb4406aa57e752
aamartinez25/effective-system
/cpu.py
1,482
4.1875
4
# #Author: Adrian Martinez #Description: takes a few inputs on CPU specs and organizes them accordingly # # cpu_ghz = float(input('Enter CPU gigahertz:\n')) #input for CPU specs cpu_core = int(input('Enter CPU core count:\n')) cpu_hyper = input('Enter CPU hyperthreading (True or False):\n') print() if cpu_...
true
9a576e7335c48f855798d6c1e42d8be4da138fd5
niksanand1717/TCS-434
/03 feb/solution_2.py
499
4.15625
4
num1 = eval(input("Enter the first number: ")) num2 = eval(input("Enter the second number: ")) count1, count2 = 0, 0 print("\n\nNumbers divisible by both 3 and 5") for num in range(num1, num2+1): if num%3 == 0 and num%5 == 0: print(num) count1+= 1 print("Total numbers of numbers:",count1) print(...
true
360b2dba16714f2e2fee62d85537d49faefab8c1
niksanand1717/TCS-434
/28 april/fourth.py
292
4.34375
4
"""Input a string and return all the words starting with vowels""" import re pattern = '^[aeiou]' str1 = input("enter string: ") print("Following are the words in entered string starting with vowel: ", end=' ') [print(word, end=' ') for word in str1.split(" ") if re.match(pattern, word)]
true
e3c9452a5563afe71101af97ced7f3834d042b83
niksanand1717/TCS-434
/28 april/first.py
276
4.5
4
"""Print all the words from a string having length of 3""" import re pattern = '(...)$' input_data = input("input string: ") print("Following are the words which have length 3: ") for words in input_data.split(" "): if re.match(pattern, words): print(words, end=" ")
true
d448f3cebeff50b9eb66a2d1749d703c7a4f635e
farmani60/coding_practice
/topic10_bigO/log_n.py
1,147
4.15625
4
""" Logarithmic time complexities usually apply to algorithms that divide problems in half every time. If we implement (Algorithm A) going through all the elements in an array, it will take a running time of O(n). We can try using the fact that the collection is already sorted. Later, we can divide in half as we look ...
true
0f8fe20a3d49ce95591f9d9c46dd57d17e007866
nomatterhowyoutry/GeekPython
/HT_1/Task6.py
263
4.28125
4
# 6. Write a script to check whether a specified value is contained in a group of values. # Test Data : # 3 -> [1, 5, 8, 3] : True # -1 -> (1, 5, 8, 3) : False list = [1, 5, 8, 3] tuple = tuple(list) print(3 in list) print(-1 in tuple)
true
96819f1bdd9469451af6089d77a9c6a979709856
vanTrant/py4e
/ex3_try_exec/script.py
361
4.1875
4
# hours = input('Enter Hours: ') # rate = input('Enter Rate: ') try: hours = float(input('Enter Hours: ')) rate = float(input('Enter Rate: ')) except: print('Please enter a valid number') quit() if hours > 40: overtime_pay = (hours - 40) * (rate * 1.5) pay = 40 * rate + overtime_pay else: ...
true
d5b0514e7c3e53f7f1bf6ec53717c79f81325591
yevgenybulochnik/lp3thw
/ex03/drill1.py
859
4.375
4
# Simple print statement that prints a string print("I will count my chickens:") # Prints a string then divides 30 by 6 then adds 25 print("Hens", 25 + 30 / 6) # Prints a string then gives you the remainder of 75/3 or 3 and subtracts from 100 print("Roosters", 100 - 25 * 3 % 4) print("Now I will count the eggs:") # ...
true
8905a8a1c3bd892fef8604ff4e1c8741c730654a
PaulSweeney89/squareroot
/sqrt_test.py
830
4.3125
4
# defining a fuction to calculate the square root of a positive real number # using Newton's method (ALTERNATIVE) while True: A = float(input("Please input positive value ")) if A > 0: break else: ...
true
0ad794722abfb826b414f7d7eeb51f6b59293c5f
ljsauer/DS-From-Scratch
/Notes/Chapter 4.py
1,188
4.375
4
"""Linear Algebra: the branch of math that deals with vector spaces """ # # Vectors - objects that can be added together to form new vectors, # and that can be multiplied by scalars; points in some # finite-dimensional space from typing import List Vector = List[float] height_weight_age = [70, ...
true
6b997548a37e7a761a789a4b44df67cfa69651d8
blainekuhn/Python
/Reverse_text.py
255
4.15625
4
def reverse(text): word = [text] new_word = "" count = len(text) - 1 for letter in text: word.insert(0, letter) for a in range(len(word) - 1): new_word = new_word + word[a] return new_word print reverse("This is my text to reverse")
true
494d979b41757904cbcc0e9f10a6adfb0d5132f2
Gopi3998/UPPERCASE-AND-LOWERCASE
/Uppercase and Lowercase...py
527
4.34375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: print('Starting the program for count the upper and lower case'.center(80,'*')) sample = input('enter string: ') uppercase = 0 lowercase = 0 for ch in sample: if str .isupper(ch): uppercase+=1 elif str.islower(ch): lowercase+=1 print('No of upper...
true
6e9034990271d7ed4549663f9d537dd7ac8f6a86
Veletronic/Farmville
/Sheep_class.py
1,217
4.125
4
from Animal import * class Sheep(Animal): #Cow inherits from Animal """A sheep""" #Constructor def __init__(self): #Call the parent class constructor with default value #Growth rate =1; food requirement = 3; water requirement = 3 super().__init__(1,3,3) self._type...
true
14025dd27c8f83cf0fed8b4cfea0c76badea0319
sarahovey/AnalysisOfAlgos
/hw1/mergesort.py
1,995
4.15625
4
#Sort #Merge Sort def merge_sort(numbers): #Divide the list into halves recursively if len(numbers) > 1: #get midpoint of list mid = len(numbers)/2 left = numbers[:mid] right = numbers[mid:] merge_sort(left) merge_sort(right) #index varia...
true
2ad2891489db9ee7ddfd36acf02fbf71eac598bf
codeaudit/tutorial
/exercises/exercise01.py
1,863
4.125
4
# The goal of this exercise is to show how to run simple tasks in parallel. # # EXERCISE: This script is too slow, and the computation is embarrassingly # parallel. Use Ray to execute the functions in parallel to speed it up. # # NOTE: This exercise should work even if you have only one core on your # machine because t...
true
cf3480dca530bcedcb764f2cb0655914d004a409
Abhishek-kr7/Basic-Python-Programming
/09_Functions_in_python.py
1,759
4.375
4
def hello(): """This function will print the Hello Message when called""" print('Hey there! Hello') # hello() def hello_user(user): '''This function will take a parameter or name and will print hello with the parameter/name''' print("Hello",user, "How are you") hello_user('abhi') print(help(hell...
true
5fc1530a3fb637127abf517484c0e96f3940fdd4
Axl11475581/Projects-Folder
/Python Exercises/Python Basics/Practical Exercise.py
2,256
4.53125
5
# 7 Exercise to practice the previous topics viewed 1 price_product_1 = input("What is the price of the product 1?: \n ") quantity_product_1 = input("How many of the product 1 will you buy?: \n ") price_product_2 = input("What is the price of the product 2?: \n ") quantity_product_2 = input("How many of the product 2 ...
true
770dfec0ac2a38cd1d55cd33087dde8caf87db28
ikamesh/Algorithms
/inputs.py
1,314
4.375
4
import random """This is file for generating input list for algorithms""" #input method1 -- filling list with try-except def infinite_num_list(): print(""" Press enter after each input. Press 'x' to when done...! """) num_list = [] while True: num = input("Enter num to fill the list : "...
true
7504bbb277af091a8b5b4bd1230ea416f169a5b3
uit-inf-1400-2021/uit-inf-1400-2021.github.io
/lectures/oop-02-03-oo-concepts/code/extending.py
1,281
4.375
4
#!/usr/bin/env python3 """ Based on code from the OOP book. """ class ContactList(list): def search(self, name): '''Return all contacts that contain the search value in their name.''' matching_contacts = [] for contact in self: if name in contact.name: m...
true
d0fec4e684b774cbc4b07cce6c7d7bacfa6681ca
shortma1/Coyote
/day6.py
615
4.25
4
# # functions # print("Hello") # print() is a function # num_char = len("Hello") # len() is also a function # print(num_char) # def my_function(): # def defines function, my_function() is the name of the function, and : finished the function definition # print("Hello") # print("Bye") # my_function() # to...
true
a08f76a2e3ccc91b0e0ebae2c191fd09f7c43063
piluvr/Python
/max.py
233
4.125
4
# your code goes here nums =[] input1 = int(input("Enter a number: ")) input2 = int(input("Enter a number: ")) input3 = int(input("Enter a number: ")) nums.append(input1) nums.append(input2) nums.append(input3) print(str(max(nums)))
true
d8c92e58919689ff644004479aad9cbae61218e2
shanjiang1994/LeetCode_for_DataScience
/Solutions/Array/88.Merge Sorted Array.py
2,809
4.34375
4
''' Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2. Example: Input: nums...
true
92b23cdfa9a34ba5230c0353dbc1958a63a38658
Skryvvara/DS1-Soullevel-Calculator
/soullevelcalc.py
1,287
4.1875
4
# returns cost of the given level # when level = 12 the returned cost is from level 11 -> 12 def get_level_cost(level: int) -> int: return int(round((0.02 * pow(level, 3)) + (3.06 * pow(level, 2)) + (105.6 * level) - 895, 0)) # returns the amount of possible levelups # takes the current level and the amount of hel...
true
cf79d548cfb65bb4ea3073cd0d1723981cea1400
sydoruk89/math_series
/math_series/series.py
1,177
4.1875
4
def fibonacci(n): """ The function return the nth value in the fibonacci series. Args: n (int): integer """ if n >= 0: if n < 2: return n else: return fibonacci(n - 1) + fibonacci(n - 2) else: return 'Please provide a positive number' ...
true
45521599af6d990c059840b0f1b70c9d3c482c6f
anshdholakia/Python_Projects
/map_filter.py
1,387
4.21875
4
# numbers=["1","2","3"] # # # for i in range(len(numbers)): # not suitable every-time to use a for loop # # numbers[i]=int(numbers[i]) # # # using a map function # numbers=list(map(int,numbers)) # # # numbers[2]=numbers[2]+5 # # print(numbers[2]) # def sq(a): # return a*a # num=[1,2,124,4,5,5,12...
true
6c465540793c7d032822d027ff5e58837b8fcf31
lovaraju987/Python
/learning concepts and practising/basics/sep,end,flash.py
443
4.15625
4
''' sep, end, flash''' print('slfhs',2,'shalds',end = ' ') # by default print statement ends with \n(newline).so, this 'end' is used to change to ending of the print statement when we required it print('sfjsaa',3,'hissa') print('sfjsaa',2,'hissa',sep = ' ') # by default multiple statemnets in one print without any s...
true
5733608db00de58d07cd64754e9592302e8e7dd6
badri-venkat/Computational-Geometry-Algorithms
/PolygonHelper.py
849
4.21875
4
def inputPolygon(numberOfPoints): polygonArray = [] print( "Enter the points in cyclic order. Each point is represented by space-separated coordinates." ) i=0 while i<numberOfPoints + 1: x, y = map(int, input().split()) polygonArray.append(tuple([x, y])) i+=1 if i...
true
e01e7b007f7041fccc232fc3e9ab9ecacb44dec4
kradical/ProjectEuler
/p9.py
467
4.15625
4
# A Pythagorean triplet is a set of three # natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet # for which a + b + c = 1000. # Find the product abc. def test(): for a in range(1, 333): for b in range(1000-a): ...
true
732c172fbce4e4cac32875feb880b5e1c6ac59f4
CucchiettiNicola/PythonProgramsCucchietti
/Compiti-Sistemi/Es32/Es32.py
1,475
4.75
5
the_count = [1,2,3,4,5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quartiers'] # this first kind of for-loop goes trough a list for number in the_count: print(f"This is count {number}") # same as above for fruit in fruits: print(f"A fruit of type: {fruit}") #...
true
272d6b26253dfb3573be18709097920d1dbb07ab
cb-kali/Python
/Day13.py
1,021
4.1875
4
''' Introduction to python class: Class --> it's like a blueprint of codedesing. class method --> A function writen inside a class is called a method. attributes --> a variable writen inside a class is called an attributes. Introduction of a class/object ''' # req:- ''' You have to create a class, it should your ...
true
29e91abac0e3e1202cd2fef2f4666bfe681dc9be
robert0525/Python-
/hello.py
393
4.1875
4
first_name = input("What's is your first name? ") print("Hello", first_name) if first_name == "Robert": print(first_name, "is learning Python") elif first_name == "Maxi": print(first_name, " is learning with fellow students in the Comunity! Me too!") else: print("You should totally learn Python, {}!".form...
true
a8cb384dc0440a3f8ae962d3c543af8e179fa9cd
riteshelias/UMC
/ProgramFlow/guessgame.py
1,734
4.125
4
import random answer = random.randint(1, 10) print(answer) tries = 1 print() print("Lets play a guessing game, you can exit by pressing 0") guess = int(input("try count - {}. Please enter a number between 1 and 10: ".format(tries))) while guess != answer: if guess == 0: print("Bye, have a nice day!") ...
true
16f595b7e1ff1b8b22ab8ba1221d96448a03d15e
daniel10012/python-onsite
/week_01/03_basics_variables/07_conversion.py
526
4.375
4
''' Celsius to Fahrenheit: Write the necessary code to read a degree in Celsius from the console then convert it to fahrenheit and print it to the console. F = C * 1.8 + 32 Output should read like - "27.4 degrees celsius = 81.32 degrees fahrenheit" NOTE: if you get an error, ...
true
9e6b89661cd68140884634d1a7978e4afc899e98
daniel10012/python-onsite
/week_02/11_inheritance/01_class_attributes.py
910
4.40625
4
''' Flush out the classes below with the following: - Add inheritance so that Class1 is inherited by Class2 and Class2 is inherited by Class3. - Follow the directions in each class to complete the functionality. ''' class Class1: def __init__(self, x): self.x = x # define an __init__() met...
true
fe26c3fa3494717d2cb65c234594323fae19a5f0
daniel10012/python-onsite
/week_04/intro_apis/01_countries.py
1,117
4.375
4
''' Use the countries API https://restcountries.eu/ to fetch information on your home country and the country you're currently in. In your python program, parse and compare the data of the two responses: * Which country has the larger population? * How much does the are of the two countries differ? * Print the native ...
true
06774114cb67d9626933f4f3d752b8beb4f9f2b2
daniel10012/python-onsite
/week_03/01_files/04_rename_doc.py
1,156
4.125
4
''' Write a function called sed that takes as arguments a pattern string, a replacement string, and two filenames; it should read the first file and write the contents into the second file (creating it if necessary). If the pattern string appears anywhere in the file, it should be replaced with the replacement string. ...
true
cd99f695faa50653c2ca9488547a528059c94d62
daniel10012/python-onsite
/week_02/06_tuples/01_make_tuples.py
502
4.34375
4
''' Write a script that takes in a list of numbers and: - sorts the numbers - stores the numbers in tuples of two in a list - prints each tuple Notes: If the user enters an odd numbered list, add the last item to a tuple with the number 0. ''' my_list = [5,3,32,1,3,9,5,3,2,2,5] my_list.sort() if len(...
true
fd1561a9a0a9c1cf29c24efbf299c0e3e135fa19
balaramhub1/Python_Test
/Tuple/Tuple_03.py
668
4.125
4
''' Created on Jul 17, 2014 @author: HOME The script is to see the function of T.index[x] and T.count(x) methods of Tuple ''' list1=['hello','balaram'] color = ("red","green","blue",list1) fruit =(5,"lemon",8,"berry",color,"grapes","cherry") numtup=(4,6,3,2,5,23,3,2,4,2,3,5) print("Elements of List1 are : ",...
true
bd2ca872c954096e50e818e402969a3bc9a1ff8b
balaramhub1/Python_Test
/Math/math_03.py
394
4.125
4
''' Created on Jun 14, 2020 Usage of Random module @author: beherb2 ''' import random print(random.random()) # Choose a random number from a list l=[1,2,3,4,5,6] print(random.choice(l)) # generate a random number between a range print(random.randint(10,100)) # end number is not included print(random.randrange(10...
true
9b1e5b1a994bc633e8eabe5131f79db0bbfd2c21
jage6277/Portfolio
/Discrete Structures/Unsorted to Sorted List.py
1,559
4.21875
4
# This function takes two sorted lists and merges them into one sorted list # Input: L1,L2 - Two sorted lists # Output: L - One sorted list def merge(L1,L2): L = [] # Array where the sorted list will be stored while len(L1) != 0 and len(L2) != 0: # While L1 and L2 are both nonempty if ...
true
9ca92b5f121723702b7901dfa4d2d3f86885b077
rnagle/pycar
/project1/step_2_complete.py
810
4.25
4
# Import built-in python modules we'll want to access csv files and download files import csv import urllib # We're going to download a csv file... # What should we name it? file_name = "banklist.csv" # Use urllib.urlretrieve() to download the csv file from a url and save it to a directory # The csv link can be found...
true
2f00505d175bd72b047b898d367fc9a201b9c0e8
vivekbhadra/python_samples
/count_prime.py
684
4.125
4
''' COUNT PRIMES: Write a function that returns the number of prime numbers that exist up to and including a given number count_primes(100) --> 25 By convention, 0 and 1 are not prime. ''' """ Spyder Editor This is a temporary script file. """ def isprime(num): flag = True for n in range(2, (num // 2) + 1): ...
true
3c043341d16e6c27c947230779d248f00b72a6c6
glennpantaleon/python2.7
/doughnutJoe.py
2,197
4.4375
4
''' A program designed for the purpose of selling coffee and donuts. The coffee and donut shop only sells one flavor of coffee and donuts at a fixed price. Each cup of coffee cost seventy seven cents and each donut cost sixty four cents. This program will imediately be activated upon a business. \/\/\/\\/\/\/\...
true
7f7d73dd0b2be68187d745c8a3893d52a587a2e3
erickclasen/PMLC
/xor/xor_nn_single_layer.py
1,571
4.21875
4
import numpy as np # sigmoid function def nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x)) print("XOR: With a hidden layer and the non-linear activation function on the output layer.") print("Fails!") ''' 2 inputs 1 output l0 is the input layer values, aka X l1 is the hi...
true
71716899604df84cc40aa5650cad8dc91df5c05c
shouvikbj/IBM-Data-Science-and-Machine-Learning-Course-Practice-Files
/Python Basics for Data Science/loops.py
532
4.34375
4
num = 2 # for loop in a range for i in range(0, num): print(i + 1) for i in range(num): print(i + 1) # for loop in case of tuples names = ("amrita", "pori", "shouvik", "moni") for name in names: print(name) # for loop in case of lists names = ["amrita", "pori", "shouvik", "moni"] for name in names: ...
true
c1649abbfeea25a8b318f96a8dfe086a1d8a1a40
cyphar/ncss
/2014/w2/q4complex.py
1,806
4.1875
4
#!/usr/bin/env python3 # Enter your code for "Mysterious Dates" here. # THIS WAS MY INITAL SOLUTION. # IT DOES NOT PASS THE TEST CASES. # However, the reason I added this is because this code will take any date # format (not just the given ones) and brute-force the first non-ambiguous # representation. It is (in my op...
true
76c2a205292169daea9e1c5c085dea4525992e94
javedbaloch4/python-programs
/01-Basics/015-print-formatting.py
490
4.125
4
#!C:/python/python print("Content-type: text/html\n\n") s = "string" x = 123 # print ("Place my variable here: %s" %s) # Prints the string and also convert this into string # print("Floating point number: %0.3f" %1335) # Prints the following floating number .3 is decimal point # print("Convert into string %r" %x) # ...
true
54a10d41ef8a3bc55c624d1115bff0d731dff64f
androidSec/SecurityInterviews
/docs/custom_linked_list.py
837
4.15625
4
''' Create a linked list that supported add and remove. Numbers are added in ascending order, so if the list was 1,3,5 and 4 was added it would look like 1,3,4,5. ''' class custom_linked_list: def __init__(self): self.custom_list = [] def add(self, number): if len(self.custom_list) == 0: self.custom_list.app...
true
51fce45bb405ab2fc62e3f0cdfd92759b9e4f515
vijayb5hyd/class_notes
/turtle_race.py
2,138
4.28125
4
import turtle # Import every object(*) from module 'turtle' from turtle import * speed(100) penup() # The following code is for writing 0 to 13 numbers on the sheet # By default, the turtle arrow starts at the middle of the page. goto(x,y) will take it to (x,y). goto(-120,120) for step in range...
true
fdc37d4b6119ef863393cc36eec3fe8cbeafa09f
ramchinthamsetty/learning
/Python3/Advanced/decorators2.py
2,605
4.65625
5
""" 1. Demystifying Decorators for Simple Use. 2. Helps in Building Libraries and Frameworks. 3. Encapuslating details and providing simple interface. """ def simple_func1(x): ''' @return - Square of given values ''' return x*x # Passing the reference to a varibaale # dec_func is stored ...
true
bf5a57816608353f402c38cbb0f0294fbad96731
cintax/dap_2019
/areas_of_shapes.py
944
4.21875
4
#!/usr/bin/env python3 import math def circle(): radius = int(input("Give radius of the circle: ")) print(f"The area is {math.pi*(radius**2):6f}") def rectangle(): width = int(input("Give width of the rectangle: ")) height = int(input("Give height of the rectangle: ")) print(f"The area is {heigh...
true
b6d75f871bb2a85f93d87234fd97c73cd7350ecf
hiSh1n/learning_Python3
/Day_02.py
1,249
4.3125
4
#This is day 2 #some variable converters int(),str(), bool(), input(), type(), print(), float(), by default everything is string. #Exercise 03- #age finder birth_year = input("what's your Birth Year:") age = (2021 - int(birth_year)) print("your are " + str( age) + " years old !") print(" ") ...
true
a61941a1d02f0fe26da9dfb3586341bcaa5cb419
joshuaabhi1802/JPython
/class2.py
793
4.125
4
class mensuration: def __init__(self,radius): self.radius=radius self.pi= 22/7 def area_circle(self): area = self.pi*self.radius**2 return area def perimeter_circle(self): perimeter = 2*self.pi*self.radius return perimeter def volume_sphere(self): ...
true
abd5cb0421cd452bdb1405cca6a680f7f7f2ead3
mthompson36/newstuff
/codeacademypractice.py
856
4.1875
4
my_dict = {"bike":1300, "car":23000, "boat":75000} """for number in range(5): print(number, end=',')""" d = {"name":"Eric", "age":26} for key in d: print(d.items()) #list for each key and value in dictionary for key in d: print(key, d[key]) #list each key and value in dictionary just once(not like above exampl...
true
b3b88fe8ea17fd2a5d32e6ca796633d9855c7aa4
Izaya-Shizuo/lpthw_solutions
/ex9.py
911
4.5
4
# Here's some new strange stuff, remember type it exactly # Assigning the days variable with a string containing the name of all the 7 days in their short form days = "Mon Tue Wed Thu Fri Sat Sun" # Assigning the month variable with the name of the months from Jan to Aug in their short forms. After ech month's name the...
true
d1608587d280fd2ed388aaa71241f856421f7648
todaatsushi/python-data-structures-and-algorithms
/algorithms/sort/insertion_sort.py
1,025
4.40625
4
""" Insertion sort. Sort list/array arr of ints and sort it by iterating through and placing each element where it should be. """ def insertion_sort(arr, asc=True): """ Inputs: - Arr - list of ints to be sorted. Assumes arr is longer than 1 element long. - asc - True for ascending, False for desce...
true
453fc0baf0163d84d4b0b26ffa2164826bec58cf
fslichen/Python
/Python/src/main/java/Set.py
207
4.34375
4
# A set is enclosed by a pair of curly braces. # Set automatically removes duplicate elements. set = {'apple', 'pear', 'banana', 'apple'} print(set) if 'apple' in set: print('Apple is in the set.')
true
41bac5b84ed3e03a44faaf6a3cdcb39649e8ba0d
shubhamjain31/demorepo
/Python_practice/Practice_10.py
330
4.125
4
from collections import Counter str = 'In the example below, a string is passed to Counter. It returns dictionary format, with key/value pair where the key is the element and value is the count. It also considers space as an element and gives the count of spaces in the string.' count = Counter(str).most_common(10) pr...
true
ad947590ffed3dcfe73337bea8ffe8e68b6910ef
sky-bot/Interview_Preparation
/Educative/Permutation_in_a_String_hard/sol.py
1,806
4.40625
4
# Given a string and a pattern, find out if the string contains any permutation of the pattern. # Permutation is defined as the re-arranging of the characters of the string. For example, “abc” has the following six permutations: # abc # acb # bac # bca # cab # cba # If a string has ‘n’ distinct characters it will hav...
true
a1ff9c00543721443a49cee0b3c9ecbe1741f740
sky-bot/Interview_Preparation
/Educative/LinkedList/Palindrome_LinkedList.py
1,343
4.125
4
class Node: def __init__(self, value, next=None): self.value = value self.next = next def is_palindromic_linked_list(head): slow = head fast = head tail = None count = 1 middle = None while(fast.next and fast.next.next): slow = slow.next fast = fast.next.n...
true
179576de0a97a3a2957d7cdcedf93d53e203869e
Switters37/helloworld
/lists.py
758
4.25
4
#print range(10) #for x in range (3): # print 'x=',x #names = [['dave',23,True],['jeff',24,False],['mark',21,True]] #for x in names: # print x #print names [1][1] #numbers in square brackets above will index over in the list. So in this case, the list will index over 1 list, and then 1 space in th...
true
1260a7849253566d81c9d5c8d0836f3c20b71bac
NihalSayyad/python_learnigs
/51DaysOfCode/017/Enumerator_in_py.py
221
4.15625
4
''' In we are interested in an index of a list, we use enumerate. ''' countries = ['Finland', 'Sweden', 'Norway', 'Denmark', 'Iceland'] for index, i in enumerate(countries): print(f"country {i} is at index {index}")
true
465380ce5b174a59245d0691e8394672def2d779
devanbenz/PythonStuff
/MIT OCW/LectureSix/lectureSix.py
2,618
4.40625
4
## Recursion - # **Process of repeating items in a self-similar way # '''Droste effect''' - picture within a picture # Divide and conquer # Decrease and conquer # Algorithmically we reduce a problem into smaller parts in #order to solve problems # Semantically it is a function that is called within the body #o...
true
bb17f15513d9e77d524d9396beabff0470adab0e
sejalg1019/project-97
/guessingGame.py
559
4.3125
4
import random print("Number guessing game!") number = random.randint(1,9) chances = 0 print("Guess a number between 1-9 (You only have 5 chances to guess correctly)") while chances < 5: guess = int(input("Enter your guess:")) if guess == number: print("Congratulations, you won!") break ...
true
19bc00052a6249859a29cbd57b55e1ac2821c175
Nsk8012/TKinter
/1.py
426
4.34375
4
from tkinter import * #import Tkinter lib window = Tk() #Creating window window.title("Print") #Giving name of the window l1 = Label(window, text="Hello World!",font=('Arial Bold',50)) #label is used to print line of text on window gui l1.grid(column=0,row=0) #grid set the position of label on window window.geometr...
true
83119fa61c4da7286fba5de1586d2df40a5bcb7f
SW1992/100-Days-Of-Code
/Forty-third-day.py
1,271
4.625
5
# Day Forty Three # Python Range & Enumerate # range() function # the python range function can be thought of as a form of loop # it loops through & produces list of integer values # it takes three parameters, start, end & step # if you specify only an end value, it will loop up to the number (exclusive) #...
true
c3a81e455e13111e4f3d39301727e1b8a20ae464
codingandcommunity/intro-to-python
/beginner/lesson7/caesar.py
494
4.15625
4
''' Your task is to create a funcion that takes a string and turns it into a caesar cipher. If you do not know what a caesar cipher is, here's a link to a good description: https://learncryptography.com/classical-encryption/caesar-cipher ''' def makeCipher(string, offset): # Your code here return string s = i...
true
b530e63e5290ca037d25b0d547fee2f963b91a26
codingandcommunity/intro-to-python
/beginner/lesson7/piglatin.py
655
4.28125
4
''' Write a function translate that translates a list of words to piglatin ex) input = ['hello', 'world'] output = ['ellohay', 'orldway'] remember, you can concactenate strings using + ex) 'hello' + ' ' + 'world' = 'hello world' ''' def translate( ): # Your code here phrase = (input("Enter a phrase -> ")...
true
6f5b4a260426de11c79686367fc4d854d3d2c10a
carlosarli/Learning-python
/old/str_methods.py
458
4.21875
4
name = 'lorenzo' #this is a string object if name.startswith('lo'): print('yes') if name.find('lo') != -1: #.find finds the position of a string in a string, and returns -1 if it's not succesfull in finding the string in the string print('yes') delimiter = '.' namelist = ['l', 'o', 'r', 'e', 'n', 'z', 'o'] pri...
true
e7ce661b78ca1fb34ee44f025de804f0fc4cec29
AkshayGulhane46/hackerRank
/15_string_split_and_join.py
512
4.28125
4
# Task # You are given a string. Split the string on a " " (space) delimiter and join using a - hyphen. # # Input Format # The first line contains a string consisting of space separated words. # # Output Format # Print the formatted string as explained above. def split_and_join(line): a = line.split(" ") # a is ...
true
625abfb54078aa303cfc1e7d9f358a0fc1b6528d
kolodziejp/Learning-Part-1
/Smallest_Value.py
343
4.28125
4
# Finding the smallest value in a range small = None print ("Let us look for the smallest value") for number in [21, 42, 13, 53, -5, 2, 56, 119, -23, 99, 2, 3, 9, 87]: if small is None: small = number elif number < small: small = number print (small, number) print ("The smalle...
true
c5f22e3b607f0af078e1506feb80d6d81041862c
kolodziejp/Learning-Part-1
/Ex_5_1.py
480
4.1875
4
# entered numbers are added, counted and average computed count = 0 total = 0 while True: num = input ("Enter a number: ") if num == "done": break try: fnum = float(num) #convert to floating number except: print ("Invalid Data!") continue # should...
true
e925e128a91016a06b95f1c88d3c9a7f8c1628f8
ApurvaW18/python
/Day 3/Q2.py
377
4.25
4
''' 2.From a list containing ints, strings and floats,make three lists to store them separately. ''' l=['aa','bb','cc',1,2,3,1.45,14.51,2.3] ints=[] strings=[] floats=[] for i in l: if (type(i))==int: ints.append(i) elif (type(i))==float: floats.append(i) else: string...
true
0ccd24589fd5833bd9dd205fe3bf34a315f533eb
ApurvaW18/python
/Day 6/Q2.py
678
4.125
4
''' 2.Write program to implement Selection sort. ''' a = [16, 19, 11, 15, 10, 12, 14] i = 0 while i<len(a): s=min(a[i:]) print(s) j=a.index(s) a[i],a[j] = a[j],a[i] i=i+1 print(a) def selectionSort(array, size): for step in range(size): min_idx = step for i...
true
9fef6a6753a7fc3f577a737d811d5179fe0d1435
oski89/udemy
/complete-python-3-bootcamp/my-files/advanced_lists.py
398
4.25
4
l = [1, 2, 3, 3, 4] l.append([5, 6]) # appends the list as an item print(l) l = [1, 4, 3, 3, 2] l.extend([5, 6]) # extends the list print(l) print(l.index(3)) # returns the index of the first occurance of the item l.insert(2, 'inserted') # insertes at index print(l) l.remove(3) # removes the first occurance pr...
true
800319d01235504239ac6011970662a0b9dc7a76
Tduncan14/PythonCode
/pythonGuessGame.py
834
4.21875
4
#Guess my number ## #The computer picks a random number between 1 and 100 #The player tries to guess it and the computer lets #The player on guessing the numner is too high, too low # or right on the money import random print("\tWelcome to 'Guess My Number'!") print("\n I'm thinking of a number between 1 and 100.") ...
true
4741931113c64c098b5d06449bceafc4949bab1f
seen2/Python
/workshop2019/secondSession/function.py
415
4.1875
4
# without parameter def func(): a, b = 10, 20 c = a+b print(c) # func() def funcP(a, b): ''' takes two integer and print its sum ''' c = a+b print(c) # default argument comes last in parameter sequence. def funcDefaultP(a, b=1, c=1): ''' takes three integer and print its su...
true
e90d7ae10791ac7dd407d940ed3e444770d087c1
seen2/Python
/bitwiseOperators/bitwiseLogicalOperators.py
406
4.125
4
def main(): a=2 # 2=ob00000010 b=3 # 3=ob00000011 # logical operations print(f"{a} AND {b}={a&b}") print(f"{a} OR {b}={a|b}") # takes binary of a and flips its bits and add 1 to it. # whilch is 2 's complement of a print(f"2's complement of {a} ={~a}") # exclusive OR (...
true
78c62c8944c81c10e80cc64673aab404ff0f4bd5
GeorgeMohammad/Time2ToLoseWeightCalculator
/WeightLossCalculator.py
1,081
4.3125
4
####outputs the amount of time required to lose the inputted amount of weight. #computes and returns the amount of weight you should lose in a week. def WeeklylbLoss(currentWeight): return (currentWeight / 100) #Performs error checking on a float. def NumTypeTest(testFloat): errorFlag = True while(err...
true
b7df58e4d45c16fc5fe35e2ba028378c9cf227d8
rcreagh/network_software_modelling
/vertex.py
606
4.125
4
#! usr/bin/python """This script creates an object of class vertex.""" class Vertex(object): def __init__(self, name, parent, depth): """Initialize vertex. Args: name: Arbitrary name of the node parent: Parent vertex of the vertex in a tree. depth: Number of edges between the vertex itself ...
true
8c2e4e8110aa53f0b5ecffce8b2b80ba2bbeb1aa
gittangxh/python_learning
/io_input.py
364
4.3125
4
def reverse(text): return text[::-1] def is_palindrome(text): newtext='' for ch in text: if ch.isalpha() and ch.isnumeric(): newtext+=ch.lower() return newtext == reverse(newtext) something = input('Enter text:') if is_palindrome(something): print('yes, it is palindrome') el...
true
b54ece015da6564cd0c5c839f67149774f0e0888
niteshsrivats/IEEE
/Python SIG/Classes/Class 6/regularexp.py
2,377
4.375
4
# Regular expressions: Sequence of characters that used for # searching and parsing strings # The regular expression library 're' should be imported before you use it import re # Metacharacters: characters with special meaning # '.' : Any character "b..d" # '*' : Zero or m...
true
77f86f9689a16c3a8d9438a24b5d13b67bd6c6f0
alanvenneman/Practice
/Final/pricelist.py
614
4.125
4
items = ["pen", "notebook", "charge", "scissors", "eraser", "backpack", "cap", "wallet"] price = [1.99, .5, 4.99, 2.99, .45, 9.99, 7.99, 12.99] pricelist = zip(items, price) for k, v in pricelist: print(k, v) cart = [] purchase = input("Enter the first item you would like to buy: ") cart.append(purchase) second =...
true
4e7693939c6098c938fce30f8915f19b80dc2ecd
SteveWalsh1989/Coding_Problems
/Trees/bst_branch_sums.py
2,265
4.15625
4
""" Given a Trees, create function that returns a list of it’s branch sums ordered from leftmost branch sums to the rightmost branch sums __________________________________________________________________ 0 1 / \ 1 2 3 / \ / \ 2 4 5 6 7 / \ ...
true
a21b1e8a04826d5391cfa5eac83e0d4b12d22859
SteveWalsh1989/Coding_Problems
/Arrays/sock_merchant.py
634
4.3125
4
def check_socks(arr, length): """ checks for number of pairs of values within an array""" pairs = 0 # sort list arr.sort() i = 0 # iterate while i < (length - 1): # set values current = arr[i] next = arr[i + 1] # check if the same sock or different ...
true
70ed3e204149399b43259d4fa675d705cc4d9121
yueranwu/CP1404_prac06
/programming_language.py
946
4.125
4
"""CP1404/CP5632 Practical define ProgrammingLanguage class""" class ProgrammingLanguage: """represent a programming language""" def __init__(self, name, typing, reflection, year): """Initiate a programming language instance name: string, the name of programming language typi...
true