blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
53c4afdf08f7e0ec27d981d51a6db6c7b280da3d | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/web-dev-notes-resource-site/2-content/Data-Structures/1-Python/dfs/maze_search.py | 1,105 | 4.3125 | 4 | """
Find shortest path from top left column to the right lowest column using DFS.
only step on the columns whose value is 1
if there is no path, it returns -1
(The first column(top left column) is not included in the answer.)
Ex 1)
If maze is
[[1,0,1,1,1,1],
[1,0,1,0,1,0],
[1,0,1,0,1,1],
[1,1,1,0,1,1]],
the answer ... | true |
f611a878a16540a8544d96b179da3dbe91d2edf7 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_Another-One/Project Euler/Problem 04/sol1.py | 872 | 4.1875 | 4 | """
Problem:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
"""
from __future__ import print_function
limit = int(input("limit? "))
# fe... | true |
43815ab10b7af65236aff86fec476d95b2231dc7 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/web-dev-notes-resource-site/2-content/ciriculumn/week-17/python/Introduction-Programming-Python/Solutions/Module7TaxesChallengeSolution.py | 1,675 | 4.3125 | 4 | # Declare and initialize your variables
country = ""
province = ""
orderTotal = 0
totalWithTax = 0
# I am declaring variables to hold the tax values used in the calculations
# That way if a tax rate changes, I only have to change it in one place instead
# of searching through my code to see where I had a specific nume... | true |
31f32bc2b4e184cccc98e3a1e08f707a7d3b4138 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/PYTHON_PRAC/python-mega-algo/bit_manipulation/count_number_of_one_bits.py | 755 | 4.1875 | 4 | def get_set_bits_count(number: int) -> int:
"""
Count the number of set bits in a 32 bit integer
>>> get_set_bits_count(25)
3
>>> get_set_bits_count(37)
3
>>> get_set_bits_count(21)
3
>>> get_set_bits_count(58)
4
>>> get_set_bits_count(0)
0
>>> get_set_bits_count(256)... | true |
a3845d1c4997ab5729ac3d57d09b96bc3636a5be | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/Beginners-Python-Examples-master/algorithms/analysis/count.py | 877 | 4.28125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Simple algorithm to count
# number of occurrences of (n) in (ar)
# Sudo: Algorithm
# each time (n) is found in (ar)
# (count) varible in incremented (by 1)
# I've put spaces to separate different
# stages of algorithms for easy understanding
# however isn't a good practi... | true |
acdb65d6e812f3f98073ac68414d41fec6da9136 | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/WEEKS/wk17/d2/code-signal/return-index-of-string-in-list.py | 894 | 4.375 | 4 | # Write a function that searches a list of names(unsorted) for the name "Bob" and returns the location in the list. If Bob is not in the array, return -1.
#
# Examples:
#
# csWhereIsBob(["Jimmy", "Layla", "Bob"]) β 2
# csWhereIsBob(["Bob", "Layla", "Kaitlyn", "Patricia"]) β 0
# csWhereIsBob(["Jimmy", "Layla", "James"])... | true |
9016bf310d2a3796cf746f8dce4bdf3eca7ff56f | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Sorting/Quick Sort/quick_sort.py | 2,006 | 4.21875 | 4 | # Program to implement QuickSort Algorithm in Python
"""
This function takes last element as pivot, places the pivot element at
its correct position in sorted array, and places all smaller(smaller than
pivot) to left of pivot and all greater elements to right of pivot
"""
def partition(arr, low, high):
"""
... | true |
d4c4ae8d85acbc6ee1e558adf68f81ee46e5e50f | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/leetcode/Queue_Using_Stack.py | 1,397 | 4.4375 | 4 | # Implement the following operations of a queue using stacks.
#
# push(x) -- Push element x to the back of queue.
# pop() -- Removes the element from in front of queue.
# peek() -- Get the front element.
# empty() -- Return whether the queue is empty.
# Example:
#
# MyQueue queue = new MyQueue();
#
# queue.push(1);
# q... | true |
5bbce313a69a231f379074df30877d764b26835f | bgoonz/UsefulResourceRepo2.0 | /GIT-USERS/TOM-Lambda/CSEUFLX_Algorithms_GP/00_demo.py | 239 | 4.1875 | 4 | import math
radius = 3
area = math.pi * radius * radius
<<<<<<< HEAD
print(f'The area of the circle is {area:.3f} ft\u00b2')
=======
print(f"The area of the circle is {area:.3f} ft\u00b2")
>>>>>>> 23fb4d348bb9c7b7b370cb2afcd785793e3816ea
| true |
f920a8d5c1a3bbcb5fb2de8de1f6fc16268a2966 | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/course-work/cs-guided-project-python-i/src/demonstration_01.py | 348 | 4.21875 | 4 | """
Challenge #1:
Create a function that takes two numbers as arguments and return their sum.
Examples:
- addition(3, 2) β 5
- addition(-3, -6) β -9
- addition(7, 3) β 10
"""
def addition(a, b):
# Your code here
print("i am inside the function")
return a + b
print("this lives outside the function")
pr... | true |
737a88c7ed53a9bcc2ce17afb8abf4ab5a1c8ba4 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Sorting/Shell Sort/shell_sort.py | 1,601 | 4.15625 | 4 | # Python program for implementation of Shell Sort
"""
Shell sort is a highly efficient sorting algorithm and is based on insertion sort algorithm.
Shell sort is the generalization of insertion sort which overcomes the drawbacks of insertion sort by comparing elements separated by a gap of several positions.
Shell sor... | true |
5b8e3a233922c9dfe86b8d43004bdd9debfbbfb5 | bgoonz/UsefulResourceRepo2.0 | /_MY_ORGS/Web-Dev-Collaborative/blog-research/ciriculumn/week.16-/python-lecture/15a-input-validation1.py | 350 | 4.15625 | 4 | # Input Validation
# - prompt
# - handle empty string
# - make it a number
# - handle exceptions
# - require valid input
age = 1
while age:
age = input("What's your age? ")
if age:
try:
age = int(float(age))
print(f'Cool! You had {age} birthdays.')
except:
pr... | true |
34ace4f7e6af7e263ba09ea7c1547a54b1dbd804 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/1-projects/lambda/LambdaSQL/LambdaSQL-master/LambdaSQL.py | 998 | 4.125 | 4 | import sqlite3 as sql
connection = sql.connect("rpg_db.sqlite3")
print(
*connection.execute(
"""
SELECT cc.name, ai.name
FROM charactercreator_character AS cc, armory_item AS ai,
charactercreator_character_inventory AS cci
WHERE cc.character_id = cci.character_id
AND ai.item_id = cci.item_id
LIMIT 10;
"""... | true |
04556c7505ff2a77185611cf43a9796df0fd2293 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/_External-learning-resources/_PYTHON/Python-master/factorial.py | 643 | 4.28125 | 4 | import math
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
n = int(input("Input a number to compute the factiorial : "))
print(factorial(n))
"""
Method 2:
Here we are going to use in-built fuction for factorial which is provided by Python for
user conveniance.
Step... | true |
f2d4fc82f7fda06b56265a8369998c0318b65c47 | bgoonz/UsefulResourceRepo2.0 | /_OVERFLOW/Resource-Store/01_Questions/_Python/enum.py | 507 | 4.28125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Enum function
# yields a tuple of element and it's index
def enum(ar):
for index in range(len(ar)):
yield ((index, ar[index]))
# Test
case_1 = [19, 17, 20, 23, 27, 15]
for tup in list(enum(case_1)):
print(tup)
# Enum function is a generator does not
# ret... | true |
e1707172df8425f34b1ff548061e6459fb73ae08 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/web-dev-notes-resource-site/2-content/Python/intro_programming-master/notebooks/rocket.py | 991 | 4.25 | 4 | from math import sqrt
class Rocket:
# Rocket simulates a rocket ship for a game,
# or a physics simulation.
def __init__(self, x=0, y=0):
# Each rocket has an (x,y) position.
self.x = x
self.y = y
def move_rocket(self, x_increment=0, y_increment=1):
# Move the rocket... | true |
e648a1d072498fa610f6de94960414ff7105d28e | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/BLOG/Data-Structures/1-Python/strings/validate_coordinates.py | 1,689 | 4.28125 | 4 | """"
Create a function that will validate if given parameters are valid geographical coordinates.
Valid coordinates look like the following: "23.32353342, -32.543534534". The return value should be either true or false.
Latitude (which is first float) can be between 0 and 90, positive or negative. Longitude (which is s... | true |
11e1edbecab930d3e1e4d95fe9fb83602849a167 | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/course-work/cs-guided-project-python-i/src/demonstration_09.py | 736 | 4.5 | 4 | """
Challenge #9:
Write a function that creates a dictionary with each (key, value) pair being
the (lower case, upper case) versions of a letter, respectively.
Examples:
- mapping(["p", "s"]) β { "p": "P", "s": "S" }
- mapping(["a", "b", "c"]) β { "a": "A", "b": "B", "c": "C" }
- mapping(["a", "v", "y", "z"]) β { "a"... | true |
755287b03fd2fc73be13ad660015e28a119e87ca | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/BLOG/Data-Structures/1-Python/maths/find_primitive_root_simple.py | 2,240 | 4.25 | 4 | import math
"""
For positive integer n and given integer a that satisfies gcd(a, n) = 1,
the order of a modulo n is the smallest positive integer k that satisfies
pow (a, k) % n = 1. In other words, (a^k) β‘ 1 (mod n).
Order of certain number may or may not be exist. If so, return -1.
"""
def find_order(a, n):
if... | true |
4b29471c64eb3d3005ba1b7484d0fb9bf72ee325 | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/course-work/Python-Brain-Teasers/hamming_weight.py | 1,004 | 4.28125 | 4 | """
Given an unsigned integer, write a function that returns the number of '1' bits
that the integer contains (the
[Hamming weight](https://en.wikipedia.org/wiki/Hamming_weight))
Examples:
- `hamming_weight(n = 00000000000000000000001000000011) -> 3`
- `hamming_weight(n = 00000000000000000000000000001000) -> 1`
- `ha... | true |
99d4b3a3a7bd6e1455cd7fed0e538cca41a634b1 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/_External-learning-resources/_PYTHON/Python-master/Guessing_Game.py | 1,523 | 4.15625 | 4 | from random import randint
from time import sleep
print("Hello Welcome To The Guess Game!")
sleep(1)
print("I'm Geek! What's Your Name?")
name = input()
sleep(1)
print(f"Okay {name} Let's Begin The Guessing Game!")
a = comGuess = randint(
0, 100
) # a and comGuess is initialised with a random number between 0 and... | true |
1fcc988f266d75b8a780b95ffa2bd64f6883aa8f | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/BLOG/ciriculumn/week-17/python/Introduction-Programming-Python/Solutions/Module4MortgageCalculatorChallengeSolution.py | 1,140 | 4.3125 | 4 | # Declare and initialize the variables
monthlyPayment = 0
loanAmount = 0
interestRate = 0
numberOfPayments = 0
loanDurationInYears = 0
# Ask the user for the values needed to calculate the monthly payments
strLoanAmount = input("How much money will you borrow? ")
strInterestRate = input("What is the interest rate on t... | true |
610a0d008ceef29a052a5cbac5629c90cb572906 | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/leetcode/Binary_tree Paths.py | 813 | 4.125 | 4 | # Given a binary tree, return all root-to-leaf paths.
#
# Note: A leaf is a node with no children.
#
# Example:
#
# Input:
#
# 1
# / \
# 2 3
# \
# 5
#
# Output: ["1->2->5", "1->3"]
#
# Explanation: All root-to-leaf paths are: 1->2->5, 1->3
class TreeNode:
def __init__(self, x):
self.val = x
... | true |
7ea462ab48138a58f7ec2fcc9621c9ff0123b91a | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Trees/Binary Tree To DLL/binary_tree_to_dll.py | 2,995 | 4.3125 | 4 | """
Binary trees are a type of data tree data structure in which a node can only have 0,1 or 2 children only.
Linked list is a type of linear data structure in which one object/node along with data, also contains the address of next object/node.
Doubly linked list is a type of linked list in which a node points to both... | true |
28b801fcac4ab98370601886f27c42a5609535f0 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Backtracking/Sudoku Solver/sudoku.py | 2,810 | 4.125 | 4 | def print_grid(arr):
for i in range(9):
for j in range(9):
print(arr[i][j], end=" "),
print()
# Function to Find the entry in the Grid that is still not used
def find_empty_location(arr, l):
for row in range(9):
for col in range(9):
if arr[row][col] == 0:
... | true |
61cceb2f1eb17b506be7da7bd67c2f8404a6b4ce | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/leetcode/Subtree_of_another_Tree.py | 1,208 | 4.15625 | 4 | # Given two non-empty binary trees s and t, check whether tree t has exactly the same structure
# and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all
# of this node's descendants. The tree s could also be considered as a subtree of itself.
#
# Example 1:
# Given tree s:
#
# ... | true |
de89caf4b942e789f946e8fb69bb933bdb883f9c | bgoonz/UsefulResourceRepo2.0 | /_Job-Search/InterviewPractice-master/InterviewPractice-master/Python/capsLock.py | 517 | 4.15625 | 4 | # Complete the pressAForCapsLock function below.
def pressAForCapsLock(message):
letters = []
found = False
for i in message:
if i is "a" or i is "A":
found = not found
continue
if found is True:
letters.append(i.upper())
else:
lett... | true |
1d52e5100932c35be77dca0eedf505cf6bc6fdae | bgoonz/UsefulResourceRepo2.0 | /_RESOURCES/my-gists/MAIN_GIST_FOLDER/76acedd4d2/76acedd4d2c1d58a424e1fe33a9aa011af6c62d3908fdeee020629a38a6f599f/08-LongestSemiAlternatingSubString.py | 1,861 | 4.28125 | 4 | # You are given a string s of length n containing only characters a and b.
# A substring of s called a semi-alternating substring if it does not
# contain three identical consecutive characters.
# Return the length of the longest semi-alternating substring.
# Example 1: Input: "baaabbabbb" | Output: 7
# Explanati... | true |
446eded13c97935e5b53597b35ec1118e0a4df91 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/my-gists/ARCHIVE/by-extension/python/merge_sort.py | 1,728 | 4.21875 | 4 | import timeit
from random import randint
def merge_sort(collection, length, counter):
if len(collection) > 1:
middle_position = len(collection) // 2
left = collection[:middle_position]
right = collection[middle_position:]
counter = merge_sort(left, length, counter)
counter ... | true |
891e45259cac6b0f22ac6d993dfb527569b2931b | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/PYTHON_PRAC/learn-python/src/control_flow/test_while.py | 960 | 4.53125 | 5 | """WHILE statement
@see: https://docs.python.org/3/tutorial/controlflow.html
@see: https://docs.python.org/3/reference/compound_stmts.html#the-while-statement
The while loop executes as long as the condition remains true. In Python, like in C, any
non-zero integer value is true; zero is false. The condition may also ... | true |
067b10f83c7b00d42b1d23184af4b6e3ce29a732 | bgoonz/UsefulResourceRepo2.0 | /GIT-USERS/ashishdotme/programming-problems/python/recursion-examples/06-product-of-list.py | 598 | 4.34375 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created by Ashish Patel
Copyright Β© 2017 ashish.me
ashishsushilpatel@gmail.com
"""
"""
Write the below function recursively
# prod(L): number -> number
# prod(L) is the product of numbers in list L
# should return 1 if list is empty
def prod(L):
product, i = 1,0
... | true |
2f21c4f01170a9826b62ac8773cf607df88b1b88 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/_External-learning-resources/02-pyth/algorithms-master/algorithms/matrix/crout_matrix_decomposition.py | 1,298 | 4.125 | 4 | """
Crout matrix decomposition is used to find two matrices that, when multiplied
give our input matrix, so L * U = A.
L stands for lower and L has non-zero elements only on diagonal and below.
U stands for upper and U has non-zero elements only on diagonal and above.
This can for example be used to solve systems of l... | true |
e00af86d7504f79df399d6008c017ff23a9a36c0 | bgoonz/UsefulResourceRepo2.0 | /_MY_ORGS/Web-Dev-Collaborative/blog-research/Data-Structures/1-Python/stack/valid_parenthesis.py | 556 | 4.125 | 4 | """
Given a string containing just the characters
'(', ')', '{', '}', '[' and ']',
determine if the input string is valid.
The brackets must close in the correct order,
"()" and "()[]{}" are all valid but "(]" and "([)]" are not.
"""
def is_valid(s: str) -> bool:
stack = []
dic = {")": "(",
"}": "{"... | true |
92c60c6141e1215c2d130b9d37bccf2a1e9b8ada | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Arrays/Divisor Sum/divisor_sum.py | 633 | 4.40625 | 4 | """
Aim: Calculate the sum of all the divisors of the entered number and display it.
"""
# function to find out all divisors and add them up
def divisorSum(n):
temp = []
for i in range(1, n + 1):
# condition for finding factors
if n % i == 0:
temp.append(i)
# adding all divisor... | true |
b75d2ff11f681b2d8ceb3896c14de6257e2ed051 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Trees/Expression Tree Evaluation/expression_tree_evaluation.py | 2,499 | 4.625 | 5 | # The expression tree is a binary tree in which each internal node corresponds to the operator like +,-,*,/,^ and
# each leaf node corresponds to the operand so for example expression tree for 3 + ((5+9)*2) - 3,5,9,2 will be leaf nodes
# and +,+,* will be internal and root nodes. It can be used to represent an expressi... | true |
e3624ed59b0788f845692017723c3004bf6480fb | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/_Learning/02_unordered_lists.py | 1,506 | 4.40625 | 4 | # In order to implement an unordered list, we will construct what is commonly known as a
# Linked List. We need to be sure that we can maintain the relative positioning of the
# items. However, there is no requirement that we maintain that positioning in contiguous
# memory.
# ---------------------------------------... | true |
3761502dbbdf79559a617c2c053a009aaa29e8d1 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/Beginners-Python-Examples-master/useful_scripts/password_generator.py | 1,410 | 4.15625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Now-a-days, hashes of our passwords are
# flowing on internet, but to avoid password
# getting discovered by whoever got their hands
# on them, a password should contain:
# 1. Least 8 characters
# 2. No words, instead randomly chosen characters
# 3. Ch... | true |
54b4af276b100f7461cc66399402005726a15b79 | bgoonz/UsefulResourceRepo2.0 | /_OVERFLOW/Resource-Store/01_Questions/_Python/pigLatin.py | 601 | 4.15625 | 4 | # Pig Latin Word Altering Game
# function to convert word in pig latin form
def alterWords():
wordToAlter = str(input("Word To Translate : "))
alteredWord = (
wordToAlter[1:] + wordToAlter[0:2] + "y"
) # translating word to pig latin
if len(wordToAlter) < 46:
print(alteredWord)
else... | true |
bb1075bd0a0bcaf938e4f45eeb705dbdb751df42 | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/learn-python/src/functions/test_lambda_expressions.py | 1,342 | 4.59375 | 5 | """Lambda Expressions
@see: https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions
Small anonymous functions can be created with the lambda keyword. Lambda functions can be used
wherever function objects are required. They are syntactically restricted to a single expression.
Semantically, they are jus... | true |
893f815791a090130faf05d42e959acd64ebcb25 | bgoonz/UsefulResourceRepo2.0 | /_MY_ORGS/Web-Dev-Collaborative/blog-research/Data-Structures/1-Python/map/word_pattern.py | 1,175 | 4.25 | 4 | """
Given a pattern and a string str, find if str follows the same pattern.
Here follow means a full match, such that there is a bijection between a
letter in pattern and a non-empty word in str.
Example 1:
Input: pattern = "abba", str = "dog cat cat dog"
Output: true
Example 2:
Input:pattern = "abba", str = "dog cat... | true |
ae27520913674390e809620c54463d13c4e88d63 | bgoonz/UsefulResourceRepo2.0 | /GIT-USERS/TOM-Lambda/CS35_IntroPython_GP/day3/intro/11_args.py | 2,852 | 4.34375 | 4 | # Experiment with positional arguments, arbitrary arguments, and keyword
# arguments.
# Write a function f1 that takes two integer positional arguments and returns
# the sum. This is what you'd consider to be a regular, normal function.
<<<<<<< HEAD
def f1(a, b):
return a + b
=======
def f1(a, b):
return a + b... | true |
de268aba734cf2c5da11ead13b3e83802fd39809 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/BLOG/ciriculumn/week-17/python/my-intro-BG/2/Module14FileMissingErrorChallengeSolution.py | 1,112 | 4.34375 | 4 | # import libraries we will use
import sys
# Declare variables
filename = ""
fileContents = ""
# Ask the user for the filename
filename = input("PLease specify the name of the file to read ")
# open the file, since you may get an error when you attempt to open the file
# For example the file specified may not exist
#... | true |
a05b3c15ce1004e4df54f1425f52c445d7ee97ef | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/BLOG/Data-Structures/1-Python/strings/decode_string.py | 1,207 | 4.15625 | 4 | # Given an encoded string, return it's decoded string.
# The encoding rule is: k[encoded_string], where the encoded_string
# inside the square brackets is being repeated exactly k times.
# Note that k is guaranteed to be a positive integer.
# You may assume that the input string is always valid; No extra white spaces... | true |
c98e8b74c3374fb90d5ebe1b75c661147b793a10 | bgoonz/UsefulResourceRepo2.0 | /_RESOURCES/my-gists/__CONTAINER/36edf2915f/36edf2915f396/cloning a list.py | 247 | 4.125 | 4 | # Python program to copy or clone a list
# Using the Slice Operator
def Cloning(li1):
li_copy = li1[:]
return li_copy
# Driver Code
li1 = [4, 8, 2, 10, 15, 18]
li2 = Cloning(li1)
print("Original List:", li1)
print("After Cloning:", li2)
| true |
7c74890541d696de85faa5a01f6838e86909e460 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_Another-One/ArithmeticAnalysis/NewtonRaphsonMethod.py | 944 | 4.125 | 4 | # Implementing Newton Raphson method in python
# Author: Haseeb
from sympy import diff
from decimal import Decimal
from math import sin, cos, exp
def NewtonRaphson(func, a):
""" Finds root from the point 'a' onwards by Newton-Raphson method """
while True:
x = a
c = Decimal(a) - (Decimal(eval... | true |
8d010e336acfd86fe9c1660ec0a8daa5e96c9d97 | DYarizadeh/My-Beginner-Python-Codes- | /Factoral.py | 241 | 4.15625 | 4 | def Factoral():
n = int(input("Input a number to take the factoral of: "))
if n < 0:
return None
product = 1
for i in range (1,n+1):
product *= i
print(i,product)
Factoral()
| true |
91d5e51709447c56ac07dffdddf2af84c08faa98 | hitulshah/python-code-for-beginners | /list.py | 1,485 | 4.3125 | 4 | #fibonacci sequence
# term = int(input('Enter terms:'))
# n1 = 0
# n2 = 1
# if term <= 0 :
# print('Please enter valid term')
# elif term == 1 :
# print(n1)
# else :
# for i in range(term) :
# print(n1)
# x = n1 + n2
# n1 = n2
# n2 = x
#list and files examples
# fnam... | true |
d429625575170c30a12a6fed8853dccc3adf4897 | ojaaaaas/llist | /insertion.py | 1,246 | 4.28125 | 4 | #to insert a node in a linked list
class Node:
def __init__(self,data):
self.data = data
self.next = None
class linkedList:
def __init__(self):
self.head = None
#in the front
def push(self,new_data):
new_node = Node(new_data)
new_node.next = self.head
self.he... | true |
c20b3f2791e46bdf8d0d36a231cb910eb308d7e6 | exequielmoneva/Small-Python-Exercises | /Small Python Exercises/impresion en triangulo.py | 377 | 4.1875 | 4 | #Calculate and print the number (without using strings) in order to create a triangle until N-1
for i in range(1,int(input("Insert the size of the triangle: "))):
print((10**(i)//9)*i)#This is a way to get the number without the str()
"""
Explanation for (10**(i)//9)*i:
example for number 2:
10**2 = 100
100/22... | true |
5a1b3b9c6ea33d83ac87571a95d83d4f7cf36d5f | daniel-dc-cd/AMMAshi-Saudi-Digital-Academy---Data-Science-Immersive---Bootcamps | /07_week/02_day_assignment/05_intermediate_function_1.py | 2,279 | 4.21875 | 4 | #============================================
# Arwa Ashi - HW 2 - Week 7 - Oct 19, 2020
#============================================
# random.random() returns a random floating number between 0.000 and 1.000
# random.random() * 50 returns a random floating number between 0.000 and 50.000, i.e. scaling the range of r... | true |
7282997020b9c81cf7591af4d63f81a124617bc9 | daniel-dc-cd/AMMAshi-Saudi-Digital-Academy---Data-Science-Immersive---Bootcamps | /07_week/03_day_assignment/assignment_module_1.py | 1,186 | 4.46875 | 4 | #===================================================
# Arwa Ashi - HW 3 - Week 7 - Oct 19, 2020
#===================================================
#==================================================================
# In each cell complete the task using basic Python functions
#=======================================... | true |
97c85007fd951698ae1461901a5b81daf46c59e5 | 2narayana/Automate-the-boring-stuff-with-Python---Practical-projects | /005 - PasswordLocker.py | 1,566 | 4.4375 | 4 | #! python3
# This program saves passwords and sends to the clipboard the desired password when executed.
# To open it, we type "5 - PasswordLocker" <argument> on cmd prompt.
# "5 - PasswordLocker.bat" must be downloaded along with PasswordLocker.py so that the command above works.
PASSWORDS = {'email': 'F7minlBD... | true |
a145c849ce706b4943e412b66b740df18c9c42b0 | AEI11/PythonNotes | /circle.py | 652 | 4.125 | 4 | # create a class
class Circle:
# create a class variable
pi = 3.14
# create a method (function defined inside of a clas) with 2 arguments
#self is implicitly passed
# radius is explicitly passed when we call the method
def area(self, radius):
# returns the class variable on the class * ... | true |
e8fff60820753fa85e18992c5b3b850be01405f1 | Hya-cinthus/GEC-Python-camp-201806-master | /level2/level2Exercises.py | 1,630 | 4.3125 | 4 | #Ex. 1
#write a function that tests whether a number is prime or not.
#hint: use the modulo operator (%)
#hint: n=1 and n=2 are separate cases. 1 is not prime and 2 is prime.
#Ex. 2
#write a function that computes the Least Common Multiple of two numbers
#Ex. 3
#write a program that prints this pa... | true |
6415ea8be338eb96b5d04a49f6241733265954b5 | Hya-cinthus/GEC-Python-camp-201806-master | /level1/noMultiplesOf3-demo.py | 336 | 4.4375 | 4 | #noMultiplesOf3.py
#write a program that prints out all numbers
#from 0 to 100
#that are NOT multiples of 3.
#modulo operator: the remainder of a division
#print(3%3) #gives us 0
#print(4%3) #gives us 1
#print(5%3) #gives us 2
#print(6%3) #gives us 0 (6 is divisible by 3)
x = 0
for x in range(101):
if (x%3!=0):
... | true |
b274ae7106e79fb4d9a8185fd5af8046c75b3982 | spyderlabs/OpenSource-2020 | /Python/bubble_sort.py | 2,385 | 4.28125 | 4 | """
This is a function that takes a numeric list as a parameter and returns the sorted list.
It does not modify the given list, as it works with a copy of it.
It is a demonstrative algorithm, used for informational and learning purposes.
It is open to changes, but keep the code clear and... | true |
f2871acea16906fa59c0d086375ae0fe1975f937 | spyderlabs/OpenSource-2020 | /Python/binary_search.py | 1,968 | 4.28125 | 4 | print('''INSTRUCTIONS FOR ADAPTED CODE:
can run a binary search in the following ways:
1) in python shell:
run code as is
2) in your terminal:
open a command line / terminal
cd to the path of binary_search.py
type your list (e.g. 1 2 4 10 12) and key (e.g. 4) in t... | true |
0ba8ab8dd079c11acd0440120bdaf321250b7c15 | Deepanshus98/D_S_A | /btLEFTVIEWOFBT.py | 1,160 | 4.28125 | 4 | # A class to store a binary tree node
class Node:
def __init__(self, key, left=None, right=None):
self.key = key
self.left = left
self.right = right
# Recursive function to print the left view of a given binary tree
def leftView(root, level=1, last_level=0):
# base case:... | true |
31c35ef90615947354bc91315d77e85935ce1922 | Deepanshus98/D_S_A | /BSTsearchgivenkeyinBST.py | 1,700 | 4.25 | 4 | # A class to store a BST node
class Node:
def __init__(self, data, left=None, right=None):
self.data = data
self.left = left
self.right = right
# Recursive function to insert a key into a BST
def insert(root, key):
# if the root is None, create a new node and return it
... | true |
52014cac130bed41ee581f4656a31cbf4009276b | garethkusky/CityCourseSpring | /week8/eliminateDupes.py | 743 | 4.21875 | 4 | __author__ = 'acpb968'
#Write a function that returns a new list by eliminating the duplicate values in the list. Use the
#following function header:
#def eliminateDuplicates(lst):
#Write a test program that reads in a list of integers, invokes the function, and displays the result.
#Here is the sample run of the progr... | true |
01be969de4bcf42b9d0227b7629baa5cec4b98e3 | tonyraymartinez/pythonProjects | /areaCalc.py | 1,649 | 4.21875 | 4 | import math
shape = raw_input("What shape will you be getting the area for?\n"+
"enter 'r' for rectangle,\n"+
"enter 's' for square,\n"+
"enter 'c' for circle,\n"+
"enter 'e' for ellipse\n"+
"enter 't' for triangle\n: ")
shape = s... | true |
4ff3a8c5abab7e8f59c7151d15dc9a74a0dd7ff0 | glenjantz/DojoAssignments | /pythonreview/oop/car.py | 1,349 | 4.15625 | 4 | # Create a class called Car. In the__init__(), allow the user to specify the following attributes: price, speed, fuel, mileage.
# If the price is greater than 10,000, set the tax to be 15%. Otherwise, set the tax to be 12%.
# Create six different instances of the class Car. In the class have a method called display_al... | true |
da0157620558c8403cb9ce95cb9cc6ef883c4b58 | mmweber2/hackerrank | /dropbox.py | 1,850 | 4.21875 | 4 | # Based on a problem from Dropbox:
# http://hr.gs/redbluebluered
def wordpattern(pattern, input, word_map=None):
"""Determines if pattern matches input.
Given a pattern string and an input string, determine if the pattern matches the input,
such that each character in pattern maps to a substring of in... | true |
bf556141a20e2fe990dd93a720de386c23623877 | aktersabina122/Story_Generator_Python | /Story_generator_Python.py | 1,162 | 4.4375 | 4 |
# Challenge One (Input and String Formatting)
# You and a partner will try to use your knowledge of Python to create a MadLib function.
# HOW-TO: Create a multi-line string variable called my_story which contains a short story about an animal in a specific borough of New York, performing some action involving o... | true |
0698789bdda90a3f1b455a79375c6950c6d63bd9 | caalive/PythonLearn | /stroperate/shoppingcar2.py | 1,570 | 4.125 | 4 |
product_list = [('Iphone',5900),
('Mac Pro',12000),
('Coffee',50),
('Book',40)]
shopping_list = [];
def print_product_list():
for index,item in enumerate(product_list):
print(index,item)
def print_shopping_list():
for item in shopping_list:
pr... | true |
d06ee8dbbe3ee90a32dea1db820f7dc9102e4eb9 | wbabicz/lpthw-exercises | /ex15.py | 681 | 4.3125 | 4 | # from sys import argv
# script, filename = argv
# # Opens the filename passed in and assigns it to the variable txt.
# txt = open(filename)
# # Prints out the name of the file.
# print " Here's your file %r:" % filename
# # Reads the text from file and prints it.
# print txt.read()
#print "Type the fil... | true |
1ceeab4b174534c56451b46d31881141a641f2d2 | Shruthi410/coffee-machine | /main.py | 2,462 | 4.21875 | 4 | MENU = {
"espresso": {
"ingredients": {
"water": 50,
"coffee": 18,
},
"cost": 1.5,
},
"latte": {
"ingredients": {
"water": 200,
"milk": 150,
"coffee": 24,
},
"cost": 2.5,
},
"cappuccino": {
... | true |
ea2adc967d52fdd81ba44c29677ccba708393979 | JB0925/Python_Syntax | /words.py | 991 | 4.375 | 4 | from typing import List
my_words = ['cat', 'dog', 'ear', 'car', 'elephant']
def uppercase_words(words: List[str] = my_words) -> None:
"""Print out each string in a list in all caps"""
for word in words:
print(word.upper())
print(uppercase_words())
def only_words_that_start_with_e(words: List[str] =... | true |
2f94e530bd1c00a5b185f33996d7eb3f64879d36 | AnupBagade/Hackerrank | /Algorithms/String/reverse_string.py | 341 | 4.375 | 4 | """
Reverse a string using recurssion
"""
def reverse_string(s):
if len(s) == 0:
return s
else:
return reverse_string(s[1:]) + s[0]
if __name__ == '__main__':
input_string = input('Please enter string to be reversed ')
result = reverse_string(input_string)
print('String reversed ... | true |
2472183f0d0853dfe2a3949e784b8bdc5d23f289 | AnupBagade/Hackerrank | /Algorithms/DailyinterviewPro/longest_consecutive_sequence.py | 1,206 | 4.28125 | 4 | """
You are given an array of integers. Return the length of the longest
consecutive elements sequence in the array.
For example, the input array [100, 4, 200, 1, 3, 2] has the longest consecutive
sequence 1, 2, 3, 4, and thus, you should return its length, 4.
def longest_consecutive(nums):
# code.
print longest_... | true |
04633470b57fcf55cae2fd005a87fed153ab1509 | eidehua/ctci-practice | /Python/Data Structures/Arrays and Strings/1.1.py | 2,839 | 4.3125 | 4 | # Implement an algorithm to determine if a string has all unique characters.
# What if you cannot use additional data structures?
# assumption: assume uppercase and lowercase are different characters
def has_unique_chars(str):
counts = {} # dictionary to see if we have seen the character already
for i in range... | true |
0809ca6802fee1cc1ef0974245103df2d39998c4 | insidepower/pythontest | /s60/009stringMani.py | 718 | 4.28125 | 4 | txt = "I like Python"
print txt[2:6] # like
print txt.find("like") # 2
if txt.find("love") == -1:
print "What's wrong with you?"
print txt.replace("like", "love") ## new string
print txt.upper() # I LIKE PYTHON
print "Length", len(txt) ## 13
txt2 = ""
if txt2:
print "txt2 contains characters"
el... | true |
46bc17759e7b3472aa698890b6efb858a43cef88 | Snehasis124/PythonTutorials | /ForLoop.py | 332 | 4.4375 | 4 | #10TH PROGRAM
#INTRODUCTION TO FORLOOP
new_list = ['Hello' , 'Good Morning']
word = input("Add your word ")
new_list.append(word)
for value in new_list:
print(value)
# A DEMO PROGRAM
def menu(list, question):
for entry in list: print( 1 + list.index(entry), print (")") + entry )
return input(question) -... | true |
2287851d9eae7e8571f9b5af63db2d5d9fd800f1 | jamiejamiebobamie/CS-1.3-Core-Data-Structures | /project/CallRoutingProject_scenario1.py | 1,719 | 4.28125 | 4 | """
SCENARIO #1
As there is no order to the routes in the route file, the entirety of the file
has to be read.
Open the file. Iterate through it. Searching each digit of each route.
If the program reaches the end of a route, we check to see if that route is cheaper than the current
lowest price and change the lowest ... | true |
ab289ec04193676086b1d75f52bcb24277a51d3e | go2bed/python-simple-neural-network | /com.chadov/MathFormulaNeuralNetwork.py | 1,608 | 4.25 | 4 | from numpy import *
# Teaching the computer to predict the output
# of a mathematical expression without "knowing"
# exact formula (a+b)*2
class NeuralNetwork(object):
def __init__(self):
random.seed(1)
self.weights = 2 * random.random((2, 1)) - 1
# Takes the inputs and corresponding
# ... | true |
c280d8d38c950ece6999026b6aa9705c35a24e21 | josethz00/python_basic | /numbers.py | 723 | 4.25 | 4 | import math
pi = math.pi
print('{:.2f}'.format(pi)) #formating decimal numbers by the right way
print(f'{pi:.4f}') #formating decimal numbers by a simple way
num1 = input("Please enter the first number") #this way, the value will be gotten as default(as a string)
num2 = input("Please enter the second number") #this ... | true |
950d8358a2248895e9262524ce4a657150a26276 | cvvlvv/Python_Exercise | /Day_2.py | 688 | 4.125 | 4 |
# coding: utf-8
# Day 2:
# Prime Factorization - Have the user enter a number and find all Prime Factors (if there are any) and display them.
# In[ ]:
def PrimeFactors ():
n = int(input("Please give a number."))
PrimeFactors = []
prime = []
for i in range(2,n+1):
for j in range(2,i):
... | true |
39eda1352d4fee20921bd18bdeb7d4cbf9c1cc3b | xytracy/python | /ex15.py | 358 | 4.25 | 4 | from sys import argv
script,filename=argv
txt= open(filename)
#open is a command taht reaads our text file
print"here's your file %r:" %filename
print txt.read()
#the "." (dot) is to add a command
print"type the filename again:"
file_again=raw_input(">")
txt_again=open(file_again)
print txt_again.... | true |
acedccda8b6286d03e1813e0df26c8ff05565e6b | danielgulloa/CTCI | /Python/Chapter1/check_Permutation.py | 459 | 4.25 | 4 | '''
Implement a function which reverses a string
(The original question is Implement a function void reverse(char+ str) in C or C++ which reverses a null-terminated string)
'''
def reverse(mystring):
newstr="";
n=len(mystring)
for i in range(n):
newstr+=mystring[n-i-1]
return newstr;
testCases=['anagram', 'hel... | true |
980d1824dc8c6d9ecd0744025d777ccc0c559465 | mcdonald5764/CTI110 | /P5T2_FeetToInches_DarinMcDonald.py | 492 | 4.3125 | 4 | # Convert inches to feet
# 10/30
# CTI-110 P5T2_FeetToInches
# Darin McDonald
#
# Set a conversion value
# Get input from the user on how many feet there are
# Multiply feet and the conversion varible to get feet to inches
# Display how many inches per foot
inches_per_foot = 12
def main():
feet ... | true |
2b9f0439ddf165d662c5c8e9d351f23105e6adf5 | mcdonald5764/CTI110 | /P3HW2_Shipping_McDonald.py | 1,215 | 4.375 | 4 | # CTI-110
# P3HW2 - Shipping Charges
# Darin McDonald
# 9/27
#
# Get a number of pounds input from the user
# Check to see if the weight is less than or equal to 2
# Display the cost of the weight multipled by the first rate per pound
# Check to see if the weight is more than 2 but less than or equal to 6
#... | true |
3a05a1b5aa614dff3bc38af5550c24787799b870 | gaul/src | /interview/needles.py | 1,094 | 4.15625 | 4 | #!/usr/bin/env python
'''\
Given two strings, remove all characters contained in the latter from
the former. Note that order is preserved. For example:
"ab", "b" -> "a"
"abcdabcd", "acec" -> "bdbd"
What is the run-time of your algorithm? How much memory does it use? Is it
optimal?
linear search... | true |
08ac0896c2ba4ffa89ecccca61971fb93c1db3ab | negaryuki/phyton-class-2019 | /Homework/Assignment - BMI.py | 493 | 4.34375 | 4 | print("Welcome to Negar's BMI calculator !\n (^o^)/")
print('Please enter your weight(Kg):')
weight = float(input())
print('Almost there, now please enter your height(m):')
height = float(input())
BMI = weight / (height * height)
print('and your BMI is: ', BMI)
if BMI <= 18.5:
print('Result is : Underweight :(')... | true |
d078650393b437da6f97ab813e133f232c466912 | kmusgro1/pythonteachingcode | /P1M4kristymusgrove.py | 695 | 4.125 | 4 | # [ ] create, call and test the str_analysis() function
statement = ""
def str_analysis(statement):
while True:
statement = input("enter a word or number: ")
if statement.isdigit():
statement=int(statement)
if statement > 99:
print(statement,"is a bi... | true |
e432237f67c107fe532b66635511262226b941be | vpc20/python-strings-and-things | /CharacterFrequency.py | 1,473 | 4.28125 | 4 | # Write a function that takes a piece of text in the form of a string and returns the letter
# frequency count for the text. This count excludes numbers, spaces and all punctuation marks.
# Upper and lower case versions of a character are equivalent and the result should all be in
# lowercase.
#
# The function should r... | true |
3a71f044ad80d32140424a35875893031f4628a5 | Enid-Sky/python-fundamentals | /appendMethod.py | 729 | 4.75 | 5 | # Call .append() on an existing list to add a new item to the end
# With append you can add integers, dictionaries, tuples, floating points, and any objects.
# Python lists reserve extra space for new items at the end of the list. A call to .append() will place new items in the available space.
mixed = [1, 2] #... | true |
2d14fbb76b0c71fadb9a4ab965b5b6e3d31924dd | ellelater/Baruch-PreMFE-Python | /Level_1/Level_1_ROOT_FOLDER/1.2/1.2.10/n1.2.10.py | 827 | 4.4375 | 4 | """
This program demonstrates the time cost of creating lists with for-loop and comprehension.
"""
import time
def main():
# 10a creates the list with for-loop
start1 = time.time()
lst1 = []
for i in range(10000000):
if i % 10 == 0:
lst1.append(i)
print "Time cost of loop:", t... | true |
6900f2506f65c3924e81c990fb17ad572af5f0f6 | ellelater/Baruch-PreMFE-Python | /level4/4.1/4.1.1/4.1.1_main.py | 2,468 | 4.5625 | 5 | '''
This program is to demonstrate string functions.
'''
s = ' The Python course is the best course that I have ever taken. '
# 4.1.1 a Display the length of the string.
print 'The length of the string is {0}'.format(len(s))
# 4.1.1 b Find the index of the first 'o' in the string.
print "The index of the first 'o... | true |
0f778b2a6514a9a7b2218dd688c789f8f09d70fd | bohdan-holodiuk/python_core | /lesson5/hw5/Counting_sheep.py | 842 | 4.3125 | 4 | """
Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present).
For example,
[True, True, True, False,
True, True, True, True ,
True, False, True, False,
True, False, False, True ,
True... | true |
e82894a863e7bc24cd1a17432b99630d9cfc604c | Oboze1/UCI_homework | /04-Python2/create_notes_drs.py | 1,446 | 4.25 | 4 | import os
#imports os
#defines the function main to create the folder directory system
def main():
#
#checks to see if the 'CyberSecurity-Notes' directory already exits
#
if os.path.isdir("CyberSecurity-Notes") == False:
#uses 'os.mkdir' to make a directory 'CyberSecurity-Notes'
#
... | true |
55d6f682df04071d77456fefaa8e89e00e6eede9 | SpartaKushK/First | /coin_flip_simulator.py | 816 | 4.1875 | 4 | '''
#Coin Flip Simulation - Write some code that simulates flipping a single coin however many times the user decides.
# The code should record the outcomes and count the number of tails and heads.
'''
import random
def flip_coin():
flip_results = []
total_heads = 0
total_tails = 0
num_of_flips = int(i... | true |
322ea317e128b82eb03ffb98a1501a7b0ddbbd4c | payalbhatia/Machine_Learning | /*Python_Basics/Command_Line_Argument/command_line_argument.py | 478 | 4.125 | 4 | import sys
# check if it has any arguments
print()
arg_num = len(sys.argv)
if arg_num == 1:
print('there are no arguments')
elif arg_num > 1:
# subtract 1 because one of the arguments is the file name
print('there are %d arguments ' % (arg_num-1))
print(sys.argv)
print('first argument is:', sys.argv[1])
... | true |
d851d6a26beedfdd9217f92a9d31052d8bcd02e8 | Travis-ugo/pythonTutorial | /Class.py | 801 | 4.3125 | 4 | # A Class in python is like an object constuctor or a blueprint for creating object.
# all classes have function called __init__(), which always executes when the class
# is being initiated.
# use the __init__() function to assign values to object properties, or other operationns
# that are nessesary to do when th obj... | true |
e51665d1d889fc309ec96cb7a3357dcdc6b27f90 | devesh37/HackerRankProblems | /Datastructure_HackerRank/Linked List/MergeTwoSortedLlinkedLists.py | 1,620 | 4.1875 | 4 | #!/bin/python3
#Problem Link: https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists/problem
import math
import os
import random
import re
import sys
class SinglyLinkedListNode:
def __init__(self, node_data):
self.data = node_data
self.next = None
class SinglyLinkedList:
def __ini... | true |
5cb576a8f9e9891f8046e0f8e0f188f5d98241bd | zepedac6581/cti110 | /P3WH1_ColorMixer_Zepeda.py | 1,563 | 4.34375 | 4 | # A program that allows users to input primary colors as a mix and ouputs
# a secondary color.
# CTI-110-0003
# P3HW1 - Color Mixer
# Clayton Zepeda
# 2-14-2019
#
def main():
# User inputs two primary colors
# Primary colors are red, blue and yellow.
print("The primary colors are red, blue, and yellow... | true |
182bb72bf884e6f1678e7fcf5f408c7b521a1900 | alvinwang922/Data-Structures-and-Algorithms | /Strings/Compare-Version-Numbers.py | 1,904 | 4.125 | 4 | """
Given two version numbers, version1 and version2, compare them.
Version numbers consist of one or more revisions joined by a
dot '.'. Each revision consists of digits and may contain
leading zeros. Every revision contains at least one character.
Revisions are 0-indexed from left to right, with the leftmost
revi... | true |
3adb0122c6c2190389ffa9c91e2e3013f08310fa | alvinwang922/Data-Structures-and-Algorithms | /Trees/Tree-To-LinkedList.py | 1,529 | 4.21875 | 4 | """
Convert a Binary Search Tree to a sorted Circular Doubly-Linked List
in place. You can think of the left and right pointers as synonymous
to the predecessor and successor pointers in a doubly-linked list.
For a circular doubly linked list, the predecessor of the first element
is the last element, and the succes... | true |
e9c31922276c7e2e860cd5716b72e9a7ff0a613b | alvinwang922/Data-Structures-and-Algorithms | /LinkedList/Odd-Even-LinkedList.py | 1,001 | 4.125 | 4 | """
Given a singly linked list, group all odd nodes together followed by the
even nodes. Please note here we are talking about the node number and not
the value in the nodes.
You should try to do it in place. The program should run in O(1) space
complexity and O(nodes) time complexity.
"""
# Definition for singly-... | true |
63a2c6bd1837d4d68b58bb0b4e7d6767c9e6a6ab | alvinwang922/Data-Structures-and-Algorithms | /DFS/Reconstruct-Itinerary.py | 1,476 | 4.375 | 4 | """
Given a list of airline tickets represented by pairs of
departure and arrival airports [from, to], reconstruct the
itinerary in order. All of the tickets belong to a man who
departs from JFK. Thus, the itinerary must begin with JFK.
Note:
If there are multiple valid itineraries, you should return
the itinerary ... | true |
760df47c1a3a8a7cdb8b3353e3ac4b2ff5f34f45 | alvinwang922/Data-Structures-and-Algorithms | /Strings/ZigZag-Conversion.py | 971 | 4.25 | 4 | """
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this:
P A H N
A P L S I I G
Y I R
Write the code that will take a string and make this conversion given a number of rows
"""
class Solution:
def convert(self, s: str, numRows: int) -> str:
if numRows == ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.