blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
45741e375f049b22566ca98b54f966a531d18178 | sonalinegi/Training-With-Acadview | /thread.py | 1,039 | 4.21875 | 4 | #Create a threading process such that it sleeps for 5 seconds and then prints out a message.
import threading
import time
import math
def mythread() :
print('thread is starting')
time.sleep(5)
print('thread is ending')
t=threading.Thread(target=mythread)
t.start()
#Make a thread that prints numbers from ... | true |
805d046c0b89d814faafebef53c44e37eb23b69a | onc-healthit/SPD | /SPD Data Generator/nppes_data_generators/npis/utils.py | 860 | 4.25 | 4 | import operator
from fn.func import curried
def backward_digit_generator(number):
'''
Given a number, produces its digits one at a time starting from the right
:param number:
:return:
'''
if number == 0:
return
yield number % 10
yield from backward_digit_generator(number // 10... | true |
0e641db8d691a96cc7ea8a2336bc336c59330a4f | solomonli/PycharmProjects | /CodingBat/Logic-1/love6.py | 530 | 4.125 | 4 | def love6(a, b):
"""
The number 6 is a truly great number. Given two int values, a and b,
return True if either one is 6. Or if their sum or difference is 6.
Note: the function abs(num) computes the absolute value of a number.
love6(6, 4) → True
love6(4, 5) → False
love6(1, 5) → True
:... | true |
0cfc99ea3265b2f6e04e1378e2730dff56e9bc02 | solomonli/PycharmProjects | /Stanford/Python Numpy Tutorial.py | 1,237 | 4.1875 | 4 | def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
small = [x for x in arr if x < pivot]
mid = [x for x in arr if x == pivot]
big = [x for x in arr if x > pivot]
print(small, " AND ", mid, " AND ", big)
return quicksort(small) + mid + quicksort(big)
print(q... | true |
69f79ee16e480e49518c42354e0a5cae79d33c90 | solomonli/PycharmProjects | /The Absolute Basics/Chapter 3/Section 1.py | 1,112 | 4.28125 | 4 | __author__ = 'phil'
# Basic prompt
input("Prompt")
# Feeding the entered data from the prompt into a String variable
inputString = input("Enter something: ")
# Now output the String
print("You entered:", inputString)
# Assigning to a variable, and performing a calculation
mathsInt = (input("Enter an integer: ") / 2)... | true |
3d83a21171ae14b33c7ce1bf1fab9a2f8a2575d9 | Zak-Kent/Hack_O_class | /wk1/names_challenge.py | 835 | 4.21875 | 4 | """
The goal of this challenge is to create a function that will take a list of
names and a bin size and then shuffle those names and return them in a
list of lists where the length of the inner lists match the bin size.
For example calling the function with a list of names and size 2 should return
a list of list... | true |
da632a41ed0b9cd24276ccde14c70b2080fe2bdd | akyerr/Codewars-Examples | /facebook_likes.py | 823 | 4.1875 | 4 | """
You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item.
Implement a function likes :: [String] -> String, which must take in input array, containing the names of people who li... | true |
64a1ce15b855819cf6b3456f95bb87c4ee592052 | akyerr/Codewars-Examples | /add_and_convert_to_Binary.py | 284 | 4.40625 | 4 | """
Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition.
The binary number returned should be a string.
"""
def add_binary(a,b):
result = bin(a+b)
return result[2:]
print(add_binary(1,1)) | true |
c687037d35ef6aacc65d171c1d87ae2f7367a972 | karar-vir/python | /difference_between_sort_and_sorted.py | 375 | 4.34375 | 4 | langs = ["haskell", "clojure", "apl"]
print(sorted(langs)) #sorted(langs) will return the new list bt it will not effect the original list
print('original list : ',langs)
langs.sort() #langs.sort() will return the new sorted list placed at the previous list
print(langs)
#Reverse() funtion
print('origin... | true |
56925000eaeb4f5f51574302ac5aada4e9657783 | Adrncalel/holbertonschool-higher_level_programming | /0x06-python-classes/4-square.py | 893 | 4.5 | 4 | #!/usr/bin/python3
class Square:
"""An empty class that defines a square"""
def __init__(self, size=0):
"""inizialization and conditioning input only to be integer"""
'''
if isinstance(size, int) == False:
raise TypeError("size must be an integer")
if size < 0:
... | true |
dd0cc39c574724db9e894830f1b60b788a8f95f6 | Adrncalel/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 475 | 4.28125 | 4 | #!/usr/bin/python3
"""
This is the add_integer module
The function adds two integers or floats
"""
def add_integer(a, b=98):
"""This function adds to variables 'a' and 'b' which
can be either float or int and returns the value
casted to int"""
if isinstance(a, (float, int)) is False:
raise Ty... | true |
f41270ab8de5dcb8b5405ae7c5c6b163021a1906 | ngupta10/Python_Learnings | /Basic Python Scripts/List&Functions.py | 2,416 | 4.625 | 5 | """
0.Setup:
a.create a list of integers and assign it to a variable
b.create a list of strings and assign it to a variable
c.create a list of floats and assign it to a variable
1.Passing A List to A Function:
a.create a function that takes and returns an input
b.print a call of the function you creat... | true |
025c7bf7c4ab66a8aa5e826964f7a68ca0245b88 | ngupta10/Python_Learnings | /Basic Python Scripts/commentsAndMathOperators.py | 1,538 | 4.1875 | 4 | """
comments practice:
1.create a single line comment 2.create a multiple line comment
"""
# enter your code for "comments practice" between this line and the line below it---------------------------------------
# --------------------------------------------------------------------------------------------... | true |
2567d02810607eb8e12826e5aceb419dfedf2a9d | fs412/codingsamples | /HW01fransabetpour-1.py | 2,090 | 4.25 | 4 | """ My name is Fran Sabetpour and here is my script for the classic "Rock, Paper, Scissors" game! """
def startover():
# User gets to input their choice between rock, paper, scissors.
game = input("Let's play some Rock, Paper, Scissors! R = rock, S = scissors, P = paper. Press Q if you would like to quit. Now le... | true |
c8fc402ee1dcba95dc7b9e3d5bc1f408fb66e418 | JohnJGreen/1310Python | /hw01/hw01_task4.py | 786 | 4.125 | 4 | # John Green
# UT ID 1001011958
# 9/01/13
# Write a program that asks the user to enter two real numbers (not integers) and
# computes and displays the following opertations between the two:
# multiplication, division, integer division, modulo , exponentiation
# hw01_task4
# First number
first_flt = float(input("En... | true |
c2eb184d8c3088aeb4adf1f491ae54be853fbb1f | ABROLAB/Basecamp-Technical-Tasks | /Task_7.py | 883 | 4.1875 | 4 | '''
Write a function that takes an array of positive
integers and calculates the standard deviation of
the numbers. The function should return the standard deviation.
'''
def Calc_Standard_Dev(int_array):
standard_deviation = 0
sqr_mean = 0
sqr_array = []
# step 1: calculate the mean
mean = s... | true |
5cbd32acc84eec60397e0adf2ee48a05cfbfc371 | ProjitB/StoreHouse | /bomberman/Assignment1_20161014/brick.py | 582 | 4.21875 | 4 | import random
from random import randint
class Brick(object):
def __init__(self, board):
'''Initializes the board
'''
self.board = board.board
#Random initial location for Brick
x = randint(3, board.size)
y = randint(3, board.size - 1)
#If original position n... | true |
3f5345a8ed48cbdcb9f72d4a7d3df7ffdb2277c4 | thessaly/python_boringstuff | /2.py | 1,069 | 4.25 | 4 |
name = ''
# Example of infinite loop
#while name != 'your name':
# print('Please type your name.')
# name = input()
#print('Thanks!')
# When used in conditions, 0, 0.0 and ' ' are considered False
# name = ''
# while not name:
# print('Enter your name:')
# name = input()
# print('How many guests will yo... | true |
932a5f8d571d30fb08e416aa450b224373b3c750 | AssiaHristova/SoftUni-Software-Engineering | /Programming Basics/nested_loops/train_the_trainers.py | 477 | 4.125 | 4 | n = int(input())
presentation = input()
sum_all_grades = 0
all_grades = 0
while presentation != 'Finish':
sum_grades = 0
avg_grade = 0
for i in range(1, n + 1):
grade = float(input())
sum_grades += grade
avg_grade = sum_grades / i
sum_all_grades += grade
all_grades +... | true |
c866045f8650d004b4541b8a06365930eddc9b5c | SiddharthandTiger/Sid | /P5.py | 570 | 4.1875 | 4 | a= float(input("Enter your height 'ONLY NUMERICAL VALUE':-"))
b= input("Enter your height unit (i.e. the value you have given above is in cm or m or feets or inches):-")
c= float(input("enter your weight in KG:-"))
if(b=='cm'):
print('your BMI is',c/((a/100)**2))
elif(b=='m'):
... | true |
aa9168455b376a7e4ff03366b971f4de63a16bc9 | gurpsi/python_projects | /python_revision/11_tuple.py | 1,039 | 4.34375 | 4 | '''
List a = [1,2,3]
List occupies more space as we have more number of methods available with it and it is mutable.
i.e. Add, Remove, Change data.
Tuple b = (1,4,6,9)
Occupies less memory as we have less number of methods available with it, and it is immutable.
i.e. Cannot be changed.
'''
import sys
import timeit
#... | true |
49ae693e992687dc0034379a74e4a6c072b758f6 | csfx-py/hacktober2020 | /fizzBuzz.py | 392 | 4.34375 | 4 | #prints fizzz if number is divisible by 3
#prints buzz if number is divisible by 5
#prints fizzbuzx if divisible by both
def fizzbuzz(number):
if(number%3 == 0 and number%5 == 0):
print("fizzbuzz")
elif(number%3 == 0):
print("fizz")
elif(number%5 == 0):
print("buzz")
else:
... | true |
76cfbd5e7ea13120b5c46dff5febce0b24e6988d | csfx-py/hacktober2020 | /python-programs/data-visualization-matplotlib-pandas/retail_visualize.py | 2,685 | 4.21875 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
if __name__ == '__main__':
retail_csv = pd.read_csv("BigMartSalesData.csv")
# 1. Plot Total Sales Per Month for Year 2011. How the total sales have increased over months in Year 2011.
df = retail_csv.query("Year == 2011").filter(["Mon... | true |
cc90a561902bfc788ade5a2925905bba658db3cd | MJ702/pythonprogamming | /cryptography/method/caesar_cipher.py | 430 | 4.21875 | 4 | def encrypt(text, key):
result = ""
for i in range(len(text)):
char = text[i]
if char.isupper():
result += chr((ord(char) + key - 65) + 65)
else:
result += chr((ord(char) + key - 97) + 97)
return result
text = str(input("Enter your string to encrypt data: "... | true |
d24086a0e9a5e5ddf882e0b5d3b829d304041e23 | doa-elizabeth-roys/CP1404_practicals | /prac_05/word_occurrences.py | 440 | 4.40625 | 4 | user_input = input("Text:")
word_count_dict = {}
words = user_input.split()
print(words)
for word in words:
word_count_dict[word] = word_count_dict.get(word,0) + 1
words = list(word_count_dict.keys())
words.sort()
# use the max function to find the length of the largest word
length_of_longest_word = max((len(word) fo... | true |
607fa56c3bbec30c64ed08ef5c1b06cdac2e2410 | whdesigns/Python3 | /1-basics/6-review/2-input/1-circle.py | 399 | 4.53125 | 5 | import math
# Read radius from user
print("Please enter radius")
radius = float(input())
# Calculate area and circumference
area = math.pi * (radius * radius)
# alternative
# math.pi * (radius ** 2)
# math.pi * pow(radius, 2) # Best for more advanced code
circumference = 2 * math.pi * radius
# Display result
print(... | true |
36f6cc335f53c4c86fd0de9576278e9c38367115 | maread99/pyroids | /pyroids/lib/physics.py | 418 | 4.15625 | 4 | #! /usr/bin/env python
"""Physics Functions.
FUNCTIONS
distance() Direct distance from point1 to point2
"""
import math
from typing import Tuple
def distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float:
"""Return direct distance from point1 to point2."""
x_dist = abs(point1[0] - point2[0])
... | true |
3f56f4b41784ae7476834a851926d9e578501808 | AndreeaEne/Daily-Programmer | /Easy/239.py | 1,266 | 4.125 | 4 | # Back in middle school, I had a peculiar way of dealing with super boring classes. I would take my handy pocket calculator and play a "Game of Threes". Here's how you play it:
# First, you mash in a random large number to start with. Then, repeatedly do the following:
# If the number is divisible by 3, divide it by 3.... | true |
43a6204ab7f836ebf6c5b97403fc6df968a1aafc | laplansk/learnPythonTheHardWay | /ex6.py | 1,041 | 4.40625 | 4 | # These declare and instantiate string variables
# in the case of x, %d is replaced by 10
# in the case of y, the first %s is replaced by the value of binary
# and the second is replaced by the value of do_not
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those w... | true |
ef5407467b1a7da16a79c927729f4d157f042499 | nishantml/Data-Structure-And-Algorithms | /recusrion/program-1.py | 261 | 4.1875 | 4 | def fun1(x):
if x > 0:
print(x)
fun1(x - 1)
print('completed the setup now returning')
fun1(3)
"""
In Above First printing was done the recursive call was made
Printing was done at calling time that before the function was called
""" | true |
0281244f624f9d6c3d83e1a2294d327a000132d7 | nishantml/Data-Structure-And-Algorithms | /startup-practice/get_indices.py | 596 | 4.15625 | 4 | """
Create a function that returns the indices of all occurrences of an item in the list.
Examples
get_indices(["a", "a", "b", "a", "b", "a"], "a") ➞ [0, 1, 3, 5]
get_indices([1, 5, 5, 2, 7], 7) ➞ [4]
get_indices([1, 5, 5, 2, 7], 5) ➞ [1, 2]
get_indices([1, 5, 5, 2, 7], 8) ➞ []
Notes
If an element does not exist i... | true |
f92c49b214c64a797c8e6276ffd068f3e6ac5478 | nishantml/Data-Structure-And-Algorithms | /Hash/keyword-rows.py | 1,270 | 4.21875 | 4 | """
Given a List of words, return the words that can be typed using letters of alphabet on only one row's
of American keyboard like the image below.
Example:
Input: ["Hello", "Alaska", "Dad", "Peace"]
Output: ["Alaska", "Dad"]
Note:
You may use one character in the keyboard more than once.
You may assume the... | true |
3da81d30e6f07bceff071f6b48da10100f2cf4b8 | nishantml/Data-Structure-And-Algorithms | /complete-dsa/array/maxSubArray.py | 849 | 4.15625 | 4 | """
53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Example 1:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
Example 2:
Input: nums = [1]
Output: 1
Exampl... | true |
207b15ac6ca59619d6a17eab2ad4064d111f39b2 | nishantml/Data-Structure-And-Algorithms | /basics-data-structure/queue/implementQueueUsingLinkedList.py | 1,735 | 4.21875 | 4 | class Node:
def __init__(self, data=None):
self.data = data
self.next = None
class Queue:
def __init__(self):
self.first = None;
self.last = None;
self.length = 0;
def enqueue(self, data):
new_node = Node(data)
if self.first is None:
sel... | true |
b03744213e17b2f45a3990ec4cb803c1ef49fb77 | nishantml/Data-Structure-And-Algorithms | /basics-data-structure/queue/implementQueueUsingArray.py | 1,714 | 4.125 | 4 | class Queue:
def __init__(self):
self.array = []
self.length = 0
# adding the data to the end of the array
def enqueue(self, data):
self.array.append(data)
self.length += 1
return
# popping the data to the start of the array
def dequeue(self):
poped ... | true |
40dcadcd7aa500001b2a52db747ee1bf3f340ef8 | andrewar/primes_challenge | /primes/primes.py | 1,562 | 4.15625 | 4 | import sys
def print_primes(n):
"""Print out the set of prime numbers, and their multiples"""
primes_list = get_primes(n)
mult_table = {}
# Get the largest val for the formatting fields
cell_size = len(str(primes_list[-1]**2))
print(" %*s"%(cell_size, " "), end=" ")
for i in range(len... | true |
33cbd8235d4731b0497356f6768effe36034cca3 | datadave/machine-learning | /brain/converter/calculate_md5.py | 1,348 | 4.4375 | 4 | #!/usr/bin/python
'''@calculate_md5
This file converts an object, to hash value equivalent.
'''
import hashlib
def calculate_md5(item, block_size=256*128, hr=False):
'''calculate_md5
This method converts the contents of a given object, to a hash value
equivalent.
@md5.update, generate an md5 che... | true |
0fc21bdcf2ef872f72b86a5b581289533e34eba6 | mevans86/rosalind | /signed_permutations.py | 978 | 4.125 | 4 | import itertools
import math
def list_of_signed_permutations(n):
"""Lists all possible signed permutations of +-1, 2, 3, ..., n."""
ret = [ ]
for mult in list(itertools.product([-1, 1], repeat=n)):
for perm in list(itertools.permutations(range(1, n+1))):
ret.append(tuple([x * y for x, y in zip(list(mult), perm... | true |
aa9cce79ad87722276485c7f47d71dfd922d7de6 | PFSWcas/CS231n_note | /python/Assignment2/test_as_strided.py | 1,153 | 4.125 | 4 | import numpy as np
def rolling_window(a, window):
"""
Make an ndarray with a rolling window of the last dimension
Parameters
----------
a : array_like
Array to add rolling window to
window : int
Size of rolling window
Returns
-------
Array that is a view of the... | true |
c4acc908848a00d733add4aca3f199abfcb01f90 | AmeerCh/programs | /python/product.py | 361 | 4.40625 | 4 | print('To find the product of three numbers, ',end = '')
Number1 = int(input('enter the first number:'))
Number2 = int(input('Enter the second number:'))
Number3 = int(input('Enter the third number:'))
Product = Number1 * Number2 * Number3
print('The product of ' + str(Number1) + ', ' + str(Number2) + ' and ' + st... | true |
a380c16b83a1955e6177f5d9c58219a28e0c37fe | CardinisCode/CS50_aTasteOfPython | /loops.py | 444 | 4.34375 | 4 |
statement = "Hello world!"
# Lets print a statement 10x
# Using a While loop:
# i = 0
# while i < 10:
# print(statement)
# i += 1
# # Using a for loop
# for i in range(0, 10):
# print(i + 1, ":", statement)
# Lets take user input to know how many times we should repeat our statement:
# repeat = int(i... | true |
10de18333ff1f9ae2d56a1a4fa32190dd3e61b73 | Th3Av1at0r/CIS106-Avi-Schmookler | /Assignment 7/Activity 2.py | 2,604 | 4.1875 | 4 | # this program takes your age
# in years and gives it back
# in months, days, hours, or seconds
def get_years():
variable = 0
while variable == 0:
print("how many years old are you?")
years = input()
if years.isdigit():
return float(years)
else:
... | true |
fbd01ecb2d1feced945e6b8571262954aa9522c2 | Th3Av1at0r/CIS106-Avi-Schmookler | /Assignment 5/Activity 7.py | 735 | 4.125 | 4 | def get_dog_name():
print("What's your dog's name?")
dog_name = (input())
return dog_name
def display_result(dog_name, dog_age):
print(str(dog_name) + " is " + str(dog_age) + " years old in dog years")
def get_human_dog_age():
print("How many years old is your dog?")
human_dog_age =... | true |
65747b4d5abe06171304fa704489c60e1b3b74b6 | hernu123/-2020-2021-Spring-Term---Assignment-iv | /main.py | 392 | 4.21875 | 4 | number = int(input("Enter a natural number : "))
if number < 1:
print("Number needs to be greater than 1")
elif number == 1:
print(number, " is neigher prime nor composite")
else:
for divisor in range(2, (number//2)+1):
if (number % divisor) == 0:
print(number,"is a Composite Number")
... | true |
66325e151b3f2faa5330e7c81b540fbeba460a05 | natelee3/python2 | /largest_number.py | 239 | 4.34375 | 4 | #Largest Number
#Create a list of numbers and print the largest number.
simple_list = [3, 4, 5, 455, 7, .5]
largest = 0
for num in simple_list:
if num > largest:
largest = num
print("The largest number is " + str(largest))
| true |
70b64bb3ed106042aaeef9725e63c45b6c6597ab | aliciamorillo/Python-Programming-MOOC-2021 | /Part 2/13. Alphabetically in the middle.py | 277 | 4.25 | 4 | letter1 = input("1st letter:")
letter2 = input("2nd letter:")
letter3 = input("3rd letter:")
word = letter1 + letter2 + letter3
def sortString(str):
return ''.join(sorted(str))
sortedWord = sortString(word)
print("The letter in the middle is", sortedWord[1]) | true |
166c104c7ebe8887d9024c1f9c38c48cf097c351 | aliciamorillo/Python-Programming-MOOC-2021 | /Part 1/10. Story.py | 438 | 4.28125 | 4 | #Please write a program which prints out the following story.
# The user gives a name and a year, which should be inserted into the printout.
name = input("Please type in a name: ")
year = input("Please type in a year: ")
print(name +" is valiant knight, born in the year " + year + ". One morning " + name + " wok... | true |
b104fd468a1d78cc3fd81dff7447034a121aa80c | aliciamorillo/Python-Programming-MOOC-2021 | /Part 1/14. Times five.py | 239 | 4.28125 | 4 | #Please write a program which asks the user for a number.
# The program then prints out the number multiplied by five.
number = int(input("Please type in a number:"))
plusNumber = number * 5
print(f"{number} times 5 is {plusNumber}") | true |
4381ba344238c7ef2e13b41bc46a376ea263283d | lvamaral/RubyAlgorithms | /Dynamic Programming/ways_to_make_change.py | 918 | 4.1875 | 4 | # Print a single integer denoting the number of ways we can make change for n dollars using an infinite supply of "coins" types of coins.
def make_change(coins, n, index = 0, memo = {}):
if n == 0:
return 1
if index >= len(coins):
return 0
#Save the current amount being considered and the ... | true |
c62b31e26706cd226cae4272f1cf605aa4be4449 | limahseng/cpy5python | /compute_bmi.py | 420 | 4.375 | 4 | # Filename: compute_bmi.py
# Author: Lim Ah Seng
# Created: 20130221
# Modified: 20130221
# Description: Program to get user weight and height and
# calculate body mass index
# main
# prompt and get weight
weight = int(input("Enter weight in kg: "))
# prompt and get height
height = float(input("Enter height in m: ")... | true |
21f60b7d94eba832b6ebcc239e36ccf3e9659420 | sivamu77/upGrade_assignment3 | /assignment_3.py | 1,020 | 4.40625 | 4 | import numpy as np
#1 Create a numpy array starting from 2 till 50 with a stepsize of 3.
arr=np.arange(2,50,3)
print(arr)
#2 Accept two lists of 5 elements each from the user. Convert them to numpy arrays. Concatenate these arrays and print it. Also sort these arrays and print it.
ip1=np.array([int(input()) ... | true |
b4db2715ae8bcc60054ac33698703d5549e71410 | shadydealer/Python-101 | /Solutions/week02/simplify_fraction.py | 854 | 4.15625 | 4 | def gcd(a,b):
if b == 0:
raise ZeroDivisionError("Cannot mod with zero.")
t = 0
while b != 0:
t = b
b = a% b
a = t
return a
def simplify_fraction(fraction):
if fraction[1] == 0:
raise ZeroDivisionError("Denominator cannot be zero.")
greatest_common_divid... | true |
58d9fa137a59df449b58aaedc1e97d1365efdd36 | Jainesh-roy/guess-the-number | /guess the number.py | 644 | 4.15625 | 4 | # exercise 3
# guess the number
import random
rand_num = random.randint(0,20)
guesses = 0
print("welcome to the game - Guess the number")
print("you have only 9 chances to guess the number\n")
while guesses < 9:
inp = int(input("Enter a number: "))
if inp > rand_num:
print("\nenter a smaller number")
... | true |
7befe78ab3db0f80d82bdd423d442075f46dd168 | Spiritual-Programmer/Python-Course | /working_strings.py | 720 | 4.40625 | 4 | #working with strings and functions
phrase = "Giraffe Academy"
#can use \ to add " or other texts
#\n starts text on next line
#concatenation(adding or appending on) with strings
print(phrase + " is cool, plus me concatening strings")
#functions
print("converting string into uppercase letter")
print(phrase.upper)
... | true |
356efc42abb2c8fd6e16f5d9ceb478ea15c0c63f | akuppala21/Fundamentals-of-CS | /lab4/loops/cubesTable.py | 1,454 | 4.28125 | 4 |
def main():
table_size = get_table_size()
while table_size != 0:
first = get_first()
inc = get_increment()
show_table(table_size, first, inc)
table_size = get_table_size()
# Obtain a valid table size from the user
def get_table_size():
size = int(input("Enter number of rows in table (... | true |
f8f61ab1a1037adb9cfa8d5fe038ef4c884a8370 | Liam-Hearty/ICS3U-Assignment-6B-Python | /triangle_perimeter_calculator.py | 1,222 | 4.25 | 4 | #!/usr/bin/env python3
# Created by: Liam Hearty
# Created on: October 2019
# This program calculates perimeter of a triangle.
def calculate_perimeter(L1, L2, L3):
# calculate perimeter and return perimeter
import math
# process
perimeter = L1 + L2 + L3
return perimeter
def main():
# thi... | true |
28b5ede7a2a33bffdc8457344eeb32ee53cb01d7 | shoredata/dojo-python | /dojo-python-misc/fn_basic_2.py | 2,074 | 4.34375 | 4 | # Functions Basic II
# ====================
# Objectives
# --------------------
# Learn how to create basic functions in Python
# Get comfortable using lists
# Get comfortable having the function return an expression/value
# Countdown - Create a function that accepts a number as an input.
# Return a new array that c... | true |
3689b5598cb5d4e686f99c9eb2f9423b19203ef6 | RAHULMJP/impact_assignment | /attendence_assignment.py | 1,484 | 4.15625 | 4 | ## Question
# In a university, your attendance determines whether you will be allowed to attend your graduation ceremony.
# You are not allowed to miss classes for four or more consecutive days.
# Your graduation ceremony is on the last day of the academic year, which is the Nth day.
# Your task is to determi... | true |
07bb532beaf548f1e074fcb8c4fa601c3433b6f4 | rpryzant/code-doodles | /interview_problems/2019/pramp/drone.py | 997 | 4.125 | 4 | """
drone flight planner
minimum amount of energy for drone to complete flight
burns 1 per ascend
gains 1 per descend
sideways is 0
given
route: array( triples )
e.g. route = [ [0, 2, 10],
[3, 5, 0],
[9, 20, 6],
[10, 12, 15],
[10, 10... | true |
6201b019816bde69b2c679f0715585154c7443a8 | Jardon12/dictionary | /dictionaryoperator.py | 586 | 4.75 | 5 | # empty dictionary
d={}
print(f"my dictionary is {d}")
students = {1: "John", 2: "Valentina", 3: "Beatriz"}
students_list = {"John", "Valentina", "Beatriz"}
# add a new student
students[7] = "Carlos"
print(f"my students are: {students}")
# In a dictionary the order is not important, because you have keys to access th... | true |
e442ff2b09bedaf9ce8a69d3bee8bd565f849375 | omkar6644/Python-Training | /Assignment/2.py | 514 | 4.1875 | 4 | #the below program takes 3 inputs from the user and finds a quadratic equation.
#import square root function from math module
from math import sqrt
a = float(input("a=: "))
b = float(input("b=: "))
c = float(input("c=: "))
#Quadratic function
def quadEqu(a, b ,c):
d = b**2-4*a*c
if d > 0:
x... | true |
d246141eb7b825492dd658c0de99fed57fe9d12d | omkar6644/Python-Training | /encapsulation.py | 1,616 | 4.375 | 4 | #encapsulation of private methods
#encapsulation is a process of binding the data and code together or it is the process of providing controlled access to the private members of the class.
class Car:
def __init__(self):
self.__updateSoftware()
def drive(self):
print('driving')
d... | true |
eb207182c7235e1b63aa899e387e833a429dbe8f | kinalee/holbertonschool-higher_level_programming | /0x06-python-test_driven_development/3-say_my_name.py | 541 | 4.4375 | 4 | #!/usr/bin/python3
"""
3-say_my_name
that prints "My name is " and two given arguments
Contains one module: say_my_name
"""
def say_my_name(first_name, last_name=""):
"""
first_name and last_name should be strings
"""
try:
print("My name is {:s} {:s}".format(first_name, last_name))
except:... | true |
d6057b286992e14e2fdd09d65fcc64c4fd09a7b8 | StephenPrivette/Project-Euler | /Euler Problem 14.py | 1,050 | 4.15625 | 4 | ##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 → 2 → 1
##It can be seen that this sequence
##(start... | true |
938adaab2d7f01cf3a5f38f96baa3310ac409ef1 | vivekbishwokarma99/Lab_Project | /LabFour/Qn_Three.py | 282 | 4.125 | 4 | '''
3.Write a Python program to guess a number between 1 to 9.Note :User is prompted to enter a guess.
If the user guesses wrong then the prompt appears again until the guess is correct, on successful guess,
user will get a "Well guessed!" message, and the program will exit.
''' | true |
cca9b7e9503372777d4e6ac612e433c2f2c2dcfc | cesarm9/PythonExercises | /function_sum_2_numbers.py | 302 | 4.125 | 4 | def sum(a, b): #names the function as sum and takes parameters a and b
total = a + b #saves the sum of a and b in the total variable
return total #returns total as the result of the function
print(sum(2, 3)) #prints the value of return according to the parameters given to the sum function | true |
7a6d13483d43d23e51ae6ea11d9521afaedf4720 | NguyenDuyCuong/Learning | /Python/whileloop.py | 558 | 4.28125 | 4 | i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1
else:
print("i is no longer less than 6")
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
for x in "banana":
print(x)
for x in range(6):
print(x)
# The range() function defaults to increment the sequence by 1, h... | true |
af17172772fd42b3a09b0686f8f254de6b2e3398 | NguyenDuyCuong/Learning | /Python/myscope.py | 852 | 4.21875 | 4 | # A variable created inside a function belongs to the local scope of that function, and can only be used inside that function.
# The local variable can be accessed from a function within the function:
def myfunc():
x = 300
def myinnerfunc():
print(x)
myinnerfunc()
myfunc()
# A variable created in the main ... | true |
222aed1628d593bb583a5999a76eca65c24cd499 | iamdanielchino/wejapa20wave1 | /Lab1of2.py | 855 | 4.34375 | 4 | #Quiz: Calculate
#In this quiz you're going to do some calculations for a tiler.
#Two parts of a floor need tiling. One part is 9 tiles wide by 7 tiles long, the other is 5 tiles wide by 7 tiles long. Tiles come in packages of 6.
#1. How many tiles are needed?
#2. You buy 17 packages of tiles containing 6 tiles each. ... | true |
df3b46c7a5582d882d4abb8c4178de62a4f68a2a | hunthunt2010/CompilersGroup2 | /ToTheAST/namespace.py | 884 | 4.15625 | 4 | #!/usr/bin/env python
#Taylor Schmidt
#ToTheAST group assignment
#namespace implementation
class Namespace:
def __init__ (self):
self.nameString = ''
def addName(self, newName):
"takes a new name string as an arg and returns a tuple with its index and length in the global string"
nameLength = len(newName... | true |
401917d8f5f1028ca7163f1c29fc8bf252cf3655 | cmulliss/gui_python | /challenges/oop_syntax.py | 1,405 | 4.3125 | 4 | class Student:
def __init__(self, name, grades):
self.name = name
self.grades = grades
def average(self):
return sum(self.grades) / len(self.grades)
student = Student("Bob", (90, 90, 93, 78, 90))
student2 = Student("Rolf", (100, 89, 93, 78, 100))
print(student.name)
print(student.grad... | true |
383e729b72c0c31f1d137206bba33d2d8ce5b763 | cmulliss/gui_python | /challenges/lambda.py | 515 | 4.34375 | 4 | # lambda fns dont have a name and only used to return values.
print((lambda x, y: x + y)(5, 7))
# def double(x):
# return x * 2
# list comprehensions
sequence = [1, 2, 3, 4, 5]
# doubled = [double(x) for x in sequence]
doubled = [(lambda x: x * 2)(x) for x in sequence]
print(doubled)
# if you want to use la... | true |
27bd9ff92a28e481101e751b7abb5646a4c89fb9 | HorseBackAI/PythonBlockchain | /6_标准库/6-standard-library-assignment/assignment.py | 413 | 4.125 | 4 | import random
import datetime
# 1) Import the random function and generate both a random number
# between 0 and 1 as well as a random number between 1 and 10.
rn1 = random.random()
rn2 = random.randint(1, 10)
print(rn1, rn2)
print()
# 2) Use the datetime library together with the random number
# to generate a rando... | true |
d872e611e08f88b8ecc0eccfb20ced6534406140 | Azevor/My_URI_Reply | /beginner/1006.py | 433 | 4.15625 | 4 | '''
Read three values (variables A, B and C), which are the three student's grades.
Then, calculate the average, considering that grade A has weight 2, grade B has
weight 3 and the grade C has weight 5. Consider that each grade can go from 0
to 10.0, always with one decimal place.
'''
m_N1 = float(input())*2
m_N2 = fl... | true |
176e5fddfb93a10aa9a3775878d24bf69ebf1416 | khanaw/My-Python-practice | /Fibonacci+Sequence+Generator.py | 1,647 | 4.59375 | 5 |
# coding: utf-8
# # Fibonacci Sequence Generator
#
# ### Enter a number and generate its Fibonacci Number to that number
# The limit is set to 250. You can increase the limit but may get errors. Use recursion to obtain better results at higher numbers. If you wanted to find 1500, it would be better to run the numb... | true |
2d95b0d05e10b25907ad90e44da69b3eb854dd4e | pythonerForEver/EZ-Project | /guess_number.py | 2,096 | 4.15625 | 4 | #! /usr/bin/python3.6
import random
def game_help(minimum=0, maximum=100):
print("""
you have 5 chance to guess number in our mind that
is between {min_}<number<{max_}.
""".format(min_=minimum, max_=maximum))
def guess_number():
maximum = 100
minimum = 0
... | true |
3629b979e2f3bef3ddd7554ce77b88f43ffebfc8 | inventsekar/LinuxTools-Thru-Perl-and-Python | /linux-wc-command-implementation-Thru-Python.py | 779 | 4.1875 | 4 | #!/usr/bin/python
# inventsekar 5th march 2018
# python implementation of Linux tool "wc"
line1 = raw_input("Please enter line1:");
line2 = "A quite bubble floating on a sea of noise. - The God of Small Things - Arundhati Roy";
line3 = "Hello, How are you";
#-------------------------------------#
# Finding number of... | true |
5c342d84049215a42fb64986ecbdff53baf62da8 | vanessa617/Dev_2017 | /tuples.py | 531 | 4.46875 | 4 | #creating a tuple
t1 = ('a','b','c')
print type(t1)
#create an empty tuple
t2 = ()
print t2
print type(t2)
#you have to use a comma even if the tuple has one element
t2 = (1,)
print t2
#getting the first element
print t1[0] #output = a
#getting the last element
print t1[-1] #output = c
#getting elements using slic... | true |
f03a785fce0b9814e652bd587bb824d64588adaa | cpe202spring2019/lab1-JackBeauche | /lab1.py | 2,132 | 4.1875 | 4 |
def max_list_iter(int_list): # must use iteration not recursion
# finds the max of a list of numbers and returns the value (not the index)
# If int_list is empty, returns None. If list is None, raises ValueError
# Check if list is None:
if (type(int_list) == type(None)):
raise ValueError
# Ch... | true |
554a6913036341f20d00e1d6341c98a411331869 | abhiunix/python-programming-basics. | /forloop.py | 1,152 | 4.875 | 5 | #forLoop
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
for city in cities:
print(city)
print("Done!")
#Using the range() Function with for Loops
for i in range(3):
print("Hello!")
#range(start=0, stop, step=1)
#Creating and Modifying Lists
#In addition to extracting information from li... | true |
506f053a5695a697513ed9599f28d76c70069869 | abhiunix/python-programming-basics. | /enumerate.py | 745 | 4.5 | 4 | #Enumerate
#enumerate is a built in function that returns an iterator of tuples containing indices and values of
#a list. You'll often use this when you want the index along with each element of an iterable in a loop.
letters = ['a', 'b', 'c', 'd', 'e']
for i, letter in enumerate(letters):
print(i, letter)
#Quiz:... | true |
85ad6a8a91801ca457548e5ec62eacd5090c9c14 | RileyWaugh/ProjectEuler | /Problem5.py | 1,103 | 4.125 | 4 | #Problem: 2520 is the smallest number divisible by 1,2,3,...10.
# What is the smallest number divisible by 1-20 (more generally, 1-n)?
import math
def greatestLesserPower(x,y):
#findsthe greatest power of x less than or equal to y
if x > y:
return 0
product = 1
while product <= y:
product *= x
return prod... | true |
b2b71150f3d13bfd8de9d35a6fd26f500dcb409c | josenavarro-leadps/class-sample | /teamManager.py | 1,426 | 4.28125 | 4 | #made a class that contains the goals, age, and name.
#"self" is always being needed
class player(object):
def __init__(self, goals, age, name):
self.goals = goals
self.age = age
self.name = name
#now I made a function in my class
def playerstats(self):
print("name" +... | true |
3cfeda8a19cc9e5e490fa862e0744ab1122fb419 | 14masterblaster14/PythonTutorial | /P11_tryexception.py | 1,142 | 4.125 | 4 | #############################
#
# 21# Try Except :
# - The try block lets you test a block of code for errors.
# - The except block lets you handle the error.
# - The finally block lets you execute code, regardless of the result
# of the ... | true |
74c8e37b1aee8458ec2a85dd3cc3f8912b0796bd | 95ktsmith/holbertonschool-machine_learning | /math/0x06-multivariate_prob/0-mean_cov.py | 863 | 4.34375 | 4 | #!/usr/bin/env python3
""" Mean and Covariance """
import numpy as np
def mean_cov(X):
"""
Calculates the mean and covariance of a data set
X is a numpy.ndarray of shape(n, d) containing the data set
n is the number of data points
d is the number of dimensions in each data point
Return... | true |
17ed305f38dc835d83d6661db0de6a9ba8cca688 | njcssa/summer2019_wombatgame | /student_assessment/student_assessment1.py | 2,990 | 4.1875 | 4 | # To do with instructors:
# create 5 variables which all hold different types of data
# at least 1 should hold an int
# at least 1 should hold a double
# at least 1 should hold a boolean
# at least 1 should hold a string
# 1 variable can hold whatever you want
# then print out what one variable holds
# make a progr... | true |
e214dfe2f5ee9b8bbf23bbe42daf9a62bbb4c316 | varunkudva/Programming | /dynamic_programming/balanceParenthesis.py | 722 | 4.21875 | 4 | """
Given n pairs of parentheses, find all possible balanced combinations
Solution:
1. Start with clean slate and add left parenthesis.
2. Add right parenthesis only if there are more left parenthesis than right.
3. Stop if left count == n or right count > left count.
"""
def add_parenthesis(n, left, right, idx, res)... | true |
e76a4f77828e4af880bfc6de8bc99e6a86f58bd7 | RocqJones/python3x_mega | /1.0Basics_Recap/1.8whileLoopRecap.py | 924 | 4.1875 | 4 | # The program will allow a user to create username n password & store in a list then verify the password.
# create user
user_name = input("Enter User Name: ")
user_password = input("Enter new password:")
user_db = []
user_db.append(user_name)
user_db.append(user_password)
# test db
# print(user_db)
# Break
for symbo... | true |
88e9d79d5194b389f295f37e2a4b7d6264bbd817 | stdout-se/tenant | /random_utils.py | 1,042 | 4.125 | 4 | import random
def from_dungeon_level(table, dungeon_level: int):
for (value, level) in reversed(table):
if dungeon_level >= level:
return value
return 0
def random_choice_from_dict(choice_dict: dict):
"""
Provided a dictionary, will return a randomly selected key string. The key... | true |
8b13f5f6647438ba94bba082bcbdeb8d87e2f8ae | SzymonSauer/Python-basics | /BMI_Calculator.py | 412 | 4.21875 | 4 | print("Enter your height: ")
height = float(input())
if height >=3.00:
print("Wow! You are the world's highest man! ;)")
print("Enter your weight: ")
weight = float(input())
bmi = weight/(height**2)
print("BMI:"+str(bmi))
if bmi<18.5:
print("You are too thin!")
elif bmi>=18.5 and bmi <25:
p... | true |
ba80abfcae511a6681c294525ebc1caea40f5681 | birsandiana99/UBB-Work | /FP/Laboratory Assignments/Sapt 1/Assignment 1/pb8.py | 1,389 | 4.125 | 4 | def prim(x):
'''
Input: x-integer number
Output: sem (0 if the number is not prime, 1 if the number is prime)
Determines if the number given is prime or not by verifying if it has any divisors other than itself
'''
sem=1
'special case if the value given is 1 or is a multiple of 2'
if x==... | true |
a2bfd8ddd0c0c484fcfa54807d770d2527a57d6e | birsandiana99/UBB-Work | /FP/Laboratory Assignments/Sapt 1/first 1.py | 260 | 4.125 | 4 | def sum(a,b):
'''
Adds two numbers.
Input: a, b -integer numbers
Output: the sum of a and b (integer)
'''
return a+b
x=int(input("Give me the first number: "))
y=int(input("Give me the first number: "))
print("The sum is: ", sum(x,y))
| true |
5d31c9047b9c34c18a894b1fcceba1cb3d531a5a | DhirendraBhatta/Jupyter | /rpsgame.py | 977 | 4.34375 | 4 | #Assignment of Rock Paper Scissor Game by Dhirendra Bhatta
import random
comp = random.randint(1,3)
print("Computer's generated input is: ",comp)
user = int(input('Enter 1 for rock,2 for paper and 3 for scissor '))
while user not in [1,2,3]:
user = int(input('Enter 1 for rock,2 for paper and 3 for scissor '... | true |
fd63741c194d59c392125be8f8553e610c616b0d | Xenocide007/Python-Projects | /3.py | 1,009 | 4.1875 | 4 | #3 in a row
import random
names = []
gameBoard = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]]
def inputNames():
name1 = raw_input("Enter first player's name here: \t")
name2 = raw_input("Enter second player's name here: \t")
return name1, name2
def first(name1, name2):
num1 = int(raw_input("%s, guess a numb... | true |
4dfb1a39f65da88252968ef388cb29817dcc14ee | gabrielSSimoura/ReverseWordOrder | /main.py | 556 | 4.40625 | 4 | # Write a program (using functions!) that asks the user for a long string containing multiple words.
# Print back to the user the same string, except with the words in backwards order.
# For example, say I type the string:
# My name is Gabriel
# Then I would see the string:
# Gabriel is name My
# shown back to me... | true |
e9bc436baa593405e732b1cb59db5d72945be174 | chanyoonzhu/leetcode-python | /708-Insert_into_a_Sorted_Circular_Linked_List.py | 1,215 | 4.125 | 4 | """
# Definition for a Node.
class Node:
def __init__(self, val=None, next=None):
self.val = val
self.next = next
"""
"""
- two pointers
- O(n), O(1)
"""
class Solution:
def insert(self, head: 'Optional[Node]', insertVal: int) -> 'Node':
if not head:
node = Node(insertVal)
... | true |
f9e731280039de962fbd886d3603f04ee5a2bff1 | chanyoonzhu/leetcode-python | /319-Bulb_Switcher.py | 418 | 4.21875 | 4 | """
- Math logic
- intuition: light bulbs that are left on are switched odd number of times. Divisors come in pairs 12 = 2 * 6 = 3 * 4, only exception is when n is a square number like 16 = 4 * 4 (one single divisor).
So only square numbers will be on at the end. Find all square numbers equal to or less than n.
- O... | true |
96fcc3eecfd5be51af858e83e8dd064ff390a2d5 | AidanH6/PythonBeginnerProjects | /higherlower.py | 990 | 4.46875 | 4 | """
Create a simple game where the computer randomly selects a number between 1 and 100 and the user has to guess what the number is.
After every guess, the computer should tell the user if the guess is higher or lower than the answer.
When the user guesses the correct number, print out a congratulatory message.
""... | true |
ca82fd8d846dcc3e569e0440c21a3e49ff9b35e6 | lgope/python-world | /crash-course-on-python/week-4/video_exercise_dictionary.py | 1,474 | 4.375 | 4 | # The "toc" dictionary represents the table of contents for a book. Fill in the blanks to do the following: 1) Add an entry for Epilogue on page 39. 2) Change the page number for Chapter 3 to 24. 3) Display the new dictionary contents. 4) Display True if there is Chapter 5, False if there isn't.
toc = {"Introduction":... | true |
0dcd9fb38728ea5f8cf73c0650a4a0090d364781 | ardus-uk/consequences | /p2.py | 2,029 | 4.4375 | 4 | #!/usr/bin/python
""" Some examples of using lists """
# Author: Peter Normington
# Last revision: 2013-11-18
example_number = 0
# The following is used to divide the sections of output
print "--------------------------------------------\n"
with open('./datafiles/Consequences', 'r') as f:
# f is a file handle.
# ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.