blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
6113013b9935b8862a5298c340613568329f9080 | coltonneil/IT-FDN-100 | /Assignment 8/Banking.py | 1,294 | 4.5625 | 5 | #!/usr/bin/env python3
"""
requires Python3
Script defines and creates a "bank account" which takes an initial balance and allows users to withdraw, deposit, check
balance, and view transaction history.
"""
# define class Account
class Account:
# initialize account with balance as initial, create empty transact... | true |
6a89874f05bb0c6f201b60f9d682fae6be3b07d5 | coltonneil/IT-FDN-100 | /Assignment 5/hw5.py | 2,557 | 4.15625 | 4 | import string
"""
This script reads in a file, parses the lines and creates a list of words from the lines
Calculates the word frequency
Gets the word with the maximum frequency
Gets the minimum frequency and a list of words with that frequency
Calculates the percentage of words that are unique in the file and prints ... | true |
5dcb6b3a1ae292cd38048b560d0d4c7639aedffd | elliebui/technical_training_class_2020 | /data_structures/week_2_assignments/list_without_duplicate.py | 595 | 4.3125 | 4 | """
Write a function that takes a list and returns a new list that contains all the elements of the first list
minus all the duplicates. The order should remain the same.
"""
def get_list_without_duplicate(input_list):
new_list = []
for item in input_list:
if item not in new_list:
new_list... | true |
89c5b83a6b8cb4bb8ccb405dbee0511cb1263baf | figengungor/Download-EmAll | /500px.py | 816 | 4.15625 | 4 | #Author: Figen Güngör
#Year: 2013
#Python version: 2.7
################ WHAT DOES THIS CODE DO? ##############################
#######################################################################
###############Download an image from 500px############################
##############################################... | true |
defeadae77a82c2f897efa0d84653ebe0f199d31 | wassen1/dbwebb-python | /kmom10/prep/analyze_functions.py | 978 | 4.1875 | 4 | """
Functions for analyzing text
"""
# text = "manifesto.txt"
def read_file(filename):
"""
Returns the file from given filename
"""
with open(filename) as fh:
return fh.read()
def number_of_vowels(filename):
"""
Calculate how many vowels a string contains
"""
content = read_file... | true |
0fefdd08af95b8b6e671a8507102e34362e83c5c | Octaith/euler | /euler059.py | 2,785 | 4.21875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107.
A modern encryption method is to take a text file, ... | true |
012dc26cf8d7b28a0764bc4a3df1cda6c4f772f6 | samullrich/crawl_project | /queueADT.py | 478 | 4.125 | 4 | class QueueADT:
def __init__(self):
self.container = []
self.the_queue = []
#self.visited = [starting_node]
def push(self, value): # First item is at front of the list/index 0
self.container.append(value)
def pop(self):
return self.container.pop(0) # Ho... | true |
37e893393b4b18703ea2849ee396910eb12950f1 | GitError/python-lib | /Learn/Udemy/decorators.py | 1,214 | 4.5625 | 5 | """
Intro to decorators
"""
# decorator - adding additional functionality on the runtime
# commonly used in web frameworks such as flask and django e.g. routing etc.
# @ is used to declare decorators
# returning a function from within a function
def func():
print('upper function')
def func2():
print... | true |
0afbfb4deb70181e4ea434f63c3d4968fb3aa332 | dikshit22/PathaPadha-Python-DS-P-1 | /Assignment-3/1. Making String From String.py | 543 | 4.40625 | 4 | #Program to get a string made of the first 2 and the last 2 chars from a given
#string. If the string length is less than 2, print 'empty string'.
string = input("Enter a string:\t")
if(len(string) >= 2):
newstr = string[:2]+string[-2:]
print("\tThe new string is:", newstr)
else:
print("\tEmpty strin... | true |
a170005cece2a46858802ec6ecbef9c4e2fdf8e8 | dikshit22/PathaPadha-Python-DS-P-1 | /Assignment-4/1. Highest In List.py | 311 | 4.40625 | 4 | #Program to find the highest element in a list
l = eval(input('Enter the list: '))
h = l[0]
for i in l:
if(i > h):
h = i
print('\tThe highest element in the list is:', h)
'''
OUTPUT
Enter the list: [1, 4, 2, 6, 3, 5, 9, 7, 8]
The highest element in the list is: 9
'''
| true |
d689b639f06393b670f5b1e4b08bd0eeaa534efd | dikshit22/PathaPadha-Python-DS-P-1 | /Assignment-3/2. Adding 'ing' Or 'ly'.py | 670 | 4.5 | 4 | #Program to add 'ing' at the end of a given string (length should be at least 3).
#If the given string already ends with 'ing' then add 'ly' instead. If the
#string length of the given string is less than 3, leave it unchanged.
string = input("Enter a string:\t")
if(len(string) >= 3):
if(string[-3:] != 'ing')... | true |
8244082d74426f04bcd25d8f0013cf8d4f7a94fb | ramkishor-hosamane/Coding-Practice | /Optum Company/11.py | 469 | 4.21875 | 4 | '''
In a given String return the most frequent vowel coming.
'''
def most_frequent_vowel(string):
string = string.lower()
hashmap = {'a':0,'e':0,'i':0,"o":0,"u":0}
for letter in string:
if hashmap.get(letter)!=None:
hashmap[letter]+=1
max_freq = 0
max_freq_vowel = None
for letter in hashmap:
if hashmap[l... | true |
390cd4a7fe778a936274eea5cad6e0022a61c2a8 | ramkishor-hosamane/Coding-Practice | /Optum Company/3.py | 620 | 4.1875 | 4 | '''
3. Find the middle element of the linked lists in a single pass (you can only traverse the
list once).
'''
class Node:
def __init__(self,val=None):
self.data = val
self.next = None
class Linked_List:
def __init__(self):
self.head = None
def insert(self,val):
cur = self.head
if cur==None:
self.he... | true |
deac09987b6d4f6ea09c2806efdf36a55fc63729 | rookiy/Leetcode | /SymmetricTree_3th.py | 1,300 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# 使用迭代。分别访问对称的节点。
class Solution:
# @param {TreeNode} root
# @return {boolean}
def isSymmetric(self, root):
if not root:
return... | true |
c9f6c5e7e26087552034fe851306c1e43485d163 | SabastianMugazambi/Word-Counter | /act_regex3.py | 1,271 | 4.6875 | 5 | # Regular expressions activity III
# Learning about regex match iterators.
import re
def main():
poem = readShel()
printRegexMatches(r'.\'.', poem)
def readShel():
'''Reads the Shel Silverstein poem and returns a string.'''
filename = 'poem.txt'
f = open(filename,'r')
poem = f.read()
f.cl... | true |
e1a8dba62fe06205d1dd1cfa8262c45d51449439 | yuvrajschn15/Source | /Python/14-for_loop.py | 341 | 4.65625 | 5 | # to print from 1 to 20 we can use print statement for 20 times or use loops
# range is used to define the range(kinda like limit) of the for loop
print("this will print from 0 to 19")
for i in range(20):
print(i, end=" ")
print("\n")
print("this will print from 1 to 20")
for j in range(20):
print(j + 1, e... | true |
7d00cae2fdac22e0ce5c78c67fcc7844cb608c32 | vinayakgaur/Algorithm-Problems | /Split a String in Balanced Strings.py | 784 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 18 10:32:00 2021
@author: VGaur
"""
#Balanced strings are those who have equal quantity of 'L' and 'R' characters.
#Given a balanced string s split it in the maximum amount of balanced strings.
#Return the maximum amount of splitted balanced stri... | true |
280804ce0568b0e832b2ed3a530d475d2a919332 | martvefun/I-m-Human | /CustomError.py | 1,395 | 4.25 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
class Error(Exception):
"""Base class for exceptions"""
pass
class InputError(Error):
"""Exception raised for errors in the input.
Attributes:
expr -- input expression in which the error occurred
msg -- explanation of the error
"""
... | true |
39f9d0b9f3d60ce8f55ccb09bfdaa58da9db8166 | NileshNehete/Learning_Repo | /Python_Pro/Python_if-else.py | 1,048 | 4.125 | 4 | # Enter tree numbers and print the biggest and lowest number
num1 = input("Enter First Number :")
num2 = input("Enter Second Number :")
num3 = input("Enter Third Number :")
if (( num1 > num2 ) and ( num1 > num3 )):
print ("First number %d is the biggest number" %num1)
if ( num2 > num3 ):
print ("Third... | true |
b88a5762d830799a96266825de4ebabb7ab2ec65 | arensdj/snakes-cafe | /snakes_cafe.py | 2,198 | 4.40625 | 4 | # data structures containing lists of the various menu items and customer name
appetizers = ['Wings', 'Cookies', 'Spring Rolls']
entrees = ['Salmon', 'Steak', 'Meat Tornado', 'A Literal Garden']
desserts = ['Ice Cream', 'Cake', 'Pie']
drinks = ['Coffee', 'Tea', 'Unicorn Tears']
customer_name = input("Please enter your... | true |
310bf320e2e333e36cda462a8d4dbbd38faf8fe5 | bragon9/leetcode | /21MergeTwoSortedListsRecursive.py | 1,252 | 4.125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
if not(l1) and not(l2):
return None
if not(l1):
return l2
... | true |
185f85d5d9a23e9b2eaa2e03f1069e0884823f30 | leonhostetler/undergrad-projects | /numerical-analysis/12_matrices_advanced/givens_rotation_matrix.py | 1,251 | 4.21875 | 4 | #! /usr/bin/env python
"""
Use Givens rotation matrices to selectively zero out the elements of a matrix.
Leon Hostetler, Mar. 2017
USAGE: python givens-rotation-matrix.py
"""
from __future__ import division, print_function
import numpy as np
n = 3 # Size of matrix
A = np.array([(1, 2, 0),
(1, 1, 1... | true |
f7f22d37ce06b19e8c501540460a956c402d53c4 | leonhostetler/undergrad-projects | /computational-physics/04_visual_python/newtons_cradle_damped.py | 1,612 | 4.40625 | 4 | #! /usr/bin/env python
"""
Shows an animation of a two-pendulum newton's cradle. This
program shows only the spheres--think of the pendulum rods as being invisible.
Additionally, this program features a damping parameter mu = 0.11 such that the motion
decays to zero in approximately 12 collisions.
Leon Hostetler, Feb... | true |
3cf2c99c7e05ef76b41823e28b68c940753cd1fe | leonhostetler/undergrad-projects | /computational-physics/11_classes/rectangles.py | 1,370 | 4.59375 | 5 | #! /usr/bin/env python
"""
Defines a Rectangle class with two member variables length
and width. Various member functions, such as area and perimeter, are
defined, and the addition operator is overloaded to define rectangle addition.
Leon Hostetler, Mar. 30, 2017
USAGE: python rectangles.py
"""
from __future__ impor... | true |
226bd859ee5daa32acaec0afe3d6de4539c708e4 | leonhostetler/undergrad-projects | /computational-physics/09_integration_modular/hypersphere_volume.py | 1,233 | 4.46875 | 4 | #! /usr/bin/env python
"""
Compute the volume of an n-dimensional hypersphere
using the Monte Carlo mean-value method.
The volume is computed for hyperspheres with dimensions from 0 to 12
and plotted.
Leon Hostetler, Mar. 7, 2017
USAGE: python hypersphere_volume.py
"""
from __future__ import division, print_functio... | true |
d9b906bd062339dcbf45944dc6c5f6f7f3c3e033 | leonhostetler/undergrad-projects | /computational-physics/03_plotting/polar_plot.py | 659 | 4.15625 | 4 | #! /usr/bin/env python
"""
Plot a polar function by converting to cartesian coordinates.
Leon Hostetler, Feb. 3, 2017
USAGE: polar_plot.py
"""
from __future__ import division, print_function
import numpy as np
import matplotlib.pyplot as plt
# Main body of program
theta = np.linspace(0, 10*np.pi, 1000) # The valu... | true |
d6be4afe4ab27720853d615d1b0cc2578e753704 | jazzlor/LPTHW | /ex4.py | 685 | 4.15625 | 4 | name = 'Jazzy'
age = 36 # not a like
height = 54 # inches
weight = 200 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
cm = 2.54 #single cm
kg = 0.453592 #singl kg
print(f"Let's talk about {name}.")
print(f"She's {height} inches tall")
print(f"She's {weight} pounds heavy")
print(f"Actually that's not too heavy.")
... | true |
6faaf0768daada7527f0b0f31abbb7cfa2e8c6f2 | d3m0n4l3x/python | /file_io.txt | 876 | 4.21875 | 4 | #!/usr/bin/python
#https://www.tutorialspoint.com/python/file_methods.htm
#Open a file
fo = open("foo.txt", "r+")
print "Name of the file: ", fo.name
print "Closed or not : ", fo.closed
print "Opening mode : ", fo.mode
print "Softspace flag : ", fo.softspace
'''
Name of the file: foo.txt
Closed or not : False
Openin... | true |
07fb525464c530a2d0c4e9a16560e2dc0ab98e29 | Amenable-C/software-specialLectureForPython | /ch005.py | 202 | 4.1875 | 4 | num1 = int(input("What is the first number?"))
num2 = int(input("What is the second number?"))
num3 = int(input("What is the third number?"))
answer = (num1 + num2) * num3
print("The answer is", answer) | true |
1247bf7c34fc646e011f35d599dc229427980cc2 | brianramaswami/NLP | /PROJECT2/proj2.py | 2,586 | 4.375 | 4 | #Brian Ramaswami
#bramaswami@zagmail.gonzaga.edu
#CPSC475
#Project2 types of substring searches.
'''
GO TO MAIN AND SELECT WHICH PROGRAM TO RUN
'''
import sys
'''
HELPER FUNCTIONS
'''
def readInFile(fileName):
f = open(fileName, "r")
print(f.read())
'''
OPENS FILE TO READ IN CONTENT
'''
def my_open():
pri... | true |
c290eac1e0eb4f0aeb77ebeb2cbc8857bfdae226 | becerra2906/jetbrains_academy | /airmile/air_mile_calculator.py | 1,901 | 4.625 | 5 | ### By: Alejandro Becerra
#done as part of Jet Brains Academy Python learning Path
#serves to calculate the number of months required to pay for a
#flight with miles generated with customer credit card purchases.
#print welcome message
print("""Hi! Welcome to your credit card miles calculator.
This program will he... | true |
9e914e1d5f56cd6079bad7b3f3c5cbdb148778f9 | team31153/test-repo | /Aaryan/Chapter5HW/C5Problem2.py | 597 | 4.15625 | 4 | #!/usr/bin/env python3
def daysOfTheWeek(x):
if x == 0:
return("Sunday")
elif x == 1:
return("Monday")
elif x == 2:
return("Tuesday")
elif x == 3:
return("Wednesday")
elif x == 4:
return("Thursday")
elif x == 5:
return("Friday")
elif x == 6:
return("Saturday")
e... | true |
373a78cc034227556576c08d4af934dde44ea391 | team31153/test-repo | /Ryan/RyanChapter5HW/10findHypot.py | 312 | 4.125 | 4 | #!/usr/bin/env python3
firstLength = int(input("Enter the length for the first side: "))
secondLength = int(input("Enter the length for the second side: "))
hypot = 0
def findHypo(f, s, h):
f2 = f * f
s2 = s * s
h = f2 + s2
h = h ** 0.5
print(h)
findHypo(firstLength, secondLength, hypot)
| true |
e86b9c57eb5c8577ca8fe42015584dbb9bdef94a | leemiracle/use-python | /taste_python/cook_book/files_io.py | 855 | 4.75 | 5 | # 1. Reading and Writing Text Data
# 2. Printing to a File
# 3. Printing with a Different Separator or Line Ending
# 4. Reading and Writing Binary Data
# 5. Writing to a File That Doesn’t Already Exist
# 6. Performing I/O Operations on a String
# 7. Reading and Writing Compressed Datafiles
# 8. Iterating Over Fixed-Siz... | true |
ccf258949439b444ead45f58513ba3e91e60b19d | fiolisyafa/CS_ITP | /01-Lists/3.8_SeeingTheWorld.py | 477 | 4.15625 | 4 | places = ["London", "NYC", "Russia", "Japan", "HongKong"]
print(places)
#temporary alphabetical order
print(sorted(places))
print(places)
#temporary reverse alphabetical order
rev = sorted(places)
rev.reverse()
print(rev)
print(places)
#permanently reversed
places.reverse()
print(places)
#back to original
places.reve... | true |
8c03b0bc52759815166152c93555c912f05482ca | fiolisyafa/CS_ITP | /03-Dictionaries/6.11_Cities.py | 733 | 4.1875 | 4 | cities = {
"Canberra": {
"country": "Australia",
"population": "6573",
"fact": "Capital city but nothing interesting happens."
},
"London": {
"country": "England",
"population": "5673",
"fact": "Harry Potter grew up here."
},
"Jakarta": {
... | true |
79268b3094c685df6c9471c733c92f4ac1a059bb | Br111t/pythonIntro | /pythonStrings.py | 2,022 | 4.65625 | 5 |
string_1 = "Data Science is future!"
string_2 = "Everybody can learn programming!"
string_3 = "You will learn how to program with Python"
#Do not change code above this line
# #prints the length of the string including spaces
# print(len(string_2))
# #Output: 32
# #print the index of the first 'o'; the ind... | true |
a953212a542bde4920cd0361dc18769538bb4bfb | sridivyapemmaka/PhythonTasks | /dictionaries.py | 419 | 4.15625 | 4 | #dictonaries methods()
#clear()
"removes all the elements from the list"
list1={1:"sri",2:"java",3:"python"}
list2=list1.clear()
print(list1)
output={}
#copy()
"returns a copy of the list"
list1={1,2,3,4}
list2=list1.copy()
print(list2)
output={1,2,3,4}
#get()
"returns the values of the specified li... | true |
bd2aa8788af65e20d7b261860e66a02635de5ff8 | zssvaidar/code_py_book_data_structures_and_algo | /chap03_recursion/reverse_list_another_way.py | 568 | 4.21875 | 4 | from typing import List
IntList = List[int]
def reverse_list(l: IntList) -> IntList:
"""Reverse a list without making the list physically smaller."""
def reverse_list_helper(index: int):
if index == -1:
return []
rest_rev: IntList = reverse_list_helper(index - 1)
first: ... | true |
ecbfb19bb09dd71d1a832dbbf71553cf306cacdd | zssvaidar/code_py_book_data_structures_and_algo | /chap04_sequences/stack.py | 1,123 | 4.21875 | 4 | class Stack:
"""
Last in, first out.
Stack operations:
- push push the item on the stack O(1)
- pop returns the top item and removes it O(1)
- top returns the top item O(1)
"""
def __init__(self):
self.items = []
... | true |
d712835020e89a2909bfaf1c6d8c01be181be89a | Marcus893/algos-collection | /cracking_the_coding_interview/8.1.py | 390 | 4.15625 | 4 | Triple Step: A child is running up a staircase with n steps and can hop either 1 step, 2 steps, or 3
steps at a time. Implement a method to count how many possible ways the child can run up the
stairs.
def triple_step(n):
lst = [0] * (n+1)
lst[0] = 1
lst[1] = 1
lst[2] = 2
for i in range(3, n+1):... | true |
06c573fce10ea205d810c7d62e86681a29554d7f | Marcus893/algos-collection | /cracking_the_coding_interview/4.6.py | 737 | 4.15625 | 4 | Successor: Write an algorithm to find the "next" node (i.e., in-order successor) of a given node in a
binary search tree. You may assume that each node has a link to its parent.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
self.parent = None... | true |
8ed0786f818d82c26edc14d46b405b7c602fafc2 | Marcus893/algos-collection | /cracking_the_coding_interview/2.4.py | 1,080 | 4.34375 | 4 | Partition: Write code to partition a linked list around a value x, such that all nodes less than x come
before all nodes greater than or equal to x . lf x is contained within the list, the values of x only need
to be after the elements less than x (see below) . The partition element x can appear anywhere in the
"right ... | true |
2c00d4fb1a570e9d053eb1e9283ecea2c343e48b | Marcus893/algos-collection | /cracking_the_coding_interview/3.5.py | 505 | 4.125 | 4 | Sort Stack: Write a program to sort a stack such that the smallest items are on the top. You can use
an additional temporary stack, but you may not copy the elements into any other data structure
(such as an array). The stack supports the following operations: push, pop, peek, and isEmpty.
def sortStack(stack):
re... | true |
023986d7eda3cad02f6a783dd88764eb1a939cf6 | s3icc0/Tutorials | /DBTut/Lesson 009 Object Oriented Programming/pytut_009_001.py | 1,178 | 4.34375 | 4 | # OBJECT ORIENTED PROGRAMMING
"""
Real World Objects : Attribute & Capabilities
DOG
Attributes (Fields / Variables) : Height, Weight, Favorite Food
Capabilities (Methods / Functions): Run, Walk, Eat
"""
# Object is created for a template called Class
# Classes defines Attributes and Capabilities of an Object
class... | true |
fd7a49e1c672cf48f42228ebf83969de974dbf4c | s3icc0/Tutorials | /DBTut/Lesson 006 Lists/pytut_006_exe_002.py | 1,413 | 4.375 | 4 | # GENERATE THE MULTIPLICATION TABLE
# With 2 for loops fill the cells in a multidimensional list with a
# multiplication table using values 1-9
''' This should be the result:
1, 2, 3, 4, 5, 6, 7, 8, 9,
2, 4, 6, 8, 10, 12, 14, 16, 18,
3, 6, 9, 12, 15, 18, 21, 24, 27,
4, 8, 12, 16, 20, 24, 28, 32, 36,
5, 10, 15, 20, 25... | true |
9ea520cffdffe7d5a3e69cce58048b6b8a51cbe5 | s3icc0/Tutorials | /DBTut/Lesson 008 Reading Writing Files/pytut_008_001.py | 1,488 | 4.40625 | 4 | # READING AND WRITING TEXT TO A FILE
# os module help to manipulate files
import os
# with helps to properly close the file in case of crash
# locate the file
# mode='w' will override anything already in the file
# mode='a' will enable appending to the file only
# UTF-8 store text using Unicode
# define where to st... | true |
7cbb06c3818d3343558ff13e08f4c98825bdb943 | s3icc0/Tutorials | /DBTut/Lesson 001 Learn to Program/pytut_001_exe_002.py | 871 | 4.21875 | 4 | # If age is 5 Go to Kindergarten
# Ages 6 through 17 goes to grades 1 through 12
# If age is greater then 17 say go to college
# Try to complete with 10 or less lines
# Input age
# Convert age to Integer
age = eval(input('Enter age: '))
# Evaluate age and print correct result
if age == 5:
print('Go to Kindergarte... | true |
fe8fa2c1030929f662e9ed24224999a7c1919053 | s3icc0/Tutorials | /DBTut/Lesson 009 Object Oriented Programming/pytut_009_002.py | 1,542 | 4.125 | 4 | # GETTERS and SETTERS
# protects our objects from assigning bad fields and values
# provides improved output
class Square:
def __init__(self, height='0', width='0'):
self.height = height
self.width = width
# Getter - property will allow us to access the fields internally
@property
d... | true |
301028f45991ec452118fb86b9c4f0fb8c42f2fc | s3icc0/Tutorials | /Sebastiaan Mathôd Tutorial/001 Enumerate.py | 452 | 4.1875 | 4 | # ------------------------------------------------------------------------------
# WALK THROUGH THE LIST
citties = ['Marseille', 'Amsterdam', 'New York', 'London']
""" # The bad way
i = 0 # create counter variable
for city in citties:
print(i, city)
i += 1
"""
# The good way - Pythonic way
# enumerate retu... | true |
24fb622a60d869b5bfdc639dec4c0de71826dd1c | s3icc0/Tutorials | /Corey Schafer Tutorial/OOP 2 Class Variables.py | 1,209 | 4.15625 | 4 | """ Python Object-Oriented Programming
https://www.youtube.com/watch?v=ZDa-Z5JzLYM
"""
class Employee:
num_of_emps = 0
raise_amount = 1.04 # class variable
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + ... | true |
70c317bf1feded53134e4df778b22ce1aa0ec127 | lundergust/basic | /intro/basic_calulator.py | 225 | 4.34375 | 4 | num1 = input("enter a number")
num2 = input("enter another number")
# float allows us to read as decimals. For some reason it is not needed
# although the tutorial says it is
result = float(num1) + float(num2)
print(result)
| true |
c83b32a848d04303ae3ee36696623f7fb12f73b9 | Dzhano/Python-projects | /nested_loops/train_the_trainers.py | 452 | 4.21875 | 4 | n = int(input())
total_average_grade = 0
grades = 0
presentation = input()
while presentation != "Finish":
average_grade = 0
for i in range(n):
grade = float(input())
average_grade += grade
total_average_grade += grade
grades += 1
print(f"{presentation} - {(average_grade / n)... | true |
bb3fda8131f7ab620bd3e00f66286c13bf8d9b1b | SarthakSingh2010/PythonProgramming | /basics/MapFuncAndLamdaExp.py | 999 | 4.4375 | 4 | # Python program to demonstrate working
# of map.
# Return double of n
def addition(n):
return n + n
# We double all numbers using map()
numbers = (1, 2, 3, 4)
result = map(addition, numbers)
print(list(result))
# Double all numbers using map and lambda
numbers = (1, 2, 3, 4)
result = map(lambda ... | true |
146ccde11f165c54bfed745d5109f9f4dbd764f4 | IrakliDevelop/python-small-projects | /generateAlphabetDictionary.py | 323 | 4.21875 | 4 | '''
the purpose of this program is to generate for you sequence that you can use to create dictionary of alphabetical characters with numeric values of place in alphabet assigned to them
'''
char = 'a'
i = 1
while char <="z":
print("\"" + char + "\" : " + str(i) + ", ", end="")
char = chr(ord(char)+1)
i +=... | true |
ea2b440a310eead72ebb03def89eeff21b4c60da | afrokoder/csv-merge | /loops.py | 393 | 4.15625 | 4 |
outer_loop = 1
while outer_loop < 10:
inner_loop = 1
while inner_loop < outer_loop + 1:
print (outer_loop, end="")
inner_loop = inner_loop + 1
print()
outer_loop = outer_loop + 1
#outer_loop = 10
for outer_loop in range (9,0,-1):
for inner_loop in range (9,0,-1):
if inn... | true |
50b22625006adb5db8fc1c57eaa3d0cc6fa97848 | afrokoder/csv-merge | /food_list_exercise.py | 607 | 4.25 | 4 | #creating a list of food items for each day of the week
mon_menu = ["white_rice", "stir_fry", "sesame_chicken", "beef", "fried_rice"]
tue_menu = ["bread", "stir_fry", "sesame_chicken", "beef", "fried_rice", "potatoes"]
user_selection = input("Enter Your Order: ")
user_selection = user_selection.lower()
#for x in m... | true |
64e5a24e7b43691b706769be21a938f9db548197 | smallest-cock/python3-practice-projects | /End-of-chapter challenges in ATBS/Chapter 03 – Functions/Collatz sequence.py | 1,447 | 4.40625 | 4 | def collatz(number):
try:
while number != 1:
if number % 2 == 0:
print(number // 2)
number = number // 2
elif number % 2 == 1:
print(number * 3 + 1)
number = number * 3 + 1
except ValueError:
print("Error: Th... | true |
abe9db15437d1d72d1b33b6690ebf34c456fc72e | smallest-cock/python3-practice-projects | /End-of-chapter challenges in ATBS/Chapter 08 – Reading and Writing Files/RegexSearch.py | 1,921 | 4.46875 | 4 | #! /usr/bin/python3
# RegexSearch.py - Searches all text files in a given folder using a (user supplied)
# regex, and prints the lines with matched regex on the screen
import re, os, sys
# creates regex object to be used to find text files
regexTxt = re.compile(r'.txt$')
# checks to see if 2nd argument is a director... | true |
0b241218404ab2aecf9090d2a939f5ad3de1af91 | hcarvente/jtc_class_code | /class_scripts/bootcamp_scripts/nested_data_practice.py | 2,164 | 4.34375 | 4 | # lists inside lists
shopping_list = [['mangos', 'apples', 'oranges'], ['carrots,', 'broccoli','lettuce'], ['corn flakes', 'oatmeal']]
# print(shopping_list)
#access an inner list
# print(shopping_list[1])
# ONE MORE LEVEL DOWN
# access an ITEM inside an inner list
# print(shopping_list[1][0])
shopping_list[1].appe... | true |
aedccc4e66cd18e351eccae9fa706c61405dd998 | hcarvente/jtc_class_code | /class_scripts/bootcamp_scripts/functions_practice.py | 2,300 | 4.34375 | 4 | #RUNNING EXISTING FUNCTIONS
# print is a function
# print('hi')
# # name of the function comes first, followed by parentheses
# # what is inside the parenthese is called 'parameters' or 'argument'
# print(int(2.0))
# CREATING A FUNCTION
# DEFININF a function
def say_hello():
#anything inside as part of the function ... | true |
a75e26f1173c782f29c254c092cf40a446154a5c | TrueNought/AdventOfCode2020 | /Day3/Day3.py | 907 | 4.125 | 4 | def count_trees(route, right, down):
total_trees = 0
index = 0
index_length = len(route[0]) - 1
height = 0
while height < len(route):
if route[height][index] == '#':
total_trees += 1
index += right
height += down
if index > index_length:
ind... | true |
d295238e7d3b549ff31956008f2620fcec5529ba | GiTJiMz/Advanced-programming | /10-09-2020/W37/greeter.py | 415 | 4.15625 | 4 | #!/usr/bin/env python3
import random
def simple_greeting(name):
return "hello! " + name
def time_greeting(name):
from datetime import datetime
return f"It's {datetime.now()}, {name}"
greetings = [ simple_greeting
, time_greeting
]
greeting = random.choice(greetings)
print(greet... | true |
f4225c3e3ae3588dbfaa7ab8b0ebb0bb555dbf67 | idzia/Advent_of_code | /day_6/day_6.py | 1,860 | 4.4375 | 4 | """
How many redistribution cycles must be completed, to repeat the value
For example, imagine a scenario with only four memory banks:
The banks start with 0, 2, 7, and 0 blocks.
The third bank has the most blocks, so it is chosen for redistribution.
Starting with the next bank (the fourth bank) and then continuing
... | true |
12d273ecfd2c3b7603d23ab272905f8108af167b | dovewing123/LehighHacksFall2016 | /scientist.py | 2,315 | 4.15625 | 4 | __author__ = 'Alexandra'
def scientist(scientistCount):
if scientistCount == 0:
#print("\"Oh no! The parade is going to be ruined! It's supposed to go by the river, but ",
#"the river is a mess!\"")
input("\"Oh no! The parade is going to be ruined! I'm supposed to make the float... | true |
84cf3eee10b3ffd05bcb2930ee134646da979cb7 | moisotico/Python-excercises | /excersices/lists/queue_linked_list.py | 1,352 | 4.375 | 4 | # Represents the node of list.
class Node:
def __init__(self, data):
self.data = data
self.next = None
class CreateList:
# Declaring tle pointer as null.
def __init__(self):
self.head = Node(None)
self.tail = Node(None)
# method to add element to linked list queue
... | true |
69f281633daafdebdb472d1db228660eb9344164 | Ndkkqueenie/hotel-guest | /guest.py | 2,502 | 4.59375 | 5 | #Let's say we have a text file containing current visitors at a hotel.
# We'll call it, guests.txt. Run the following code to create the file.
# The file will automatically populate with each initial guest's first name on its own line.
guests = open("guests.txt", "w")
initial_guests = ["Bob", "Andrea", "Manuel", "Pol... | true |
21edc9be5705343c347caaba952e3c26da5f6781 | eclairsameal/TQC-Python | /第2類:選擇敘述/PYD202.py | 226 | 4.40625 | 4 | x = int(input())
if x%3==0 and x%5==0:
print(x,"is a multiple of 3 and 5.")
elif x%3==0:
print(x,"is a multiple of 3.")
elif x%5==0:
print(x,"is a multiple of 5.")
else:
print(x,"is not a multiple of 3 or 5.") | true |
594d46ab05cf2c2aa160bc7a331ee448f19b69fc | rdsim8589/holbertonschool-higher_level_programming | /0x06-python-test_driven_development/4-print_square.py | 458 | 4.28125 | 4 | #!/usr/bin/python3
"""
This is the "Print Square" module
The Print Square module supplies the simple function\
to print a square of # of a size
"""
def print_square(size):
"""
Return the square of # of size x size
"""
if not isinstance(size, int):
raise TypeError("size must be an integer")
... | true |
702df8cff2c17e2685aac36a4384b8b499bf7e05 | bhavikjadav/Python_Crash_Course_Eric_Matthes_Chapter_4 | /4.9_Cube Comprehension.py | 273 | 4.25 | 4 | #!/usr/bin/env python
# coding: utf-8
# # 4-9. Cube Comprehension: Use a list comprehension to generate a list of the first 10 cubes.
# In[1]:
# This is call Comprehension of a list.
cubes = [value**3 for value in range(1, 10)]
# In[2]:
print(cubes)
# In[ ]:
| true |
14732573cc07a9067e3362c35343bd1755b4d707 | LogeshRe/Python-Utilities | /Filelist.py | 810 | 4.1875 | 4 | # This Program is to get the List of files in a folder
# On Running it opens file explorer.
# Choose the folder you want.
# Once again explorer opens.
# Give a name for file and save it as txt.
# The file contains the list of all files in the folder.
# 23/12/18
from tkinter.filedialog import askdirectory
from tkin... | true |
d3c8c439fcecd822f0c85be872905a7a8200ce5b | lingsitu1290/code-challenges | /random_problems.py | 1,818 | 4.1875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Write a program that asks the user to enter 10
# words, one at a time. The program should then
# display all 10 words in alphabetical order. Write
# this program using a loop so that you don't have to
# write any additional lines of code if you were to
# change the prog... | true |
f4b55e2ea2389bf8dd460a526c99ce0ba16225cf | lingsitu1290/code-challenges | /flip_the_bit.py | 1,552 | 4.15625 | 4 | # Various ways to return 1 if 0 is given and return 0 if 1 is given
def flip_the_bit(num):
"""
>>> flip_the_bit(1)
0
>>> flip_the_bit(0)
1
"""
if num == 0:
return 1
else:
return 0
#switch, break, return
def flip_the_bit(num):
"""
>>> flip_the_bit(1)
0
... | true |
3dd89365fb041b8a6f6581059c8fd761a6c3036e | ARUN14PALANI/Python | /PizzaOrder.py | 1,051 | 4.1875 | 4 | print("Welcome to AKS Pizza Stall!")
pizza_size = input(str("Please mention your pizza size 'S/M/L': "))
add_peproni = input("Do you need add peproni in your pizza? Mention (y/n): ")
add_cheese = input("Do you need add extra cheese in your pizza? Mention (y/n): ")
bill_value = 0
print(add_peproni.lower())
print(pizza_s... | true |
b42b11517300a0271107d0206f050dde24ca3bf1 | ChiragTutlani/DSA-and-common-problems | /Algorithms/dijkstra_algorithm.py | 1,565 | 4.1875 | 4 | # Three hash tables required
# 1. Graph
# 2. Costs
# 3. Path/Parent Node
graph = {
"start":{
"a":6,
"b":2
},
"a":{
"finish":1
},
"b":{
"a":3,
"finish":5
},
"finish":{}
}
# print(graph)
inf = float("inf")
costs = {
"a": 6,
... | true |
96254fbc29edc870dbf9e6db304f997f0147ef93 | mjuniper685/LPTHW | /ex6.py | 1,156 | 4.375 | 4 | #LPTHW Exercise 6 Strings and Text
#create variable types_of_people with value of 10 assigned to it
types_of_people = 10
#Use string formatting to add variable into a string stored in variable x
x = f"There are {types_of_people} types of people."
#create variable binary and assign it a string
binary = "binary"
#create ... | true |
6b92d4b843d9754a6206e9d93e5348a769719895 | Oskorbin99/Learn_Python | /Other/Lamda.py | 520 | 4.15625 | 4 | # Simple lambda-functions
# add = lambda x, y: print(x+y)
# add(5, 4)
# But it is not good because do not assign a lambda expression, use a def
def add_def(x, y): print(x+y)
add_def(5, 4)
# Use lambda for sort
tuples = [(1, 'd'), (2, 'b'), (4, 'a'), (3, 'c')]
print(sorted(tuples, key=lambda x: x[1]))
p... | true |
eab8aa205f7463c74d64ecf91d1d1c053deda762 | barmalejka/Advanced_Python | /hw2/pt1.py | 598 | 4.21875 | 4 | import operator
def calc(x, y, operation):
try:
x = float(x)
y = float(y)
except ValueError:
return 'Inputs should be numbers. Please try again.'
operations = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.truediv}
if ... | true |
985440717e2e19291a05f9afe5b9f7bda9d5ccfa | manas1410/Python-addition | /Addition.py | 419 | 4.15625 | 4 | #program to find the addition of two numbers
#takes the input of 1st number from the user and stores it in num1
num1 = int(input("Please enter your number num1:"))
#takes the input of 2nd number from thwe user and stores it in num2
num2 = int(input("Please enter your number num2:"))
#stores the addition of two numb... | true |
a5d29c3be92b2eb4bc8cd2f2fbf8faf8cb37f0d6 | dorayne/Fizzbuzz | /fizzbuzz.py | 1,595 | 4.125 | 4 | #!/usr/bin/env python
# initialize default values for variables
start_c = 1
end_d = 101
div_a = 3
div_b = 5
def error_check(test):
# convert input to integer, exit program if input is not a number
try:
tested = int(test)
return tested
except:
print "Invalid input, please try again ... | true |
829259503dfa0153bcd851bb901474d436a595ff | KRSatpute/GreyAtom-Assignments | /25Nov2017/map_func_run.py | 1,128 | 4.125 | 4 | """
Write a higher order generalized mapping function that takes a list and
maps every element of that list into another list and return that list
ex:
i) Given a list get a new list which is squares of all the elemments of the
list
ii) Given a list get a list which has squares of all the even numbers and
cubes of all... | true |
fb3abdd0cd80c80246907fdccc11fa1c2c3af742 | sanjanprakash/Hackerrank | /Languages/Python/Python Functionals/map_lambda.py | 367 | 4.1875 | 4 | cube = lambda x: x*x*x # complete the lambda function
def fibonacci(n):
# return a list of fibonacci numbers
arr = []
if (n > 0) :
if (n >= 2) :
arr = [0,1]
while (n > 2) :
arr.append(arr[-1] + arr[-2])
n -= 1
else :
arr =... | true |
2663bd81905b0b3d0b5a0d1a69acc6c190456821 | DanielMSousa/beginner-projects | /1. BMI Calculator/Calculadora IMC.py | 867 | 4.1875 | 4 | """
Created on Thu Jun 17 21:54:11 2021
@author: daniel
"""
print('###################################################')
print(' BMI Calculator ')
print('###################################################')
print()
print("This program can't substitute any doctor or health profession... | true |
d663e2af3f922141c364ecc842dfb337b6f1ea9a | brianpendleton-zz/anagram | /scripts/find_anagrams.py | 674 | 4.25 | 4 | """
Script to find anagrams given an input word and a filepath to a text file of
known words.
Argparse or Optparse could be used, but no current requirements for optional
flags or features to the script.
"""
from anagram import find_anagrams, load_words_file
import sys
def main(word, filepath):
valid_words = lo... | true |
2bd8767bf274053e614965265ac628b3a5c255f8 | colingdc/project-euler | /4.py | 489 | 4.15625 | 4 | # coding: utf-8
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
def is_palindrome(n):
return str(n) == str(n)[::-1]
palindromes = []
for i in range(1... | true |
e09b68fe95f607bf91a6aae1bddbec12185e7ff0 | antdevelopment1/dictionaries | /word_summary.py | 656 | 4.3125 | 4 | # Prints a dictionary containing the tally of how many
# times each word in the alphabet was used in the text.
# Prompts user for input and splits the result into indiviual words.
user_input = input("Please provide a string to be counted by words: ").split(" ")
diction = {} # Creates an empty dictionary.
for word i... | true |
b117c4ffe9a092727d29ec759efb4b99b1ef3944 | ivaben/lambdata | /lambdata_maltaro/df_utils.py | 578 | 4.40625 | 4 | """
utility functions for working with DataFrames
"""
import pandas
import numpy
TEST_DF = pandas.DataFrame([1, 2, 3])
def add_list_to_dataframe(mylist, df):
"""
Adds a list to pandas dataframe as a new column. Then returns the extended
dtaframe.
"""
df["new_column"] = mylist
return df
de... | true |
51440d306d7272a3b6a18f79515d37366c4c624e | melissed99/driving-route-finder | /dijkstra.py | 1,023 | 4.125 | 4 | def least_cost_path(graph, start, dest, cost):
"""Find and return a least cost path in graph from start vertex to dest vertex.
Efficiency: If E is the number of edges, the run-time is
O( E log(E) ).
Args:
graph (Graph): The digraph defining the edges between the
vertices.
start: The ve... | true |
aef1daa1692f2536688c27101e11b4a830767599 | spicywhale/LearnPythonTheHardWay | /ex8.py | 747 | 4.375 | 4 | #assigns the variable
formatter = "{} {} {} {}"
#changes formatter's format to function. This allows me to replace the {} in line 2 with 4 other values, be it lines of text, numbers or values.
#prints formatter with 4 different values
print(formatter.format(1, 2, 3, 4))
#prints formatter with 4 different values
print(f... | true |
9545460a2aead536e4ee5ab78f74b31584012464 | amandathedev/Python-Fundamentals | /03_more_datatypes/1_strings/04_05_slicing.py | 412 | 4.40625 | 4 | '''
Using string slicing, take in the user's name and print out their name translated to pig latin.
For the purpose of this program, we will say that any word or name can be
translated to pig latin by moving the first letter to the end, followed by "ay".
For example: ryan -> yanray, caden -> adencay
'''
name = inpu... | true |
1995310414b904bbc19de4c6709f1dc1049b20f0 | amandathedev/Python-Fundamentals | /02_basic_datatypes/02_01_cylinder.py | 315 | 4.21875 | 4 | '''
Write the necessary code calculate the volume and surface area
of a cylinder with a radius of 3.14 and a height of 5. Print out the result.
'''
import math
radius = 3.14
height = 5
volume = math.pi * (radius ** 2) * height
volume = round(volume, 2)
print("The volume of the cyliner is " + str(volume) + ".") | true |
3f3c65621a8c08e005a3efe10aeb16c43524a08a | amandathedev/Python-Fundamentals | /12_string_formatting/12_01_fstring.py | 1,791 | 4.34375 | 4 | '''
Using f-strings, print out the name, last name, and quote of each person in the given dictionary,
formatted like so:
"The inspiring quote" - Lastname, Firstname
'''
famous_quotes = [
{"full_name": "Isaac Asimov", "quote": "I do not fear computers. I fear lack of them."},
{"full_name": "Emo Philips", "quo... | true |
4fd88f7c40fd99638e7b0ec03a4e353927d57f50 | amandathedev/Python-Fundamentals | /03_more_datatypes/4_dictionaries/04_19_dict_tuples.py | 471 | 4.40625 | 4 | '''
Write a script that sorts a dictionary into a list of tuples based on values. For example:
input_dict = {"item1": 5, "item2": 6, "item3": 1}
result_list = [("item3", 1), ("item1", 5), ("item2", 6)]
'''
# http://thomas-cokelaer.info/blog/2017/12/how-to-sort-a-dictionary-by-values-in-python/
import operator
input_... | true |
3cad7c59eb9cb4fe0e7ee41c01abe41b51c11669 | danielzengqx/Python-practise | /1 min/binary search.py | 708 | 4.125 | 4 | #Binary search -> only for the sorted array
#time complexity -> O(logn)
array = [1, 2, 3, 4, 5]
def BS(array, start, end, value):
mid = (start + end) / 2
if start > end:
print "None"
return
if array[mid] == value:
print mid
return
elif array[mid] > value:
BST(array, start, mid-1, value)
elif array[mi... | true |
7176d418d1a0dc3f60f8d419d73174ab0184f160 | danielzengqx/Python-practise | /CC150 5th/CH9/9.1.py | 866 | 4.15625 | 4 | #a child is running up a staircase with n steps, and can hop either 1 step, 2 step, 3 step at a time
#Implement a method to count how many possible ways the child can run up the stairs
def stair(n, counter):
if n == 0:
counter[0] += 1
return
if n < 1:
return
else:
stair(n-1, counter)
stair(... | true |
fd9d02de7d3f099f5d4267804fe5c7a4b8ee4a69 | danielzengqx/Python-practise | /CC150 5th/CH2/2.5 best solution.py | 2,564 | 4.125 | 4 | # Given a circular linked list, implement an algorithm which returns node at the beginning of the loop.
# EXAMPLE
# input: A -> B -> C -> D -> E -> C [the same C as earlier]
# output: C
# 1), assume we have two types of runners, first, slow runner(s1) and fast runner (s2). s1 increment by 1 and s2 increment by 2
# 2)... | true |
b1e6b5ea5c807000c7c463917b25bcc09812385f | danielzengqx/Python-practise | /CC150 5th/CH5/5.2.py | 781 | 4.125 | 4 | #Given a (decimal - e.g. 0.72) number that is passed in as a string, print the 32 bits binary rep- resentation. If the number can not be represented accurately in binary, print “ERROR”
# the number base 5th version, the number is between 0 to 1, the max number is 1 - 2^(-32)
# 1), There are two types of binary repres... | true |
e3fa4d976c1d6c1b6decfa4c0d24962076d5f829 | danielzengqx/Python-practise | /CC150 5th/CH5/5.8.py | 1,589 | 4.21875 | 4 | #1, screen is stored as a single array of bytes.
#2, width of screen can be divided by 8 pixels or 1 byte
#3, eight consecutive pixels to store in one byte
#4, height of the screen can be derived from
#---------the width of screen
#---------the length of a single array
#---------height = the length of a single arra... | true |
1cb1e67c83c2ed46f228e1deea7359f2c3974fc5 | Makhanya/PythonMasterClass | /OOP2/specialMethods.py | 2,056 | 4.5625 | 5 | """
Special Methods
2.(Polymorphism) The same operation works for different kinds of objects
How does the following work in Python
8 + 2 #10
"8" + "2" #82
The answer is "special method"
Python classes have special(also known as "magic... | true |
ef4ff8fd0f38d7aae7463c629e9b3775dcc671a5 | Makhanya/PythonMasterClass | /TuplesSets/loopingTuple.py | 392 | 4.53125 | 5 | # Looping
# We can use a for loop to iterate over a tuple just like a list!
# names = (
# "Colt", "Blue", "Rusty", "Lassie"
# )
# for name in names:
# print(name)
# months = ("January", "February", "March", "April", "May", "June",
# "July", "August", "September", "October", "November", "December")
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.