blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
301ac2b22fd395a78ceb5d8bbe9f75e05dee0c1b | SamuelVera/Algorithims-Misc | /bucketSort/Python/bucketSort.py | 2,159 | 4.3125 | 4 | def insertSort(arr: list, order: str = "asc") -> list:
"""Apply insert sort in the given order for the given array of integers
-------------------
Complexity:
Time: O(n^2)
Space: O(n) Array in memory
-------------------
Parameters:
arr : list
List to order
order ... | true |
d61520033fdb1d0402bb719b9242cf18095d62e2 | achillesecos/15-112-term-project | /dijkstra.py | 2,139 | 4.15625 | 4 | #Term Project
#Achilles Ecos
#aecos
#Graph Theory
#Cite Pseudo code from Wikipedia
#https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
class Graph:
def __init__(self):
#dictionary of nodes to its neighboring nodes where key is node and
#value is array of neighboring nodes
self.graph = {}
self.weight = {... | true |
c3bb54518500f812fc7a04184ac3789384338027 | yuri77/Sorting | /src/iterative_sorting/iterative_sorting.py | 1,256 | 4.21875 | 4 | # TO-DO: Complete the selection_sort() function below
def selection_sort(arr):
for i in range(len(arr)):
print("arr", arr)
last_index = len(arr)
current = arr[i]
# TODO: can I find index of the smallest element and the value at the same time, i.e in one loop?
smallest = min(... | true |
5ad96eda63d0304403695bad58753f9847ea77e4 | DavidIyoriobhe/Week-2 | /Area of a Trapezoid.py | 481 | 4.3125 | 4 | #This is a program is written to calculate the area of a Trapezoid
"""You are given any values to work with, as the program
is only to assist you in solving this problem.
Hence, you will be required to enter values as appropriate."""
a = float(input("Enter a value for the shorter base, a: "))
b = float(input("Ente... | true |
8f2cf30c2b3bd9deb637539ad59a7a832d61fb9a | cfrome77/ProgrammingMeritBadge | /python/tempConverter.py | 947 | 4.25 | 4 | #!/usr/bin/env python3
''' Temperature Convertor
Converts from fahrenheit to celsius
'''
done = False # Variable to determine if we are done processing or not
while not done: # Repeat until the done flag gets set
temp = int(input("Enter the temperature in degrees Farenheight (F): ")) # reads... | true |
4ccdec52e51795aa67503fabc1c2b08816440432 | santhoshdevaraj/Algos | /419.py | 1,539 | 4.125 | 4 | # Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's,
# empty slots are represented with '.'s. You may assume the following rules:
# You receive a valid board, made of only battleships or empty slots.
# Battleships can only be placed horizontally or vertically. In other ... | true |
3fa3618c5d43b2c07b26a46b32d8d7eecfc48f2f | Ezlan97/python3-fullcourse | /fullcourse.py | 2,659 | 4.28125 | 4 | #import libary
from math import *
#simple print
print("Hello World!")
print(" /|")
print(" / |")
print(" / |")
print(" /___|")
#variable
name = "John"
age = 25
print("There once was a man name " + name + ", ")
print("he was " + str(age) + " years old.")
print("he really liked the name " + name +... | true |
249d5c418b62ac935e377286bd77c00bfe0fcc50 | ppaul456/Python | /Assignments/homework_assignment_3/working_with_lists.py | 856 | 4.15625 | 4 | #Pohsun Chang
#830911
#MSITM6341
#09/17/2019
grocery_items = ['Apple','Orange', 'Steak', 'Chicken', 'water']
# create 5 items in a list
price_of_grocery_items = [40,30,60,50,10]
# ceate each item's price in another list
print(grocery_items)
print(price_of_grocery_items)
print(grocery_items[2]+' costs $'+str(price_of_g... | true |
97c162ba4d94d9563b62768d5ed2c3faec5ecd59 | mcharanrm/python | /stack/maximum_element.py | 651 | 4.3125 | 4 | '''Find the maximum element in the stack
after performing few queries
1 x -Push the element x into the stack.
2 -Delete the element present at the top of the stack.
3 -Print the maximum element in the stack.
'''
#ProblemStatement:
#https://www.hackerrank.com/challenges/maximum-element/problem
def maximum_el... | true |
7f68390c001467a4904cbecb34d490161f24ca19 | SoftwareIntrospectre/Problem-Solving-Practice | /Convert_lambda_to_def.py | 795 | 4.34375 | 4 | # Convert a Lambda Expression into a def statement (function)
##Example 1: Check if a number is even
# Step 1: Take original lambda expression
even = lambda num: num % 2 == 0
print even(4) # returns True
print even(5) # returns False
# Step 2: Convert syntax to def statement
def even(num):
return num % 2 == 0... | true |
e3abca0fbb77725fc086141f6e88f063447ddcc3 | SoftwareIntrospectre/Problem-Solving-Practice | /InheritanceWithMeals.py | 841 | 4.46875 | 4 | # Use inheritance to create Derived Classes: Breakfast, Lunch, and Dinner from the Base Class: Meal
class Meal(object):
def __init__(self):
print 'This is a meal'
def timeOfDay(self):
print 'Any time of day'
class Breakfast(Meal):
def __init__(self):
Meal.__init__(s... | true |
fded2bf256ad45b75f0e9f4dc0ff364f942a5181 | mirondanielle/hello-world | /Week1project6 - Miron.py | 759 | 4.34375 | 4 | Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> radius = float(input("Enter the radius: "))
Enter the radius: 7
>>> area = 3.14 * radius ** 2
>>> print ("The area is", area, "square units.")
... | true |
ebb0a30391415bf601c50a11d56c365703cebc16 | siyengar88/Python4selenium | /DemoTest1/InterchangeFLinList.py | 425 | 4.46875 | 4 | #Python program to interchange first and last elements in list
li=[1,2,3,4,5,6,7,8]
print("{} {}".format("Original List: ",li))
temp=li[-1] #storing the last element in a temporary variable
li[-1]=li[0] #Bringing first element to last position
li[0]=temp #storing last element in first position
p... | true |
3c127048a5aaff0b8a4d6f41fdfccd821c25ceb8 | techsparksguru/python_ci_automation | /Class2/python_functions.py | 1,167 | 4.78125 | 5 | """
https://www.tutorialspoint.com/python3/python_functions.htm
https://docs.python.org/3/library/functions.html
https://realpython.com/documenting-python-code/
"""
# Creating a function
def my_function():
print("Hello from a function")
# Calling a Function
my_function()
## Functions with arguments/Parameters
def... | true |
91158d5f59f950c22ac811b0f9125c10c6da71f6 | DtjiPsimfans/Python-Set | /python_set.py | 1,544 | 4.28125 | 4 | # Python Set
class PythonSet:
"""
This class contains attributes of a python set.
"""
def __init__(self, elements=[]):
# type: (list or str) -> None
self.elements: list = [] # initial value
for element in elements:
if element not in self.elements:
self.elements.append(element)
self.elements... | true |
c8fae950c0238d63e5a2e3e2dc3eecec4e87383e | ErhardMenker/MOOC_Stuff | /fundamentalsOfComputing/interactiveProgramming/notes_acceleration&friction.py | 808 | 4.21875 | 4 | ## The spaceship class has two fields:
# self.angle is the ship orientation (the angle, in radians, of the ship's forward velocity from the x-axis)
# self.angle_vel is the speed in which the ship moves in the current direction
## Acceleration
# Acceleration can be modeled by increasing the velocity with time, just as ... | true |
a7d76c6044048cf5775dc5b92e90536fa3acfbac | ErhardMenker/MOOC_Stuff | /fundamentalsOfComputing/interactiveProgramming/notes_variables.py | 1,056 | 4.375 | 4 | # variables - placeholders for important values
# used to avoid recomputing values and to
# give values names that help reader understand code
# valid variable names - consists of letters, numbers, underscore (_)
# starts with letter or underscore
# case sensitive (capitalization matters)
# legal names - ninja, Ninj... | true |
220e2b2bfd11ceff670fae721a0b0211830bf0c3 | xzpjerry/learning | /python/est_tax.py | 1,885 | 4.21875 | 4 | #! /usr/bin/env python3
'''
Estimating federal income tax. Assignment 1, CIS 210
Authors: Zhipeng Xie
Credits: 'python.org' document
Inputer income and num_of_exemption, output tax.
'''
def brain (temp_income, temp_num_of_exempt):
'''
(float or int, int) -> float
return estimated tax r... | true |
15c5cdcc306952ab21b7afed16435aad8cd3e8eb | zhangzhongyang0521/python-basic | /python-quickstart/comment.py | 1,140 | 4.1875 | 4 | # -*- coding:utf-8 -*-
# coding=utf-8
'''
@ description: according to height and weight to calc BMI
@ author: tony.zhang
@ date: 2020.06.20
'''
"""
another format multiline comment
"""
print('''according to height and weight to calc BMI''')
# ================application begin================
# input you... | true |
4a849488c7669e1a41a05fa101f675d3940385c4 | dahlvani/PythonTextProjects | /String Information.py | 798 | 4.28125 | 4 | def reverse(s):
str = ""
for i in s:
str = i + str
return str
print("Your reversed string is", str)
def countvowels(s):
num_vowels=0
for char in s:
if char in "aeiouAEIOU":
num_vowels = num_vowels+1
print ("Your string has", num_vowels, "vowels")
#I call a functi... | true |
108bda1e87d44a3b1839c6665e833c9247e0a669 | nicklutuxun/Calculator-of-pi | /Calculator of pi.py | 782 | 4.28125 | 4 |
# coding: utf-8
# In[ ]:
import matplotlib.pyplot as plt
import time
#n is the term of Maclaurin series
print('Hi! This is a program to calculate the approximate value of pi')
n=int(input('Please enter n:'))
#Time starts
time_start=time.time()
sum_i=0
for i in range(1,n+1):
sum_i=(sum_i+(-1)**(i-1)/(2*i-1))
... | true |
c30b0d745e69c5fe6f9333188a7fd61fe2ae66d7 | Rishi-saw/Python-3 | /objectOrientedProgrammingUsingPython/operatorOverloadingDunderMethods.py | 1,481 | 4.375 | 4 | class Salary:
'''__funcname__ are known as duncder methods particularly used for operator overloading and object value management'''
def __init__(self, amount, type):
self.amount = amount
self.type = type
def __add__(self, other): # this is a dunder method
... | true |
9623052ed6b863c5001d9331c0536eeefe22dad9 | DesLandysh/My100daysPath | /003_of_100/3_1.py | 201 | 4.28125 | 4 | # Odd or even
number = int("33") # int(input("which number do you want to check? "))
if number % 2 == 0:
print(f"this number {number} is even.")
else:
print(f"this number {number} is odd.")
| true |
5504a7da4128f03acc7902f0d0a7f6ecbf558f0f | DesLandysh/My100daysPath | /009_of_100/9_1.py | 837 | 4.3125 | 4 | # Grading program
# database of student_scores in dict names: scores
# write a program that converts their scores to grades. -> new dict
# DO NOT modify student_score dict
# DO NOT write any print statements.
# scores 91 - 100 = "Outstanding"
# scores 81 - 90 = "Excedds Expectations"
# Scores 71 - 80 = "Acceptable"
# s... | true |
590f0f9c8f8aaac4fd1c9d6f8ca4bbae283ac85b | thomaskellough/PracticePython | /Exercise 11 - Check Primality Functions.py | 537 | 4.21875 | 4 | """
Ask the user for a number and determine whether the number is prime or not.
(For those who have forgotten, a prime number is a number that has no divisors).
You can (and should!) use your answer to Exercise 4 to help you.
"""
your_number = int(input('Give me a number.\n'))
def prime(number):
count = 0
f... | true |
c19bbd21a3956fdc109a8e205ff179f7d2055c8d | w3cp/coding | /python/python-3.5.1/4-control-flow/17-func-lambda-expressions.py | 782 | 4.3125 | 4 | # Small anonymous functions can be created with the lambda keyword.
# This function returns the sum of its two arguments: lambda a, b: a + b .
# Lambda functions can be used wherever function objects are required.
# They are syntactically restricted to a single expression.
# Semantically, they are just syntactic sugar ... | true |
f45117116f0c463dfe6cbe9657e78cbf838692b1 | SuguruChhaya/python-tutorials | /Data Structures and Algorithms/mergeS.py | 2,776 | 4.21875 | 4 | #Practicing mergeosrt iterative
def merge(arr, arrEmpty, l, m, r):
#Define 3 pointers
#Beginning of first subarray
a = l
#Beginning of second subarray
b = m+1
#Beginning of big subarray we are copying into
c = l
#I think I can check for special case. I can do it after the solution works... | true |
28311956d8c5c460f7b516211d30594e0f3036c8 | austinjalexander/sandbox | /c/learntoprogram/week1/code_compare/user_input.py | 849 | 4.28125 | 4 | # notice how we don't have to explictly declare the types
# of each variable (e.g., int, double, etc.);
# moreover, we can actually put an integer in a variable on
# one line and then put a string in the same variable on the next;
# oh boy can this dupe us!
integer_number = 0
decimal_number = 0.0
my_string = "Your... | true |
1c0dc260738867d30e283219ff70d1cc5361c98d | iniffit/learning-projects | /Dice Roll.py | 1,701 | 4.21875 | 4 | # This is a dice roll simulator. You can run the program to roll two dice after answering questions. The dice roll is represented by 2 seperate integers.
# This is my first ever solo program in Python
# Some key learning points I got from writing this program
# - Importing modules (Random)
# - Nesti... | true |
63e29b7a6e7ace44cf07457f347d2ab77a164018 | dani888/cs110 | /alarm2.py | 2,533 | 4.25 | 4 | # alarm2.py -- an alarm clock with a clock as a component field
from clock import *
import time
class AlarmClock():
'''A (fake) alarm clock. We say it's fake because it "tocks"
a minute every real second. Like Clock, this is a 24 hour clock.
'''
def __init__(self):
t = time.localt... | true |
a81806a7e25e2898341c6ed62d02ea3e218af725 | McEnos/sorting_algorithms | /merge_sort.py | 763 | 4.25 | 4 | def merge_sort(sequence):
"""
Sequence of numbers is taken as input, and is split into two halves, following which they are recursively sorted.
"""
if len(sequence) < 2:
return sequence
mid = len(sequence) // 2
left_seqeunce = merge_sort(sequence[:mid])
right_sequence = merge_sort(sequen... | true |
ee227446623008c77762cf5b5abc4971e4e1bc9a | bentevo/ddd | /exercises/wordchecker.py | 1,494 | 4.125 | 4 | # the words that are not correct are listed in the 'wrong' list, and the words are an empty list for the user to add
wrong = ["apples", "cheese", "fries", "banana", "kangaroo", "quick", "triangle", "manatee"]
words = []
# input sentence.
sentence = input("Hello! Please enter your sentence here. ")
# splitting the se... | true |
4d6e4835ff49407f93cd78b7ca2a4163bf4177fe | Patibandha/new-python-education | /riddhi_work/reverse_str.py | 847 | 4.53125 | 5 | # wap to take string from the user and print it back in reverse order.
def reverse(s):
try:
# if entry.isalpha():
if type(s) == str:
entry = ""
for i in s:
entry = i + entry
# return entry
return entry
elif type(s) == in... | true |
8488dde2c2713f28327d1ac9b23a46593c3a5be9 | shankardengi/DataStructure | /doubly_linked_list.py | 2,719 | 4.3125 | 4 | class Node:
def __init__(self,data):
self.data = data
self.next = None
self.prev = None
@staticmethod
def insert_node_front(first):
data = int(input("Enter Data into node:"))
node = Node(data)
if first == None:
first = node
else:
... | true |
3adedd21d929bef168600b2d6ef34ce11e72eb55 | shankardengi/DataStructure | /linkedlist_first_second_higst.py | 1,878 | 4.1875 | 4 | class linked_list:
def __init__(self,data):
self.data = data
self.next = None
@staticmethod
def create_list():
size = int(input("size of list:"))
first = None
for i in range(size):
data = linked_list(int(input("Enter Data:")))
data.next = firs... | true |
1fcc6be6104b92ed66e40247e901ca155aace569 | ebenp/python2 | /median_index.py | 1,138 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Eben Pendleton"
__credits__ = "Derived from https://stackoverflow.com/questions/24101524/finding-median-of-list-in-python"
__status__ = "Production"
def median_index(vals):
'''
Return the best approximate median index from a given list.
The median... | true |
0a530e962a1f1aefd3545e47d8cb3752b196c9b1 | chuxinh/cs50-2019 | /pset6/caesar.py | 1,179 | 4.53125 | 5 | """Implement a program that encrypts messages using Caesar’s cipher, per the below.
$ python caesar.py 13
plaintext: HELLO
ciphertext: URYYB
Details of Caesar’s cipher can be found here: https://lab.cs50.io/cs50/labs/2019/x/caesar/
"""
from cs50 import get_string
import sys
def main():
# validate command line ar... | true |
fd3d7bbd01cfae6eece77c24859d31f63df2ddbd | cynful/project-euler | /p014.py | 1,072 | 4.125 | 4 | #!/usr/bin/env python
"""
Longest Collatz sequence
Problem 14
The following iterative sequence is defined for the set of positive
integers:
n -> n/2 (n is even)
n -> 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following
sequence:
13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 ... | true |
b311b1b8860571cc22cac9a1bd0bfe434e65e9f8 | cynful/project-euler | /p025.py | 708 | 4.15625 | 4 | #!/usr/bin/env python
"""
1000-digit Fibonacci number
Problem 25
The Fibonacci sequence is defined by the recurrence relation:
F_n = F_n-1 + F_n-2, where F_1 = 1 and F_2 = 1.
Hence the first 12 terms will be:
F_1 = 1
F_2 = 1
F_3 = 2
F_4 = 3
F_5 = 5
F_6 = 8
F_7 = 13
F_8 = 21
F_... | true |
3294213b6ed2bcb5e4448fc1de49cb86944aa1d9 | ivankitanov/repos | /loops.py | 712 | 4.21875 | 4 | # numbers= ["43", "42", "41", "44", "47", "1", "8"]
# def odd_or_even():
# even=[]
# odd=[]
# for number in numbers:
# if number%2==0:
# even.append(number)
# else:
# odd.append(number)
# print("The even numbers are: ")
# for num1 in even:
# print num1
# ... | true |
fe61c77e817977b8902c53dfd5679c9b3f4f63fc | WebSovereign/school_database | /database.py | 520 | 4.1875 | 4 | import sqlite3
def create_database():
# Create a connection to sqlite3
# Try to connect to a database called 'school.db'
# If 'school.db' does not exist, create it
conn = sqlite3.connect("school.db")
# Create a cursor to make queries with
c = conn.cursor()
c.execute("""
CREATE TA... | true |
303922169d991f88cc03caef981a5fd5e02d6d24 | loganpassi/Python | /Algorithms and Data Structures/HW/HW1/vowelCount.py | 936 | 4.40625 | 4 | #Logan Passi
#CPSC-34000
#08/27/19
#vowelCount.py
#Write a short Python function that counts the number of vowels in a given
#character string.
def countVowels(inpStr, length):
vowelList = ['a', 'e', 'i', 'o', 'u'] #list of vowels
vowelListLength = len(vowelList)
numVowels = 0
for i in range... | true |
2627b9607e29b29182c6d0facad6997a7364d804 | loganpassi/Python | /coin_flip.py | 796 | 4.3125 | 4 | ##Logan Passi
##09/28/2016
##Prog6_5.py
##In class exercise to demonstrate the use of
##the random function when simulating a coin toss.
import random #make random functions accessible
def main():
NUM_FLIPS = 10 #Python named constant
counter = int() #counter variable
numHeads = int(); numTails ... | true |
322252f7121d81d02b81cfbeaab782bfdafc9584 | acakocic/Python-project | /sort.py | 1,167 | 4.15625 | 4 | from main import children_list, printChildrenOut
from person import *
# Sorting the list by lastName, firstName in ascending order.
print("\n\nSorting the list by lastName, firstName in ascending order.\n")
for i in range(len(children_list)):
for j in range(i + 1, len(children_list)):
name_i = child... | true |
7a2de52d3c767785d6e0f202d551e2340fc0cfa7 | puneethnr/Code | /Programs/Microsoft/DayOfTheWeekThatIsKDaysLater.py | 588 | 4.21875 | 4 | '''
Given current day as day of the week and an integer K, the task is to find the day of the week after K days.
'''
def day_of_week(day: str, k: int) -> str:
# WRITE YOUR BRILLIANT CODE HERE
days = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Satur... | true |
269456d426c16b56c8681ebca684f8ae772b4961 | puneethnr/Code | /Programs/Amazon/PalindromeNumber.py | 1,271 | 4.375 | 4 | # Check if a number is Palindrome
# In this post a different solution is discussed.
# 1) We can compare the first digit and the last digit, then we repeat the process.
# 2) For the first digit, we need the order of the number. Say, 12321.
# Dividing this by 10000 would get us the leading 1.
# The trailing 1 can be ... | true |
4d7983328450feabfd0cd69ecac92bfe98fe6637 | MeganPu/Tech-Savvy-Megan | /HW String.py | 2,223 | 4.21875 | 4 | #Exercise 5
def any_lowercase1(s):
for c in s:
if c.islower():
return True
else:
return False
team = 'New England Patriots'
print(any_lowercase1(team))
#This function only check the first character of the string and
#will return True only if the first character in ... | true |
7ebee19c4c6a6d652656cdf1b21bb2c228695ad1 | Aman-dev271/Pythonprograming | /54th_list_comprihentions.py | 299 | 4.28125 | 4 | # List comprehension in python
# write a program to print the number that are divisible by 3
ls = []
for i in range(100):
if i%3==0:
ls.append(i)
print(ls)
# To do this in one line we use the List comprehensions
# let see
ls = [ i for i in range(100) if i%10 == 0 ]
print(ls)
| true |
2d39437a2a5b5b632d6a5c208cb8d886883689e1 | Yaswant-Kumar-Singhi/python-tkinter-BMI-GUI | /bmi.py | 314 | 4.34375 | 4 |
print('This program is used to calculate BMI of an individual \n')
name = input("Enter your name")
weight = float(input("Enter your weight"))
height = float(input("Enter your height"))
ht_in_m = (height * 0.3048)
ht_cal = ht_in_m **2
bmi = weight / ht_cal
print(f"{name} your BMI is {bmi}")
| true |
b3d9854387f203d67891339aacbe8cf9cb16a337 | shubhangi2803/Practice_Python | /Exercise 9.py | 909 | 4.40625 | 4 | # Generate a random number between 1 and 9 (including 1 and 9).
# Ask the user to guess the number, then tell them whether they
# guessed too low, too high, or exactly right.
# (Hint: remember to use the user input lessons from the very first exercise)
# Extras:
# 1. Keep the game going until the user types “exit”
# ... | true |
ae40f7eea66a9ad3393f4cb7151c58a8b53aece9 | ryanriccio1/prog-fund-i-repo | /main/labs/lab6/(ec)ryan_riccio_6_17_lab6.py | 2,038 | 4.34375 | 4 | # this is from program 6-17 (in the spotlight)
# according to the powerpoint, i can get extra credit from this
# search_coffee_record.py
# this program searches inventory records from coffee.txt
# main function
def main():
try:
found = False
# get user input for the coffee they want to find
... | true |
d0432ba360aa0bec509ee9b26f9d0f4a7438f8e6 | bangerterdallas/portfolio | /Chessboard_Generator_Password_Checker/chessboard.py | 2,340 | 4.125 | 4 | import turtle
tr = turtle.Turtle()
tr.speed(0)
class Chessboard:
def __init__(self, tr, startX, startY, width=100, height=100):
self.height = height
self.width = width
self.x_pos = startX
self.y_pos = startY
# create a method to draw a circle
def __draw_rectan... | true |
a3966789b472f5a2bd4a6e75255911504babb545 | yashdobariya/-Guess-Number-Game | /Guess Number.py | 621 | 4.15625 | 4 |
# Guess The Number
n=25
num_of_guess=1
print(" Guess Number Game:")
print("num of guesses is limited to only 5 times")
while(num_of_guess<=5):
guess_number = int(input("Guess the Number:\n"))
if guess_number<25:
print("your number is smaller than Guess")
elif guess_number>25:
p... | true |
8b8c9b4f2b7b8271bac29ca78639e3f861f4ca5f | cshintov/Courses | /principles_of_computing/part1/week1/homework/appendsums.py | 270 | 4.25 | 4 | def appendsums(lst):
"""
Repeatedly append the sum of the current last three elements of lst to lst.
"""
for i in range(25):
sum_three = sum(lst[-3:])
lst.append(sumthree)
sum_three = [0, 1, 2]
appendsums(sum_three)
print sum_three[10]
| true |
e513d7a10d95ed865101d06784e67a37a276cef9 | oneraghavan/AlgorithmsNYC | /ALGO101/UNIT_01/TopDownMergeSort_mselender.py | 1,070 | 4.1875 | 4 | #TopDownMergeSortInPython:
#A Python implementation of the pseudocode at
#http://en.wikipedia.org/wiki/Merge_sort
def merge_sort(m):
if len(m) <=1:
return m
left = []
right = []
middle = int(len(m) / 2)
for x in range(0, middle):
left.append(m[x])
for x in range(middle, len(m... | true |
fc2d1524844bda179bac2ff82d50411eee4ae829 | shahaddhafer/Murtada_Almutawah | /Challenges/weekSix/dayThree.py | 2,825 | 4.25 | 4 | # Binary String Expansion
# ---------------------------------------------------------------------------------
# You will be given a string containing characters ‘0’, ‘1’, and ‘?’. For every ‘?’, either ‘0’ or ‘1’ characters can be substituted. Write a recursive function that returns an array of all valid strings that h... | true |
5effbb6beab2b4ce0027863909cde56512ebc7a0 | shahaddhafer/Murtada_Almutawah | /Challenges/weekThree/dayFour.py | 2,217 | 4.28125 | 4 |
# Is Palindrome
# --------------------------------------------------------------------------------
# Strings like "Able was I, ere I saw Elba" or "Madam, I'm Adam" could be considered palindromes, because (if we ignore spaces, punctuation and capitalization) the letters are the same from front and back. Create a funct... | true |
ce3fa6c3c2e0337712a0ad658c974e49ac46d516 | KodaHand/LP3THW | /ex6.py | 1,010 | 4.5625 | 5 | # declares types of people
types_of_people = 10
# x is now equal to a string while putting types_of_people in it
x = f"There are {types_of_people} types of people."
# declares binary
binary = "binary"
# declares do_not
do_not = "don't"
# makes y a string and puts binary and do_not into it
y = f"Those who know {binary}... | true |
e5a553b35d9d178cfc0add1957e6d34a0760eb0d | McMunchly/python | /pypractice/e13.py | 397 | 4.25 | 4 | # create a fibonacci sequence up to a user-inputted length
limit = int(input("Enter number of fibonacci digits to display: "))
numbers = []
num1 = 1;
num2 = 1;
while(limit > 0):
if(len(numbers) < 2):
numbers.append(num1)
else:
num1 = numbers[len(numbers) - 1]
num2 = numbers[len(numbe... | true |
b64356a7f937b2cbdf67639fe77c0d95bf2264f9 | McMunchly/python | /games/game.py | 1,231 | 4.15625 | 4 | # move around a little play area
import random
blank = "."
def DisplayMap(area, size):
for x in range(0, size):
row = ""
for y in range(0, size):
row = row + area[y + (size * x)] + " "
print(row)
def Move(move, coord, board):
board[coord] = blank
if command ... | true |
5b9f964265daa61a5629c2c2c5c57708d1a4a127 | taoxm310/CodeNote | /A_Byte_of_Python/str_format.py | 802 | 4.21875 | 4 | age = 20
name = 'time'
# 不省略index
print('{0} was {1} years old when he wrote this book'.format(name,age))
# 省略index
print('{} was {} years old when he wrote this book'.format(name,age))
# 用变量名
print('{name} was {age} years old when he wrote this book'.format(name=name,age=name))
# f-string
print(f'why is {name} play... | true |
ffc749569b1b8703910f19b5f269a52ff579b5c3 | guptaNswati/holbertonschool-higher_level_programming | /0x07-python-classes/102-square.py | 1,170 | 4.4375 | 4 | #!/usr/bin/python3
"""
This is a Square class.
The Square class creates a square and calculates its area.
"""
class Square:
"""
Initialize Square object
"""
def __init__(self, size=0):
self.size = size
@property
def size(self):
return self.__size
@size.setter
def siz... | true |
9b32a23d496fa5162c68963daf4c73efbfb4fd70 | yonicarver/cs265 | /Lab/4/lab04/s1.py | 1,182 | 4.28125 | 4 | # python 3.5
# -----------------------------------------------------------------------------
# Yonatan Carver
# CS 265 - Advanced Programming
# Lab 04
# -----------------------------------------------------------------------------
# Q2.1 Look at the students input file in the directory. Write a Python program
# that, f... | true |
abb08002375faf85d8eaae6025f8c3aaf19bc0da | Gritide/Py | /ps37.py | 1,429 | 4.21875 | 4 | #Dogukan Celik
#Dogukan.Celik89@myhunter.cuny.edu
def computeFare(zone, ticketType):
"""
Takes as two parameters: the zone and the ticket type.
Returns the Copenhagen Transit fare, as follows:
3 If the zone is 2 or smaller and the ticket type is "adult", the fare is 23.
3If the zone is ... | true |
9d09f5c1cb775fcb7b29ca648f2566f55bb59048 | SaintClever/Pythonic | /quiz/questions.py | 2,938 | 4.375 | 4 | """ Quiz questions and answers """
import random
# Return / enter not included: 3 spaces
questions = {
'1. What is the result of f"{2 + 2} + {10 % 3}": ': '4 + 1',
'2. Assuming name = "Jane Doe", what does name[1] return: ': 'a',
'3. What will name.find("Doe") return from "Jane Doe": ': '5',
'4. Wha... | true |
deb1dee5fbd43c861c574176ae1f9acd5ca2d317 | cwg1003/team-6-456 | /Confighandler.py | 1,577 | 4.53125 | 5 | # Author: Chad Green & Diyorbek Juraev
# Date: 03/31/2021
'''
This program:
1. validates an input file and contents in it.
2. Handle file opening in a mode
2.1. Handle file exceptions, etc.
3. Search file contents
'''
import magic
def parse_file(filename):
#open the file to read, and implement the logic as require... | true |
726ec712ff946acea5ede884c030d2ed61cb9422 | TirumaliSaiTeja/Python | /app.py | 1,801 | 4.15625 | 4 | # weight = int(input("weight: "))
# unit = input("(L)bs or (K)gs: ")
# if unit.upper() == "L":
# converted = weight * 0.45
# print(f"You are {converted} kilos")
# else:
# converted = weight / 0.45
# print(f"You are {converted} pounds")
# course = 'learning python course'
# print('learning' in course)
... | true |
55d1327b7920652db09011cca88e7597fd527588 | edelira/rock-paper-scissors | /rock-paper-scissors.py | 1,545 | 4.15625 | 4 | import random
print "Welcome to Rock, Paper, Scissors! \nBest out of five wins! \nSelect your tool"
user_score = 0
computer_score = 0
def score():
print "Current score \nUser: %d \nComputer: %d" %(user_score, computer_score)
while True:
user_pick = raw_input("Rock, paper or scissors? ").lower()
options ... | true |
b4e4f0b90bba0259511a0c1654729d71d1fec7fb | YashDjsonDookun/home-projects | /Projects/HOME/PYTHON/Codecademy/Vacation/Vacation.py | 933 | 4.125 | 4 | print ("Please choose a city from Los Angeles, Tampa, Pittsburgh or Charlotte.")
def hotel_cost(nights):
#Assuming that the hotel costs $140/nights
return 140 * nights
def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pitt... | true |
fc403310c072617a16037a0a1c1600e883d4e556 | radetar/hort503 | /Assignment03/ex30.py | 463 | 4.15625 | 4 | people = 30
cars = 40
trucks = 15
if cars > people:
print("We should take the cars")
elif cars < people:
print("We should not take the cars")
else:
print("We can't decide")
if trucks > cars:
print("Too many trucks")
elif trucks < cars:
print("maybe we could take the trucks")
else:... | true |
973f067b608ac5da1cdd7efbffcde8c3973235d9 | Bicky23/Data_structures_and_algorithms | /merge_sort/myversion_inversions.py | 1,205 | 4.1875 | 4 | def merge_sort_inversions(array):
# base case
if len(array) <= 1: return array, 0
# split into two and recurse
mid = len(array) // 2
left, left_inversions = merge_sort_inversions(array[:mid])
right, right_inversions = merge_sort_inversions(array[mid:])
# merge and return
sorted_array, ... | true |
a9ef5ee835e77018609406891d020a72be16d91e | halilibrahimdursun/class2-functions-week04 | /4.9_alphabetical_order.py | 386 | 4.53125 | 5 | def alphabetical_order(words=''):
"""takes an input form user in which the words seperated with hyphen icon(-), sorts the words in alphabetical order,
adds hyphen icon (-) between them and gives the output of it."""
words = words.split('-')
words.sort()
return '-'.join(words)
print(alphabetical_or... | true |
ef219d587fb46ba7dd01c69f55e05aca2b0de6f1 | sn1p3r46/pyspacexy | /psyspacexy/point.py | 1,610 | 4.4375 | 4 | #!/usr/bin/python3
from numbers import Number
class Point:
"""
This class is meant to describe and represent points in a 2D plane,it also
implements some basic operations.
"""
def __init__(self,x,y):
if not isinstance(x,Number) or not isinstance(y,Number):
TypeError("Coordin... | true |
3a934cf92f631e657b1191106a0db02e70f707da | JAYASANKARG/cracking_the_coding_interview_solution | /is_unique.py | 892 | 4.21875 | 4 | """Is Unique: Implement an algorithm to determine if a string has all unique characters. What if you
cannot use additional data structures clear
"""
"""s=input("Enter the string : ")
before_set=len(s)
s=set(s)
after_Set=len(s)
if(before_set==after_Set):
print("all is unique")
else:
print("Not unique")
o(1)
r... | true |
e90427b98d48bc2feab9fdc1d3091a538f99cbaf | willtseng12/dsp | /python/q8_parsing.py | 2,105 | 4.59375 | 5 | # The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against them). Write a program to r... | true |
4ff04cb313be5cb69b00b116cfaf71cfd771ba25 | spicy-crispy/python | /py4e/iterationtest.py | 373 | 4.25 | 4 | count = 0
print('Before:', count)
# This loop goes through the numbers in the list and counts their position
for thing in [9, 41, 12, 3, 74, 15]:
count = count + 1
print(count, thing)
print('After:', count)
print('Summing in a loop')
sum = 0
print('Before:', sum)
for item in [9, 41, 12, 3, 74, 15]:
sum = ... | true |
0f541ff7da0c1b58ddc9dba2b5a2b8c31e6dfe9b | spicy-crispy/python | /bio/symbol_array.py | 1,058 | 4.15625 | 4 | def symbol_array(genome, symbol):
array = {}
n = len(genome)
extended_genome = genome + genome[0:n//2 - 1] # extended because circular DNA,
# so must extend genome by length of the window (minus 1) to catch the tail to head fusion nucleotides.
# note: if you dont -1, still get same answer, j... | true |
adc84c39f426a9010de6de00f2b1c27bdf2b6807 | TiffanyD/Hangman | /GuessingWithLimit.py | 2,660 | 4.1875 | 4 | from math import pi
spaces = " "
spaces2 = " "
print ("%sShapes available to compute: Triangle, Square, Rectangle, Circle" %spaces)
def multiplier(counter,number,retain,shape):
return numbe... | true |
fdcc00bc129f576f5f339c853b5919ed3963cbbd | cavan33/My_OpenBT_Backup | /PyScripts/Scikit-Learn Learning/StatisticalLearning_ScikitLearn.py | 2,549 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
================================
Statistical learning: the setting and
the estimator object in scikit-learn
================================
This section of the tutorial...
"""
from sklearn import datasets
iris=datasets.load_iris()
data=iris.data
data.shape
# Example ... | true |
113024536e704d0d7852f867f4f6b42cf2b592f1 | qqqq5566/pythonTest | /ex5.py | 852 | 4.3125 | 4 | #-*- coding:utf-8 -*-
#python 中的格式化输出变量
#如果在{0}有数字,则其他的{n},必须也是数字
my_name = 'Zend A. Shaw'
my_age = 35
my_height = 74
my_weight = 180
my_eyes = 'blue'
my_teeth = 'White'
my_hair = 'Brown'
#f 是format的意思
#print(f'Let\'s talk about {my_name}') #这中格式化字符串从Python3.6开始使用
print("Let's talk about {}.".format(my_name))
prin... | true |
2df2ae4378929ad2fdd58be254c9795c0ee7c2aa | AadeshSalecha/HackerRank---Python-Domain | /Classes/ClassesDealingwithComplexNumbers.py | 2,658 | 4.3125 | 4 | #Classes: Dealing with Complex Numbers
#by harsh_beria93
#Problem
#Submissions
#Leaderboard
#Discussions
#Editorial
#For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations.
#
#The real and imaginary precisio... | true |
cd9f1f81a4b28f44315851db386f710356a8ffe7 | Seemasikander116/ASSIGNMENT-1-2-AND-3 | /Assignment 3.py | 1,760 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# Seema Sikander
# seemasikander116@gmail.com
# Assignment #3
# PY04134
# question 1: Make calculator with addition , subtraction, multiplication, division and power
# In[1]:
print('***Calculator***')
x=int(input('Enter Number1:'))
y=int(input('Enter Number2:'))
print('Sum of ... | true |
772101a29feadcb198dcba45f0a2300edfd54ecc | suniljarad/unity | /Assignment2_3.py | 1,113 | 4.53125 | 5 | #
#Step 1 : Understand the problem statement
#step 2 : Write the Algorithm
#Step 3 : Decide the programming language
#Step 4 : Write the Program
#Step 5 : Test the Written Program
#program statement:
# accept one number from user and return its factorial.
###############################################... | true |
32ba947924046228ab39a8ac4ff350d3e38613eb | suniljarad/unity | /Assignment1_3.py | 1,294 | 4.28125 | 4 | #
#Step 1 : Understand the problem statement
#step 2 : Write the Algorithm
#Step 3 : Decide the programming language
#Step 4 : Write the Program
#Step 5 : Test the Written Program
#program statement:
# Take one function named as Add() which accepts two numbers from user and return addition of that two numb... | true |
7f2a3f00292a7cd74e77020f9ac27c9f142f9c04 | suniljarad/unity | /Assignment1_8.py | 1,066 | 4.5 | 4 | #
#Step 1 : Understand the problem statement
#step 2 : Write the Algorithm
#Step 3 : Decide the programming language
#Step 4 : Write the Program
#Step 5 : Test the Written Program
#program statement:
# accept number from user and print that number of “*” on screen
######################################... | true |
80c369d21ed6c57919bc5700a044d51c26cb6857 | suniljarad/unity | /Assignment2_1.py | 1,936 | 4.125 | 4 | #
#Step 1 : Understand the problem statement
#step 2 : Write the Algorithm
#Step 3 : Decide the programming language
#Step 4 : Write the Program
#Step 5 : Test the Written Program
#program statement:
#Create on module named as Arithmetic which contains 4 functions as Add()for addition,Sub()for subtraction,Mult... | true |
41ca92cc3e3850e3e24d28a55e594ae386bab853 | Bhumiika16/Python_Assignment | /Problem(2.5).py | 520 | 4.28125 | 4 | #Length, Breadth and Heigth of both the cuboid is taken as an input from user.
dimensions_x = list(map(int, input().split(",")))
dimensions_y = list(map(int, input().split(",")))
#Initialized volume of both the cuboid as One.
volume_of_x, volume_of_y = 1, 1
#Loop is run 3 times to multiply all the 3 dimesnions of the... | true |
7e8d417286b457522937ab5bf79664b56322ee38 | chiren/kaggle-micro-courses | /python/lesson-03/ex-02.py | 339 | 4.125 | 4 | """
Exercise 02:
Define a function named avg2 which takes 2 arguments n1, n2 and return the average
of n1, n2.
Then run your avg2 function with 2 numbers, and print out the result
ex:
result = avg2(3, 4)
print("Result:", result)
"""
# define your function here
# Call your function with 2 numbers, and print ou... | true |
a0d2d1375a743c8efc7264405b0698de33eb9f45 | chiren/kaggle-micro-courses | /python/lesson-03/ex-05-solution.py | 698 | 4.25 | 4 | """
Exercise 05:
Define 2 functions. The first one named larger which takes 2 numbers,
and return the larger of the 2 numbers. The second one named smaller which
takes 2 numbers and return the smaller one.
Call your functions with 2 number, and print out the results
ex:
a, b = 4, -5
print("The larger of a and b is... | true |
596798d01ca2ddc3e7498da16e9066dec7c042c1 | chiren/kaggle-micro-courses | /python/lesson-04/ex-01-solution.py | 752 | 4.125 | 4 | """
Function Name: first_item
Function Arguments: list
Return: The first item of the list
Function Name: last_item
Function Arguments: list
Return: The last item of the list
"""
# define your function here
def first_item(list):
return list[0]
def last_item(list):
return list[-1]
# The following codes test... | true |
8c83babb242becf48e9f9da462432a43addbdf5f | chiren/kaggle-micro-courses | /python/lesson-05/ex-09.py | 992 | 4.5 | 4 | """
Define a function which takes a list of grades, and calculates the Grade Point Average(GPA)
for the courses taken. Assuming each course has the same weight.
Function Name: gpa
Function Arguments: grades which is a list of grades
Returns gpa which is a decimal number
** NOTE **
This time there is no grade_to_po... | true |
dda91b44d572827db5ce113732a936e22058d125 | hoops92/Intro-Python-I | /src/05_lists.py | 545 | 4.34375 | 4 | # For the exercise, look up the methods and functions that are available for use
# with Python lists.
x = [1, 2, 3]
y = [5, 6, 7]
# For the following, DO NOT USE AN ASSIGNMENT (=).
# Change x so that it is [1, 2, 3, 4]
# YOUR CODE HERE
x.append(4)
print(x)
# Using y, change x so that it is [1, 2, 3, 4, 8, 9, 10]
# ... | true |
ced82fd1194a648e6f884744d02261fa3c4758a8 | yusuf-zain/1786-voting-simulator | /1786-voting-simulator.py | 1,378 | 4.125 | 4 | import sys
print("""""")
print("""Welcome to Voting Simulator 1786.
Before we can decide whether you could vote,
we will have to ask you some questions.
Please answer in a yes/no format (besides age).
""")
closing = """Thank you for playing!"""
landowner = (input("Do you own any land? ").lower())
if landowner is not {"... | true |
4fb31538c36bc9ed15236ec487ef579ae17855e9 | reisenbrandt/python102 | /sequences.py | 1,182 | 4.5 | 4 | # strings
'example string'
empty_string = ''
# integers
7
# floats
7.7
# booleans
True
False
# list => indicated by square brackets
languages = ['python', 'javascript', 'html', 'css']
empty_list = []
# lists use a zero based index => ALWAYS starts at 0
# lists have two indexes => a positive index and a negative in... | true |
7cdf8971bb0c2e8cfd7886227578219128aa9e18 | gxgarciat/Playground-PythonPractice | /D4_p.py | 2,491 | 4.3125 | 4 | # Type a program that will play Rock, Paper, Scissors against the user
# Use the ASCII code to show the selection from the computer and the user
import random
computerRound = 0
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
... | true |
6f05809c55668ea82385da806958702556da9912 | gxgarciat/Playground-PythonPractice | /D3_c4.py | 1,205 | 4.40625 | 4 | # Build a program that create an automatic pizza order
# Consider that there are three types of pizza: Small ($15), Medium ($20) and large ($25)
# If you want to add pepperoni, you will need to add $2 for a small pizza
# For the Medium or large one, you will need to add $3
# If you want extra cheese, the added price wi... | true |
ecd967ece7662a1551df91ec391e81c29d947220 | soyo-kaze/PythonTuT101 | /Chap2 Functions.py | 770 | 4.28125 | 4 | """
-Chapter 2-
\Functions/
->It is systematic way of solving a problem by dividing the problem into several
sub-problems and then integrating them and form final program.
->This approach also called stepwise refinement method or modular approach.
=Built-in Functions=
1. input function: accepts string from user w... | true |
dce5e0e8c42cb355700d961c51b1a4f7f508ed3b | vidyakinjarapu/Automate_the_boring_stuff | /ch_6/bulletPointAdder.py | 603 | 4.1875 | 4 | '''
get the text from the clipboard, add a star and space to the beginning of each
line, and then paste this new text to the clipboard.
1.Paste text from the clipboard.
2.Do something to it.
3.Copy the new text to the clipboard. '''
#!python
import pyperclip
text = pyperclip.paste()
# print(text)
#Code to add star an... | true |
f6f37a78f00dd4ae18d8a3b203f6420365d9baac | Sai-Bharadwaj/JenkinsWorking | /input.py | 403 | 4.15625 | 4 | x=int(input("Enter First Number:"))
y=int(input("Enter Second Number:"))
#z=int(input("Enter Third Number:"))
#if(x>y):
# print("First number is greater,",x)
#else:
# print("Second Number is greater,",12)
#l= x if x>y and x>z else y if y>z else z
#print("Max values is:",l)
l = "Both Numbers are equaly" if x==... | true |
b2ae37fbc3424ab6abf424c972dfcf0f71c029ef | Dominic-Perez/CSE | /LuckySevens/More Python Notes.py | 1,620 | 4.46875 | 4 | #shopping_list(0) = "2% milk"
#print(shopping_list)
#print(shopping_list[0])
# Looping through lists
#for item in shopping_list:
# print(item)
'''
1. Make a list
2. change the 3rd thing on the list
3. print the item
4.print the full list
'''
#List = ["straw", "nut", "glass", "lime", "table", "chair", "Tonatiuh", ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.