blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
570355c3e6194b38f10fc7c0d72d1a829b08c60e
Pranjul-Sahu/Assignment
/Assignment 1 Question2.py
263
4.5
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #Write a Python program that accepts a word from the user and reverse it. rev_word = input() print("Enter the Word -", rev_word) reversed_word = rev_word[-1::-1] print("After reversing the word -",reversed_word)
true
91427a056a6b775cc3a27efba4e79939b8d495eb
JacobFrank714/CSProjects
/cs 101/labs/lab07.py
2,114
4.5
4
# ALGORITHM : # 1. display the main menu and ask user what task they want performed # 2. check what their answer is # 3. depending on what the answer is, ask the user what the want encoded/decoded or quit the program # 4. ask how many numbers they want to shift the message by # 5. p...
true
a2b93cfc53ae35c80dba5f35d37c9832d49604bd
JacobFrank714/CSProjects
/cs 101/programs/program 1.py
1,393
4.3125
4
#Jacob Frank, session 0002, Program #1 #getting the values of all the ingredients for each recipe set recipe_cookies = {'butter':2.5, 'sugar':2, 'eggs':2, 'flour':8} recipe_cake = {'butter':0.5, 'sugar':1, 'eggs':2, 'flour':1.5} recipe_donuts = {'butter':0.25, 'sugar':0.5, 'eggs':3, 'flour':5} print('Welcome t...
true
1fb7869848da06f165db950213f1d56ac07524d7
joshuajweldon/python3-class
/exercises/ch08/calc.py
1,020
4.15625
4
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x*y def divide(x, y): try: r = x / y except ZeroDivisionError: r = "Undef." return r operators = { '+': add, '-': subtract, '*': multiply, '/': divide } input("Calcula...
true
49df67062148f557043a9005b57a7ca95b8c8ae5
General-Blue/Intro-to-Python
/py_basics_1.py
466
4.1875
4
# print hello to the world print("hello world") # ask the user of your program their name and save it into a variable x = input("What is your username? ") # say hello to the user print("hello "+ x) # import the random library import random # use the random library to save a random number into a variable x = random.rand...
true
5fa811d85c8c128549e67f391425a37f164363a3
aakashp4/Complete-Python-3-Bootcamp
/ch01_overview/task1_2_starter.py
1,348
4.6875
5
""" task1_2_starter.py For this task, you are to manually extract the domain name out of the URLs mentioned on our slide. The URLs are: https://docs.python.org/3/ https://www.google.com?gws_rd=ssl#q=python http://localhost:8005/contact/501 Additional Hints: 1. Prompt for a URL input ...
true
b2f2f3f0e57dd0a23e8a55cbe46a847d895c0ce5
vinozy/data-structures-and-algorithms
/interviews/reverse-LL/linked_list.py
1,396
4.15625
4
from node import Node class LinkedList: """ create a linked list """ def __init__(self, iterable=[]): """Constructor for the LinkedList object""" self.head = None self._size = 0 if type(iterable) is not list: raise TypeError('Invalid iterable') for ...
true
7fc2af4757d2fbce2d4281ce60fd73113963db01
vinozy/data-structures-and-algorithms
/interviews/reverse-LL/reverse_ll.py
666
4.125
4
from linked_list import LinkedList as LL from node import Node # def reverse_ll(list1): # """Reverse a singly linked list.""" # current = list1.head # list2 = LL() # while current is not None: # # list2.insert(current) # list2.head = Node(current.val, list2.head) # current = cu...
true
1f355ae733498d81e81f2192451550b24b0427f8
vinozy/data-structures-and-algorithms
/data_structures/binary_search_tree/bst_binary_search.py
596
4.375
4
def bst_binary_search(tree, value): """Use binary search to find a value in a binary search tree. Return True if value in tree; return False if value not in tree.""" if not tree.root: return False current = tree.root while current: if current.val == value: return True ...
true
ffba3a558382e3802c9c3437b90df9d983f26bc3
Amazon-Lab206-Python/space_cowboy
/Fundamentals/fun.py
729
4.5
4
# Odd/Even: # Create a function called odd_even that counts from 1 to 2000. As your loop executes have your program print the number of that iteration and specify whether it's an odd or even number. def odd_even(x): for x in range(1,2001): if (x % 2 == 0): print "This is an even number." ...
true
561f8099654f1753fcf261095177d7b599aae3ea
bmoretz/Daily-Coding-Problem
/py/dcp/problems/dynamic/staircase.py
1,115
4.4375
4
'''Number of ways to climb a staircase. There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. For example, if N is 4, then there are 5 unique ways: 1, 1,...
true
fd30b62e24e537c9d9aecda7c5684e2a48bae4a6
bmoretz/Daily-Coding-Problem
/py/dcp/leetcode/linkedlist/deep_copy_random.py
2,173
4.125
4
''' 138. Copy List with Random Pointer. A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. The Linked List is represented in the input/output as a list of n nodes. Each node is represented as a pair of [...
true
d86beb66b939aef66b3dda13f1c67910396c4284
bmoretz/Daily-Coding-Problem
/py/dcp/leetcode/matrix/diagonal_traverse.py
1,070
4.125
4
''' 498. Diagonal Traverse. Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,4,7,5,3,6,8,9] Explanation: Note: The total number of elements of the gi...
true
7f9c125e8e64b1db69cd0725ff1ab8a5d70e385a
bmoretz/Daily-Coding-Problem
/py/dcp/problems/recursion/triple_step.py
1,034
4.28125
4
""" Triple Step. A child is running up a staircase with n steps and can hop either 1 step, 2 steps or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs. """ def triple_step1(n): def triple_step(n): if n < 0: return 0 if n == 0: ...
true
b3c7f5e853458690c0528815b3dcf4b763569829
bmoretz/Daily-Coding-Problem
/py/dcp/problems/math/rand_5n7.py
1,391
4.3125
4
""" Rand7 from Rand5. Implement a method rand7() given rand5(). That is, given a method that generates a random number between 0 and 4 (inclusive), write a method that generates a random number between 0 and 6 (inclusive). """ from random import randrange def rand5(): return randrange(0, 5) """ rand7 1 simple ...
true
3e2b3173d94ca20e83dadb4dea98d4b181823e5e
bmoretz/Daily-Coding-Problem
/py/dcp/problems/stack_queue/queue_of_stacks.py
747
4.21875
4
""" Queue of Stacks. Implement a MyQueue class which implements a queue using two stacks. """ from .stack import Stack class my_queue1(): def __init__(self): self.data = Stack() self.top = None def enqueue(self, item): if item is None: return self.data.push(item) if self.top ...
true
38a0300e0534dafcde09dbb4aadc78d83aa3f576
astikagupta/HW04
/HW04_ex08_12.py
442
4.25
4
# Structure this script entirely on your own. # See Chapter 8: Strings Exercise 12 for guidance # Please do provide function calls that test/demonstrate your function def rotate_word(x,y): for i in x: z = ord(i) w = z+y print chr(w), def main(): x = raw_input("enter the string:") y = int(raw_input("en...
true
f7c7428ea359a51853286191f0a33900cfcb1a98
marshall159/travelling-Salesman
/cities.py
2,514
4.1875
4
def read_cities(file_name): # no unit tests """ Read in the cities from the given `file_name`, and return them as a list of four-tuples: [(state, city, latitude, longitude), ...] Use this as your initial `road_map`, that is, the cycle Alabama -> Alaska -> Arizona -> ... -> Wyoming...
true
408fe1cb12b633f09f4a21b8801c678c5f3b021c
verilogtester/pyalgo_love
/TREE_traversal_Iterative_approach.py
2,371
4.34375
4
# Python program to for tree traversals (This is Iterative Approach) # A class that represents an individual node in a # Binary Tree class Node: def __init__(self,key): self.left = None self.right = None self.val = key # A function to do inorder tree traversal # def iter_printInorde...
true
0bd775286b5335f1ff414be9f32c36cb95a08a89
gopinathrajamanickam/PythonDS
/isAnagram.py
940
4.125
4
# Validate Anagram # given two strings as input Check if they can be considered anagrams # i.e the letters in those stringss to be rearranged to form the other def isAnagram(str1,str2): # if the letter freq count is same for given strings it can be called anagrams result = 'Not Anagrams' freq_dict = {} ...
true
a45e3ad473e925a83e631efb7890d5b952de5120
njgupta23/LeetCode-Challenges
/array/rotate-arr.py
601
4.125
4
# Rotate Array # Given an array, rotate the array to the right by k steps, where k is non-negative. # Example 1: # Input: [1,2,3,4,5,6,7] and k = 3 # Output: [5,6,7,1,2,3,4] # Explanation: # rotate 1 steps to the right: [7,1,2,3,4,5,6] # rotate 2 steps to the right: [6,7,1,2,3,4,5] # rotate 3 steps to the right: [5,...
true
2d3f1e2d5077308ba207b3a2334863a3a97240e7
hostjbm/py_gl
/T2. OOP/Class decorator/func_decoratoration_by_class.py
508
4.21875
4
# Basic example of decorator defined by class class decorator(): def __init__(self, func): print(10) self.func = func def __call__(self, *args): print('Called {func} with args: {args}'.format( func=self.func.__name__, args=args)) print(self, args) return sel...
true
efadbaf73428bcfd21f780a19e642b166187c8d7
Maulik5041/PythonDS-Algo
/Recursion/power_of_a_number.py
219
4.375
4
"""Power of a number using Recursion""" def power(base, exponent): if exponent == 0: return 1 else: return base * power(base, exponent - 1) if __name__ == '__main__': print(power(2, 3))
true
7d9d43833516f1d63cac72274c64df2f2eed1a53
poojamadan96/code
/function/factUsingRecursive.py
219
4.375
4
#factorial using recursive function = Fucntion which calls itself num=int(input("Enter no. to get factorial ")) def fact(num): if num==1: return 1 else: return num*fact(num-1) factorial=fact(num) print(factorial)
true
89e7001639f286cbf0b2548e6d9f305014c34da7
Sammybams/30-days-of-code-Intermediate-May
/Day 7.py
1,409
4.34375
4
def my_cars(array): """ You come to the garage and you see different cars parked there in a straight line. All the cars are of different worth. You are allowed to choose any amount of cars and they will be yours. The only condition is that you can't select 2 cars that are parked beside each other. ...
true
f981a1ee2c36b151e2834ec47d8d97069c536991
rithwikgokhale/SimpleCalculator
/PA1_Question1.py.py
1,042
4.1875
4
#Python Script to solve quadratic equations and give the solutions print ("Quadratic Equations: ax^2+bx+c = 0") a = int(input("Enter the coefficients of a: ")) b = int(input("Enter the coefficients of b: ")) c = int(input("Enter the coefficients of c: ")) d = b**2-4*a*c # this is the discriminant for the enter...
true
28c4462f2efdd143096fb430d96ac12ba94af4f0
JoshKallagunta/ITEC-2905-Lab-1
/Lab1.py
276
4.28125
4
name = input("What is your name? ") birthMonth = input("What month were you born?") print("Hello " + name + "!") count = len(str(name)) print("There are " + str(count) + " characters in your name!") if birthMonth == "August": print("Happy birthday month!") else: ""
true
74f94a7bdd8d2ab3d45348c299f6cd1f0aa97e50
carpepraedam/data_structures
/sorting/Bubble_Sort/python/bubble.py
1,256
4.15625
4
def comparator(val_a, val_b): """ Default comparator, checks if val_a > val_b @param {number} val_a @param {number} val_b @return {bool} : True if val_a > val_b else False """ return val_a > val_b def bubble(l, comparator=comparator): """ Bubble sort a given list @param {list} ...
true
db56a2db15dd354a3e2b832f7be1887d2b139433
Donal-Murphy/EP305-Computational-Physics-I
/Labwork/cone_area(5_3_19)/cone_area.py
1,493
4.40625
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 5 14:04:56 2019 @author: Donal Murphy Description: returns the surface area of a cone given its height and radius """ #this program calculates the surface area of a cone given the radius and height import numpy as np #needed for pi #------------------...
true
06e04411c77035b2330f2a17f7ad5e17a3f04a33
mfjimenezmoreno/eLOAD_Bipotentiostat
/Python app/SortingTuples.py
268
4.21875
4
c = {'a':10,'b':1,'c':22} #A supercompressed way to sort a dictionary by highest values #items returns keys and values as tuples, then the for iteration flips the tuples value/key, and finally sorted function takes place print(sorted([ (v,k) for k,v in c.items() ]))
true
6c933cbcfe6e2d9906565bf68e69e89c1cb4c5dd
k8thedinosaur/labs
/weather.py
2,410
4.25
4
# # Lab: PyWeather # # Create a program that will prompt a user for city name or zip code. # Use that information to get the current weather. Display that information # to the user in a clean way. # ## Advanced # # * Also ask the user if they would like to see the results in C or F. import requests package = { "A...
true
982dec507c2d8ca14d0ed5f664c84cd716642019
k8thedinosaur/labs
/dice.py
1,414
4.53125
5
# # Lab: Dice # ##### Goal # Write a simple program that, when run, prompts the user for input then prints a result. # ##### Instructions # Program should ask the user for the number of dice they want to roll as well as the number of sides per die. # #### Documentation # 1. [Compound statements](https://docs.python.org...
true
3a028d9759a1129eac81d21d78ed4e753487763e
yenext1/python-bootcamp-september-2020
/lab5/exercise_5.py
1,059
4.21875
4
print("Lets make a Arithmetic Progression!") a1 = int(input("Choose the first number (a1)")) d = int(input("Great! choose the number you and to add (d)")) n = int(input("How many numbers should we sum? (n)")) sum = (n/2)*(2*a1+(n-1)*d) print(f" The sum of the numbers in the serie is {sum}") """ Uri's comments: =====...
true
ebc1c450857f3035e6129f58627a982dfffa224f
JaromPD/Robot-Finds-Kitten-Project
/rfk/game/shared/point.py
1,943
4.4375
4
class Point: """A distance from a relative origin (0, 0). The responsibility of Point is to hold and provide information about itself. Point has a few convenience methods for adding, scaling, and comparing them. Attributes: _x (integer): The horizontal distance from the origin. _y (in...
true
af932265190463ccbfc52464566f72485309411f
patvdc/python
/01-basics/06-functions/10_lambda.py
442
4.46875
4
print("lambda +") x = lambda a : a + 10 print(x(5)) print("lambda *") x = lambda a, b : a * b print(x(5, 6)) print("lambda +") x = lambda a, b, c : a + b + c print(x(5, 6, 2)) # usage in another function (nested function) print("nested lambda using lambda double") def multiply(n): return lambda a: a * n double=...
true
d56e4c53f4e447580df9fef8b4316aeee3b89148
liugongfeng/CS61A
/mentor03.py
834
4.25
4
### Question 3 """Given some list lst, possibly a deep list, mutate lst to have the accumulated sum of all elements so far in the list. If there is a nested list, mutate it to similarly reflect the accumulated sum of all elements so far in the nested list. Return the total sum of lst. Hint: The isinstance function ...
true
54d5983b9ea33ecd84e16af3e5f41bcd569bd798
devmohit-live/Prep
/Maths/prime_numbers_inRange.py
951
4.1875
4
import math def primeNumer(n) -> list: ''' Sieve Of Erathosthenes Algorithm to find numers within the range are prime or not, here we just jump to the next multiples of the current number in an array and make it False, we explicitly make the 0 and 1 False, this alogorithm help us to solve this O(N) task in ...
true
2bc921e8e92091742cadfd34d86a0d9ad01a57f2
sonalgupta06cs/Python_Projects
/PythonBasicsProject/listExercises.py
816
4.28125
4
# find the largest number in a list numbers = [3, 6, 11, 2, 8, 4, 10] maxNum = numbers[0] for number in numbers: if number > maxNum: maxNum = number else: continue print("max number is ", maxNum) # Remove the duplicates from the list - 1 numbersList1 = [2, 2, 4, 6, 3, 4, 6, 1] uniques = [] cou...
true
631a1183574d0d8a6cef80da7a8edf209052b24c
sonalgupta06cs/Python_Projects
/PythonProjectBasics2/loopsExcercises.py
741
4.125
4
print("-----------ForLoopExercise----------------") # add the price and sum the total amount prices = [10, 20, 30] total = 0 for price in prices: total += price print(f'total is {total}') print("----------ForLoopExerciseToPrint'F'-----------------") numbers = [5, 2, 5, 2, 2] for number in numbers: print(number...
true
033054b27f059ea4a505bf79329116aa692b78f3
millenagena/Python-Scripts
/aula06 - desafio 004 analise, numeros, letras etc.py
499
4.15625
4
a = input('Type something: ') print('The primitive type of this value is: {}'.format(type(a))) print('Does it have only numbers? {}'.format(a.isnumeric())) print('Does it have only letters? {}'.format(a.isalpha())) print('Does it have only numbers and letters? {}'.format(a.isalnum())) print('Does it have only spaces?...
true
8a6b2a226d1188f7b9ab30d192d843bdbdad0e78
leandromjunior/Codewars
/duplicate encoder/duplicateEncoder.py
611
4.1875
4
# The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character # appears only once in the original string, or ")" if that character appears more than once in the original string. # Ignore capitalization when determining if a character is a duplicate....
true
37008caf6079ac122daf822f483f3cdc26420a38
mfcust/operators_comments
/operators_comments.py
1,360
4.6875
5
###Operators and comments### ###You can write comments like this!!### '''Or if your comments span multiple lines, like this and this and this, you can use three single quotes to comment out large blocks of code.''' #1) Write a comment below by using the '#' symbol. #2) Write a multi-line comment below by usin...
true
85fb92186a54ee75f8d14ca7ede685782bc3fdc6
gkl1107/Python-algorithm
/alice_words.py
1,189
4.25
4
''' Write a program that creates a text file named alice_words.txt containing an alphabetical listing of all the words, and the number of times each occurs. ''' word_dict = {} with open("alice_in_wonderland.txt") as file: line = file.readline() while line: no_punct = "".join([char for char in line if char.isalpha...
true
23751a9b31c21edd67b5b54342f3a8dfb299c517
gkl1107/Python-algorithm
/alphabet_cipher.py
867
4.625
5
#!/usr/bin/python ''' A function that implements a substitution cipher. the function takea two parameters, the message you want to encrypt, and a string that represents the mapping of the 26 letters in the alphabet. ''' import string def cipher(message, str_mapping): upperCase_mapping = str_mapping.upper() ...
true
8e6a6b7a3f5f3fd341079d6e0435ffb0e4f2e477
weikuochen/LeetCode
/LeetCode_000009.py
937
4.21875
4
""" Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of using extra space. You could also try reversing an integer. However, if you...
true
4a841929d8277ce9ebdc78055bf26752aea6e4b2
yarosmar/beetroot-test-repo
/calculator.py
667
4.1875
4
def calculate(): operation = input() number_1 = int(input()) number_2 = int(input()) if operation == '+': print('{} + {} = '.format(number_1, number_2)) print(number_1 + number_2) elif operation == '-': print('{} - {} = '.format(number_1, number_2)) print(numb...
true
f988f37a28f4994bcb69f3db84cb3f5777c249c4
BabaYegha/pythonExercises
/week-02/unique.py
315
4.15625
4
def unique(uniqList): unique_list = [] for x in uniqList: if x not in unique_list: unique_list.append(x) for x in unique_list: print(x) numbers = [1, 11, 34, 11, 52, 61, 1, 34] print("Original list: [1, 11, 34, 11, 52, 61, 1, 34]") print("Unique list: ") unique(numbers)
true
f88b4c5f5238bb699783ef2b678e4d7f0ff5dedd
jilesingh/LearnPythonTheHardWay
/chapter1/ex20.py
1,096
4.3125
4
# -*- coding utf-8 -*- # This code is written and run using Python Version 3.6.8 from sys import argv script, input_file = argv def print_all(f): print (f.read()) def rewind(f): f.seek(0) def print_a_line(line_count, f): print (line_count, f.readline()) current_file = open(input_file) print ("First l...
true
f48ca78c0c9e5b0d8b91d87f757ea0cf57e462f4
jilesingh/LearnPythonTheHardWay
/chapter1/ex16.py
1,194
4.3125
4
# -*- coding utf-8 -*- # This code is written and run using Python Version 3.6.8 from sys import argv script, filename = argv print ("We are going to erase %r." % filename) print ("If you don't want that, hit CTRL+C") print ("If you do want that, hit Return") input("?") print ("Openeing the file.....") target = open...
true
111c6397fbda31698130e27bdfe8a30565a50d95
shivamkalra111/Tkinter-GUI
/buttons.py
379
4.15625
4
from tkinter import * root = Tk() def click(): mylabel = Label(root, text = "Clicked the button!!") mylabel.pack() #click the button again and again the text comes up multiple times #can also use x color codes mybutton = Button(root, text = "Click me", padx = 50, pady = 50, command = click, fg = 'y...
true
2c9fd4e0e74f12b7c7da6595cae99190eaa597e2
Marklar9197/Python-Project
/game.py
1,166
4.1875
4
#This program takes a random number between 1 and 10 and asks the user to guess it. import random random_num = random.randint(1,10) print(random_num) # Being used for testing purposes guess = int(input("What is my number? > ")) small_num = int(input('Lower > ')) large_num = int(input('Higher > ')) replay = input...
true
1eda22930e4ea80cce1894da1b9ffdf3f3a71fab
ranjithmanda/solaris
/B1/solaris_samples/count_words.py
585
4.1875
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 5 09:16:38 2020 @author: gupta count number of times each word occurred in given string. find count of each digits in given number. find specific digit found in given number. """ # this program is incomplete. need to explain further. given_str = "this is a good day , ...
true
ca59919a9b447c2d7b0db5cf2bde7257a684d3b9
mattdix27/miniprojects
/dijkstra.py
2,055
4.125
4
import sys ''' Graph with multiple nodes as well as edges with lengths Find the shortest distance to any node ''' graph = { 'a':[{'b':4},{'c':8},{'d':7}], 'b':[{'a':4},{'e':12}], 'c':[{'a':8},{'d':2},{'e':3}], 'd':[{'a':7},{'c':2},{'f':10}], 'e':[{'b':12},{'c':3},{'g':18}], 'f':[{'d':10},{'g':20}], 'g':...
true
0daa638eb46824a06007d0d220b3763f0450c926
Disha-Shivale/Exceptionhandling
/regex1.py
483
4.53125
5
import re s = "Hello from Python, This is Reg Expression" i = re.search("^Hello", s) # ^Starts with if (i): print("String Match!") else: print("No match") #Example 2 i = "Hello from Python" print() #Find all lower case characters alphabetically between "a" and "m": x = re.findall("[a-z]", i) print(x) print() ...
true
d6e502c150a837f17610cfdc88ef536c99363e1c
mohammadasim/python-course
/Errors _and_exceptions/homework.py
1,354
4.15625
4
# Problem 1 # Handle the exception thrown by the code below by using try and except blocks def square_root(): for i in ['a','b','c']: try: print(i**2) except TypeError as wrong_list_items: print('Wrong list items provided. Please provide either int or floating point') ...
true
ede487fdcd22575b67b235343dd5c69bc8a094e8
mohammadasim/python-course
/while_loops.py
396
4.15625
4
x = 0 while x < 5: print('The value of x is {}'.format(x)) x += 1 else: print( 'X is not less than 5') # break, continue, pass # We can use break, continue and pass statements in our loops to add additional functionality for various cases # break: Breaks out of the current closest enclosing loop. # continu...
true
1c0844e3c04f201687718b037286e60a567a7cc0
mohammadasim/python-course
/python_generators/generator.py
2,410
4.71875
5
''' We have learned how to cerate functions with def and the return statement. Generator functions allow us to write a function that can send back a value and then later resume to pick up where it left off. This type of function is a generator in Python, allowing us to generate a sequence of values over time. The main...
true
31981e597b9583b5423ca38a8e78c3ac5012e239
mohammadasim/python-course
/variables.py
622
4.3125
4
# Python is dynamically typed, it means that we can assign any type of value to a variable. # Unlike Java which is statically typed. Which means we have to declare the type of the variable and can only # assign that type of value to it. a = 5 print a a = a + a print a a = 'b' # We can use the type function to determi...
true
e3caadd4da05454be2fc7540c9374bb8689ab210
mohammadasim/python-course
/ood_class_object_attributes.py
1,413
4.1875
4
class Dog(): # Class Objject Attributes # These are the same for all instances of a Class # These are identical to Static attributes in Java species = 'mammal' # Constructor of the class with three arguments # We can provide default values for these attributes and they will be overwritten if the values is ...
true
fe51c43cf891d8ab1ade5c71756e538d392ba738
beckytrantham/PythonI
/lab3.py
297
4.125
4
#Reads the temperature in F from the keyboard, then prints the equivalent in C. #Formula C = 5 / 9 * (F - 32) temp = raw_input('What is the temperature in degrees Fahrenheit? ') ftemp = float(temp) ctemp = 5.0 / 9.0 * (ftemp - 32) print 'The temperature is {} degrees Centigrade.' .format(ctemp)
true
3447720ec6cde0cfe9f375462a2c4d69f0488775
theLoFix/30DOP
/Day24/Day24_Excercise02.py
457
4.25
4
# Below you'll find a divide function. Write exception handling so that we catch ZeroDivisionError exceptions, TypeError exceptions, and other kinds of ArithmeticError. def divide(a, b) try: print(a / b) except ZeroDivisionError: print("Cannot divide by zero") except TypeError: print("Both values must be numb...
true
9bbe017ba0c1efb455de424cb1a234a408bb5bfa
theLoFix/30DOP
/Day10/Day10_Excercise01.py
778
4.3125
4
# Inside the tuple we have the album name, the artist (in this case, the band), the year of release, and then another tuple containing the track list. # Convert this outer tuple to a dictionary with four keys. tuple1 = ( "The Dark Side of the Moon", "Pink Floyd", 1973, ( "Speak to Me", "Breathe", "On ...
true
525bc17db7c6eae600218137c3c8586e5d5dc78f
theLoFix/30DOP
/Day07/Day07_Excercise1.py
464
4.25
4
# Ask the user to enter their given name and surname in response to a single prompt. Use split to extract the names, and then assign each name to a different variable. For this exercise, you can assume that the user has a single given name and a single surname. answer = (input("Please provide your first and last name....
true
7d760eb55f99e40f16d5264b5be50fb5cb2b2e6b
league-python/Level0-Module1
/_03_if_else/_3_tasty_tomato/tasty_tomato.py
665
4.375
4
from tkinter import * import tkinter as tk window_width = 600 window_height = 600 root = tk.Tk() canvas = tk.Canvas(root, width=window_width, height=window_height, bg="#DDDDDD") canvas.grid() # 1. Ask the user what color tomato they would like and save their response # You can give them up to three choices # 2...
true
d28e288c8f8bda49d0291861c5bfaea407761818
wenyan666/wenyan-python
/ex18.py
930
4.40625
4
# -*- coding:UTF-8 -*- # this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print "arg1:%r, arg2: %r." % (arg1, arg2) # OK, that *args is actually pointless, we can just do this def print_two_again(arg1, arg2): print "arg1:%r, arg2:%r" % (arg1, arg2) # or just type one argu...
true
d746b68a08610c3e5ddc4b953ca0335c248a3b59
PRai0409/code1
/first.py
2,271
4.28125
4
#PROGRAM 1 print("PROGRAM 1") fname =input("Enter any filename :") print("Output :") op=fname.split(".") #print(type(op)) print("filename : ",op[0]) print("extension : ",op[1]) #PROGRAM 2 print("\nPROGRAM 2") fnum = int(input("Enter first number :")) #print(type(fnum)) snum = int(input("Enter second number :")) total...
true
29eaffb27ed811d9e2ebc82927281793be6f2b7e
shubham-ricky/Python-Programming---Beginners
/Vowels.py
1,404
4.125
4
""" a) Write a function getVowels that takes in an utterance as argument and returns the vowels (A, E, I, O, U) in uppercase. Sort your list according to the sequence of the alphabets in your vowels. b) Write the function countChars that takes in an utterance and a character as arguments, and call the function to r...
true
d514c8d421a394644d686512f387f5ca2e54ddd8
Robert-Siberry/IntroToGit
/numberguess2.py
492
4.21875
4
print("The Guessing Game") import random number=random.randint(1,9) guess=0 counter=0 while guess!=number and guess!="exit": guess=input("Please guess a number between 1 and 9: ") if guess == "exit": break guess = int(guess) counter=counter+1 if guess < number: print("Thats too low!"...
true
98f6a84e85c8e12b4c2fdba7a0560dcc53ce0fae
zhane98/studying
/lesson21.py
310
4.40625
4
# string formatting/interpolation = %s inside of a string to mark where we want other strings inserted. # E.g: name = 'Calvin' place = 'KFC' time = '8 pm' # how to add pm food = 'chicken' print("Hello %s, you are invited to a party at %s at %s. Please bring %s." %(name, place, time, food))
true
f6e1ed77f1e44b905af6895e212f34c3ec828a14
zhane98/studying
/codewars2.py
998
4.3125
4
# RETURNING STRINGS # Make a function that will return a greeting statement that uses an input; # your program should return, "Hello, <name> how are you doing today?". def greet(name): #Good Luck (like you need it) return "Hello, " + name + " how are you doing today?" print(greet('Zhané')) #calling the func...
true
9b1e159cf387cbf25cf0950cdd8194a21d45bea3
nayan-pradhan/python
/stack.py
2,154
4.1875
4
# Nayan Man Singh Pradhan # Stack Class class Stack: # initialize stack def __init__(self, stack_size): self.array = [None] * stack_size self.stack_size = stack_size self.top = 0 # bool to check if stack is empty or not def isEmpty (self): print("Stack is empty? -> ", ...
true
5ee0fc5ac97c785c83ae956918ac9b85b66f1f0e
BryantLuu/daily-coding-problems
/15 - pick a random number from a stream given limited memory space.py
1,088
4.15625
4
""" Good morning. Here's your coding interview problem for today. This problem was asked by Facebook. Given a stream of elements too large to store in memory, pick a random element from the stream with uniform probability. Upgrade to premium and get in-depth solutions to every problem. If you liked this problem, fe...
true
846a9d273b15a562439a612c84ea911381a3d446
BryantLuu/daily-coding-problems
/12 - N steps generic fib.py
1,088
4.21875
4
""" Good morning. Here's your coding interview problem for today. This problem was asked by Amazon. There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. ...
true
fe1e91d58da2d16bb07a1cacc30639f60d250bc6
vishnuster/python
/guess the number.py
320
4.125
4
#This program will ask you to guess a number import random a=random.randint(1,20) while True: b=int(input("Guess the number")) if (b < a): print("You have entered less") elif(b > a): print("You have entered greater") else: print("You have guessed it right. It's",b) continue
true
cbe00582a3809efa45860c4cec2cc93f16cc25a7
vishnuster/python
/Validating_Postal_Codes.py
698
4.1875
4
"""A postal code must be a number in the range of (100000,999999). A postal code must not contain more than one alternating repetitive digit pair. Alternating repetitive digits are digits which repeat immediately after the next digit. In other words, an alternating repetitive digit pair is formed by two equal digit...
true
28064a9d6b548dcbafbfa320f92f8ed73a089749
abhinavramkumar/basic-python-programs
/divisors.py
465
4.25
4
# Create a program that asks the user for a number and then prints out a list # of all the divisors of that number. (If you don’t know what a divisor is, # it is a number that divides evenly into another number. # For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) number = int(input("Find divisors f...
true
c510831fdef3482c6394535297180366c2d7741a
Did-you-eat-my-burrito/employee_class_homework
/main.py
2,344
4.25
4
from employee_class import Employee print("*==================================*") print("* 1. show employee list *") print("* 2. add employee *") print("* 3. update employee *") print("* 4. delete employee *") print("* 5. quit app *") print("...
true
4b3ba75135a3c8bcdb993db2b2f7bdd946aa6916
sol83/python-simple_programs_5
/Parameters & Return/print_multiple.py
807
4.6875
5
""" Print multiple Fill out print_multiple(message, repeats), which takes as parameters a string message to print, and an integer repeats number of times to print message. We've written the main() function for you, which prompts the user for a message and a number of repeats. Here's a sample run of the program: $ py...
true
2f61edad23612fdfe7e9a3194f4dfc035f934db8
Yehuda1977/DI_Bootcamp
/Week9/Day2/Exercises.py
1,809
4.1875
4
# Exercise 1 : Built-In Functions # Python has many built-in functions, and if you do not know how to use it, you can read document online. # But Python has a built-in document function for every built-in functions. # Write a program to print some Python built-in functions documents, such as abs(), int(), raw_input()....
true
0a4ef8ad261499611af95096cc162f3cea0b6d9d
Yehuda1977/DI_Bootcamp
/Week7Python/Day2Feb15/dailychallengematrix.py
1,766
4.59375
5
# Hint: Look at the remote learning “Matrix” videos # The matrix is a grid of strings (alphanumeric characters and spaces) with a hidden message in it. # To decrypt the matrix, Neo reads each column from top to bottom, starting from the leftmost column, select only the alpha characters and connect them, then he replac...
true
0ac723f1b6026fb1b19cedad93ebeda3ceb2ab3c
Yehuda1977/DI_Bootcamp
/Week6Python/Day2Feb8/dailychallenge.py
1,348
4.59375
5
# 1. Using the input function, ask the user for a string. The string must be 10 characters long. # If it’s less than 10 characters, print a message which states “string not long enough” # If it’s more than 10 characters, print a message which states “string too long” # 2. Then, print the first and last characte...
true
7cd999d480f77e97259a6da7716217ca42dac450
cdt-data-science/cdt-tea-slides
/2015/theo/optimisation/cost_functions/Cost_Function.py
2,685
4.40625
4
__author__ = 'theopavlakou' class Cost_Function(object): """ An abstract class that provides the interface for cost functions. In this context, a cost function is not a function of the data points or the targets. It is purely a function of the parameters passed to it. Therefore, a cost function...
true
7c2886dc4ba552d982ff8e3883ad142ade94bed6
prayasshrivastava/Python-Programming
/Name&age.py
382
4.21875
4
# Create a program that asks the user to enter their name and their age #Print out a message that will tell them the year that they will turn 95 years old. #!/usr/bin/python3 import datetime name=input("Enter your name: ") age =int(input("Enter your age: ")) z=95-age x=datetime.datetime.now() y=(x.year) p=y+z print(n...
true
479a5121a83c7d842158e0103026d6705b5a355c
bdrummo6/Sprint-Challenge--Data-Structures-Python
/names/binary_search_tree.py
2,415
4.375
4
class BSTNode: def __init__(self, value): self.value = value self.left = None self.right = None # Insert the given value into the tree def insert(self, value): new_node = BSTNode(value) # Compare the new value with the parent node if self.value: ...
true
c949deb09588dd751cccd359fa7c403e47a1a46c
stefanpostolache/pythonHandsOnExamples
/complete/example-0/main.py
1,433
4.21875
4
import random """ Module containing functions to create a hand of cards """ def createHand(handsize): """ Creates a hand of cards Args: handsize (int): size of the hand of cards Returns: tuple: hand and remainder of the deck """ deck = generateDeck() deck = shuffle(deck) ...
true
b92b3348fa54343d7ee3a47c52ad10104292e99a
joshua-paragoso/PythonTutorials
/13_numpyArrays.py
2,103
4.5625
5
# Numpy arrays are great alternatives to Python Lists. Some of the key advantages of Numpy arrays are that # they are fast, easy to work with, and give users the opportunity to perform calculations across entire # arrays. # In the following example, you will first create two Python lists. Then, you will import the n...
true
89b4791ec2c77af0224a9970b5c2f093a9e2a3a9
AnkitaTandon/NTPEL
/python_lab/sum_of_cubes.py
254
4.34375
4
''' Q3 (Viva) : Write a Python program for finding cube sum of first n natural numbers. ''' sum=0 n=int(input("Enter the value of n: ")) for i in range(1,n+1): sum += (i*i*i) print("The sum of the cubes of first n natural numbers = ", sum)
true
edb4f262aa8eca2abf3754958c29ad3eade451e6
AnkitaTandon/NTPEL
/python_lab/1b.py
245
4.1875
4
''' Lab Experiment 1b: Write aprogram which accepts the radius of a circle from the user and computes it's area. ''' num=int(input("Enter the radius of the circle: ")) a=3.14*num*num print("Area of the circle = ",a)
true
32d593104fa5ca8d27dcda20491664a5a60f59bc
AnkitaTandon/NTPEL
/python_lab/add_set.py
392
4.125
4
''' Lab Experiment 6b: Write a program to add members in a set. ''' s=set({}) n=int(input("Enter the number of elements to add to a new set:")) print("Enter the elements-") for i in range(n): s.add(int(input())) print(s) n=int(input("Enter the number of elements to update to a set:")) print("Enter the e...
true
c862d7b2ed1835580cccd4768cc7703b6a79d6e1
nothingtosayy/Strong-Number-in-python
/main.py
349
4.1875
4
def StrongNumber(x): sum = 0 for i in str(x): fact = 1 for j in range(1,int(i)+1): fact = fact*int(j) sum = sum + fact return sum number = int(input("Enter a number : ")) if number == StrongNumber(number): print(f"{number} is a strong number") else: print(f"{numbe...
true
fcbf5e0b09aa329d4f5e092990d344290c2b9206
frappefries/Python
/Assignment/ex1/prg7.py
696
4.40625
4
#!/usr/bin/env python3 """Program to create a list with 10 items in it and perform the below operations a) Print all the elements b) Perform slicing c) Perform repetition with * operator d) Concatenate with other list Usage: python3 prg7.py """ def init(): """Perform operations on the list object and display the...
true
e838153c9ffe71dcd43b77bd2b78d198d2c14193
frappefries/Python
/Assignment/ex1/prg6.py
1,073
4.46875
4
#!usr/bin/env python3 """Program to read a string and print each character separately. also do a) slice the string using [:]operator to create subtstrings b) repeat the string 100 times using the * operator c) read the second string and concatenate it with the first string using + op...
true
5bc62025f4a8731214f840073dbfd5a980678449
frappefries/Python
/Assignment/ex1/prg17.py
1,038
4.53125
5
#!/usr/bin/env python3 """Program to find the biggest and smallest of N numbers (use functions to find the biggest and smallest numbers) Usage: python3 prg17.py """ def init(): """Fetch 5 numbers and display the smallest and biggest number""" num = [] print("Enter 5 numbers:") for item in range(5): ...
true
feef9f3d26f617fefd95cd910c2ae481f9ba8386
jenniferjqiai/Python-for-Everybody
/Chapter 8/Exercise 4.py
649
4.3125
4
#Exercise 4: Download a copy of the file www.py4e.com/code3/romeo.txt. # Write a program to open the file romeo.txt and read it line by line. For each line, # split the line into a list of words using the split function. For each word, # check to see if the word is already in a list. If the word is not in the list, add...
true
de6b6981980fad37774192df2b7bab67f773511b
atmilich/DaltonPython
/hw2.py
2,081
4.125
4
def convertScoreToGrade(n): grade = "" if(99 <= int(n) <= 100): print("true") grade = "A+" elif(96 <= int(n) <= 98): grade = "A" elif(93 <= int(n) <= 95): grade = "A-" elif(90 <= int(n) <= 92): grade = "B+" elif(87 <= int(n) <= 89): grade = "B" elif(84 <= int(n) <= 86): grade = "B-" elif(81 <= int...
true
f3fddc03d0ba3399490a014e3bbcae93a411cf62
EarthenSky/Python-Practice
/misc&projects/ex(1-5).py
1,154
4.28125
4
# This is a built in python library that gives access to math functions import math # Uses pythagorean theorm to find the hypotenuse of a triangle def find_hypotenuse(a, b): return math.sqrt(a ** 2 + b ** 2) # Inital statement print "This is a right triangle hypotenuse calculator." # Define Global input paramet...
true
8da15a787b0276cae157b598910d8eadbc809ee0
EarthenSky/Python-Practice
/misc&projects/ex(1-4).py
1,314
4.3125
4
# Initial print statements print "Name: Gabe Stang" print "Class: Magic Number 144" print "Teacher: Mr. Euclid \n" # "def" is how you define a function / method. # A function in python may or may not have a return value. # Outputs a string detailing what numbers were added and the solution def string_sum(num1, num2):...
true
dcecd97b65c9cffa90b45aa04186619d0b8f791e
Cherchercher/magic
/answers/flatten_array.py
407
4.46875
4
def flatten_array_recursive(a): """ recursively flattened nested array of integers Args: a: array to flatten which each element is either an integer or a (nested) list of integers Returns: flattened array """ result = [] for i in a: if type(i) == list: result += f...
true
5b60b8daede4884824ec4652dd1e35b1099b18a5
league-python-student/level0-module1-RedHawk1967
/_03_if_else/_5_shape_selector/shape_selector.py
1,083
4.40625
4
import turtle from tkinter import messagebox, simpledialog, Tk # Goal: Write a Python program that asks the user whether they want to # draw a triangle, square, or circle and then draw that shape. if __name__ == '__main__': window = Tk() window.withdraw() # Make a new turtle my_t...
true
436a5a72ec807c80d379373be7f619e982a7f663
edufreitas-ds/Datacamp
/01 - Introduction to Python/03 - NumPy/12 - Average versus median_adapted.py
1,142
4.1875
4
""" You now know how to use numpy functions to get a better feeling for your data. It basically comes down to importing numpy and then calling several simple functions on the numpy arrays: import numpy as np x = [1, 4, 8, 10, 12] np.mean(x) np.median(x) The baseball data is available as a 2D numpy array with...
true