blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
7956966c7aa9ffed8da7d23e75d98ae1867c376a | vlad-bezden/py.checkio | /electronic_station/similar_triangles.py | 2,498 | 4.28125 | 4 | """Similar Triangles
https://py.checkio.org/en/mission/similar-triangles/
This is a mission to check the similarity of two triangles.
You are given two lists as coordinates of vertices of each triangle.
You have to return a bool. (The triangles are similar or not)
Example:
similar_triangles... | true |
d880c75abc5b1980a6e0bd5b2435c647963a08d1 | vlad-bezden/py.checkio | /oreilly/median_of_three.py | 1,986 | 4.125 | 4 | """Median of Three
https://py.checkio.org/en/mission/median-of-three/
Given an List of ints, create and return a new List
whose first two elements are the same as in items,
after which each element equals the median of the three elements
in the original list ending in that position.
Input: Li... | true |
d8803c10cf12c5afb6898dd2c5cce4e7be0adeed | vlad-bezden/py.checkio | /oreilly/chunk.py | 1,083 | 4.4375 | 4 | """Chunk.
https://py.checkio.org/en/mission/chunk/
You have a lot of work to do, so you might want to split it into smaller pieces.
This way you'll know which piece you'll do on Monday,
which will be for Tuesday and so on.
Split a list into smaller lists of the same size (chunks).
The last ch... | true |
a1241876f32a8cbcfa522b6393ae8ba20837549b | vlad-bezden/py.checkio | /elementary/split_list.py | 885 | 4.375 | 4 | """Split List
https://py.checkio.org/en/mission/split-list/
You have to split a given array into two arrays.
If it has an odd amount of elements,
then the first array should have more elements.
If it has no elements, then two empty arrays should be returned.
example
Input: Array.
Ou... | true |
93b69fd2a07e076c8d968d862e19bb1831aa6aab | vlad-bezden/py.checkio | /mine/skew-symmetric_matrix.py | 2,305 | 4.1875 | 4 | """Skew-symmetric Matrix
https://py.checkio.org/en/mission/skew-symmetric-matrix/
In mathematics, particularly in linear algebra, a skew-symmetric matrix
(also known as an antisymmetric or antimetric) is a square matrix A
which is transposed and negative. This means that it satisfies the
equation ... | true |
b1dee53024fb0e1420d3d3443eb26f6f2c949bf1 | linkel/MITx-6.00.1x-2018 | /Week 1 and 2/alphacount2.py | 1,218 | 4.125 | 4 | s = 'kpreasymrrs'
longest = s[0]
longestholder = s[0]
#go through the numbers of the range from the second letter to the end
for i in (range(1, len(s))):
#if this letter is bigger or equal to the last letter in longest variable then add it on (meaning alphabetical order)
if s[i] >= longest[-1]:
longest ... | true |
fc17ad2770c01b01220527948074999663a5cb0e | amir-mersad/ICS3U-Unit5-01-Python | /function.py | 885 | 4.46875 | 4 | #!/usr/bin/env python3
# Created by: Amir Mersad
# Created on: November 2019
# This program converts temperature in degrees Celsius
# to temperature degrees Fahrenheit
def celsius_to_fahrenheit():
# This program converts temperature in degrees Celsius
# to temperature degrees Fahrenheit
# Input
ce... | true |
a642a315921776c3d5920bd3e9f649a888462773 | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Standard_Library/Built-in Functions/l-n/list_test.py | 2,003 | 4.46875 | 4 | """class list([iterable])"""
# https://www.programiz.com/python-programming/methods/built-in/list
"""Rather than being a function, list is actually a mutable sequence type, as documented in Lists
and Sequence Types — list, tuple, range.
The list() constructor creates a list in Python.
Python list() constructor takes ... | true |
3ec93bc3e2bbb8ec2f59a612ac2ad112aa1f4930 | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Language_Reference/6. Expressions/6.2. Atoms/6.2.8. Generator expressions/example.py | 230 | 4.25 | 4 | # A generator expression is a compact generator notation in parentheses.
# A generator expression yields a new generator object.
a = (x**2 for x in range(6))
print(f"a: {a}")
print(f"type(a): {type(a)}")
for i in a:
print(i)
| true |
d866a29053b2e57c7dacf0d44ebaa0078138305a | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Standard_Library/Built-in Functions/a-b/all__test.py | 1,808 | 4.25 | 4 | """all(iterable)"""
# https://www.programiz.com/python-programming/methods/built-in/all
"""Return True if all elements of the iterable are true (or if the iterable is empty). Equivalent to:"""
def all_func(iterable):
for element in iterable:
if not element:
return False
return True
def m... | true |
5315e68a06067a3ab9a99178ab86ce613dc163fb | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Standard_Library/Built-in Functions/c-d/divmod__test.py | 816 | 4.21875 | 4 | """divmod(a, b)"""
# https://www.programiz.com/python-programming/methods/built-in/divmod
"""Take two (non complex) numbers as arguments and return a pair of numbers consisting
of their quotient and remainder when using integer division.
With mixed operand types, the rules for binary arithmetic operators apply.
For in... | true |
f312b493d986a88f5f05e4ef2c0db055aa8a8c8d | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Standard_Library/Built-in Functions/l-n/min_test.py | 2,432 | 4.25 | 4 | """min(iterable, *[, key, default])
min(arg1, arg2, *args[, key])"""
# https://www.programiz.com/python-programming/methods/built-in/min
"""Return the smallest item in an iterable or the smallest of two or more arguments.
If one positional argument is provided, it should be an iterable. The smallest item in the it... | true |
bf573e2b7eafe79adde1e52d40e21d5d393b043e | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Language_Reference/6. Expressions/6.2. Atoms/6.2.4. Displays for lists, sets and dictionaries/example.py | 218 | 4.125 | 4 | # The comprehension consists of a single expression followed by at least one for clause
# and zero or more for or if clauses.
a = [x**2 for x in range(11) if x % 2 == 0]
print(f"a: {a}")
print(f"type(a): {type(a)}")
| true |
e5de070bfe40a82008d8d9e6ed6986c618dc7043 | corridda/Studies | /Articles/Python/pythonetc/year_2018/october/python_etc_oct_23.py | 1,278 | 4.1875 | 4 | """https://t.me/pythonetc/230"""
"""You can modify the code behavior during unit tests not only by using mocks and other advanced techniques
but also with straightforward object modification:"""
import random
import unittest
from unittest import TestCase
# class Foo:
# def is_positive(self):
# return sel... | true |
beb99591beb990888eb58b3d949b3b44a21bcb2f | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Standard_Library/Built-in Functions/s-z/tuple_test.py | 724 | 4.40625 | 4 | """ tuple([iterable])
class type(object)
class type(name, bases, dict)"""
# https://www.programiz.com/python-programming/methods/built-in/tuple
"""Rather than being a function, tuple is actually an immutable sequence type, as documented
in Tuples and Sequence Types — list, tuple, range.
If an iterable is pass... | true |
8341587ff2d172282ab6b00a82ea56380f062e4f | corridda/Studies | /CS/Programming_Languages/Python/Python_Documentation/The_Python_Tutorial/Chapter 5. Data Structures/5.6. Looping Techniques/Looping Techniques.py | 1,713 | 4.15625 | 4 | import math
# looping through dictionaries -> items()
knights = {'gallahad': 'the pure', 'robin': 'the brave'}
for k,v in knights.items():
print(k, ':', v)
# looping through a sequence ->
# the position index and corresponding value can be retrieved at the same time using the enumerate() function.
for i, v in enu... | true |
6b3f8316bc32ae76e7975953ae2839bc47a0d317 | swyatik/Python-core-07-Vovk | /Task 4/2_number_string.py | 293 | 4.15625 | 4 | number = 1234
strNumber = str(number)
product = int(strNumber[0]) * int(strNumber[1]) * int(strNumber[2]) * int(strNumber[3])
reversNumber = int(strNumber[::-1])
print('Product of number %d is %15d' % (number, product))
print('Inverse number to number %d is %8d' % (number, reversNumber)) | true |
8aa5fbf8d58db8094e0dab793af65cab51b378e8 | aakinlalu/Mini-Python-Projects | /dow_csv/dow_csv_solution.py | 1,713 | 4.125 | 4 | """
Dow CSV
-------
The table in the file 'dow2008.csv' has records holding the
daily performance of the Dow Jones Industrial Average from the
beginning of 2008. The table has the following columns (separated by
commas).
DATE OPEN HIGH LOW CLOSE VOLUME ADJ_CLOSE
2008-01-02 13261.82 ... | true |
99728de2ec99c6e60ff42a3a7811f5268028031d | jhoover4/algorithms | /cracking_the_coding/chapter_1-Arrays/7_rotate_matrix.py | 2,120 | 4.40625 | 4 | import unittest
from typing import List
def rotate_matrix(matrix: List[List[int]]) -> List[List[int]]:
"""
Problem: Rotate an M x N matrix 90 degrees.
Answer:
Time complexity: O(MxN)
"""
if not matrix or not matrix[0]:
raise ValueError("Must supply valid M x N matrix.")
col_len... | true |
3708eda29bf47b6a2ab23eb56e8f95b9f88e4a5e | ChaitDevOps/Scripts | /PythonScripts/ad-lists.py | 1,018 | 4.5 | 4 | #!/usr/bin/python
# ad-lists.py
# Diving a little deeper into Lists.
#.append() Appends an element to the 'END' of the exisitng list.
from __future__ import print_function
l = [1,2,3]
l.append([4])
print(l)
#.extend() extends list by appending elements from the iterable
l = [4,5,6]
l.extend([7,8,9])
print(l)
# .in... | true |
85769cf60c277a432a21b44b95e3814d23511666 | ChaitDevOps/Scripts | /PythonScripts/lambda.py | 556 | 4.15625 | 4 | #!/usr/bin/python
# Lambda Expressions
# lambda.py
# Chaitanya Bingu
# Lamba expressions is basically a one line condensed version of a function.
# Writing a Square Function, we will break it down into a Lambda Expression.
def square(num):
result = num**2
print result
square(2)
def square(num):
print num... | true |
9f44f5d1b42a232efb349cd9a484b1eb0d68372f | ChaitDevOps/Scripts | /PythonScripts/advanced_strings.py | 2,053 | 4.4375 | 4 | #!/usr/bin/python
# Chait
# Advanced Strings in Python.
# advanced_strings.py
from __future__ import print_function
# .capitalize()
# Converts First Letter of String to Upper Case
s = "hello world"
print(s.capitalize())
# .upper() and .lower()
print(s.upper())
print(s.lower())
# .count() and .find()
# .count() -- W... | true |
bcc7ae5bdfe6d3a4f2b0433ca78c7c931a629519 | Pigiel/udemy-python-for-algorithms-data-structures-and-interviews | /Array Sequences/Array Sequences Interview Questions/Array Sequence Interview Questions/Sentence-Reversal.py | 1,431 | 4.21875 | 4 | #!/usr/bin/env python3
""" Solution """
def rev_word1(s):
return ' '.join(s.split()[::-1])
""" Practise """
def rev_word2(s):
return ' '.join(reversed(s.split()))
def rev_word3(s):
"""
Manually doing the splits on the spaces.
"""
words = []
length = len(s)
spaces = [' ']
# Index Tracker
i = 0
# While ind... | true |
19a3cc106f1dadaf621ef20dd79d62861ab01ac7 | Pigiel/udemy-python-for-algorithms-data-structures-and-interviews | /Sorting and Searching/01_Binary_Search.py | 754 | 4.25 | 4 | #!/usr/bin/env python3
def binary_search(arr, element):
# First & last index value
first = 0
last = len(arr) - 1
found = False
while first <= last and not found:
mid = (first + last) // 2 # // required for Python3 to get the floor
# Match found
if arr[mid] == element:
found = True
# set new midp... | true |
78993e5a2442e7947655a263788fbf83a9c50c0d | kartik-mewara/pyhton-programs | /Python/25_sets_methods.py | 672 | 4.4375 | 4 | s={1,2,3,4,5,6}
print(s)
print(type(s))
s1={}
print(type(s1)) #this will result in type of dict so for making empty set we follow given method
s1=set()
print(type(s1))
s1.add(10)
s1.add(20)
print(s1)
s1.add((1,2,3))
# s1.add([1,2,3]) this will throws an erros as we can only add types which are hashable of unmutable as ... | true |
51fe08037ca0d96b83b0dadded63411c1791aecd | kartik-mewara/pyhton-programs | /Python/05_typecasting.py | 593 | 4.125 | 4 | # a="1234"
# a+=5
# print(a) this will not work as a is a string but we expect ans 1239so for that we will type cast a which is string into int
a="1234"
print(type(a))
a=int(a)
a+=5
print(type(a))
print(a)
# now it will work fine
# similerly we can type cast string to int to string int to float float to in etc
b=2.3... | true |
332bb7e70a8168e8194a995f6eca4b1983997400 | kartik-mewara/pyhton-programs | /Python/13_string_template.py | 255 | 4.34375 | 4 | letter='''Dear <|name|>
you are selected on the date
Date: <|date|> '''
name=input("Enter name of person\n")
date=input("Enter date of joining\n")
# print(letter)
letter=letter.replace("<|name|>",name)
letter=letter.replace("<|date|>",date)
print(letter) | true |
fd6f4950b4fdd76631619868f22938333061c7e3 | kheraankit/coursera | /interactive_python_rice/rock_paper_scissors_lizard_spock.py | 2,975 | 4.28125 | 4 |
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
import random
# helper functions
def number_to_name(number):
"""
This function accepts a 'number' as a key and
... | true |
2b6117afba9745fddf4f5622132b528848badc9a | bellajcord/Python-practice | /controlflow.py | 2,822 | 4.4375 | 4 | # Logical operators
# and
(1 > 2) and (2 < 3)
# multiple
(1 == 2) or (2 == 3) or (4 == 4)
##################################
### if,elif, else Statements #####
##################################
# Indentation is extremely important in Python and is basically Python's way of
# getting rid of enclosing brackets like... | true |
0352bb392701674291b3c5d2ce0af52a5834e9d4 | NathanontGamer/Multiplication-Table | /multiplication table.py | 894 | 4.46875 | 4 | #define function called multiplication table
def muliplication_table ():
#input number and number of row
number = int(input("Enter column / main number: "))
number_row = int(input("Enter row / number that (has / have) to times: "))
#for loop with range number_row
for i in range (1, number_ro... | true |
01d46d24b6c692f85aec4efcba110013b0b0a579 | suraj13mj/Python-Practice-Programs | /10. Python 31-01-20 --- Lists/Program5.py | 218 | 4.21875 | 4 | #Program to sort a 2D List
lst=[[25,13],[18,2],[19,36],[17,3]]
def sortby(element): #sorts based on column 2
return(element[1])
print("Before Sorting:",lst)
lst.sort(key=sortby)
print("After Sorting:",lst) | true |
706558592b4863c72ef112dfc3ab98588d5f796b | suraj13mj/Python-Practice-Programs | /32. Python 06-03-20 --- File Handling/Program1.py | 1,247 | 4.34375 | 4 | #Program to demonstrate basic file operations in Python
def createFile(filename):
fh=open(filename,"w")
print("Enter File contents:")
print("Enter '#' to exit")
while True:
line=input()
if line=="#":
break
fh.write(line+"\n")
fh.close()
def appendData(filename):
fh=open(filename,"a")
print("Enter ... | true |
30342271877f7edcf5c7b66362c5955599dee4f7 | suraj13mj/Python-Practice-Programs | /38. Python 15-04-20 --- NumPy/Program2.py | 498 | 4.125 | 4 | # Program to read a m x n matrix and find the sum of each row and each column
import numpy as np
print("Enter the order of the Matrix:")
r = int(input())
c = int(input())
arr = np.zeros((r,c),dtype=np.int8)
print("Enter matrix of order "+str(r)+"x"+str(c))
for i in range(r):
for j in range(c):
arr[i,j] = int(inp... | true |
cc88f1c06b6491398275065144285e7ab8e033ca | Mhtag/python | /oops/10public_protected_pprivate.py | 862 | 4.125 | 4 | class Employee:
holidays = 10 # Creating a class variables.
var = 10
_protec = 9 # Protected variables can be used by classes and sub classes.
__private = 7 # Private Variables can be used by only this class.
def __init__(self, name, salary, role):
self.name = name
... | true |
1236969d33c8c56768f35f63367e8fd54db295ab | BALAVIGNESHDOSTRIX/py-coding-legendary | /Advanced/combin.py | 473 | 4.1875 | 4 | '''
Create a function that takes a variable number of arguments, each argument representing the number of items in a group, and returns the number of permutations (combinations) of items that you could get by taking one item from each group.
Examples:
combinations(2, 3) ➞ 6
combinations(3, 7,... | true |
7c2acffba62cb6408f085fb2bf233c1ac2714c64 | jotawarsd/Shaun_PPS-2 | /assignments_sem1/assign6.py | 375 | 4.3125 | 4 | '''
Assignment No: 6
To accept a number from user and print digits of number in a reverse order using function.
'''
num1 = input("number : ") #get input from user
def reverse(s1):
n = len(s1) - 1 #establish index of last digit
for i in range(n,-1,-1): #printing the number in reverse
print(s1[i]... | true |
b97639963d80069a0c86b5eac5b58cae944877fd | guohuacao/Introduction-Interactive-Programming-Python | /week2-Guess-The-Number.py | 2,559 | 4.21875 | 4 | # "Guess the number" mini-project
# This code runs under http://www.codeskulptor.org/ with python 2.7
#mini-project description:
#Two player game, one person thinks of a secret number, the other peson trys to guess
#In this program, it will be user try to guess at input field, program try to decide
#"higher", "lower"... | true |
e33f71ec867753fa1a5029f0891fad03c9fce52b | sachinsaxena021988/Assignment7 | /MovingAvarage.py | 599 | 4.15625 | 4 | #import numpy module
import numpy as np
#define array to for input value
x=np.array([3, 5, 7, 2, 8, 10, 11, 65, 72, 81, 99, 100, 150])
#define k as number of column
k=3
#define mean array to add the mean
meanarray =[]
#define range to loop through numpy array
for i in range(len(x)-k+1):
#in... | true |
4fa2954258c033bc635614a03bde2f888e9e360f | Veraxvis/PRG105 | /5.2/derp.py | 726 | 4.1875 | 4 | def main():
costs = monthly()
print("You spend", '$' + "{:,.2f}".format(costs) + " on your car per month.")
per_year = yearly(costs)
print("In total you spend", '$' + "{:,.2f}".format(per_year) + " on your car per year.")
def monthly():
car_payment = float(input("Please enter your monthly car paym... | true |
7a23e70d9095909a575ebcad73b29b016b8f4da0 | miklo88/cs-algorithms | /single_number/single_number.py | 1,612 | 4.125 | 4 | '''
Input: a List of integers where every int except one shows up twice
Returns: an integer
'''
'''
UPER UPER TIME
so this function takes in a list of ints. aka a list[1,2,3,4,5,6]
of nums where every int shows up twice except one so like list[1,1,2,2,3,4,4,5,5,6,6]
so i need to return the int that is only listed once... | true |
235df1baba7c9ffe9222dfee29da356e2a1762fa | timlax/PythonSnippets | /Create Class v2.py | 1,369 | 4.21875 | 4 |
class Animal(object):
"""All animals"""
alive = ""
# Define the initialisation function to define the self attributes (mandatory in a class creation)
def __init__(self, name, age):
# Each animal will have a name and an age
self.name = name
self.age = age
# The description... | true |
c9894657052e2db7a9bafdf51ae0f63fe25258bb | mikkope123/ot-harjoitustyo | /src/city/city.py | 1,752 | 4.5 | 4 | import math
class City:
"""A class representing a city on the salesman's route.':
Attributes:
x1, x2: cartesian coordinates representing the location of the city on the map
"""
def __init__(self, x1: float, x2: float):
"""Class constructor that creates a new city
Args:
... | true |
dff9d0f6b9dca11422d9d97ff54352aca8e6eacf | Faranaz08/assignment_3 | /que13.py | 600 | 4.1875 | 4 | #write a py program accept N numbers from the user and find the sum of even numbers
#product of odd numbers in enterd in a list
lst=[]
even=[]
odd=[]
sum=0
prod=1
N=int(input("enter the N number:"))
for i in range(0,N):
ele = int(input())
lst.append(ele)
if ele%2==0:
even.append(ele)
... | true |
2b783a4762657b56447de189929a210aa8e69bac | exclusivedollar/Team_5_analyse | /Chuene_Function_3.py | 724 | 4.28125 | 4 | ### START FUNCTION
"""This function takes as input a list of these datetime strings,
each string formatted as 'yyyy-mm-dd hh:mm:ss'
and returns only the date in 'yyyy-mm-dd' format.
input:
list of datetime strings as 'yyyy-mm-dd hh:mm:ss'
Returns:
returns a list of strings where each element in
the returned... | true |
987de188f535849170f5d44dafef82c543ad1bb6 | sstagg/bch5884 | /20nov05/exceptionexample.py | 237 | 4.125 | 4 | #!/usr/bin/env python3
numbers=0
avg=0
while True:
inp=input("Please give me a number or the word 'Done': ")
if inp=="Done":
break
else:
x=float(inp)
avg+=x
numbers+=1
avg=avg/numbers
print ("The average is %.2f" % (avg)) | true |
cee079505a684ef5a58041492ed437eba43572b5 | JayAgrawalgit/LearnPython | /1. Learn the Basics/1.9 Functions/1. What are Functions.py | 1,282 | 4.5625 | 5 | # Functions are a convenient way to divide your code into useful blocks,
# allowing us to order our code, make it more readable, reuse it and save some time.
# Also functions are a key way to define interfaces so programmers can share their code.
# How do you write functions in Python?
# As we have seen on previous tu... | true |
a10abea0005837374d7908ed655aa4fddfe87e61 | JayAgrawalgit/LearnPython | /1. Learn the Basics/1.2 Variables and Types/1. Numbers.py | 628 | 4.4375 | 4 | # Python supports two types of numbers - integers and floating point numbers. (It also supports complex numbers, which
# will not be explained in this tutorial).
# To define an integer, use the following syntax:
myint = 7
print("Integer Value printed:",myint)
# To define a floating point number, you may use one of th... | true |
55d49ce7240c7af9c27430d134507103cc6739c7 | JayAgrawalgit/LearnPython | /1. Learn the Basics/1.11 Dictionaries/1. Basics.py | 688 | 4.15625 | 4 | # A dictionary is a data type similar to arrays, but works with keys and values instead of indexes.
# Each value stored in a dictionary can be accessed using a key,
# which is any type of object (a string, a number, a list, etc.) instead of using its index to address it.
# For example, a database of phone numbers could... | true |
a9ad5d63cd98a178b4efdf2343c9e4f083d42a24 | uc-woldyemm/it3038c-scripts | /Labs/Lab5.PY | 486 | 4.15625 | 4 | print("Hello Nani keep doing your great work")
print("I know you're busy but is it okay if i can get some information about you")
print("How many years old are you?")
birthyear = int(input("year: "))
print("What day you born")
birthdate = int(input("date: "))
print("Can you also tell me what month you were born")
bir... | true |
235bd7c02a7555c8d059e401b18bf9bb4c6ee2dc | PranilDahal/SortingAlgorithmFrenzy | /BubbleSort.py | 854 | 4.375 | 4 | # Python code for Bubble Sort
def BubbleSort(array):
# Highest we can go in the array
maxPosition = len(array) - 1
# Iterate through the array
for x in range(maxPosition):
# For every iteration, we get ONE sorted element.
# After x iterations, we have x sorted elements
# We don't swap on the... | true |
7a5ecb354bfdd283896bcbfdb5b177bd53b90b15 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Strings/WildCardMatching.py | 1,442 | 4.40625 | 4 |
"""
String matching where one string contains wildcard characters
Given two strings where first string may contain wild card characters and second string is a normal string.
Write a function that returns true if the two strings match. The following are allowed wild card characters
in first string.
* --> Matches wit... | true |
38333c31be9bf385cbc0ad0f612ce39907f30648 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/LinkedList/MoveLastToFirst.py | 787 | 4.46875 | 4 | from GeeksForGeeks.LinkedList.SinglyLinkedList import LinkedList
"""
Move last element to front of a given Linked List
Write a C function that moves last element to front in a given Singly Linked List. For example, if the given Linked
List is 1->2->3->4->5, then the function should change the list to 5->1->2->3->4.
""... | true |
b5a1b48719e01685184f6546f5bac08e7804502e | vidyasagarr7/DataStructures-Algos | /Cormen/2.3-5.py | 761 | 4.125 | 4 |
def binary_search(input_list,key):
"""
Binary search algorithm for finding if an element exists in a sorted list.
Time Complexity : O(ln(n))
:param input_list: sorted list of numbers
:param key: key to be searched for
:return:
"""
if len(input_list) is 0:
return False
else ... | true |
f0420e011a39072b2edd46884b9bcdb1ede1270b | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Arrays/CheckConsecutive.py | 1,492 | 4.125 | 4 | import sys
"""
Check if array elements are consecutive | Added Method 3
Given an unsorted array of numbers, write a function that returns true if array consists of consecutive numbers.
Examples:
a) If array is {5, 2, 3, 1, 4}, then the function should return true because the array has consecutive numbers
from 1 to 5... | true |
7eefbcb7099c14384b4046d2cfcece1fba35a473 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Strings/InsertSpaceAndPrint.py | 916 | 4.15625 | 4 |
"""
Print all possible strings that can be made by placing spaces
Given a string you need to print all possible strings that can be made by placing spaces (zero or one) in between them.
Input: str[] = "ABC"
Output: ABC
AB C
A BC
A B C
"""
def toString(List):
s = []
for x in List:
... | true |
dd9088ed2e952a61cbc2f117274edd650d4aae16 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/LinkedList/ReverseAlternateKnodes.py | 1,182 | 4.15625 | 4 | from GeeksForGeeks.LinkedList.SinglyLinkedList import LinkedList
"""
Reverse alternate K nodes in a Singly Linked List
Given a linked list, write a function to reverse every alternate k nodes (where k is an input to the function)
in an efficient way. Give the complexity of your algorithm.
Example:
Inputs: 1->2->3-... | true |
57e66fcfe37a98d3b167627e8d0451ad9f37f567 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Arrays/ConstantSumTriplet.py | 1,203 | 4.25 | 4 | """
Find a triplet that sum to a given value
Given an array and a value, find if there is a triplet in array whose sum is equal to the given value.
If there is such a triplet present in array, then print the triplet and return true. Else return false.
For example, if the given array is {12, 3, 4, 1, 6, 9} and given su... | true |
6356464fb2f5e1c1440e0a5af8c7bc2ab5188183 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Arrays/TwoRepeatingNumbers.py | 1,133 | 4.28125 | 4 |
"""
Find the two repeating elements in a given array
You are given an array of n+2 elements. All elements of the array are in range 1 to n.
And all elements occur once except two numbers which occur twice. Find the two repeating numbers.
For example, array = {4, 2, 4, 5, 2, 3, 1} and n = 5
The above array has n + ... | true |
ee861e0efdb6e5515dd24ad97b15d2fecefde994 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/LinkedList/NthElement.py | 877 | 4.125 | 4 | from GeeksForGeeks.LinkedList.SinglyLinkedList import LinkedList,Node
"""
Write a function to get Nth node in a Linked List
Write a GetNth() function that takes a linked list and an integer index and returns the data value stored in the node at that index position.
Example:
Input: 1->10->30->14, index = 2
Output:... | true |
c71547e58e1d6c3c5d5caade6d1091312a3d6f71 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Strings/PrintDistinctPermutations.py | 1,065 | 4.125 | 4 | """
Print all distinct permutations of a given string with duplicates
Given a string that may contain duplicates, write a function to print all permutations of given string
such that no permutation is repeated in output.
Examples:
Input: str[] = "AB"
Output: AB BA
Input: str[] = "AA"
Output: AA
Input: str[] = "... | true |
b5b4d136247ccd07ddc1da1a665775f36c1713a4 | vidyasagarr7/DataStructures-Algos | /Trees/SearchElement.py | 1,191 | 4.21875 | 4 | from Karumanchi.Trees import BinaryTree
from Karumanchi.Queue import Queue
def search_element(node,element):
"""
Algorithm for searching an element Recursively
:param node:
:param element:
:return:
"""
if not node:
return False
else:
if node.data == element:
... | true |
18858b1ec937e1850ab9ae06c83dc35d15d36c85 | vidyasagarr7/DataStructures-Algos | /609-Algos/Lab-2/BubbleSort.py | 513 | 4.28125 | 4 |
def bubble_sort(input_list):
"""
Bubble Sort algorithm to sort an unordered list of numbers
:param input_list: unsorted list of numbers
:return: sorted list
"""
for i in range(len(input_list)):
for j in range(len(input_list)-1-i):
if input_list[j]>input_list[j+1]:
... | true |
2f45a066f0b461b0992094cb8f515ce3f4dd2269 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Strings/ReverseWords.py | 420 | 4.4375 | 4 |
"""
Reverse words in a given string
Example: Let the input string be “i like this program very much”.
The function should change the string to “much very program this like i”
"""
def reverse_words(string):
words_list = string.split(' ')
words_list.reverse()
return ' '.join(words_list)
if __name__=='__m... | true |
e20c9d2168f9e5c23ef638185ae2e00adbb90dfa | vidyasagarr7/DataStructures-Algos | /Karumanchi/Searching/CheckDuplicates.py | 1,726 | 4.28125 | 4 |
from Karumanchi.Sorting import MergeSort
from Karumanchi.Sorting import CountingSort
def check_duplicates(input_list):
"""
O(n^2) algorithm to check for duplicates
:param input_list:
:return:
"""
for i in range(len(input_list)):
for j in range(i+1,len(input_list)):
if input... | true |
2ef19d4886644d077c1f53c97f7de400c7019540 | vidyasagarr7/DataStructures-Algos | /GeeksForGeeks/Arrays/Rearrange.py | 1,096 | 4.1875 | 4 |
"""
Rearrange an array so that arr[i] becomes arr[arr[i]] with O(1) extra space
Given an array arr[] of size n where every element is in range from 0 to n-1. Rearrange the given array so that
arr[i] becomes arr[arr[i]]. This should be done with O(1) extra space.
Examples:
Input: arr[] = {3, 2, 0, 1}
Output: arr[]... | true |
4b1793f6d8c391ad17ecdfabc74702886aa02ebc | vidyasagarr7/DataStructures-Algos | /Karumanchi/Selection/KthSmallest.py | 1,531 | 4.40625 | 4 | from Karumanchi.Sorting import QuickSort
def partition(list,start,end):
"""
Partition Algorithm to partition a list - selecting the end element as the pivot.
:param list:
:param start:
:param end:
:return:
"""
i=start-1
pivot = list[end]
for j in range(start,end):
if lis... | true |
0f1edc71a026eac62eb4b641c0bd9ede2a98bbee | imran9891/Python | /PyFunctionReturns.py | 882 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# <h3 align="center">Function Return</h3>
# In[ ]:
def sum1(num1, num2):
def another_func(n1,n2):
return n1 + n2
return another_func
def sum2(num1, num2):
def another_func2(n1,n2):
return n1 + n2
return another_func2(num1, num2)
print(sum1(10,... | true |
d7c4c21563a09c85d82d652626eb7f5230b9254d | khairooo/Learn-linear-regression-the-simplest-way | /linear regression.py | 1,829 | 4.4375 | 4 | # necessary packages
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error,r2_score
# generate random data-set
np.random.seed(0)
# generate 100 random numbers with 1d array
x = np.random.ran... | true |
efa056ec08f3358df04e1da1bdef6db73dec39c3 | chenlongjiu/python-test | /rotate_image.py | 936 | 4.25 | 4 | '''
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
'''
class Solution(object):
def rotate(self, matrix):
for row in xrange(len(matrix)):
for col in xrange(row,len(matrix)):
matrix[row][col], ma... | true |
4debf55c34b266031b2c68890e629717f6043d76 | geekysid/Python-Basics | /4. Dictionary/Dictionary Challenge Modified 2.py | 1,714 | 4.21875 | 4 | # Modify the program so that the exits is a dictionary rather than a list, with the keys being the numbers of the
# locations and the values being dictionaries holding the exits (as they do at present). No change should be needed
# to the actual code.
locations = {0: "You are sitting in front of a computer learning Py... | true |
e75b0ab18452e7da90b5f6c81bc317224eaf24f1 | jmshin111/alogrithm-test | /merge two sorted list.py | 1,746 | 4.15625 | 4 | # A single node of a singly linked list
import sys
import timeit
class Node:
# constructor
def __init__(self, data=None):
self.data = data
self.next = None
# A Linked List class with a single head node
class LinkedList:
def __init__(self):
self.head = None
self.end = None... | true |
439f8e77560fa42094e061ba7c4e1bd71956b8fd | mohdelfariz/distributed-parallel | /Lab5-Assignment3.py | 1,284 | 4.25 | 4 | # Answers for Assignment-3
# Importing mySQL connector
import mysql.connector
# Initialize database connection properties
db_connection = mysql.connector.connect(
host="localhost",
user="root",
passwd="",
database="my_first_db"
)
# Show newly created database (my_first_db should be on th... | true |
453d4cfd55465b4793848e9ba7935aff0592dde1 | gopikris83/gopi_projects | /GlobalVariables.py | 401 | 4.25 | 4 | # -------- Defining variables outside of the function (Using global variables) ----------------
x = "Awesome"
def myfunc():
print (" Python is "+x)
myfunc()
# ---------- Defining variables inside of the function (Using local variables) --------------------------
x = "Awesome"
def myfunc():
x... | true |
e65c2135625c668523ea865f75bc320b2cdab043 | gr8tech/pirple.thinkific.com | /Python/Homework3/main.py | 931 | 4.1875 | 4 | '''
Python Homework Assignment 3
Course: Python is Easy @ pirple
Author: Moosa
Email: gr8tech01@gmail.com
`If` statements; Comparison of numbers
'''
def number_match(num1, num2, num3):
'''
Functions checks if 2 or more of the given numbers are equal
Args:
num1, num2, num3
num1, num2, num3 can be an Integer or ... | true |
1582966887ebcfcec8a2ddb74e0823cb7b72c95e | Chethan64/PESU-IO-SUMMER | /coding_assignment_module1/5.py | 212 | 4.25 | 4 | st = input("Enter a string: ")
n = len(st)
flag = 0
for i in st:
if not i.isdigit():
flag = 1
if(flag):
print("The string is not numeric")
else:
print("The string is numeric")
| true |
b024cf8229c1ea31c1299d283b52375d0c11ec10 | Abdelmuttalib/Python-Practice-Challenges | /Birthday Cake Candles Challenge/birthDayCakeCandles.py | 815 | 4.15625 | 4 |
####### SOLUTION CODE ########
def birthdayCakeCandles(candles):
## initializing an integer to hold the value of the highest value
highest = 0
## count of highest to calculate how many the highest value is found in the array
count_of_highest = 0
## iterate over the array to determine the high... | true |
067c383afe1a81e2b864b2f8d274c2e7768ed190 | shreyashg027/Leetcode-Problem | /Data Structure/Stacks.py | 504 | 4.125 | 4 | class Stack:
def __init__(self):
self.stack = []
def push(self, data):
if data not in self.stack:
self.stack.append(data)
def peek(self):
return self.stack[len(self.stack)-1]
def remove(self):
if len(self.stack) <= 0:
return 'No element in the s... | true |
4bce5f49c82972c9e7dadd48794bcc545e25095b | miketwo/euler | /p7.py | 704 | 4.1875 | 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?
'''
from math import sqrt, ceil
def prime_generator():
yield 2
yield 3
num = 3
while True:
num += 2
if is_prime(num):
... | true |
9e84eeb486846d437d69a8d08c717240cbb462a5 | TejaswitaW/Advanced_Python_Concept | /RegEx12.py | 260 | 4.125 | 4 | #use of function fullmatch in regular expression
import re
s=input("Enter string to be matched")
m=re.fullmatch(s,"abc")
if(m!=None):
print("Complete match found for the string:",m.start(),m.end())
else:
print("No complete match found for the string")
| true |
d139c57f5add5f8be6008fad651ea3eca04e4c39 | TejaswitaW/Advanced_Python_Concept | /ExceptionElse.py | 385 | 4.15625 | 4 | #Exception with else block
#else block is executed only when there is no exception in try block
try:
print("I am try block,No exception occured")
except:
print("I am except block executed when there is exception in try block")
else:
print("I am else block,executed when there is no exception in try block")
f... | true |
1f4069a21af18b88a7ddf117162036d212f2135c | lfarnsworth/GIS_Python | /Coding_Challenges/Challenge2/2-List_Overlap.py | 1,133 | 4.375 | 4 | # 2. List overlap
# Using these lists:
#
# list_a = ['dog', 'cat', 'rabbit', 'hamster', 'gerbil']
# list_b = ['dog', 'hamster', 'snake']
# Determine which items are present in both lists.
# Determine which items do not overlap in the lists.
# #Determine which items overlap in the lists:
def intersection(list_a, list_b... | true |
f91c9dd7ea1c66a0a757d32dc00c3e1f0adef7e7 | udhayprakash/PythonMaterial | /python3/06_Collections/03_Sets/a_sets_usage.py | 1,219 | 4.40625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Purpose: Working with Sets
Properties of sets
- creating using {} or set()
- can't store duplicates
- sets are unordered
- can't be indexed
- Empty sets need to be represented using set()
- stores only immutable object - ... | true |
627c4ac2e040d41a4e005253e1dd7c20f9d5cf63 | udhayprakash/PythonMaterial | /python3/04_Exceptions/11_raising_exception.py | 1,248 | 4.28125 | 4 | #!/usr/bin/python3
"""
Purpose: Raising exceptions
"""
# raise
# RuntimeError: No active exception to reraise
# raise Exception()
# Exception
# raise Exception('This is an error')
# Exception: This is an error
# raise ValueError()
# ValueError
# raise TypeError()
# raise NameError('This is name error')
# NameErro... | true |
79eb6b4be07ee81b3a360a3fe2ab759947735a5e | udhayprakash/PythonMaterial | /python3/19_Concurrency_and_Parallel_Programming/02_multiprocessing/b1_process_pool.py | 1,587 | 4.40625 | 4 | """
Purpose: Multiprocessing with Pools
Pool method allows users to define the number of workers and
distribute all processes to available processors in a
First-In-First-Out schedule, handling process scheduling automatically.
Pool method is used to break a function into multiple small parts using
... | true |
6782bce539f905db7c05238f1b906edf054b5aeb | udhayprakash/PythonMaterial | /python3/19_Concurrency_and_Parallel_Programming/01_MultiThreading/a_function_based/f_custom_thread_class.py | 939 | 4.375 | 4 | #!/usr/bin/python
# Python multithreading example to print current date.
# 1. Define a subclass using Thread class.
# 2. Instantiate the subclass and trigger the thread.
import datetime
import threading
class myThread(threading.Thread):
def __init__(self, name, counter):
threading.Thread.__init__(self... | true |
2e7734c27ca1713f780710c935c2981fa7bc0577 | udhayprakash/PythonMaterial | /python3/09_Iterators_generators_coroutines/02_iterators/e_user_defined_iterators.py | 926 | 4.65625 | 5 | #!/usr/bin/python3
"""
Purpose: Iterators
- To get values from an iterator objects
1. Iterate over it
- for loop
- converting to other iterables
- list(), tuple(), set(), dict()
2. To apply next()
... | true |
37b606ca02ac4bfd4e53e038c0280ee660d3277c | udhayprakash/PythonMaterial | /python3/10_Modules/04a_os_module/display_tree_of_dirs.py | 637 | 4.125 | 4 | #!/usr/bin/python
"""
Purpose: To display the tree strcuture of directories only , till three levels
test
sub1
sub2
subsub1
"""
import os
import sys
MAX_DEPTH = 3 # levels
given_path = sys.exec_prefix # input('Enter the path:')
print(given_path)
def display_folders(_path, _depth):
if _depth !=... | true |
f99296176c5701a5fe9cbc10d37767fa91ab06f4 | udhayprakash/PythonMaterial | /python3/15_Regular_Expressions/d_re_search.py | 965 | 4.59375 | 5 | """
Purpose: Regular Expressions
Using re.match
- It helps to identify patterns at the starting of string
Using re.search
- It helps to identify patterns at the ANYWHERE of string
"""
import re
target_string = "Python Programming is good for health"
# search_string = "python"
for search_strin... | true |
5399535d50a3bc576a80fd1cd911b70a8891d6c6 | udhayprakash/PythonMaterial | /python3/10_Modules/03_argparse/b_calculator.py | 1,183 | 4.5 | 4 | #!/usr/bin/python
"""
Purpose: command-line calculator
"""
import argparse
def addition(n1, n2):
return n1 + n2
def subtraction(s1, s2):
return s1 - s2
def multiplication(m1, m2, m3):
return m1 * m2 * m3
# Step 1: created parser object
parser = argparse.ArgumentParser(description="Script to add two/... | true |
ef14eb6c7361331b6c3ba966a7a128a48d7b0b45 | udhayprakash/PythonMaterial | /python3/19_Concurrency_and_Parallel_Programming/01_MultiThreading/c_locks/b1a_class_based_solution.py | 760 | 4.21875 | 4 | """
Purpose: Class based implementation of
synchronization using locks
"""
from threading import Lock, Thread
from time import sleep
class Counter:
def __init__(self):
self.value = 0
self.lock = Lock()
def increase(self, by):
self.lock.acquire()
current_value = self.value... | true |
3259d55b1aa7a9a2112a9eafe5ef2234966e0adc | udhayprakash/PythonMaterial | /python3/13_OOP/b_MRO_inheritance/01_single_inheritance.py | 1,521 | 4.28125 | 4 | """
Purpose: Single Inheritance
Parent - child classes relation
Super - sub classes relation
NOTE: All child classes should make calls to the parent class
constructors
MRO - method resolution order
"""
class Account:
"""
Parent or super class
"""
def __init__(self):
self.balanc... | true |
b92994e333cf4ef258773b508a5107d81a1d321c | udhayprakash/PythonMaterial | /python3/13_OOP/a_OOP/11_static_n_class_methods.py | 1,243 | 4.28125 | 4 | #!/usr/bin/python
"""
Methods
1. Instance Methods
2. class Methods
3. static Methods
Default Decorators: @staticmethod, @classmethod, @property
"""
class MyClass:
my_var = "something" # class variable
def display(self, x):
print("executing instance method display(%s,%s)" % (self, x))
... | true |
23978697bff6a4c96fa402731c3a700a5ab6a6ab | udhayprakash/PythonMaterial | /python3/06_Collections/02_Tuples/04_immutability.py | 471 | 4.3125 | 4 | #!/usr/bin/python3
"""
Purpose: Tuples are immutable
- They doesnt support in-object changes
"""
mytuple = (1, 2, 3)
print("mytuple", mytuple, id(mytuple))
# Indexing
print(f"{mytuple[2] =}")
# updating an element in tuple
try:
mytuple[2] = "2.2222"
except TypeError as ex:
print(ex)
print("t... | true |
c81f107aece79ddbbddbe4b9185f3dd2ab40f8a7 | udhayprakash/PythonMaterial | /python3/14_Code_Quality/00_static_code_analyses/e_ast_module.py | 1,820 | 4.15625 | 4 | #!/usr/bin/python
"""
Purpose: AST(Abstract Syntax Tree) Module
Usage
- Making IDEs intelligent and making a feature everyone knows as intellisense.
- Tools like Pylint uses ASTs to perform static code analysis
- Custom Python interpreters
- Modes of Code Compilation
- exec: We ... | true |
52d5d2268407c434c4ca567c1cf52bc3d8c72783 | udhayprakash/PythonMaterial | /python3/03_Language_Components/09_Loops/i_loops.py | 916 | 4.28125 | 4 | #!/usr/bin/python3
"""
Purpose: Loops
break - breaks the complete loop
continue - skip the current loop
pass - will do nothing. it is like a todo
sys.exit - will exit the script execution
"""
import sys
i = 0
while i <= 7:
i += 1
print(i, end=" ")
print("\n importance of break")
i ... | true |
151a7dcf87ee5c6458eac386a5831f90dcc746a3 | udhayprakash/PythonMaterial | /python3/15_Regular_Expressions/a_re_match.py | 734 | 4.5 | 4 | """
Purpose: Regular Expressions
Using re.match
- It helps to identify patterns at the starting of string
- By default, it is case-sensitive
"""
import re
# print(dir(re))
target_string = "Python Programming is good for health"
search_string = "python"
print(f"{target_string.find(search_string) =... | true |
696622f014f6ab152e691c301c2ae66a054aa1c9 | udhayprakash/PythonMaterial | /python3/07_Functions/032_currying_functions.py | 1,944 | 5.03125 | 5 | #!/usr/bin/python3
"""
Purpose: Currying Functions
- Inner functions are functions defined inside another function that can be used for various purposes, while
currying is a technique that transforms a function that takes multiple arguments into a sequence of functions that each take a single argument.
-... | true |
713d449e4646683292f37d3e16792f2eaa58052d | udhayprakash/PythonMaterial | /python3/11_File_Operations/01_unstructured_file/i_reading_large_file.py | 757 | 4.1875 | 4 | #!/usr/bin/python3
"""
Purpose: To read large file
"""
from functools import partial
def read_from_file(file_name):
"""Method 1 - reading one line per iteration"""
with open(file_name, "r") as fp:
yield fp.readline()
def read_from_file2(file_name, block_size=1024 * 8):
"""Method 2 - reading bloc... | true |
208da5282d2ac39f6a51343025bd78f422d2441b | alecbw/Learning-Projects | /Bank Account.py | 1,147 | 4.34375 | 4 | """ This code does the following things
Top level: creates and manipulates a personal bank account
* accepts deposits
* allows withdrawals
* displays the balance
* displays the details of the account """
class BankAccount(object):
balance = 0
def __init__(self, name):
self.name = name
def __repr__(self... | true |
13408db5de2e32cd359d691ac80ad724b2495253 | TaiPham25/PhamPhuTai---Fundamentals---C4E16 | /Session04/clera.py | 742 | 4.15625 | 4 |
print ('Guess your number game')
print ('Now think of a number from 0 to 100, then press " Enter"')
input()
print("""
All you have to do is to asnwer to my guess
'c' if my guess is 'C'orrect
'l' if my guess is 'L'arge than your number
's' if my guess is 'S'mall than your number
""")
#string formatting
from random imp... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.