blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
5077815f19f7bd1d729650704069e64e448cd89c | Souravdg/Python.Session_4.Assignment-4.2 | /Vowel Check.py | 776 | 4.15625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
"""
Problem Statement 2:
Write a Python function which takes a character (i.e. a string of length 1) and returns
True if it is a vowel, False otherwise.
"""
def vowelChk(char):
if(char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u'):
ret... | true |
fb6ac747fcf5d0fc4fc360cdfbb7e146f9e099e4 | sharyar/design-patterns-linkedin | /visitor.py | 1,285 | 4.25 | 4 | class House(object):
def accept(self, visitor):
''' The interface to accept a visitor '''
# Triggers the visiting operation
visitor.visit(self)
def work_on_hvac(self, hvac_specialist):
print(self, 'worked on by', hvac_specialist)
# This creates a reference to the HVAC s... | true |
9dd9050ffca4e9c67628c713695472613b6ef5bd | mas254/tut | /String methods.py | 349 | 4.125 | 4 | course = "Python for Beginners"
print(len(course))
print(course.upper())
print(course.find("P"))
# You get 0 here as this is the position of P in the string
print(course.find("z"))
# Negative 1 is if not found
print(course.replace("Beginners", "Absolute Beginners"))
print(course)
print("Python" in course)
# All case se... | true |
132d54605b7b373f7d8494dce66665cf80cd9373 | mas254/tut | /creating_a_reusable_function.py | 935 | 4.28125 | 4 | message = input('>')
words = message.split(' ')
emojis = {
':)': 'smiley',
':(': 'frowney'
}
output = ''
for word in words:
output += emojis.get(word, word) + ' '
print(output)
def emojis(message):
words = message.split(' ')
emojis = {
':)': 'smiley',
':(': 'frowney'
}
outpu... | true |
cda3560dfafcb1c358ea0c6ff93477d6e868bb68 | sabach/restart | /script10.py | 540 | 4.375 | 4 | # Write a Python program to guess a number between 1 to 9.
#Note : User is prompted to enter a guess.
#If the user guesses wrong then the prompt appears again
#until the guess is correct, on successful guess,
#user will get a "Well guessed!" message,
#and the program will exit.
from numpy import random
randonly_sele... | true |
713773b1c5d7b50b23270a1ac5f7ca2aa62ac58b | VelizarMitrev/Python-Homework | /Homework1/venv/Exercise6.py | 343 | 4.34375 | 4 | nand = input("Choose a number ")
operator = input("Input + OR * for either computing a number or multiplying it ")
sum = 0
if operator == "+":
for x in range(1, int(nand) + 1):
sum = sum + x
if operator == "*":
sum = 1
for x in range(1, int(nand) + 1):
sum = sum * x
print("The final ... | true |
b44c3fcdf3aa99d88f9d5a03c7d12cb64e9715d6 | VelizarMitrev/Python-Homework | /Homework2/venv/Exercise10.py | 387 | 4.34375 | 4 | def fibonacci(num): # this is a recursive solution, in this case it's slower but the code is cleaner
if num <= 1:
return num
else:
return(fibonacci(num-1) + fibonacci(num-2))
numbers_sequence = input("Enter how many numbers from the fibonacci sequence you want to print: ")
print("Fibonacci sequenc... | true |
02d3f469da092a1222b12b48327c61da7fc1fea3 | mvargasvega/Learn_Python_Exercise | /ex6.py | 903 | 4.5 | 4 | types_of_people = 10
# a string with embeded variable of types_of_people
x = f"There are {types_of_people} types of people."
binary = "binary"
do_not = "don't"
# assigns a string to y with embeded variables
y = f"Those who know {binary} and those who {do_not}."
print(x)
print(y)
print(f"I said: {x}")
# printing a st... | true |
b13dd7edaf3c6269f3d3fa90682eeeb989d78571 | TigerAppsOrg/TigerHost | /deploy/deploy/utils/click_utils.py | 586 | 4.1875 | 4 | import click
def prompt_choices(choices):
"""Displays a prompt for the given choices
:param list choices: the choices for the user to choose from
:rtype: int
:returns: the index of the chosen choice
"""
assert len(choices) > 1
for i in range(len(choices)):
click.echo('{number}) {... | true |
2609c2b1f06d647b086493c1294a1652787cefd8 | FranciscoValadez/Course-Work | /Python/CS119-PJ 6 - Simple Calculator/PJ 6 - Simple Calculator/PJ_6___Simple_Calculator.py | 1,900 | 4.5 | 4 | # Author: Francisco Valadez
# Date: 1/23/2021
# Purpose: A simple calculator that shows gives the user a result based on their input
#This function is executed when the user inputs a valid operator
def Results(num1, num2, operator):
if operator == '+':
print("Result:", num1, operator, num2, "=", (num1 ... | true |
f5617054ec164da96fe6c2d4b638c9889060bbf0 | hirani/pydec | /pydec/pydec/math/parity.py | 2,695 | 4.15625 | 4 | __all__ = ['relative_parity','permutation_parity']
def relative_parity(A,B):
"""Relative parity between two lists
Parameters
----------
A,B : lists of elements
Lists A and B must contain permutations of the same elements.
Returns
-------
parity : integer
... | true |
e3f3da252345a8e54f3e7bff4d6c695d379b5e42 | grupy-sanca/dojos | /039/2.py | 839 | 4.53125 | 5 | """
https://www.codewars.com/kata/55960bbb182094bc4800007b
Write a function insert_dash(num) / insertDash(num) / InsertDash(int num)
that will insert dashes ('-') between each two odd digits in num.
For example: if num is 454793 the output should be 4547-9-3.
Don't count zero as an odd digit.
Note that the number wil... | true |
4fd23931962dd3a22a5a168a9a49bc68fd8eadd6 | grupy-sanca/dojos | /028/ex2.py | 1,416 | 4.40625 | 4 | """
A newly opened multinational brand has decided to base their company logo on the three most common characters in the company name.
They are now trying out various combinations of company names and logos based on this condition.
Given a string, which is the company name in lowercase letters, your task is to find the... | true |
f17e7bc0acc2e97393a392ffb15e96a3f9f805f2 | ayust/controlgroup | /examplemr.py | 645 | 4.28125 | 4 | # A mapper function takes one argument, and maps it to something else.
def mapper(item):
# This example mapper turns the input lines into integers
return int(item)
# A reducer function takes two arguments, and reduces them to one.
# The first argument is the current accumulated value, which starts
# out with t... | true |
41b44b20257c4a5e99ca9af99d7ca7fc7066ed1c | Lesikv/python_tasks | /python_practice/matrix_tranpose.py | 654 | 4.1875 | 4 | #!usr/bin/env python
#coding: utf-8
def matrix_transpose(src):
"""
Given a matrix A, return the transpose of A
The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.
"""
r, c = len(src), len(src[0])
res = [[None] * r for i i... | true |
c70cbbe6dd0107e74cd408a899dc6bbe77432829 | reenadhawan1/coding-dojo-algorithms | /week1/python-fundamentals/selection_sort.py | 1,044 | 4.15625 | 4 | # Selection Sort
x = [23,4,12,1,31,14]
def selection_sort(my_list):
# find the length of the list
len_list = len(my_list)
# loop through the values
for i in range(len_list):
# for each pass of the loop set the index of the minimum value
min_index = i
# compare the current value... | true |
249cbda74673f28d7cc61e8be86cdfef2b855e2a | Bharadwaja92/DataInterviewQuestions | /Questions/Q_090_SpiralMatrix.py | 414 | 4.4375 | 4 | """""""""
Given a matrix with m x n dimensions, print its elements in spiral form.
For example:
#Given:
a = [ [10, 2, 11],
[1, 3, 4],
[8, 7, 9] ]
#Your function should return:
10, 2, 11, 4, 9, 7, 8, 1, 3
"""
def print_spiral(nums):
# 10, 2, 11, 4, 9, 7, 8, 1, 3
# 4 Indicators -- row start and end, column s... | true |
8b2af30e0e3e4fc2cfefbd7c7e9a60edc42538c0 | Bharadwaja92/DataInterviewQuestions | /Questions/Q_029_AmericanFootballScoring.py | 2,046 | 4.125 | 4 | """""""""
There are a few ways we can score in American Football:
1 point - After scoring a touchdown, the team can choose to score a field goal
2 points - (1) after scoring touchdown, a team can choose to score a conversion,
when the team attempts to score a secondary touchdown or
(2) an u... | true |
604a4bb01ff02dc0da1ca2ae0ac71e414c5a6afe | Bharadwaja92/DataInterviewQuestions | /Questions/Q_055_CategorizingFoods.py | 615 | 4.25 | 4 | """""""""
You are given the following dataframe and are asked to categorize each food into 1 of 3 categories:
meat, fruit, or other.
food pounds
0 bacon 4.0
1 STRAWBERRIES 3.5
2 Bacon 7.0
3 STRAWBERRIES 3.0
4 BACON 6.0
5 strawberries 9.0
6 Strawberries 1.0
7 pecans 3.0
Can... | true |
58401ce6e6a3876062d2a629d39314432e08b64f | mattling9/Algorithms2 | /stack.py | 1,685 | 4.125 | 4 | class Stack():
"""a representation of a stack"""
def __init__(self, MaxSize):
self.MaxSize = MaxSize
self.StackPointer = 0
self.List = []
def size(self):
StackSize = len(self.List)
return StackSize
def pop(self):
StackSize = self.StackSize()
... | true |
31b272d2675be1ecfd20e9b4bae4759f5b533106 | iemeka/python | /exercise-lpthw/snake6.py | 1,792 | 4.21875 | 4 | #declared a variable, assigning the string value to it.
#embedded in the string is a format character whose value is a number 10 assigned to it
x = "There are %d types of people." % 10
#declared a variable assigning to it the string value
binary = "binary"
#same as above
do_not = "don't"
# also same as above but with w... | true |
ed10b4f7cebef6848b14803ecf76a16b8bc84ca4 | iemeka/python | /exercise-lpthw/snake32.py | 713 | 4.40625 | 4 | the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for-loop goes through a list
for number in the_count:
print "This is count %d" % number
# same as above
for fruit in fruits:
print "A fruit of type: %s" % fruit
fo... | true |
bb1a2972bc806e06fe6302c703c158130318bf07 | iemeka/python | /exercise-lpthw/snake20.py | 1,128 | 4.21875 | 4 | from sys import argv
script, input_file = argv
# a function to read the file held and open in the variable 'current_file' and then passed..
# the variable is passed to this functions's arguement
def print_all(f):
print f.read()
# seek takes us to the begining of the file
def rewind(f):
f.seek(0)
# we print the nume... | true |
3d3bb07c0afda8d2c9943a39883cbbee67bfe4b1 | icgowtham/Miscellany | /python/sample_programs/tree.py | 2,130 | 4.25 | 4 | """Tree implementation."""
class Node(object):
"""Node class."""
def __init__(self, data=None):
"""Init method."""
self.left = None
self.right = None
self.data = data
# for setting left node
def set_left(self, node):
"""Set left node."""
... | true |
87661803c954900ef11a81ac450ffaaf76b83167 | truas/kccs | /python_overview/python_database/database_03.py | 1,482 | 4.375 | 4 | import sqlite3
'''
The database returns the results of the query in response to the cursor.fetchall call
This result is a list with one entry for each record in the result set
'''
def make_connection(database_file, query):
'''
Common connection function that will fetch data with a given query in a specific D... | true |
5217a281d3ba76965d0cb53a38ae90d16e7d7640 | truas/kccs | /python_overview/python_oop/abstract_animal_generic.py | 2,001 | 4.25 | 4 | from abc import ABC, abstractmethod #yes this is the name of the actual abstract class
'''
From the documentation:
"This module provides the infrastructure for defining abstract base classes (ABCs) in Python"
'''
class AbstractBaseAnimal(ABC):
'''
Here we have two methods that need to be implemented by any clas... | true |
f0c289169c7eea7a8d4675450cda1f36b10c3baf | alexeydevederkin/Hackerrank | /src/main/python/min_avg_waiting_time.py | 2,648 | 4.4375 | 4 | #!/bin/python3
'''
Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant,
a customer is served by following the first-come, first-served rule, Tieu simply minimizes
the average waiting time of his customers. So he gets to decide who is served first,
regardless of how sooner or ... | true |
2e86e6d499de5d51f19051728db135aac6b36044 | avisek-3524/Python- | /oddeven.py | 260 | 4.1875 | 4 | '''write a program to print all the numbers from
m-n thereby classifying them as even or odd'''
m=int(input('upper case'))
n=int(input('lower case'))
for i in range(m,n+1):
if(i%2==0):
print(str(i)+'--even')
else:
print(str(i)+'--odd') | true |
4a4f0e71027d92fa172f78811993aa1d62e2a6c7 | JuveVR/Homework_5 | /Exercise_2.py | 2,650 | 4.21875 | 4 | #2.1
class RectangularArea:
"""Class for work with square geometric instances """
def __init__(self, side_a, side_b):
"""
Defines to parameters of RectangularArea class. Checks parameters type.
:param side_a: length of side a
:param side_b:length of side a
"""
sel... | true |
0b0e1f3f55ae4faa409b1fefb704b577aebb6c87 | saicataram/MyWork | /DL-NLP/Assignments/Assignment4/vowel_count.py | 801 | 4.3125 | 4 | """
*************************************************************************************
Author: SK
Date: 30-Apr-2020
Description: Python Assignments for practice;
a. Count no of vowels in the provided string.
*************************************************************************************
"""
def vowel_c... | true |
bd557b8cb881b1a6a0832b347c6855289a7c7cef | saicataram/MyWork | /DL-NLP/Assignments/Assignment4/lengthofStringinList.py | 528 | 4.375 | 4 | """
*************************************************************************************
Author: SK
Date: 30-Apr-2020
Description: Python Assignments for practice;
a. Count length of the string in list provided.
*************************************************************************************
"""
string = ... | true |
d4aa13f6bd5d92ad0445200c91042b1b72f8f4cc | lilianaperezdiaz/cspp10 | /unit4/Lperez_rps.py | 2,982 | 4.3125 | 4 | import random
#function name: get_p1_move
# arguments: none
# purpose: present player with options, use input() to get player move
# returns: the player's move as either 'r', 'p', or 's'
def get_p1_move():
move=input("rock, paper, scissors: ")
return move
#function name: get_comp_move():
# argum... | true |
287660ee7a1580903b9815b83106e8a5bd6e0c20 | 5folddesign/100daysofpython | /day_002/day_004/climbing_record_v4.py | 2,228 | 4.15625 | 4 | #python3
#climbing_record.py is a script to record the grades, and perceived rate of exertion during an indoor rock climbing session.
# I want this script to record: the number of the climb, wall type, grade of climb, perceived rate of exertion on my body, perceived rate of exertion on my heart, and the date and time... | true |
6367b485bbbeb065dc379fa1164072db6bac22e4 | risbudveru/machine-learning-deep-learning | /Machine Learning A-Z/Part 2 - Regression/Section 4 - Simple Linear Regression/Simple linear reg Created.py | 1,590 | 4.3125 | 4 | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
#X is matrix of independent variables
#Y is matrix of Dependent variables
#We predict Y on basis of X
dataset = pd.read_csv('Salary_data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 1].values
# Spli... | true |
84c9145c5802f5f1b2c2e70b8e2038b573220bd5 | renan09/Assignments | /Python/PythonAssignments/Assign8/fibonacci2.py | 489 | 4.15625 | 4 | # A simple generator for Fibonacci Numbers
def fib(limit):
# Initialize first two Fibonacci Numbers
a, b = 0, 1
# One by one yield next Fibonacci Number
while a < limit:
yield a
#print("a : ",a)
a, b = b, a + b
#print("a,b :",a," : ",b)
# Create a gener... | true |
be1a6beb03d6f54c3f3d42882c84031cd415dc83 | shaversj/100-days-of-code-r2 | /days/27/longest-lines-py/longest_lines.py | 675 | 4.25 | 4 | def find_longest_lines(file):
# Write a program which reads a file and prints to stdout the specified number of the longest lines
# that are sorted based on their length in descending order.
results = []
num_of_results = 0
with open(file) as f:
num_of_results = int(f.readline())
for... | true |
f99e68cfa634143883bfce882bc3b399bf1f1fcf | shaversj/100-days-of-code-r2 | /days/08/llist-py/llist.py | 862 | 4.21875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def add(self, data):
new_node = Node(data)
node = self.head
# Get to the last node
previous = None
while node is... | true |
1b68f58a36594c14385ff3e3faf8569659ba0532 | derekcollins84/myProjectEulerSolutions | /problem0001/problem1.py | 521 | 4.34375 | 4 | '''
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
'''
returnedValues = []
sumOfReturnedValues = 0
for testNum in range(1, 1000):
if testNum % 3 == 0 or \
testNum ... | true |
8b29ca12d190975f7b957645e9a18b4291e662a1 | Sohom-chatterjee2002/Python-for-Begineers | /Assignment 2 -Control statements in Python/Problem 6.py | 556 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 23 14:25:28 2020
@author: Sohom Chatterjee_CSE1_T25
"""
#The set of input is given as ages. then print the status according to rules.
def age_status(age):
if(age<=1):
print("in_born")
elif(age>=2 and age<=10):
print("child")
elif(... | true |
413524181632130eb94ef936ff18caecd4d47b06 | nikhilroxtomar/Fully-Connected-Neural-Network-in-NumPy | /dnn/activation/sigmoid.py | 341 | 4.1875 | 4 | ## Sigmoid activation function
import numpy as np
class Sigmoid:
def __init__(self):
"""
## This function is used to calculate the sigmoid and the derivative
of a sigmoid
"""
def forward(self, x):
return 1.0 / (1.0 + np.exp(-x))
def backward(self, x):
... | true |
8e96a6fcac5695f7f0d47e1cf3f6ecef9382cbbf | janvanboesschoten/Python3 | /h3_hours_try.py | 275 | 4.125 | 4 | hours = input('Enter the hour\n')
try:
hours = float(hours)
except:
hours = input('Error please enter numeric input\n')
rate = input('Enter your rate per hour?\n')
try:
rate = float(rate)
except:
rate = input('Error please enter numeric input\n')
| true |
ed98b46454cb7865aadfe06077dff076dfd71a73 | mujtaba4631/Python | /FibonacciSeries.py | 308 | 4.5625 | 5 | #Fibonacci Sequence -
#Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number.
n = int(input("enter the number till which you wanna generate Fibonacci series "))
a = 0
b = 1
c = a+1
print(a)
print(b)
for i in range(0,n):
c = a+ b
print(c)
a,b=b,c
| true |
2ddc4abc64069852fdd535b49a26f5712463f14a | nathanandersen/SortingAlgorithms | /MergeSort.py | 1,122 | 4.25 | 4 | # A Merge-Sort implementation in Python
# (c) 2016 Nathan Andersen
import Testing
def mergeSort(xs,key=None):
"""Sorts a list, xs, in O(n*log n) time."""
if key is None:
key = lambda x:x
if len(xs) < 2:
return xs
else:
# sort the l and r halves
mid = len(xs) // 2
... | true |
614d2f3dfc383cf24fd979bb2918bef80fda3450 | fancycheung/LeetCodeTrying | /easy_code/Linked_List/876.middleofthelinkedlist.py | 1,180 | 4.15625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
@author:nali
@file: 876.middleofthelinkedlist.py
@time: 2018/9/3/上午9:41
@software: PyCharm
"""
"""
Given a non-empty, singly linked list with head node head, return a middle node of linked list.
If there are two middle nodes, return the second middle node.
Exam... | true |
4afad10bff966b08e4f0aab782049901a3fb66dc | BalintNagy/GitForPython | /Checkio/01_Elementary/checkio_elementary_11_Even_the_last.py | 1,261 | 4.21875 | 4 | """\
Even the last
You are given an array of integers. You should find the sum of the elements
with even indexes (0th, 2nd, 4th...) then multiply this summed number and
the final element of the array together. Don't forget that the first element
has an index of 0.
For an empty array, the r... | true |
92067b660f1df00f7d622b49388994c892145033 | BalintNagy/GitForPython | /OOP_basics_1/01_Circle.py | 572 | 4.125 | 4 | # Green Fox OOP Basics 1 - 1. feladat
# Create a `Circle` class that takes it's radius as cinstructor parameter
# It should have a `get_circumference` method that returns it's circumference
# It should have a `get_area` method that returns it's area
import math
class Circle:
def __init__(self, radius):
... | true |
7852ff2dfef25e356a65c527e94ee88d10c74a0b | BalintNagy/GitForPython | /Checkio/01_Elementary/checkio_elementary_16_Digits_multiplication.py | 929 | 4.40625 | 4 | """\
Digits Multiplication
You are given a positive integer. Your function should calculate the product
of the digits excluding any zeroes.
For example: The number given is 123405. The result will be 1*2*3*4*5=120
(don't forget to exclude zeroes).
Input: A positive integer.
Output: The p... | true |
d5353aa98262d9de8b540c9ae863bde41ab0cda9 | mura-wx/mura-wx | /python/Practice Program/basic program/chekPositifAndNegatif.py | 306 | 4.15625 | 4 | try :
number=int(input("Enter Number : "))
if number < 0:
print("The entered number is negatif")
elif number > 0:
print("The entered number is positif")
if number == 0:
print("number is Zero")
except ValueError :
print('The input is not a number !') | true |
76b5171706f347c58c33eed212798f84c6ebcfd1 | zuxinlin/leetcode | /leetcode/350.IntersectionOfTwoArraysII.py | 1,434 | 4.1875 | 4 | #! /usr/bin/env python
# coding: utf-8
'''
'''
class Solution(object):
'''
Given two arrays, write a function to compute their intersection.
Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].
Note:
Each element in the result should appear as many times as it shows in both a... | true |
37e1234e8f39adc280dc20a3c39ea86f93143b0e | zuxinlin/leetcode | /leetcode/110.BalancedBinaryTree.py | 1,342 | 4.28125 | 4 | #! /usr/bin/env python
# coding: utf-8
'''
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as:
a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
Example 1:
Given the following tree [3,9,20,null,null,15... | true |
7a750725399d333e2cd1b46add1b8cc0c02b1522 | MadyDixit/ProblemSolver | /Google/Coding/UnivalTree.py | 1,039 | 4.125 | 4 | '''
Task 1: Check weather the Given Tree is Unival or Not.
Task 2: Count the Number of Unival Tree in the Tree.
'''
'''
Task 1:
'''
class Tree:
def __init__(self,x):
self.val = x
self.left = None
self.right = None
def insert(self, data):
if self.val:
if self.val > da... | true |
02d2c723586f0b98c48dde041b20e5ec86809fae | pkray91/laravel | /string/string.py | 1,254 | 4.4375 | 4 | print("Hello python");
print('Hello python');
x = '''hdbvfvhbfvhbf'''
y = """mdnfbvnfbvdfnbvfvbfm"""
print(y)
print(x)
a='whO ARE you Man';
print(a);
print(a.upper());
print(a.lower());
print(len(a));
print(a[1]);
#sub string not including the given position.
print(a[4:8]);
#The strip() method removes any whitespace f... | true |
996520dcd43c24c0391fc8767ee4eb9f8f3d309e | AdityaChavan02/Python-Data-Structures-Coursera | /8.6(User_input_no)/8.6.py | 481 | 4.3125 | 4 | #Rewrite the program that prompts the user for a list of numbers and prints the max and min of the numbers at the end when the user presses done.
#Write the program to store the numbers in a list and use Max Min functions to compute the value.
List=list()
while True:
no=input("Enter the no that you so des... | true |
0ac525f075a96f8a749ddea35f8e1a59775217c8 | ZoranPandovski/al-go-rithms | /sort/selection_sort/python/selection_sort.py | 873 | 4.125 | 4 | #defines functions to swap two list elements
def swap(A,i,j):
temp = A[i]
A[i] = A[j]
A[j] = temp
#defines functions to print list
def printList(A,n):
for i in range(0,n):
print(A[i],"\t")
def selectionSort(A,n):
for start in range(0,n-1):
min=start #min is the index of the small... | true |
6b2ae13e2f7dfa26c15cef55978cf7e70f4bf711 | ZoranPandovski/al-go-rithms | /dp/min_cost_path/python/min_cost_path_.py | 809 | 4.21875 | 4 |
# A Naive recursive implementation of MCP(Minimum Cost Path) problem
R = 3
C = 3
import sys
# Returns cost of minimum cost path from (0,0) to (m, n) in mat[R][C]
def minCost(cost, m, n):
if (n < 0 or m < 0):
return sys.maxsize
elif (m == 0 and n == 0):
return cost[m][n]
else:
... | true |
1f2547aa08428209cf4d106ad8361033dd411efc | ZoranPandovski/al-go-rithms | /strings/palindrome/python/palindrome2.py | 369 | 4.53125 | 5 | #We check if a string is palindrome or not using slicing
#Accept a string input
inputString = input("Enter any string:")
#Caseless Comparison
inputString = inputString.casefold()
#check if the string is equal to its reverse
if inputString == inputString[::-1]:
print("Congrats! You typed in a PALINDROME!!")
else:
... | true |
fc9287fca6c7b390cbd47ae7f70806b10d6114c3 | ZoranPandovski/al-go-rithms | /data_structures/b_tree/Python/check_bst.py | 1,131 | 4.28125 | 4 | """
Check whether the given binary tree is BST(Binary Search Tree) or not
"""
import binary_search_tree
def check_bst(root):
if(root.left != None):
temp = root.left
if temp.val <= root.val:
left = check_bst(root.left)
else:
return False
else:
... | true |
bf23783e9c07a11cdf0a186ab28da4edc1675b54 | ZoranPandovski/al-go-rithms | /sort/Radix Sort/Radix_Sort.py | 1,369 | 4.1875 | 4 | # Python program for implementation of Radix Sort
# A function to do counting sort of arr[] according to
# the digit represented by exp.
def countingSort(arr, exp1):
n = len(arr)
# The output array elements that will have sorted arr
output = [0] * (n)
# initialize count array as 0
count = [0] * (10)
# Store ... | true |
45d1f94946fb66eb792a8dbc8cbdb84c216d381c | ZoranPandovski/al-go-rithms | /math/leapyear_python.py | 491 | 4.25 | 4 | '''Leap year or not'''
def leapyear(year):
if (year % 4 == 0) and (year % 100 != 0) or (year % 400==0) : #checking for leap year
print(year," is a leap year") #input is a leap year
else:
print(year," is not a leap year") #input is not a leap year
year=int(input("Enter the year: "))
while year<=999 or year>=... | true |
533b8c91219f7c4a2e51f952f88581edb8446fd5 | ZoranPandovski/al-go-rithms | /sort/python/merge_sort.py | 1,809 | 4.25 | 4 | """
This is a pure python implementation of the merge sort algorithm
For doctests run following command:
python -m doctest -v merge_sort.py
or
python3 -m doctest -v merge_sort.py
For manual testing run:
python merge_sort.py
"""
from __future__ import print_function
def merge_sort(collection):
"""Pure implementa... | true |
0fbd0364c4afb58c921db8d3a036916e69b5a2b1 | ZoranPandovski/al-go-rithms | /sort/bubble_sort/python/capt-doki_bubble_sort.py | 652 | 4.3125 | 4 | # Python program for implementation of Bubble Sort
# TIME COMPLEXITY -- O(N^2)
# SPACE COMPLEXITY -- O(1)
def bubbleSort(arr):
n = len(arr)
# Traverse through all array elements
for i in range(n):
# Last i elements are already in place
for j in range(0, n-i-1):
# traver... | true |
0b275806d4228c967856b0ff6995201b7af57e5e | ZoranPandovski/al-go-rithms | /data_structures/Graphs/graph/Python/closeness_centrality.py | 1,585 | 4.28125 | 4 | """
Problem :
Calculate the closeness centrality of the nodes of the given network
In general, centrality identifies the most important vertices of the graph.
There are various measures for centrality of a node in the network
For more details : https://en.wikipedia.org/wiki/Closeness_centrality
Formula :
let C(x) be ... | true |
9b8696686283cf9e7afea3bf7b1ac976c3233a54 | ZoranPandovski/al-go-rithms | /dp/EditDistance/Python/EditDistance.py | 1,017 | 4.15625 | 4 | from __future__ import print_function
def editDistance(str1, str2, m , n):
# If first string is empty, the only option is to
# insert all characters of second string into first
if m==0:
return n
# If second string is empty, the only option is to
# remove all characters of first string
if n==0:
return m
#... | true |
044b06fda913253faaa6ac13b30308aa18c7aa47 | th3n0y0u/C2-Random-Number | /main.py | 577 | 4.4375 | 4 | import random
print("Coin Flip")
# 1 = heads, 2 = tails
coin = random.randint(1,2)
if(coin == 1):
print("Heads")
else:
print("Tails")
# Excecise: Create a code that mimics a dice roll using random numbers. The code of the print what number is "rolled", letting the user what it is.
dice = random.randint(1,6)
... | true |
869a95eb86410b60b95c95c08ab58a93193b55e1 | thevarungrovers/Area-of-circle | /Area Of Circle.py | 209 | 4.25 | 4 | r = input("Input the radius of the circle:") # input from user
r = float(r) # typecasting
a = 3.14159265 * (r**2) # calculating area
print(f'The area of circle with radius {r} is {a}') # return area
| true |
2c969e27e178cb286b98b7e320b5bbdcaee3b8f7 | ProximaDas/HW06 | /HW06_ex09_04.py | 1,579 | 4.53125 | 5 | #!/usr/bin/env python
# HW06_ex09_04.py
# (1)
# Write a function named uses_only that takes a word and a string of letters,
# and that returns True if the word contains only letters in the list.
# - write uses_only
# (2)
# Can you make a sentence using only the letters acefhlo? Other than "Hoe
# alfalfa?"
# - writ... | true |
308a96b56534d587575e0be55f037bdcbeb5c06e | subbul/python_book | /lists.py | 2,387 | 4.53125 | 5 | simple_list = [1,2,3]
print "Simple List",simple_list
hetero_list = [1,"Helo",[100,200,300]]# can containheterogenous values
print "Original List",hetero_list
print "Type of object hetero_list",type(hetero_list) # type of object, shows its fundamental data type, for e.g., here it is LIST
print "Item at index 0 ... | true |
6a8aa8ce16427dab54ddc650747a5fcb306b86ba | twilliams9397/eng89_python_oop | /python_functions.py | 897 | 4.375 | 4 | # creating a function
# syntax def name_of_function(inputs) is used to declare a function
# def greeting():
# print("Welcome on board, enjoy your trip!")
# # pass can be used to skip without any errors
#
# greeting() # function must be called to give output
#
# def greeting():
# return "Welcome on board, enjoy... | true |
27c6ec9e71d1d1cdd87ae03180937f2d798db4b2 | leocjj/0123 | /Python/python_dsa-master/recursion/int_to_string.py | 393 | 4.125 | 4 | #!/usr/bin/python3
"""
Convert an integer to a string
"""
def int_to_string(n, base):
# Convert an integer to a string
convert_string = '0123456789ABCDEF'
if n < base:
return convert_string[n]
else:
return int_to_string(n // base, base) + convert_string[n % base]
if __name__ == '__mai... | true |
e81c76e31dd827790d6b98e739763201cfc618ab | tlepage/Academic | /Python/longest_repetition.py | 1,121 | 4.21875 | 4 | __author__ = 'tomlepage'
# Define a procedure, longest_repetition, that takes as input a
# list, and returns the element in the list that has the most
# consecutive repetitions. If there are multiple elements that
# have the same number of longest repetitions, the result should
# be the one that appears first. If the i... | true |
9682bdce76206453617d5b26c2c219becb5d4001 | yougov/tortilla | /tortilla/formatters.py | 444 | 4.125 | 4 | # -*- coding: utf-8 -*-
def hyphenate(path):
"""Replaces underscores with hyphens"""
return path.replace('_', '-')
def mixedcase(path):
"""Removes underscores and capitalizes the neighbouring character"""
words = path.split('_')
return words[0] + ''.join(word.title() for word in words[1:])
def... | true |
d817d8f491e23137fd24c3184d6e594f1d8381b0 | GaneshManal/TestCodes | /python/practice/syncronous_1.py | 945 | 4.15625 | 4 | """
example_1.py
Just a short example showing synchronous running of 'tasks'
"""
from multiprocessing import Queue
def task(name, work_queue):
if work_queue.empty():
print('Task %s nothing to do', name)
else:
while not work_queue.empty():
count = work_queue.get()
tota... | true |
5a9161c4f8f15e0056fd425a5eee58de16ec45bf | beb777/Python-3 | /003.py | 417 | 4.28125 | 4 | #factorial n! = n*(n-1)(n-2)..........*1
number = int(input("Enter a number to find factorial: "))
factorial = 1;
if number < 0:
print("Factorial does not defined for negative integer");
elif (number == 0):
print("The factorial of 0 is 1");
else:
while (number > 0):
factorial = factorial * number
... | true |
1c922b07b6b1f011b91bc75d68ece9b8e2958576 | Leah36/Homework | /python-challenge/PyPoll/Resources/PyPoll.py | 2,168 | 4.15625 | 4 | import os
import csv
#Create CSV file
election_data = os.path.join("election_data.csv")
#The list to capture the names of candidates
candidates = []
#A list to capture the number of votes each candidates receives
num_votes = []
#The list to capture the number of votes each candidates gather
percent_votes = []
#... | true |
faaf4b222a3b9e120d0197c218bcd6e25c3422a4 | bwblock/Udacity | /CS101/quiz-median.py | 621 | 4.21875 | 4 | #! /usr/bin/env python
# Define a procedure, median, that takes three
# numbers as its inputs, and returns the median
# of the three numbers.
# Make sure your procedure has a return statement.
def bigger(a,b):
if a > b:
return a
else:
return b
def biggest(a,b,c):
return bigger(a,bigger(b... | true |
a759beda8dd1ef2309a0c200c3442bed4228f455 | naotube/Project-Euler | /euler7.py | 616 | 4.21875 | 4 | #! /usr/bin/env python
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13,
# we can see that the 6th prime is 13.
# What is the 10001st prime number?
primes = [2,3]
def is_prime(num):
"""if num is a prime number, returns True, else returms False"""
for i in primes:
if num % i == 0:
... | true |
cd9902d851dd5f7d4527d6bb80fa8abf13ef59c7 | ubaidahmadceh/python_beginner_to_expert | /isdigit_function.py | 218 | 4.25 | 4 | number = input("Enter your number : ")
if number.isdigit():
print("this is numeric (0-9)")
elif number.isalpha():
print("this is string !!")
else:
print("This is not numeric , this is symbol or alphabet")
| true |
95a17e11a79f68563c393524c22b6f45b0365599 | rob256/adventofcode2017 | /python3/day_2/day_2_part_1.py | 977 | 4.15625 | 4 | from typing import List
def checksum_line(numbers_list: iter) -> int:
"""
Given a list of numbers, return the value of the maximum - minimum values
"""
min_number = max_number = numbers_list[0]
for number in numbers_list[1:]:
min_number = min(min_number, number)
max_number = max(ma... | true |
e6886af2f0373dea4fac1f974cfca7574bca353b | daniel-cretney/PythonProjects | /primality_functions.py | 481 | 4.4375 | 4 | # this file will take a number and report whether it is prime or not
def is_primary():
number = int(input("Insert a number.\n"))
if number <= 3:
return True
else:
divisor = 2
counter = 0
for i in range(number):
if number % divisor == 0:
... | true |
48ea70aaf45047d633f7469efd286ddcfb1a4ec3 | jamesjakeies/python-api-tesing | /python3.7quick/5polygon.py | 347 | 4.53125 | 5 | # polygon.py
# Draw regular polygons
from turtle import *
def polygon(n, length):
"""Draw n-sided polygon with given side length."""
for _ in range(n):
forward(length)
left(360/n)
def main():
"""Draw polygons with 3-9 sides."""
for n in range(3, 10):
polygon(n, 80)
... | true |
29362f4276d7ac83c520b89417bed94d2a771a4f | jamesjakeies/python-api-tesing | /python_crash_tutorial/Ch1/randomwalk.py | 352 | 4.25 | 4 | # randomwalk.py
# Draw path of a random walk.
from turtle import *
from random import randrange
def random_move(distance):
"""Take random step on a grid."""
left(randrange(0, 360, 90))
forward(distance)
def main():
speed(0)
while abs(xcor()) < 200 and abs(ycor()) < 200:
random_move(10... | true |
51578c97eb0b4a7478be114fa2eca98b713613ca | WillDutcher/Python_Essential_Training | /Chap05/bitwise.py | 674 | 4.375 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
# Completed Chap05: Lesson 21 - Bitwise operators
x = 0x0a
y = 0x02
z = x & y
# 02x gives two-character string, hexadecimal, with leading zero
# 0 = leading zero
# 2 = two characters wide
# x = hexadecimal display of integer value
# 08b gives eight-char... | true |
1ce0280f860821796f022583f2b5b96950f587b9 | WillDutcher/Python_Essential_Training | /Chap05/boolean.py | 670 | 4.1875 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
# Completed Chap05: Lesson 23 - Comparison operators
print("\nand\t\tAnd")
print("or\t\tOr")
print("not\t\tNot")
print("in\t\tValue in set")
print("not in\t\tValue not in set")
print("is\t\tSame object identity")
print("is not\t\tNot same object identity... | true |
9be5e6cad8942160830e3d4bcca8c66dcac52370 | Avinashgurugubelli/python_data_structures | /linked_lists/singly_linked_list/main.py | 2,546 | 4.46875 | 4 | from linked_list import LinkedList
from node import Node
# Code execution starts here
if __name__ == '__main__':
# Start with the empty list
linked_list_1 = LinkedList()
# region nodes creation
first_node, second_node, third_node = Node(), Node(), Node()
first_node.data = 5
second_node.data = 1... | true |
6413f86569da08a37374f72a6c330b1fd67ff02e | DayGitH/Python-Challenges | /DailyProgrammer/DP20170705B.py | 896 | 4.21875 | 4 | """
[2017-07-05] Challenge #322 [Intermediate] Largest Palindrome
https://www.reddit.com/r/dailyprogrammer/comments/6ldv3m/20170705_challenge_322_intermediate_largest/
# Description
Write a program that, given an integer input n, prints the largest integer that is a palindrome and has two factors
both of string lengt... | true |
9843b352194d21f8a67d7de52ba0b2c59c27bc2f | DayGitH/Python-Challenges | /DailyProgrammer/DP20160916C.py | 2,259 | 4.25 | 4 | """
[2016-09-16] Challenge #283 [Hard] Guarding the Coast
https://www.reddit.com/r/dailyprogrammer/comments/5320ey/20160916_challenge_283_hard_guarding_the_coast/
# Description
Imagine you're in charge of the coast guard for your island nation, but you're on a budget. You have to minimize how
many boats, helicopters ... | true |
78237d17e529cdd02fe42dd409c705b22e255eb8 | DayGitH/Python-Challenges | /DailyProgrammer/20120403B.py | 1,081 | 4.46875 | 4 | """
Imagine you are given a function flip() that returns a random bit (0 or 1 with equal probability). Write a program that
uses flip to generate a random number in the range 0...N-1 such that each of the N numbers is generated with equal
probability. For instance, if your program is run with N = 6, then it will genera... | true |
0b541c06a55954a41a1cf02de616696c28d9abf8 | DayGitH/Python-Challenges | /DailyProgrammer/DP20121023B.py | 1,571 | 4.1875 | 4 | """
[10/23/2012] Challenge #106 [Intermediate] (Jugs)
https://www.reddit.com/r/dailyprogrammer/comments/11xjfd/10232012_challenge_106_intermediate_jugs/
There exists a problem for which you must get exactly 4 gallons of liquid, using only a 3 gallon jug and a 5 gallon
jug. You must fill, empty, and/or transfer liquid... | true |
b268c2242ac7769abf8155f8299f3222452c706c | DayGitH/Python-Challenges | /DailyProgrammer/DP20120702A.py | 1,509 | 4.28125 | 4 | """
Before I get to today's problem, I'd just like to give a warm welcome to our two new moderators, nooodl and Steve132! We
decided to appoint two new moderators instead of just one, because rya11111 has decided to a bit of a break for a while.
I'd like to thank everyone who applied to be moderators, there were lots ... | true |
08e590ff030b1b2a50b3a0caadd086f4def3630c | DayGitH/Python-Challenges | /DailyProgrammer/20120611B.py | 2,005 | 4.40625 | 4 | """
You can use the reverse(N, A) procedure defined in today's easy problem [20120611A] to completely sort a list. For
instance, if we wanted to sort the list [2,5,4,3,1], you could execute the following series of reversals:
A = [2, 5, 4, 3, 1]
reverse(2, A) (A = [5, 2, 4, 3, 1])
reverse(5, A) (A = [1, 3,... | true |
8be851749005732519c82b72d3b7796187b59edc | DayGitH/Python-Challenges | /DailyProgrammer/DP20160408C.py | 2,212 | 4.15625 | 4 | """
[2016-04-08] Challenge #261 [Hard] magic square dominoes
https://www.reddit.com/r/dailyprogrammer/comments/4dwk7b/20160408_challenge_261_hard_magic_square_dominoes/
# Description
An NxN magic square is an NxN grid of the numbers 1 through N^2 such that each row, column, and major diagonal adds up
to M = N(N^(2)+1... | true |
0b0a585867ad3f4081fb6734d314797ad4dfe6e3 | DayGitH/Python-Challenges | /DailyProgrammer/20120310A.py | 363 | 4.1875 | 4 | """
Write a program that will compare two lists, and append any elements in the second list that doesn't exist in the first.
input: ["a","b","c",1,4,], ["a", "x", 34, "4"]
output: ["a", "b", "c",1,4,"x",34, "4"]
"""
inp1 = ["a","b","c",1,4,]
inp2 = ["a", "x", 34, "4"]
final = inp1[:]
for a in inp2:
if a not in f... | true |
cedde37647701d970cc14b091dd084966a18d480 | DayGitH/Python-Challenges | /DailyProgrammer/DP20120808A.py | 1,026 | 4.1875 | 4 | """
[8/8/2012] Challenge #86 [easy] (run-length encoding)
https://www.reddit.com/r/dailyprogrammer/comments/xxbbo/882012_challenge_86_easy_runlength_encoding/
Run-Length encoding is a simple form of compression that detects 'runs' of repeated instances of a symbol in a string
and compresses them to a list of pairs of... | true |
679d823627f1fc41e7027d234a4ae51b9ba3868d | DayGitH/Python-Challenges | /ProjectEuler/pr0019.py | 1,393 | 4.15625 | 4 | """
You are given the following information, but you may prefer to do some research for yourself.
* 1 Jan 1900 was a Monday.
* Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on le... | true |
dca128ba4183ba191a980e31fbe857280b70450f | DayGitH/Python-Challenges | /DailyProgrammer/20120331A.py | 502 | 4.125 | 4 | """
A very basic challenge:
In this challenge, the
input is are : 3 numbers as arguments
output: the sum of the squares of the two larger numbers.
Your task is to write the indicated challenge.
"""
"""
NOTE: This script requires three input arguments!!!
"""
import sys
arguments = len(sys.argv)
if arguments != 4:
... | true |
ff0d12abcd0f3b346d1da0bb9b0ac5aa0c25f473 | DayGitH/Python-Challenges | /DailyProgrammer/20120216C.py | 975 | 4.125 | 4 | '''
Write a program that will take coordinates, and tell you the corresponding number in pascals triangle. For example:
Input: 1, 1
output:1
input: 4, 2
output: 3
input: 1, 19
output: error/nonexistent/whatever
the format should be "line number, integer number"
for extra credit, add a function to simply print the trian... | true |
e468767ef3ec92629303e5c294e393f29ae6ee83 | DayGitH/Python-Challenges | /DailyProgrammer/20120218A.py | 906 | 4.34375 | 4 | '''
The exercise today asks you to validate a telephone number, as if written on an input form. Telephone numbers can be
written as ten digits, or with dashes, spaces, or dots between the three segments, or with the area code parenthesized;
both the area code and any white space between segments are optional.
Thus, al... | true |
f8ce35aa7a18e0b7a6febbd227e0b7a16f2fd832 | DayGitH/Python-Challenges | /DailyProgrammer/DP20120629B.py | 1,232 | 4.25 | 4 | """
Implement the hyperoperator [http://en.wikipedia.org/wiki/Hyperoperation#Definition] as a function hyper(n, a, b), for
non-negative integers n, a, b.
hyper(1, a, b) = a + b, hyper(2, a, b) = a * b, hyper(3, a, b) = a ^ b, etc.
Bonus points for efficient implementations.
thanks to noodl for the challenge at /... | true |
db322807d137276219ecaab479af539fe4088cb5 | DayGitH/Python-Challenges | /DailyProgrammer/DP20170619A.py | 1,147 | 4.125 | 4 | """
[2017-06-19] Challenge #320 [Easy] Spiral Ascension
https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/
# Description
The user enters a number. Make a spiral that begins with 1 and starts from the top left, going towards the right, and
ends with the square of tha... | true |
dea6624c859356ed196474cbb7f746f5d5b44dd8 | DayGitH/Python-Challenges | /DailyProgrammer/DP20120808C.py | 1,199 | 4.1875 | 4 | """
[8/8/2012] Challenge #86 [difficult] (2-SAT)
https://www.reddit.com/r/dailyprogrammer/comments/xx970/882012_challenge_86_difficult_2sat/
Boolean Satisfiability problems are problems where we wish to find solutions to boolean equations such as
(x_1 or not x_3) and (x_2 or x_3) and (x_1 or not x_2) = true
Thes... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.