blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
e96d7f79807fea9e89b781a804d3aee0e8249464 | greall2/-Python-Fundamentals-Problem-Sheet | /Problem5.py | 1,025 | 4.25 | 4 | #Emerging Technologies
#Python Fundatmentals Problem Sheet
#Ríona Greally - G00325504
#5. Write a guessing game where the user must guess a secret number. After every guess the program tells the user whether their number was too large or too small.
#At the end the number of tries needed should be printed.
#It counts... | true |
2b8cfc3d2dfb676f71fdd9500d5296f318b6dd95 | mahfuz-raihan/URI-problem-solve | /uri1038.py | 1,009 | 4.21875 | 4 | # URI 1038
"""
Using the following table, write a program that reads a code and the amount of an item. After, print the value to pay. This is a very simple program with the only intention of practice of selection commands.
"""
print("CODE SPECIFICATION PRICE")
print("1 Cachorro Quente R$ 4.00")
... | true |
cac982f525c85a3f51718f98d7e335817cb6b18b | AshokDon/Numbers | /Spy_number.py | 478 | 4.25 | 4 | '''
Spy Number
A number is said to be a Spy number if the sum of all the digits
is equal to the product of all digits.
Sample input 1:
132
Output:
Spy Number
Sample input 2:
1412
output:
Spy Number
'''
num=int(input())
sum_of_digits=0
product_of_digits=1
while num:
r=num%10
sum_of_digits+=r
... | true |
8c22b7b2915d4a3cd1b206c0568e0d2dec8efdbb | dsayan1708/Python | /ExceptionHandling.py | 393 | 4.125 | 4 | while True:
try:
age = int(input("Enter the number to check eligibility : "))
break
except ValueError:
print("You might have entered string. Try integer value. Try again please...")
except:
print("Unexpected error")
if(age>18):
print("You are eligibile to play ... | true |
e5e5a22f7ea1026f361855b1b15a8340dae06100 | ImranKhanPrince/needed-weight-for-perfect-bmi-measured-with-height | /bmi.py | 1,021 | 4.1875 | 4 | import math
#take an input
usr_input = input("Enter Your Height in feet and inch eg. 5.6 \n=> ")
#checks wheather user inputted right formatted height
#but that counts 5.11.5 as error because that cant be a float so checking on the first digit by splitting the input
while True:
try:
str(float(usr_input.split('.... | true |
55e4ea149e83315bb3cb53996caf86c225860fea | kannanParamasivam/datastructures_and_algorithm | /tree/is_tree_symmetric.py | 1,115 | 4.46875 | 4 | '''
101. Symmetric Tree
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 following [1,2,2,null,3,null,3] is not:
1
/ \
2 2
\ \
3 3
Note:
... | true |
336869b1efc408c3b8b81e6e5d707f39608115c2 | swanzie/ada-build-solutions | /07-dictionaries/accountgenerator.py | 1,244 | 4.53125 | 5 | #account generator using a list of dictionaries (student accounts that have keys: name, ID, email)
import random
#ask user for name
def get_full_name():
student_name = input("full name: ")
return student_name
#create list with user inputted names
names = []
def get_list_names():
more_names = True
choice = ""... | true |
b8ef00e71eb4f360980ded07d2b7926c66487c49 | wuyuxiao3/leetcode | /p243_shortest_dist.py | 964 | 4.125 | 4 | # Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.
# Example:
# Assume that words = ["practice", "makes", "perfect", "coding", "makes"].
# Input: word1 = “coding”, word2 = “practice”
# Output: 3
# Input: word1 = "makes", word2 = "coding"
# ... | true |
d02894a8645b190e880617bbf2ebcc0a60a845c0 | SweHar/Time-Series-Analysis-On-M5-Dataset | /strings_cypher.py | 1,716 | 4.59375 | 5 | astr = "---i love zfdulardz strings---"
str1 = "zfd"
str2 = "reg"
"""
lstrip, rstrip, strip function
"""
print(astr.lstrip("-"))
print(astr.rstrip("-"))
print(astr.strip("-"))
"""
min and max
"""
print(f"min is {min(astr)}")
print(max(astr))
"""
maketrans is used to map contents of str1 to str2 for str: i.e. python... | true |
056ee47acabe4494efe0af610f9b3f6c10461810 | Anjualbin/workdirectory | /fundamentals/checkletterinstring.py | 279 | 4.125 | 4 | text="luminar technolab"
chr=input("Enter the charactor to check:")
for i in text:
if i in text:
print("The charactor is present in the string")
break
else:
print('not present')
# if chr in text:
# print("present")
# else:
# print("not present") | true |
afcb50c46df095880185a481b3c9de2a9dd23661 | Anjualbin/workdirectory | /operators/arithmetic.py | 530 | 4.3125 | 4 | # (+,-,*,/,//-floor division, **-exponent)
num1=int(input("enter the first number:"))
num2=int(input("wnter the second number:"))
sum=num1+num2
print("the sum is",sum)
dif=num1-num2
print("the difference is",dif)
mul=num1*num2
print("the product is",mul)
div=num1/num2
print("the div result is",div)
flr=num1//num2... | true |
c04743d9b1a7a86045be1603c55016b18d16311e | Anjualbin/workdirectory | /Python collections/set/setfunctions.py | 388 | 4.28125 | 4 | # set functions
s2=set() # set() function creates an empty set
s2.add("hello") # add() is used to add a new element to the set
s2.add(True)
s2.add(67.7)
s2.add(80)
print(s2)
for i in s: # looping through the set
print(i)
s2.remove(80) # remove a specific element from the set
s2.clear() ... | true |
3ea7a0ab601de467e0dca94e07576ea2c2b600d1 | aumamageswaran/coding-projects | /math-programs/solve-proportion.py | 1,158 | 4.21875 | 4 | '''Program created by Akul Umamageswaran.'''
'''NOTE:
This program finds the missing value in a proportion.
It solves for either x1, x2, y1, or y2, given the other 3.
The following layout is used.
x1 / x2 = y1 / y2
The program will prompt you for integer values.
During those prompts, please ONLY ENTER integers.
Othe... | true |
bc28c60e51427c845acf308e42f40e14e8201e41 | sumeyaali/Code_Challenges | /Intro/pinterest.py | 2,035 | 4.375 | 4 | # Given a hashmap where the keys are integers, print out all of the values of the hashmap in reverse order, ordered by the keys.
# For example, given the following hashmap:
# {
# 14: "vs code",
# 3: "window",
# 9: "alloc",
# 26: "views",
# 4: "bottle",
# 15: "inbox",
# 79: "widescreen",
# 16: "coffee",
... | true |
87788f61ff3c45a9802ffbf616eb2920e40847f8 | levep/python-devops-JB | /string/string_length.py | 238 | 4.46875 | 4 | #!/bin/python3
# Write a Python program to calculate the length of a string.
def string_length(str1):
count = 0
for char in str1:
count += 1
return count
print(string_length('the is no way to learn without coding'))
| true |
70d71120b7bcb739cb1e89cc295981225ac8bf6e | albertfougy/problem_solving_python_ds_algo | /algorithm_analysis/what_is_algo_analysis/benchmark_analysis.py | 934 | 4.21875 | 4 | """
In the time module there is a function called time that will return the current
system clock time in seconds since some arbitrary starting point. By calling this
function twice, at the beginning and at the end, and then computing the difference,
we can get an exact number of seconds (fractions in most cases) for ex... | true |
1225b4d0984b3e5c351e2742abe060863cd98cbf | firas-hamdi/Python_games | /tic_toe/side.py | 544 | 4.125 | 4 | def choose_side():
side=''
accepted_side_values=['X','O']
while side.upper() not in accepted_side_values:
side=input("Choose which side you want to play: O or X ")
if side.upper() not in accepted_side_values:
print("This is Tic Tac Toe, you can only choose X or O")
if side.up... | true |
214acfe57b316b6e475c039986c82a9a648bf495 | jasonn1124/Projects | /Classic Algorithms/Classic algorithms - Collatz conjecture.py | 1,306 | 4.40625 | 4 | # Classic algorithms - Collatz Conjecture -
"""
1) Accepts integer input of > 1.
2) Record number of steps needed for target to reach 1.
3) Algorithm of : If n is even, divide by 2. If n is odd, multiply by 3 and add 1.
"""
# Imports
import subprocess
# Function - Clears screen
def cls():
subprocess.c... | true |
31f9c61771fef76e9ca2aeed7b9733355593f818 | Lindseyj79/python-interfaces | /building-interfaces/01 - tk_window.py | 401 | 4.40625 | 4 | # Python 3 - Window tkinter program
# Author: J.Smith
# Import tkinter library
from tkinter import *
# Create a tkinter window
window = Tk()
# Set window title
window.title('Label Example')
# Set window size
window.geometry('500x500')
# Create a label
label = Label(window, text = 'Hello World!')
# Add label to windo... | true |
d85f5790828506198141837336c08e8a4293ad92 | victorsemenov1980/MIT_6.0001_6.0002 | /1/ProblemSet4/untitled2.py | 1,411 | 4.40625 | 4 | def load_words(file_name):
'''
file_name (string): the name of the file containing
the list of words to load
Returns: a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this function may
take a while to finish.
'''
print(... | true |
39e4162643a85f3a7c04cda8ec57c89ff88f56dc | 16nishma/random-number-generators | /random#2.py | 827 | 4.40625 | 4 | #guess the number game using a for loop
#imports the ability to get a random number (we will learn more about this later!)
from random import *
numberOfGuesses=0
#Generates a random integer.
aRandomNumber=randint(1, 20)
print("The random number (secret) is: ", aRandomNumber)
# For Testing: print(aRandomNumbe... | true |
f4d76563ed6e52e9f13ec97a285df14ad19cb17f | mulualem04/ISD-practical-5 | /ISD practical5Q3b.py | 242 | 4.125 | 4 | import math # this will import math module
x=int(input("Inser integer for x: "))
y=int(input("Inser integer for y: "))
if 1+x>x**math.sqrt(2): # returns the square root of 2
y=y+x
print(x)
print(y)
else:
print(y)
| true |
2b77a4e7e4340f637bb9bc6c8feb75b25279fe72 | renatomak/trybe-exercises | /CC/bloco_34/dia_4/exercicio01.py | 491 | 4.15625 | 4 | #n = int(input())
def list_of_numbers(number):
result = []
for n in range(number):
num = n+1
is_divisible_by_three = num % 3 == 0
is_divisible_by_five = num % 5 == 0
if (is_divisible_by_three and is_divisible_by_five):
result.append('FizzBuzz')
else:
if is_divisible_by_three:
... | true |
1d04591aebd8d5e2ce6c2197812433afa0681860 | makeTaller/Crash_Course_Excercises | /conditions.py | 435 | 4.28125 | 4 | home = "Chicago"
print("Do you live in chicago?")
print(home == "Chicago")
love = "no"
print("Do you have a love?")
print(love == "yes")
money = "no"
drugs = "yes"
print("Do you have any money or drugs")
print( money == "yes" or drugs == "yes")
books = ["Ralph Emerson", "james Allen", "jndrew carnege"]
books = [book... | true |
58375519b6588a3268e3295e3a1f6b81822b7f01 | makeTaller/Crash_Course_Excercises | /dinner_table.py | 208 | 4.21875 | 4 |
dinner_table = input("How many guest will be attending dinner tonight?")
dinner_table = int(dinner_table)
if dinner_table >= 8:
print(" Sorry can't eat here! " )
else:
print(" Your table is ready.")
| true |
750b9014db2f19bcfc8ae344420ef2c0e21b4e48 | CDAdkins/CS138 | /Week 7/hw7project2.py | 1,367 | 4.34375 | 4 | # Exercise No. 2
# File Name: hw7project2.py
# Programmer: Chris Adkins
# Date: May. 11, 2020
#
# Problem Statement: This program generates a speeding ticket given the limit and the speed.
#
# Overall Plan:
# 1. Get input from the user and initialize a speed and limit variable.
# 2. If the limit is gr... | true |
655a607ed18967eb4460b14db4dcb6bedd449c53 | CDAdkins/CS138 | /Week 7/hw7project2_Wrong.py | 1,655 | 4.65625 | 5 | # Exercise No. 2
# File Name: hw7project2.py
# Programmer: Chris Adkins
# Date: Mar. 9, 2020
#
# Problem Statement: This program takes a date in MM/DD/YYYY
#
# Overall Plan:
# 1. Get input from the user.
# 2. Use the user's input and check it against our array of days in a month.
# 3. If the date is w... | true |
665955f79b712dfe8d74e010c117377e04a706e3 | CDAdkins/CS138 | /Week 2/hw2project3.py | 1,526 | 4.53125 | 5 | #! /usr/bin/python
# Exercise No. 3
# File Name: hw2project3.py
# Programmer: Chris Adkins
# Date: Feb. 4, 2020
#
# Problem Statement: A program to average a user-defined number of test scores.
#
# Overall Plan:
# 1. Print a welcome message to the user.
# 2. Create an int to hold the number of tests t... | true |
84948a182ca63d9b0a586f66f2d61acccd32c4ff | saqibzia-dev/DSA | /Practice/8 Oxygen Value.py | 1,291 | 4.34375 | 4 | """
The selection of MPCS exams includes a fitness test which is conducted on the ground.
There will be a batch of 3 trainees, appearing for a running test on track for 3 rounds.
You need to record their oxygen level after every round.
After trainees are finished with all rounds, calculate for each trainee his av... | true |
b809da42928e5a890a923eeb9cea89e40a55b40c | jquiros2290/python_nov_2017 | /justin_quiros/practice.py | 710 | 4.15625 | 4 | #Find and Replace
words = "It's thanksgiving day. It's my birthday, too!"
print words.find("day")
#replaced day with the month
print words.replace("day", "month")
#Finding the min and max values of a string
x = [1,54,234,-11,35,99]
print min(x)
print max(x)
# Finding values within a variable using indicies
y = ["h... | true |
15f48cbfa20673fba614fc2d92b7bfa119440d8c | kdebski/book-python | /oop-advanced/src/oop-dependency-injection.py | 677 | 4.1875 | 4 | class Engine(object):
"""Example engine base class.
Engine is a heart of every car. Engine is a very common term and could be
implemented in very different ways.
"""
class GasolineEngine(Engine):
"""Gasoline engine."""
class DieselEngine(Engine):
"""Diesel engine."""
class ElectroEngine(E... | true |
d15aaf46ba4f8a7963dc6c6fb753c3e3f8762f0f | sn2606/python-scientific-stack | /NumericalDifferentiation.py | 1,358 | 4.15625 | 4 | # 8.18. In this exercise we will experiment with numerical differentiation using data from Computer
# Problem 3.1:
# t | 0.0 1.0 2.0 3.0 4.0 5.0
# y | 1.0 2.7 5.8 6.6 7.5 9.9
# For each of the following methods for estimating the derivative, compute the derivative of the
# original data and also experiment with randoml... | true |
4685f6c3dca43695f4cb2a737a402559ade4cc93 | yuhangwang/plot | /plot/tk/dictTK/update.py | 1,570 | 4.15625 | 4 | """
Update the second dictionary with
the contents of the first dictionary.
"""
from typing import Dict
import copy
def update(src, target):
"""Recursively update.
Update the target using
content from the src.
Items from src which are not in
target will be discarded.
A easy way to remember th... | true |
fb284154631cfbfa1b686cb0d9ee2e396cb31cbe | Birger9/Tank-game | /boxmodels.py | 1,053 | 4.40625 | 4 | """
This file defines the different types of box models and their attributes
"""
import images
class BoxModel:
""" This class defines a model of the box, it contains information on the type of box,
whether it can be moved, destroyed and the sprite.
"""
def __init__(self, sprite, movable, destructable, bo... | true |
c7b90dfc2e3cfd382f1fceb685e6948043897d83 | NK84/python3.5 | /game_ex2_1.py | 2,638 | 4.4375 | 4 | # -*-coding: utf-8 -*-
# 'random' module is used to shuffle field, see:
# https://docs.python.org/3/library/random.html#random.shuffle
import random
# Empty tile, there's only one empty cell on a field:
EMPTY_MARK = 'x'
# Dictionary of possible moves if a form of:
# key -> delta to move the empty tile on a field.
M... | true |
081e1dd272fe691d39bcf91efa3c554e19dbf8d1 | nam01012000/PhamThanhNam-CA18A1A-44495-BaiGoDiem | /Example Rational Number.py | 2,706 | 4.25 | 4 | """
File: rational.py
Author: Phaam Thanh Nam
Date: 28/10/21
Resources to manipulate rational numbers.
"""
class Rational(object):
"""Represents a rational number."""
def __init__(self, numer, denom) :
"""Constructor creates a number with the given
numerator and denominator a... | true |
8f6a928a4bf99d792600aee5b13eb932df626837 | shubhamjangir/Flask | /Flask_2.py | 1,702 | 4.15625 | 4 | #Dynamic URL and Variable Rules
'''
When creating an application, it’s quite cumbersome to hard-code each URL.
A better way to resolve this problem is through building Dynamic URLs.
Let us briefly understand the meaning of a few common terms first.
Dynamic Routing: It is the process of getting dynamic data(variable na... | true |
2439987cb65fe7ac4610ca98f0ab7f7ddfc9a215 | ravalishnuguri/CSPP_1 | /M4/p2/p2/bob_counter.py | 544 | 4.21875 | 4 | '''Assume s is a string of lower case characters.
Write a program that prints the number of times the string 'bob' occurs in s. For example,
if s = 'azcbobobegghakl', then your program should print
Number of times bob occurs is: 2'''
def main():
'''program to find bob string'''
str1 = input()
# the input... | true |
7792b7fc13d91f7378148a9b3b946e3873a6b504 | nskwak/python | /24_BinarySearchTree.py | 1,747 | 4.28125 | 4 | #! /usr/bin/python2.7
#####################################################################
# https://medium.com/@sarahelson81/top-15-interview-questions-for-test-automation-engineers-e6c20842910
# Question 3
# Write a program to find the depth of binary search tree, without using recursion.
print("====================... | true |
28d7f718c9c9db05dda8945f5ea16cfebeb18e12 | gaudard/PyForBeginners | /chapter2Ex.py | 342 | 4.15625 | 4 | # Chapter 2 exercise
# v = final velocity
# u = initial velocity
# a = acceleration (solving for)
# t = time
#int will error if a float is used, set all variables to floats
v = float(input('final velocity: '))
u = float(input('inital velocity: '))
t = float(input('time: '))
a = (v-u)/t
print(type(a), a) #prints type... | true |
6b65cc62be537e444a82e61b106eef148f66339e | jungleQi/leetcode-sections | /classification/data structure/4-stack/4-150. Evaluate Reverse Polish Notation.py | 1,191 | 4.25 | 4 | '''
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Valid operators are +, -, *, and /. Each operand may be an integer or another expression.
Note that division between two integers should truncate toward zero.
It is guaranteed that the given RPN expression is always valid.
That means the ... | true |
f863d71aaf606f6040bb015304395da4cf2f1249 | jungleQi/leetcode-sections | /classification/data structure/1-linked list/two link/21. Merge Two Sorted Lists.py | 821 | 4.25 | 4 | '''
Merge two sorted linked lists and return it as a new list.
The new list should be made by splicing together the nodes of the first two lists.
Example:
Input: 1->2->4, 1->3->4
Output: 1->1->2->3->4->4
'''
from ....utils import *
def mergeTwoLists(l1, l2):
dummy = ListNode(0)
head = dummy
while l1 and... | true |
8c90d4d5d1f1258c2d23eff4836760c35a9c4e1d | jungleQi/leetcode-sections | /classification/data structure/4-stack/4-1249. Minimum Remove to Make Valid Parentheses.py | 1,045 | 4.125 | 4 | '''
Given a string s of '(' , ')' and lowercase English characters.
Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string.
Formally, a parentheses string is valid if and only if:
It is the empty string, ... | true |
1f9608f04988ad799776c1e7fee2b342f04e6839 | chenkc805/CS61AProjects | /Projects/scheme/zip.py | 429 | 4.1875 | 4 | def zip(s):
""" Takes in a list of pairs and converts it into a pair of lists,
where the first list contains all of the first elements of the original pairs,
and the second list contains all of the second elements.
>>> zip([[1,2]])
[[1], [2]]
>>> zip([[1,2],[3,4],[5,6]])
[[1, 3, 5], [2, 4, 6]]
"""
if len(s... | true |
639aa60e0b4ea44180ca1ee2f0fbef27a7fe5376 | Anthony4421/Python-Course-Assignments-2018 | /TelevisionObject.py | 2,049 | 4.15625 | 4 | #Assignment 6
#Create a Television Object
#Anthony Swift
class Television(object):
def __init__(self, model, screen_size, volume, channel):
#Print message each time an object is created
print("\nA new television has been built!")
#Setup the attributes
self.model = model
self.screen_size = scree... | true |
ccbd7f90e26f7699ac66751ef950c5322dd9deea | lohitbadiger/Python-teaching-all | /Rekha/6_TupleDataType.py | 694 | 4.375 | 4 | list=(1,2,3,4)
print(list)
print(list[0])
print(list[2])
list[2]=7 #error bcz immutable value cannot be changed
print(list[2])
# An empty tuple
empty_tuple = ()
print (empty_tuple)
# Creating non-empty tuples
# One way of creation
tup = 'python', 'geeks'
print(tup)
# Another for doing the same
tup = ... | true |
eed05a5a87918652c8cb98db0efa0fa0bf6dacbb | lohitbadiger/Python-teaching-all | /lohit/3format_method.py | 538 | 4.375 | 4 |
# Format method
# in this method we can print the variables using {}
num1 = 3.1212
num2 = 2.23232222
lo = 10.83329238
loh = 29.28928
# method formating
print('this is first num1 {0} this is num2 is {1} this is loht {2:.3}, "last number",{3:.4f}'.format(num1, num2, lo, loh))
# one more method to print using F-stri... | true |
aa8e95e8b1ee994e7571839ce49b339394e52b00 | Stpka/calc | /calc.py | 2,847 | 4.25 | 4 | # calculator
import math
from rich.console import Console
from rich.table import Table
console = Console() # I dont know what is it, but i must did it ;)
table = Table(show_header=True, header_style="bold magenta")
table.add_column("Operation")
table.add_column("Name")
table.add_column("definition", justify="rig... | true |
9a0da529fb43142576f3b3fbdbb6b7c57f16b43d | LPRowe/coding-interview-practice | /old_practice_problems/arcade/intro-problems/medium/differentSquares.py | 1,968 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 12 15:33:49 2020
@author: Logan Rowe
Given a rectangular matrix containing only digits, calculate the number of
different 2 × 2 squares in it.
Example
For
matrix = [[1, 2, 1],
[2, 2, 2],
[2, 2, 2],
[1, 2, 3],
[2, 2, 1]]
the out... | true |
1d4cc0819b5c9eef6f4cdc3e882e846d01015c7e | LPRowe/coding-interview-practice | /old_practice_problems/arcade/the-core/easy/maxMultiple.py | 800 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 14 01:17:39 2020
@author: Logan Rowe
Given a divisor and a bound, find the largest integer N such that:
N is divisible by divisor.
N is less than or equal to bound.
N is greater than 0.
It is guaranteed that such a number exists.
Example
For divisor = 3 and bound = 10... | true |
0b7d12b2b0078bca907ad3b43265677292847095 | LPRowe/coding-interview-practice | /old_practice_problems/arcade/the-core/easy/isPower.py | 850 | 4.40625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 28 23:27:44 2020
@author: Logan Rowe
Determine if the given number is a power of some non-negative integer.
Example
For n = 125, the output should be
isPower(n) = true;
For n = 72, the output should be
isPower(n) = false.
Input/Output
[execution time limit] 4 seconds ... | true |
49f2535edd0545871fd80034a9072aa924e534d6 | LPRowe/coding-interview-practice | /old_practice_problems/arcade/intro-problems/easy/firstDigit.py | 750 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 11 16:19:30 2020
@author: Logan Rowe
Find the leftmost digit that occurs in a given string.
Example
For inputString = "var_1__Int", the output should be
firstDigit(inputString) = '1';
For inputString = "q2q-q", the output should be
firstDigit(inputString) = '2';
For in... | true |
57e4c52a2663ed81bd17e4e974ac01753b16d229 | LPRowe/coding-interview-practice | /old_practice_problems/arcade/intro-problems/medium/sumUpNumbers.py | 1,323 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 12 15:22:54 2020
@author: Logan Rowe
CodeMaster has just returned from shopping. He scanned the check of the items
he bought and gave the resulting string to Ratiorg to figure out the total
number of purchased items. Since Ratiorg is a bot he is definitely going to
au... | true |
cd048390e6ff4271612f4419c08bdde85d6e46cb | LPRowe/coding-interview-practice | /old_practice_problems/arcade/intro-problems/medium/isMAC48Address.py | 1,787 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 12 14:12:26 2020
@author: Logan Rowe
A media access control address (MAC address) is a unique identifier assigned
to network interfaces for communications on the physical network segment.
The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly
f... | true |
d9dacebf5ebd6ef9051c70528830d62b91a33bef | LPRowe/coding-interview-practice | /old_practice_problems/arcade/the-core/easy/candles.py | 1,776 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 26 23:55:09 2020
@author: Logan Rowe
When a candle finishes burning it leaves a leftover. makeNew leftovers can be combined to make a new candle, which, when burning down, will in turn leave another leftover.
You have candlesNumber candles in your possession. What's the... | true |
6e4e39ef1e3f02f380442150fcae299204d80700 | LPRowe/coding-interview-practice | /old_practice_problems/data-structures/arrays/rotate-image.py | 1,250 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 6 00:17:31 2020
@author: Logan Rowe
"""
'''
Note: Try to solve this task in-place (with O(1) additional memory),
since this is what you'll be asked to do during an interview.
You are given an n x n 2D matrix that represents an image.
Rotate the image by 90 degrees (c... | true |
41b7a79d1f6f5ebcc8883b858377d36023b20684 | LPRowe/coding-interview-practice | /old_practice_problems/data-structures/arrays/first-non-repeating-character.py | 1,646 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 5 23:14:34 2020
@author: Logan Rowe
Find the index of the first non-repeating character in a string
example strings:
'aaabccc' --> b
'aabbaazaa' --> z
only lowercase alphabetical characters no numbers or symbols.
net coding time: 5 minutes
"""
def first_no... | true |
b9665270de0ffa4c5563bd5210f53e9a27e3e706 | Hayley-Lim/python-challenge | /PyPoll/PyPoll/Resources/main.py | 2,978 | 4.34375 | 4 | import os
import csv
filename = "election_data.csv"
#open and read csv
with open(filename) as csvfile:
csvreader = csv.reader(csvfile,delimiter=",")
#skip the headers
next(csvreader)
#create a variable to calculate the total number of votes cast
num_rows=0
#create an empty list to store... | true |
59d4b30ef06ad903a5b736edfa712a9fb5ccf5ad | idiotfenn/useless-project-example | /source/grades.py | 1,198 | 4.15625 | 4 | #!/bin/python
import pickle
grades = {}
if input("Do you have an existing grade file? (Y/n)")[0].lower() == "y":
try:
grades = pickle.load(open(input("What is the name of the file?"), "rb"))
print("Current grades:")
for name in grades.keys():
print(name + "'s grade is '" + grad... | true |
d778ca7c2235452565996829b4616dd35fdbfb63 | NamrataDutta/Python-Lab-Assignments | /Lab1/Source/Lab-1/Q1.py | 1,410 | 4.375 | 4 | #Initializing symbols list
Symbol =['$','@','#','!']
while True :
passwcheck = input("Enter the password :")
#calculating the length of the entered password and checking the conditions
if len(passwcheck)< 6 :
print("The length of the password should be at least 6 characters long")
continue
elif len(passwc... | true |
6d9e549730a063c0571a395eef8667e2045ad07d | dliberat/django-ghost | /game/Trie.py | 2,324 | 4.15625 | 4 | TRIE_BRANCH = -1
class TrieNode(object):
def __init__(self, depth=0):
self.value = TRIE_BRANCH
self.children = dict()
self.depth = depth
self.height = -1
class Trie(object):
def __init__(self, root=None):
if root is not None:
self.root = root
else:
... | true |
fb90aa5d47986ffae1c45745a7d565f61045e871 | rahul-soshte/hunter-algos | /pythonprac/filterlambda.py | 408 | 4.4375 | 4 | # Python Program to find numbers divisible
# by thirteen from a list using anonymous
# function
# Take a list of numbers.
my_list = [12, 65, 54, 39, 102, 339, 221, 50, 70, ]
# use anonymous function to filter and comparing
# if divisible or not
# result = list(filter(lambda x: (x % 13 == 0), my_list))
result... | true |
2d399c1919baef3640df434bbcf9982ed4ea668a | boluwaji11/Encryption-Project | /main_encryption.py | 2,074 | 4.4375 | 4 | # This program creates an encryption system for text files
import random
# Define the main function
def main():
code_generator()
encryption(code_generator())
decryption(code_generator())
# Define the code generator function
def code_generator():
# Using ASCII characters as the code for encryption
... | true |
523e44db5fd44655991bc6bc96fd9bfa418bca22 | TanyoTanev/SoftUni---Python-Basics | /AscIITable.py | 483 | 4.4375 | 4 | #Print Part of the ASCII Table
#Find online more information about ASCII (American Standard Code for Information Interchange) and write a program that
# prints part of the ASCII table of characters on the console. On the first line of input you will receive the char
# index you should start with and on the second lin... | true |
64358243dce472c36c10421ac185a46ceb5061a4 | maddiegabriel/girlGuides | /guessNumber.py | 995 | 4.21875 | 4 | #!/usr/bin/python
import time
import random
#variables
playersChoice = ''
computerChoice = ''
numOfRounds = 0
computerScore = 0
playerScore = 0
#game:
print("\nIn this game, you have to guess what number the computer chose. If you are right, you win a point!")
print("How many times you want to guess the number?")
nu... | true |
a57cb6139e568863a1ff38d6aac805a0f4a2a978 | UCB-INFO-PYTHON/RamiroCadavidREPO | /week_06/piggy/piggy.py | 2,484 | 4.28125 | 4 | def is_consonant_j(char):
'''A function to check if a character is a consonant. Will return Boolean value'''
# use list of consonants rather than vowels here- just in case there is a non-letter character?
consonants = "bcdfghjklmnpqrstvwxyz"
if char.lower() in consonants:
return(True)
else:
... | true |
f8624797e56ce61ecc66e5ce1cf8093c4f8159ba | SrLozano/HackerRankChallenges | /Python Challenges/maxMin/maxMin.py | 931 | 4.25 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'maxMin' function below.
#
# The function is expected to return a LONG_INTEGER_ARRAY.
# The function accepts following parameters:
# 1. STRING_ARRAY operations
# 2. INTEGER_ARRAY x
#
def maxMin(operations, x):
aux = [] #a... | true |
731248cf020ce90eab79b65633a5f4c4f36e45f0 | rohaaan/Data-Structures-and-Algorithms-using-Python | /iterative_recursion.py | 1,556 | 4.46875 | 4 | #===============================================================================
# Name: Iterative_Recursion
# Purpose: Demonstrate implementation of recursion using iterations.
# Note for other contributors: Do not forget to <<Update>> the 'History' block.
# History:
# Date: 14 Jan 2017
# Author: Rohan Kumbhar
... | true |
d112479e65b846b64f94222d447c262759312cf4 | Sandylin520/Python_Learning | /L10_Erros _and_Exception/test_.py | 944 | 4.15625 | 4 | import unittest
import cap
# When this lowercase python gets passed into the text function,
# that it always returns back the capitalized P version of Python.
class TestCap(unittest.TestCase):
def test_one_word(self):
text = 'python'
result = cap.cap_text(text)
self.assertEqual(result,"Pyt... | true |
6085e915022a3f65afb3a696aeec0fa71f6465d4 | nadja-git/T_T_T | /Tic_Tac_Toe.py | 2,978 | 4.4375 | 4 | #Step 1: Write a function that can print out a board.
# Set up your board as a list, where each index 1-9 corresponds with a number on a number pad,
# so you get a 3 by 3 board representation.
def display_board(board):
clear_output()
print(' '+ board[7]+ ' | ' +board[8]+ ' | ' +board[9])
print('---... | true |
66274167af58f857896c21383d83fc622e6bf701 | bara-dankova/Exercise14 | /rockpaperscissors.py | 1,718 | 4.4375 | 4 | # import modules
from random import randint
# define function with no parameters
def rps():
# ask user for input and make sure they enter one of the three options
human = input("Please enter R for ROCK, P for PAPER or S for SCISSORS: ")
while not human in ["R", "P", "S"]:
human = input("Please ente... | true |
6365d34cd320b5c5ac71141e4d2ac95c9d78aeb1 | ashok159/Intro-to-CS-Programs | /Celsius to Fahrenheit.py | 235 | 4.15625 | 4 | #Name: Ashok Surujdeo
#Date: February 23, 2021
#Email: Ashok.Surujdeo65@myhunter.cuny.edu
#This program runs: Celsius to Fahrenheit
C = int(input("Please enter the temperature in degrees Celsius: "))
F = (C*9/5)+32
print ("The temperature is", F, "degrees Fahrenheit")
| true |
82ee7ecb2037036dfd0a5ee80a0bf92415efd1df | harrisonm12/ReadingJournal | /shapes.py | 2,198 | 4.375 | 4 | import turtle
#------------------------------------------------------------------------------
# Starter code to get things going
# (feel free to delete once you've written your own functions
#------------------------------------------------------------------------------
# Create the world, and a turtle to put in it
b... | true |
2bfe8d15a454fac5c48070e92d22658c3ec5efab | kp425/Competitive-Coding | /DS/Tree.py | 2,519 | 4.15625 | 4 | import Queue
class Node:
def __init__(self, value):
self.value = value
self.lChild = None
self.rChild = None
class Tree:
def __init__(self, *args):
self.root = None
def find(self, value):
temp_node = self.root
while(temp_node != None):
if(value < temp_node.value):
temp_node = temp_node.l... | true |
73dd5fb7e875c476ab3c8a5efcc34b008749af49 | Marist-CMPT120-FA19/-Kathryn-McCullough--Lab-5 | /sentence-stats.py | 762 | 4.34375 | 4 | #name: Kathryn McCullough
#e-mail address: kathryn.mccullough1@marist.edu
#description: Make a program where the user can input text and the computer can output stats on the text
def text():
print("This program accepts a sentence as input and computes")
print("a variety of statistics about the sentence.\... | true |
aedc7fd805bd122844c79ebf7cc72092006068e7 | gl051/python-samples | /samples/super/teacher.py | 771 | 4.15625 | 4 | from individual import Individual
class Teacher(Individual):
""" A teacher is an individual """
def __init__(self, firstname, lastname, subject):
super().__init__(firstname, lastname)
self._subject = subject
""" Override the parent method """
def fullname(self):
return f'{self... | true |
4034c46b91aba38fa3409981ce38695961a91697 | Praveenstein/pythonBasic | /closest_number/finding_closest_number.py | 1,232 | 4.59375 | 5 | # -*- coding: utf-8 -*-
""" Finding the closest number
This script allows the user to find the closest number
to a given positive integer N, that could be expressed
as 2^p
This script requires that `math` be installed within the Python
environment you are running this script in.
This file contains the following func... | true |
0cd5970584591d3c5b4823974b6e17ed2e4ee6fc | agonzalezcurci/class-work | /ex10.4.py | 491 | 4.625 | 5 | #Dictionaries have item method which returns a list of tuples which can now be sorted by key
d = {"b":10, "a":1, "c": 22}
t = list(d.items())
print(t)
t.sort()
print(t)
# combining items, tuple assignments and for, you get a code which traverses the key and values in a dict in a single loop
for key, val in list(d.it... | true |
0c627d4fcc16271c9d79bb8ebc5ee90d9c065517 | agonzalezcurci/class-work | /ex9.0.py | 600 | 4.34375 | 4 | #dictionaries are a map between two indices called a key-value pair
eng2sp = {"one": "uno", "two": "dos", "three": "tres"}
print(eng2sp)
# dictionary key lets you look up attached value
print(eng2sp["two"])
# len returns the number of pairs
print(len(eng2sp))
# in operator tell us if key in dictionary
if "one"... | true |
a167487014eb48554a032e07b12a02a259bce74e | DjFaulkner89/Python-Days_to_hours | /DaysIntoHoursCalculater.py | 1,188 | 4.25 | 4 | calculation_to_units = 24
name_of_unit = "hours"
def days_to_units(num_of_days):
if num_of_days > 0:
return f"{num_of_days} days are {num_of_days * calculation_to_units}{name_of_unit}"
elif num_of_days == 0:
return 'you entered a 0, please return a positive number'
def validate_an... | true |
562d81832674ba78f113f2c839922a0842d1c369 | Milittle/fluent_python | /chapter-01/example-1-1.py | 2,042 | 4.15625 | 4 | #!/usr/bin/python
#-*- coding: utf-8 -*-
# author: milittle
import collections
# create a named tuple Class
Card = collections.namedtuple('Card', ['rank', 'suit'])
class FrenchDeck:
ranks = [str(n) for n in range(2, 11)] + list('JQKA')
suits = 'spades diamonds clubs hearts'.split()
def __init__(self):
... | true |
7f2db9fc3fbca174123898e1d8407e56f1edda40 | CBarreiro96/Mock_Interview_Holberton | /0x01_Shell_C/Code/Alphabet_alternating_Lower_Upper.py | 552 | 4.1875 | 4 | #!/usr/bin/python3
'''
Write a program that prints the ASCII alphabet, in reverse order, alternating lowercase and uppercase (z in lowercase and Y in uppercase) , not followed by a new line.
* You can only use one print function with string format
* You can only use one loop in your code
* You are not allowed... | true |
18f5dba8b4fae4ccf34de64385c10b5434f40aa4 | anubhavv1998/HACKERRANK | /python.py | 1,091 | 4.3125 | 4 | /* In the Gregorian calendar, three conditions are used to identify leap years:
The year can be evenly divided by 4, is a leap year, unless:
The year can be evenly divided by 100, it is NOT a leap year, unless:
The year is also evenly divisible by 400. Then it is a leap year.
This means that in the Gregorian calendar,... | true |
b6f520d5a6dde1a7f5c768577a3e0c3f60099a1c | leamonta/lps_compsci | /problem_sets/ps3_tester.py | 259 | 4.125 | 4 | print("Hi! What's your name?")
name = input()
print("And how old are you?")
age = int(input())
if age < 18:
print("You're cool!")
else:
if name == "Minkus":
print("You're cool!")
else:
print("You're too many years old and your name is not Minkus")
| true |
47daf3f4bdccefd803f7ad9908cfc1d8006e5996 | bqnguyen2002/Project-3-Queue-the-Stacking-of-the-Deque | /Delimiter_Check.py | 2,050 | 4.25 | 4 | import sys # for sys.argv, the command-line arguments
from Stack import Stack
def delimiter_check(filename):
# TODO replace pass with an implementation that returns True
# if the delimiters (), [], and {} are balanced and False otherwise.
#Source: https://stackoverflow.com/questions/2988211/how-to-... | true |
099aa63890d2cd866166e90362912e4a267756d1 | philip-bbaale/Algorithms | /valid_parenthesis.py | 1,046 | 4.125 | 4 | class Solution:
def isValid(self, s: str) -> bool:
self.s = s
s_copy = []
openings = ["(", "{", "["]
closings = [')', '}', ']']
valid_pairs = ['()', '{}', '[]']
for i in self.s:
if i in openings:
s_copy.append(i)
if i... | true |
778904e30ec13b852e1e771d0c63d834c001aca3 | zubairwazir/technical_tests | /insertion_sort.py | 836 | 4.375 | 4 | def insertion_sort(array):
for index in range(1, len(array)):
position = index
temp_value = array[index]
while position > 0 and array[position - 1] > temp_value:
array[position] = array[position - 1]
position = position - 1
array[position] = temp_value
""... | true |
f0916dcc56641ce7932ee61c76d3587ae7fb3c79 | Skiller9090/GetDone | /Projects/tutorials/Python 3/for loops.py | 311 | 4.34375 | 4 | '''
A for loop is a loop what iterates over a set of data...
'''
for i in range(0,15): # This loop will print all whole numbers from 0 to 15 not including 15.
print(i)
for i in "string": # Every loop it will set i to the next letter of the string so 1st loop i == s, 2nd loop i == t and so on...
print(i)
| true |
1fc02b4cebc3fce06c6dc9259f21fda600722d04 | Skiller9090/GetDone | /Projects/tutorials/Python 3/tkinter.py | 683 | 4.25 | 4 | from tkinter import * # import tkinter
root = Tk() # creates tkinter windows and sets it to the root variable
def printhi(): # Creates a defintion (A definiton is a code which can be called on)
print("Hi") # The code in the definition in this case it prints Hi
title_label = Label(root,text="This is a test") # create... | true |
9d65ecff4e032897bdb06f573480581713a1df9f | HafseeMan/SCAWeek3 | /week4.py | 816 | 4.46875 | 4 | import re
# Assignment: Using conditional statements, loops and regular expression in program.
attendance = ["hafsah","boy","manal","zainab","rashida"]
#checks if any of the attendees is "boy". loops through the list.
for name in attendance:
if(name == "boy"):
print(name + ": SCA is for GIRLS ONLY. Access ... | true |
59ff85d078bf8f6db316b15e5fa5a090aa417f51 | FRodrigues42/telephone_numbers | /telephone_numbers.py | 1,639 | 4.40625 | 4 | import re
def get_telephone_numbers(s):
"""
Parses a string with a telephone number to get only the area code,
the sub area code and the rest of the number.
Returns: A tuple of strings.
"""
numbers = get_phone_numbers(s)
if not numbers:
# This condition is for the cas... | true |
34207cb4fb5ac182f43c409a40bf05ed53a13789 | Rocket-007/First-year-College-Class-Projects-2021- | /loginproblem.py | 1,067 | 4.15625 | 4 | userName = input("Hello! K-Tech Industrues! \n\nUsername: ")
password = input("Password: ")
count = 0
count += 1
while userName == userName and password == password:
if count == 3:
print("\nThree Username and Password Attempts used. Goodbye")
break
elif userName == 'kenneth' and pas... | true |
2a5da8e90eef49f556e66e0a7a7eed65aa06e2d6 | ewangplay/exercise | /python/sample/test09.py | 202 | 4.125 | 4 | #!/usr/bin/python
def max(a,b):
if(a>b):
print a
else:
print b
x=int(raw_input('Enter the first integer: '))
y=int(raw_input('Enter the second integer: '))
print 'the max integer is: ',max(x,y)
| true |
2ed45c5ca5562f87d352b48d385348db73ea692f | HalaAlmulhim/Python- | /python/python_fundamentals/Functions Basic II.py | 2,361 | 4.46875 | 4 | #1 Countdown - Create a function that accepts a number as an input.
# Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element).
#Example: countdown(5) should return [5,4,3,2,1,0]
def Countdown(num):
num_list = []
for val in range(num, -1,-1):
num_... | true |
8fc390c8b9b691219b4f7c0b1001c2be117596dd | bhavinidata/DataStructuresAndAlgorithms | /TreesAndGraphs/compareBinaryTrees.py | 1,574 | 4.1875 | 4 | # Write an efficient algorithm thats able to compare
# two binary search trees. The method returns
# true if the trees are identical (same topology
# with same values in the nodes) otherwise it returns false.
# =========================================================
class TreeNode:
def __init__(self, x):
... | true |
d8e36fe7f67429889a18d994e00382993e7956af | arjungoel/Python-for-Data-Science-and-ML-BootCamp | /Python for Data Science and ML Udemy/Abstraction in Python/abc2.py | 665 | 4.40625 | 4 | # Abstract class and Abtsract method in Python...
from abc import ABC, abstractmethod
#Enforcing Abstraction...
class Animal(ABC):
@abstractmethod #using abstractmethod as a decorator...
def move(self):
pass
class Human(Animal):
def move(self):
print("The human can run and speak")
... | true |
b08a4533e2449792fe905e13dcdf357cf8a70721 | clipklop/treehouse | /algorithms/quicksort.py | 519 | 4.125 | 4 | """
* Algorithms: Quicksort
"""
import random
import sys
import os
from helper.load import load_numbers
numbers = load_numbers(sys.argv[1])
def quicksort(values):
"""Divide and Conquer"""
if len(values) <= 1:
return values
pivot = values[0]
less = [x for x in values[1:] if x <= pivot]... | true |
521486eb3d0c31d49581eb406bcccaab42d10ffe | joseph-palermo/ICS3U-Unit4-03-Python | /for.py | 554 | 4.3125 | 4 | #!/usr/bin/env python3
# Created by: Joseph Palermo
# Created on: October 2019
# This program uses a for do while loop to get the factorial of integers
def main():
# this function uses a for do while loop to get the factorial of integers
# variables
counter = 0
square = 1
# input
integer = ... | true |
46483bcc9ff617e69f54e683c1ce657de413290f | ppwatchic/abbreviated-intro-to-python | /age_in_2035.py | 1,011 | 4.21875 | 4 | """
ITERATION ONE:
Write a program that displays your first name and age today in 2015.
The program should also dispaly your age in 2035.
Provided is some code showing you how to start.
"""
name = "Pingping"
age_today = 31
print name + " is " + str(age_today) + " years old today."
# TODO: Find how many years from no... | true |
5d0b3f2798c0a5bd63658a263565d6ec64f61f17 | kevinot-codingdojo/python_pract | /python_pract/testes.py | 526 | 4.15625 | 4 | # def add(a,b):
# x = a + b
# return x
# # the return value gets assigned to the "result" variable
# result = add(3,5)
# print result # this should print 8
# def multiply(arr,num):
# print arr, num
# for x in arr:
# print x
# x *= num
# print arr
# return arr
# a = [2,4,10,16]
# ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.