blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d95a59cedaa3724c86391d90ef72bfe66d6586f8 | merinjo90/PHYTHON_MINI_PROJECT | /Bank_Application/bank_application.py | 2,197 | 4.34375 | 4 |
"""
#create a bank application.
# : "Account"-parent class, with a "BankName: ABC bank,IFSCcode : 45154,Balance" as
# class variables. inital balace "10000"common to all customer.
# :"AccountHolder"-child class, with instance variables "name,AccNo" and functions
# "Deposit,widrow,Bala... | true |
61b9117744cbaca25ef9ec0144b0bb5fc276cc78 | mrseidel-classes/archives | /ICS3U/ICS3U-2019-2020F/Code/notes/20 - formal_documentation/formalDocumentation_ex3.py | 1,175 | 4.46875 | 4 | #-----------------------------------------------------------------------------
# Name: Formal Documentation i.e. docstrings (formalDocumentation_ex3.py)
# Purpose: Provides an example of how to create docstrings in Python using
# formal documentation standards.
#
# Author: Mr. Seidel
# Created: ... | true |
bf39ffd74d9b82192bffa74b189dd30b71788dc3 | mrseidel-classes/archives | /ICS3U/ICS3U-2019-2020F/Code/notes/30 - dictionaries/dictionaries_ex1.py | 827 | 4.5 | 4 | #-----------------------------------------------------------------------------
# Name: Dictionaries (dictionaries_ex1.py)
# Purpose: To provide examples of how to use dictionaries
# Accessing keys, values, and adding in information
#
# Author: Mr. Seidel
# Created: 18-Nov-2018
# Updated... | true |
1f20f0afd76db21f0a9b952d072892e981a47d1d | mrseidel-classes/archives | /ICS3U/ICS3U-2019-2020S/Code/notes/21 - logging/logging_ex1.py | 2,170 | 4.15625 | 4 | #-----------------------------------------------------------------------------
# Name: Logging (logging_ex1.py)
# Purpose: To provide examples of how to debug and log information in
# Python programs.
#
# Author: Mr. Seidel
# Created: 11-Nov-2018
# Updated: 02-May-2020 (updated Non... | true |
57b208265cf027b9cfd74921fbb1b16cb2ebf371 | mrseidel-classes/archives | /ICS4U/ICS4U-2021-2022S/Code/examples/recursion/Python/recursive_drawing.py | 976 | 4.28125 | 4 | '''
Recursive example using Turtle graphics to draw
Modified from this work
https://p5js.org/examples/simulate-recursive-tree.html
'''
def branch(height, theta): # recursive function
'''
Draws a single branch of a tree.
Parameters
----------
height : int
The length of the branch in the tre... | true |
6c4ca067f7d85cb9b3c999fca62a3b332fe18604 | mrseidel-classes/archives | /ICS3U/ICS3U-2018-2019-Code/notes/08b - logging/logging_ex5.py | 2,992 | 4.40625 | 4 | #-----------------------------------------------------------------------------
# Name: Logging (logging_ex5.py)
# Purpose: To provide examples of how to debug and log information in
# Python programs.
# Important:
# This version implicitly creates a CRITICAL error
# ... | true |
4c577daf3b94303327af0cfbf8ca06b63cdf98f2 | mrseidel-classes/archives | /ICS3U/ICS3U-2018-2019S/Code/notes/02 - conditionalStatements (if)/conditionalStatements.py | 883 | 4.21875 | 4 | #-----------------------------------------------------------------------------
# Name: Conditional Statements (conditionalStatements.py)
# Purpose: To provide information about how conditional statements (if)
# work in Python
#
# Author: Mr. Seidel
# Created: 15-Aug-2018
# Updated: 15-Aug-2... | true |
1825a895b2ece800dfb949c115529043607cd498 | theIncredibleMarek/algorithms_in_python | /insertion_sort.py | 2,537 | 4.1875 | 4 | #!/usr/bin/env python3
# TODO - start from the 2nd element - index is 1
# if ascending - check if smaller than the one immediately preceding
# if descending - check if bigger than the one immediately preceding
# finish when you reach the end of the list
def sort(input, ascending=True):
print("Original: {}".forma... | true |
963fdbbf6fe77bcbd86e55c03d7ec1938de8d6f7 | Prot0type1/IS-51-FINAL | /FINAL.py | 1,378 | 4.125 | 4 | """
start
this program will output the grades of students on the final by:
-number of grades
-average of grades
-percentage of grades above the average percentage
the average grade is 83.25.
the total number of grades is 24.
the percentage of grades above average is 54.17
the list will be introduced from... | true |
79bf452c4f9f4e5d78565fd0efdfa77f5302e891 | shearocke/IT_SQL1 | /MyDatabase.py | 1,074 | 4.4375 | 4 | import sqlite3
# create a name for the database
database = 'Company.db'
# create a connection to the database
conn = sqlite3.connect(database)
# conn.execute('DROP TABLE IF EXISTS Customers')
#
# create table with fields and data types
# conn.execute('''CREATE TABLE Customers
# (id INT NOT NULL,
# ... | true |
68647861144f8807638df84e08185d03264c8d02 | Carla08/cracking-the-interview | /data_structures/linked_lists/node_lists_problems.py | 2,890 | 4.125 | 4 | from typing import List
from data_structures.linked_lists.linked_list import LinkedList
def reverse_linked_list(lst):
n = lst.head
_next = None
_prev = lst.head
while n:
_next = n.nxt
n.nxt = _prev
_prev = n
n = _next
lst.head.nxt = None
lst.head = _prev
ret... | true |
c25ab8635033d6aa75ba95f82cdd6b7d2f8d3301 | MichaelKirkaldyV/Algos_ | /findmiddle.py | 1,330 | 4.125 | 4 |
class Node:
def __init__(self, value):
self.value = value
self.next = None
class LinkedList:
def __init__(self, head=None):
self.size = 0
self.head = head
def insertNode(self, value):
node = Node(value)
print(node)
if self.head == None:
... | true |
f71dc34a7f9a7010f8c6cf830149d3a649a996b1 | daviidluna/PythonLists | /lists.py | 1,195 | 4.1875 | 4 | mine = ['a promised', 'land', 'hehe']
print(mine)
yes = ['cabbage', 'eggplant', 'watermelon']
if 'watermelon' in yes:
print('yes, watermelon is present in the list \'yes\'')
wait_list = ['amanda', 'fiber', 'oliver']
if 'oliver' in wait_list:
print('yes he is on the wait list')
# Accessing list items
one = ['... | true |
859566908e2be6b188a8c660df0e7d766d1624b5 | ahdeshpande/PythonPrograms | /html_unordered_list.py | 1,454 | 4.21875 | 4 | def string_list_to_html_ul(string_list):
"""
Function that converts a string list to an HTML unordered list
"""
# Create a html unordered list from the user input list.
# Add the start tag of ul
html_string = "<ul>\n"
# Iterate through input list
for user_input in string_list:
... | true |
a05cc0a95deaa4eeb51a108105ec6d11dfa77df6 | unclexo/data-structures-and-algorithms | /3.Maps/python/Map.py | 2,894 | 4.125 | 4 | """
The implementation of Map ADT
But using Python list ADT
"""
class Map:
""" Creates empty map instance """
def __init__(self):
self._items = list()
""" Returns the number of entries in the map """
def __len__(self):
return len(self._items)
""" Determines if the map co... | true |
a702ddc653080253f5b99f72af3a6bfc7577c212 | jaychovatiya4995/B6-python-Es-LU | /day4Assignment1.py | 573 | 4.5625 | 5 | # Find all occurrence of substring in given string
import re
test_str = "what we think we become; we are python programmer"
# get substring
test_sub = input("Enter a substring : ")
# printing original string
print("The original string is : " + test_str)
# printing substring
print("The substrin... | true |
0cf9b382e746712ad7fcf946a17f029b137c3ace | hari197/Tasks | /Task3.py | 603 | 4.40625 | 4 | # Program to find the sum of the series 1 + 3^2/3^3 + 5^2/5^3... upto n terms
#Taking input from user for the number of terms
n=int(input("Please enter the number of terms: "))
sum=0 #initialize sum
i=1 #initialize increment variable for loop
counter=0 #initialize counter
#If the input from the user is 0, print ... | true |
4597c560c59325945747cf07858f5acc54e57435 | jswindlehurst/SumofPrimes2 | /main.py | 1,066 | 4.1875 | 4 | import math
def is_prime(number):
if number > 1:
if number == 2:
return True
if number % 2 == 0:
return False
for current in range(3, int(math.sqrt(number) + 1), 2):
if number % current == 0:
return False
return True
return Fa... | true |
157b9433760356c688e53921e2669343b3855881 | levashovn/test_task_sos | /task_5.py | 971 | 4.1875 | 4 | import random
def create_txt_file():
ask = True
f = open('random_numbers.txt', 'w')
while ask:
try:
rows_count = int(input('Please enter a number of rows to write: '))
ask = False
for row in range(rows_count):
for i in range(25):
num = random.randint(1, 100)
f.write(str(num))
f.write('... | true |
659a31b1550d3e59f969b1d33d1dbf0be88b6baf | DanielBMeeker/module4 | /main/basic_if.py | 1,919 | 4.21875 | 4 | """
Program: basic_if.py
Author: Daniel Meeker
Date: 06/09/2020
This program accepts user input for desired membership
level then calculates and returns the cost of the level.
"""
# function definitions:
def get_membership(): # Get user input
membership = input("Welcome to the Programmer's Toolkit Monthly Su... | true |
ce0923065367583a597ca521b774fa28ff50b04f | jekhokie/scriptbox | /python--learnings/list_comprehension.py | 1,098 | 4.25 | 4 | #!/usr/bin/env python
#
# Topics: List Comprehension
#
# Background: List comprehension examples and functionality.
#
# Sources:
# - https://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/
import unittest
# test functionality
class TestMethods(unittest.TestCase):
def test_loop(self):
... | true |
ae9f23d7211586056bcc0419a76fd8cb2cf756fd | Saurabh-001/Small-Python-Projects | /Guess the Number/Input Range.py | 1,450 | 4.25 | 4 | import random
import math
name = input("Enter your name: ")
lower_bound = int(input("Enter the lower bound: "))
upper_bound = int(input("Enter the upper bound: "))
maximum_chance = int(math.log2(upper_bound-lower_bound+1)) + 1
wins = 0
row_wins = 0
option = 'Y'
option_list = ['Y','N','y','n']
while option=='Y' or... | true |
86c7acab30712b8770f6b413e8d34854c5715622 | deadbok/eal_programming | /Assignment 2A/prog1.py | 1,037 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# The above lines tell the shell to use python as interpreter when the
# script is called directly, and that this file uses utf-8 encoding,
# because of the country specific letter in my surname.
'''
Name: Program 1
Author: Martin Bo Kristensen Grønholdt.
Version: 1.0 (13/1... | true |
bf5f81da98a32189b8c4d147b522e9ddaf30db0b | deadbok/eal_programming | /Assignment 2A/prog2.py | 1,948 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# The above lines tell the shell to use python as interpreter when the
# script is called directly, and that this file uses utf-8 encoding,
# because of the country specific letter in my surname.
'''
Name: Program 2
Author: Martin Bo Kristensen Grønholdt.
Version: 1.0 (13/1... | true |
7d9f56f41b590c03af0be8e72ba22b92a933cbf0 | deadbok/eal_programming | /Assignment B1/prog7.py | 1,140 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# The above lines tell the shell to use python as interpreter when the
# script is called directly, and that this file uses utf-8 encoding,
# because of the country specific letter in my surname.
'''
Name: Program 7
Author: Martin Bo Kristensen Grønholdt.
Version: 1.0 (6/11... | true |
ca11d5f806eb1105b7d11d2ed52890f049b33407 | deadbok/eal_programming | /Assignment 5/prog6.py | 2,424 | 4.46875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# The above lines tell the shell to use python as interpreter when the
# script is called directly, and that this file uses utf-8 encoding,
# because of the country specific letter in my surname.
"""
Name: Program 6 "Test Average and Grade"
Author: Martin Bo Kristensen Grø... | true |
5b5ace9639d6044ebca12fd640dbf83fc0aa053b | guto-alves/datastructures-and-algorithms | /daily-coding-problem/88-ContextLogic-Division/division.py | 750 | 4.21875 | 4 | """
Implement division of two positive integers without using the division,
multiplication, or modulus operators. Return the quotient as an integer,
ignoring the remainder.
"""
def divide(dividend, divisor):
if divisor == 0:
return None
sign = -1 if dividend < 0 or divisor < 0 else 1
di... | true |
6564708f15277b9bd4f0ef5adcdbaf97d52dfae8 | lawun330/Python_Basics | /Regular Expression/regular expressions.py | 2,013 | 4.625 | 5 | #regular expressions work with strings
import re
string=r"@" #a raw string called "@" desired to be matched
#raw strings don't escape anything which makes regular expression easier
if re.match(string,"wun333@gmail.com"):
#re.match() matches one string with another starting from the beginning of both strings... | true |
4b6e5276714dd23c45a39e1fe9bd7adccee3cf36 | quizque/ICS4U | /Labs/Lab 1/Calculators.py | 924 | 4.3125 | 4 | import math
# Calculate area of a cone
# INPUTS
# - Radius (float)
# - Height (float)
# OUTPUT
# - Area (print)
print("~~~~~ CALCULATE AREA OF CONE ~~~~~")
print("Area of the cone: ", (1/3)*(3.14159*math.pow(float(input("Enter radius of cone: ")),2)*float(input("Enter height of cone: "))))
# Calculate fahrenhei... | true |
efb714d84deea785f55a6057e7889eac10d7c26d | quizque/ICS4U | /Labs/Lab 9/Part2.py | 730 | 4.28125 | 4 | #********************************************************************************
#** Nick Coombe 2020/03/14 ***
#** Lab 9 Part 2 ***
#** ***
#** Part 2 of Lab 9 ***
#** Create a function that prints a box ***
#** ***
#********************************************************************************
# Prints a box of g... | true |
db8923680b9e9f72b78ece2c179dccb9bf1e8a83 | carlabeltran/data_analytics_visualization | /3.1_introduction_to_python_I/in_class/07-Ins_Conditionals/conditionals.py | 376 | 4.1875 | 4 | x = 1
y = 10
if x > y:
print("x is greater than y!")
if x == 1:
print("x equals one")
if y != 1:
print("y is not one")
if (x == 1 and y == 10):
print("both conditionals are true")
if (x > 10):
print("x is greater than 10")
elif (x < 5):
print("x is less than 5")
else:
print("x is between 5 and 10")
... | true |
34f5adc2c7c2150186b7f45496db28f1258b03d4 | adrianlebaron/python_notes | /work/week_three.py | 1,265 | 4.125 | 4 | # make variable word
# def word_reverser(string):
# print(f"I'm sorry, you need to be at least 25 years old")
# usernames = [
# 'jon',
# 'tyrion',
# 'theon',
# 'cersei',
# 'sansa',
# ]
# for username in usernames:
# if username == 'cersei':
# print(f'Sorry, {username}, you are not allowed')
# ... | true |
a2bc458851e87a37aab20734fb93c3754024d0c8 | adrianlebaron/python_notes | /dictionaries/complicated/comprehension.py | 659 | 4.40625 | 4 | # Exercise 21: Solution in small_course.py
Section 1, Lecture 47
Exercise for reference:
Filter the dictionary by removing all items with a value of greater than 1.
d = {"a": 1, "b": 2, "c": 3}
# Answer:
d = {"a": 1, "b": 2, "c": 3}
d = dict((key, value) for key, value in d.items() if value <= 1)
print(d)
Explana... | true |
04b064ff66f0758e9c3d79da65b372ddaca16e32 | wesenu/python-algorithms | /insertion_sort.py | 970 | 4.46875 | 4 | # From Lecture 3, Insertion Sort & Merge Sort
class InsertionSortArray:
''' Maintains a sorted one-dimensional array of comparable elements using insertion sort.
The one-dimensional array is represented as a list.
Interface with the array using insert, remove, and display. '''
def __init__(self, array... | true |
9cd7fe204067cdff5641d3603a032e3604d44f93 | Anirban2404/MachineLearning_Coursera | /Assignments_Python/Week2/computeCost.py | 771 | 4.15625 | 4 | # COMPUTECOST Compute cost for linear regression J = COMPUTECOST(X, y, theta)
# computes the cost of using theta as the parameter for linear regression to fit
# the data points in X and y
import numpy as np
def computeCost(X, y, theta):
# Initialize some useful values
m = y.size # number of training examples
... | true |
ddcb7e96cc70e2df680acd96fc321d9561d8761e | sraj-s/Data-case-handling | /grid.py | 266 | 4.28125 | 4 | from tkinter import *
root = Tk()
#creating a label widget
myLabel1 = Label(root, text="Hello world")
myLabel2 = Label(root, text="My name is sambeg")
#shoving it into the screen
myLabel1.grid(row=0, column=0)
myLabel2.grid(row=1, column=5)
root.mainloop()
| true |
242f6e74796f62432d702fe1b422965a55a0292f | rajputrajat/teaching_basic_programming | /day_22/functions_exercise.py | 788 | 4.15625 | 4 | # take - how many numbers in a list
# take individual number, and create a list
# print that list
# find out maximum and minimum number in that list
def make_list():
count = int(input('how many numbers: '))
numbers = []
for n in range(count):
num = int(input('enter number: '))
numbers.appen... | true |
fd24661a2c11233d39c60fbb3780b8265d79764e | yedkk/python-datastructure-algorithm | /python basic/basic 5.py | 568 | 4.1875 | 4 | # This is the programs that convert Celsius to Fahrenheit
# I get the number of Celsius and print the list of convert
# Author Kangong Yuan
# Get the input from users
celsius = int(input("Enter the number of celsius temperatures to display: "))
# Print the title of list
print('Celsius\tFahrenheit')
# Set the variab... | true |
c4d1cb84dbd8b6b343baa94fed074c62ebc7c18b | yedkk/python-datastructure-algorithm | /python basic/basic 2.py | 875 | 4.375 | 4 | #This progroms want to get user's weight and height and calculate their then tell then the situation of their bmi
#First get the wieght and height of the user
#Second calculate the bemi throgh formula
#Third decide the situation of their bmi
# Author Kangdong Yuan
#Get the input of the height and the weight
height=fl... | true |
63024e12ceabc427d785a055513a66c73b586ed9 | yedkk/python-datastructure-algorithm | /python basic/basic_GUI.py | 1,161 | 4.5625 | 5 | # This program ask user to give sides and return graph to users
# Author Kangdong Yuan
# import random and turtle
import random
import turtle
t = turtle.Turtle()
# set the function
def makePolygon (sides,length,width,fillColor,angle,borderColor):
# fill the color
t.color(borderColor,fillColor)
t.begin_fill()... | true |
48efb4754266b43608892f0aca35ca015648994b | serapred/algorithms | /sorting/insertion_sort.py | 846 | 4.28125 | 4 | def insertion_sort(collection):
"""
Pure pyton implementation of the insertion sort algorithm
@collection: some mutable collection of unordered items
@returns: same collection in ascending order
time complexity:
- lower bound omega(n)
- average theta(n^2)
- upper bou... | true |
95e19c84d5a8838e3d9fe33f9a47253118acd256 | raysales/treehouse-festival-level-up-your-code | /map.py | 690 | 4.46875 | 4 | # What does it do?
# map() applies a function to an iterable
flowers = ['sunflower', 'daisy', 'rose', 'peony']
# regular loop
plural = []
for flower in flowers:
if flower[-1] == 'y':
plural.append(flower[:(len(flower) -1)] + 'ies')
else:
plural.append(flower + 's')
print(plural)
# map()
def ... | true |
0847e5ba72fca9d6cb7dc07d5e92aa93222cd9aa | mtlam/ASTP-720_F2020 | /HW5/particle.py | 2,678 | 4.125 | 4 | '''
Michael Lam
ASTP-720, Fall 2020
Class to represent a point-mass particle
Also performs the integration
'''
import numpy as np
from coordinate import Coordinate
class Particle:
"""
Class that contains the coordinates and
mass of a point particle
In order to do the integration, it will
also kee... | true |
31c2a5b3138eb55415adefcee51d7ac8ab982c6d | ArahamLag/pyfeb20repo | /script.py | 584 | 4.125 | 4 | import math
def get_number(number):
if isinstance(number, int):
print(" a number was passed to the function")
if number % 2 == 0:
print(' the number is even')
else:
print(' the number is odd')
if number < 0:
print("""the number i... | true |
ec6fa5468bc9a7e951606c74afd906077b3ad7e4 | changsquare/first | /practice8.py | 1,258 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 22 17:12:45 2019
@author: chang2
"""
'''
lambda expression
They are syntactically restricted to a single expression.
Semantically, they are just syntactic sugar for a normal function definition.
Like nested function definitions, lambda functions ... | true |
1ebb051f83721b594e644dfb8ba540d1f10c4f67 | HariAc/python-calculator | /calc.py | 663 | 4.28125 | 4 | operation = input('''
welcome to python calculator
+ for addition
- for subtraction
* for multiplication
/ for division
enter the operation= ''')
num1 = int(input('Enter your first number: '))
num2 = int(input('Enter your second number: '))
if operation == '+':
print('{} + {} = '.format(num1, num2))
print(num... | true |
b1d98614995b6117e1029e008c801d64f54668ca | eldss-classwork/CSC110 | /Creating Modules/oldLady.py | 1,537 | 4.375 | 4 | # Evan Douglass
# HW 8: Children's song, the reprise
# Grade at challenge
'''This module defines several variables and methods used to print the
children's song "There was an Old Lady"'''
# Animals used in the song
ANIMALS = ('fly.', 'spider,', 'bird.', 'cat.',
'dog.', 'goat.', 'cow.', 'horse.')
# A list of the s... | true |
77dd52e0b2643c3982971cd606ae1ba993d8d435 | eldss-classwork/CSC110 | /Creating Modules/oldMcDonald.py | 2,814 | 4.125 | 4 | # Evan Douglass
# HW 8: Children's Songs, the Sequel
# Grade at challenge
'''The oldMcDonald module houses several functions that can be used to write
the children's song "Old McDonald"'''
SOUNDS = []
ANIMALS = []
# Title method
# No parameters
def title():
'Outputs the song title and a blank line'
print('Old ... | true |
73a144d3bf620a3ea9287afd4cb713eb8fd6fab6 | zhangpengGenedock/leetcode_python | /110. Balanced Binary Tree.py | 1,901 | 4.125 | 4 | """
https://leetcode.com/problems/balanced-binary-tree/
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... | true |
7b0811fcdf971e01cbcf0f532fb8a79d1f0c69cb | zhangpengGenedock/leetcode_python | /101. Symmetric Tree.py | 1,750 | 4.25 | 4 | # -*- coding:utf-8 -*-
__author__ = 'zhangpeng'
"""
https://leetcode.com/problems/symmetric-tree/description/
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the fo... | true |
8de2024a2a527db07a59f6ccc1efc09d9980ef70 | zhangpengGenedock/leetcode_python | /695. Max Area of Island.py | 2,409 | 4.1875 | 4 | """Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected
4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
Find the maximum area of an island in the given 2D array. (If there is no island, the maximum area is... | true |
1ff6cf2ba685fc061555a0641b048717b28efe52 | JackLu1/mks66-matrix | /matrix.py | 1,876 | 4.40625 | 4 | """
A matrix will be an N sized list of 4 element lists.
Each individual list will represent an [x, y, z, 1] point.
For multiplication purposes, consider the lists like so:
x0 x1 xn
y0 y1 yn
z0 z1 ... zn
1 1 1
"""
import math
#print the matrix such that it looks like
#the template in the top co... | true |
ee3d3d94e1cf31ae5d554d84c748299cb97f4c43 | esau91/Python | /Problems/leetcode/google_interview.py | 671 | 4.21875 | 4 |
def find_shortest(given_dict):
shortest = {}
iteration = 0
flag = True
while flag:
for key, value in given_dict.items():
key_len = len(key)
if iteration < key_len:
key_subs = key[:iteration]
print(key_subs)
if key_subs no... | true |
231fa24241fc27bc737aa93fc2ca3a6372404d12 | arora-yash/Python-Programming | /jumbled_words.py | 1,853 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 21 07:19:51 2018
@author: yashkumararora
"""
import random
def choose():
words = ['rainbow','computer','science','programming','mathematics','player','condition','reverse','water','board']
pick = random.choice(words)
return pick
def j... | true |
85e0f87adcf9ada348c1d7874fa382c7ac669595 | bflaven/BlogArticlesExamples | /stop_starting_start_stopping/pandas_learning_basics/pandas_learning_basics_1.py | 1,923 | 4.40625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
[path]
cd /Users/brunoflaven/Documents/01_work/blog_articles/stop_starting_start_stopping/pandas_learning_basics/
[file]
python pandas_learning_basics_1.py
# source
- How to use Regex in Pandas
https://kanoki.org/2019/11/12/how-to-use-regex-in-pandas/
"""
import n... | true |
eaa71e3f62af7581cd31fb221f3ca86f9542c253 | ketanAggarwal58/Python | /replaceS.py | 1,153 | 4.40625 | 4 | """
The replace_ending function replaces the old string in a sentence with the new string,
but only if the sentence ends with the old string. If there is more than one occurrence
of the old string in the sentence, only the one at the end is replaced, not all of them.
For example, replace_ending("abca... | true |
e9e5e3c934a033c2ce0a8a1828fa5d33782452fe | ketanAggarwal58/Python | /loops.py | 373 | 4.25 | 4 | print("we have two types of loops in python");
print("1. for loop");
print("2. while loop");
print("this is an example of for loop");
for x in range(10):
print(x);
for y in range(2,10):
print(y);
print("this is an example of while loop");
i = 0;
while i < 7:
print(i);
i += 1;
if i == 5:
... | true |
79880cd75b02737461959fa4e9c4bb4acb946506 | TejshreeLavatre/Basic-Codes | /Check Age.py | 345 | 4.1875 | 4 | #Check whether or not a person is eligible to join the 18-30 club
name = input('Hello, please enter your name: ')
print("Hello {}".format(name))
age = int(input('Please enter your age: '))
if 18 <= age < 31:
print('Welcome to the 18-30 club, {}'.format(name))
else:
print('Sorry, you aren\'t eligible for this h... | true |
bf5284cdd1371fc420383ddc0f5da4791edcdeda | Developernation/codefights | /cfights/python3_solutions/mexFunction.py | 971 | 4.25 | 4 | #You've just started to study impartial games, and came across an interesting theory.
#The theory is quite complicated, but it can be narrowed down to the following statements:
#solutions to all such games can be found with the mex function. Mex is an abbreviation of
#minimum excludant: for the given set s it finds ... | true |
af1e1ba7b841076f8399af7d75881c21b190f55d | Nikilesh-123/Nikilesh-Kammila | /palindromenumber.py | 329 | 4.46875 | 4 | # the palindrome in numeric
# for numeric enter the numeric character
# for example number
number = int(input("enter the string"))
string = str(number)
rev_string= string[: : -1]
print("reversed string:", rev_string)
if string == rev_string:
print("the num is palindrome: ")
else:
print("the num is not a palin... | true |
a794ae5e7412d33dda5acba1daca455fa511a603 | nicolas-git-hub/python-sololearn | /7_Object_Oriented_Programming/magic_methods.py | 1,127 | 4.6875 | 5 | # Magic methods are special methods which have double underscores at the beginning and end of their names.
# They are also known as dunders.
#
# So far, the only one we have encountered is __init__, but there are several others.
#
# They are used to create functionality that can't be represented as a normal method.
#
#... | true |
c5c350e2167cb1271de5f2b3005bdde2d8a15417 | nicolas-git-hub/python-sololearn | /6_Functional_Programming/map.py | 620 | 4.375 | 4 | # The built-in function map an filter are very useful higher-order functions that operate
# on lists (or similar objects called iterables).
# The function map takes a function and an iterable as arguments, and returns a new iterable
# with the function applied to each argument.
#
# Example:
def add_five(x):
return... | true |
948433a5b39c9350d3ce26f72baa2c44872bd9ba | nicolas-git-hub/python-sololearn | /5_More_Types/none.py | 883 | 4.375 | 4 | # The "None" object is used to represent the absence of a value.
# It is similar to null in other programming languages.
# Like other "empty" values, such as (), [] and the empty string,
# it is "False" when converted to a "Boolean variable".
# When entered at the Python console, it is displayed as the empty string.
p... | true |
dad02800e2723cc1ef2ffdcef944ac63361c0514 | nicolas-git-hub/python-sololearn | /6_Functional_Programming/recursion.py | 1,782 | 4.5625 | 5 | # Recursion is a very important concept in functional programming.
# The funcdamental part of recursion is self-reference - function calling themselves.
# It is used to solve problems that can be broken up into easier sub-problems of the same type.
#
# A classic example of a function that is implemented recursively is ... | true |
659a5e141cc44c7e9f530bf103df12e6ddf1f0f5 | nicolas-git-hub/python-sololearn | /6_Functional_Programming/functional_programming.py | 1,836 | 4.4375 | 4 | # Functional programming is a style of programming that (as the name suggests) is
# based around functions.
# A key part of functional programming is higher-order functions. We have seen this idea
# briefly in the previous lesson on functions as objects.
# Higher-order functions take other functions as arguments, or re... | true |
ac68e238a4ad576c4fd33580a9e28f8828ba30e8 | btranscend/numericalIntegration | /polynomial.py | 2,936 | 4.28125 | 4 | #!/usr/bin/python3
import unittest
class Polynomial(object):
# Constructor where the object
# is the degree of a given polynomial
def __init__(self, degree):
self.degree = degree
self.coef = []
# Constructor where the object is
# are the coefficients of a given polynomial
def setCoef(self, coef):... | true |
e67547d2156ec0a913d048b4643ad6b1d8b380aa | pankaj-pundir/The-projects | /dexterous/3danim_example.py | 2,576 | 4.40625 | 4 | """
============
3D animation
============
A simple example of an animated plot... In 3D!
"""
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import matplotlib.animation as animation
def Gen_RandLine(length, dims=2):
"""
Create a line using a random walk algorithm
... | true |
54cd3f14708ee889f563c0f84c0817f69857a451 | eeyoo/python | /src/function.py | 742 | 4.28125 | 4 | #! /usr/bin/python
# function without return statement
def fib(n):
"""Print a Fibonacci series up to n."""
a,b = 0, 1
while a < n:
print a,
a, b = b, a+b
# call fib function
print 'fib(2000)'
raw_input('press any to continue...')
fib(2000)
# assign fib to another name
f = fib
print '\nfib(... | true |
391b35097d6ff5d3f4194f27dcf0bfdc7d9587c5 | Philip-Loeffler/python | /SectionTen/OOPandClassesPT2.py | 1,556 | 4.46875 | 4 | # this section is entitled "instances, constructors, sets and more"
# class: template for creating obects. all objects created using the same class will have the same characterists
# object: an instance of a class
# instantiate: create an instance of a class
# method: a function defined in a class
# attribute: a variab... | true |
1831cdeeb37ef3058db155431c00059a138ad5f3 | Philip-Loeffler/python | /SectionFour/nestedForLoops.py | 323 | 4.21875 | 4 | for i in range(1, 13):
for j in range(1, 13):
print("{0} times {1} is {2}".format(j, i, i * j))
print("--------------")
# first loop runs 1 time, then inner loop will run all the way through
# then come back to the outer loop, which then again but incremented one time
# and inner loops runs through ful... | true |
8d6be190063a8dbbcc4cb9637db8801429a2e676 | Philip-Loeffler/python | /SectionFive/sortingList.py | 576 | 4.6875 | 5 |
even = [2, 4, 6, 8]
odd = [1, 3, 5, 7, 9]
# extend will combine and add all of the iterables from the list and adds them to it
even.extend(odd)
print(even)
# sort will sort the sequence of numbers
# sort method doesnt create a copy of the list, it rearranges the items of the list
# lists are mutable and their conten... | true |
3dc389c7dadea1293fd13bdc0127a166e9815867 | Philip-Loeffler/python | /SectionFour/in&NotInConditions.py | 468 | 4.15625 | 4 | parrot = "Norweigian blue"
letter = input("enter a character: ")
# checking to see if a letter is in parrot
if letter in parrot:
print("{} is in {}".format(letter, parrot))
else:
print("i dont need that letter")
# here is using not
activity = input("What would you like to do today ")
# checking to see if ... | true |
8313c2cf9fe5a1c478d690ddad54cdb7d459c56c | Philip-Loeffler/python | /SectionFive/nestedLists.py | 815 | 4.3125 | 4 | empty_list = []
even = [2, 4, 6, 8]
odd = [1, 3, 5, 7, 9]
numbers = [even, odd]
# this will print out [[2,4,6,8], [1,3,5,7,9]]
# you have a list within a list
print(numbers)
# will create the 2 seperate lists and print them out
for number_list in numbers:
print(number_list)
# will print out the values inside thos... | true |
cc96e31133f2e20a9563adc61c970b233fb1e010 | perrym6949/CTI110 | /P3HW1_Debugging_Perry.py | 580 | 4.1875 | 4 | # System Grading Output
# 3/23/2021
# CTI-110 P3HW1-Debugging
# Madelyn Perry
#
def main():
# Program takes number grade and outputs letter grade.
# Use 10-point grading scale:
A = 90
B = 80
C = 70
D = 60
F = 50
score = input('Please input your grade: ')
Grd = int(score) # Grd <-... | true |
78cd91b1ab16e08d3057757ed6e47960d6eafeee | steve-yuan-8276/pythonScrapy | /practiceFolder/ComputerProgrammingforKids/area_or_perimeter.py | 538 | 4.3125 | 4 | length = int(input("Please input the length(cm): "))
width = int(input("Please input the width(cm): "))
def area_of_the_rectangle(length, width):
area_of_the_rectangle = length * width
return area_of_the_rectangle
def perimeter_of_the_rectangle(length, width):
perimeter_of_the_rectangle = (length + width)... | true |
b5f319cd9f4748295a89f14c6090a51fd10a93a2 | TheShrug/Advent-of-Code | /day2/day-2-1.py | 791 | 4.21875 | 4 | def contains_count_of_any_letter(string, count):
""" Returns bool of whether or not the provided
string contains count number of any unique letter.
This could be optimized further to prevent unnecessary
processing.
:param string:
:param count:
:return bool:
"""
for char in string:
... | true |
4fb3c69cf7196c8cd8251eb5b46e6a98fdfc27da | emmanuelrobles/School | /Python/Harvard/Assigment 5/pairs.py | 1,749 | 4.125 | 4 | """
1) Using the English DictionaryPreview the documentView in a new window that Downey provides, find all words in the dictionary whose reverse is also in the dictionary. There are about 500 such unordered pairs: build a list with each pair appearing once in alphabetic order. Your list should start with the pair ('... | true |
11ebd324957354748a4cc483fb8bb74075c68556 | COrtaDev/Data-Structures-and-Algorithms | /HackerRank/InterviewPrep/ProblemSolving/theMaximumSubArray/maxSubArr.py | 2,451 | 4.1875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the maxSubarray function below.
def maxSubarray(arr):
# the subarray will be a slice of the array where all elements are contiguous
# the subsequence however are elements that are non contiguous
# we observe that if all ele... | true |
9bcfb99ff91f61a3e715e030072624156317acc9 | candiepih/alx-higher_level_programming | /0x0C-python-almost_a_circle/models/square.py | 1,499 | 4.15625 | 4 | #!/usr/bin/python3
"""Contains `Square` class defination"""
from .rectangle import Rectangle
class Square(Rectangle):
"""Class inherits from `Rectangle` class"""
def __init__(self, size, x=0, y=0, id=None):
"""Initializes instance attributes
Args:
size (int): size of rectangle
... | true |
8a452b2ec4376064b51e01e191cc92a38c64d263 | candiepih/alx-higher_level_programming | /0x06-python-classes/2-square.py | 622 | 4.46875 | 4 | #!/usr/bin/python3
"""Represent a square class"""
class Square:
"""Derives a square """
def __init__(self, size=0):
"""Initializes the data
Args:
size (int): size of the square
Note:
Do not include the `self` parameter in the ``Args`` section.
Raises:
... | true |
37ec3b0724e970e6b7e9cb5f2af524fc2985f1db | keertanaganiga/Lockdown_coding | /reverse.py | 298 | 4.21875 | 4 | '''
Reverse words in a given String in Python We are given a string and we need to reverse words of given string ?
Examples:
Input :
str = "AIET CHALLENGES IIT"
Output :
str = "IIT CHALLENGES AIET"
'''
str1="AIET CHALLENGES IIT"
print(str1[::-1])
'''
another solution:
str1=input()
print... | true |
cea99b8e2289e57e6de606356ef75d8cdc862f24 | gishbg/my_pynet | /CL1ex7.py | 850 | 4.375 | 4 | #!/usr/bin/env
"""
7. Write a Python program that reads both the YAML file and the JSON file created in exercise6 and pretty prints the data structure that is returned.
"""
from __future__ import print_function, unicode_literals
import yaml
import json
from pprint import pprint
def output_format(my_list, file_type)... | true |
259c1a81fdc5a7e7b731daf4a6aab6dba03dc649 | SonikaVashistha/python-practice | /basics/com/shanu/Circle.py | 370 | 4.21875 | 4 | from math import pi
r=2
# area of circle up to 2 decimal places
print("Area of circle with radius", str(r), "is", round(pi*r**2,2))
# area of circle up to 4 decimal places
print("Area of circle with radius", str(r), "is", '%.4f'%(pi*r**2))
# circumference of circle upto 2 decimal places
print("Circumference of the c... | true |
87cff0de5eafdf4641444a16a7273a6697a087b8 | SteffiBaumgart/Computer_Science_1 | /pairs.py | 553 | 4.21875 | 4 | #uses a recursive function to count the number of pairs of repeated characters in a string. Pairs of characters cannot overlap.
# Steffi Baumgart
# 1 May 2015
def main():
message = input("Enter a message: \n")
print("Number of pairs: " + pair(message, 0))
def pair (message, count):
if len(... | true |
43d42ae79ca535deb5c4ccede2474f6ee83bcf48 | everbird/leetcode-py | /2013/convert-sorted-list-to-binary-search-tree.py | 1,554 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
class ListNode(object):
next = None
value = 0
def __init__(self, value, next=None):
self.value = value
self.next = next
class TreeNode(object):
left = None
right = None
value = 0
depth = 0
def __init__(self, value, left=... | true |
aecae5acc5d8ddd02c2667c69ee53a1fa50606e8 | SinghJitender/Python | /Hackerrank/lists.py | 1,676 | 4.46875 | 4 | '''
Consider a list (list = []). You can perform the following commands:
insert i e: Insert integer at position .
print: Print the list.
remove e: Delete the first occurrence of integer .
append e: Insert integer at the end of the list.
sort: Sort the list.
pop: Pop the last element from the list.
reverse: Reverse t... | true |
ed5d56877cb4be73f548bf20c5d0ee72715f2190 | SinghJitender/Python | /ControlFlowStatements/ForLoop.py | 449 | 4.3125 | 4 | # For iterating over the elements
list =[1,2,3,4,5,6,7,8,9,10]
for num in list:
print(num)
str = "This is a string"
for letter in str:
print(letter,end='_')
# tuple unpacking
list =[(1,2),(3,4),(5,6),(7,8)]
for tuple in list:
print(tuple)
for a,b in list:
print(a)
print(b)
d={'k1':1,'k2':2,'k3':... | true |
94ecf79c8b7d707aceab8db8a4c0a4c45ac5b8f8 | SinghJitender/Python | /ObjectsAndDataStructures/ListAndDictionary.py | 1,431 | 4.21875 | 4 | # list are similar to arrays in python. they can hold any type of data and supports indexing and slicing function juts as string
list = [1,2,3,4,5]
print(list)
list = ["one","two",'three']
print(list)
list = ["One",120,133.45]
print(list)
list = [1,2,3,4,5]
print(list[0]) # items at index - 0
print(list[1:]) # All ite... | true |
2d2739e330eab90653f90240664d2c3940ed10fc | SinghJitender/Python | /MethodsAndFunctions/LambdaExpression.py | 720 | 4.46875 | 4 | # map() and filter()
# lambda expression are anonymous functions
# map() is used to map each item in the list to the given function and returns a list
def sqrt(num):
return num**2
mylist = [1,2,3,4,5]
print(list(map(sqrt,mylist)))
#filter() can be used to filter the list based upon a condition
def check_len(str):... | true |
c11398aadb3f3da34439229f95449f0f01087330 | ncrowder/python-programming-edX | /assignment3.py | 1,858 | 4.1875 | 4 | # This function accepts a 2-dimensional list of characters (like a crossword puzzle) and a string (word) as input arguments.
# It searches the rows and columns of the 2d list to find a match for the word.
# If a match is found, this functions capitalizes the matched characters in 2-dimensional list and returns the li... | true |
5a00cec088a18c1dcf20908b1817e5cd08e6f189 | raferti/code_war | /recover_secret_string_from_random_triplets.py | 1,977 | 4.125 | 4 | """
There is a secret string which is unknown to you. Given a collection of
random triplets from the string, recover the original string.
A triplet here is defined as a sequence of three letters such that each
letter occurs somewhere before the next in the given string. "whi" is a
triplet for the string "whatisup".
... | true |
e0fc6db597a2366baa0fd1f924ef2434e32f1410 | raferti/code_war | /calculator.py | 1,395 | 4.40625 | 4 | """
Create a simple calculator that given a string of operators (), +, -, *, /
and numbers separated by spaces returns the value of that expression
Example:
Calculator().evaluate("2 / 2 + 3 * 4 - 6") # => 7
Remember about the order of operations! Multiplications and divisions have
a higher priority and should be per... | true |
5df0a3355c0c64bddb283a5908f95b6f304eaea0 | AfanasAbigor/Python_Basic | /GUI_Turtle_Race.py | 1,412 | 4.1875 | 4 | from turtle import Turtle, Screen
import random
screen = Screen()
screen.setup(width=500, height=500) #Set height & width of Screen
screen.bgcolor("black") #change BackGround Color
line = Turtle("turtle")
line.goto(250, 250)
line.color("white")
line.right(90)
line.forward(500)
user_bet = screen.textinput(title="Mak... | true |
b9c93ccdc24fee371cb9a0e2da8de6c0c71bdab8 | mateuspadua/design-patterns | /creational/singleton/refactoring-guru.py | 1,375 | 4.3125 | 4 | from typing import Optional
class Singleton:
"""
The Singleton class defines the `getInstance` method that lets clients
access the unique singleton instance.
"""
_instance: Optional = None
def __init__(self) -> None:
if Singleton._instance is not None:
raise ReferenceErro... | true |
2e27d73c47bd768f5c78a156a4db813ffc2a2fbd | mateuspadua/design-patterns | /advanced_python_topics/inheritance.py | 1,028 | 4.25 | 4 |
class Pet:
""" Base class for all pets """
def __init__(self, name, species):
self.name = name
self.species = species
def get_name(self):
return self.name
def get_species(self):
return self.species
def __str__(self):
return '{} is a {}'.format(self.name, s... | true |
9fce218f362efcd12371809d4ace99df88e07e2e | mateuspadua/design-patterns | /creational/abstract_factory/udemy.py | 1,732 | 4.1875 | 4 | """
Provide an interface for creating
families of related objects without
specifying their concrete classes.
"""
# abstract classes (interfaces)
class Shape2DInterface:
def draw(self):
raise NotImplementedError()
class Shape3DInterface:
def build(self):
raise NotImplementedError()
# conc... | true |
e0f66b5ac2b3136a38a93187e8a4732d83f744f6 | apurva13/assignment-2 | /answer3.py | 249 | 4.3125 | 4 | #Take the input of 3 variables x, y and z . Print their values on screen.
x=int(input('enter value of x:'))
y=int(input('enter value of y:'))
z=int(input('enter value of z:'))
print ('Value of x:',x)
print ('Value of y:',y)
print ('Value of z:',z)
| true |
966665af55225f40fdd4da19c28dd883a43f62ff | davidknoppers/holbertonschool-higher_level_programming | /0x0B-python-input_output/4-append_write.py | 367 | 4.1875 | 4 | #!/usr/bin/python3
"""
One function in this module
append_write opens a file and appends some text to it
"""
def append_write(filename="", text=""):
"""
open file
put some text at the end of it
close that file
"""
with open(filename, mode='a', encoding="utf-8") as myFile:
chars_written... | true |
b34422e86b7dab5bb5166bc8f2db81eae755310f | davidknoppers/holbertonschool-higher_level_programming | /0x06-python-test_driven_development/5-text_indentation.py | 563 | 4.21875 | 4 | #!/usr/bin/python3
"""
text_indentation - inserts newline into a text
Requires a str input, otherwise raises errors
Prints the result, no return value
"""
def text_indentation(text):
"""
Adds newlines to a string based on sep, and prints it
"""
if text is None or not isinstance(text, str) or len(text)... | true |
2ffd661c6dd804ab70294c05204bc7a5fe835a1b | davidknoppers/holbertonschool-higher_level_programming | /0x07-python-classes/100-singly_linked_list.py | 2,312 | 4.125 | 4 | #!/usr/bin/python3
"""
Implementation of a basic singly linked list in Python
Sorted lowest to highest by node value
Offers basic print function
"""
class Node(object):
"""
creates node with next set to None as default
"""
def __init__(self, data, next_node=None):
if type(data) is not int or i... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.