blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
b86433902a7cf3e9dcba2d7f254c4318656ca7f7 | heba-ali2030/number_guessing_game | /guess_game.py | 2,509 | 4.1875 | 4 | import random
# check validity of user input
# 1- check numbers
def check_validity(user_guess):
while user_guess.isdigit() == False:
user_guess = input('please enter a valid number to continue: ')
return (int(user_guess))
# 2- check string
def check_name(name):
while name.isalpha() == False:
... | true |
01a31344d5f0af270c71baa134890070081a1d5c | ColgateLeoAscenzi/COMPUTERSCIENCE101 | /LAB/Lab01_challenge.py | 898 | 4.28125 | 4 |
import time
import random
#Sets up the human like AI, and asks a random question every time
AI = random.randint(1,3)
if AI == 1:
print "Please type a number with a decimal!"
elif AI == 2:
print "Give me a decimal number please!"
elif AI == 3:
print "Please enter a decimal number!"
#defines t... | true |
676f4845dc145feee1be508213721e26f2e55b2a | ColgateLeoAscenzi/COMPUTERSCIENCE101 | /HOMEWORK/hw3_leap.py | 2,055 | 4.15625 | 4 | # ----------------------------------------------------------
# -------- PROGRAM 3 ---------
# ----------------------------------------------------------
# ----------------------------------------------------------
# Please answer these questions after having completed this
# program
# ---... | true |
7004bc9b49acc1a75ac18e448c2256cbec808cf4 | CodyPerdew/TireDegredation | /tirescript.py | 1,350 | 4.15625 | 4 | #This is a simple depreciation calculator for use in racing simulations
#Users will note their tire % after 1 lap of testing, this lets us anticipate
#how much any given tire will degrade in one lap.
#From there the depreciation is calculated.
sst=100 #Set tire life to 100%
st=100
mt=100
ht=100
p... | true |
f0afa65944197e58bad3e76686cef9c2813ab16d | chrismlee26/chatbot | /sample.py | 2,521 | 4.34375 | 4 | # This will give you access to the random module or library.
# choice() will randomly return an element in a list.
# Read more: https://pynative.com/python-random-choice/
from random import choice
#combine functions and conditionals to get a response from the bot
def get_mood_bot_response(user_response):
#add some... | true |
e8642c64ba0981f3719635db11e52a0823e89b68 | league-python/Level1-Module0 | /_02_strings/_a_intro_to_strings.py | 2,954 | 4.6875 | 5 | """
Below is a demo of how to use different string methods in Python
For a complete reference:
https://docs.python.org/3/library/string.html
"""
# No code needs to be written in this file. Use it as a reference for the
# following projects.
if __name__ == '__main__':
# Declaring and initializing a string variabl... | true |
f17492efff4bbe8ce87a626abfece629c0297a83 | prajjwalkumar17/DSA_Problems- | /dp/length_common_decreasing_subsequence.py | 1,918 | 4.375 | 4 | """ Python program to find the Length of Longest Decreasing Subsequence
Given an array we have to find the length of the longest decreasing subsequence that array can make.
The problem can be solved using Dynamic Programming.
"""
def length_longest_decreasing_subsequence(arr, n):
max_len = 0
dp = []
# In... | true |
97174dfe60fdb0b7415ba87061573204d41490bc | rosa637033/OOAD_project_2 | /Animal.py | 597 | 4.15625 | 4 | from interface import move
class Animal:
#Constructor
def __init__(self, name, move:move):
self.name = name
self._move = move
# any move method that is in class move
def setMove(self, move) -> move:
self._move = move
# This is where strategy pattern is implemented.
def ... | true |
fb05fad10a27e03c50ef987443726e2acd11d49a | adamchainz/workshop-concurrency-and-parallelism | /ex4_big_o.py | 777 | 4.125 | 4 | from __future__ import annotations
def add_numbers(a: int, b: int) -> int:
return a + b
# TODO: time complexity is: O(_)
def add_lists(a: list[int], b: list[int]) -> list[int]:
return a + b
# TODO: time complexity is O(_)
# where n = total length of lists a and b
def unique_items(items: list[i... | true |
7c4b8a424c943510052f6b15b10a06a402c06f08 | prasadnaidu1/django | /Adv python practice/QUESTIONS/10.py | 845 | 4.125 | 4 | #Question:
#Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
#Suppose the following input is supplied to the program:
#hello world and practice makes perfect and hello world again
#Then, the output s... | true |
11b760a6ae93888c812d6d2912eb794d98e9c3e0 | mohadesasharifi/codes | /pyprac/dic.py | 700 | 4.125 | 4 | """
Python dictionaries
"""
# information is stored in the list is [age, height, weight]
d = {"ahsan": [35, 5.9, 75],
"mohad": [24, 5.5, 50],
"moein": [5, 3, 20],
"ayath": [1, 1.5, 12]
}
print(d)
d["simin"] = [14, 5, 60]
d.update({"simin": [14, 5, 60]})
print(d)
age = d["mohad"][0]
print(age)
for k... | true |
b6ba17928cbcb5370f5d144e64353b9d0cd8fcbd | Mohsenabdn/projectEuler | /p004_largestPalindromeProduct.py | 792 | 4.125 | 4 | # Finding the largest palindrome number made by product of two 3-digits numbers
import numpy as np
import time as t
def is_palindrome(num):
""" Input : An integer number
Output : A bool type (True: input is palindrome, False: input is not
palindrome) """
numStr = str(num)
for i in range(len(numS... | true |
82aff3d2c7f6ad8e4de6df39d481df878a7450f7 | sree714/python | /printVowel.py | 531 | 4.25 | 4 | #4.Write a program that prints only those words that start with a vowel. (use
#standard function)
test_list = ["all", "love", "and", "get", "educated", "by", "gfg"]
print("The original list is : " + str(test_list))
res = []
def fun():
vow = "aeiou"
for sub in test_list:
flag = False
... | true |
8d6df43f43f157324d5ce3012252c3c89d8ffba4 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/gpa_calculator.py | 688 | 4.15625 | 4 | print "Hi,Yao! Let's calculate the students' GPA!"
LS_grade = float(raw_input ("What is the LS grade?")) # define variable with a string and input, no need to use "print" here.
G_grade = float(raw_input ("What is the G grade?")) # double (()) works
RW_grade = float(raw_input ("What is the RW grade?"))
F... | true |
6cefa99cdb92c9ed5738d4a40855a78b22e23b1b | Vladyslav92/Python_HW | /lesson_8/1_task.py | 2,363 | 4.34375 | 4 | # mobile numbers
# https://www.hackerrank.com/challenges/standardize-mobile-number-using-decorators/problem
# Let's dive into decorators! You are given mobile numbers.
# Sort them in ascending order then print them in the standard format shown below:
# +91 xxxxx xxxxx
# The given mobile numbers may have +91, 91 or 0 wr... | true |
a1d76dd2a74db5557596f2f3da1fbb2bf70474d2 | chavadasagar/python | /reverse_string.py | 204 | 4.40625 | 4 | def reverse_str(string):
reverse_string = ""
for x in string:
reverse_string = x + reverse_string;
return reverse_string
string = input("Enter String :")
print(reverse_str(string))
| true |
86643c2fe7599d5b77bdcbe3e6c35aa88ba98ecc | aemperor/python_scripts | /GuessingGame.py | 2,703 | 4.25 | 4 | ## File: GuessingGame.py
# Description: This is a game that guesses a number between 1 and 100 that the user is thinking within in 7 tries or less.
# Developer Name: Alexis Emperador
# Date Created: 11/10/10
# Date Last Modified: 11/11/10
###################################
def main():
#... | true |
4978f92dab090fbf4862c4b6eca6db01150cf0b7 | aemperor/python_scripts | /CalcSqrt.py | 1,059 | 4.1875 | 4 | # File: CalcSqrt.py
# Description: This program calculates the square root of a number n and returns the square root and the difference.
# Developer Name: Alexis Emperador
# Date Created: 9/29/10
# Date Last Modified: 9/30/10
##################################
def main():
#Prompts user for a + num... | true |
a7eda8fb8d385472dc0be76be4a5397e7473f724 | petyakostova/Software-University | /Programming Basics with Python/First_Steps_in_Coding/06_Square_of_Stars.py | 237 | 4.15625 | 4 | '''Write a console program that reads a positive N integer from the console
and prints a console square of N asterisks.'''
n = int(input())
print('*' * n)
for i in range(0, n - 2):
print('*' + ' ' * (n - 2) + '*')
print('*' * n)
| true |
3f25e4489c087b731396677d6337e4ad8633e793 | petyakostova/Software-University | /Programming Basics with Python/Simple-Calculations/08-Triangle-Area.py | 317 | 4.3125 | 4 | '''
Write a program that reads from the console side and triangle height
and calculates its face.
Use the face to triangle formula: area = a * h / 2.
Round the result to 2 decimal places using
float("{0:.2f}".format (area))
'''
a = float(input())
h = float(input())
area = a * h / 2;
print("{0:.2f}".format(area))
| true |
87f5fd7703bafe4891fb042de2a7f1770c602995 | BreeAnnaV/CSE | /BreeAnna Virrueta - Guessgame.py | 771 | 4.1875 | 4 | import random
# BreeAnna Virrueta
# 1) Generate Random Number
# 2) Take an input (number) from the user
# 3) Compare input to generated number
# 4) Add "Higher" or "Lower" statements
# 5) Add 5 guesses
number = random.randint(1, 50)
# print(number)
guess = input("What is your guess? ")
# Initializing Variables
ans... | true |
6a59184a4ae0cee597a190f323850bb706c09b11 | BreeAnnaV/CSE | /BreeAnna Virrueta - Hangman.py | 730 | 4.3125 | 4 | import random
import string
"""
A general guide for Hangman
1. Make a word bank - 10 items
2. Pick a random item from the list
3. Add a guess to the list of letters guessed Hide the word (use *) (letters_guessed = [...])
4. Reveal letters already guessed
5. Create the win condition
"""
guesses_left = 10
word_bank = [... | true |
6f3f133dbbc8fc6519c54cc234da5b367ee9e80d | stark276/Backwards-Poetry | /poetry.py | 1,535 | 4.21875 | 4 | import random
poem = """
I have half my father's face
& not a measure of his flair
for the dramatic. Never once
have I prayed & had another man's wife
wail in return.
"""
list_of_lines = poem.split("\n")
# Your code should implement the lines_printed_backwards() function.
# This function takes in a list of strings... | true |
955d4bebf2c1c01ac20c697a2bba0809a4b51b46 | patilpyash/practical | /largest_updated.py | 252 | 4.125 | 4 | print("Program To Find Largest No Amont 2 Nos:")
print("*"*75)
a=int(input("Enter The First No:"))
b=int(input("Enter The Second No:"))
if a>b:
print("The Largest No Is",a)
else:
print("The Largest No Is",b)
input("Enter To Continue") | true |
b939c070c0cbdfa664cea3750a0a6805af4c6a10 | Yatin-Singla/InterviewPrep | /Leetcode/RouteBetweenNodes.py | 1,013 | 4.15625 | 4 | # Question: Given a directed graph, design an algorithm to find out whether there is a route between two nodes.
# Explanation
"""
I would like to use BFS instead of DFS as DFS might pigeonhole our search through neighbor's neighbor whereas the target
might the next neighbor
Additionally I'm not using Bi-directional ... | true |
e92e09888bff7072f27d3d24313f3d53e37fc7dc | Yatin-Singla/InterviewPrep | /Leetcode/Primes.py | 609 | 4.1875 | 4 | '''
Write a program that takes an integer argument and returns all the rpimes between 1 and that integer.
For example, if hte input is 18, you should return <2,3,5,7,11,13,17>.
'''
from math import sqrt
# Method name Sieve of Eratosthenes
def ComputePrimes(N: int) -> [int]:
# N inclusive
ProbablePrimes = [True... | true |
b9a12d0975be4ef79abf88df0b083da68113e76b | Yatin-Singla/InterviewPrep | /Leetcode/ContainsDuplicate.py | 730 | 4.125 | 4 | # Given an array of integers, find if the array contains any duplicates.
# Your function should return true if any value appears at least twice in the array,
# and it should return false if every element is distinct.
# * Example 1:
# Input: [1,2,3,1]
# Output: true
# * Example 2:
# Input: [1,2,3,4]
# Output: false
# * ... | true |
b459e8a597c655f68401d3c8c73a68decfba186e | Yatin-Singla/InterviewPrep | /Leetcode/StringCompression.py | 1,090 | 4.4375 | 4 | '''
Implement a method to perform basic string compression using the counts of repeated characters.
For example, the string aabccccaa would become a2b1c5a3.
If the compressed string would not become smaller than the original string,
you method should return the original string. Assume the string has only uppercase an... | true |
74d654a737cd20199860c4a8703663780683cea4 | quanzt/LearnPythons | /src/guessTheNumber.py | 659 | 4.25 | 4 | import random
secretNumber = random.randint(1, 20)
print('I am thinking of a number between 1 and 20.')
#Ask the player to guess 6 times.
for guessesTaken in range(1, 7):
print('Take a guess.')
guess = int(input())
if guess < secretNumber:
print('Your guess is too low')
elif guess > secretNumb... | true |
0a5d7f42c11be6f4fb2f9ede8340876192080d8d | Dana-Georgescu/python_challenges | /diagonal_difference.py | 631 | 4.25 | 4 | #!/bin/python3
''' Challenge from https://www.hackerrank.com/challenges/diagonal-difference/problem?h_r=internal-search'''
#
# Complete the 'diagonalDifference' function below.
#
# The function is expected to return an INTEGER.
# The function accepts 2D_INTEGER_ARRAY arr as parameter.
#
def diagonalDifference():
... | true |
537eb97c8fa707e1aee1881d95b2bf497123fd67 | jeffsilverm/big_O_notation | /time_linear_searches.py | 2,520 | 4.25 | 4 | #! /usr/bin/env python
#
# This program times various search algorithms
# N, where N is the size of a list of strings to be sorted. The key to the corpus
# is the position of the value to be searched for in the list.
# N is passed as an argument on the command line.
import linear_search
import random
import sys
corpu... | true |
abbb02f14ecbea14004de28fc5d5daddf65bb63e | jeffsilverm/big_O_notation | /iterative_binary_search.py | 1,292 | 4.1875 | 4 | #! /usr/bin/env python
#
# This program is an implementation of an iterative binary search
#
# Algorithm from http://rosettacode.org/wiki/Binary_search#Python
def iterative_binary_search(corpus, value_sought) :
"""Search for value_sought in corpus corpus"""
# Note that because Python is a loosely typed language,... | true |
0fd4177666e9d395da20b8dfbfae9a300e53f873 | jhoneal/Python-class | /pin.py | 589 | 4.25 | 4 | """Basic Loops
1. PIN Number
Create an integer named [pin] and set it to a 4-digit number.
Welcome the user to your application and ask them to enter their pin.
If they get it wrong, print out "INCORRECT PIN. PLEASE TRY AGAIN"
Keep asking them to enter their pin until they get it right.
Finally, print "PIN ACCEPTED. ... | true |
bf92d64a05ccf277b13dd50b1e21f261c5bba43c | NikitaBoers/improved-octo-sniffle | /averagewordlength.py | 356 | 4.15625 | 4 | sentence=input('Write a sentence of at least 10 words: ')
wordlist= sentence.strip().split(' ')
for i in wordlist:
print(i)
totallength= 0
for i in wordlist :
totallength =totallength+len(i)
averagelength=totallength/ len(wordlist)
combined_string= "The average length of the words in this sentence is "+str(ave... | true |
292ad196eaee7aab34dea95ac5fe622281b1a845 | LJ1234com/Pandas-Study | /06-Function_Application.py | 969 | 4.21875 | 4 | import pandas as pd
import numpy as np
'''
pipe(): Table wise Function Application
apply(): Row or Column Wise Function Application
applymap(): Element wise Function Application on DataFrame
map(): Element wise Function Application on Series
'''
############### Table-wise Function Application ####... | true |
e45c11a712bf5cd1283f1130184340c4a8280d13 | LJ1234com/Pandas-Study | /21-Timedelta.py | 642 | 4.125 | 4 | import pandas as pd
'''
-String: By passing a string literal, we can create a timedelta object.
-Integer: By passing an integer value with the unit, an argument creates a Timedelta object.
'''
print(pd.Timedelta('2 days 2 hours 15 minutes 30 seconds'))
print(pd.Timedelta(6,unit='h'))
print(pd.Timedelta(days=2)... | true |
4c4d5e88fde9f486210ef5bd1595775e0adce53c | aiworld2020/pythonprojects | /number_99.py | 1,433 | 4.125 | 4 | answer = int(input("I am a magician and I know what the answer will be: "))
while (True):
if answer < 10 or answer > 49:
print("The number chosen is not between 10 and 49")
answer = int(input("I am choosing a number from 10-49, which is: "))
continue
else:
break
factor = 99 - ... | true |
5608d39b85560dc2ea91e943d60716901f5fe88b | longroad41377/selection | /months.py | 337 | 4.4375 | 4 | monthnames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
month = int(input("Enter month number: "))
if month > 0 and month < 13:
print("Month name: {}".format(monthnames[month-1]))
else:
print("Month number must be between 1... | true |
087a85027a5afa03407fed80ccb82e466c4f46ed | ch-bby/R-2 | /ME499/Lab_1/volumes.py | 2,231 | 4.21875 | 4 | #!\usr\bin\env python3
"""ME 499 Lab 1 Part 1-3
Samuel J. Stumbo
This script "builds" on last week's volume calculator by placing it within the context of a function"""
from math import pi
# This function calculates the volumes of a cylinder
def cylinder_volume(r, h):
if type(r) == int and type(h) == int:... | true |
d571d28325d7278964d45a25a4777cf8f121f0ce | ch-bby/R-2 | /ME499/Lab4/shapes.py | 1,430 | 4.46875 | 4 | #!/usr/bin/env python3#
# -*- coding: utf-8 -*-
"""
****************************
ME 499 Spring 2018
Lab_4 Part 1
3 May 2018
Samuel J. Stumbo
****************************
"""
from math import pi
class Circle:
"""
The circle class defines perimeter, diameter and area of a circle
... | true |
393dffa71a0fdb1a5ed69433973afd7d6c73d9ff | neelismail01/common-algorithms | /insertion-sort.py | 239 | 4.15625 | 4 | def insertionSort(array):
# Write your code here.
for i in range(1, len(array)):
temp = i
while temp > 0 and array[temp] < array[temp - 1]:
array[temp], array[temp - 1] = array[temp - 1], array[temp]
temp -= 1
return array
| true |
df11433519e87b3a52407745b274a6db005d767c | jtquisenberry/PythonExamples | /Interview_Cake/hashes/inflight_entertainment_deque.py | 1,754 | 4.15625 | 4 | import unittest
from collections import deque
# https://www.interviewcake.com/question/python/inflight-entertainment?section=hashing-and-hash-tables&course=fc1
# Use deque
# Time = O(n)
# Space = O(n)
# As with the set-based solution, using a deque ensures that the second movie is not
# the same as the current movi... | true |
fcbb62045b3d953faf05dd2b741cd060376ec237 | jtquisenberry/PythonExamples | /Jobs/maze_runner.py | 2,104 | 4.1875 | 4 | # Alternative solution at
# https://www.geeksforgeeks.org/shortest-path-in-a-binary-maze/
# Maze Runner
# 0 1 0 0 0
# 0 0 0 1 0
# 0 1 0 0 0
# 0 0 0 1 0
# 1 - is a wall
# 0 - an empty cell
# a robot - starts at (0,0)
# robot's moves: 1 step up/down/left/right
# exit at (N-1, M-1) (never 1)
# length(of the shortes... | true |
ba8395ab64f7ebb77cbfdb205d828aa552802505 | jtquisenberry/PythonExamples | /Interview_Cake/arrays/reverse_words_in_list_deque.py | 2,112 | 4.25 | 4 | import unittest
from collections import deque
# https://www.interviewcake.com/question/python/reverse-words?section=array-and-string-manipulation&course=fc1
# Solution with deque
def reverse_words(message):
if len(message) < 1:
return message
final_message = deque()
current_word = []
for i ... | true |
9adfabfbc83b97a11ee5b2f23cea5ec2eb357dd5 | jtquisenberry/PythonExamples | /Interview_Cake/sorting/merge_sorted_lists3.py | 1,941 | 4.21875 | 4 | import unittest
from collections import deque
# https://www.interviewcake.com/question/python/merge-sorted-arrays?course=fc1§ion=array-and-string-manipulation
def merge_lists(my_list, alices_list):
# Combine the sorted lists into one large sorted list
if len(my_list) == 0 and len(alices_list) == 0:
... | true |
148c6d9d37a9fd79e06e4371a30c65a5e36066b2 | jtquisenberry/PythonExamples | /Jobs/multiply_large_numbers.py | 2,748 | 4.25 | 4 | import unittest
def multiply(num1, num2):
len1 = len(num1)
len2 = len(num2)
# Simulate Multiplication Like this
# 1234
# 121
# ----
# 1234
# 2468
# 1234
#
# Notice that the product is moved one space to the left each time a digit
# of the top number is multip... | true |
b8b7d0a3067b776d6c712b2f229ef65448b9a4d9 | jtquisenberry/PythonExamples | /Interview_Cake/arrays/reverse_words_in_list_lists.py | 2,120 | 4.375 | 4 | import unittest
from collections import deque
# https://www.interviewcake.com/question/python/reverse-words?section=array-and-string-manipulation&course=fc1
# Solution with lists only
# Not in place
def reverse_words(message):
if len(message) < 1:
return
current_word = []
word_list = []
fina... | true |
4b8c656ea711a2274df26c044ec6a7d7ce7b33bc | bojanuljarevic/Algorithms | /BST/bin_tree/bst.py | 1,621 | 4.15625 | 4 |
# Zadatak 1 : ručno formiranje binarnog stabla pretrage
class Node:
"""
Tree node: left child, right child and data
"""
def __init__(self, p = None, l = None, r = None, d = None):
"""
Node constructor
@param A node data object
"""
self.parent = p
self.le... | true |
5f5e0b19e8b1b6d0b0142eb63621070a50227142 | steven-liu/snippets | /generate_word_variations.py | 1,109 | 4.125 | 4 | import itertools
def generate_variations(template_str, replace_with_chars):
"""Generate variations of a string with certain characters substituted.
All instances of the '*' character in the template_str parameter are
substituted by characters from the replace_with_chars string. This function
generate... | true |
8dbfcde0a480f44ea8f04d113a5214d7ddb9d290 | jgkr95/CSPP1 | /Practice/M6/p1/fizz_buzz.py | 722 | 4.46875 | 4 | '''Write a short program that prints each number from 1 to num on a new line.
For each multiple of 3, print "Fizz" instead of the number.
For each multiple of 5, print "Buzz" instead of the number.
For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.
'''
def main():
'''Read numbe... | true |
86c07784b9a2a69756a3390e8ff70b2a4af78652 | Ashishrsoni15/Python-Assignments | /Question2.py | 391 | 4.21875 | 4 | # What is the type of print function? Also write a program to find its type
# Print Funtion: The print()function prints the specified message to the screen, or other
#standard output device. The message can be a string,or any other object,the object will
#be converted into a string before written to the screen.
p... | true |
6575bbd5e4d495bc5f8b5eee9789183819761452 | Ashishrsoni15/Python-Assignments | /Question1.py | 650 | 4.375 | 4 | #Write a program to find type of input function.
value1 = input("Please enter first integer:\n")
value2 = input("Please enter second integer:\n")
v1 = int(value1)
v2 = int(value2)
choice = input("Enter 1 for addition.\nEnter 2 for subtraction.\nEnter 3 for multiplication:\n")
choice = int(choice)
if choice... | true |
ea4c7aaefa309e8f0db99f4f43867ebd1bd52282 | Shahriar2018/Data-Structures-and-Algorithms | /Task4.py | 1,884 | 4.15625 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 4:
The telephone company want to i... | true |
c6d84e1f238ac03e872eea8c8cb3566ac0913646 | Cpeters1982/DojoPython | /hello_world.py | 2,621 | 4.21875 | 4 | '''Test Document, leave me alone PyLint'''
# def add(a,b):
# x = a + b
# return x
# result = add(3, 5)
# print result
# def multiply(arr, num):
# for x in range(len(arr)):
# arr[x] *= num
# return arr
# a = [2,4,10,16]
# b = multiply(a,5)
# print b
'''
The function multiply takes two parameter... | true |
e6536e8399f1ceccd7eb7d41eddcc302e3dda66b | guv-slime/python-course-examples | /section08_ex04.py | 1,015 | 4.4375 | 4 | # Exercise 4: Expanding on exercise 3, add code to figure out who
# has the most emails in the file. After all the data has been read
# and the dictionary has been created, look through the dictionary using
# a maximum loop (see chapter 5: Maximum and Minimum loops) to find out
# who has the most messages and print how... | true |
f9a66f5b0e776d063d812e7a7185ff6ff3c5615f | maryamkh/MyPractices | /ReverseLinkedList.py | 2,666 | 4.3125 | 4 | '''
Reverse back a linked list
Input: A linked list
Output: Reversed linked list
In fact each node pointing to its fron node should point to it back node ===> Since we only have one direction accessibility to a link list members to reverse it I have to travers the whole list, keep the data of the nodes and then rearra... | true |
145413092625adbe30b158c21e5d27e2ffcfab50 | maryamkh/MyPractices | /Squere_Root.py | 1,838 | 4.1875 | 4 | #!/usr/bin/python
'''
Find the squere root of a number. Return floor(sqr(number)) if the numebr does not have a compelete squere root
Example: input = 11 ===========> output = 3
Function sqrtBinarySearch(self, A): has time complexity O(n), n: given input: When the number is too big it becomes combursome
... | true |
8b9f850c53a2a020b1deea52e301de0d2b6c47c3 | CodingDojoDallas/python_sep_2018 | /austin_parham/user.py | 932 | 4.15625 | 4 | class Bike:
def __init__(self, price, max_speed, miles):
self.price = price
self.max_speed = max_speed
self.miles = miles
def displayInfo(self):
print(self.price)
print(self.max_speed)
print(self.miles)
print('*' * 80)
def ride(self):
print("Riding...")
print("......")
print("......")
self.mi... | true |
36a4f28b97be8be2e7f6e20965bd21f554270704 | krismosk/python-debugging | /area_of_rectangle.py | 1,304 | 4.6875 | 5 | #! /usr/bin/env python3
"A script for calculating the area of a rectangle."
import sys
def area_of_rectangle(height, width = None):
"""
Returns the area of a rectangle.
Parameters
----------
height : int or float
The height of the rectangle.
width : int or float
The width o... | true |
dacaf7998b9ca3a71b6b90690ba952fb56349ab9 | Kanthus123/Python | /Design Patterns/Creational/Abstract Factory/doorfactoryAbs.py | 2,091 | 4.1875 | 4 | #A factory of factories; a factory that groups the individual but related/dependent factories together without specifying their concrete classes.
#Extending our door example from Simple Factory.
#Based on your needs you might get a wooden door from a wooden door shop,
#iron door from an iron shop or a PVC door from th... | true |
ab049070f8348f4af8caeb601aee062cc7a76af2 | Kanthus123/Python | /Design Patterns/Structural/Decorator/VendaDeCafe.py | 1,922 | 4.46875 | 4 | #Decorator pattern lets you dynamically change the behavior of an object at run time by wrapping them in an object of a decorator class.
#Imagine you run a car service shop offering multiple services.
#Now how do you calculate the bill to be charged?
#You pick one service and dynamically keep adding to it the prices f... | true |
861fab844f5dcbf86c67738354803e27a0a303e9 | russellgao/algorithm | /dailyQuestion/2020/2020-05/05-31/python/solution_recursion.py | 950 | 4.21875 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# 递归
def isSymmetric(root: TreeNode) -> bool:
def check(left, right):
if not left and not right:
return True
if not left or not right:
... | true |
20bb2a14fbb695fa1d1868147e8e2afc147cecc3 | fatychang/pyimageresearch_examples | /ch10 Neural Network Basics/perceptron_example.py | 1,157 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 9 12:56:47 2019
This is an example for runing percenptron structure to predict bitwise dataset
You may use AND, OR and XOR in as the dataset.
A preceptron class is called in this example.
An example from book deep learning for computer vision with Python ch10
@author: ... | true |
847ace6bebef81ef053d6a0268fa54e36072dd72 | chenshaobin/python_100 | /ex2.py | 1,113 | 4.1875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
# Write a program which can compute the factorial of a given numbers.
# The results should be printed in a comma-separated sequence on a single line.Suppose the following input is supplied to the program: 8 Then, the output should be:40320
"""
# 使用while
"""
n = int... | true |
baa5ff5f08103e624b90c7a754f0f5cc60429f0e | chenshaobin/python_100 | /ex9.py | 581 | 4.15625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
# Write a program that accepts sequence of lines as input
# and prints the lines after making all characters in the sentence capitalized.
"""
# solution1
"""
lst = []
while True:
x = input("Please enter one word:")
if len(x) == 0:
break
lst.appen... | true |
eaeed21766f75657270303ddac34c8dcae8f4f01 | Scientific-Computing-at-Temple-Physics/prime-number-finder-gt8mar | /Forst_prime.py | 605 | 4.375 | 4 | # Marcus Forst
# Scientific Computing I
# Prime Number Selector
# This function prints all of the prime numbers between two entered values.
import math as ma
# These functions ask for the number range, and assign them to 'x1' and 'x2'
x1 = int(input('smallest number to check: '))
x2 = int(input('largest number to ... | true |
4845e44fa0afcea9f4293f45778f6b4ea0da52b0 | jamiegowing/jamiesprojects | /character.py | 402 | 4.28125 | 4 | print("Create your character")
name = input("what is your character's name")
age = int(input("how old is your character"))
strengths = input("what are your character's strengths")
weaknesses = input("what are your character's weaknesses")
print(f"""You'r charicters name is {name}
Your charicter is {age} years old
stren... | true |
142ecec208f83818157ce4c8dff7495892e5d5d2 | yagizhan/project-euler | /python/problem_9.py | 450 | 4.15625 | 4 | # A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
# a2 + b2 = c2
# For example, 32 + 42 = 9 + 16 = 25 = 52.
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.
def abc():
for c in range(1, 1000):
for b in range(1, c):
... | true |
7d45513f6cb612b73473be6dcefaf0d2646bc629 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /decorators.py | 1,146 | 4.96875 | 5 | # INTRODUCTION TO BASIC DECORATORS USING PYTHON 3
# Decorators provide a way to modify functions using other functions.
# This is ideal when you need to extend the functionality of functions
# that you don't want to modify. Let's take a look at this example:
# Made with ❤️ in Python 3 by Alvison Hunter - June 15th, 202... | true |
a2a6348689cab9d87349099ae927cecad07ade1a | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /intro_to_classes_employee.py | 1,839 | 4.65625 | 5 | # --------------------------------------------------------------------------------
# Introduction to classes using getters & setters with an employee details example.
# Made with ❤️ in Python 3 by Alvison Hunter - March 16th, 2021
# JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj
# --------------... | true |
a1f5c161202227c1c43886a0efac0c18be4b2894 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /population_growth.py | 1,199 | 4.375 | 4 | # In a small town the population is p0 = 1000 at the beginning of a year.
# The population regularly increases by 2 percent per year and moreover
# 50 new inhabitants per year come to live in the town. How many years
# does the town need to see its population greater or equal to p = 1200 inhabitants?
# ---------------... | true |
fd287a7a3dad56ef140e053eba439de50cdfd9b6 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /dice.py | 983 | 4.40625 | 4 | #First, you only need the random function to get the results you need :)
import random
#Let us start by getting the response from the user to begin
repeat = input('Would you like to roll the dice [y/n]?\n')
#As long as the user keeps saying yes, we will keep the loop
while repeat != 'n':
# How many dices does the use... | true |
d94493c20365c14ac8393ed9384ec6013cf553d4 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /interest_calc.py | 2,781 | 4.1875 | 4 | # Ok, Let's Suppose you have $100, which you can invest with a 10% return each year.
#After one year, it's 100×1.1=110 dollars, and after two years it's 100×1.1×1.1=121.
#Add code to calculate how much money you end up with after 7 years, and print the result.
# Made with ❤️ in Python 3 by Alvison Hunter - September 4t... | true |
00575e9b32db9476ffc7078e85c58b06d4ed98f2 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /format_phone_number.py | 1,248 | 4.1875 | 4 | # --------------------------------------------------------------------------------
# A simple Phone Number formatter routine for nicaraguan area codes
# Made with ❤️ in Python 3 by Alvison Hunter - April 4th, 2021
# JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj
# -------------------------------... | true |
1c03ec92c1c0b26a9549bf8fd609a8637c1e0918 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /weird_not_weird_variation.py | 960 | 4.34375 | 4 | # -------------------------------------------------------------------------
# Given an integer,n, perform the following conditional actions:
# If n is odd, print Weird
# If n is even and in the inclusive range of 2 to 5, print Not Weird
# If n is even and in the inclusive range of 6 to 20, print Weird
# If n is eve... | true |
1e8270231129139869e687fbab776af985abdacb | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /guess_random_num.py | 871 | 4.34375 | 4 | # -------------------------------------------------------------------------
# Basic operations with Python 3 | Python exercises | Beginner level
# Generate a random number, request user to guess the number
# Made with ❤️ in Python 3 by Alvison Hunter Arnuero - June 4th, 2021
# JavaScript, Python and Web Development tip... | true |
5c92d100afaeff3c941bb94bd906213b11cbd0bd | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /tower_builder.py | 644 | 4.3125 | 4 | # Build Tower by the following given argument:
# number of floors (integer and always greater than 0).
# Tower block is represented as * | Python: return a list;
# Made with ❤️ in Python 3 by Alvison Hunter - Friday, October 16th, 2020
def tower_builder(n_floor):
lst_tower = []
pattern = '*'
width = (n_flo... | true |
9030b8aa3ca6e00f598526efe02f28e3cc8c8fca | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /user_details_cls.py | 2,565 | 4.28125 | 4 | # --------------------------------------------------------------------------------
# Introduction to classes using a basic grading score for an student
# Made with ❤️ in Python 3 by Alvison Hunter - March 16th, 2021
# JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj
# -----------------------------... | true |
9a79519d12b3d7dbdbb68c14cc8f764b40db1511 | ChristianECG/30-Days-of-Code_HackerRank | /09.py | 1,451 | 4.40625 | 4 | # ||-------------------------------------------------------||
# ||----------------- Day 9: Recursion 3 ------------------||
# ||-------------------------------------------------------||
# Objective
# Today, we're learning and practicing an algorithmic concept
# called Recursion. Check out the Tutorial tab for learning... | true |
7405e9613731ccfdc5da27bf26cf12059e8b4899 | ChristianECG/30-Days-of-Code_HackerRank | /11.py | 1,745 | 4.28125 | 4 | # ||-------------------------------------------------------||
# ||---------------- Day 11: 2D Arrays --------------------||
# ||-------------------------------------------------------||
# Objective
# Today, we're building on our knowledge of Arrays by adding
# another dimension. Check out the Tutorial tab for learning... | true |
7af39c66eba7f0299a47f3674f199233923b4ba9 | abasired/Data_struct_algos | /DSA_Project_2/file_recursion_problem2.py | 1,545 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 19:21:50 2020
@author: ashishbasireddy
"""
import os
def find_files(suffix, path):
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also cont... | true |
782b07d8fc6ca8ee98695353aa91f9d6794ea9ca | Delrorak/python_stack | /python/fundamentals/function_basic2.py | 2,351 | 4.34375 | 4 | #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 add(i):
my_list = []
for i in range(i, 0-1, -1):
my_list.append(i)
... | true |
886c8f7719475fdf6723610d3fb07b1a6566e825 | Chahbouni-Chaimae/Atelier1-2 | /python/invr_chaine.py | 323 | 4.4375 | 4 | def reverse_string(string):
if len(string) == 0:
return string
else:
return reverse_string(string[1:]) + string[0]
string = "is reverse"
print ("The original string is : ",end="")
print (string)
print ("The reversed string is : ",end="")
print (reverse_string(string... | true |
207404ca1e3a25f6a9d008ddbed2c7ca827c789b | eigenric/euler | /euler004.py | 763 | 4.125 | 4 | # author: Ricardo Ruiz
"""
Project Euler Problem 4
=======================
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.
"""
import itertools
def is_pal... | true |
d4d673ef94eca4ddfd5b6713726e507dad1849d6 | abhaj2/Phyton | /sample programs_cycle_1_phyton/13.py | 285 | 4.28125 | 4 | #To find factorial of the given digit
factorial=1
n=int(input("Enter your digit"))
if n>0:
for i in range(1,n+1):
factorial=factorial*i
else:
print(factorial)
elif n==0:
print("The factorial is 1")
else:
print("Factorial does not exits")
| true |
047d6aa0dd53e1adaf6989cd5a977f07d346c73c | abhaj2/Phyton | /sample programs_cycle_1_phyton/11.py | 235 | 4.28125 | 4 | #to check the entered number is +ve or -ve
x=int(input("Enter your number"))
if x>0:
print("{0} is a positive number".format(x))
elif x==0:
print("The entered number is zero")
else:
print("{0} is a negative number".format(x)) | true |
5bd43106071a675af17a6051c9de1f0cee0e0aec | abhaj2/Phyton | /cycle-2/3_c.py | 244 | 4.125 | 4 | wordlist=input("Enter your word\n")
vowel=[]
for x in wordlist:
if('a' in x or 'e' in x or 'i' in x or 'o' in x or'u' in x or 'A' in x or 'E' in x or 'I' in x or 'O'in x or"U" in x):
vowel.append(x)
print(vowel)
| true |
a1a9fc369a0b994c99377dc6af16d00612a68f3b | juliaviolet/Python_For_Everybody | /Overtime_Pay_Error.py | 405 | 4.15625 | 4 | hours=input("Enter Hours:")
rate=input("Enter Rate:")
try:
hours1=float(hours)
rate1=float(rate)
if hours1<=40:
pay=hours1*rate1
pay1=str(pay)
print('Pay:'+'$'+pay1)
elif hours1>40:
overtime=hours1-40.0
pay2=overtime*(rate1*1.5)+40.0*rate1
pay3=str(pay2)
... | true |
6995eed67a401cd363dcfa60b2067ef13732becb | ha1fling/CryptographicAlgorithms | /3-RelativePrimes/Python-Original2017Code/Task 3.py | 1,323 | 4.25 | 4 | while True: #while loop for possibility of repeating program
while True: #integer check for input a
try:
a= input ("Enter a:")
a= int(a)
break
except ValueError:
print ("Not valid, input integers only")
while True: #integer check ... | true |
64d01a920fcf73ad8e0e2f55d894029593dc559d | zitorelova/python-classes | /competition-questions/2012/J1-2012.py | 971 | 4.34375 | 4 | # Input Specification
# The user will be prompted to enter two integers. First, the user will be prompted to enter the speed
# limit. Second, the user will be prompted to enter the recorded speed of the car.
# Output Specification
# If the driver is not speeding, the output should be:
# Congratulations, you are within... | true |
efba9a36610e4837f4723d08518a5255da5a881a | TonyZaitsev/Codewars | /8kyu/Remove First and Last Character/Remove First and Last Character.py | 680 | 4.3125 | 4 | /*
https://www.codewars.com/kata/56bc28ad5bdaeb48760009b0/train/python
Remove First and Last Character
It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry with strings with less ... | true |
0c17db71399217a47698554852206d60743ef93e | TonyZaitsev/Codewars | /7kyu/Reverse Factorials/Reverse Factorials.py | 968 | 4.375 | 4 | """
https://www.codewars.com/kata/58067088c27998b119000451/train/python
Reverse Factorials
I'm sure you're familiar with factorials – that is, the product of an integer and all the integers below it.
For example, 5! = 120, as 5 * 4 * 3 * 2 * 1 = 120
Your challenge is to create a function that takes any number and r... | true |
3d35471031ccadd2fc2e526881b71a7c8b55ddc0 | TonyZaitsev/Codewars | /8kyu/Is your period late?/Is your period late?.py | 1,599 | 4.28125 | 4 | """
https://www.codewars.com/kata/578a8a01e9fd1549e50001f1/train/python
Is your period late?
In this kata, we will make a function to test whether a period is late.
Our function will take three parameters:
last - The Date object with the date of the last period
today - The Date object with the date of the check
c... | true |
019b5d23d15f4b1b28ee9d89112921f4d325375e | TonyZaitsev/Codewars | /7kyu/Sum Factorial/Sum Factorial.py | 1,148 | 4.15625 | 4 | """
https://www.codewars.com/kata/56b0f6243196b9d42d000034/train/python
Sum Factorial
Factorials are often used in probability and are used as an introductory problem for looping constructs. In this kata you will be summing together multiple factorials.
Here are a few examples of factorials:
4 Factorial = 4! = 4 * ... | true |
56be1dd38c46c57d5985d8c85b00895eeca5777d | TonyZaitsev/Codewars | /5kyu/The Hashtag Generator/The Hashtag Generator.py | 2,177 | 4.3125 | 4 | """
https://www.codewars.com/kata/52449b062fb80683ec000024/train/python
The Hashtag Generator
The marketing team is spending way too much time typing in hashtags.
Let's help them with our own Hashtag Generator!
Here's the deal:
It must start with a hashtag (#).
All words must have their first letter capitalized.
If... | true |
3afc1ab7a0de2bb6dc837084dd461865a2c34089 | mirpulatov/racial_bias | /IMAN/utils.py | 651 | 4.15625 | 4 | def zip_longest(iterable1, iterable2):
"""
The .next() method continues until the longest iterable is exhausted.
Till then the shorter iterable starts over.
"""
iter1, iter2 = iter(iterable1), iter(iterable2)
iter1_exhausted = iter2_exhausted = False
while not (iter1_exhausted and iter2_exhausted):
... | true |
77c9f7f18798917cbee5e7fc4044c3a70d73bb33 | amitrajhello/PythonEmcTraining1 | /psguessme.py | 611 | 4.1875 | 4 | """The player will be given 10 chances to guess a number, and when player gives a input, then he should get a feedback
that his number was lesser or greater than the random number """
import random
key = random.randint(1, 1000)
x = 1
while x <= 10:
user_input = int(input('Give a random number to play the ... | true |
67e83fd9552337c410780198f08039044c925965 | Mickey248/ai-tensorflow-bootcamp | /pycharm/venv/list_cheat_sheet.py | 1,062 | 4.3125 | 4 | # Empty list
list1 = []
list1 = ['mouse', [2, 4, 6], ['a']]
print(list1)
# How to access elements in list
list2 = ['p','r','o','b','l','e','m']
print(list2[4])
print(list1[1][1])
# slicing in a list
list2 = ['p','r','o','b','l','e','m']
print(list2[:-5])
#List id mutable !!!!!
odd = [2, 4, 6, 8]
odd[0] = 1
print(o... | true |
c9f325732c1a2732646deadb25c9132f3dcae649 | samir-0711/Area_of_a_circle | /Area.py | 734 | 4.5625 | 5 | import math
import turtle
# create screen
screen = turtle.Screen()
# take input from screen
r = float(screen.textinput("Area of Circle", "Enter the radius of the circle in meter: "))
# draw circle of radius r
t=turtle.Turtle()
t.fillcolor('orange')
t.begin_fill()
t.circle(r)
t.end_fill()
turtle.penup()
# calculate are... | true |
c7ac2454578be3c3497759f156f7bb9f57415433 | dawid86/PythonLearning | /Ex7/ex7.py | 513 | 4.6875 | 5 | # Use words.txt as the file name
# Write a program that prompts for a file name,
# then opens that file and reads through the file,
# and print the contents of the file in upper case.
# Use the file words.txt to produce the output below.
fname = input("Enter file name: ")
fhand = open(fname)
# fread = fhand.read()
# p... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.