blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
3240a4861835743383217a7768313f9a16aa7df0 | mike03052000/python | /Training/HackRank/Level-1/class-2.py | 1,336 | 4.375 | 4 | class Employee:
'Common base class for all employees'
''' An object's attributes may or may not be visible outside the class definition.
You need to name attributes with a double underscore prefix,
and those attributes then are not be directly visible to outsiders.
'''
__empCount = 0... | true |
6a0be9160a8a18409bcaf0d7f7153dad2e2dfeb5 | mike03052000/python | /Training/2014-0110-training/Code_python/Oop/Solutions/point1.py | 2,186 | 4.25 | 4 | #!/usr/bin/env python
"""
Sample classes that support addition of points and calculation of vectors.
"""
import math
NO_COLOR, RED, GREEN, BLUE = range(4)
STR_COLOR_MAP = {
NO_COLOR: 'white',
RED: 'red',
GREEN: 'green',
BLUE: 'blue',
}
class Point(object):
"""A basic Cartesian point that kn... | true |
2ad1f251ebc95fc0efbc57a166695c6f630818a8 | mike03052000/python | /Training/2014-0110-training/Code_python/TextAndFiles/Solutions/filter2.py | 1,835 | 4.3125 | 4 | #!/usr/bin/env python
"""
Filters using generator functions.
Use generator functions to write filters.
Each filter function takes the following arguments:
1. An iterable
2. A function that returns the line filtered or None if the item
is to be skipped.
Each filter function returns a generator (because the f... | true |
26803b446432b3d65eb0eb2ae3a6118a9163610b | jbbranch9/jbbranch9.github.io | /CS_160/Python_Programs/Programs/loan_calc/loan_calc.py | 1,262 | 4.34375 | 4 | import math
#this function prompts for input while ensuring the returned value is a number
def get_float(prompt):
x = "x"
while type(x) != float:
try:
x = float(input(prompt))
except ValueError:
print("")
print("Error: Input must be a number.")
pr... | true |
b4a2ec21b21c2a0ef4d5b49b94108cb16f9d221f | kalyanrohan/LEARNING-AND-TESTING | /DICTIONARIES.py | 2,849 | 4.625 | 5 | #my_func is to tell which number is greater
def my_func():
num1=float(input("enter the first number: "))
num2=float(input("enter the second number: "))
num3=float((input("enter the third number: ")))
if num1>=num2 and num1>=num3:
return num1
elif num2 >=num1 and num2 >= num3:
return ... | true |
bb69486317743b8aa75fcc8bb79893ca299a159c | katiamega/python_language | /students/km61/Mehedyuk_Kateryna/homework3.py | 2,818 | 4.40625 | 4 | # your co---'For loop with range'--------------------
#task1
"""Given two integers A and B (A<= B).
#Print all numbers from A to B inclusively."""
a=int(input())
b=int(input())
#int, because a, b==numbers
for i in range(a,b+1):
print(i)
#task2
"""Given two integers A and B. Print all numbers from A to B inclu... | true |
1b707476cf42d351c5d4ffca2e6b1433bcf405ef | twumm/Algorithms | /eating_cookies/eating_cookies.py | 1,131 | 4.21875 | 4 | #!/usr/bin/python
import sys
# The cache parameter is here for if you want to implement
# a solution that is more efficient than the naive
# recursive solution
def eating_cookies(n, cache=None):
# set a list to contain the list of possible combinations
if n < 0:
return 0
elif n == 0:
ret... | true |
e20f500c4d34b202e0c4a45bf6706c2c61b24613 | ladnayan/Betahub-application | /sign_in.py | 1,430 | 4.1875 | 4 | import os
def sign_in(d):
"""function for sign in by checking hash value stored in dictionary"""
for i in range(3):
print("Enter your user name:")
name=input()
l=d.keys() #change made
if name not in l:
os.system('clear')
... | true |
1dfcf7366a1d039dd6b3a734faaee4c4115c18f4 | soujanyaKonduru/learnprog | /InputListFuntionForPython.py | 706 | 4.375 | 4 |
# input
name = input('please enter your name:')
# print with formatting
# you can use 'f' (formatting) with print like below
name = "sai"
print(f'Hello {name} welcome')
# with f in print function the variables in { and } will be replaced with its values
# list
# list is used to hold a variable with multiple values.
... | true |
854cfb58af8bb3a16ebe40ec87e5aca11af76f71 | Object-Oriented101/LearningProgrammingFundamentals | /LearningPython/test.py | 263 | 4.125 | 4 | import tkinter as tk
from tkinter import ttk
# Create the application window
window = tk.Tk()
# Create the user interface
my_label = ttk.Label(window, text="Hello World!")
my_label.grid(row=1, column=1)
# Start the GUI event loop
window.mainloop()
| true |
1425cdeb87bee46d628961da883c8baa79316a8a | richardx14/pythonBeginners | /usernames.py | 304 | 4.1875 | 4 | usernames = {}
while True:
print(usernames)
print("Enter username:")
username = input()
if username in usernames.keys():
print(username + " is the username of " + usernames[username])
else:
print("Enter name:")
name = input()
usernames[username] = name
print(usernames[username])
| true |
060c65fe1cc4496e24976a9cc53e52a79970f5f8 | gloria-ho/algorithms | /python/convert_string_to_camel_case.py | 707 | 4.40625 | 4 | # https://www.codewars.com/kata/convert-string-to-camel-case
# Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized.
# Examples
# to_camel_case("the-stealth-warrior") # retur... | true |
cfecd7c33bffda13c24f9d5248380e7c2c0041d4 | gloria-ho/algorithms | /python/remove_the_minimum.py | 1,117 | 4.125 | 4 | # https://www.codewars.com/kata/563cf89eb4747c5fb100001b
# The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the most boring exhibitions. She gives them a rating, and then removes the one with the lowest rating.
# However, just as... | true |
c28fa1f661a241ac347bff80edd8f12aa077eda0 | gloria-ho/algorithms | /python/find_the_unique_number.py | 757 | 4.21875 | 4 | # https://www.codewars.com/kata/find-the-unique-number-1
# There is an array with some numbers. All numbers are equal except for one. Try to find it!
# findUniq([ 1, 1, 1, 2, 1, 1 ]) === 2
# findUniq([ 0, 0, 0.55, 0, 0 ]) === 0.55
# Its guaranteed that array contains more than 3 numbers.
# The tests contain some ver... | true |
6ca4a40be9de8736614265926feade3f6280782a | ChrisCodesNow/wb | /01_basics/01_arrays/02_transpose.py | 704 | 4.1875 | 4 | '''
Approach 1:
Create matrix T with m rows.
Fill T from A's old col to T's new row
Runtime: O(nm)
Space Complexity: O(nm)
'''
# Asume input matrix is a 2D
from typing import List
class Solution:
def transpose(self, A: List[List[int]]) -> List[List[int]]:
T = [ [] for _ in range(len(A[0])) ]
... | true |
df13ba743447e85d0d4a509d968a88a78e37ec7f | cce-bigdataintro-1160/winter2020-code | /3-python-notebook/13-writing-files-disk.py | 1,409 | 4.40625 | 4 | file_path = 'file_to_write.txt'
# To write a file using python we'll use the method `open`, here's the list of opening modes
# r Open text file for reading. The stream is positioned at the
# beginning of the file.
#
# r+ Open for reading and writing. The stream is positioned at the
# beginning of the file... | true |
f5f613ecb20878537948001b3a67b1b83f1daab3 | andrewbowler/Programming-2018 | /fibonacci.py | 361 | 4.21875 | 4 | num = int(input('Enter #: '))
def fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci (n - 2)
print(str(fibonacci(num)))
#a(n) = a(n-1) + a(n-2)
""" I followed the recursion formula
I learned in discrete--did NOT expect
it to work, thought it would be MUCH harder
b... | true |
b7d838d56a655db99740e0a015e3a3bab61343da | jawsnnn/python-pluralsight | /iterations/mapper.py | 1,219 | 4.21875 | 4 | from decimal import Decimal
from functools import reduce
# map() takes a function and runs it over a sequence(s) of inputs generating another sequence with the outputs of the function
color = ['blue', 'white', 'grey']
animal = ['whale', 'monkey', 'man']
place = ['asian', 'european', 'mythical']
def combine (color, a... | true |
4e1e679d21c1216c1b475657db166acdae9721f3 | StevenGaris/codingbat | /Warmup2/string_bits.py | 244 | 4.125 | 4 |
# Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo".
def string_bits(word):
return word[::2]
print(string_bits("Hello"))
print(string_bits("Hi"))
print(string_bits("Heeololeo")) | true |
834b0aaf7e75123d54bcd3cd69a19afe33c390fa | OldDon/UdemyPythonCourse | /UdemyPythonCourse/2.37 Functions and Conditionals 3.py | 336 | 4.21875 | 4 | # Program to convert Celcius to Farenheit....
# Test for lowest possible temperature that physical matter can reach....
# That temperature is -273.15 degrees Celcius
def cel_to_fahr(c):
if c < -273.15:
return "That temperature doesn't make sense!"
else:
f = c * 9/5 + 32
return f
print(cel_... | true |
5960c63c76d83cf3a0c149c90a10cad92333bd9b | Jiaxigu/pycogram | /pycogram/dijkstra.py | 1,700 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Single-source shortest path algorithm for non-negative graphs.
"""
import math
def dijkstra(graph, source):
"""
Given a graph and a source within the graph,
find shortest paths and distances for all nodes.
The edges in the graph must be non-negative.
Parameters
---... | true |
6e13c17b6c4b1afc7b016b837ed9459a3a9a65ce | davidgoldcode/cs-guided-project-computer-memory-basics | /src/demonstration_2.py | 1,684 | 4.375 | 4 | """
Given an unsigned integer, write a function that returns the number of '1' bits
that the integer contains (the
[Hamming weight](https://en.wikipedia.org/wiki/Hamming_weight))
Examples:
- `hamming_weight(n = 00000000000000000000001000000011) -> 3`
- `hamming_weight(n = 00000000000000000000000000001000) -> 1`
- `ha... | true |
1f350dc709c3aa29a440137a3616de38be1a4872 | Chu66y8unny/TP2e | /code/C02/ex2-2-1.py | 209 | 4.3125 | 4 | import math
def sphere_vol(r):
return 4.0 / 3.0 * math.pi * r**3
if __name__ == '__main__':
radius = 5
vol = sphere_vol(radius)
print(f"The volume of a sphere with radius {radius} is {vol}")
| true |
a59598e5251e5d48d4b26623dc23516aec27be73 | Mazama1980/FloweryJitteryLint | /guess.py | 801 | 4.15625 | 4 | """This is a Guess the Number Game"""
import random
number=random.randint(1,20)
max_guesses=6
#max_guesses=2
print("Hint:the number is: ", number)
player=input('Hello! What is your name? ')
print('Hello '+ player + '.')
print("I am thinking of a number between 1 and 20.")
print()
for guess_count in range(1, max_gue... | true |
dfa69eebab5e0e970c27288a2b1233319546a4c0 | dogac00/Codewars | /mumbling.py | 1,244 | 4.28125 | 4 | # The problem is:
# This time no story, no theory. The examples below show you how to write function accum:
# Examples:
# accum("abcd") -> "A-Bb-Ccc-Dddd"
# accum("RqaEzty") -> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
# accum("cwAt") -> "C-Ww-Aaa-Tttt"
# The parameter of accum is a string which includes only letters fro... | true |
53612dd6bfbd359d5c4f5a14d72d5ab8a30b6d42 | eevans01/development_python | /08-Stacks/stacks.py | 1,737 | 4.15625 | 4 | #Programmer: Eric Evans, M.Ed.
#Program Name: Introducton to Stacks
#Description: Working with LIFO Stacks, For Loops, and Conditional Statements
#
stack_ascending = [1, 2, 3, 4, 5] #Create ascending stack with integers 1, 2, 3, 4, & 5
stack_ascending.append(6) #Appends 6 to the top of the stack
stack_ascending.append(... | true |
9a4f02d7ce1ad6dd5558536323687e759983f58f | jprsurendra/core_python | /oops/aggregation_and_composition.py | 1,351 | 4.5 | 4 |
class Salary:
def __init__(self, pay):
self.pay = pay
def get_total(self):
return (self.pay * 12)
'''
Example of Aggregation in Python
Aggregation is a week form of composition. If you delete the container object contents objects can live without container object.
'''
class Employee... | true |
5bc3826763bd156effca51adddbdf7b3e530f6f8 | cxvdy/shehacks2021 | /shehacks.py | 801 | 4.21875 | 4 | import random
#The user chooses the numbers for the range
print("Choose a range of numbers")
start = int(input("Enter first number: "))
end = int(input("Enter last number: "))
#Exit app if user inputs data format
if(start > end):
print("Incorrect range")
exit()
#generate random number
random = random.randint... | true |
2709bea47e7e15ea3ef7096bea724532f168a251 | HetDaftary/Competitive-Coding-Solutions | /Geeks-For-Geeks/Practice/Array/Rotate-Array.py | 752 | 4.21875 | 4 | #User function Template for python3
class Solution:
#Function to rotate an array by d elements in counter-clockwise direction.
def rotateArr(self,A,D,N):
#Your code here
ls = A[D:] + A[:D]
for i in range(N):
A[i] = ls[i]
#{
# Driver Code Starts
#Initial Templat... | true |
91f8c8973e2594549e81c6e2a01f264309b91150 | umesh-gattem/Pyhton_matplotlib | /matplotlibExamples/SampleExample.py | 1,779 | 4.71875 | 5 | import matplotlib.pyplot as plt
import numpy as np
'''The following three lines will us used to draw a graph between two axis.
The Y axis label is some numbers and it takes the numbers from 1,2,3,4.
Here X axis values are not specified but it takes the same values as Y axis .
But x axis starts values from 0 and ends a... | true |
1ee1ac04d1eb09efabb44f80299bb866d4c558d6 | kyle-mccarthy/syrian-data-io | /src/hw1.py | 521 | 4.375 | 4 | # the list example, adding items the interating
list_example = []
list_example.append('one value')
list_example.append('another value')
list_example.append('the last value')
# iterate the list
for items in list_example:
print(items)
# the dict example
dict_example = {}
dict_example['key'] = 'value'
dict_example['... | true |
a1bbb1f93e4043c3acceb5ce1bdab21c9f377e9f | atishbits/101 | /numberEndingWith3.py | 1,537 | 4.34375 | 4 | import sys
import pdb
'''
Every number that ends with three follows a very interesting property:
"Any number ending with 3 will always have a multiple that has all 1's".
for eg, for,
3 : 111
13 : 111111
and so on.
Now the question is, given a number ending with 3, return this factor, or return the numb... | true |
79602418e46aafda87bd9ed0bd900dc23f7ad40e | csaund/project-euler | /3and5.py | 556 | 4.28125 | 4 | # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
def find_and_add(limit):
sum = 0
for i in range(0, limit):
by_three = i % 3 == 0
by_five = i % 5 == 0
... | true |
f30e7ea8bd88827e96094d2307d0fb9db0704864 | NethajiNallathambi/PYTHON_Programming | /Beginner_Level/alphabet.py | 201 | 4.1875 | 4 | A = input("Enter any character: ");
if A == '0':
exit();
else:
if((A>='a' and A<='z') or (A>='A' and A<='Z')):
print(A, "is an alphabet.");
else:
print(A, "is not an alphabet.");
| true |
b1d84a0b2993b545ebeeb25989cd8a3ae1a3e465 | victoriamreese/python-scripts | /kata_split_and_add.py | 1,034 | 4.15625 | 4 | #Split then add both sides of an array together
#completed 1/30/19
#https://www.codewars.com/kata/split-and-then-add-both-sides-of-an-array-together/train/python
import numpy as np
def split_and_add(numbers, n):
while len(numbers)>1 and n>0:
top = np.asarray(numbers[0:int(len(numbers)/2)])
bottom =... | true |
ca905c1edb62859fe90cb39cdf796b984830a9f5 | Demoleas715/PythonWorkspace | /Notes/Lists.py | 338 | 4.21875 | 4 | '''
Created on Oct 20, 2015
@author: Evan
'''
names=[]
names=input("Give me a list of names on one line")
name_list=names.split()
for n in name_list:
print(n)
'''
print("Enter a list of names. Leave blank when done.")
n=input()
while n!="":
names.append(n)
n=input()
names.reverse()
for n in names... | true |
8ef4a8725f579b70954af40048ecaa50106c6051 | lyubadimitrova/ffpopularity | /scripts/visualization.py | 1,625 | 4.125 | 4 | import matplotlib.pyplot as plt
import numpy as np
def draw(to_plot, title, xlabel, ylabel, plot_type, rotation=0):
"""
Uses matplotlib to draw a diagram.
Args:
to_plot - dict - A dictionary in the form {<xtick label> : <y_value>}
title - str - The title of the plot.
xlabel - str - The title of the x axis.
yla... | true |
06b1dca2316277e19ade91653a391d8021633e96 | Aastha-520609/python_learning | /dictionarie.py | 576 | 4.25 | 4 | dict={}#creating a dictionary
dict['apple']= 150#assigning key to the dict and the value
dict['banana']=60
dict
print(dict)
#another way to create a dictionary
mail_adress={'aastha':'aastha@gmail.com','pasta':'pasta@gmail.com'}
print(mail_adress)
print(mail_adress.keys())#to print keys of dictionary
print(mail_adress... | true |
1f08427b2c69fc702f6cdcbf78693ee3cd1c98ef | akoschnitzki/Module-6--Lab- | /Lab 6- Problem 6.py | 411 | 4.46875 | 4 | # Name- Alexander Koschnitzki
# Date- 11-4-21
# CSS - 225
# Number 6
# What this program does is that it calculates the factorial of a number
# when you input it. You can input any number and it can be able to
# find the factorial of it.
def factorial(n):
if n == 0:
return 1
else:
r... | true |
7dfe5989d5a473f38c03d43e76e9f169aa664eae | zypdominate/keepcoding | /books/book4 图解算法/code/demo2_select_sort.py | 622 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Description:选择排序
# Author:zhuyuping
# datetime:2020/8/11 22:31
import random
def find_smallest(arr):
smallest = arr[0]
smallest_index = 0
for i in range(1, len(arr)):
if arr[i] < smallest:
smallest = arr[i]
smallest_index = i
... | true |
499d1040d18da84ebb1fd28c492fbf3d17d86ad7 | AbhishekR25/cerner_2_5_2021 | /BreakTheName.py | 498 | 4.5 | 4 | #cerner_2tothe5th_2021
# Get all substrings of a given string using slicing of string
# initialize the string
input_string = "floccinaucinihilipilification"
# print the input string
print("The input string is : " + str(input_string))
# Get all substrings of the string
result = [input_string[i: j] for ... | true |
f11be425bec8f1c9587b049d841663cb1b89cee7 | peterlewicki/pythonCrashCourseExercises | /strippingNames.py | 352 | 4.25 | 4 | # Use a variable to represent a person's name, and include some whitespace characters at the beginning and the end of the name. Print the name once, so the whitespace around the name is displayed. Then print the name using stripping functions
name = " Harold Ramis"
print(name)
print(name.lstrip())
name1 = "Bill Murra... | true |
cc80f0669f274ebdd2e6e860d9f6f6b2e9fcf28f | VaishnaviMuley19/Coursera-Courses | /Google IT Automation with Python/Crash Course on Python/Assignment_7/Prog_1.py | 1,101 | 4.5625 | 5 | #The is_palindrome function checks if a string is a palindrome.
#A palindrome is a string that can be equally read from left to right or right to left,
#omitting blank spaces, and ignoring capitalization. Examples of palindromes are words like kayak and radar,
#and phrases like "Never Odd or Even". Fill in the blank... | true |
baf951773998b1d9c20f478aa1567d1f8c58f2a2 | VaishnaviMuley19/Coursera-Courses | /Python 3 Programming/Python Basics/Week_1_Assignment.py | 862 | 4.3125 | 4 | # First Question
""" 1. There is a function we are providing in for you in this problem called square. It takes one integer and returns the square of
that integer value. Write code to assign a variable called xyz the value 5*5 (five squared). Use the square function, rather than
just multiplying with *. """
x... | true |
84d3d9bc61bf679c555df9f7f8b929ea44babdcd | VaishnaviMuley19/Coursera-Courses | /Google IT Automation with Python/Crash Course on Python/Assignment_6/Prog_5.py | 244 | 4.375 | 4 | #The show_letters function should print out each letter of a word on a separate line.
#Fill in the blanks to make that happen.
def show_letters(word):
for x in word:
print(x)
show_letters("Hello")
# Should print one line per letter
| true |
56f7f14e82b4328d78962b9a817011edf9e2b909 | VaishnaviMuley19/Coursera-Courses | /Python 3 Programming/Python Basics/Week_2_Assignment_1.py | 774 | 4.375 | 4 | # First Question
""" 1. Write a program that extracts the last three items in the list sports and assigns it to the variable last. Make sure to write your
code so that it works no matter how many items are in the list. """
sports = ['cricket', 'football', 'volleyball', 'baseball',
'softball', 'track ... | true |
162bc28a9b6461ad4675488bb8fa2b525fcac456 | rbo7nik/movie_trailer_website | /main.py | 2,849 | 4.21875 | 4 | from movie import Movie
from fresh_tomatoes import open_movies_page
# Application class that runs the program until the user quits
class MainApp():
# Method that gets user input one line at a time
# Returns the user_input as a string
def user_input():
usr_input = raw_input()
if usr_input ==... | true |
397fd3bc37a5c7f8c9baec4c0ee91491a4502680 | MingHin-Cheung/python_review | /list.py | 758 | 4.25 | 4 | food = ["pizza", "sushi", "burger"]
nums = [1, 2, 3, 10, 20]
print(food) # print list
print(food[1]) # pizza
print(food[-1]) # burger
print(food[1:]) # start at position 1
print(food[1:2]) # start at position 1,up to 2 but not include
food[1] = "pasta"
print(food)
food.extend(nums) # combine 2 lists
print(food)... | true |
c90d14599963d087b7503a82e1c4b1cdaeba1c56 | CindyMacharia/Lab01 | /Project03RockPaperScissors.py | 2,359 | 4.28125 | 4 | import random
comp_points = 0
player_points = 0
def choose_option():
user_choice = input("Rock, Paper or Scissors: ")
if user_choice in ["Rock","rock"]:
user_choice = "Rock"
elif user_choice in ["Paper","paper"]:
user_choice = "Paper"
elif user_choice in ["Scissors", "scis... | true |
8ed095e93890ebbe6e3aba1e84284f3c0c61f534 | vduan/project-euler | /problem2.py | 1,127 | 4.125 | 4 | """
Problem Statement:
Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum of the eve... | true |
a18557a658e1de0edc612f57d66ada58cc15c02e | RaySCS/Classical-Problems | /armstrongNumber.py | 523 | 4.125 | 4 | #An armstrong number, also known as a narcissistic number is the sum of cubes of each digit is equal to the number itself.
import math
def isArmstrong(number):
sum = 0
len_Num = len(str(number))
for digit in str(number):
num = int(digit)
sum += math.pow(num,len_Num)
if(math.trunc(sum)... | true |
27155bff9d1714fe6e4a7dc41c6efa899330e669 | imanshaterian/guess-game | /game.py | 1,177 | 4.125 | 4 | import random
# get a name for game
playerName = input('please enter your name:\n')
# saying hi to player
print('hi {} you have 100 chance to guess the number i choose between 1 and 100 :)\n'.format(playerName))
# the program chooses a number between 1 and 100
finalNumber = random.randrange(1, 101)
# get a number from ... | true |
ade83772fcbb26d792bf4d17722fa905f96e87a0 | nagamiya/NLP100 | /Python/Chapter1/08_Cipher_Text.py | 598 | 4.125 | 4 | '''
Implement a function cipher that converts a given string with the specification:
Every alphabetical letter c is converted to a letter whose ASCII code is (219 - [the ASCII code of c])
Keep other letters unchanged
Use this function to cipher and decipher an English message.
'''
def clipher(text):
clipher_text ... | true |
2b96baf9f2294a63f9f6b5af8a9f74311508a0dd | judDickey1/Codewars | /getMiddlechar.py | 489 | 4.1875 | 4 | def get_middle(s):
char = list(s)
indToPrint = int(len(char) / 2)
if len(char) % 2 == 0 :
return(char[indToPrint-1] + char[indToPrint])
else:
return(char[indToPrint])
"""
You are going to be given a word. Your job is to return the middle character of the word. If the word... | true |
b440f90bc093f57c201b8fcfe81d41e67470229f | thebeanogamer/Classwork | /Python/Flight Check.py | 476 | 4.1875 | 4 | while True:
distance = int(input("How far is your journey in km?"))
if 40075 >= distance >= 500 :
canFly = input("Can you/do you want to fly?")
if canFly == "Yes" or canFly == "yes":
print ("Take a plane!")
else:
print ("Get on a boat or a coach!")
elif distance >= 40075:
print ("Hop on a space shuttl... | true |
0423c2f5ed7a6a7bda0da8e1699596b8b66db869 | KTyanScavenger/KTSPortfolio | /triviatest (1).py | 2,566 | 4.15625 | 4 | #Kyla Ryan
#1/19
#Trivia Challenge
#Trivia Game that reads a plain text file
import sys
##NAME THE FILE NAME
##ASSIGN MODE (PERMISSIONS TO THE FILE)
def open_file(file_name,mode):
"""OPEN A FILE"""
try:
the_file=open(file_name,mode)
except IOError as e:
print("Unable to open fi... | true |
2afa1d26f765fb2f12e3a92ad964adfd61c44e6b | zoiaivanova/elementarytasks | /chessboard/fn_chessboard/fn_chessboard.py | 906 | 4.15625 | 4 | from errors import InvalidSideError
def validate_side(side: str) -> str:
"""
invalid -1, 0, adbc, ' '
valid 1, 5, 20
:param side: user input string for validation
:return: raise ValueError if side isn't a natural positive number otherwise return side in str format
"""
if not (side.isdigi... | true |
06b8092bde81d83faaacf205c8e8a3c8ec973bf0 | IvanicsSz/ivanics | /calc.py | 706 | 4.125 | 4 | #!/usr/bin/env python
import sys,io
start = "\033[1m"
end = "\033[0;0m"
def calc(num1,num2,op): #calculations
if (op=="+"):
return num1+num2
elif(op=="-"):
return num1-num2
elif (op=="*"):
return num1*num2
elif (op=="/"):
return num1/num2
else:
return "No... | true |
850227aab194e38c3f01803bfec31e56e96f3129 | wisdom2018/pythonLearn | /IteratorVSIterable.py | 1,571 | 4.25 | 4 | #! /usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2020/7/23 8:34 AM
# @Author: zhangzhihui.wisdom
# @File:IteratorVSIterable.py
from collections import Iterable, Iterator
# Collection data type: list、tuple、dict、set、str
# can use isinstance() to judge a object whether is iterable
# Iterator not only can use for ... | true |
a277f82a839763513ebc15b31fb646d0f041f770 | wisdom2018/pythonLearn | /venv/findMaxAndMin.py | 692 | 4.1875 | 4 | #! /usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2020/7/19 12:21 PM
# @Author: zhangzhihui.wisdom
# @File:findMaxAndMin.py
# using iterable implement to find max value and min value of list, and return type is tuple
def findMax(number):
if not number:
return [None, None]
else:
min_value... | true |
b6a0f20b24ec91b1cbdf811ffbb68ca12145a5fc | diogoamvieira/DSBA-Data-Mining-Ex | /Ex1.py | 381 | 4.28125 | 4 | '''gives the volume of the cylinder and the surface area of that cylinder'''
import numpy as np
pi = np.pi
r = int(input('Choose a Radius for a Cylinder: '))
h = int(input('Choose a Height for a Cylinder: '))
totalvolume = pi * r ** 2 * h
surface = 2 * pi * r * 2 + 2 * pi * r * h
print('The cylinder has a volume o... | true |
6e66e173d709c54c95d8126add279871e172b02e | angelofallars/sandwich-maker | /sandwich_maker.py | 2,342 | 4.28125 | 4 | #! python3
# sandwich_maker.py - Ask the user for a sandwich preference.
import pyinputplus as pyip
# Cost of the ingredients
prices = {'wheat': 10,
'white': 7,
'sourdough': 15,
'chicken': 40,
'turkey': 55,
'ham': 45,
'tofu': 40,
'ched... | true |
0c0594f330d1f31fc67b00d055725a2a865e428d | dannyhollman/holbertonschool-interview | /0x19-making_change/0-making_change.py | 500 | 4.28125 | 4 | #!/usr/bin/python3
"""
function that determine the fewest number of coins
needed to meet a given total
"""
def makeChange(coins, total):
""" Determine fewest number of coins to meet total """
count = 0
coin_total = 0
if total <= 0:
return 0
coins = sorted(coins, reverse=True)
for co... | true |
3e2a7276439b8450e3e89d0f9bdd70c198d859d5 | gaddiss3651/cti110 | /P3T1_AreasOfRectangles_ShannonGaddis.py | 831 | 4.25 | 4 | # P3T1
# Areas Of Rectangles
# Shannon Gaddis
# March 6, 2018
# Get the dimensions of rectange 1
recLength1 = int(input('Enter the length of the first rectangle: '))
recWidth1 = int(input('Enter the width of the first rectangle: '))
# Get the dimensions of rectangle 2
recLength2 = int(input('Enter the l... | true |
99b2882520ac7afa090acc358da7f2997fd6b04e | phuclinh9802/ds_and_a | /Week 1/Day 1/main.py | 1,447 | 4.40625 | 4 | # python Data Structures & Algorithm study
# iterate with index
y = [3,5,6]
for index, item in enumerate(y):
print(index, item)
# sort by 2nd letter
x = ['hello', 'hi', 'xin chao', 'gc']
print(sorted(x, key=lambda k : k[1]))
# find the index of first occurence of an item
letter = 'djeqnakocie'
print(letter.in... | true |
7d8b3637c1ceeb1f1d6f7bf9f5d72a8544cf7658 | frankroque/simple-python | /Desktop/GitPython/SimplePython.py | 517 | 4.3125 | 4 | print("Simple Python Progam")
print("Let us descend:")
def reverseArray(array):
beg = 0
last = len(array) - 1
temp = 0
for i in range(0, len(array)):
temp = array[beg]
array[beg] = array[last]
array[last] = temp
beg += 1
last -= 1
print(array)
orderArray = [1,2,3,4,5,6,7,8,9,10]
print(orderArray)
pri... | true |
36d88f0620981c38f4df7747e2d796db181c7362 | BlacknallW/Python-Practice-2 | /greater_than_zero.py | 209 | 4.21875 | 4 | #Print list of numbers greater than 0.
number_list = [5,19,5,20,-1,-5,-9,-23,10,11,51,-17]
empty_list = []
for numbers in number_list:
if numbers > 0:
empty_list.append(numbers)
print(empty_list) | true |
be06b76e68aa53fd34d6c535801af7579c3ba3df | havenshi/leetcode | /549. Binary Tree Longest Consecutive Sequence II.py | 1,424 | 4.21875 | 4 | # Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree.
#
# Especially, this path can be either increasing or decreasing. For example, [1,2,3,4] and [4,3,2,1] are both considered valid, but the path [1,2,4,3] is not valid. On the other hand, the path can be in the child-Parent-chi... | true |
eb03991f844f476e6225bbbc476f6175a974b75a | herbeeg/hg-project-euler | /1-10/problem_3.py | 1,684 | 4.21875 | 4 | from math import sqrt
class LargestPrimeFactor:
"""
A very crude way of calculating prime
numbers. While checking factors is
a single operation, I feel there
is a simpler more 'mathematical'
way of doing this.
Execution time increases exponentially
as the passed number increases in
... | true |
7af1eac6f6e0b64c50e09b3f790a8ee307402f7f | Sabbir2809/Python-For-Beginners | /Week1-Introduction/getting_input_from_theUser.py | 944 | 4.21875 | 4 | # The built-in input function requests and obtains user input:
name = input("What's your name?")
print(name)
#python takes input as a string we have to type cast the input
value1 = input("Enter first number: ")
value2 = input("Enter second number: ")
total = value1 + value2
print(total)
print(type(total))
#type cas... | true |
4b2c490a94fca02d4c08e8d7910cc68e8bf5b35b | Lmineor/Sword-to-Offer | /bin/16.py | 348 | 4.15625 | 4 | def Power(base,exponent):
result = 1
if base == 0:
return 0
if exponent == 0:
return 1
elif exponent < 0:
for i in range(-exponent):
result = result*base
return 1/result
else:
for i in range(exponent):
result = result*base
retur... | true |
1bb36406d02d23e554d352a12903b829eb15000e | SimaSheibani/Assignments_Northeastern_University | /stars/christmas_tree.py | 558 | 4.21875 | 4 | def main():
height = int(input("Please enter an odd number:"))
while (height < 3) or (height % 2 == 0):
height = int(input("It was not an odd number, pick another one:"))
widt = height
for row in range(height):
if (row == 0):
print(' '*int(widt/2), '*')
elif (row ==... | true |
514408a731d619ede7edf4689b6067b94c96ba83 | SimaSheibani/Assignments_Northeastern_University | /numbers/magic_squre_validator.py | 1,169 | 4.15625 | 4 | '''This program take the input as three separate lines.
Each line consist of three numerical characters.
The program evaluate whether or not the sum of any 3 digits
horizontally, vertically, or diagonally equals 15.
'''
def main():
row_1 = (input("Enter a magic number:\n"))
row_2 = (input())
row_3 = input... | true |
77c82b9a06720c11a08639e7554714d22b3cb5e1 | suthirakprom/Python_BootcampKIT | /week02/ex/ex/projects/01_dice.py | 682 | 4.1875 | 4 | import random
welcome_message = "Welcome to the dices game!"
warning_message = "USAGE: The number must be between 1 and 8"
flag = True
sum = 0
print(welcome_message)
while flag:
try:
n = int(input("Enter the number of dices you want to roll: "))
if n<1 or n>8:
n = 10/0
else:
... | true |
dd6c8f0ab35288b6b45d7662a4a33fb3edaf86ed | suthirakprom/Python_BootcampKIT | /week03/ex/projects/01_stringreplace_minproj_01.py | 1,950 | 4.15625 | 4 | choice = True
while choice:
paragraph = input("Please input a paragraph:\n")
searchStr = input("Please input a String search:\n")
splitParagraph = paragraph.split()
# count the number of searchStr that contained in the paragraph
count = paragraph.count(searchStr)
# the amount of words need to be... | true |
b63b2742f854d0e731be3536cffc3439ec6fd544 | suthirakprom/Python_BootcampKIT | /week02/ex/ex/03_vote.py | 220 | 4.21875 | 4 | age = int(input('Input your age: '))
if age > 0 and age < 18:
print("You aren't adult yet... Sorry can't vote")
elif age >= 18:
print("You are eligible to vote")
else:
print("Age must be a positive digit") | true |
1cf95499837804e17cc1abfccd87fa2dc2b97b07 | sraaphorst/daily-coding-problem | /dcp_py/day062/day062.py | 806 | 4.28125 | 4 | #!/usr/bin/env python3
# day062.py
# By Sebastian Raaphorst, 2019.
from math import factorial
def num_paths(n: int, m: int) -> int:
"""
Calculate the number of paths in a rectangle of dimensions n x m from the top left to the bottom right.
This is incredibly easy: we have to make n - 1 moves to the righ... | true |
d9a3ddf6ecc082c06d34ca28c450f4488ce548b9 | WarmisharrowPy/Bill-Creator | /Code.py | 1,745 | 4.3125 | 4 | product1_name, product1_price = input("Product1 Name : "), input("Product1 price : ")
product2_name, product2_price = input("Product2 Name : "), input("Product2 price : ")
product3_name, product3_price = input("Product3 Name : "), input("Product3 price : ")
company_name = input("Enter your Compa... | true |
01ff50c872e6dab70fdbac06c4672556d68e50eb | sa3mlk/projecteuler | /python/euler145.py | 1,250 | 4.21875 | 4 | #!/usr/bin/env python
"""
Some positive integers n have the property that the sum [ n + reverse(n) ] consists entirely of odd (decimal) digits. For instance, 36 + 63 = 99 and 409 + 904 = 1313. We will call such numbers reversible; so 36, 63, 409, and 904 are reversible. Leading zeroes are not allowed in either n or re... | true |
23604a6c43668ad273bbfb22c7196103369734df | adunk/python-practice | /Playground/practice_code/standard/_tempfile_lib.py | 479 | 4.21875 | 4 | import tempfile
# useful for storing data only useful for the execution of the program
# Create a temporary file
temp = tempfile.TemporaryFile()
# Write to a temporary file
# write() takes a bytes object. In order to convert a string to a bytes literal, we place b in front of the string
temp.write(b'Save this specia... | true |
fcc9dfc361292c9f16dcbd2ad39535b4a27bc9e7 | adunk/python-practice | /Playground/practice_code/standard/_date_time.py | 1,085 | 4.3125 | 4 | import calendar
from datetime import datetime
from datetime import timedelta
now = datetime.now()
print(now)
print(now.date())
print(now.year)
print(now.month)
print(now.hour)
print(now.minute)
print(now.second)
print(now.time())
# date() and time() are methods as they combine several attributes
# Change the formatti... | true |
6df111c48708618cd09cf59e4d6a924693761f09 | PythonCoder8/python-174-exercises-wb | /Intro-to-Programming/exercise-1.py | 770 | 4.6875 | 5 | '''
Exercise 1: Mailing Address
Create a program that displays your name and complete mailing address formatted in
the manner that you would usually see it on the outside of an envelope. Your program
does not need to read any input from the user.
'''
recipentName = input('Enter your name: ')
homeAddress = input(... | true |
687b36241453acb14547356e338d4164adf8f0a8 | michealodwyer26/MPT-Senior | /Labs/Week 4/decompose.py | 635 | 4.1875 | 4 | '''
python program for prime number decomposition of n
Input: n - int
Output: primes with their power
How to?
repeat for each potential prime divisor
test if is divisor
extract its power and write them
'''
import math
def primeDecomp():
# read input
n = int(input("n = "))
# repeat for potentia... | true |
f7ba87b71fe436891b00644f07254c5b9ae8aa9d | michealodwyer26/MPT-Senior | /Labs/Week 2/invest.py | 1,063 | 4.28125 | 4 | # import modules
import math
# function to calculate the investment over 3 years
def invest():
'''
Invest amount1 euro at rate interest
write the numbers for each year
'''
# Input amount1, rate
amount = float(input("initial amount = "))
rate = float(input("invest rate = "))
# calculat... | true |
8ec383e8220c535da9b7ebe146477415dbd06fb9 | michealodwyer26/MPT-Senior | /Homework/Week 2/solveTriangle.py | 937 | 4.28125 | 4 | '''
This program inputs the sides a, b, c and calculates
the angles, perimeter and the area of the triangle.
'''
# import modules
import math
# function to solve out a triangle
def solveTriangle():
# input float a, b, c
a = float(input("a = "))
b = float(input("b = "))
c = float(input("c = "))
# calculate an... | true |
b4327743ca0f951cb21efee5fcd6a07eab03025c | hima-del/Learn_Python | /06_loops/01_if_else.py | 577 | 4.28125 | 4 | #The elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition".
a=200
b=20
if b>a:
print("b is greater than a")
elif a==b:
print("a and b are equal")
else:
print("a is greater than b")
#and
x=200
y=33
z=500
if x>y and z>x:
print("both conditions are true... | true |
eaa809ece2f8aee8634b7f2b7566809245d86ec1 | michaelgagliardi/2019_2020_projects | /big_calculator.py | 1,915 | 4.15625 | 4 | '''------------------------------------------------------
Import Modules
---------------------------------------------------------'''
from BigNumber import BigNumber
'''------------------------------------------------------
Main program starts here
----------------... | true |
39a33d4f12d58329dc9da4bf6f894d7f69b7ec8f | ilee38/practice-python | /coding_problems/project_e/2_even_fibonacci_nums.py | 685 | 4.15625 | 4 | #!/usr/bin/env python3
"""Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the
first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the
... | true |
92dba2e586ad1cfc713cdf353d988dfcf2ef3630 | ilee38/practice-python | /binary_search/binary_search.py | 1,203 | 4.25 | 4 | """
# Implementation of a recursive binary search algorithm
# Returns the index of the target element in a sorted array,
# an index value of -1 indicates the target elemen was not found
"""
def binarySearch(arr, target, low, high):
mid = (low + high) // 2
if arr[mid] == target:
return mid
elif low > high:
... | true |
b53c2669597df2d82297c118b688a086f00b4e52 | ilee38/practice-python | /graphs/topological_sort.py | 2,062 | 4.21875 | 4 | #!/usr/bin/env python3
from directed_graph import *
def topological_sort(G):
""" Performs topological sort on a directed graph if no cycles exist.
Parameters:
G - directed graph represented with an adjacency list
Returns:
returns a dict containing the edges in the discovery path as:
... | true |
07d74a32b25ff613f67bac48fed73db109aedbfd | John-Witter/Udemy-Python-for-Data-Structures-Algorithms-and-Interviews- | /Section 12: Array Sequences/sentence-reversal-1st.py | 496 | 4.125 | 4 | def rev_word(s):
revS = s.split() # create a list from the s string
revS = revS[::-1] # reverse the list
return ' '.join(revS) # return the list as a string with a space b/t words
print(rev_word('Hi John, are you ready to go?'))
# OUTPUT: 'go? to ready you are John, Hi'
print(rev_word(' space befo... | true |
a087f2a392d5e5ae45352fc9470eb03d79270c91 | vikasdongare/python-for-everbody | /Python Data Structures/Assign8_4.py | 753 | 4.375 | 4 | #Open the file romeo.txt and read it line by line. For each line, split the line
#into a list of words using the split() method. The program should build a list
#of words. For each word on each line check to see if the word is already in the
#list and if not append it to the list. When the program completes, sort an... | true |
94b8215f1231cf510ee949a2ff9c51501b6f7c29 | imvivek71/Python-complete-solution | /Task8/ListReverse.py | 283 | 4.40625 | 4 | #Write a Python program to reverse the order of the items in the array
#Write a Python program to get the length in bytes of one array item in the internal representation
a = [str(x) for x in input("Enter the elements seperated by space").split()]
a.reverse()
print(a)
print(len(a))
| true |
8007c463c9c8ce5d853b98412155a65df1cf02cf | imvivek71/Python-complete-solution | /Task4ModerateLevel/elementSearch.py | 614 | 4.15625 | 4 | #elements search in a string using loop & if else
str = input("Enter any strng")
z = input("Enter the char to be searched")
counts = 0
if len(z)==1:
if len(z) > 0:
count = 0
for i in range(len(str)):
if z == str[i]:
print("The element is available in index {} the string"... | true |
e4e3a3d3e4da802fc7770348f4a60521d1b72a8e | agasparo/boot2root_42 | /scripts/test.py | 842 | 4.1875 | 4 | #!/usr/bin/python3
import sys
import turtle
import os
if __name__ == '__main__':
turtle.setup()
turtle.position()
filename = "./turtle.txt"
# Open the file as f.
# The function readlines() reads the file.
with open(filename) as f:
content = f.readlines()
# Show the file contents line by line.
# We add... | true |
eaab59b8dd086f4119bddcb8a5b91b422ec9773a | bharathtintitn/HackerRankProblems | /HackerRankProblems/recursive_digit_sum.py | 1,829 | 4.125 | 4 | '''
We define super digit of an integer using the following rules:
If has only digit, then its super digit is .
Otherwise, the super digit of is equal to the super digit of the digit-sum of . Here, digit-sum of a number is defined as the sum of its digits.
For example, super digit of will be calculate... | true |
0af7fb61665bcfa144b0433bb8cb9bc0644f9d8f | bharathtintitn/HackerRankProblems | /HackerRankProblems/symmetric-difference.py | 775 | 4.3125 | 4 | '''
Task
Given sets of integers, and , print their symmetric difference in ascending order. The term
symmetric difference indicates those values that exist in either or but do not exist in both.
Input Format
The first line of input contains an integer, .
The second line contains space-separated integers.
The... | true |
98433116d7caab7f5c84d6e3edcd15803845f242 | bharathtintitn/HackerRankProblems | /HackerRankProblems/tries.py | 1,227 | 4.1875 | 4 | class Trie(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.root = {}
def insert(self, word):
"""
Inserts a word into the trie.
:type word: str
:rtype: None
"""
curr = self.root
for c in word:... | true |
ae7376bb56be79139334eb5c93d78f8e4ee5ec07 | bharathtintitn/HackerRankProblems | /HackerRankProblems/fibonacci-modified.py | 977 | 4.4375 | 4 | import sys
'''
We define a modified Fibonacci sequence using the following definition:
Given terms and where , term is computed using the following relation:
For example, if term t1 = 0 and t2=1, term t3 = 0+1^2 = 1, term t4 = 1 + 1^2 = 2, term
t5 = 1 + 2^2 = 5, and so on.
Given three integers, t1, t2, and n, compute... | true |
098f8d188e2579e6d80c1fc62d56122a75f10e57 | EffectoftheMind/Python-A-Excersizes | /operations.py | 1,099 | 4.125 | 4 | #calc with exceptions
def add(a, b):
return(a + b)
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
return a / b
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print()
while True:
try:
operation = int(input("Select Operation (1, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.